Set mtu at setup time, remove iptables rule at teardown
[vsys.git] / factory / setup-link
index df3638f..be8c949 100755 (executable)
@@ -22,7 +22,7 @@ $IP link set $EGRE up
 ETUN0=v$LINK
 ETUN1=etun$LINK
 echo $ETUN0,$ETUN1 > /sys/module/etun/parameters/newif
-ifconfig $ETUN0 up
+ifconfig $ETUN0 mtu 1458 up
 ifconfig $ETUN1 up
 
 ### Setup bridge
@@ -32,6 +32,9 @@ brctl addif $BRIDGE $EGRE
 brctl addif $BRIDGE $ETUN1
 ifconfig $BRIDGE up
 
+### Setup iptables so that packets are visible in the vserver
+iptables -t mangle -A FORWARD -o $BRIDGE -j MARK --set-mark $SLICEID
+
 ### Create "grab link" script
 GRAB=/vsys/grab-$ETUN0
 cat > $GRAB <<EOF
@@ -44,4 +47,30 @@ EOF
 chmod +x $GRAB
 echo $SLICE > $GRAB.acl 
 
+### Create "delete link" script
+DELETE=/vsys/delete-$ETUN0
+cat > $DELETE <<EOF
+#!/bin/sh
+
+# Remove iptables rule
+iptables -t mangle -D FORWARD -o $BRIDGE -j MARK --set-mark $SLICEID
+
+# Get rid of etun devices, only need name of one of them
+echo $ETUN1 > /sys/module/etun/parameters/delif
+
+# Get rid of bridge
+ifconfig $BRIDGE down
+brctl delbr $BRIDGE
+
+# Get rid of EGRE tunnel
+ip tunnel del $EGRE
+
+# Clean up files
+rm $GRAB
+rm $DELETE
+
+EOF
+chmod +x $DELETE
+echo $SLICE > $DELETE.acl 
+