Skip to contentSkip to conversation

tools/hotplug/Linux: don't needlessly use non-standard features in vif-{bridge,route}

PATCH In review Jan Beulich 4 participants 4 messages Sep 2, 2020 – Sep 7, 2020

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 tools/hotplug/Linux: don't needlessly use non-standard features in vif-{bridge,route}

We're not after any "fall-through" behavior here. Replace the constructs with ones understood by all conforming shells, including older bash (problem observed with 3.1.51(1)).

Fixes b51715f02bf9 ("tools/hotplug/Linux: remove code duplication in vif-bridge")
Fixes 3683290fc0b0 ("tools/hotplug: only attempt to call 'ip route' if there is valid command")

---
v2: Also adjust vif-route.

tools/hotplug/Linux/vif-bridge +2 -6
@@ -77,16 +77,12 @@ then
 fi
 
 case "$command" in
-    add)
-        ;&
-    online)
+    add|online)
         setup_virtual_bridge_port "$dev"
         set_mtu "$bridge" "$dev" "$type_if"
         add_to_bridge "$bridge" "$dev"
         ;;
-    remove)
-        ;&
-    offline)
+    remove|offline)
         remove_from_bridge "$bridge" "$dev"
         ;;
 esac
tools/hotplug/Linux/vif-route +2 -6
@@ -22,17 +22,13 @@ dir=$(dirname "$0")
 main_ip=$(dom0_ip)
 
 case "${command}" in
-    add)
-        ;&
-    online)
+    add|online)
         ifconfig ${dev} ${main_ip} netmask 255.255.255.255 up
         echo 1 >/proc/sys/net/ipv4/conf/${dev}/proxy_arp
         ipcmd='add'
         cmdprefix=''
         ;;
-    remove)
-        ;&
-    offline)
+    remove|offline)
         do_without_error ifdown ${dev}
         ipcmd='del'
         cmdprefix='do_without_error'
Reviewed-by on v2 1/1
#1 lore raw

RE: [PATCH v2] tools/hotplug/Linux: don't needlessly use non-standard features in vif-{bridge, route}

Quoted 8 lines

-----Original Message-----
From: Jan Beulich <[email protected]>
Sent: 02 September 2020 07:09
To: [email protected]
Cc: Ian Jackson <[email protected]>; Wei Liu <[email protected]>; Paul Durrant <[email protected]>
Subject: [PATCH v2] tools/hotplug/Linux: don't needlessly use non-standard features in vif- {bridge,route}

Quoted 7 lines

We're not after any "fall-through" behavior here. Replace the constructs with ones understood by all conforming shells, including older bash (problem observed with 3.1.51(1)).

Fixes b51715f02bf9 ("tools/hotplug/Linux: remove code duplication in vif-bridge")
Fixes 3683290fc0b0 ("tools/hotplug: only attempt to call 'ip route' if there is valid command")
Quoted 46 lines

---
v2: Also adjust vif-route.

tools/hotplug/Linux/vif-bridge +2 -6
@@ -77,16 +77,12 @@ then
 fi
 
 case "$command" in
-    add)
-        ;&
-    online)
+    add|online)
         setup_virtual_bridge_port "$dev"
         set_mtu "$bridge" "$dev" "$type_if"
         add_to_bridge "$bridge" "$dev"
         ;;
-    remove)
-        ;&
-    offline)
+    remove|offline)
         remove_from_bridge "$bridge" "$dev"
         ;;
 esac
tools/hotplug/Linux/vif-route +2 -6
@@ -22,17 +22,13 @@ dir=$(dirname "$0")
 main_ip=$(dom0_ip)
 
 case "${command}" in
-    add)
-        ;&
-    online)
+    add|online)
         ifconfig ${dev} ${main_ip} netmask 255.255.255.255 up
         echo 1 >/proc/sys/net/ipv4/conf/${dev}/proxy_arp
         ipcmd='add'
         cmdprefix=''
         ;;
-    remove)
-        ;&
-    offline)
+    remove|offline)
         do_without_error ifdown ${dev}
         ipcmd='del'
         cmdprefix='do_without_error'
Reviewed-by on v2 1/1
#2 lore raw
In reply to Jan Beulich
Quoted 11 lines · Jan Beulich

We're not after any "fall-through" behavior here. Replace the constructs with ones understood by all conforming shells, including older bash (problem observed with 3.1.51(1)).

Fixes b51715f02bf9 ("tools/hotplug/Linux: remove code duplication in vif-bridge")
Fixes 3683290fc0b0 ("tools/hotplug: only attempt to call 'ip route' if there is valid command")
Quoted 47 lines

---
v2: Also adjust vif-route.

tools/hotplug/Linux/vif-bridge +0 -0
@@ -77,16 +77,12 @@ then

fi

case "$command" in

tools/hotplug/Linux/vif-bridge +2 -6
-    add)
-        ;&
-    online)
+    add|online)
        setup_virtual_bridge_port "$dev"
        set_mtu "$bridge" "$dev" "$type_if"
        add_to_bridge "$bridge" "$dev"
        ;;
-    remove)
-        ;&
-    offline)
+    remove|offline)
        remove_from_bridge "$bridge" "$dev"
        ;;

esac

tools/hotplug/Linux/vif-route +0 -0
@@ -22,17 +22,13 @@ dir=$(dirname "$0")
 main_ip=$(dom0_ip)
 

case "${command}" in

tools/hotplug/Linux/vif-route +2 -6
-    add)
-        ;&
-    online)
+    add|online)
        ifconfig ${dev} ${main_ip} netmask 255.255.255.255 up
        echo 1 >/proc/sys/net/ipv4/conf/${dev}/proxy_arp
        ipcmd='add'
        cmdprefix=''
        ;;
-    remove)
-        ;&
-    offline)
+    remove|offline)
        do_without_error ifdown ${dev}
        ipcmd='del'
        cmdprefix='do_without_error'
Acked-by on v2 1/1
#3 lore raw
In reply to Jan Beulich
Quoted 7 lines · Jan Beulich

We're not after any "fall-through" behavior here. Replace the constructs with ones understood by all conforming shells, including older bash (problem observed with 3.1.51(1)).

Fixes b51715f02bf9 ("tools/hotplug/Linux: remove code duplication in vif-bridge")
Fixes 3683290fc0b0 ("tools/hotplug: only attempt to call 'ip route' if there is valid command")