summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bgpd/bgp_vty.c27
-rw-r--r--bgpd/rfapi/rfapi_monitor.c40
-rw-r--r--bgpd/rfapi/rfapi_vty.c18
-rw-r--r--ldpd/adjacency.c4
-rw-r--r--ldpd/interface.c5
-rw-r--r--ldpd/neighbor.c7
-rw-r--r--lib/thread.c3
-rw-r--r--zebra/zebra_evpn_mac.c5
8 files changed, 56 insertions, 53 deletions
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index 42d19d0315..c91a62ba0e 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -10173,9 +10173,11 @@ DEFUN (show_bgp_memory,
count, mtype_memstr(memstrbuf, sizeof(memstrbuf),
count * sizeof(struct community)));
if ((count = mtype_stats_alloc(MTYPE_ECOMMUNITY)))
- vty_out(vty, "%ld BGP community entries, using %s of memory\n",
- count, mtype_memstr(memstrbuf, sizeof(memstrbuf),
- count * sizeof(struct ecommunity)));
+ vty_out(vty,
+ "%ld BGP ext-community entries, using %s of memory\n",
+ count,
+ mtype_memstr(memstrbuf, sizeof(memstrbuf),
+ count * sizeof(struct ecommunity)));
if ((count = mtype_stats_alloc(MTYPE_LCOMMUNITY)))
vty_out(vty,
"%ld BGP large-community entries, using %s of memory\n",
@@ -10392,9 +10394,24 @@ static void bgp_show_failed_summary(struct vty *vty, struct bgp *bgp,
static char *bgp_peer_description_stripped(char *desc, uint32_t size)
{
static char stripped[BUFSIZ];
- uint32_t len = size > strlen(desc) ? strlen(desc) : size;
+ uint32_t i = 0;
+ uint32_t last_space = 0;
- strlcpy(stripped, desc, len + 1);
+ while (i < size) {
+ if (*(desc + i) == 0) {
+ stripped[i] = '\0';
+ return stripped;
+ }
+ if (i != 0 && *(desc + i) == ' ' && last_space != i - 1)
+ last_space = i;
+ stripped[i] = *(desc + i);
+ i++;
+ }
+
+ if (last_space > size)
+ stripped[size + 1] = '\0';
+ else
+ stripped[last_space] = '\0';
return stripped;
}
diff --git a/bgpd/rfapi/rfapi_monitor.c b/bgpd/rfapi/rfapi_monitor.c
index 58a0f8dea7..8529676118 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 b95bace0d1..d50da2bf39 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),
diff --git a/ldpd/adjacency.c b/ldpd/adjacency.c
index 7eb5663492..04a24242dc 100644
--- a/ldpd/adjacency.c
+++ b/ldpd/adjacency.c
@@ -386,9 +386,7 @@ adj_to_ctl(struct adj *adj)
}
actl.holdtime = adj->holdtime;
actl.holdtime_remaining =
- thread_is_scheduled(adj->inactivity_timer)
- ? thread_timer_remain_second(adj->inactivity_timer)
- : 0;
+ thread_timer_remain_second(adj->inactivity_timer);
actl.trans_addr = adj->trans_addr;
actl.ds_tlv = adj->ds_tlv;
diff --git a/ldpd/interface.c b/ldpd/interface.c
index af6e8fd7ec..ddf6c395ae 100644
--- a/ldpd/interface.c
+++ b/ldpd/interface.c
@@ -543,11 +543,8 @@ ldp_sync_to_ctl(struct iface *iface)
ictl.wait_time = if_get_wait_for_sync_interval();
ictl.timer_running = iface->ldp_sync.wait_for_sync_timer ? true : false;
- if (iface->ldp_sync.wait_for_sync_timer)
- ictl.wait_time_remaining =
+ ictl.wait_time_remaining =
thread_timer_remain_second(iface->ldp_sync.wait_for_sync_timer);
- else
- ictl.wait_time_remaining = 0;
memset(&ictl.peer_ldp_id, 0, sizeof(ictl.peer_ldp_id));
diff --git a/ldpd/neighbor.c b/ldpd/neighbor.c
index 867ad92e47..514bcee32b 100644
--- a/ldpd/neighbor.c
+++ b/ldpd/neighbor.c
@@ -847,11 +847,8 @@ nbr_to_ctl(struct nbr *nbr)
nctl.stats = nbr->stats;
nctl.flags = nbr->flags;
nctl.max_pdu_len = nbr->max_pdu_len;
- if (nbr->keepalive_timer)
- nctl.hold_time_remaining =
- thread_timer_remain_second(nbr->keepalive_timer);
- else
- nctl.hold_time_remaining = 0;
+ nctl.hold_time_remaining =
+ thread_timer_remain_second(nbr->keepalive_timer);
gettimeofday(&now, NULL);
if (nbr->state == NBR_STA_OPER) {
diff --git a/lib/thread.c b/lib/thread.c
index fd79503cc6..9c783808b5 100644
--- a/lib/thread.c
+++ b/lib/thread.c
@@ -756,6 +756,9 @@ unsigned long thread_timer_remain_msec(struct thread *thread)
{
int64_t remain;
+ if (!thread_is_scheduled(thread))
+ return 0;
+
frr_with_mutex(&thread->mtx) {
remain = monotime_until(&thread->u.sands, NULL) / 1000LL;
}
diff --git a/zebra/zebra_evpn_mac.c b/zebra/zebra_evpn_mac.c
index 38a36cc7ae..cbdc17653b 100644
--- a/zebra/zebra_evpn_mac.c
+++ b/zebra/zebra_evpn_mac.c
@@ -374,8 +374,9 @@ static char *zebra_evpn_zebra_mac_flag_dump(struct zebra_mac *mac, char *buf,
: "",
CHECK_FLAG(mac->flags, ZEBRA_MAC_DUPLICATE) ? "DUP " : "",
CHECK_FLAG(mac->flags, ZEBRA_MAC_FPM_SENT) ? "FPM " : "",
- CHECK_FLAG(mac->flags, ZEBRA_MAC_ES_PEER_ACTIVE) ? "LOC Active "
- : "",
+ CHECK_FLAG(mac->flags, ZEBRA_MAC_ES_PEER_ACTIVE)
+ ? "PEER Active "
+ : "",
CHECK_FLAG(mac->flags, ZEBRA_MAC_ES_PEER_PROXY) ? "PROXY " : "",
CHECK_FLAG(mac->flags, ZEBRA_MAC_LOCAL_INACTIVE)
? "LOC Inactive "