diff options
author | Donald Sharp <donaldsharp72@gmail.com> | 2022-07-19 18:07:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-19 18:07:02 +0200 |
commit | a741212913ecf7cec22d4eb1fff0258510c6ba5a (patch) | |
tree | 20a2e5a1671d6777a481f97d70f71c097be4bc1d /bgpd | |
parent | Merge pull request #11613 from anlancs/fix/minor-6 (diff) | |
parent | bgpd, ldpd: No need for an explicit NULL check for thread_timer_remain_second (diff) | |
download | frr-a741212913ecf7cec22d4eb1fff0258510c6ba5a.tar.xz frr-a741212913ecf7cec22d4eb1fff0258510c6ba5a.zip |
Merge pull request #11637 from opensourcerouting/fix/remaining_sec_for_null
*: thread_timer_remain_second NULL handling
Diffstat (limited to 'bgpd')
-rw-r--r-- | bgpd/rfapi/rfapi_monitor.c | 40 | ||||
-rw-r--r-- | bgpd/rfapi/rfapi_vty.c | 18 |
2 files changed, 24 insertions, 34 deletions
diff --git a/bgpd/rfapi/rfapi_monitor.c b/bgpd/rfapi/rfapi_monitor.c index 58a0f8dea..852967611 100644 --- a/bgpd/rfapi/rfapi_monitor.c +++ b/bgpd/rfapi/rfapi_monitor.c @@ -744,19 +744,17 @@ static void rfapiMonitorTimerExpire(struct thread *t) static void rfapiMonitorTimerRestart(struct rfapi_monitor_vpn *m) { - if (m->timer) { - unsigned long remain = thread_timer_remain_second(m->timer); + unsigned long remain = thread_timer_remain_second(m->timer); - /* unexpected case, but avoid wraparound problems below */ - if (remain > m->rfd->response_lifetime) - return; + /* unexpected case, but avoid wraparound problems below */ + if (remain > m->rfd->response_lifetime) + return; - /* don't restart if we just restarted recently */ - if (m->rfd->response_lifetime - remain < 2) - return; + /* don't restart if we just restarted recently */ + if (m->rfd->response_lifetime - remain < 2) + return; - thread_cancel(&m->timer); - } + THREAD_OFF(m->timer); { char buf[BUFSIZ]; @@ -766,7 +764,7 @@ static void rfapiMonitorTimerRestart(struct rfapi_monitor_vpn *m) rfapi_ntop(m->p.family, m->p.u.val, buf, BUFSIZ), m->rfd->response_lifetime); } - m->timer = NULL; + thread_add_timer(bm->master, rfapiMonitorTimerExpire, m, m->rfd->response_lifetime, &m->timer); } @@ -1054,19 +1052,17 @@ static void rfapiMonitorEthTimerExpire(struct thread *t) static void rfapiMonitorEthTimerRestart(struct rfapi_monitor_eth *m) { - if (m->timer) { - unsigned long remain = thread_timer_remain_second(m->timer); + unsigned long remain = thread_timer_remain_second(m->timer); - /* unexpected case, but avoid wraparound problems below */ - if (remain > m->rfd->response_lifetime) - return; + /* unexpected case, but avoid wraparound problems below */ + if (remain > m->rfd->response_lifetime) + return; - /* don't restart if we just restarted recently */ - if (m->rfd->response_lifetime - remain < 2) - return; + /* don't restart if we just restarted recently */ + if (m->rfd->response_lifetime - remain < 2) + return; - thread_cancel(&m->timer); - } + THREAD_OFF(m->timer); { char buf[BUFSIZ]; @@ -1076,7 +1072,7 @@ static void rfapiMonitorEthTimerRestart(struct rfapi_monitor_eth *m) rfapiEthAddr2Str(&m->macaddr, buf, BUFSIZ), m->rfd->response_lifetime); } - m->timer = NULL; + thread_add_timer(bm->master, rfapiMonitorEthTimerExpire, m, m->rfd->response_lifetime, &m->timer); } diff --git a/bgpd/rfapi/rfapi_vty.c b/bgpd/rfapi/rfapi_vty.c index b95bace0d..d50da2bf3 100644 --- a/bgpd/rfapi/rfapi_vty.c +++ b/bgpd/rfapi/rfapi_vty.c @@ -928,12 +928,9 @@ int rfapiShowVncQueries(void *stream, struct prefix *pfx_match) } else fp(out, "%-15s %-15s", "", ""); buf_remain[0] = 0; - if (m->timer) { - rfapiFormatSeconds( - thread_timer_remain_second( - m->timer), - buf_remain, BUFSIZ); - } + rfapiFormatSeconds( + thread_timer_remain_second(m->timer), + buf_remain, BUFSIZ); fp(out, " %-15s %-10s\n", inet_ntop(m->p.family, &m->p.u.prefix, buf_pfx, BUFSIZ), @@ -1005,12 +1002,9 @@ int rfapiShowVncQueries(void *stream, struct prefix *pfx_match) } else fp(out, "%-15s %-15s", "", ""); buf_remain[0] = 0; - if (mon_eth->timer) { - rfapiFormatSeconds( - thread_timer_remain_second( - mon_eth->timer), - buf_remain, BUFSIZ); - } + rfapiFormatSeconds(thread_timer_remain_second( + mon_eth->timer), + buf_remain, BUFSIZ); fp(out, " %-17s %10d %-10s\n", rfapi_ntop(pfx_mac.family, &pfx_mac.u.prefix, buf_pfx, BUFSIZ), |