Commit 2c74c7fd authored by Mike Hibler's avatar Mike Hibler
Browse files

Change to pass VLAN tag for all veths via tmcd rather than computing it

(incorrectly) on the node itself.

This version computes the ID in tmcd itself, the next commit of tmcd.c
will use the DB table that Leigh added.
parent 86fb275c
......@@ -175,6 +175,7 @@ sub doboot()
my $iface = $ifconfig->{IFACE};
my $ifrtabid = undef;
my $encap = $ifconfig->{ENCAP};
my $vtag = $ifconfig->{VTAG};
#
# A bit of history.
......@@ -199,7 +200,7 @@ sub doboot()
my ($upline, $downline) =
os_ifconfig_veth($iface, $inet, $mask, $id, $vmac,
$ifrtabid, $encap);
$ifrtabid, $encap, $vtag);
$upcmds .= "$upline\n ";
$upcmds .= TMROUTECONFIG . " $inet up\n ";
......
......@@ -47,7 +47,7 @@ use POSIX qw(strftime);
#
# BE SURE TO BUMP THIS AS INCOMPATIBILE CHANGES TO TMCD ARE MADE!
#
sub TMCD_VERSION() { 19; };
sub TMCD_VERSION() { 20; };
libtmcc::configtmcc("version", TMCD_VERSION());
# Control tmcc timeout.
......@@ -479,7 +479,7 @@ sub getifconfig($)
my $vethpat = q(INTERFACE IFACETYPE=(\w*) INET=([0-9.]*) MASK=([0-9.]*) );
$vethpat .= q(ID=(\d*) VMAC=(\w*) PMAC=(\w*) RTABID=(\d*) );
$vethpat .= q(ENCAPSULATE=(\d*) LAN=([-\w\(\)]*));
$vethpat .= q(ENCAPSULATE=(\d*) LAN=([-\w\(\)]*) VTAG=(\d*));
my $setpat = q(INTERFACE_SETTING MAC=(\w*) );
$setpat .= q(KEY='([-\w\.\:]*)' VAL='([-\w\.\:]*)');
......@@ -546,6 +546,7 @@ sub getifconfig($)
my $rtabid = $7;
my $encap = $8;
my $lan = $9;
my $vtag = $10;
#
# Inside a jail, the vmac is really the pmac. That is, when the
......@@ -585,6 +586,7 @@ sub getifconfig($)
$ifconfig->{"RTABID"} = $rtabid;
$ifconfig->{"ENCAP"} = $encap;
$ifconfig->{"LAN"} = $lan;
$ifconfig->{"VTAG"} = $vtag;
push(@ifacelist, $ifconfig);
}
else {
......
......@@ -25,4 +25,4 @@
* NB: See ron/libsetup.pm. That is version 4! I'll merge that in.
*/
#define DEFAULT_VERSION 2
#define CURRENT_VERSION 19
#define CURRENT_VERSION 20
......@@ -189,9 +189,9 @@ sub os_ifconfig_line($$$$$$$;$$)
#
# Specialized function for configing locally hacked veth devices.
#
sub os_ifconfig_veth($$$$$;$$)
sub os_ifconfig_veth($$$$$;$$$)
{
my ($iface, $inet, $mask, $id, $vmac, $rtabid, $encap) = @_;
my ($iface, $inet, $mask, $id, $vmac, $rtabid, $encap, $vtag) = @_;
my ($uplines, $downlines);
#
......@@ -203,8 +203,10 @@ sub os_ifconfig_veth($$$$$;$$)
require Socket;
import Socket;
# Need to derive a vlan tag. Just use the middle two octets.
my $vtag = (unpack("I", inet_aton($inet)) >> 8) & 0xffff;
if (!defined($vtag)) {
# Need to derive a vlan tag. Just use the middle two octets.
my $vtag = (unpack("I", inet_aton($inet)) >> 8) & 0xffff;
}
if ($vmac =~ /^(\w{2})(\w{2})(\w{2})(\w{2})(\w{2})(\w{2})$/) {
$vmac = "$1:$2:$3:$4:$5:$6";
......
......@@ -1428,6 +1428,7 @@ COMMAND_PROTOTYPE(doifconfig)
}
while (nrows) {
char *bufp = buf;
char *mask;
row = mysql_fetch_row(res);
if (vers >= 16) {
......@@ -1439,10 +1440,11 @@ COMMAND_PROTOTYPE(doifconfig)
* no underlying phys interface (say, colocated nodes in a
* link).
*/
mask = CHECKMASK(row[4]);
bufp += OUTPUT(bufp, ebufp - bufp,
"IFACETYPE=veth "
"INET=%s MASK=%s ID=%s VMAC=%s PMAC=%s",
row[1], CHECKMASK(row[4]), row[0], row[2],
row[1], mask, row[0], row[2],
row[3] ? row[3] : "none");
if (vers >= 14) {
......@@ -1457,6 +1459,25 @@ COMMAND_PROTOTYPE(doifconfig)
if (vers >= 17) {
bufp += OUTPUT(bufp, ebufp - bufp, " LAN=%s", row[6]);
}
/*
* Return a VLAN tag.
* XXX right now we compute this from the subnet.
*/
if (vers >= 20) {
unsigned short vtag;
struct in_addr tip, tmask;
in_addr_t addr;
int bits;
inet_aton(row[1], &tip);
inet_aton(mask, &tmask);
addr = ntohl(tmask.s_addr);
for (bits = 0; (addr & (1 << bits)) == 0; bits++)
;
vtag = (ntohl(tip.s_addr) >> bits) & 0xFFFF;
bufp += OUTPUT(bufp, ebufp - bufp, " VTAG=%d", vtag);
}
OUTPUT(bufp, ebufp - bufp, "\n");
client_writeback(sock, buf, strlen(buf), tcp);
......
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