[openvswitch] rhel: Prevent duplicate ifup calls.
Flavio Leitner
fbl at fedoraproject.org
Mon Oct 28 22:50:31 UTC 2013
commit 0455eaaccfbb3cccdbfaedc17feaa26f8f21204e
Author: Flavio Leitner <fbl at redhat.com>
Date: Mon Oct 28 17:15:26 2013 -0200
rhel: Prevent duplicate ifup calls.
applied upstream commit 5b56f96aaad4a55a26576e0610fb49bde448dabe
Signed-off-by: Flavio Leitner <fbl at redhat.com>
README.RHEL | 131 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
ifup-ovs | 38 +++++++++++++---
openvswitch.spec | 13 +++++-
3 files changed, 174 insertions(+), 8 deletions(-)
---
diff --git a/README.RHEL b/README.RHEL
new file mode 100644
index 0000000..ba2774a
--- /dev/null
+++ b/README.RHEL
@@ -0,0 +1,131 @@
+Red Hat network scripts integration
+-----------------------------------
+
+The RPM packages for Open vSwitch provide some integration with Red
+Hat's network scripts. Using this integration is optional.
+
+To use the integration for a Open vSwitch bridge or interface named
+<name>, create or edit /etc/sysconfig/network-scripts/ifcfg-<name>.
+This is a shell script that consists of a series of VARIABLE=VALUE
+assignments. The following OVS-specific variable names are supported:
+
+ - DEVICETYPE: Always set to "ovs".
+
+ - TYPE: If this is "OVSBridge", then this file represents an OVS
+ bridge named <name>. Otherwise, it represents a port on an OVS
+ bridge and TYPE must have one of the following values:
+
+ * "OVSPort", if <name> is a physical port (e.g. eth0) or
+ virtual port (e.g. vif1.0).
+
+ * "OVSIntPort", if <name> is an internal port (e.g. a tagged
+ VLAN).
+
+ * "OVSBond", if <name> is an OVS bond.
+
+ - OVS_BRIDGE: If TYPE is anything other than "OVSBridge", set to
+ the name of the OVS bridge to which the port should be attached.
+
+ - OVS_OPTIONS: Optionally, extra options to set in the "Port"
+ table when adding the port to the bridge, as a sequence of
+ column[:key]=value options. For example, "tag=100" to make the
+ port an access port for VLAN 100. See the documentation of
+ "add-port" in ovs-vsctl(8) for syntax and the section on the
+ Port table in ovs-vswitchd.conf.db(5) for available options.
+
+ - OVS_EXTRA: Optionally, additional ovs-vsctl commands, separated
+ by "--" (double dash).
+
+ - BOND_IFACES: For "OVSBond" interfaces, a list of physical
+ interfaces to bond together.
+
+Note
+----
+
+* "ifdown" on a bridge will not bring individual ports on the bridge
+down. "ifup" on a bridge will not add ports to the bridge. This
+behavior should be compatible with standard bridges (with
+TYPE=Bridge).
+
+* If 'ifup' on an interface is called multiple times, one can see
+"RTNETLINK answers: File exists" printed on the console. This comes from
+ifup-eth trying to add zeroconf route multiple times and is harmless.
+
+Examples
+--------
+
+Standalone bridge:
+
+==> ifcfg-ovsbridge0 <==
+DEVICE=ovsbridge0
+ONBOOT=yes
+DEVICETYPE=ovs
+TYPE=OVSBridge
+BOOTPROTO=static
+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:
+
+==> ifcfg-eth0 <==
+DEVICE=eth0
+ONBOOT=yes
+DEVICETYPE=ovs
+TYPE=OVSPort
+OVS_BRIDGE=ovsbridge0
+BOOTPROTO=none
+HOTPLUG=no
+
+
+Tagged VLAN interface on top of ovsbridge0:
+
+==> ifcfg-vlan100 <==
+DEVICE=vlan100
+ONBOOT=yes
+DEVICETYPE=ovs
+TYPE=OVSIntPort
+BOOTPROTO=static
+IPADDR=A.B.C.D
+NETMASK=X.Y.Z.0
+OVS_BRIDGE=ovsbridge0
+OVS_OPTIONS="tag=100"
+OVS_EXTRA="set Interface $DEVICE external-ids:iface-id=$(hostname -s)-$DEVICE-vif"
+HOTPLUG=no
+
+
+Bonding:
+
+==> ifcfg-bond0 <==
+DEVICE=bond0
+ONBOOT=yes
+DEVICETYPE=ovs
+TYPE=OVSBond
+OVS_BRIDGE=ovsbridge0
+BOOTPROTO=none
+BOND_IFACES="gige-1b-0 gige-1b-1 gige-21-0 gige-21-1"
+OVS_OPTIONS="bond_mode=balance-tcp lacp=active"
+HOTPLUG=no
+
+==> ifcfg-gige-* <==
+DEVICE=gige-*
+ONBOOT=yes
+HOTPLUG=no
+
+Reporting Bugs
+--------------
+
+Please report problems to bugs at openvswitch.org.
diff --git a/ifup-ovs b/ifup-ovs
index 6748908..4d7909a 100644
--- a/ifup-ovs
+++ b/ifup-ovs
@@ -34,7 +34,7 @@ if [ ! -x ${OTHERSCRIPT} ]; then
OTHERSCRIPT="/etc/sysconfig/network-scripts/ifup-eth"
fi
-check_recursion()
+check_recursion ()
{
[ -n "${UPPEDSTACK}" ] && for _r in ${UPPEDSTACK}; do
[ "$_r" = "$1" ] && return 1
@@ -43,6 +43,13 @@ check_recursion()
return 0
}
+ifup_ovs_bridge ()
+{
+ if ovs-vsctl br-exists "${OVS_BRIDGE}"; then :; else
+ /sbin/ifup "${OVS_BRIDGE}"
+ fi
+}
+
if [ -z "${UPPEDSTACK}" ]; then
UPPEDSTACK="${DEVICE}"
fi
@@ -65,7 +72,22 @@ fi
case "$TYPE" in
OVSBridge)
- ovs-vsctl -t ${TIMEOUT} -- --may-exist add-br "$DEVICE" $OVS_OPTIONS ${OVS_EXTRA+-- $OVS_EXTRA}
+ # 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 check_device_down "${DEVICE}"; then
+ ovs-vsctl -t ${TIMEOUT} -- --may-exist add-br "$DEVICE" $OVS_OPTIONS \
+ ${OVS_EXTRA+-- $OVS_EXTRA}
+ else
+ OVSBRIDGECONFIGURED="yes"
+ 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
+ # it is being configured after the port has been configured.
+ # The "OVSINTF" is set only after the port is configured.
if [ "${OVSBOOTPROTO}" = "dhcp" ] && [ -n "${OVSINTF}" ]; then
case " ${OVSDHCPINTERFACES} " in
*" ${OVSINTF} "*)
@@ -73,25 +95,29 @@ case "$TYPE" in
;;
esac
fi
- if [ "${OVSBOOTPROTO}" != "dhcp" ] && [ -z "${OVSINTF}" ]; then
+
+ # When dhcp is not enabled, it is possible that someone may want
+ # a standalone bridge (i.e it may not have any ports). Configure it.
+ if [ "${OVSBOOTPROTO}" != "dhcp" ] && [ -z "${OVSINTF}" ] && \
+ [ "${OVSBRIDGECONFIGURED}" != "yes" ]; then
${OTHERSCRIPT} ${CONFIG}
fi
[ -n "${STP}" ] && ovs-vsctl --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}
OVSINTF=${DEVICE} /sbin/ifup "$OVS_BRIDGE"
;;
OVSIntPort)
- /sbin/ifup "$OVS_BRIDGE"
+ 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}
;;
OVSBond)
- /sbin/ifup "$OVS_BRIDGE"
+ ifup_ovs_bridge
for _iface in $BOND_IFACES; do
/sbin/ifup ${_iface}
done
diff --git a/openvswitch.spec b/openvswitch.spec
index abd5377..0939ed6 100644
--- a/openvswitch.spec
+++ b/openvswitch.spec
@@ -19,7 +19,7 @@
Name: openvswitch
Version: 1.11.0
-Release: 5%{?dist}
+Release: 6%{?dist}
Summary: Open vSwitch daemon/database/utilities
# Nearly all of openvswitch is ASL 2.0. The bugtool is LGPLv2+, and the
@@ -37,6 +37,7 @@ Source5: ifdown-ovs
Source6: ovsdbmonitor.desktop
Source7: openvswitch-nonetwork.service
Source8: sysconfig.template
+Source9: README.RHEL
BuildRequires: systemd-units openssl openssl-devel
BuildRequires: python python-twisted-core python-zope-interface PyQt4
@@ -131,6 +132,9 @@ install -d -m 0755 $RPM_BUILD_ROOT%{python_sitelib}
mv $RPM_BUILD_ROOT/%{_datadir}/openvswitch/python/* $RPM_BUILD_ROOT%{python_sitelib}
rmdir $RPM_BUILD_ROOT/%{_datadir}/openvswitch/python/
+mkdir -p $RPM_BUILD_ROOT%{_docdir}/%{name}-%{version}
+install -p -m 0644 %{SOURCE9} $RPM_BUILD_ROOT%{_docdir}/%{name}-%{version}
+
# Get rid of stuff we don't want to make RPM happy.
rm -f \
$RPM_BUILD_ROOT%{_sbindir}/ovs-vlan-bug-workaround \
@@ -237,8 +241,9 @@ rm -rf $RPM_BUILD_ROOT%{_docdir}/ovsdbmonitor
# /usr/share/openvswitch/scripts/ovs-bugtool* are LGPLv2+
%{_datadir}/openvswitch/
%{_sharedstatedir}/openvswitch
+%{_docdir}/%{name}-%{version}/README.RHEL
# see COPYING for full licensing details
-%doc COPYING DESIGN INSTALL.SSL NOTICE README WHY-OVS rhel/README.RHEL
+%doc COPYING DESIGN INSTALL.SSL NOTICE README WHY-OVS
%files -n python-openvswitch
%{python_sitelib}/ovs
@@ -268,6 +273,10 @@ rm -rf $RPM_BUILD_ROOT%{_docdir}/ovsdbmonitor
%changelog
+* Mon Oct 28 2013 Flavio Leitner <fbl at redhat.com> - 1.11.0-6
+- applied upstream commit 5b56f96aaad4a55a26576e0610fb49bde448dabe
+ rhel: Prevent duplicate ifup calls.
+
* Mon Oct 28 2013 Flavio Leitner <fbl at redhat.com> - 1.11.0-5
- applied upstream commit 79416011612541d103a1d396d888bb8c84eb1da4
rhel: Return an exit value of 0 for ifup-ovs.
More information about the scm-commits
mailing list