From 9e5b64dac42dccdf915babf70f8f8c875955c4ad Mon Sep 17 00:00:00 2001 From: bobz965 Date: Sat, 3 Aug 2024 15:26:26 +0800 Subject: [PATCH] fix: empty /var/run/netns (#4360) Signed-off-by: bobz965 --- dist/images/start-ovs.sh | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/dist/images/start-ovs.sh b/dist/images/start-ovs.sh index efbfdf99eff..4d73e43be32 100755 --- a/dist/images/start-ovs.sh +++ b/dist/images/start-ovs.sh @@ -38,10 +38,15 @@ fi function quit { set +e - for netns in /var/run/netns/*; do - nsenter --net=$netns sysctl -w net.ipv4.neigh.eth0.base_reachable_time_ms=180000; - nsenter --net=$netns sysctl -w net.ipv4.neigh.eth0.gc_stale_time=180; - done + if [ -z "$(ls -A /var/run/netns)" ]; then + echo "no ns in /var/run/netns" + else + for netns in /var/run/netns/*; do + nsenter --net=$netns sysctl -w net.ipv4.neigh.eth0.base_reachable_time_ms=180000; + nsenter --net=$netns sysctl -w net.ipv4.neigh.eth0.gc_stale_time=180; + done + fi + # If the arp is in stale or delay status, stop vswitchd will lead prob failed. # Wait a while for prob ready. # As the timeout has been increased existing entry will not change to stale or delay at the moment @@ -154,10 +159,14 @@ set -e ovs-vsctl --no-wait set open_vswitch . other_config:flow-restore-wait="false" set +e -for netns in /var/run/netns/*; do - nsenter --net=$netns sysctl -w net.ipv4.neigh.eth0.base_reachable_time_ms=30000; - nsenter --net=$netns sysctl -w net.ipv4.neigh.eth0.gc_stale_time=60; -done +if [ -z "$(ls -A /var/run/netns)" ]; then + echo "no ns in /var/run/netns" +else + for netns in /var/run/netns/*; do + nsenter --net=$netns sysctl -w net.ipv4.neigh.eth0.base_reachable_time_ms=30000; + nsenter --net=$netns sysctl -w net.ipv4.neigh.eth0.gc_stale_time=60; + done +fi set -e chmod 600 /etc/openvswitch/*