Merge pull request #14464 from opensourcerouting/fix/dampening_crash

bgpd: Fix dampening info crash
This commit is contained in:
Donald Sharp 2023-09-23 09:51:01 -04:00 committed by GitHub
commit 7d12e26121
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 15 deletions

View File

@ -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; struct bgp_damp_info *bdi;
time_t t_now, t_diff; time_t t_now, t_diff;
char timebuf[BGP_UPTIME_LEN]; char timebuf[BGP_UPTIME_LEN] = {};
int penalty; int penalty;
struct bgp_damp_config *bdc = &damp[afi][safi]; struct bgp_damp_config *bdc = &damp[afi][safi];
@ -570,7 +570,9 @@ void bgp_damp_info_vty(struct vty *vty, struct bgp_path_info *path, afi_t afi,
/* If dampening is not enabled or there is no dampening information, /* If dampening is not enabled or there is no dampening information,
return immediately. */ return immediately. */
if (!bdc || !bdi) if (!CHECK_FLAG(path->peer->bgp->af_flags[afi][safi],
BGP_CONFIG_DAMPENING) ||
!bdi)
return; return;
/* Calculate new penalty. */ /* Calculate new penalty. */
@ -624,7 +626,9 @@ const char *bgp_damp_reuse_time_vty(struct vty *vty, struct bgp_path_info *path,
/* If dampening is not enabled or there is no dampening information, /* If dampening is not enabled or there is no dampening information,
return immediately. */ return immediately. */
if (!bdc || !bdi) if (!CHECK_FLAG(path->peer->bgp->af_flags[afi][safi],
BGP_CONFIG_DAMPENING) ||
!bdi)
return NULL; return NULL;
/* Calculate new penalty. */ /* Calculate new penalty. */

View File

@ -3142,7 +3142,7 @@ int bgp_show_mpls_vpn(struct vty *vty, afi_t afi, struct prefix_rd *prd,
return CMD_WARNING; return CMD_WARNING;
} }
table = bgp->rib[afi][SAFI_MPLS_VPN]; table = bgp->rib[afi][SAFI_MPLS_VPN];
return bgp_show_table_rd(vty, bgp, SAFI_MPLS_VPN, table, prd, type, return bgp_show_table_rd(vty, bgp, afi, SAFI_MPLS_VPN, table, prd, type,
output_arg, show_flags); output_arg, show_flags);
} }

View File

