simplify code for attach
This commit is contained in:
1 parent
7a53efe66c
commit
579f3469c8
1 file changed
+7
-10
@@ -196,29 +196,26 @@ attach() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! ip link set $LOCAL_IFNAME master $BRIDGE ||
|
if ! ip link set $GUEST_IFNAME netns $NETNS ; then
|
||||||
! ip link set $LOCAL_IFNAME up ||
|
|
||||||
! ip link set $GUEST_IFNAME netns $NETNS ; then
|
|
||||||
# failed before we assigned the veth to the container's
|
# failed before we assigned the veth to the container's
|
||||||
# namespace - delete it
|
# namespace - delete it
|
||||||
ip link del $LOCAL_IFNAME type veth || true
|
ip link del $LOCAL_IFNAME type veth || true
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! ip netns exec $NETNS ip link set $GUEST_IFNAME name $CONTAINER_IFNAME ||
|
if ! ip link set $LOCAL_IFNAME master $BRIDGE ||
|
||||||
|
! ip link set $LOCAL_IFNAME up ||
|
||||||
|
! ip netns exec $NETNS ip link set $GUEST_IFNAME name $CONTAINER_IFNAME ||
|
||||||
! ip netns exec $NETNS ip addr add $1 dev $CONTAINER_IFNAME ||
|
! ip netns exec $NETNS ip addr add $1 dev $CONTAINER_IFNAME ||
|
||||||
! ip netns exec $NETNS ip link set $CONTAINER_IFNAME up ||
|
! ip netns exec $NETNS ip link set $CONTAINER_IFNAME up ||
|
||||||
! check_command_and_run ethtool ip netns exec $NETNS ethtool -K $CONTAINER_IFNAME tx off >/dev/null ; then
|
! check_command_and_run ethtool ip netns exec $NETNS ethtool -K $CONTAINER_IFNAME tx off >/dev/null ; then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ip netns exec $NETNS ip route show | grep '^224\.0\.0\.0/4' >/dev/null ; then
|
|
||||||
# There's a multicast route already present, leave it alone.
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Route multicast packets across the weave network.
|
# Route multicast packets across the weave network.
|
||||||
ip netns exec $NETNS ip route add 224.0.0.0/4 dev $CONTAINER_IFNAME
|
if ! ip netns exec $NETNS ip route show | grep '^224\.0\.0\.0/4' >/dev/null ; then
|
||||||
|
ip netns exec $NETNS ip route add 224.0.0.0/4 dev $CONTAINER_IFNAME
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
detach() {
|
detach() {
|
||||||
|
|||||||
Reference in new issue
Block a user