Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions pipework
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ case "$1" in
DIRECT_PHYS=1
shift
;;
--macvlan-mode)
MACVLAN_MODE=1
shift
;;
esac

IFNAME=$1
Expand Down Expand Up @@ -153,8 +157,8 @@ CONTAINER_IFNAME=${CONTAINER_IFNAME:-eth1}
exit 0
}

[ "$IFTYPE" = bridge ] && [ "$BRTYPE" = linux ] && [ "$VLAN" ] && {
die 1 "VLAN configuration currently unsupported for Linux bridge."
[ "$IFTYPE" = bridge ] && [ "$BRTYPE" = linux ] && [ "$VLAN" ] && [ -z "$MACVLAN_MODE" ] && {
die 1 "VLAN configuration currently unsupported for Linux bridge. Try --macvlan-mode."
}

[ "$IFTYPE" = ipoib ] && [ "$MACADDR" ] && {
Expand Down Expand Up @@ -292,7 +296,7 @@ ln -s "/proc/$NSPID/ns/net" "/var/run/netns/$NSPID"
[ "$IFTYPE" != "route" ] && [ "$IFTYPE" != "dummy" ] && [ "$IFTYPE" != "rule" ] && [ "$IFTYPE" != "tc" ] && MTU=$(ip link show "$IFNAME" | awk '{print $5}')

# If it's a bridge, we need to create a veth pair
[ "$IFTYPE" = bridge ] && {
[ "$IFTYPE" = bridge ] && [ -z "$MACVLAN_MODE" ] && {
if [ -z "$LOCAL_IFNAME" ]; then
LOCAL_IFNAME="v${CONTAINER_IFNAME}pl${NSPID}"
fi
Expand Down Expand Up @@ -329,7 +333,7 @@ ln -s "/proc/$NSPID/ns/net" "/var/run/netns/$NSPID"
}

# If it's a physical interface, create a macvlan subinterface
[ "$IFTYPE" = phys ] && {
[ "$IFTYPE" = phys ] || ( [ "$IFTYPE" = bridge ] && [ ! -z "$MACVLAN_MODE" ] ) && {
[ "$VLAN" ] && {
[ ! -d "/sys/class/net/${IFNAME}.${VLAN}" ] && {
ip link add link "$IFNAME" name "$IFNAME.$VLAN" mtu "$MTU" type vlan id "$VLAN"
Expand Down