rhel: Enable DHCP in redhat network scripts.
authorGurucharan Shetty <gshetty@nicira.com>
Tue, 31 Jan 2012 04:17:53 +0000 (20:17 -0800)
committerGurucharan Shetty <gshetty@nicira.com>
Tue, 31 Jan 2012 22:25:39 +0000 (14:25 -0800)
The current network-script, ifup-ovs  does not work well if you
enable DHCP on the OVS. It will work if we name the bridge
alphabetically greater than the underlying physical interfaces.
Even then, it will do multiple DHCP attempts slowing down the boot
up process.

This patch allows DHCP on an OVS bridge.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
rhel/README.RHEL
rhel/etc_sysconfig_network-scripts_ifup-ovs

index 3e682b39fc972e001ef533f755944c45aa7f8998..b97fb6c0336ac91e476d53bde8236f336811dd71 100644 (file)
@@ -62,6 +62,18 @@ IPADDR=A.B.C.D
 NETMASK=X.Y.Z.0
 HOTPLUG=no
 
+Enable DHCP on the bridge:
+* Needs OVSBOOTPROTO instead of BOOTPROTO.
+* All the interfaces that can reach the DHCP server
+as a comma separated list in OVSDHCPINTERFACES.
+
+DEVICE=ovsbridge0
+ONBOOT=yes
+DEVICETYPE=ovs
+TYPE=OVSBridge
+OVSBOOTPROTO="dhcp"
+OVSDHCPINTERFACES="eth0"
+HOTPLUG=no
 
 Adding physical eth0 to ovsbridge0 described above:
 
index 7074c072ed3fb49a7cad7060680cad026210a867..18cebc4ddcab21ad5db6a561f157faea4507b8dd 100755 (executable)
@@ -36,12 +36,25 @@ fi
 case "$TYPE" in
        OVSBridge)
                ovs-vsctl -- --may-exist add-br "$DEVICE" $OVS_OPTIONS ${OVS_EXTRA+-- $OVS_EXTRA}
-               ${OTHERSCRIPT} ${CONFIG} ${2}
+               if [ "${OVSBOOTPROTO}" = "dhcp" ] && [ -n "${OVSINTF}" ]; then
+                       case ${OVSDHCPINTERFACES} in
+                               ${OVSINTF#ifcfg-} | \
+                               "${OVSINTF#ifcfg-},"* | \
+                               *",${OVSINTF#ifcfg-}" | \
+                               *",${OVSINTF#ifcfg-},"*)
+                                       BOOTPROTO=dhcp ${OTHERSCRIPT} ${CONFIG}
+                               ;;
+                       esac
+               fi
+               if [ "${OVSBOOTPROTO}" != "dhcp" ] && [ -z "${OVSINTF}" ]; then
+                       ${OTHERSCRIPT} ${CONFIG}
+               fi
                ;;
        OVSPort)
                /sbin/ifup "$OVS_BRIDGE"
                ${OTHERSCRIPT} ${CONFIG} ${2}
                ovs-vsctl -- --may-exist add-port "$OVS_BRIDGE" "$DEVICE" $OVS_OPTIONS ${OVS_EXTRA+-- $OVS_EXTRA}
+               OVSINTF=${CONFIG} /sbin/ifup "$OVS_BRIDGE"
                ;;
        OVSIntPort)
                /sbin/ifup "$OVS_BRIDGE"
@@ -55,6 +68,7 @@ case "$TYPE" in
                done
                ovs-vsctl -- --fake-iface add-bond "$OVS_BRIDGE" "$DEVICE" ${BOND_IFACES} $OVS_OPTIONS ${OVS_EXTRA+-- $OVS_EXTRA}
                ${OTHERSCRIPT} ${CONFIG} ${2}
+               OVSINTF=${CONFIG} /sbin/ifup "$OVS_BRIDGE"
                ;;
        *)
                echo $"Invalid OVS interface type $TYPE"