From 0fb426263e7834f7403eefd860cf5d36d43f8c45 Mon Sep 17 00:00:00 2001 From: "Alexey I. Froloff" Date: Thu, 3 Nov 2011 10:30:04 -0700 Subject: [PATCH] rhel: Add Red Hat network scripts integration. [Spec file changes and some documentation updates by Ben Pfaff.] --- AUTHORS | 1 + INSTALL.RHEL | 8 ++ NEWS | 1 + rhel/README.RHEL | 115 ++++++++++++++++++ rhel/automake.mk | 3 + rhel/etc_sysconfig_network-scripts_ifdown-ovs | 53 ++++++++ rhel/etc_sysconfig_network-scripts_ifup-ovs | 63 ++++++++++ rhel/openvswitch.spec.in | 27 ++-- 8 files changed, 260 insertions(+), 11 deletions(-) create mode 100644 rhel/README.RHEL create mode 100755 rhel/etc_sysconfig_network-scripts_ifdown-ovs create mode 100755 rhel/etc_sysconfig_network-scripts_ifup-ovs diff --git a/AUTHORS b/AUTHORS index 4d10e8683..00aa15e31 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,6 +1,7 @@ The following people, in alphabetical order, have either authored or signed off on commits in the Open vSwitch version control repository. +Alexey I. Froloff raorn@altlinux.org Andrew Evans aevans@nicira.com Andrew Lambeth wal@nicira.com Andy Southgate andy.southgate@citrix.com diff --git a/INSTALL.RHEL b/INSTALL.RHEL index b4523835b..039a85703 100644 --- a/INSTALL.RHEL +++ b/INSTALL.RHEL @@ -64,6 +64,14 @@ RHEL. On RHEL 5, the default RPM source directory is in this example: "kmod-openvswitch", "kmod-openvswitch-debug", and "kmod-openvswitch-kdump". +Red Hat Network Scripts Integration +----------------------------------- + +Simple integration with Red Hat network scripts has been implemented. +Please read rhel/README.RHEL in the source tree or +/usr/share/doc/openvswitch/README.RHEL in the installed openvswitch +package for details. + Reporting Bugs -------------- diff --git a/NEWS b/NEWS index 30714c500..8bb45005c 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,7 @@ post-v1.3.0 - Added ability to modify TTL in IPv4. - ovs-appctl: - New "fdb/flush" command to flush bridge's MAC learning table. + - RHEL packaging now supports integration with Red Hat network scripts. v1.3.0 - xx xxx xxxx ------------------------ diff --git a/rhel/README.RHEL b/rhel/README.RHEL new file mode 100644 index 000000000..e6617ab71 --- /dev/null +++ b/rhel/README.RHEL @@ -0,0 +1,115 @@ +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 +, create or edit /etc/sysconfig/network-scripts/ifcfg-. +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 . Otherwise, it represents a port on an OVS + bridge and TYPE must have one of the following values: + + * "OVSPort", if is a physical port (e.g. eth0) or + virtual port (e.g. vif1.0). + + * "OVSIntPort", if is an internal port (e.g. a tagged + VLAN). + + * "OVSBond", if 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). + +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 + + +Adding physical eth0 to ovsbridge0 described above: + +==> ifcfg-eth0 <== +DEVICE=eth0 +ONBOOT=yes +DEVICETYPE=ovs +TYPE=OVSPort +OVS_BRIDGE=internet +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@openvswitch.org. diff --git a/rhel/automake.mk b/rhel/automake.mk index d3c089b5d..368254109 100644 --- a/rhel/automake.mk +++ b/rhel/automake.mk @@ -6,9 +6,12 @@ # without warranty of any kind. EXTRA_DIST += \ + rhel/README.RHEL \ rhel/automake.mk \ rhel/etc_init.d_openvswitch \ rhel/etc_logrotate.d_openvswitch \ + rhel/etc_sysconfig_network-scripts_ifdown-ovs \ + rhel/etc_sysconfig_network-scripts_ifup-ovs \ rhel/kmodtool-openvswitch-el5.sh \ rhel/openvswitch-kmod-rhel5.spec \ rhel/openvswitch-kmod-rhel5.spec.in \ diff --git a/rhel/etc_sysconfig_network-scripts_ifdown-ovs b/rhel/etc_sysconfig_network-scripts_ifdown-ovs new file mode 100755 index 000000000..3b5252d7a --- /dev/null +++ b/rhel/etc_sysconfig_network-scripts_ifdown-ovs @@ -0,0 +1,53 @@ +#!/bin/bash + +# Copyright (c) 2011 Alexey I. Froloff. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +. /etc/init.d/functions + +cd /etc/sysconfig/network-scripts +. ./network-functions + +[ -f ../network ] && . ../network + +CONFIG=${1} + +source_config + +. /etc/sysconfig/network + +OTHERSCRIPT="/etc/sysconfig/network-scripts/ifdown-${REAL_DEVICETYPE}" + +if [ ! -x ${OTHERSCRIPT} ]; then + OTHERSCRIPT="/etc/sysconfig/network-scripts/ifdown-eth" +fi + +case "$TYPE" in + OVSBridge) + ${OTHERSCRIPT} ${CONFIG} $2 + retval=$? + ovs-vsctl -- --if-exists del-br "$DEVICE" + ;; + OVSPort|OVSIntPort|OVSBond) + ${OTHERSCRIPT} ${CONFIG} $2 + retval=$? + ovs-vsctl -- --if-exists del-port "$OVS_BRIDGE" "$DEVICE" + ;; + *) + echo $"Invalid OVS interface type $TYPE" + exit 1 + ;; +esac + +exit $retval diff --git a/rhel/etc_sysconfig_network-scripts_ifup-ovs b/rhel/etc_sysconfig_network-scripts_ifup-ovs new file mode 100755 index 000000000..7074c072e --- /dev/null +++ b/rhel/etc_sysconfig_network-scripts_ifup-ovs @@ -0,0 +1,63 @@ +#!/bin/bash + +# Copyright (c) 2011 Alexey I. Froloff. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +. /etc/init.d/functions + +cd /etc/sysconfig/network-scripts +. ./network-functions + +[ -f ../network ] && . ../network + +CONFIG=${1} + +need_config ${CONFIG} + +source_config + +OTHERSCRIPT="/etc/sysconfig/network-scripts/ifup-${REAL_DEVICETYPE}" + +if [ ! -x ${OTHERSCRIPT} ]; then + OTHERSCRIPT="/etc/sysconfig/network-scripts/ifup-eth" +fi + +case "$TYPE" in + OVSBridge) + ovs-vsctl -- --may-exist add-br "$DEVICE" $OVS_OPTIONS ${OVS_EXTRA+-- $OVS_EXTRA} + ${OTHERSCRIPT} ${CONFIG} ${2} + ;; + OVSPort) + /sbin/ifup "$OVS_BRIDGE" + ${OTHERSCRIPT} ${CONFIG} ${2} + ovs-vsctl -- --may-exist add-port "$OVS_BRIDGE" "$DEVICE" $OVS_OPTIONS ${OVS_EXTRA+-- $OVS_EXTRA} + ;; + OVSIntPort) + /sbin/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" + for _iface in $BOND_IFACES; do + /sbin/ifup ${_iface} + done + ovs-vsctl -- --fake-iface add-bond "$OVS_BRIDGE" "$DEVICE" ${BOND_IFACES} $OVS_OPTIONS ${OVS_EXTRA+-- $OVS_EXTRA} + ${OTHERSCRIPT} ${CONFIG} ${2} + ;; + *) + echo $"Invalid OVS interface type $TYPE" + exit 1 + ;; +esac diff --git a/rhel/openvswitch.spec.in b/rhel/openvswitch.spec.in index 2cf9535a5..46f65e237 100644 --- a/rhel/openvswitch.spec.in +++ b/rhel/openvswitch.spec.in @@ -35,17 +35,19 @@ make %{_smp_mflags} %install rm -rf $RPM_BUILD_ROOT make install DESTDIR=$RPM_BUILD_ROOT -install -d -m 755 $RPM_BUILD_ROOT/etc -install -d -m 755 $RPM_BUILD_ROOT/etc/init.d -install -m 755 rhel/etc_init.d_openvswitch \ - $RPM_BUILD_ROOT/etc/init.d/openvswitch -install -d -m 755 $RPM_BUILD_ROOT/etc/sysconfig -install -d -m 755 $RPM_BUILD_ROOT/etc/logrotate.d -install -m 755 rhel/etc_logrotate.d_openvswitch \ - $RPM_BUILD_ROOT/etc/logrotate.d/openvswitch -install -d -m 755 $RPM_BUILD_ROOT/usr/share/openvswitch/scripts -install -m 755 rhel/usr_share_openvswitch_scripts_sysconfig.template \ - $RPM_BUILD_ROOT/usr/share/openvswitch/scripts/sysconfig.template +for base in \ + etc_init.d_openvswitch \ + etc_logrotate.d_openvswitch \ + etc_sysconfig_network-scripts_ifup-ovs \ + etc_sysconfig_network-scripts_ifdown-ovs \ + usr_share_openvswitch_scripts_sysconfig.template; do + dst=$RPM_BUILD_ROOT/$(echo $base | sed 's,_,/,g') + install -d -m755 "$(dirname $dst)" + install rhel/$base "$dst" +done +docdir=$RPM_BUILD_ROOT/usr/share/doc/openvswitch-%{version} +install -d -m755 "$docdir" +install rhel/README.RHEL "$docdir" install python/compat/uuid.py $RPM_BUILD_ROOT/usr/share/openvswitch/python install python/compat/argparse.py $RPM_BUILD_ROOT/usr/share/openvswitch/python @@ -100,6 +102,8 @@ exit 0 %defattr(-,root,root) /etc/init.d/openvswitch /etc/logrotate.d/openvswitch +/etc/sysconfig/network-scripts/ifup-ovs +/etc/sysconfig/network-scripts/ifdown-ovs /etc/openvswitch/bugtool-plugins/* /usr/bin/ovs-appctl /usr/bin/ovs-benchmark @@ -142,4 +146,5 @@ exit 0 /usr/share/openvswitch/scripts/ovs-save /usr/share/openvswitch/scripts/sysconfig.template /usr/share/openvswitch/vswitch.ovsschema +/usr/share/doc/openvswitch-%{version}/README.RHEL /var/lib/openvswitch -- 2.43.0