ovs-ctl: Don't decrease max open fds if already set higher
authorThomas Graf <tgraf@suug.ch>
Thu, 8 May 2014 18:45:25 +0000 (20:45 +0200)
committerBen Pfaff <blp@nicira.com>
Fri, 9 May 2014 15:17:48 +0000 (08:17 -0700)
A user may set LimitNOFILE through systemd or other means to set
the maximum number of open file descriptors. Only modify the ulimit
if not already set to a higher value by the user.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Andy Gospodarek <gospo@redhat.com>
utilities/ovs-ctl.in

index 0735160..2f39519 100755 (executable)
@@ -227,7 +227,10 @@ start_forwarding () {
         # 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
+        MAXFD=7500
+        if [ $(ulimit -n) -lt $MAXFD ]; then
+            ulimit -n $MAXFD
+        fi
 
            # Start ovs-vswitchd.
            set ovs-vswitchd unix:"$DB_SOCK"