Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bgpd: Fix over-aggressive in de-dup BGP messages #15027

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bgpd/bgp_advertise.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ struct bgp_adj_out {
/* Advertisement information. */
struct bgp_advertise *adv;

/* Attribute hash */
uint32_t attr_hash;
/* Withdraw */
bool is_withdraw;
};

RB_HEAD(bgp_adj_out_rb, bgp_adj_out);
Expand Down
17 changes: 12 additions & 5 deletions bgpd/bgp_updgrp_adv.c
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ void bgp_adj_out_set_subgroup(struct bgp_dest *dest,
struct peer *adv_peer;
struct peer_af *paf;
struct bgp *bgp;
uint32_t attr_hash = attrhash_key_make(attr);
bool no_dedup = false;

peer = SUBGRP_PEER(subgrp);
afi = SUBGRP_AFI(subgrp);
Expand All @@ -533,6 +533,7 @@ void bgp_adj_out_set_subgroup(struct bgp_dest *dest,
&path->tx_addpath));
if (!adj)
return;
no_dedup = true;

subgrp->pscount++;
}
Expand All @@ -543,9 +544,14 @@ void bgp_adj_out_set_subgroup(struct bgp_dest *dest,
* the route wasn't changed actually.
* Do not suppress BGP UPDATES for route-refresh.
*/
if (CHECK_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_DUPLICATES)
&& !CHECK_FLAG(subgrp->sflags, SUBGRP_STATUS_FORCE_UPDATES)
&& adj->attr_hash == attr_hash) {
if (CHECK_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_DUPLICATES) &&
!CHECK_FLAG(subgrp->sflags, SUBGRP_STATUS_FORCE_UPDATES)
/* When the adj entry for dedup check was not there, dedup should not happen */
&& !no_dedup
/* Is not withdraw */
&& !adj->is_withdraw
/* Still have to compare the original attr to make sure nothing has changed */
&& adj->attr && attr && attrhash_cmp(adj->attr, attr)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adj->attr && attr seems redundant: attr can't be NULL here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are so many corner cases, I added the check anyways just to make sure no core dump could happen.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, this should never happen, otherwise we have more problems.

if (BGP_DEBUG(update, UPDATE_OUT)) {
char attr_str[BUFSIZ] = {0};

Expand Down Expand Up @@ -586,7 +592,7 @@ void bgp_adj_out_set_subgroup(struct bgp_dest *dest,

adv->baa = bgp_advertise_attr_intern(subgrp->hash, attr);
adv->adj = adj;
adj->attr_hash = attr_hash;
adj->is_withdraw = false;

/* Add new advertisement to advertisement attribute list. */
bgp_advertise_add(adv->baa, adv);
Expand Down Expand Up @@ -657,6 +663,7 @@ void bgp_adj_out_unset_subgroup(struct bgp_dest *dest,
adv = adj->adv;
adv->dest = dest;
adv->adj = adj;
adj->is_withdraw = true;

/* Note if we need to trigger a packet write */
trigger_write =
Expand Down
Loading