Commit 62ecac78 authored by Shashi Guruprasad's avatar Shashi Guruprasad

Links between real PCs and jail virtnodes now use non veth interfaces. This

allows real PCs to run any OS instead of being constrained to FreeBSD. A
detailed discussion on this topic can be found in the testbed-dev mailing
list under the thread "links between vnodes and real PCs"
parent a1e98678
......@@ -239,13 +239,13 @@ foreach my $n (@freed_nodes) {
# Clean up interfaces by clearing IPs and/or aliases.
if (! ($n =~ /sh\d+/)) {
# Its not a shark, so clean out all IPs except the control net.
DBQueryWarn("update interfaces set IP='',IPaliases=NULL,mask=NULL " .
DBQueryWarn("update interfaces set IP='',IPaliases=NULL,mask=NULL,rtabid='0',vnode_id=NULL " .
"where node_id='$n' and ".
" role='" . TBDB_IFACEROLE_EXPERIMENT() . "'")
|| $error++;
} else {
# XXX Shark Hack!
DBQueryWarn("update interfaces set IPalias='' ".
DBQueryWarn("update interfaces set IPalias='',rtabid='0',vnode_id=NULL ".
"where node_id='$n'") || $error++;
}
......
......@@ -1190,7 +1190,7 @@ if ($updating && !$impotent) {
if (physnodeisvirtnode($pnode) ||
physnodereuse($pnode) eq "unused");
DBQueryFatal("update interfaces set IP='',IPaliases=NULL,mask=NULL " .
DBQueryFatal("update interfaces set IP='',IPaliases=NULL,mask=NULL,rtabid='0',vnode_id=NULL " .
"where node_id='$pnode' and ".
" role='" . TBDB_IFACEROLE_EXPERIMENT() . "'");
......@@ -1765,12 +1765,19 @@ foreach $vnodeport (keys(%portmap)) {
#
my $pnode = $v2pmap{$vnode};
my $ip = $ips{$vnodeport};
my $vvnode = "NULL";
# Mark as being a jail interface by establishing a connection
# to the nodes table entry for the virtnode.
if (virtnodeisjailed($vnode)) {
$vvnode = "'$v2vmap{$vnode}'";
}
if (! defined($IPaliases{"$pnode:$pport"})) {
printdb("IP: $pnode:$pport $ip\n");
DBQueryFatal("update interfaces set ".
" IP='$ip',IPaliases=NULL,mask='$mask' " .
" IP='$ip',IPaliases=NULL,mask='$mask',vnode_id=$vvnode " .
"where node_id='$pnode' and iface='$pport'");
#
......@@ -3421,6 +3428,7 @@ sub CreateTopFile()
my $simnodes = 0;
my $realnodes = 0;
my $virtnodes = 0;
my $nonvirtnodes = 0;
my $trivial_ok = 0;
my $emulated = virtlanemulated($lan);
my $uselinkdelay = virtlanlinkdelay($lan);
......@@ -3432,26 +3440,29 @@ sub CreateTopFile()
$simnodes++;
$simnodelans{$lan} = 1;
} else {
# We always use an emulated link when its a
# virtnode. An emulated link can use a trivial link
# too, if the user wanted it.
if (virtnodeisvirt($node)) {
$virtnodes++;
$emulated = 1;
$virt_lans{$lan}->{"EMULATED"} = 1;
$trivial_ok = virtlantrivok($lan);
#
# An emulated link/lan between containing any
# virtnodes always uses veth devices. Note that remote
# virtual nodes never go through this path cause they
# get tunnels, so its only local virtual nodes.
#
$virt_lans{$lan}->{"USEVETH"} = 1
if (virtnodeisvirt($node));
} else {
$nonvirtnodes++;
}
$realnodes++;
}
}
if ($virtnodes > 0 && $nonvirtnodes == 0) {
# We use an emulated link if all members of the lan are
# virtnodes. An emulated link can use a trivial link
# too, if the user wanted it.
$emulated = 1;
$virt_lans{$lan}->{"EMULATED"} = 1;
$trivial_ok = virtlantrivok($lan);
#
# An emulated link/lan between containing any
# virtnodes always uses veth devices. Note that remote
# virtual nodes never go through this path cause they
# get tunnels, so its only local virtual nodes.
#
$virt_lans{$lan}->{"USEVETH"} = 1;
}
if ($simnodes > 0 && $realnodes == 0) {
$trivial_ok = 1;
# The current support where all simulated nodes
......
......@@ -1004,6 +1004,7 @@ COMMAND_PROTOTYPE(doifconfig)
MYSQL_ROW row;
char buf[MYBUFSIZE], *ebufp = &buf[MYBUFSIZE];
int nrows;
int num_interfaces=0;
/*
* Now check reserved table
......@@ -1014,32 +1015,34 @@ COMMAND_PROTOTYPE(doifconfig)
return 1;
}
/*
* Virtual nodes, do not return interface table info. No point.
* Subnode are slightly different. This test might need to be
* smarter?
/*
* For Virtual Nodes, we return interfaces that belong to it.
*/
if (reqp->isvnode && !reqp->issubnode)
goto doveths;
if (reqp->isvnode)
sprintf(buf, "vnode_id='%s'", reqp->vnodeid);
else
strcpy(buf, "vnode_id is NULL");
/*
* Find all the interfaces.
*/
res = mydb_query("select card,IP,IPalias,MAC,current_speed,duplex, "
" IPaliases,iface,role,mask,rtabid "
"from interfaces where node_id='%s'",
11, reqp->nodeid);
"from interfaces where node_id='%s' and %s",
11, reqp->pnodeid, buf);
/*
* We need pnodeid in the query. But error reporting is done
* by nodeid. For vnodes, nodeid is pcvmXX-XX and for the rest
* it is the same as pnodeid
*/
if (!res) {
error("IFCONFIG: %s: DB Error getting interfaces!\n",
reqp->nodeid);
return 1;
}
if ((nrows = (int)mysql_num_rows(res)) == 0) {
error("IFCONFIG: %s: No interfaces!\n", reqp->nodeid);
mysql_free_result(res);
return 1;
}
nrows = (int)mysql_num_rows(res);
while (nrows) {
row = mysql_fetch_row(res);
if (row[1] && row[1][0]) {
......@@ -1111,6 +1114,7 @@ COMMAND_PROTOTYPE(doifconfig)
OUTPUT(bufp, ebufp - bufp, "\n");
client_writeback(sock, buf, strlen(buf), tcp);
num_interfaces++;
if (verbose)
info("IFCONFIG: %s", buf);
}
......@@ -1150,8 +1154,14 @@ COMMAND_PROTOTYPE(doifconfig)
return 1;
}
if ((nrows = (int)mysql_num_rows(res)) == 0) {
if (num_interfaces == 0) {
error("IFCONFIG: %s: No interfaces!\n", reqp->nodeid);
mysql_free_result(res);
return 1;
} else {
mysql_free_result(res);
return 0;
}
}
while (nrows) {
char *bufp = 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