Skip to content

Commit

Permalink
Merge pull request jpetazzo#15 from PeerXu/master
Browse files Browse the repository at this point in the history
Add support for openvswitch.
  • Loading branch information
Jérôme Petazzoni committed Dec 29, 2013
2 parents 8cdefd6 + 08928b1 commit 203186c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,14 @@ be `2`, `6`, `a`, or `e`. You can check [Wikipedia](
http://en.wikipedia.org/wiki/MAC_address) if you want even more details.


## Support Open vSwitch

If you want to attach a container to the Open vSwitch bridge, no problem.

ovs-vsctl list-br
ovsbr0
pipework ovsbr0 $(docker run -d mysql /usr/sbin/mysqld_safe) 192.168.1.2/24

## Cleanup

When a container is terminated (the last process of the net namespace exits),
Expand Down
17 changes: 15 additions & 2 deletions pipework
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ MACADDR=$4
if [ -d /sys/class/net/$IFNAME ]
then
if [ -d /sys/class/net/$IFNAME/bridge ]
then IFTYPE=bridge
then
IFTYPE=bridge
BRTYPE=linux
elif $(which ovs-vsctl >/dev/null) && $(ovs-vsctl list-br|grep -q ^$IFNAME$)
then
IFTYPE=bridge
BRTYPE=openvswitch
else IFTYPE=phys
fi
else
Expand Down Expand Up @@ -115,7 +121,14 @@ ln -s /proc/$NSPID/ns/net /var/run/netns/$NSPID
LOCAL_IFNAME=vethl$NSPID
GUEST_IFNAME=vethg$NSPID
ip link add name $LOCAL_IFNAME type veth peer name $GUEST_IFNAME
ip link set $LOCAL_IFNAME master $IFNAME
case "$BRTYPE" in
linux)
ip link set $LOCAL_IFNAME master $IFNAME
;;
openvswitch)
ovs-vsctl add-port $IFNAME $LOCAL_IFNAME
;;
esac
ip link set $LOCAL_IFNAME up
}

Expand Down

0 comments on commit 203186c

Please sign in to comment.