ovs-ctl: Raise the limit on the number of open file descriptors.
[cascardo/ovs.git] / utilities / ovs-ctl.in
index 6465fdf..f765553 100755 (executable)
@@ -224,10 +224,13 @@ 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 "n-handler-threads" file descriptors per bridge
+        # port, so this allows a very large number of bridges and ports.
+        MAXFD=65535
+        if [ $(ulimit -n) -lt $MAXFD ]; then
+            ulimit -n $MAXFD
+        fi
 
            # Start ovs-vswitchd.
            set ovs-vswitchd unix:"$DB_SOCK"