From: Andy Bavier Date: Fri, 1 May 2009 16:03:51 +0000 (+0000) Subject: Use MACVLAN instead of bridge X-Git-Url: http://git.onelab.eu/?p=nodemanager-topo.git;a=commitdiff_plain;h=26a6e5f99e3c9a53bb2f0980a1f82e1efb7a2463 Use MACVLAN instead of bridge --- diff --git a/NodeManager-topo.spec b/NodeManager-topo.spec index 55d414f..8188f9d 100644 --- a/NodeManager-topo.spec +++ b/NodeManager-topo.spec @@ -2,7 +2,7 @@ Name: NodeManager-topo Version: 0.4 -Release: 1 +Release: 3 Summary: Plugin supporting creating a default virtual topology. Group: System Environment/Daemons diff --git a/setup-egre-link b/setup-egre-link index e6494af..56771f6 100755 --- a/setup-egre-link +++ b/setup-egre-link @@ -21,29 +21,16 @@ EGRE=d$LINK $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 -ip link add name $ETUN0 type veth peer name $ETUN1 -ifconfig $ETUN0 mtu 1458 up -ifconfig $ETUN1 up - -### Setup bridge -BRIDGE=c$LINK -brctl addbr $BRIDGE -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 +### Setup macvlan +MACV=a$LINK +ip link add link $EGRE $MACV type macvlan ### Put a process in the vserver so we can move the interface there su $SLICE -c "sleep 30 &" PID=`su $SLICE -c "pgrep -n sleep"` -$IP link set $ETUN0 netns $PID +$IP link set $MACV 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" +su $SLICE -c "sudo /sbin/ifconfig $MACV ${VIRTIP}${SUBNET} mtu 1458 up" ### Set rate tc qdisc add dev $EGRE root handle 1: htb default 10 diff --git a/setup-nat b/setup-nat index e76a359..bb9053a 100644 --- a/setup-nat +++ b/setup-nat @@ -40,7 +40,6 @@ naddress --add --nid $SLICEID --ip $INTNET sleep 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" diff --git a/teardown-egre-link b/teardown-egre-link index a0d5e5b..46debc1 100755 --- a/teardown-egre-link +++ b/teardown-egre-link @@ -5,23 +5,7 @@ KEY=$2 LINK=${KEY}x${NODEID} EGRE=d$LINK -BRIDGE=c$LINK -ETUN1=b$LINK -MARK=`iptables -t mangle -L -v|grep -m 1 $BRIDGE|awk '{print $NF}'` - -# Remove iptables rules. Sometimes there is more than one. -while [ $? -eq 0 ]; do - iptables -t mangle -D FORWARD -o $BRIDGE -j MARK --set-mark $MARK -done - -# Get rid of etun devices, only need name of one of them -ip link delete dev $ETUN1 - -# Get rid of bridge -ifconfig $BRIDGE down -brctl delbr $BRIDGE - -# Get rid of EGRE tunnel +# Get rid of EGRE tunnel and MACVLAN interface ip tunnel del $EGRE