Update for iproute-2.6.28
authorAndy Bavier <acb@cs.princeton.edu>
Mon, 20 Apr 2009 17:17:46 +0000 (17:17 +0000)
committerAndy Bavier <acb@cs.princeton.edu>
Mon, 20 Apr 2009 17:17:46 +0000 (17:17 +0000)
NodeManager-topo.spec
setup-egre-link
setup-nat
teardown-egre-link
teardown-nat
topo.py

index 3b0d4bf..55d414f 100644 (file)
@@ -1,8 +1,8 @@
 %define url $URL$
 
 Name:          NodeManager-topo
-Version:       0.3
-Release:       3
+Version:       0.4
+Release:       1
 Summary:       Plugin supporting creating a default virtual topology.
 
 Group:         System Environment/Daemons
index 16c366a..e6494af 100755 (executable)
@@ -15,17 +15,16 @@ SUBNET=`expr match "$VIRTNET" '.*\(/[0-9]*\)'`
 LINK=${KEY}x${NODEID}
 
 modprobe ip_gre
-modprobe etun
 
 ### Setup EGRE tunnel
 EGRE=d$LINK
-$IP tunnel add $EGRE  mode gre/eth remote $REMOTE key $KEY ttl 64
+$IP tunnel add $EGRE  mode gre type eth remote $REMOTE key $KEY ttl 64
 $IP link set $EGRE up
 
 ### Setup etun
 ETUN0=a$LINK
 ETUN1=b$LINK
-echo $ETUN0,$ETUN1 > /sys/module/etun/parameters/newif
+ip link add name $ETUN0 type veth peer name $ETUN1
 ifconfig $ETUN0 mtu 1458 up
 ifconfig $ETUN1 up
 
@@ -40,11 +39,10 @@ ifconfig $BRIDGE up
 iptables -t mangle -A FORWARD -o $BRIDGE -j MARK --set-mark $SLICEID
 
 ### Put a process in the vserver so we can move the interface there
-su $SLICE -c "sleep 30" &
-sleep 1
-PID=`su $SLICE -c "pgrep sleep"`
-chcontext --ctx 1 -- echo $PID > /sys/class/net/$ETUN0/new_ns_pid 
-sleep 1
+su $SLICE -c "sleep 30 &"
+PID=`su $SLICE -c "pgrep -n sleep"`
+$IP link set $ETUN0 netns $PID
+naddress --add --nid $SLICEID --ip ${VIRTIP}${SUBNET}
 su $SLICE -c "sudo /sbin/ifconfig $ETUN0 ${VIRTIP}${SUBNET} up; sudo /sbin/route add -net $VIRTNET dev $ETUN0"
 
 ### Set rate
index 7eb87c6..e76a359 100644 (file)
--- a/setup-nat
+++ b/setup-nat
@@ -16,25 +16,31 @@ modprobe etun
 # NAT interface must be unique on a single node.
 #
 BASE="10.0.$KEY"
+EXTIP=$BASE.1
+EXTNET=$EXTIP/24
+INTIP=$BASE.2
+INTNET=$INTIP/24
+BASENET=$BASE.0/24
 
 ### Setup etun
 ETUN0=nat$KEY
 ETUN1=natx$KEY
-echo $ETUN0,$ETUN1 > /sys/module/etun/parameters/newif
-ifconfig $ETUN1 $BASE.1/24 up
+ip link add name $ETUN0 type veth peer name $ETUN1
+ifconfig $ETUN1 $EXTNET up
 
 /sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
 /sbin/iptables -A FORWARD -i eth0 -o $ETUN1 -m state --state RELATED,ESTABLISHED -j ACCEPT
 /sbin/iptables -A FORWARD -i $ETUN1 -o eth0 -j ACCEPT
 
 ### Put a process in the vserver so we can move the interface there
-su $SLICE -c "sleep 30" &
-sleep 1
-PID=`su $SLICE -c "pgrep sleep"`
-chcontext --ctx 1 -- echo $PID > /sys/class/net/$ETUN0/new_ns_pid 
+su $SLICE -c "sleep 30 &"
+PID=`su $SLICE -c "pgrep -n sleep"`
+$IP link set $ETUN0 netns $PID
+naddress --add --nid $SLICEID --ip $INTNET
 sleep 1
 
-su $SLICE -c "sudo /sbin/ifconfig $ETUN0 $BASE.2/24 up; \
- sudo /sbin/route add -net $BASE.0/24 $ETUN0; \
- sudo /sbin/route add default gw $BASE.1"
+su $SLICE -c "sudo /sbin/ifconfig $ETUN0 $INTNET up; \
+ sudo /sbin/route add -net $BASENET $ETUN0; \
+ sudo /sbin/route add default gw $EXTIP; \
+ sudo /sbin/ifconfig lo 127.0.0.1/8 up"
 
index efa2aea..a0d5e5b 100755 (executable)
@@ -16,7 +16,7 @@ while [ $? -eq 0 ]; do
 done
 
 # Get rid of etun devices, only need name of one of them
-echo $ETUN1 > /sys/module/etun/parameters/delif
+ip link delete dev $ETUN1 
 
 # Get rid of bridge
 ifconfig $BRIDGE down
index c1029b4..c237338 100644 (file)
@@ -9,7 +9,7 @@ ETUN1=natx$KEY
 /sbin/iptables -D FORWARD -i $ETUN1 -o eth0 -j ACCEPT
 
 # Get rid of etun devices, only need name of one of them
-echo $ETUN1 > /sys/module/etun/parameters/delif
+ip link delete dev $ETUN1 
 
 
 
diff --git a/topo.py b/topo.py
index 7bf8bf7..a9a9853 100755 (executable)
--- a/topo.py
+++ b/topo.py
@@ -338,6 +338,7 @@ def update_hosts(slicename, hosts):
 
 
 def start(options, config):
+    run ("echo 1 > /proc/sys/net/ipv4/ip_forward")
     pass