From: Ben Pfaff Date: Mon, 18 Jul 2011 20:51:12 +0000 (-0700) Subject: debian: Add support for bridge compatibility. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9fc47ed759a82391070dfbda0e06592eb0a18391;p=openvswitch debian: Add support for bridge compatibility. This adds support for bridge compatibility to the generic Open vSwitch init scripts and to the Debian packaging. See https://bugs.launchpad.net/ubuntu/+source/openvswitch/+bug/808224. --- diff --git a/debian/.gitignore b/debian/.gitignore index b681ee41..7b8dffea 100644 --- a/debian/.gitignore +++ b/debian/.gitignore @@ -6,6 +6,7 @@ /files /nicira-switch /openvswitch +/openvswitch-brcompat /openvswitch-common /openvswitch-common.copyright /openvswitch-controller diff --git a/debian/automake.mk b/debian/automake.mk index 26db1cb5..7e166ddc 100644 --- a/debian/automake.mk +++ b/debian/automake.mk @@ -6,6 +6,9 @@ EXTRA_DIST += \ debian/copyright \ debian/copyright.in \ debian/dirs \ + debian/openvswitch-brcompat.install \ + debian/openvswitch-brcompat.manpages \ + debian/openvswitch-brcompat.postinst \ debian/openvswitch-common.dirs \ debian/openvswitch-common.install \ debian/openvswitch-common.manpages \ diff --git a/debian/control b/debian/control index 25f65ce5..1978b73c 100644 --- a/debian/control +++ b/debian/control @@ -81,6 +81,21 @@ Description: Open vSwitch controller implementation . Open vSwitch is a full-featured software-based Ethernet switch. +Package: openvswitch-brcompat +Architecture: linux-any +Depends: ${shlibs:Depends}, openvswitch-switch (= ${binary:Version}) +Recommends: bridge-utils +Description: Open vSwitch bridge compatibility support + openvswitch-brcompat provides a way for applications that use the + Linux bridge to gradually migrate to Open vSwitch. Programs that + ordinarily control the Linux bridge module, such as "brctl", instead + control the Open vSwitch kernel-based switch. + . + Once this package is installed, adding BRCOMPAT=yes in + /etc/default/openvswitch-switch enables bridge compatibility. + . + Open vSwitch is a full-featured software-based Ethernet switch. + Package: openvswitch-dbg Section: debug Architecture: linux-any diff --git a/debian/openvswitch-brcompat.install b/debian/openvswitch-brcompat.install new file mode 100644 index 00000000..fad09f1e --- /dev/null +++ b/debian/openvswitch-brcompat.install @@ -0,0 +1 @@ +_debian/vswitchd/ovs-brcompatd usr/sbin diff --git a/debian/openvswitch-brcompat.manpages b/debian/openvswitch-brcompat.manpages new file mode 100644 index 00000000..2fc0180f --- /dev/null +++ b/debian/openvswitch-brcompat.manpages @@ -0,0 +1 @@ +_debian/vswitchd/ovs-brcompatd.8 diff --git a/debian/openvswitch-brcompat.postinst b/debian/openvswitch-brcompat.postinst new file mode 100755 index 00000000..8113e31a --- /dev/null +++ b/debian/openvswitch-brcompat.postinst @@ -0,0 +1,15 @@ +#!/bin/sh + +# If openvswitch-switch is installed, and then later openvswitch-brcompat is +# installed, make sure that ovs-brcompatd starts. +if test X"$1" = Xconfigure && \ + test -x /etc/init.d/openvswitch-switch && \ + test -e /var/run/openvswitch/ovs-vswitchd.pid; then + invoke-rc.d openvswitch-switch start || exit $? +fi + +#DEBHELPER# + +exit 0 + + diff --git a/debian/openvswitch-switch.init b/debian/openvswitch-switch.init index 36bc2089..a9bf4439 100755 --- a/debian/openvswitch-switch.init +++ b/debian/openvswitch-switch.init @@ -25,22 +25,34 @@ (test -x /usr/sbin/ovs-vswitchd && test -x /usr/bin/ovsdb-server) || exit 0 +. /usr/share/openvswitch/scripts/ovs-lib.sh test -e /etc/default/openvswitch-switch && . /etc/default/openvswitch-switch -ovs_ctl=/usr/share/openvswitch/scripts/ovs-ctl +if test X"$BRCOMPAT" = Xyes && test ! -x /usr/sbin/ovs-brcompatd; then + BRCOMPAT=no + log_warning_msg "ovs-brcompatd missing, disabling bridge compatibility" +fi + +ovs_ctl () { + set /usr/share/openvswitch/scripts/ovs-ctl "$@" + if test X"$BRCOMPAT" = Xyes; then + set "$@" --brcompat + fi + "$@" +} start () { - set $ovs_ctl ${1-start} --system-id=random + set ovs_ctl ${1-start} --system-id=random if test X"$FORCE_COREFILES" != X; then set "$@" --force-corefiles="$FORCE_COREFILES" fi "$@" || exit $? - $ovs_ctl --protocol=gre enable-protocol + ovs_ctl --protocol=gre enable-protocol } stop () { - $ovs_ctl stop + ovs_ctl stop } case $1 in @@ -58,7 +70,7 @@ case $1 in start ;; status) - $ovs_ctl status + ovs_ctl status ;; force-reload-kmod) start force-reload-kmod diff --git a/debian/openvswitch-switch.template b/debian/openvswitch-switch.template index 70ca53e8..46816eaa 100644 --- a/debian/openvswitch-switch.template +++ b/debian/openvswitch-switch.template @@ -2,3 +2,7 @@ # FORCE_COREFILES: If 'yes' then core files will be enabled. # FORCE_COREFILES=yes + +# BRCOMPAT: If 'yes' and the openvswitch-brcompat package is installed, then +# Linux bridge compatibility will be enabled. +# BRCOMPAT=no diff --git a/utilities/ovs-ctl.8 b/utilities/ovs-ctl.8 index 885771c9..8d8088ad 100644 --- a/utilities/ovs-ctl.8 +++ b/utilities/ovs-ctl.8 @@ -65,30 +65,41 @@ bridge module and tries loading the Open vSwitch kernel module again. (This is because the Open vSwitch kernel module cannot coexist with the Linux bridge module before 2.6.37.) . +.IP 2. +If \fB\-\-brcompat\fR was specified, loads the Open vSwitch bridge +compatibility module. +. .PP The \fBstart\fR command skips the following steps if \fBovsdb\-server\fR is already running: -.IP 2. +.IP 3. If the Open vSwitch database file does not exist, it creates it. If the database does exist, but it has an obsolete version, it upgrades it to the latest schema. . -.IP 3. +.IP 4. Starts \fBovsdb-server\fR. . -.IP 4. +.IP 5. Initializes a few values inside the database. . -.IP 5. +.IP 6. If the \fB\-\-delete\-bridges\fR option was used, deletes all of the bridges from the database. . .PP The \fBstart\fR command skips the following step if \fBovs\-vswitchd\fR is already running: -.IP 6. +.IP 7. Starts \fBovs\-vswitchd\fR. . +.PP +The \fBstart\fR command skips the following step if +\fBovs\-brcompatd\fR is already running or if \fB\-\-brcompat\fR is +not specified: +.IP 8. +Starts \fBovs\-brcompatd\fR. +. .SS "Options" .PP Several command-line options influence the \fBstart\fR command's @@ -181,9 +192,13 @@ Overrides the file name for the OVS database schema. .SH "The ``stop'' command" . .PP -The \fBstart\fR command shuts down Open vSwitch. If -\fBovs\-vswitchd\fR is running, kills it and waits for it to -terminate, then it does the same for \fBovsdb\-server\fR. +The \fBstop\fR command shuts down Open vSwitch. It kills any running +\fBovs\-brcompatd\fR, \fBovs\-vswitchd\fR, or \fBovsdb\-server\fR +daemons and waits for them to terminate. +. +.PP +The \fBstop\fR command does not unload the Open vSwitch kernel +modules. . .PP This command does nothing and finishes successfully if the OVS daemons @@ -192,15 +207,18 @@ aren't running. .SH "The ``status'' command" . .PP -The \fBstatus\fR command checks whether the OVS daemons are running -and prints messages with that information. It exits with status 0 if +The \fBstatus\fR command checks whether the OVS daemons +\fBovs-vswitchd\fR and \fBovsdb\-server\fR are running and prints +messages with that information. If \fB\-\-brcompat\fR is specified, +it also checks for \fBovs\-brcompatd\fR. It exits with status 0 if the daemons are running, 1 otherwise. . .SH "The ``version'' command" . .PP The \fBversion\fR command runs \fBovsdb\-server \-\-version\fR and -\fBovs\-vswitchd \-\-version\fR. +\fBovs\-vswitchd \-\-version\fR. If \fB\-\-brcompat\fR is specified, +it also runs \fBovs\-brcompatd \-\-version\fR. . .SH "The ``force\-reload\-kmod'' command" . @@ -224,11 +242,13 @@ listed in step 1, including IP and IPv6 addresses and routing table entries. . .IP 4. -Unloads the Open vSwitch kernel module. +Unloads the Open vSwitch kernel module (including the bridge +compatibility module if it is loaded). . .IP 5. Starts OVS back up, as if by a call to \fBovs\-ctl start\fR. This -reloads the kernel module and restarts the OVS daemons. +reloads the kernel module and restarts the OVS daemons (including +\fBovs\-brcompatd\fR, if \fB\-\-brcompat\fR is specified). . .IP 6. Restores the kernel configuration state that was saved in step 3. @@ -289,6 +309,21 @@ and allowed only with \fB\-\-protocol=tcp\fR or . Prints a usage message and exits successfully. . +.SH "OPTIONS" +.PP +In addition to the options listed for each command above, this option +controls the behavior of several of \fBovs\-ctl\fR's commands. +. +.IP "\fB\-\-brcompat\fR" +By default, \fBovs\-ctl\fR does not load the Open vSwitch bridge +compatibility module and does not start or check the status or report +the version of the \fBovs\-brcompatd\fR daemon. This option enables +all of those behaviors. +. +.IP +The \fBstop\fR command always stops \fBovs\-brcompatd\fR, if it is +running, regardless of this option. +. .SH "EXIT STATUS" . \fBovs\-ctl\fR exits with status 0 on success and nonzero on failure. @@ -356,5 +391,5 @@ distribution are good examples of how to use \fBovs\-ctl\fR. . .SH "SEE ALSO" . -\fBREADME\fR, \fBINSTALL.LINUX\fR, \fBovsdb\-server\fR(8), +\fBREADME\fR, \fBINSTALL.Linux\fR, \fBovsdb\-server\fR(8), \fBovs\-vswitchd\fR(8). diff --git a/utilities/ovs-ctl.in b/utilities/ovs-ctl.in index da6ea814..01741e75 100755 --- a/utilities/ovs-ctl.in +++ b/utilities/ovs-ctl.in @@ -30,7 +30,7 @@ done ## start ## ## ----- ## -insert_modules_if_required () { +insert_openvswitch_mod_if_required () { # If openvswitch_mod is already loaded then we're done. test -e /sys/module/openvswitch_mod && return 0 @@ -51,6 +51,11 @@ insert_modules_if_required () { action "Inserting openvswitch module" modprobe openvswitch_mod } +insert_brcompat_mod_if_required () { + test -e /sys/module/brcompat_mod && return 0 + action "Inserting brcompat module" modprobe brcompat_mod +} + ovs_vsctl () { ovs-vsctl --no-wait --timeout=5 "$@" } @@ -155,7 +160,10 @@ start () { ulimit -Sc 67108864 fi - insert_modules_if_required || return 1 + insert_openvswitch_mod_if_required || return 1 + if test X"$BRCOMPAT" = Xyes; then + insert_brcompat_mod_if_required || return 1 + fi if daemon_is_running ovsdb-server; then log_success_msg "ovsdb-server is already running" @@ -199,6 +207,14 @@ start () { fi start_daemon "$OVS_VSWITCHD_PRIORITY" "$@" fi + + if daemon_is_running ovs-brcompatd; then + log_success_msg "ovs-brcompatd is already running" + elif test X"$BRCOMPAT" = Xyes; then + set ovs-brcompatd + set "$@" -vANY:CONSOLE:EMER -vANY:SYSLOG:ERR -vANY:FILE:INFO + start_daemon "$OVS_BRCOMPATD_PRIORITY" "$@" + fi } ## ---- ## @@ -206,6 +222,7 @@ start () { ## ---- ## stop () { + stop_daemon ovs-brcompatd stop_daemon ovs-vswitchd stop_daemon ovsdb-server } @@ -260,6 +277,9 @@ force_reload_kmod () { action "Removing datapath: $dp" ovs-dpctl del-dp "$dp" done + 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 fi @@ -332,12 +352,14 @@ set_defaults () { SYSTEM_ID= DELETE_BRIDGES=no + BRCOMPAT=no DAEMON_CWD=/ FORCE_COREFILES=yes MLOCKALL=yes OVSDB_SERVER_PRIORITY=-10 OVS_VSWITCHD_PRIORITY=-10 + OVS_BRCOMPATD_PRIORITY=-10 DB_FILE=$etcdir/conf.db DB_SOCK=$rundir/db.sock @@ -377,33 +399,34 @@ Commands: enable-protocol enable protocol specified in options with iptables help display this help message -One of the following options should be specified when starting Open vSwitch: +One of the following options is required for "start" and "force-reload-kmod": --system-id=UUID set specific ID to uniquely identify this system --system-id=random use a random but persistent UUID to identify this system -Other important options for starting Open vSwitch: +Other important options for "start" and "force-reload-kmod": --system-type=TYPE set system type (e.g. "XenServer") --system-version=VERSION set system version (e.g. "5.6.100-39265p") --external-id="key=value" add given key-value pair to Open_vSwitch external-ids --delete-bridges delete all bridges just before starting ovs-vswitchd -Less important options for starting Open vSwitch: - --daemon-cwd=DIR current working directory for OVS daemons (default: $DAEMON_CWD) - --no-force-corefiles - do not forcibly enable core dumps for OVS daemons - --no-mlockall do not lock all of ovs-vswitchd into memory - --ovsdb-server-priority=NICE - set ovsdb-server's niceness (default: $OVSDB_SERVER_PRIORITY) - --ovs-vswitchd-priority=NICE - set ovs-vswitchd's niceness (default: $OVS_VSWITCHD_PRIORITY) +Less important options for "start" and "force-reload-kmod": + --daemon-cwd=DIR set working dir for OVS daemons (default: $DAEMON_CWD) + --no-force-corefiles do not force on core dumps for OVS daemons + --no-mlockall do not lock all of ovs-vswitchd into memory + --ovsdb-server-priority=NICE set ovsdb-server's niceness (default: $OVSDB_SERVER_PRIORITY) + --ovs-vswitchd-priority=NICE set ovs-vswitchd's niceness (default: $OVS_VSWITCHD_PRIORITY) + --ovs-brcompatd-priority=NICE set ovs-brcompatd's niceness (default: $OVS_BRCOMPATD_PRIORITY) + +Options for "start", "force-reload-kmod", "status", and "version": + --brcompat enable Linux bridge compatibility module and daemon File location options: --db-file=FILE database file name (default: $DB_FILE) --db-sock=SOCKET JSON-RPC socket name (default: $DB_SOCK) --db-schema=FILE database schema file name (default: $DB_SCHEMA) -Options for enable-protocol: +Options for "enable-protocol": --protocol=PROTOCOL protocol to enable with iptables (default: gre) --sport=PORT source port to match (for tcp or udp protocol) --dport=PORT ddestination port to match (for tcp or udp protocol) @@ -439,6 +462,13 @@ set_option () { eval $var=\$value } +daemons () { + echo ovsdb-server ovs-vswitchd + if test X"$BRCOMPAT" = Xyes; then + echo ovs-brcompatd + fi +} + set_defaults extra_ids= command= @@ -504,10 +534,16 @@ case $command in stop ;; status) - daemon_status ovsdb-server && daemon_status ovs-vswitchd + rc=0 + for daemon in `daemons`; do + daemon_status $daemon || rc=$? + done + exit $rc ;; version) - ovsdb-server --version && ovs-vswitchd --version + for daemon in `daemons`; do + $daemon --version + done ;; force-reload-kmod) force_reload_kmod