I tried the solution which we discussed in the mailing list.
The problem with that solution is that we configure the
interfaces multiple times using the ifup-eth script. When we
do that, we get multiple "RTNETLINK answers: File exists"
errors. It occurs because we try to add the same "ip route"
again. According to Redhat, it is harmless and should be
ignored. But I am sure some people won't like their boot
process showing those errors. We will still see those errors
for "static" configuration which is probably OK.

----------cut here------------------------

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 is my attempt to allow DHCP on an OVS.

Signed-off-by: Gurucharan Shetty <[email protected]>
---
 rhel/README.RHEL                            |   12 ++++++++++++
 rhel/etc_sysconfig_network-scripts_ifup-ovs |   17 ++++++++++++++++-
 2 files changed, 28 insertions(+), 1 deletions(-)

diff --git a/rhel/README.RHEL b/rhel/README.RHEL
index 3e682b3..d9b68e4 100644
--- a/rhel/README.RHEL
+++ b/rhel/README.RHEL
@@ -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 space 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:
 
diff --git a/rhel/etc_sysconfig_network-scripts_ifup-ovs 
b/rhel/etc_sysconfig_network-scripts_ifup-ovs
index 7074c07..bd1a1e6 100755
--- a/rhel/etc_sysconfig_network-scripts_ifup-ovs
+++ b/rhel/etc_sysconfig_network-scripts_ifup-ovs
@@ -1,3 +1,4 @@
+t
 #!/bin/bash
 
 # Copyright (c) 2011 Alexey I. Froloff.
@@ -36,12 +37,25 @@ fi
 case "$TYPE" in
        OVSBridge)
                ovs-vsctl -- --may-exist add-br "$DEVICE" $OVS_OPTIONS 
${OVS_EXTRA+-- $OVS_EXTRA}
-               ${OTHERSCRIPT} ${CONFIG} ${2}
+               echo "$2" | grep -q "|post"
+               RETCODE=$?
+               if [ "${OVSBOOTPROTO}" = "dhcp" -a "${RETCODE}" = "0" ]; then
+                       INTF=`echo $2 | sed -e 's/ifcfg-//' -e 's/|post//'`
+                       echo "${OVSDHCPINTERFACES}" | grep -q "$INTF\(\$\| \)"
+                       if [ $? -eq 0 ]; then
+                               export BOOTPROTO="dhcp"
+                               ${OTHERSCRIPT} ${CONFIG}
+                       fi
+               fi
+               if [ "${OVSBOOTPROTO}" != "dhcp" -a "${RETCODE}" != "0" ]; 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}
+               /sbin/ifup "$OVS_BRIDGE" "${CONFIG}|post"
                ;;
        OVSIntPort)
                /sbin/ifup "$OVS_BRIDGE"
@@ -55,6 +69,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}
+               /sbin/ifup "$OVS_BRIDGE" "${CONFIG}|post"
                ;;
        *)
                echo $"Invalid OVS interface type $TYPE"
-- 
1.7.2.5

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

Reply via email to