Commit d3f49ded authored by Leigh Stoller's avatar Leigh Stoller

Minor fixes to prevent conflicting tunnel unit numbers.

parent 20484818
......@@ -3480,12 +3480,29 @@ sub GetExperiment($) { return $_[0]->{'EXPT'}; }
sub Create($$$$$;$$)
{
my ($class, $experiment, $vname, $secretkey, $style, $mask, $port) = @_;
my $exptidx = $experiment->idx();
# The new lan has the 'ready' bit set to zero.
my $lan = Lan->Create($experiment, $vname, "tunnel");
return undef
if (!defined($lan));
#
# We need an index to use for a unit number. Just look to see
# how many tunnels
#
my $query_result =
DBQueryWarn("select count(*) from lans ".
"where exptidx='$exptidx' and type='tunnel'");
if (!$query_result || !$query_result->numrows) {
$lan->Destroy();
return undef;
}
my ($tunnel_number) = $query_result->fetchrow_array();
if ($lan->SetAttribute("tunnel_number", $tunnel_number) != 0) {
$lan->Destroy();
return undef;
}
# Set the secret key for the tunnel.
if ($lan->SetAttribute("secretkey", $secretkey) != 0) {
$lan->Destroy();
......
......@@ -1625,6 +1625,13 @@ sub Create($$$$$$)
my $manager1;
my $manager2;
my $testing = 0;
my $tunnel_number;
# The tunnel number is how we generate the unit number.
if ($tunnel->GetAttribute("tunnel_number", \$tunnel_number) != 0) {
print STDERR "Could not get tunnel_number for $tunnel\n";
goto bad;
}
# We need the control network addresses, but it is possible that
# one of the nodes is not on this testbed.
......@@ -1761,7 +1768,7 @@ sub Create($$$$$$)
if (defined($manager2));
$member1->SetAttribute("tunnel_ipmask", "255.255.255.0");
$member1->SetAttribute("tunnel_lan", $linkname);
$member1->SetAttribute("tunnel_unit", $member1->memberid() + 1);
$member1->SetAttribute("tunnel_unit", $tunnel_number + 1);
$member1->SetAttribute("tunnel_style", "gre");
$member1->SetAttribute("tunnel_peerid", $virtid2);
......@@ -1790,7 +1797,7 @@ sub Create($$$$$$)
if (defined($manager1));
$member2->SetAttribute("tunnel_ipmask", "255.255.255.0");
$member2->SetAttribute("tunnel_lan", $linkname);
$member2->SetAttribute("tunnel_unit", $member2->memberid() + 1);
$member2->SetAttribute("tunnel_unit", $tunnel_number + 1);
$member2->SetAttribute("tunnel_style", "gre");
$member2->SetAttribute("tunnel_peerid", $virtid1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment