When we configure OVS using rhel ifupdown scripts,
we call ifup on a bridge twice. Once while configuring the
bridge and once while configuring the ports of the bridge.
This looks harmless but unnecessary. This patch fixes the
behavior.

Signed-off-by: Gurucharan Shetty <[email protected]>
---
 rhel/etc_sysconfig_network-scripts_ifup-ovs |   40 ++++++++++++++++++++-------
 1 file changed, 30 insertions(+), 10 deletions(-)

diff --git a/rhel/etc_sysconfig_network-scripts_ifup-ovs 
b/rhel/etc_sysconfig_network-scripts_ifup-ovs
index ae095a0..27409e5 100755
--- a/rhel/etc_sysconfig_network-scripts_ifup-ovs
+++ b/rhel/etc_sysconfig_network-scripts_ifup-ovs
@@ -22,7 +22,7 @@ cd /etc/sysconfig/network-scripts
 [ -f ../network ] && . ../network
 
 CONFIG=${1}
-TIMEOUT=10
+TIMEOUT=5
 
 need_config ${CONFIG}
 
@@ -43,6 +43,18 @@ check_recursion()
        return 0
 }
 
+ovs_vsctl ()
+{
+       ovs-vsctl -t "${TIMEOUT}" -- "$@"
+}
+
+ifup_ovs_bridge()
+{
+       if ovs_vsctl br-exists "${OVS_BRIDGE}"; then :; else
+               /sbin/ifup "${OVS_BRIDGE}"
+       fi
+}
+
 if [ -z "${UPPEDSTACK}" ]; then
        UPPEDSTACK="${DEVICE}"
 fi
@@ -57,7 +69,13 @@ done
 
 case "$TYPE" in
        OVSBridge)
-               ovs-vsctl -t ${TIMEOUT} -- --may-exist add-br "$DEVICE" 
$OVS_OPTIONS ${OVS_EXTRA+-- $OVS_EXTRA}
+               # If bridge already exists, it has been configured through other
+               # cases like OVSPort, OVSIntPort and OVSBond.
+               if ovs_vsctl br-exists "${DEVICE}"; then
+                       OVSBRIDGECONFIGURED="yes"
+               else
+                       ovs_vsctl add-br "$DEVICE" $OVS_OPTIONS ${OVS_EXTRA+-- 
$OVS_EXTRA}
+               fi
                if [ "${OVSBOOTPROTO}" = "dhcp" ] && [ -n "${OVSINTF}" ]; then
                        case " ${OVSDHCPINTERFACES} " in
                                *" ${OVSINTF} "*)
@@ -65,29 +83,31 @@ case "$TYPE" in
                                ;;
                        esac
                fi
-               if [ "${OVSBOOTPROTO}" != "dhcp" ] && [ -z "${OVSINTF}" ]; then
+               if [ "${OVSBOOTPROTO}" != "dhcp" ] && [ -z "${OVSINTF}" ] && \
+                       [ "${OVSBRIDGECONFIGURED}" != "yes" ]; then
                        ${OTHERSCRIPT} ${CONFIG}
                fi
-               [ -n "${STP}" ] && ovs-vsctl --no-wait set bridge "${DEVICE}" 
stp_enable="${STP}"
+               [ -n "${STP}" ] && ovs-vsctl -t "${TIMEOUT}" --no-wait set 
bridge \
+                       "${DEVICE}" stp_enable="${STP}"
                exit 0
                ;;
        OVSPort)
-               /sbin/ifup "$OVS_BRIDGE"
+               ifup_ovs_bridge
                ${OTHERSCRIPT} ${CONFIG} ${2}
-               ovs-vsctl -t ${TIMEOUT} -- --may-exist add-port "$OVS_BRIDGE" 
"$DEVICE" $OVS_OPTIONS ${OVS_EXTRA+-- $OVS_EXTRA}
+               ovs_vsctl --may-exist add-port "$OVS_BRIDGE" "$DEVICE" 
$OVS_OPTIONS ${OVS_EXTRA+-- $OVS_EXTRA}
                OVSINTF=${DEVICE} /sbin/ifup "$OVS_BRIDGE"
                ;;
        OVSIntPort)
-               /sbin/ifup "$OVS_BRIDGE"
-               ovs-vsctl -t ${TIMEOUT} -- --may-exist add-port "$OVS_BRIDGE" 
"$DEVICE" $OVS_OPTIONS -- set Interface "$DEVICE" type=internal ${OVS_EXTRA+-- 
$OVS_EXTRA}
+               ifup_ovs_bridge
+               ovs_vsctl --may-exist add-port "$OVS_BRIDGE" "$DEVICE" 
$OVS_OPTIONS -- set Interface "$DEVICE" type=internal ${OVS_EXTRA+-- $OVS_EXTRA}
                ${OTHERSCRIPT} ${CONFIG} ${2}
                ;;
        OVSBond)
-               /sbin/ifup "$OVS_BRIDGE"
+               ifup_ovs_bridge
                for _iface in $BOND_IFACES; do
                        /sbin/ifup ${_iface}
                done
-               ovs-vsctl -t ${TIMEOUT} -- --fake-iface add-bond "$OVS_BRIDGE" 
"$DEVICE" ${BOND_IFACES} $OVS_OPTIONS ${OVS_EXTRA+-- $OVS_EXTRA}
+               ovs_vsctl --fake-iface add-bond "$OVS_BRIDGE" "$DEVICE" 
${BOND_IFACES} $OVS_OPTIONS ${OVS_EXTRA+-- $OVS_EXTRA}
                ${OTHERSCRIPT} ${CONFIG} ${2}
                OVSINTF=${DEVICE} /sbin/ifup "$OVS_BRIDGE"
                ;;
-- 
1.7.9.5

_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev

Reply via email to