diff --git a/.gitignore b/.gitignore index e69de29..e6b7380 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1 @@ +/openvswitch-1.4.0.tar.gz diff --git a/ifdown-ovs b/ifdown-ovs new file mode 100644 index 0000000..3b5252d --- /dev/null +++ b/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/ifup-ovs b/ifup-ovs new file mode 100644 index 0000000..7074c07 --- /dev/null +++ b/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/openvswitch-configure-ovskmod-var-autoconfd.patch b/openvswitch-configure-ovskmod-var-autoconfd.patch new file mode 100644 index 0000000..1f59232 --- /dev/null +++ b/openvswitch-configure-ovskmod-var-autoconfd.patch @@ -0,0 +1,122 @@ +This is the autoconf'd result of applying +openvswitch-configure-ovskmod-var.patch. +It updates configure and .in files directly, +rather than their sources. + +diff -aru openvswitch-1.4.0.orig/configure openvswitch-1.4.0/configure +--- openvswitch-1.4.0.orig/configure 2012-01-30 23:09:16.000000000 -0800 ++++ openvswitch-1.4.0/configure 2012-02-29 21:23:09.397779430 -0800 +@@ -599,6 +607,7 @@ + am__EXEEXT_TRUE + LTLIBOBJS + LIBOBJS ++OVSKMOD + LINUX_ENABLED_FALSE + LINUX_ENABLED_TRUE + KBUILD +@@ -757,7 +766,8 @@ + PKG_CONFIG_LIBDIR + SSL_CFLAGS + SSL_LIBS +-KARCH' ++KARCH ++OVSKMOD' + + + # Initialize some variables set by options. +@@ -1417,6 +1427,7 @@ + SSL_CFLAGS C compiler flags for SSL, overriding pkg-config + SSL_LIBS linker flags for SSL, overriding pkg-config + KARCH Kernel Architecture String ++ OVSKMOD Open vSwitch kernel module name (default openvswitch_mod) + + Use these variables to override the choices made by `configure' or to help + it to find libraries and programs with nonstandard names/locations. +@@ -7882,6 +7893,12 @@ + + + ++ ++if test "X$OVSKMOD" = "X"; then ++ OVSKMOD=openvswitch_mod ++fi ++ ++ + ac_config_files="$ac_config_files Makefile datapath/Makefile datapath/linux/Kbuild datapath/linux/Makefile datapath/linux/Makefile.main tests/atlocal" + + +diff -aru openvswitch-1.4.0.orig/datapath/Makefile.in openvswitch-1.4.0/datapath/Makefile.in +--- openvswitch-1.4.0.orig/datapath/Makefile.in 2012-01-30 23:09:16.000000000 -0800 ++++ openvswitch-1.4.0/datapath/Makefile.in 2012-02-29 21:23:26.744028440 -0800 +@@ -128,6 +128,7 @@ + MAKEINFO = @MAKEINFO@ + MKDIR_P = @MKDIR_P@ + OBJEXT = @OBJEXT@ ++OVSKMOD = @OVSKMOD@ + PACKAGE = @PACKAGE@ + PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ + PACKAGE_NAME = @PACKAGE_NAME@ +diff -aru openvswitch-1.4.0.orig/Makefile.in openvswitch-1.4.0/Makefile.in +--- openvswitch-1.4.0.orig/Makefile.in 2012-01-30 23:09:16.000000000 -0800 ++++ openvswitch-1.4.0/Makefile.in 2012-02-29 21:23:27.070033119 -0800 +@@ -875,6 +875,7 @@ + MAKEINFO = @MAKEINFO@ + MKDIR_P = @MKDIR_P@ + OBJEXT = @OBJEXT@ ++OVSKMOD = @OVSKMOD@ + PACKAGE = @PACKAGE@ + PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ + PACKAGE_NAME = @PACKAGE_NAME@ +@@ -3634,6 +3635,7 @@ + -e 's,[@]RUNDIR[@],$(RUNDIR),g' \ + -e 's,[@]VERSION[@],$(VERSION),g' \ + -e 's,[@]BUILDNR[@],$(BUILDNR),g' \ ++ -e 's,[@]OVSKMOD[@],$(OVSKMOD),g' \ + -e 's,[@]localstatedir[@],$(localstatedir),g' \ + -e 's,[@]pkgdatadir[@],$(pkgdatadir),g' \ + -e 's,[@]sysconfdir[@],$(sysconfdir),g' \ +diff -aru openvswitch-1.4.0.orig/utilities/ovs-ctl.in openvswitch-1.4.0/utilities/ovs-ctl.in +--- openvswitch-1.4.0.orig/utilities/ovs-ctl.in 2012-01-30 23:08:18.000000000 -0800 ++++ openvswitch-1.4.0/utilities/ovs-ctl.in 2012-02-29 21:22:49.206489585 -0800 +@@ -31,14 +31,14 @@ + ## ----- ## + + insert_openvswitch_mod_if_required () { +- # If openvswitch_mod is already loaded then we're done. +- test -e /sys/module/openvswitch_mod && return 0 ++ # If @OVSKMOD@ is already loaded then we're done. ++ test -e /sys/module/@OVSKMOD@ && return 0 + +- # Load openvswitch_mod. If that's successful then we're done. +- action "Inserting openvswitch module" modprobe openvswitch_mod && return 0 ++ # Load @OVSKMOD@. If that's successful then we're done. ++ action "Inserting openvswitch module" modprobe @OVSKMOD@ && return 0 + + # If the bridge module is loaded, then that might be blocking +- # openvswitch_mod. Try to unload it, if there are no bridges. ++ # @OVSKMOD@. Try to unload it, if there are no bridges. + test -e /sys/module/bridge || return 1 + bridges=`echo /sys/class/net/*/bridge | sed 's,/sys/class/net/,,g;s,/bridge,,g'` + if test "$bridges" != "*"; then +@@ -47,8 +47,8 @@ + fi + action "removing bridge module" rmmod bridge || return 1 + +- # Try loading openvswitch_mod again. +- action "Inserting openvswitch module" modprobe openvswitch_mod ++ # Try loading @OVSKMOD@ again. ++ action "Inserting openvswitch module" modprobe @OVSKMOD@ + } + + insert_brcompat_mod_if_required () { +@@ -285,8 +285,8 @@ + if test -e /sys/module/brcompat_mod; then + action "Removing brcompat module" rmmod brcompat_mod + fi +- if test -e /sys/module/openvswitch_mod; then +- action "Removing openvswitch module" rmmod openvswitch_mod ++ if test -e /sys/module/@OVSKMOD@; then ++ action "Removing openvswitch module" rmmod @OVSKMOD@ + fi + + start diff --git a/openvswitch-configure-ovskmod-var.patch b/openvswitch-configure-ovskmod-var.patch new file mode 100644 index 0000000..45d6c5f --- /dev/null +++ b/openvswitch-configure-ovskmod-var.patch @@ -0,0 +1,73 @@ +diff --git a/Makefile.am b/Makefile.am +index 46de7fb..dc4a609 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -101,6 +101,7 @@ SUFFIXES += .in + -e 's,[@]RUNDIR[@],$(RUNDIR),g' \ + -e 's,[@]VERSION[@],$(VERSION),g' \ + -e 's,[@]BUILDNR[@],$(BUILDNR),g' \ ++ -e 's,[@]OVSKMOD[@],$(OVSKMOD),g' \ + -e 's,[@]localstatedir[@],$(localstatedir),g' \ + -e 's,[@]pkgdatadir[@],$(pkgdatadir),g' \ + -e 's,[@]sysconfdir[@],$(sysconfdir),g' \ +diff --git a/configure.ac b/configure.ac +--- a/configure.ac ++++ b/configure.ac +@@ -93,6 +94,12 @@ AC_ARG_VAR(KARCH, [Kernel Architecture String]) + AC_SUBST(KARCH) + OVS_CHECK_LINUX + ++AC_ARG_VAR(OVSKMOD, [Open vSwitch kernel module name (default openvswitch_mod)]) ++if test "X$OVSKMOD" = "X"; then ++ OVSKMOD=openvswitch_mod ++fi ++AC_SUBST(OVSKMOD) ++ + AC_CONFIG_FILES([Makefile + datapath/Makefile + datapath/linux/Kbuild +diff --git a/utilities/ovs-ctl.in b/utilities/ovs-ctl.in +--- a/utilities/ovs-ctl.in ++++ b/utilities/ovs-ctl.in +@@ -31,14 +31,14 @@ done + ## ----- ## + + insert_openvswitch_mod_if_required () { +- # If openvswitch_mod is already loaded then we're done. +- test -e /sys/module/openvswitch_mod && return 0 ++ # If @OVSKMOD@ is already loaded then we're done. ++ test -e /sys/module/@OVSKMOD@ && return 0 + +- # Load openvswitch_mod. If that's successful then we're done. +- action "Inserting openvswitch module" modprobe openvswitch_mod && return 0 ++ # Load @OVSKMOD@. If that's successful then we're done. ++ action "Inserting openvswitch module" modprobe @OVSKMOD@ && return 0 + + # If the bridge module is loaded, then that might be blocking +- # openvswitch_mod. Try to unload it, if there are no bridges. ++ # @OVSKMOD@. Try to unload it, if there are no bridges. + test -e /sys/module/bridge || return 1 + bridges=`echo /sys/class/net/*/bridge | sed 's,/sys/class/net/,,g;s,/bridge,,g'` + if test "$bridges" != "*"; then +@@ -47,8 +47,8 @@ insert_openvswitch_mod_if_required () { + fi + action "removing bridge module" rmmod bridge || return 1 + +- # Try loading openvswitch_mod again. +- action "Inserting openvswitch module" modprobe openvswitch_mod ++ # Try loading @OVSKMOD@ again. ++ action "Inserting openvswitch module" modprobe @OVSKMOD@ + } + + insert_brcompat_mod_if_required () { +@@ -285,8 +285,8 @@ force_reload_kmod () { + if test -e /sys/module/brcompat_mod; then + action "Removing brcompat module" rmmod brcompat_mod + fi +- if test -e /sys/module/openvswitch_mod; then +- action "Removing openvswitch module" rmmod openvswitch_mod ++ if test -e /sys/module/@OVSKMOD@; then ++ action "Removing openvswitch module" rmmod @OVSKMOD@ + fi + + start diff --git a/openvswitch.init b/openvswitch.init new file mode 100644 index 0000000..9f1506c --- /dev/null +++ b/openvswitch.init @@ -0,0 +1,94 @@ +#!/bin/sh +# +# openvswitch +# +# chkconfig: 2345 09 91 +# description: Manage Open vSwitch kernel modules and user-space daemons + +# Copyright (C) 2009, 2010, 2011 Nicira Networks, Inc. +# +# 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. +### BEGIN INIT INFO +# Provides: openvswitch-switch +# Required-Start: +# Required-Stop: +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Open vSwitch switch +### END INIT INFO + +. /usr/share/openvswitch/scripts/ovs-lib || exit 1 +test -e /etc/sysconfig/openvswitch && . /etc/sysconfig/openvswitch + +start () { + set $ovs_ctl ${1-start} + set "$@" --system-id=random + if test X"$FORCE_COREFILES" != X; then + set "$@" --force-corefiles="$FORCE_COREFILES" + fi + if test X"$OVSDB_SERVER_PRIORITY" != X; then + set "$@" --ovsdb-server-priority="$OVSDB_SERVER_PRIORITY" + fi + if test X"$VSWITCHD_PRIORITY" != X; then + set "$@" --ovs-vswitchd-priority="$VSWITCHD_PRIORITY" + fi + if test X"$VSWITCHD_MLOCKALL" != X; then + set "$@" --mlockall="$VSWITCHD_MLOCKALL" + fi + if test X"$BRCOMPAT" = Xyes; then + set "$@" --brcompat + fi + "$@" + + $ovs_ctl --protocol=gre enable-protocol + + touch /var/lock/subsys/openvswitch +} + +stop () { + $ovs_ctl stop + rm -f /var/lock/subsys/openvswitch +} + +ovs_ctl=/usr/share/openvswitch/scripts/ovs-ctl +case $1 in + start) + start + ;; + stop) + stop + ;; + restart) + stop + start + ;; + reload|force-reload) + # Nothing to do. + ;; + status) + $ovs_ctl status + ;; + version) + $ovs_ctl version + ;; + force-reload-kmod) + start force-reload-kmod + ;; + help) + printf "$0 [start|stop|restart|reload|force-reload|status|version|force-reload-kmod]\n" + ;; + *) + printf "Unknown command: $1\n" + exit 1 + ;; +esac diff --git a/openvswitch.logrotate b/openvswitch.logrotate new file mode 100644 index 0000000..1a08fa9 --- /dev/null +++ b/openvswitch.logrotate @@ -0,0 +1,20 @@ +# Copyright (C) 2009, 2010, 2011 Nicira Networks, Inc. +# +# Copying and distribution of this file, with or without modification, +# are permitted in any medium without royalty provided the copyright +# notice and this notice are preserved. This file is offered as-is, +# without warranty of any kind. + +/var/log/openvswitch/*.log { + sharedscripts + missingok + postrotate + # Tell Open vSwitch daemons to reopen their log files + if [ -e /var/run/openvswitch/ovs-vswitchd.pid ]; then + /usr/bin/ovs-appctl -t ovs-vswitchd vlog/reopen + fi + if [ -e /var/run/openvswitch/ovsdb-server.pid ]; then + /usr/bin/ovs-appctl -t ovsdb-server vlog/reopen + fi + endscript +} diff --git a/openvswitch.service b/openvswitch.service new file mode 100644 index 0000000..f39d7e6 --- /dev/null +++ b/openvswitch.service @@ -0,0 +1,12 @@ +[Unit] +Description=Open vSwitch +After=syslog.target network.target + +[Service] +Type=oneshot +ExecStart=/usr/share/openvswitch/scripts/openvswitch.init start +ExecStop=/usr/share/openvswitch/scripts/openvswitch.init stop +RemainAfterExit=yes + +[Install] +WantedBy=multi-user.target diff --git a/openvswitch.spec b/openvswitch.spec new file mode 100644 index 0000000..74a8c58 --- /dev/null +++ b/openvswitch.spec @@ -0,0 +1,210 @@ +Name: openvswitch +Version: 1.4.0 +Release: 2%{?dist} +Summary: Open vSwitch daemon/database/utilities + +# Nearly all of openvswitch is ASL 2.0. The bugtool is LGPLv2+, and the +# lib/sflow*.[ch] files are SISSL +# datapath/ is GPLv2 (although not built into any of the binary packages) +# python/compat is Python (although not built into any of the binary packages) +License: ASL 2.0 and LGPLv2+ and SISSL +URL: http://openvswitch.org +Source0: http://openvswitch.org/releases/%{name}-%{version}.tar.gz +Source1: openvswitch.service +Source2: openvswitch.init +Source3: openvswitch.logrotate +Source4: ifup-ovs +Source5: ifdown-ovs +Source6: ovsdbmonitor.desktop +Source7: openvswitch-configure-ovskmod-var.patch +Source8: ovsdbmonitor-move-to-its-own-data-directory.patch +# make the kmod name configurable since Fedora kernel ships openvswitch module +# Source7 is not applied, it's used to generate patch0 +Patch0: openvswitch-configure-ovskmod-var-autoconfd.patch +# mv ovsdbmonitordir. Source8 (accepted upstream) is source for patch1 +Patch1: ovsdbmonitor-move-to-its-own-data-directory-automaked.patch + +BuildRequires: systemd-units openssl-devel +BuildRequires: python python-twisted-core python-twisted-conch python-zope-interface PyQt4 +BuildRequires: desktop-file-utils +BuildRequires: groff graphviz + +Requires: openssl iproute module-init-tools + +Requires(post): systemd-units +Requires(preun): systemd-units + +%description +Open vSwitch provides standard network bridging functions and +support for the OpenFlow protocol for remote per-flow control of +traffic. + +%package -n python-openvswitch +Summary: Open vSwitch python bindings +License: ASL 2.0 +BuildArch: noarch +Requires: python + +%description -n python-openvswitch +Python bindings for the Open vSwitch database + +%package -n ovsdbmonitor +Summary: Open vSwitch graphical monitoring tool +License: ASL 2.0 +BuildArch: noarch +Requires: python-openvswitch = %{version}-%{release} +Requires: python python-twisted-core python-twisted-conch python-zope-interface PyQt4 + +%description -n ovsdbmonitor +A GUI tool for monitoring and troubleshooting local or remote Open +vSwitch installations. It presents GUI tables that graphically represent +an Open vSwitch kernel flow table (similar to "ovs-dpctl dump-flows") +and Open vSwitch database contents (similar to "ovs-vsctl list