summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2023-04-18 22:27:15 +0200
committerRoman Smrž <roman.smrz@seznam.cz>2023-04-18 22:27:15 +0200
commit7153a26626498d9790ddf73f6a275cc93f847c66 (patch)
treef72906906549b567eaf4a4b474e2866fd1c3c54f
parentc400e2b11cd5bfe7bd19def3e10318338f8db224 (diff)
Bring up veth peer in subnet first
-rw-r--r--src/Network.hs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/Network.hs b/src/Network.hs
index 6e3568d..702e7ad 100644
--- a/src/Network.hs
+++ b/src/Network.hs
@@ -147,6 +147,8 @@ newSubnet net vname = do
let veth = T.pack $ "veth_s" <> show idx
callOn net $ "ip link add " <> veth <> " type veth peer name veth0 netns \"" <> textNetnsName (netnsName sub) <> "\""
callOn net $ "ip addr add dev " <> veth <> " " <> textIpAddressCidr router
+ callOn sub $ "ip link set dev veth0 master br0 up" -- this end needs to go up first,
+ -- otherwise it sometimes gets stuck with NO-CARRIER for a while.
callOn net $ "ip link set dev " <> veth <> " up"
-- If the new subnet can be split further, routing rule for the whole prefix is needed
@@ -155,8 +157,6 @@ newSubnet net vname = do
<> " via " <> textIpAddress bridge
<> " dev " <> veth
<> " src " <> textIpAddress router
-
- callOn sub $ "ip link set dev veth0 master br0 up"
callOn sub $ "ip route add default via " <> textIpAddress router <> " dev br0 src " <> textIpAddress bridge
return sub