From c39506d80f3e42059e00e562f0c5b376a5246ddd Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Thu, 21 Sep 2023 16:00:10 +0300 Subject: [PATCH] bgpd: Initialise timebuf arrays to zeros for dampening reuse timer Avoid having something like this in outputs: Before: ``` munet> r1 shi vtysh -c 'show bgp dampening damp' BGP table version is 10, local router ID is 10.10.10.1, vrf id 0 Default local pref 100, local AS 65001 Status codes: s suppressed, d damped, h history, * valid, > best, = multipath, i internal, r RIB-failure, S Stale, R Removed Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self Origin codes: i - IGP, e - EGP, ? - incomplete RPKI validation codes: V valid, I invalid, N Not found Network From Reuse Path *d 2001:db8:1::1/128 2001:db8::2 (null) 65002 ? *d 2001:db8:2::1/128 2001:db8::2 (null) 65002 ? *d 2001:db8:3::1/128 2001:db8::2 (null) 65002 ? *d 2001:db8:4::1/128 2001:db8::2 (null) 65002 ? *d 2001:db8:5::1/128 2001:db8::2 (null) 65002 ? Displayed 5 routes and 5 total paths munet> r1 shi vtysh -c 'show bgp dampening flap' BGP table version is 10, local router ID is 10.10.10.1, vrf id 0 Default local pref 100, local AS 65001 Status codes: s suppressed, d damped, h history, * valid, > best, = multipath, i internal, r RIB-failure, S Stale, R Removed Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self Origin codes: i - IGP, e - EGP, ? - incomplete RPKI validation codes: V valid, I invalid, N Not found Network From Flaps Duration Reuse Path *d 2001:db8:1::1/128 2001:db8::2 2 00:03:10 (null) 65002 ? *d 2001:db8:2::1/128 2001:db8::2 2 00:03:10 (null) 65002 ? *d 2001:db8:3::1/128 2001:db8::2 2 00:03:10 (null) 65002 ? *d 2001:db8:4::1/128 2001:db8::2 2 00:03:10 (null) 65002 ? *d 2001:db8:5::1/128 2001:db8::2 2 00:03:10 (null) 65002 ? Displayed 5 routes and 5 total paths ``` After: ``` munet> r1 shi vtysh -c 'show bgp dampening damp ' BGP table version is 10, local router ID is 10.10.10.1, vrf id 0 Default local pref 100, local AS 65001 Status codes: s suppressed, d damped, h history, * valid, > best, = multipath, i internal, r RIB-failure, S Stale, R Removed Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self Origin codes: i - IGP, e - EGP, ? - incomplete RPKI validation codes: V valid, I invalid, N Not found Network From Reuse Path *d 2001:db8:1::1/128 2001:db8::2 00:00:00 65002 ? *d 2001:db8:2::1/128 2001:db8::2 00:00:00 65002 ? *d 2001:db8:3::1/128 2001:db8::2 00:00:00 65002 ? *d 2001:db8:4::1/128 2001:db8::2 00:00:00 65002 ? *d 2001:db8:5::1/128 2001:db8::2 00:00:00 65002 ? Displayed 5 routes and 5 total paths munet> r1 shi vtysh -c 'show bgp dampening flap' BGP table version is 10, local router ID is 10.10.10.1, vrf id 0 Default local pref 100, local AS 65001 Status codes: s suppressed, d damped, h history, * valid, > best, = multipath, i internal, r RIB-failure, S Stale, R Removed Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self Origin codes: i - IGP, e - EGP, ? - incomplete RPKI validation codes: V valid, I invalid, N Not found Network From Flaps Duration Reuse Path *d 2001:db8:1::1/128 2001:db8::2 2 00:00:15 00:00:00 65002 ? *d 2001:db8:2::1/128 2001:db8::2 2 00:00:15 00:00:00 65002 ? *d 2001:db8:3::1/128 2001:db8::2 2 00:00:15 00:00:00 65002 ? *d 2001:db8:4::1/128 2001:db8::2 2 00:00:15 00:00:00 65002 ? *d 2001:db8:5::1/128 2001:db8::2 2 00:00:15 00:00:00 65002 ? Displayed 5 routes and 5 total paths ``` Signed-off-by: Donatas Abraitis --- bgpd/bgp_damp.c | 2 +- bgpd/bgp_route.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bgpd/bgp_damp.c b/bgpd/bgp_damp.c index eaa2b85aba..80425ebe7a 100644 --- a/bgpd/bgp_damp.c +++ b/bgpd/bgp_damp.c @@ -558,7 +558,7 @@ void bgp_damp_info_vty(struct vty *vty, struct bgp_path_info *path, afi_t afi, { struct bgp_damp_info *bdi; time_t t_now, t_diff; - char timebuf[BGP_UPTIME_LEN]; + char timebuf[BGP_UPTIME_LEN] = {}; int penalty; struct bgp_damp_config *bdc = &damp[afi][safi]; diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index e73908b0af..95c493a8b2 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -9824,7 +9824,7 @@ static void damp_route_vty_out(struct vty *vty, const struct prefix *p, { struct attr *attr = path->attr; int len; - char timebuf[BGP_UPTIME_LEN]; + char timebuf[BGP_UPTIME_LEN] = {}; json_object *json_path = NULL; if (use_json) @@ -9883,7 +9883,7 @@ static void flap_route_vty_out(struct vty *vty, const struct prefix *p, { struct attr *attr = path->attr; struct bgp_damp_info *bdi; - char timebuf[BGP_UPTIME_LEN]; + char timebuf[BGP_UPTIME_LEN] = {}; int len; json_object *json_path = NULL;