Commit 18377ca2 authored by Mike Hibler's avatar Mike Hibler

An an OS-specific client side function (i.e., in liblocsetup) to return

the virtual interface name given the tmcc-returned ifconfig info.  tmcc
just returns the physical interface underlying a virtual interface, so it
is no good for setting up, e.g., the gated config.
parent 2b067fec
......@@ -318,9 +318,11 @@ sub gatedsetup ()
print IFS "\tarea 0.0.0.2 {\n\t\tauthtype none;\n";
foreach my $ifconfig (@ifacelist) {
my $xif = $ifconfig->{"IFACE"};
print IFS "\t\tinterface $xif { priority 1; };\n";
# only do this for IP configured interfaces
if ($ifconfig->{"IPADDR"} ne "") {
my $xif = $ifconfig->{"VIFACE"};
print IFS "\t\tinterface $xif { priority 1; };\n";
}
}
print IFS "\t};\n};\n";
......
......@@ -483,14 +483,19 @@ sub dorole()
# case for the IXP configuration stuff). This is inconsistent with many
# other config scripts, but at some point that will change.
#
sub getifconfig($)
sub getifconfig($;$)
{
my ($rptr) = @_; # Return list to caller (reference).
my ($rptr,$nocache) = @_; # Return list to caller (reference).
my @tmccresults = ();
my @ifacelist = (); # To be returned to caller.
my %ifacehash = ();
if (tmcc(TMCCCMD_IFC, undef, \@tmccresults) < 0) {
my %tmccopts = ();
if ($nocache) {
$tmccopts{"nocache"} = 1;
}
if (tmcc(TMCCCMD_IFC, undef, \@tmccresults, %tmccopts) < 0) {
warn("*** WARNING: Could not get interface config from server!\n");
@$rptr = ();
return -1;
......@@ -567,6 +572,7 @@ sub getifconfig($)
$ifconfig->{"DUPLEX"} = $duplex;
$ifconfig->{"ALIASES"} = ""; # gone as of version 27
$ifconfig->{"IFACE"} = $iface;
$ifconfig->{"VIFACE"} = $iface;
$ifconfig->{"RTABID"} = $rtabid;
$ifconfig->{"LAN"} = $lan;
$ifconfig->{"SETTINGS"} = {};
......@@ -600,10 +606,11 @@ sub getifconfig($)
} else {
#
# A veth might not have any underlying physical interface if the
# link or lan is completely contained on the node. tmcd tells us
# that by setting the pmac to "none". Note that this obviously is
# relevant on the physnode, not when called from inside a vnode.
# A veth might not have any underlying physical interface
# if the link or lan is completely contained on the node.
# tmcd tells us that by setting the pmac to "none". Note
# that this obviously is relevant on the physnode, not when
# called from inside a vnode.
#
if ($pmac ne "none") {
if (! ($iface = findiface($pmac))) {
......@@ -626,6 +633,10 @@ sub getifconfig($)
$ifconfig->{"ENCAP"} = $encap;
$ifconfig->{"LAN"} = $lan;
$ifconfig->{"VTAG"} = $vtag;
# determine the OS-specific virtual device name
$ifconfig->{"VIFACE"} = os_viface_name($ifconfig);
push(@ifacelist, $ifconfig);
}
else {
......
#!/usr/bin/perl -wT
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2005 University of Utah and the Flux Group.
# Copyright (c) 2000-2006 University of Utah and the Flux Group.
# All rights reserved.
#
......@@ -18,7 +18,7 @@ use Exporter;
os_account_cleanup os_accounts_start os_accounts_end os_accounts_sync
os_ifconfig_line os_etchosts_line
os_setup os_groupadd os_groupgid os_useradd os_userdel os_usermod os_mkdir
os_ifconfig_veth
os_ifconfig_veth os_viface_name
os_routing_enable_forward os_routing_enable_gated
os_routing_add_manual os_routing_del_manual os_homedirdel
os_groupdel os_samba_mount
......@@ -365,6 +365,25 @@ sub os_ifconfig_veth($$$$$;$$$$$)
return "";
}
#
# Compute the name of a virtual interface device based on the
# information in ifconfig hash (as returned by getifconfig).
#
sub os_viface_name($)
{
my ($ifconfig) = @_;
my $piface = $ifconfig->{"IFACE"};
#
# Physical interfaces use their own name
#
if (!$ifconfig->{"ISVIRT"}) {
return $piface;
}
warn("CygWin does not support virtual interface type '$itype'\n");
return undef;
}
#
# Generate and return an string that is approriate for putting
# into /etc/hosts.
......
......@@ -17,7 +17,7 @@ use Exporter;
$LOOPBACKMOUNT
os_account_cleanup os_ifconfig_line os_etchosts_line
os_setup os_groupadd os_useradd os_userdel os_usermod os_mkdir
os_ifconfig_veth
os_ifconfig_veth os_viface_name
os_routing_enable_forward os_routing_enable_gated
os_routing_add_manual os_routing_del_manual os_homedirdel
os_groupdel os_getnfsmounts
......@@ -289,6 +289,40 @@ sub os_ifconfig_veth($$$$$;$$$$$)
return ($uplines, $downlines);
}
#
# Compute the name of a virtual interface device based on the
# information in ifconfig hash (as returned by getifconfig).
#
sub os_viface_name($)
{
my ($ifconfig) = @_;
my $piface = $ifconfig->{"IFACE"};
#
# Physical interfaces use their own name
#
if (!$ifconfig->{"ISVIRT"}) {
return $piface;
}
#
# Otherwise we have a virtual interface: alias, veth, vlan.
#
# alias: There is no alias device, just use the phys device
# veth: veth<ID>
# vlan: vlan<ID>
#
my $itype = $ifconfig->{"ITYPE"};
if ($itype eq "alias") {
return $piface;
} elsif ($itype =~ /^(vlan|veth)$/) {
return $itype . $ifconfig->{"ID"};
}
warn("FreeBSD does not support virtual interface type '$itype'\n");
return undef;
}
#
# Generate and return an string that is approriate for putting
# into /etc/hosts.
......
......@@ -15,7 +15,7 @@ use Exporter;
qw ( $CP $EGREP $NFSMOUNT $UMOUNT $TMPASSWD $SFSSD $SFSCD $RPMCMD $HOSTSFILE
os_account_cleanup os_ifconfig_line os_etchosts_line
os_setup os_groupadd os_useradd os_userdel os_usermod os_mkdir
os_ifconfig_veth
os_ifconfig_veth os_viface_name
os_routing_enable_forward os_routing_enable_gated
os_routing_add_manual os_routing_del_manual os_homedirdel
os_groupdel os_getnfsmounts
......@@ -426,6 +426,40 @@ sub os_ifconfig_veth($$$$$;$$$$%)
return ($uplines, $downlines);
}
#
# Compute the name of a virtual interface device based on the
# information in ifconfig hash (as returned by getifconfig).
#
sub os_viface_name($)
{
my ($ifconfig) = @_;
my $piface = $ifconfig->{"IFACE"};
#
# Physical interfaces use their own name
#
if (!$ifconfig->{"ISVIRT"}) {
return $piface;
}
#
# Otherwise we have a virtual interface: alias, veth, vlan.
#
# alias: There is an alias device, but not sure what it is good for
# so for now we just return the phys device.
# vlan: vlan<VTAG>
#
my $itype = $ifconfig->{"ITYPE"};
if ($itype eq "alias") {
return $piface;
} elsif ($itype eq "vlan") {
return $itype . $ifconfig->{"VTAG"};
}
warn("Linux does not support virtual interface type '$itype'\n");
return undef;
}
#
# Generate and return an string that is approriate for putting
# into /etc/hosts.
......
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