]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: Warn operator when fd limit is set too large 15282/head
authorDonald Sharp <sharpd@nvidia.com>
Fri, 2 Feb 2024 02:18:50 +0000 (21:18 -0500)
committerDonald Sharp <sharpd@nvidia.com>
Fri, 2 Feb 2024 02:23:56 +0000 (21:23 -0500)
It's unlikely that an operator will ever set a fd
limit of over 100k.  Let's warn the operator that
things are in a bit of a wonky state.

Fixes: #15280
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
lib/event.c

index a7851f6983195e48e768a8309875201b9b858bea..6427705e90a330f979308220ac074e651b51d8e5 100644 (file)
@@ -543,6 +543,7 @@ static void initializer(void)
        pthread_key_create(&thread_current, NULL);
 }
 
+#define STUPIDLY_LARGE_FD_SIZE 100000
 struct event_loop *event_master_create(const char *name)
 {
        struct event_loop *rv;
@@ -569,6 +570,10 @@ struct event_loop *event_master_create(const char *name)
                rv->fd_limit = (int)limit.rlim_cur;
        }
 
+       if (rv->fd_limit > STUPIDLY_LARGE_FD_SIZE)
+               zlog_warn("FD Limit set: %u is stupidly large.  Is this what you intended?  Consider using --limit-fds",
+                         rv->fd_limit);
+
        rv->read = XCALLOC(MTYPE_EVENT_POLL,
                           sizeof(struct event *) * rv->fd_limit);