Commit 33beb373 authored by Mike Hibler's avatar Mike Hibler

Initial steps to enable jumbo frames on experiment interfaces.

This is just mods to the tmcd "ifconfig" command to include an MTU= arg.
Right now we don't have anything in the DB for MTU, so tmcd is just returning
"MTU=" which says to not explicitly set the MTU.

It also includes the basic client-side support which I have tested on a
physical interface with MTU=1500. Further changes will be needed to DTRT
on virtual interfaces and their physical carrier interface.

But the hope is to get the client-side part nailed down before the next
set of images are rolled, so that we will be ready when support for the
front-side (UI and DB state) get added.
parent b1110139
/*
* Copyright (c) 2000-2018 University of Utah and the Flux Group.
* Copyright (c) 2000-2019 University of Utah and the Flux Group.
*
* {{{EMULAB-LICENSE
*
......@@ -46,4 +46,4 @@
* it in clientside/tmcc/common/libsetup.pm!
*/
#define DEFAULT_VERSION 2
#define CURRENT_VERSION 43
#define CURRENT_VERSION 44
#!/usr/bin/perl -w
#
# Copyright (c) 2004-2010, 2016 University of Utah and the Flux Group.
# Copyright (c) 2004-2019 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -214,6 +214,7 @@ sub doboot()
my $iface = $ifconfig->{IFACE};
my $settings = $ifconfig->{SETTINGS};
my $lan = $ifconfig->{LAN};
my $mtu = $ifconfig->{MTU};
my $ifrtabid = undef;
#
......@@ -244,7 +245,7 @@ sub doboot()
my ($upline, $downline) =
&os_ifconfig_line($iface, $inet, $mask,
$speed, $duplex, $aliases,
$type, $lan, $settings,
$type, $lan, $mtu, $settings,
$ifrtabid, \%oscookie);
if (defined($upline) && $upline) {
......@@ -286,12 +287,13 @@ sub doboot()
my $iface = $ifconfig->{IFACE};
my $settings = $ifconfig->{SETTINGS};
my $lan = $ifconfig->{LAN};
my $mtu = $ifconfig->{MTU};
my $ifrtabid = undef;
my ($upline, $downline) =
&os_ifconfig_line($iface, $inet, $mask,
$speed, $duplex, $aliases,
$type, $lan, $settings,
$type, $lan, $mtu, $settings,
$ifrtabid, \%oscookie);
if (defined($upline) && $upline) {
......
#!/usr/bin/perl -w
#
# Copyright (c) 2000-2018 University of Utah and the Flux Group.
# Copyright (c) 2000-2019 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -85,7 +85,7 @@ use librc;
# IMPORTANT NOTE: if you change the version here, you must also change it
# in clientside/lib/tmcd/tmcd.h!
#
sub TMCD_VERSION() { 42; };
sub TMCD_VERSION() { 44; };
libtmcc::configtmcc("version", TMCD_VERSION());
# Control tmcc timeout.
......@@ -1363,11 +1363,11 @@ sub getifconfig($;$)
my $ethpat = q(INTERFACE IFACETYPE=(\w*) INET=([0-9.]*) MASK=([0-9.]*) );
$ethpat .= q(MAC=(\w*) SPEED=(\w*) DUPLEX=(\w*) );
$ethpat .= q(IFACE=(\w*) RTABID=(\d*) LAN=([-\w\(\)]*));
$ethpat .= q(IFACE=(\w*) RTABID=(\d*) LAN=([-\w\(\)]*) MTU=(\d*));
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\(\)]*) VTAG=(\d*));
$vethpat .= q(ENCAPSULATE=(\d*) LAN=([-\w\(\)]*) VTAG=(\d*) MTU=(\d*));
my $setpat = q(INTERFACE_SETTING MAC=(\w*) );
$setpat .= q(KEY='([-\w\.\:]*)' VAL='([-\w\.\:]*)');
......@@ -1403,6 +1403,7 @@ sub getifconfig($;$)
my $iface = $7;
my $rtabid = $8;
my $lan = $9;
my $mtu = $10;
#
# XXX GNU Radio hack
......@@ -1438,6 +1439,7 @@ sub getifconfig($;$)
$ifconfig->{"VIFACE"} = $iface;
$ifconfig->{"RTABID"} = $rtabid;
$ifconfig->{"LAN"} = $lan;
$ifconfig->{"MTU"} = $mtu;
$ifconfig->{"SETTINGS"} = {};
push(@ifacelist, $ifconfig);
$ifacehash{$mac} = $ifconfig;
......@@ -1454,6 +1456,7 @@ sub getifconfig($;$)
my $encap = $8;
my $lan = $9;
my $vtag = $10;
my $mtu = $11;
#
# Inside a jail, the vmac is really the pmac. That is, when the
......@@ -1511,6 +1514,7 @@ sub getifconfig($;$)
$ifconfig->{"ENCAP"} = $encap;
$ifconfig->{"LAN"} = $lan;
$ifconfig->{"VTAG"} = $vtag;
$ifconfig->{"MTU"} = $mtu;
# determine the OS-specific virtual device name
$ifconfig->{"VIFACE"} = os_viface_name($ifconfig);
......@@ -1570,6 +1574,7 @@ sub getifconfig($;$)
$pif->{"IFACE"} = $ifconfig->{"IFACE"};
$pif->{"RTABID"} = $ifconfig->{"RTABID"};
$pif->{"LAN"} = $ifconfig->{"LAN"};
$pif->{"MTU"} = $ifconfig->{"MTU"};
$pif->{"FROMVMAC"} = $ifconfig->{"VMAC"};
print STDERR "NOTE: remapping ", $ifconfig->{"VIFACE"},
" to ", $ifconfig->{"IFACE"}, "\n";
......
#!/usr/bin/perl -wT
#
# Copyright (c) 2000-2018 University of Utah and the Flux Group.
# Copyright (c) 2000-2019 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -102,7 +102,7 @@ my $GROUPDEL = "/usr/sbin/pw groupdel";
my $CHPASS = "/usr/bin/chpass -p";
my $MKDB = "/usr/sbin/pwd_mkdb -p";
my $IFCONFIGBIN = "/sbin/ifconfig";
my $IFCONFIG = "$IFCONFIGBIN %s inet %s netmask %s %s %s";
my $IFCONFIG = "$IFCONFIGBIN %s inet %s netmask %s %s %s %s";
my $IFALIAS = "$IFCONFIGBIN %s alias %s netmask %s";
my $IFC_1000MBS = "media 1000baseTX";
my $IFC_100MBS = "media 100baseTX";
......@@ -111,6 +111,8 @@ my $IFC_AUTO = "";
my $IFC_FDUPLEX = "mediaopt full-duplex";
my $IFC_HDUPLEX = "mediaopt half-duplex";
my $IFC_ADUPLEX = "";
my $IFC_1500MTU = "mtu 1500";
my $IFC_9000MTU = "mtu 9000";
my $MKDIR = "/bin/mkdir";
my $GATED = "/usr/local/sbin/gated";
my $ROUTE = "/sbin/route";
......@@ -154,12 +156,13 @@ sub os_account_cleanup($)
# Generate and return an ifconfig line that is approriate for putting
# into a shell script (invoked at bootup).
#
sub os_ifconfig_line($$$$$$$$;$$%)
sub os_ifconfig_line($$$$$$$$;$$$%)
{
my ($iface, $inet, $mask, $speed, $duplex, $aliases, $iface_type, $lan,
$settings, $rtabid, $cookie) = @_;
$mtu, $settings, $rtabid, $cookie) = @_;
my $media = "";
my $mediaopt = "";
my $mtuopt = "";
my ($uplines, $downlines);
#
......@@ -220,12 +223,24 @@ sub os_ifconfig_line($$$$$$$$;$$%)
$mediaopt = $IFC_FDUPLEX;
}
}
#
# XXX only recognize 1500 and 9000 for MTUs.
# Anything else results in the default (no explicit setting).
#
if (defined($mtu)) {
if ($mtu eq "1500") {
$mtuopt = $IFC_1500MTU;
} elsif ($mtu eq "9000") {
$mtuopt = $IFC_9000MTU;
}
}
}
$uplines = "";
if ($inet eq "") {
$uplines .= "$IFCONFIGBIN $iface up $media $mediaopt";
$uplines .= "$IFCONFIGBIN $iface up $media $mediaopt $mtuopt";
}
else {
#
......@@ -238,7 +253,7 @@ sub os_ifconfig_line($$$$$$$$;$$%)
# Config the interface.
$uplines .= sprintf($IFCONFIG, $iface, $inet, $mask,
$media, $mediaopt);
$media, $mediaopt, $mtuopt);
# An interface underlying virtual interfaces does not go down.
$downlines = "$IFCONFIGBIN $iface down"
if (defined($lan) && $lan ne "");
......
#!/usr/bin/perl -wT
#
# Copyright (c) 2000-2018 University of Utah and the Flux Group.
# Copyright (c) 2000-2019 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -115,7 +115,7 @@ my $GROUPADD = "/usr/sbin/groupadd";
my $GROUPDEL = "/usr/sbin/groupdel";
my $IPBIN = "/sbin/ip";
my $IFCONFIGBIN = "/sbin/ifconfig";
my $IFCONFIG = "$IFCONFIGBIN %s inet %s netmask %s";
my $IFCONFIG = "$IFCONFIGBIN %s inet %s netmask %s %s";
my $VLANCONFIG = "/sbin/vconfig";
# XXX 10000 is probably not right, but we don't use mii-tool here
my $IFC_10000MBS = "10000baseTx";
......@@ -125,6 +125,8 @@ my $IFC_10MBS = "10baseT";
my $IFC_FDUPLEX = "FD";
my $IFC_HDUPLEX = "HD";
my $IFC_AUTO = "$IFC_1000MBS,$IFC_100MBS,$IFC_10MBS";
my $IFC_1500MTU = "mtu 1500";
my $IFC_9000MTU = "mtu 9000";
my @LOCKFILES = ("/etc/group.lock", "/etc/gshadow.lock");
my $MKDIR = "/bin/mkdir";
my $GATED = "/usr/sbin/gated";
......@@ -409,11 +411,11 @@ sub os_account_cleanup($)
# Generate and return an ifconfig line that is approriate for putting
# into a shell script (invoked at bootup).
#
sub os_ifconfig_line($$$$$$$$;$$$)
sub os_ifconfig_line($$$$$$$$;$$$%)
{
my ($iface, $inet, $mask, $speed, $duplex, $aliases, $iface_type, $lan,
$settings, $rtabid, $cookie) = @_;
my ($miirest, $miisleep, $miisetspd, $media);
$mtu, $settings, $rtabid, $cookie) = @_;
my ($miirest, $miisleep, $miisetspd, $media, $mtuopt);
my ($uplines, $downlines);
#
......@@ -650,6 +652,7 @@ sub os_ifconfig_line($$$$$$$$;$$$)
# mean anything. We need this for virtnodes whose networks must be
# config'd from inside the container, vm, whatever.
#
$mtuopt = "";
if ($iface_type ne 'veth') {
#
# Need to check units on the speed. Just in case.
......@@ -772,13 +775,25 @@ sub os_ifconfig_line($$$$$$$$;$$$)
} else {
$uplines = "/sbin/mii-tool --force=$media $iface\n ";
}
#
# XXX only recognize 1500 and 9000 for MTUs.
# Anything else results in the default (no explicit setting).
#
if (defined($mtu)) {
if ($mtu eq "1500") {
$mtuopt = $IFC_1500MTU;
} elsif ($mtu eq "9000") {
$mtuopt = $IFC_9000MTU;
}
}
}
if ($inet eq "") {
$uplines .= "$IFCONFIGBIN $iface up";
$uplines .= "$IFCONFIGBIN $iface up $mtuopt";
}
else {
$uplines .= sprintf($IFCONFIG, $iface, $inet, $mask);
$uplines .= sprintf($IFCONFIG, $iface, $inet, $mask, $mtuopt);
$downlines = "$IFCONFIGBIN $iface down";
}
......
......@@ -2126,6 +2126,7 @@ COMMAND_PROTOTYPE(doifconfig)
char *speed = "100";
char *unit = "Mbps";
char *duplex = "full";
char *mtu = "";
char *bufp = buf;
char *mask;
......@@ -2149,6 +2150,13 @@ COMMAND_PROTOTYPE(doifconfig)
if (row[4] && row[4][0])
duplex = row[4];
/*
* XXX MTU should come out of DB.
* "9000" if using jumbo frames,
* "1500" if not,
* "" if not specified in DB (use client default)
*/
/*
* We now use the MAC to determine the interface, but
* older images still want that tag at the front.
......@@ -2221,6 +2229,10 @@ COMMAND_PROTOTYPE(doifconfig)
bufp += OUTPUT(bufp, ebufp - bufp,
" LAN=%s", lan);
}
if (vers >= 44) {
bufp += OUTPUT(bufp, ebufp - bufp,
" MTU=%s", mtu);
}
OUTPUT(bufp, ebufp - bufp, "\n");
client_writeback(sock, buf, strlen(buf), tcp);
......@@ -2244,10 +2256,13 @@ COMMAND_PROTOTYPE(doifconfig)
" where attrkey like 'shared_lan_%%' and "
" node_id='%s'", 2, reqp->nodeid);
if (res) {
char _ip[16], _mask[16], _mac[18], _speed[8];
char _ip[16], _mask[16], _mac[18], _speed[8], _mtu[6];
char *bufp = buf;
int got = 0;
/* XXX optional */
strcpy(_mtu, "");
nrows = (int)mysql_num_rows(res);
while (nrows > 0) {
nrows--;
......@@ -2270,6 +2285,9 @@ COMMAND_PROTOTYPE(doifconfig)
strncpy(_speed, row[1], sizeof(_speed)-1);
_speed[sizeof(_speed)-1] = '\0';
got++;
} else if (strcmp(row[0], "shared_lan_mtu") == 0) {
strncpy(_mtu, row[1], sizeof(_mtu)-1);
_mtu[sizeof(_mtu)-1] = '\0';
}
}
if (got == 4) {
......@@ -2277,8 +2295,13 @@ COMMAND_PROTOTYPE(doifconfig)
"INTERFACE IFACETYPE=ixgbe "
"INET=%s MASK=%s MAC=%s "
"SPEED=%sMbps DUPLEX=full "
"IFACE= RTABID=0 LAN=shared_lan_0\n",
"IFACE= RTABID=0 LAN=shared_lan_0",
_ip, _mask, _mac, _speed);
if (vers >= 44) {
bufp += OUTPUT(bufp, ebufp - bufp,
" MTU=%s", _mtu);
}
OUTPUT(bufp, ebufp - bufp, "\n");
client_writeback(sock, buf, strlen(buf), tcp);
if (verbose)
info("%s: IFCONFIG: %s", reqp->nodeid, buf);
......@@ -2338,6 +2361,7 @@ COMMAND_PROTOTYPE(doifconfig)
*/
if (vers >= 18 && !reqp->isvnode) {
char *aliasstr;
char *mtu = "";
res = mydb_query("select i.interface_type,i.mac, "
" i.current_speed,i.duplex "
......@@ -2369,10 +2393,22 @@ COMMAND_PROTOTYPE(doifconfig)
"INTERFACE IFACETYPE=%s "
"INET= MASK= MAC=%s "
"SPEED=%sMbps DUPLEX=%s "
"%sIFACE= RTABID= LAN=\n",
"%sIFACE= RTABID= LAN=",
row[0], row[1], row[2], row[3],
aliasstr);
/*
* XXX MTU should come out of DB.
* "9000" if using jumbo frames,
* "1500" if not,
* "" if not specified in DB (use client default)
*/
if (vers >= 44) {
bufp += OUTPUT(bufp, ebufp - bufp,
" MTU=%s", mtu);
}
OUTPUT(bufp, ebufp - bufp, "\n");
client_writeback(sock, buf, strlen(buf), tcp);
if (verbose)
info("%s: IFCONFIG: %s", reqp->nodeid, buf);
......@@ -2426,6 +2462,7 @@ COMMAND_PROTOTYPE(doifconfig)
while (nrows) {
char *bufp = buf;
char *ifacetype;
char *mtu = "";
int isveth, doencap;
row = mysql_fetch_row(res);
......@@ -2449,9 +2486,21 @@ COMMAND_PROTOTYPE(doifconfig)
"INTERFACE IFACETYPE=any "
"INET=%s MASK=%s MAC=%s "
"SPEED=100Mbps DUPLEX=full "
"IFACE= RTABID= LAN=%s\n",
"IFACE= RTABID= LAN=%s",
row[1], row[4], row[2], row[7]);
/*
* XXX MTU should come out of DB.
* "9000" if using jumbo frames,
* "1500" if not,
* "" if not specified in DB (use client default)
*/
if (vers >= 44) {
bufp += OUTPUT(bufp, ebufp - bufp,
" MTU=%s", mtu);
}
OUTPUT(bufp, ebufp - bufp, "\n");
client_writeback(sock, buf, strlen(buf), tcp);
if (verbose)
info("%s: IFCONFIG: %s", reqp->nodeid, buf);
......@@ -2543,6 +2592,17 @@ COMMAND_PROTOTYPE(doifconfig)
}
bufp += OUTPUT(bufp, ebufp - bufp, " VTAG=%s", tag);
/*
* XXX MTU should come out of DB.
* "9000" if using jumbo frames,
* "1500" if not,
* "" if not specified in DB (use client default)
*/
if (vers >= 44) {
bufp += OUTPUT(bufp, ebufp - bufp,
" MTU=%s", mtu);
}
}
OUTPUT(bufp, ebufp - bufp, "\n");
client_writeback(sock, buf, strlen(buf), tcp);
......@@ -2571,6 +2631,7 @@ COMMAND_PROTOTYPE(doifconfig)
while (nrows) {
char *bufp = buf;
char *ip = "", *ipmask = "", *mac = "", *lan = "";
char *mtu = "";
row = mysql_fetch_row(res);
nrows--;
......@@ -2605,15 +2666,24 @@ COMMAND_PROTOTYPE(doifconfig)
else if (!strcmp(row2[0], "tunnel_lan")) {
lan = row2[1];
}
else if (!strcmp(row2[0], "tunnel_mtu")) {
mtu = row2[1];
}
}
bufp = buf;
bufp += OUTPUT(bufp, ebufp - bufp,
"INTERFACE IFACETYPE=gre "
"INET=%s MASK=%s MAC=%s "
"SPEED=100Mbps DUPLEX=full "
"IFACE= RTABID= LAN=%s\n",
"IFACE= RTABID= LAN=%s",
ip, ipmask, mac, lan);
if (vers >= 44) {
bufp += OUTPUT(bufp, ebufp - bufp,
" MTU=%s", mtu);
}
OUTPUT(bufp, ebufp - bufp, "\n");
client_writeback(sock, buf, strlen(buf), tcp);
if (verbose)
info("%s: IFCONFIG: %s", reqp->nodeid, buf);
......@@ -2651,17 +2721,26 @@ COMMAND_PROTOTYPE(doifconfig)
nrows = (int)mysql_num_rows(res);
while (nrows > 0) {
char *bufp = buf;
nrows--;
row = mysql_fetch_row(res);
if (!row || !row[0] || !row[1] || !row[2] ||
!row[3] || !row[4])
continue;
OUTPUT(buf, sizeof(buf),
"INTERFACE IFACETYPE=alias "
"INET=%s MASK=%s ID=%s VMAC=%s PMAC=none "
"RTABID= ENCAPSULATE=0 LAN=%s VTAG=\n",
row[0], CHECKMASK(row[1]), row[2], row[3],
row[4]);
bufp += OUTPUT(bufp, ebufp - bufp,
"INTERFACE IFACETYPE=alias "
"INET=%s MASK=%s ID=%s VMAC=%s PMAC=none "
"RTABID= ENCAPSULATE=0 LAN=%s VTAG=",
row[0], CHECKMASK(row[1]), row[2],
row[3], row[4]);
/* XXX expected */
if (vers >= 44) {
bufp += OUTPUT(bufp, ebufp - bufp, " MTU=");
}
OUTPUT(bufp, ebufp - bufp, "\n");
client_writeback(sock, buf, strlen(buf), tcp);
if (verbose)
info("%s: IFCONFIG: %s", reqp->nodeid, buf);
......
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