summaryrefslogtreecommitdiffstats
path: root/bgpd
diff options
context:
space:
mode:
authorDonald Sharp <donaldsharp72@gmail.com>2022-07-19 18:07:02 +0200
committerGitHub <noreply@github.com>2022-07-19 18:07:02 +0200
commita741212913ecf7cec22d4eb1fff0258510c6ba5a (patch)
tree20a2e5a1671d6777a481f97d70f71c097be4bc1d /bgpd
parentMerge pull request #11613 from anlancs/fix/minor-6 (diff)
parentbgpd, ldpd: No need for an explicit NULL check for thread_timer_remain_second (diff)
downloadfrr-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.c40
-rw-r--r--bgpd/rfapi/rfapi_vty.c18
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),