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
chmod +x $GRAB
echo $SLICE > $GRAB.acl
+### Create "delete link" script
+DELETE=/vsys/delete-$ETUN0
+cat > $DELETE <<EOF
+#!/bin/sh
+
+# 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
+