Skip to content

Commit

Permalink
bgpd: correctly delete prefix list on peer close
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Sohn <[email protected]>
  • Loading branch information
Sohn123 committed Sep 25, 2023
1 parent 1da1eaa commit 496502f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
6 changes: 6 additions & 0 deletions bgpd/bgp_fsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1531,6 +1531,12 @@ enum bgp_fsm_state_progress bgp_stop(struct peer_connection *connection)
}
}

/* Reset the rtc-plist */
if (peer->rtc_plist != NULL) {
prefix_list_delete(peer->rtc_plist);
peer->rtc_plist = NULL;
}

/* Reset keepalive and holdtime */
if (CHECK_FLAG(peer->flags, PEER_FLAG_TIMER)) {
peer->v_keepalive = peer->keepalive;
Expand Down
5 changes: 4 additions & 1 deletion bgpd/bgp_rtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ int bgp_nlri_parse_rtc(struct peer *peer, struct attr *attr,
memcpy(&p.u.prefix_rtc.route_target, pnt + 4, psize - 4);

if (withdraw) {
prefix_bgp_rtc_set(peer->host, &p, PREFIX_PERMIT, 0);
if (prefix_bgp_rtc_set(peer->host, &p, PREFIX_PERMIT, 0)) {
zlog_info("Withdrawn prefix %pFX is not in RTC prefix-list",
&p);
}
peer->rtc_plist =
prefix_list_get(AFI_IP, 0, 1, peer->host);
bgp_withdraw(peer, &p, 0, packet->afi, packet->safi,
Expand Down
4 changes: 2 additions & 2 deletions lib/plist.c
Original file line number Diff line number Diff line change
Expand Up @@ -1476,13 +1476,13 @@ int prefix_bgp_rtc_set(char *name, struct prefix *p, int permit, int set)
prefix_list_entry_add(plist, pentry);
} else {
pentry = prefix_list_entry_lookup(
plist, p, (permit ? PREFIX_PERMIT : PREFIX_DENY), 0, 0,
plist, p, (permit ? PREFIX_PERMIT : PREFIX_DENY), -1, 0,
0);

if (!pentry)
return CMD_WARNING_CONFIG_FAILED;

prefix_list_entry_delete(plist, pentry, 1);
prefix_list_entry_delete(plist, pentry, 0);
}

return CMD_SUCCESS;
Expand Down

0 comments on commit 496502f

Please sign in to comment.