[ovs-dev] [initscripts 5/5] Refactor initscripts into distro-independent and distro-specific pieces.

Ben Pfaff blp at nicira.com
Fri Jun 17 19:22:35 UTC 2011


On Thu, Jun 16, 2011 at 03:35:01PM -0700, Andrew Evans wrote:
> [typos]

Thanks, I fixed all those.

> > +case $0 in
> > +    */*) dir0=`echo "$0" | sed 's,/[^/]*$,,'` ;;
> > +    *) dir0=./ ;;
> > +esac
> 
> Is there some reason not to use 'dirname'?

The Autoconf manual says:

    `dirname'
	 Not all hosts have a working `dirname', and you should instead
	 use `AS_DIRNAME' (*note Programming in M4sh::).  For example:

	      dir=`dirname "$file"`       # This is not portable.
	      dir=`AS_DIRNAME(["$file"])` # This is more portable.

I can't use AS_DIRNAME here because this is not an M4sh script, so I
wrote a "case" statement instead.

(I could write this in M4sh but it would be less readable.)

> > +    # Allow GRE traffic.
> > +    iptables -I INPUT -p gre -j ACCEPT
> 
> What if iptables isn't installed, or if the kernel wasn't built with the
> necessary netfilter options?

Good point.

For now, I moved this to the wrappers.  XenServer always has iptables;
for Debian I made it conditional on iptables being installed.  There
will still be an error if iptables is installed but the kernel does
not support it; so be it.

> > +etcdir=$sysconfdir/openvswitch                  # /etc/openvswitch
> 
> Incidentally, I applied this patch series and built and installed .debs
> on Ubuntu 11/Natty, and my database ended up
> in /usr/etc/openvswitch/conf.db rather than /etc/openvswitch/conf.db.
> I'm not sure if it's related to these changes.

Oops.  debian/rules needed to pass --sysconfdir=/etc to configure.

> Also, git-am complained about trailing whitespace in this patch.

Fixed.

Here's the diff that I applied.  I'll test it again and push it.

Thanks,

Ben.

diff --git a/debian/openvswitch-switch.init b/debian/openvswitch-switch.init
index 2e237b0..44ec67c 100755
--- a/debian/openvswitch-switch.init
+++ b/debian/openvswitch-switch.init
@@ -36,6 +36,10 @@ case $1 in
 	if test X"$FORCE_COREFILES" != X; then
 	    set "$@" --force-oorefiles="$FORCE_COREFILES"
 	fi
+
+	# Allow GRE traffic.
+        test ! -x /sbin/iptables || /sbin/iptables -I INPUT -p gre -j ACCEPT
+
 	"$@"
         ;;
     stop | force-stop)
diff --git a/debian/rules b/debian/rules
index 6806980..76d11a0 100755
--- a/debian/rules
+++ b/debian/rules
@@ -36,7 +36,7 @@ configure-stamp:
 	cd _debian && ( \
 		test -e Makefile || \
 		../configure --prefix=/usr --localstatedir=/var --enable-ssl \
-			--with-build-number=$(BUILD_NUMBER) \
+			--sysconfdir=/etc --with-build-number=$(BUILD_NUMBER) \
 			CFLAGS="$(CFLAGS)" $(DATAPATH_CONFIGURE_OPTS))
 	touch configure-stamp
 
diff --git a/utilities/ovs-ctl.8 b/utilities/ovs-ctl.8
index 1251b51..d649d56 100644
--- a/utilities/ovs-ctl.8
+++ b/utilities/ovs-ctl.8
@@ -46,12 +46,12 @@ Each of \fBovs\-ctl\fR's commands is described separately below.
 .SH "The ``start'' command"
 .
 .PP
-The \fBstart\fR command starts up Open vSwitch.  It performs the
+The \fBstart\fR command starts Open vSwitch.  It performs the
 following tasks:
 .
 .IP 1.
 Loads the Open vSwitch kernel module.  If this fails, and the Linux
-bridge module is loaded but no bridges exists, it tries to unload the
+bridge module is loaded but no bridges exist, it tries to unload the
 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.)
@@ -62,7 +62,7 @@ The \fBstart\fR command skips the following steps if
 .IP 2.
 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 last schema.
+upgrades it to the latest schema.
 .
 .IP 3.
 Starts \fBovsdb-server\fR.
@@ -118,7 +118,7 @@ The following options are also likely to be useful:
 .IP "\fB\-\-external\-id=\(dq\fIname\fB=\fIvalue\fB\(dq"
 Sets \fBexternal-ids:\fIname\fR to \fIvalue\fR in the database's
 \fBOpen_vSwitch\fR table.  Specifying this option multiple times adds
-multiple key-pair pairs.
+multiple key-value pairs.
 .
 .IP "\fB\-\-delete\-bridges\fR"
 Ordinarily Open vSwitch bridges persist from one system boot to the
@@ -172,7 +172,7 @@ Overrides the file name for the OVS database schema.
 .SH "The ``stop'' command"
 .
 .PP
-The \fBstart\fR command starts up Open vSwitch.  If
+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.
 .
@@ -231,7 +231,7 @@ ISC DHCP client is running on an OVS internal interface, then it will
 have to be restarted after completing the above procedure.
 .
 .PP
-Because \fBforce\-kmod\-reload\fR internally stop and starts OVS, it
+Because \fBforce\-kmod\-reload\fR internally stops and starts OVS, it
 accepts all of the options accepted by the \fBstart\fR command.
 .
 .SS "The ``help'' command"
diff --git a/utilities/ovs-ctl.in b/utilities/ovs-ctl.in
index 7c0c356..923e1b5 100755
--- a/utilities/ovs-ctl.in
+++ b/utilities/ovs-ctl.in
@@ -133,7 +133,7 @@ set_system_ids () {
     else
         log_failure_msg "no default system version, please use --system-version"
     fi
-    
+
     action "Configuring Open vSwitch system IDs" "$@" $extra_ids
 }
 
@@ -144,9 +144,6 @@ start () {
 
     insert_modules_if_required || return 1
 
-    # Allow GRE traffic.
-    iptables -I INPUT -p gre -j ACCEPT
-
     if daemon_is_running ovsdb-server; then
 	log_success_msg "ovsdb-server is already running"
     else
@@ -209,7 +206,7 @@ internal_interfaces () {
     #
     #   - There is an internal interface for every bridge, whether it
     #     has an Interface record or not and whether the Interface
-    #     record's 'type' is properly set or net.
+    #     record's 'type' is properly set or not.
     #
     #   - There is an internal interface for each Interface record whose
     #     'type' is 'internal'.
@@ -293,7 +290,7 @@ usage: $0 [OPTIONS] COMMAND
 
 This program is intended to be invoked internally by Open vSwitch startup
 scripts.  System administrators should not normally invoke it directly.
- 
+
 Commands:
   start              start Open vSwitch daemons
   stop               stop Open vSwitch daemons
@@ -316,15 +313,15 @@ Other important options for starting Open vSwitch:
 
 Less important options for starting Open vSwitch:
   --daemon-cwd=DIR   current working directory for OVS daemons (default: $DAEMON_CWD)
-  --no-force-corefiles  
+  --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 
+  --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)
 
-File location options:  
+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)
@@ -445,4 +442,4 @@ case $command in
         exit 1
         ;;
 esac
- 
+
diff --git a/utilities/ovs-lib.sh.in b/utilities/ovs-lib.sh.in
index 7e6aee9..682b712 100644
--- a/utilities/ovs-lib.sh.in
+++ b/utilities/ovs-lib.sh.in
@@ -94,7 +94,7 @@ start_daemon () {
     test -d "$DAEMON_CWD" || install -d -m 755 -o root -g root "$DAEMON_CWD"
     set "$@" --no-chdir
     cd "$DAEMON_CWD"
-    
+
     # log file
     test -d "$logdir" || install -d -m 755 -o root -g root "$logdir"
     set "$@" --log-file="$logdir/$daemon.log"
diff --git a/xenserver/etc_init.d_openvswitch b/xenserver/etc_init.d_openvswitch
index a40bccc..941a94d 100755
--- a/xenserver/etc_init.d_openvswitch
+++ b/xenserver/etc_init.d_openvswitch
@@ -76,6 +76,9 @@ start () {
             --pidfile --detach --monitor unix:/var/run/openvswitch/db.sock
     fi
 
+    # Allow GRE traffic.
+    /sbin/iptables -I INPUT -p gre -j ACCEPT
+
     touch /var/lock/subsys/openvswitch
 }
 



More information about the dev mailing list