Prepare for post-2.2.0 (2.2.90).
[sliver-openvswitch.git] / utilities / ovs-ctl.in
index 1f10491..0735160 100755 (executable)
@@ -202,6 +202,19 @@ start_ovsdb () {
     fi
 }
 
+add_managers () {
+    # Now that ovs-vswitchd has started and completed its initial
+    # configuration, tell ovsdb-server to conenct to the remote managers.  We
+    # used to do this at ovsdb-server startup time, but waiting for
+    # ovs-vswitchd to finish configuring means that remote managers see less
+    # churn in the database at startup or restart.  (For example, managers
+    # won't briefly see empty datapath-id or ofport columns for records that
+    # exist at startup.)
+    action "Enabling remote OVSDB managers" \
+       ovs-appctl -t ovsdb-server ovsdb-server/add-remote \
+           db:Open_vSwitch,Open_vSwitch,manager_options
+}
+
 start_forwarding () {
     check_force_cores
 
@@ -211,10 +224,10 @@ start_forwarding () {
         log_success_msg "ovs-vswitchd is already running"
     else
         # Increase the limit on the number of open file descriptors.
-        # On Linux, ovs-vswitchd needs about one file descriptor per
-        # switch port, so this allows a very large number of switch
-        # ports.
-        ulimit -n 5000
+        # On Linux, ovs-vswitchd needs about three file descriptors
+        # per bridge and one file descriptor per bridge port, so this
+        # allows a very large number of bridges and ports.
+        ulimit -n 7500
 
            # Start ovs-vswitchd.
            set ovs-vswitchd unix:"$DB_SOCK"
@@ -224,17 +237,6 @@ start_forwarding () {
            fi
            start_daemon "$OVS_VSWITCHD_PRIORITY" "$OVS_VSWITCHD_WRAPPER" "$@"
     fi
-
-    # Now that ovs-vswitchd has started and completed its initial
-    # configuration, tell ovsdb-server to conenct to the remote managers.  We
-    # used to do this at ovsdb-server startup time, but waiting for
-    # ovs-vswitchd to finish configuring means that remote managers see less
-    # churn in the database at startup or restart.  (For example, managers
-    # won't briefly see empty datapath-id or ofport columns for records that
-    # exist at startup.)
-    action "Enabling remote OVSDB managers" \
-       ovs-appctl -t ovsdb-server ovsdb-server/add-remote \
-           db:Open_vSwitch,Open_vSwitch,manager_options
 }
 
 ## ---- ##
@@ -304,6 +306,15 @@ restore_ofports () {
         action "Restoring ofport values" "${script_ofports}"
 }
 
+flow_restore_wait () {
+    ovs_vsctl set open_vswitch . other_config:flow-restore-wait="true"
+}
+
+flow_restore_complete () {
+    ovs_vsctl --if-exists remove open_vswitch . other_config \
+        flow-restore-wait="true"
+}
+
 restore_flows () {
     [ -x "${script_flows}" ] && \
         action "Restoring saved flows" "${script_flows}"
@@ -355,6 +366,7 @@ force_reload_kmod () {
     else
         log_warning_msg "Failed to save configuration, not replacing kernel module"
         start_forwarding
+        add_managers
         exit 1
     fi
     chmod +x "$script_interfaces"
@@ -370,9 +382,14 @@ force_reload_kmod () {
         action "Removing openvswitch module" rmmod openvswitch
     fi
 
+    # Start vswitchd by asking it to wait till flow restore is finished.
+    flow_restore_wait
     start_forwarding
 
+    # Restore saved flows and inform vswitchd that we are done.
     restore_flows
+    flow_restore_complete
+    add_managers
 
     restore_interfaces
 
@@ -414,10 +431,15 @@ restart () {
     restore_ofports
 
     stop_forwarding
+
+    # Start vswitchd by asking it to wait till flow restore is finished.
+    flow_restore_wait
     start_forwarding
 
-    # Restore the saved flows.
+    # Restore saved flows and inform vswitchd that we are done.
     restore_flows
+    flow_restore_complete
+    add_managers
 
     # Restore the interfaces if required. Return true even if restore fails.
     restore_interfaces || true
@@ -664,6 +686,7 @@ case $command in
     start)
         start_ovsdb
         start_forwarding
+        add_managers
         ;;
     stop)
         stop_forwarding