@ -9824,7 +9824,7 @@ static void damp_route_vty_out(struct vty *vty, const struct prefix *p,
{ {
struct attr *attr = path->attr; struct attr *attr = path->attr;
int len; int len;
char timebuf[BGP_UPTIME_LEN]; char timebuf[BGP_UPTIME_LEN] = {};
json_object *json_path = NULL; json_object *json_path = NULL;
if (use_json) 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 attr *attr = path->attr;
struct bgp_damp_info *bdi; struct bgp_damp_info *bdi;
char timebuf[BGP_UPTIME_LEN]; char timebuf[BGP_UPTIME_LEN] = {};
int len; int len;
json_object *json_path = NULL; json_object *json_path = NULL;
@ -11085,7 +11085,7 @@ static int bgp_show_community(struct vty *vty, struct bgp *bgp,
const char *comstr, int exact, afi_t afi, const char *comstr, int exact, afi_t afi,
safi_t safi, uint16_t show_flags); safi_t safi, uint16_t show_flags);
static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi, static int bgp_show_table(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
struct bgp_table *table, enum bgp_show_type type, struct bgp_table *table, enum bgp_show_type type,
void *output_arg, const char *rd, int is_last, void *output_arg, const char *rd, int is_last,
unsigned long *output_cum, unsigned long *total_cum, unsigned long *output_cum, unsigned long *total_cum,
@ -11446,12 +11446,12 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi,
if (type == bgp_show_type_dampend_paths if (type == bgp_show_type_dampend_paths
|| type == bgp_show_type_damp_neighbor) || type == bgp_show_type_damp_neighbor)
damp_route_vty_out(vty, dest_p, pi, display, damp_route_vty_out(vty, dest_p, pi, display,
AFI_IP, safi, use_json, afi, safi, use_json,
json_paths); json_paths);
else if (type == bgp_show_type_flap_statistics else if (type == bgp_show_type_flap_statistics
|| type == bgp_show_type_flap_neighbor) || type == bgp_show_type_flap_neighbor)
flap_route_vty_out(vty, dest_p, pi, display, flap_route_vty_out(vty, dest_p, pi, display,
AFI_IP, safi, use_json, afi, safi, use_json,
json_paths); json_paths);
else { else {
if (detail_routes || detail_json) { if (detail_routes || detail_json) {
@ -11607,7 +11607,7 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi,
return CMD_SUCCESS; return CMD_SUCCESS;
} }
int bgp_show_table_rd(struct vty *vty, struct bgp *bgp, safi_t safi, int bgp_show_table_rd(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
struct bgp_table *table, struct prefix_rd *prd_match, struct bgp_table *table, struct prefix_rd *prd_match,
enum bgp_show_type type, void *output_arg, enum bgp_show_type type, void *output_arg,
uint16_t show_flags) uint16_t show_flags)
@ -11636,7 +11636,7 @@ int bgp_show_table_rd(struct vty *vty, struct bgp *bgp, safi_t safi,
memcpy(&prd, dest_p, sizeof(struct prefix_rd)); memcpy(&prd, dest_p, sizeof(struct prefix_rd));
prefix_rd2str(&prd, rd, sizeof(rd), bgp->asnotation); prefix_rd2str(&prd, rd, sizeof(rd), bgp->asnotation);
bgp_show_table(vty, bgp, safi, itable, type, output_arg, bgp_show_table(vty, bgp, afi, safi, itable, type, output_arg,
rd, next == NULL, &output_cum, rd, next == NULL, &output_cum,
&total_cum, &json_header_depth, &total_cum, &json_header_depth,
show_flags, RPKI_NOT_BEING_USED); show_flags, RPKI_NOT_BEING_USED);
@ -11686,7 +11686,7 @@ static int bgp_show(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
table = bgp->rib[afi][safi]; table = bgp->rib[afi][safi];
/* use MPLS and ENCAP specific shows until they are merged */ /* use MPLS and ENCAP specific shows until they are merged */
if (safi == SAFI_MPLS_VPN) { if (safi == SAFI_MPLS_VPN) {
return bgp_show_table_rd(vty, bgp, safi, table, NULL, type, return bgp_show_table_rd(vty, bgp, afi, safi, table, NULL, type,
output_arg, show_flags); output_arg, show_flags);
} }
@ -11699,7 +11699,7 @@ static int bgp_show(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
if (safi == SAFI_EVPN) if (safi == SAFI_EVPN)
return bgp_evpn_show_all_routes(vty, bgp, type, use_json, 0); return bgp_evpn_show_all_routes(vty, bgp, type, use_json, 0);
return bgp_show_table(vty, bgp, safi, table, type, output_arg, NULL, 1, return bgp_show_table(vty, bgp, afi, safi, table, type, output_arg, NULL, 1,
NULL, NULL, &json_header_depth, show_flags, NULL, NULL, &json_header_depth, show_flags,
rpki_target_state); rpki_target_state);
} }
@ -12023,7 +12023,7 @@ static void bgp_show_path_info(const struct prefix_rd *pfx_rd,
|| CHECK_FLAG(pi->flags, BGP_PATH_SELECTED)))) || CHECK_FLAG(pi->flags, BGP_PATH_SELECTED))))
route_vty_out_detail(vty, bgp, bgp_node, route_vty_out_detail(vty, bgp, bgp_node,
bgp_dest_get_prefix(bgp_node), pi, bgp_dest_get_prefix(bgp_node), pi,
AFI_IP, safi, rpki_curr_state, afi, safi, rpki_curr_state,
json_paths); json_paths);
} }

View File

@ -887,7 +887,7 @@ extern void route_vty_out_detail(struct vty *vty, struct bgp *bgp,
struct bgp_path_info *path, afi_t afi, struct bgp_path_info *path, afi_t afi,
safi_t safi, enum rpki_states, safi_t safi, enum rpki_states,
json_object *json_paths); json_object *json_paths);
extern int bgp_show_table_rd(struct vty *vty, struct bgp *bgp, safi_t safi, extern int bgp_show_table_rd(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
struct bgp_table *table, struct prefix_rd *prd, struct bgp_table *table, struct prefix_rd *prd,
enum bgp_show_type type, void *output_arg, enum bgp_show_type type, void *output_arg,
uint16_t show_flags); uint16_t show_flags);