All new accounts created on Gitlab now require administrator approval. If you invite any collaborators, please let Flux staff know so they can approve the accounts.

Commit d24b6598 authored by Leigh B. Stoller's avatar Leigh B. Stoller

Version 18 change; Return ifconfig info, including speed and duplex,

for physical interfaces underlying veth interfaces; The interfaces are
configured as part of regular ifconfig, rather then as a hack in veth
configuration.

Most of the info return is left blank, especially INET (ip address)
which indicates the special handling.
parent 2ae69a98
......@@ -19,7 +19,7 @@ use Exporter;
check_nickname bootsetup startcmdstatus whatsmynickname
TBBackGround TBForkCmd vnodejailsetup plabsetup vnodeplabsetup
jailsetup dojailconfig findiface libsetup_getvnodeid
ixpsetup libsetup_refresh
ixpsetup libsetup_refresh gettopomap
TBDebugTimeStamp TBDebugTimeStampsOn
......@@ -28,7 +28,7 @@ use Exporter;
CONFDIR TMDELAY TMJAILNAME TMSIMRC TMCC
TMNICKNAME TMSTARTUPCMD FINDIF
TMROUTECONFIG TMLINKDELAY TMDELMAP
TMROUTECONFIG TMLINKDELAY TMDELMAP TMTOPOMAP
TMGATEDCONFIG TMSYNCSERVER TMKEYHASH TMNODEID TMEVENTKEY
);
......@@ -47,7 +47,7 @@ use POSIX qw(strftime);
#
# BE SURE TO BUMP THIS AS INCOMPATIBILE CHANGES TO TMCD ARE MADE!
#
sub TMCD_VERSION() { 17; };
sub TMCD_VERSION() { 18; };
libtmcc::configtmcc("version", TMCD_VERSION());
# Control tmcc timeout.
......@@ -214,6 +214,7 @@ sub TMEVENTKEY() { CONFDIR() . "/eventkey";}
sub TMNODEID() { CONFDIR() . "/nodeid";}
sub TMROLE() { CONFDIR() . "/role";}
sub TMSIMRC() { CONFDIR() . "/rc.simulator";}
sub TMTOPOMAP() { CONFDIR() . "/topomap";}
#
# This is a debugging thing for my home network.
......@@ -591,6 +592,53 @@ sub getifconfig($)
return 0;
}
#
# Read the topomap and return something.
#
sub gettopomap($)
{
my ($rptr) = @_; # Return array to caller (reference).
my $topomap = {};
my $section;
my @slots;
if (! -e TMTOPOMAP()) {
$rptr = {};
return 0;
}
if (!open(TOPO, TMTOPOMAP())) {
warn("*** WARNING: ".
"gettopomap: Could not open " . TMTOPOMAP() . "!\n");
@$rptr = ();
return -1;
}
#
# First line of topo map describes the nodes.
#
while (<TOPO>) {
if ($_ =~ /^\#\s*([-\w]*): ([-\w,]*)$/) {
$section = $1;
@slots = split(",", $2);
$topomap->{$section} = [];
next;
}
chomp($_);
my @values = split(",", $_);
my $rowref = {};
for (my $i = 0; $i < scalar(@values); $i++) {
$rowref->{$slots[$i]} = $values[$i];
}
push(@{ $topomap->{$section} }, $rowref);
}
close(TOPO);
$$rptr = $topomap;
return 0;
}
#
# Convert from MAC to iface name (eth0/fxp0/etc) using little helper program.
#
......@@ -645,50 +693,6 @@ sub getrouterconfig($$)
return 0;
}
#
# Special case. If the routertype is "static-ddijk" then we run our
# dijkstra program on the linkmap, and use that to feed the code
# below (it outputs exactly the same goo).
#
# XXX: If we change the return from tmcd, the output of dijkstra will
# suddenly be wrong. Yuck, need a better solution.
#
if ($type eq "static-ddijk") {
#
# We get the linkmap from the proj directory.
#
my ($pid, $eid, $vname) = check_nickname();
my $linkmap = "/proj/$pid/exp/$eid/tbdata/linkmap";
if (! -e $linkmap) {
warn("*** WARNING: $linkmap does exist!\n");
@$rptr = ();
$$ptype = undef;
return -1;
}
if (!open(DIJK, "cat $linkmap | $BINDIR/dijkstra $vname |")) {
warn("*** WARNING: Could not invoke dijkstra on linkmap!\n");
@$rptr = ();
$$ptype = undef;
return -1;
}
while (<DIJK>) {
push(@tmccresults, $_);
}
if (! close(DIJK)) {
if ($?) {
warn("*** WARNING: dijkstra exited with status $?!\n");
}
else {
warn("*** WARNING: Error closing dijkstra pipe: $!\n");
}
@$rptr = ();
$$ptype = undef;
return -1;
}
}
#
# ROUTERTYPE=manual
# ROUTE DEST=192.168.2.3 DESTTYPE=host DESTMASK=255.255.255.0 \
......@@ -925,7 +929,7 @@ sub bootsetup()
# be expensive.
#
dorole();
return ($pid, $eid, $vname);
}
......
......@@ -1253,6 +1253,47 @@ COMMAND_PROTOTYPE(doifconfig)
if (vers < 10)
return 0;
/*
* First, return config info the physical interfaces so those can be
* set up. We do this just for the physical node; no need to send it
* back every single time!
*/
if (vers >= 18 && !reqp->isvnode) {
res = mydb_query("select distinct "
" i.interface_type,i.mac, "
" i.current_speed,i.duplex "
" from veth_interfaces as v "
"left join interfaces as i on "
" i.node_id=v.node_id and i.iface=v.iface "
"where v.iface is not null and v.node_id='%s'",
4, reqp->pnodeid);
if (!res) {
error("IFCONFIG: %s: "
"DB Error getting interfaces underlying veths!\n",
reqp->nodeid);
return 1;
}
nrows = (int)mysql_num_rows(res);
while (nrows) {
char *bufp = buf;
row = mysql_fetch_row(res);
bufp += OUTPUT(bufp, ebufp - bufp,
"INTERFACE IFACETYPE=%s "
"INET= MASK= MAC=%s "
"SPEED=%sMbps DUPLEX=%s "
"IPALIASES=\"\" IFACE= "
"RTABID= LAN=\n",
row[0], row[1], row[2], row[3]);
client_writeback(sock, buf, strlen(buf), tcp);
if (verbose)
info("IFCONFIG: %s", buf);
nrows--;
}
mysql_free_result(res);
}
/*
* Outside a vnode, return only those veths that have vnode=NULL,
* which indicates its an emulated interface on a physical node. When
......
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