Index: fedkit/gateway_lib.pm
===================================================================
--- fedkit/gateway_lib.pm	(revision c3a3fe3b87f04c0fd9fb3a50bb72b35d7cf88bfd)
+++ fedkit/gateway_lib.pm	(revision f8fa72ba913bb6209f71fb3ea1dafb371d25a87b)
@@ -27,4 +27,8 @@
 my $FINDIF = "/usr/local/etc/emulab/findif";
 my $TMCC = "/usr/local/etc/emulab/tmcc";
+
+# Linux choices
+my $BRCTL = "/usr/sbin/brctl";
+my $IPROUTE = "/sbin/ip route ";
 
 # Takes an ssh config file and a reference to a hash of keys whose values must
@@ -176,15 +180,32 @@
     }
 
-    system("ifconfig $bridge create");
-    warn "Cannot create bridge: $?\n" if $?;
-    foreach my $a (@addr) {
-	system("ifconfig $iface delete $a");
-	warn "Cannot delete address $a: $?\n" if $?;
-    }
-    system("ifconfig $bridge addm $iface up");
-    warn "Cannot add intefrace $iface to bridge: $?\n" if $?;
-    system("ifconfig $bridge addm $tap");
-    warn "Cannot add intefrace $tap to bridge: $?\n" if $?;
-    return $?;
+    my $uname = `uname`;
+    chomp $uname;
+
+    if ($uname =~ /FreeBSD/) {
+	system("ifconfig $bridge create");
+	warn "Cannot create bridge: $?\n" if $?;
+	foreach my $a (@addr) {
+	    system("ifconfig $iface delete $a");
+	    warn "Cannot delete address $a: $?\n" if $?;
+	}
+	system("ifconfig $bridge addm $iface up");
+	warn "Cannot add intefrace $iface to bridge: $?\n" if $?;
+	system("ifconfig $bridge addm $tap");
+	warn "Cannot add intefrace $tap to bridge: $?\n" if $?;
+	return $?;
+    }
+    elsif ($uname =~ /Linux/) {
+	system("$IFCONFIG $iface 0.0.0.0 down");
+	system("$BRCTL addbr $bridge");
+	warn "Cannot create bridge: $?\n" if $?;
+	system("$BRCTL addif $bridge $tap");
+	system("$BRCTL addif $bridge $iface");
+	system("$BRCTL stp $bridge off");
+	system("$IFCONFIG $bridge up");
+	system("$IFCONFIG $tap up");
+	system("$IFCONFIG $iface up");
+	return $?;
+    }
 }
 
@@ -194,8 +215,15 @@
     my $ipipe = new IO::Pipe() || die "Can't create pipe for ifconfig: $!\n";
     my @addr;
+    my $uname = `uname`;
+    my $ipre = "inet\\s+([0-9\\.]+)";
+    chomp $uname;
+
+    if ($uname =~ /Linux/) {
+	$ipre = "inet\\s+addr:\\s*([0-9\\.]+)";
+    }
 
     $ipipe->reader("$IFCONFIG $iface");
     while(<$ipipe>) {
-	/inet\s+([0-9\.]+)/ && push(@addr, $1);
+	/$ipre/ && push(@addr, $1);
     }
     $ipipe->close();
@@ -207,10 +235,26 @@
     my($dest) =@_;
     my $rpipe = new IO::Pipe() || die "Can't create pipe for route: $!\n";
-
-    $rpipe->reader("$ROUTE get $dest");
+    my $uname = `uname`;
+    chomp $uname;
+    my $route;
+    my $dev_re;
+
+    if ($uname =~ /Linux/) {
+	$route = $IPROUTE;
+	$dev_re = "\\s+dev\\s+(\\S+)";
+    }
+    elsif ($uname =~ /FreeBSD/) {
+	$route = $ROUTE;
+	$dev_re = 'interface:\\s*([[:alnum:]]+)';
+    }
+
+
+    print "$route get $dest\n";
+    $rpipe->reader("$route get $dest");
     while (<$rpipe>) {
-	/interface:\s*([[:alnum:]]+)/ && do {
+	/$dev_re/ && do {
 	    my $iface = $1;
 	    $rpipe->close();
+	    print "matched: $iface\n";
 	    return $iface;
 	};
@@ -290,10 +334,18 @@
 
 
-sub emulab_config_filename {
-    # Find the configuration file in the usual place, which depends on what
-    # experiment and project we're in.
+sub config_filename {
+    # Find the configuration file in the usual places, if there is one in
+    # /usr/local/federation/etc, use it, otherwise look in the emulab standard
+    # filesystems which depends on what experiment and project we're in.
     my $pid;
     my $eid;
     my $filename;
+    my $fed_dir = "/usr/local/federation/etc/";
+    my $hn = `hostname`;
+    chomp $hn;
+    $hn =~ s/\..*//;
+
+    return "$fed_dir/$hn.gw.conf" if -r "$fed_dir/$hn.gw.conf";
+
     my $tmcd = new IO::Pipe() || die "Can't create pipe: $!\n";
 
@@ -308,7 +360,4 @@
     }
     $tmcd->close();
-    my $hn = `hostname`;
-    chomp $hn;
-    $hn =~ s/\..*//;
     $filename = "/proj/$pid/exp/$eid/tmp/$hn.gw.conf"
 	if $pid and $eid;
@@ -316,4 +365,5 @@
     return $filename;
 }
+
 
 sub wait_for_port {
