ovs-ctl: Restore ability to create 256 bridges.
[sliver-openvswitch.git] / utilities / ovs-ctl.in
index 01741e7..f10e98a 100755 (executable)
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2009, 2010, 2011 Nicira Networks, Inc.
+# Copyright (C) 2009, 2010, 2011, 2012 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.
@@ -17,7 +17,7 @@ case $0 in
     */*) dir0=`echo "$0" | sed 's,/[^/]*$,,'` ;;
     *) dir0=./ ;;
 esac
-. "$dir0/ovs-lib.sh" || exit 1
+. "$dir0/ovs-lib" || exit 1
 
 for dir in "$sbindir" "$bindir" /sbin /bin /usr/sbin /usr/bin; do
     case :$PATH: in
@@ -56,12 +56,19 @@ insert_brcompat_mod_if_required () {
     action "Inserting brcompat module" modprobe brcompat_mod
 }
 
+insert_mod_if_required () {
+    insert_openvswitch_mod_if_required || return 1
+    if test X"$BRCOMPAT" = Xyes; then
+        insert_brcompat_mod_if_required || return 1
+    fi
+}
+
 ovs_vsctl () {
     ovs-vsctl --no-wait --timeout=5 "$@"
 }
 
 ovsdb_tool () {
-    ovsdb-tool -vANY:console:emer "$@"
+    ovsdb-tool -vANY:console:off "$@"
 }
 
 create_db () {
@@ -160,10 +167,7 @@ start () {
         ulimit -Sc 67108864
     fi
 
-    insert_openvswitch_mod_if_required || return 1
-    if test X"$BRCOMPAT" = Xyes; then
-        insert_brcompat_mod_if_required || return 1
-    fi
+    insert_mod_if_required || return 1
 
     if daemon_is_running ovsdb-server; then
        log_success_msg "ovsdb-server is already running"
@@ -195,9 +199,10 @@ start () {
     if daemon_is_running ovs-vswitchd; then
        log_success_msg "ovs-vswitchd is already running"
     else
-       # Increase the limit on the number of open file descriptors since
-       # ovs-vswitchd needs a few per bridge
-       ulimit -n 4096
+       # Increase the limit on the number of open file descriptors.
+       # ovs-vswitchd needs 16 per datapath, plus a few extra, so this
+       # should allow for 256 (or more) bridges.
+       ulimit -n 5000
 
        # Start ovs-vswitchd.
        set ovs-vswitchd unix:"$DB_SOCK"
@@ -369,7 +374,13 @@ set_defaults () {
     DPORT=
     SPORT=
 
-    if (lsb_release --id) >/dev/null 2>&1; then
+    type_file=$etcdir/system-type.conf
+    version_file=$etcdir/system-version.conf
+
+    if test -e "$type_file" ; then
+        SYSTEM_TYPE=`cat $type_file`
+        SYSTEM_VERSION=`cat $version_file`
+    elif (lsb_release --id) >/dev/null 2>&1; then
         SYSTEM_TYPE=`lsb_release --id -s`
         system_release=`lsb_release --release -s`
         system_codename=`lsb_release --codename -s`
@@ -394,6 +405,7 @@ Commands:
   stop               stop Open vSwitch daemons
   status             check whether Open vSwitch daemons are running
   version            print versions of Open vSwitch daemons
+  load-kmod          insert modules if not already present
   force-reload-kmod  save OVS network device state, stop OVS, unload kernel
                      module, reload kernel module, start OVS, restore state
   enable-protocol    enable protocol specified in options with iptables
@@ -418,7 +430,7 @@ Less important options for "start" and "force-reload-kmod":
   --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":
+Options for "start", "force-reload-kmod", "load-kmod", "status", and "version":
   --brcompat         enable Linux bridge compatibility module and daemon
 
 File location options:
@@ -548,6 +560,9 @@ case $command in
     force-reload-kmod)
        force_reload_kmod
         ;;
+    load-kmod)
+        insert_mod_if_required
+        ;;
     enable-protocol)
         enable_protocol
         ;;