]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: Add a Dev catch for when a timer is set for > 1 year
authorDonald Sharp <sharpd@nvidia.com>
Fri, 25 Feb 2022 13:19:07 +0000 (08:19 -0500)
committerDonald Sharp <sharpd@nvidia.com>
Fri, 25 Feb 2022 13:19:07 +0000 (08:19 -0500)
Since there are timers that are created based upon doing some
math and we know that unsigned values when doing math and we accidently
subtract a larger number from a smaller number causes the unsigned
number to wrap to very large numbers, let's put in a small catch
in place to see if there are any places in the system that
mistakes are made and FRR is accidently creating a problem
for itself.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
lib/lib_errors.c
lib/lib_errors.h
lib/thread.c

index acc9a05c33528a40cf32f3e56be602cef79c4e2e..a658e4c29514308ea8c034cb41c6ca56c564f0d9 100644 (file)
@@ -68,6 +68,12 @@ static struct log_ref ferr_lib_warn[] = {
                .description = "The Event subsystem has detected a file descriptor read/write event without an associated handling function.  This is a bug, please collect log data and open an issue.",
                .suggestion = "Gather log data and open an Issue",
        },
+       {
+               .code = EC_LIB_TIMER_TOO_LONG,
+               .title = "The Event subsystem has detected an internal timer that is scheduled to pop in greater than one year",
+               .description = "The Event subsystem has detected a timer being started that will pop in a timer that is greater than one year.  This is a bug, please collect log data and open an issue.",
+               .suggestion = "Gather log data and open an Issue",
+       },
        {
                .code = EC_LIB_RMAP_RECURSION_LIMIT,
                .title = "Reached the Route-Map Recursion Limit",
index 64ac6c1cebad85790427fc77fe27825456271825..91f206f74a4e21d02177b1834f7b953ad0ecb959 100644 (file)
@@ -48,6 +48,7 @@ enum lib_log_refs {
        EC_LIB_SLOW_THREAD_WALL,
        EC_LIB_STARVE_THREAD,
        EC_LIB_NO_THREAD,
+       EC_LIB_TIMER_TOO_LONG,
        EC_LIB_RMAP_RECURSION_LIMIT,
        EC_LIB_BACKUP_CONFIG,
        EC_LIB_VRF_LENGTH,
index 58b8e206fadf41a7830f9b1181ca6901557a5d9b..bc3bfe89d48aa1e86087da89dcde1b1af5575d4e 100644 (file)
@@ -1052,6 +1052,12 @@ static void _thread_add_timer_timeval(const struct xref_threadsched *xref,
                if (thread_timer_list_first(&m->timer) == thread)
                        AWAKEN(m);
        }
+#define ONEYEAR2SEC (60 * 60 * 24 * 365)
+       if (time_relative->tv_sec > ONEYEAR2SEC)
+               flog_err(
+                       EC_LIB_TIMER_TOO_LONG,
+                       "Timer: %pTHD is created with an expiration that is greater than 1 year",
+                       thread);
 }