summaryrefslogtreecommitdiffstats
path: root/bgpd
diff options
context:
space:
mode:
authorDonald Sharp <donaldsharp72@gmail.com>2023-09-20 13:32:51 +0200
committerGitHub <noreply@github.com>2023-09-20 13:32:51 +0200
commit4e5627fb20172504f6a007b3002b2f7ff6895436 (patch)
tree4e1b12c4510086d639ebeb0c3413f703e04907a1 /bgpd
parentMerge pull request #14440 from fdumontet6WIND/fix_oid_bgp4v2 (diff)
parenttests: replace ctime with ctime_r (diff)
downloadfrr-4e5627fb20172504f6a007b3002b2f7ff6895436.tar.xz
frr-4e5627fb20172504f6a007b3002b2f7ff6895436.zip
Merge pull request #14442 from mjstapp/fix_no_ctime
bgpd, pathd: replace ctime() with ctime_r()
Diffstat (limited to 'bgpd')
-rw-r--r--bgpd/bgp_btoa.c6
-rw-r--r--bgpd/bgp_labelpool.c2
-rw-r--r--bgpd/bgp_mplsvpn.c3
-rw-r--r--bgpd/bgp_nexthop.c5
-rw-r--r--bgpd/bgp_route.c5
-rw-r--r--bgpd/bgp_updgrp.c5
-rw-r--r--bgpd/bgpd.h4
7 files changed, 19 insertions, 11 deletions
diff --git a/bgpd/bgp_btoa.c b/bgpd/bgp_btoa.c
index fc3363b09..8e27d9769 100644
--- a/bgpd/bgp_btoa.c
+++ b/bgpd/bgp_btoa.c
@@ -120,6 +120,7 @@ int main(int argc, char **argv)
struct in_addr dip;
uint16_t viewno, seq_num;
struct prefix_ipv4 p;
+ char tbuf[32];
s = stream_new(10000);
@@ -155,7 +156,7 @@ int main(int argc, char **argv)
subtype = stream_getw(s);
len = stream_getl(s);
- printf("TIME: %s", ctime(&now));
+ printf("TIME: %s", ctime_r(&now, tbuf));
/* printf ("TYPE: %d/%d\n", type, subtype); */
@@ -239,7 +240,8 @@ int main(int argc, char **argv)
source_as = stream_getw(s);
printf("FROM: %pI4 AS%d\n", &peer, source_as);
- printf("ORIGINATED: %s", ctime(&originated));
+ printf("ORIGINATED: %s", ctime_r(&originated,
+ tbuf));
attrlen = stream_getw(s);
printf("ATTRLEN: %d\n", attrlen);
diff --git a/bgpd/bgp_labelpool.c b/bgpd/bgp_labelpool.c
index dc032660c..883338610 100644
--- a/bgpd/bgp_labelpool.c
+++ b/bgpd/bgp_labelpool.c
@@ -1131,7 +1131,7 @@ static void show_bgp_nexthop_label_afi(struct vty *vty, afi_t afi,
ifindex2ifname(iter->nh->ifindex,
iter->nh->vrf_id));
tbuf = time(NULL) - (monotime(NULL) - iter->last_update);
- vty_out(vty, " Last update: %s", ctime(&tbuf));
+ vty_out(vty, " Last update: %s", ctime_r(&tbuf, buf));
if (!detail)
continue;
vty_out(vty, " Paths:\n");
diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c
index 00930dea6..3a04514c0 100644
--- a/bgpd/bgp_mplsvpn.c
+++ b/bgpd/bgp_mplsvpn.c
@@ -4205,6 +4205,7 @@ static void show_bgp_mplsvpn_nh_label_bind_internal(struct vty *vty,
struct bgp *bgp_path;
struct bgp_table *table;
time_t tbuf;
+ char buf[32];
vty_out(vty, "Current BGP mpls-vpn nexthop label bind cache, %s\n",
bgp->name_pretty);
@@ -4222,7 +4223,7 @@ static void show_bgp_mplsvpn_nh_label_bind_internal(struct vty *vty,
ifindex2ifname(iter->nh->ifindex,
iter->nh->vrf_id));
tbuf = time(NULL) - (monotime(NULL) - iter->last_update);
- vty_out(vty, " Last update: %s", ctime(&tbuf));
+ vty_out(vty, " Last update: %s", ctime_r(&tbuf, buf));
if (!detail)
continue;
vty_out(vty, " Paths:\n");
diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c
index 7f1a6e73e..d12dc2233 100644
--- a/bgpd/bgp_nexthop.c
+++ b/bgpd/bgp_nexthop.c
@@ -972,6 +972,7 @@ static void bgp_show_nexthop(struct vty *vty, struct bgp *bgp,
{
char buf[PREFIX2STR_BUFFER];
time_t tbuf;
+ char timebuf[32];
struct peer *peer;
json_object *json_last_update = NULL;
json_object *json_nexthop = NULL;
@@ -1070,14 +1071,14 @@ static void bgp_show_nexthop(struct vty *vty, struct bgp *bgp,
json_last_update = json_object_new_object();
json_object_int_add(json_last_update, "epoch", tbuf);
json_object_string_add(json_last_update, "string",
- ctime(&tbuf));
+ ctime_r(&tbuf, timebuf));
json_object_object_add(json_nexthop, "lastUpdate",
json_last_update);
} else {
json_object_int_add(json_nexthop, "lastUpdate", tbuf);
}
} else {
- vty_out(vty, " Last update: %s", ctime(&tbuf));
+ vty_out(vty, " Last update: %s", ctime_r(&tbuf, timebuf));
}
/* show paths dependent on nexthop, if needed. */
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index 1e4334ed5..775213fe4 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -10090,6 +10090,7 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn,
char tag_buf[30];
struct attr *attr = path->attr;
time_t tbuf;
+ char timebuf[32];
json_object *json_bestpath = NULL;
json_object *json_cluster_list = NULL;
json_object *json_cluster_list_list = NULL;
@@ -10983,11 +10984,11 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn,
json_last_update = json_object_new_object();
json_object_int_add(json_last_update, "epoch", tbuf);
json_object_string_add(json_last_update, "string",
- ctime(&tbuf));
+ ctime_r(&tbuf, timebuf));
json_object_object_add(json_path, "lastUpdate",
json_last_update);
} else
- vty_out(vty, " Last update: %s", ctime(&tbuf));
+ vty_out(vty, " Last update: %s", ctime_r(&tbuf, timebuf));
/* Line 10 display PMSI tunnel attribute, if present */
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_PMSI_TUNNEL)) {
diff --git a/bgpd/bgp_updgrp.c b/bgpd/bgp_updgrp.c
index e47ea8aa8..701c7aba5 100644
--- a/bgpd/bgp_updgrp.c
+++ b/bgpd/bgp_updgrp.c
@@ -689,6 +689,7 @@ static int update_group_show_walkcb(struct update_group *updgrp, void *arg)
json_object *json_peers = NULL;
json_object *json_pkt_info = NULL;
time_t epoch_tbuf, tbuf;
+ char timebuf[32];
if (!ctx)
return CMD_SUCCESS;
@@ -724,7 +725,7 @@ static int update_group_show_walkcb(struct update_group *updgrp, void *arg)
json_time = json_object_new_object();
json_object_int_add(json_time, "epoch", epoch_tbuf);
json_object_string_add(json_time, "epochString",
- ctime(&epoch_tbuf));
+ ctime_r(&epoch_tbuf, timebuf));
json_object_object_add(json_updgrp, "groupCreateTime",
json_time);
json_object_string_add(json_updgrp, "afi",
@@ -794,7 +795,7 @@ static int update_group_show_walkcb(struct update_group *updgrp, void *arg)
json_object_int_add(json_subgrp_time, "epoch",
epoch_tbuf);
json_object_string_add(json_subgrp_time, "epochString",
- ctime(&epoch_tbuf));
+ ctime_r(&epoch_tbuf, timebuf));
json_object_object_add(json_subgrp, "groupCreateTime",
json_subgrp_time);
} else {
diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h
index c3e55b711..b80e0e787 100644
--- a/bgpd/bgpd.h
+++ b/bgpd/bgpd.h
@@ -2598,8 +2598,10 @@ static inline int peer_group_af_configured(struct peer_group *group)
static inline char *timestamp_string(time_t ts)
{
time_t tbuf;
+ char timebuf[32];
+
tbuf = time(NULL) - (monotime(NULL) - ts);
- return ctime(&tbuf);
+ return ctime_r(&tbuf, timebuf);
}
static inline bool peer_established(struct peer_connection *connection)