ofpbuf: Fix trivial spelling typo.
[cascardo/ovs.git] / rhel / etc_sysconfig_network-scripts_ifup-ovs
index 017346d..f3fc05e 100755 (executable)
@@ -60,22 +60,43 @@ fi
        fi
 done
 
-[ -f /var/lock/subsys/openvswitch ] || /sbin/service openvswitch start
+SERVICE_UNIT=/usr/lib/systemd/system/openvswitch-nonetwork.service
+if [ -f $SERVICE_UNIT ] && [ -x /usr/bin/systemctl ]; then
+       if ! systemctl --quiet is-active openvswitch-nonetwork.service; then
+               systemctl start openvswitch-nonetwork.service
+       fi
+else
+       if [ ! -f /var/lock/subsys/openvswitch ]; then
+               /sbin/service openvswitch start
+       fi
+fi
 
 case "$TYPE" in
-       OVSBridge)
+       OVSBridge|OVSUserBridge)
                # If bridge already exists and is up, it has been configured through
                # other cases like OVSPort, OVSIntPort and OVSBond. If it is down or
                # it does not exist, create it. It is possible for a bridge to exist
                # because it remained in the OVSDB for some reason, but it won't be up.
+               if [ "${TYPE}" = "OVSUserBridge" ]; then
+                       DATAPATH="netdev"
+               fi
                if check_device_down "${DEVICE}"; then
                        ovs-vsctl -t ${TIMEOUT} -- --may-exist add-br "$DEVICE" $OVS_OPTIONS \
                        ${OVS_EXTRA+-- $OVS_EXTRA} \
-                       ${STP+-- set bridge "$DEVICE" stp_enable="${STP}"}
+                       ${STP+-- set bridge "$DEVICE" stp_enable="${STP}"} \
+                       ${DATAPATH+-- set bridge "$DEVICE" datapath_type="$DATAPATH"}
                else
                        OVSBRIDGECONFIGURED="yes"
                fi
 
+               # If MACADDR is provided in the interface configuration file,
+               # we need to set it using ovs-vsctl; setting it with the "ip"
+               # command in ifup-eth does not make the change persistent.
+               if [ -n "$MACADDR" ]; then
+                       ovs-vsctl -t ${TIMEOUT} -- set bridge "$DEVICE" \
+                               other-config:hwaddr="$MACADDR"
+               fi
+
                # When dhcp is enabled, the assumption is that there will be a port to
                # attach (otherwise, we can't reach out for dhcp). So, we do not
                # configure the bridge through rhel's ifup infrastructure unless
@@ -100,27 +121,54 @@ case "$TYPE" in
        OVSPort)
                ifup_ovs_bridge
                ${OTHERSCRIPT} ${CONFIG} ${2}
-               ovs-vsctl -t ${TIMEOUT} -- --may-exist add-port "$OVS_BRIDGE" "$DEVICE" $OVS_OPTIONS ${OVS_EXTRA+-- $OVS_EXTRA}
+               # The port might be already in the database but not yet
+               # in the datapath.  So, remove the stale interface first.
+               ovs-vsctl -t ${TIMEOUT} \
+                       -- --if-exists del-port "$OVS_BRIDGE" "$DEVICE" \
+                       -- add-port "$OVS_BRIDGE" "$DEVICE" $OVS_OPTIONS ${OVS_EXTRA+-- $OVS_EXTRA}
                OVSINTF=${DEVICE} /sbin/ifup "$OVS_BRIDGE"
                ;;
        OVSIntPort)
                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}
-               ${OTHERSCRIPT} ${CONFIG} ${2}
+               if [ -n "${OVSDHCPINTERFACES}" ]; then
+                       for _iface in ${OVSDHCPINTERFACES}; do
+                               /sbin/ifup ${_iface}
+                       done
+               fi
+               BOOTPROTO="${OVSBOOTPROTO}" ${OTHERSCRIPT} ${CONFIG} ${2}
                ;;
        OVSBond)
                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}
-               ${OTHERSCRIPT} ${CONFIG} ${2}
+               ovs-vsctl -t ${TIMEOUT} -- --may-exist add-bond "$OVS_BRIDGE" "$DEVICE" ${BOND_IFACES} $OVS_OPTIONS ${OVS_EXTRA+-- $OVS_EXTRA}
                OVSINTF=${DEVICE} /sbin/ifup "$OVS_BRIDGE"
                ;;
        OVSTunnel)
                ifup_ovs_bridge
                ovs-vsctl -t ${TIMEOUT} -- --may-exist add-port "$OVS_BRIDGE" "$DEVICE" $OVS_OPTIONS -- set Interface "$DEVICE" type=$OVS_TUNNEL_TYPE $OVS_TUNNEL_OPTIONS ${OVS_EXTRA+-- $OVS_EXTRA}
-               ${OTHERSCRIPT} ${CONFIG} ${2}
+               ;;
+       OVSPatchPort)
+               ifup_ovs_bridge
+               ovs-vsctl -t ${TIMEOUT} -- --may-exist add-port "$OVS_BRIDGE" "$DEVICE" $OVS_OPTIONS -- set Interface "$DEVICE" type=patch options:peer="${OVS_PATCH_PEER}" ${OVS_EXTRA+-- $OVS_EXTRA}
+               ;;
+       OVSDPDKPort)
+               ifup_ovs_bridge
+               ovs-vsctl -t ${TIMEOUT} -- --may-exist add-port "$OVS_BRIDGE" "$DEVICE" $OVS_OPTIONS -- set Interface "$DEVICE" type=dpdk ${OVS_EXTRA+-- $OVS_EXTRA}
+               ;;
+       OVSDPDKRPort)
+               ifup_ovs_bridge
+               ovs-vsctl -t ${TIMEOUT} -- --may-exist add-port "$OVS_BRIDGE" "$DEVICE" $OVS_OPTIONS -- set Interface "$DEVICE" type=dpdkr ${OVS_EXTRA+-- $OVS_EXTRA}
+               ;;
+       OVSDPDVhostPort)
+               ifup_ovs_bridge
+               ovs-vsctl -t ${TIMEOUT} -- --may-exist add-port "$OVS_BRIDGE" "$DEVICE" $OVS_OPTIONS -- set Interface "$DEVICE" type=dpdkvhost ${OVS_EXTRA+-- $OVS_EXTRA}
+               ;;
+       OVSDPDKVhostUserPort)
+               ifup_ovs_bridge
+               ovs-vsctl -t ${TIMEOUT} -- --may-exist add-port "$OVS_BRIDGE" "$DEVICE" $OVS_OPTIONS -- set Interface "$DEVICE" type=dpdkvhostuser ${OVS_EXTRA+-- $OVS_EXTRA}
                ;;
        *)
                echo $"Invalid OVS interface type $TYPE"