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

Bgp filter fun (backport #15466) #15548

Merged
merged 3 commits into from
Mar 14, 2024
Merged
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
5 changes: 3 additions & 2 deletions bgpd/bgp_conditional_adv.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,9 @@ static void bgp_conditional_adv_routes(struct peer *peer, afi_t afi,
if (update_type == UPDATE_TYPE_ADVERTISE &&
subgroup_announce_check(dest, pi, subgrp, dest_p,
&attr, &advmap_attr)) {
bgp_adj_out_set_subgroup(dest, subgrp, &attr,
pi);
if (!bgp_adj_out_set_subgroup(dest, subgrp,
&attr, pi))
bgp_attr_flush(&attr);
} else {
/* If default originate is enabled for
* the peer, do not send explicit
Expand Down
34 changes: 19 additions & 15 deletions bgpd/bgp_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -2956,7 +2956,7 @@ void subgroup_process_announce_selected(struct update_subgroup *subgrp,
{
const struct prefix *p;
struct peer *onlypeer;
struct attr attr;
struct attr attr = { 0 }, *pattr = &attr;
struct bgp *bgp;
bool advertise;

Expand Down Expand Up @@ -2984,26 +2984,30 @@ void subgroup_process_announce_selected(struct update_subgroup *subgrp,
advertise = bgp_check_advertise(bgp, dest, safi);

if (selected) {
if (subgroup_announce_check(dest, selected, subgrp, p, &attr,
if (subgroup_announce_check(dest, selected, subgrp, p, pattr,
NULL)) {
/* Route is selected, if the route is already installed
* in FIB, then it is advertised
*/
if (advertise) {
if (!bgp_check_withdrawal(bgp, dest, safi)) {
struct attr *adv_attr =
bgp_attr_intern(&attr);

bgp_adj_out_set_subgroup(dest, subgrp,
adv_attr,
selected);
} else
if (!bgp_adj_out_set_subgroup(dest,
subgrp,
pattr,
selected))
bgp_attr_flush(pattr);
} else {
bgp_adj_out_unset_subgroup(
dest, subgrp, 1, addpath_tx_id);
}
} else
bgp_attr_flush(pattr);
}
} else
bgp_attr_flush(pattr);
} else {
bgp_adj_out_unset_subgroup(dest, subgrp, 1,
addpath_tx_id);
bgp_attr_flush(pattr);
}
}

/* If selected is NULL we must withdraw the path using addpath_tx_id */
Expand Down Expand Up @@ -5958,10 +5962,10 @@ bool bgp_outbound_policy_exists(struct peer *peer, struct bgp_filter *filter)
if (peer->sort == BGP_PEER_IBGP)
return true;

if (peer->sort == BGP_PEER_EBGP
&& (ROUTE_MAP_OUT_NAME(filter) || PREFIX_LIST_OUT_NAME(filter)
|| FILTER_LIST_OUT_NAME(filter)
|| DISTRIBUTE_OUT_NAME(filter)))
if (peer->sort == BGP_PEER_EBGP &&
(ROUTE_MAP_OUT_NAME(filter) || PREFIX_LIST_OUT_NAME(filter) ||
FILTER_LIST_OUT_NAME(filter) || DISTRIBUTE_OUT_NAME(filter) ||
UNSUPPRESS_MAP_NAME(filter)))
return true;
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion bgpd/bgp_updgrp.h
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ extern struct bgp_adj_out *bgp_adj_out_alloc(struct update_subgroup *subgrp,
extern void bgp_adj_out_remove_subgroup(struct bgp_dest *dest,
struct bgp_adj_out *adj,
struct update_subgroup *subgrp);
extern void bgp_adj_out_set_subgroup(struct bgp_dest *dest,
extern bool bgp_adj_out_set_subgroup(struct bgp_dest *dest,
struct update_subgroup *subgrp,
struct attr *attr,
struct bgp_path_info *path);
Expand Down
41 changes: 23 additions & 18 deletions bgpd/bgp_updgrp_adv.c
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ bgp_advertise_clean_subgroup(struct update_subgroup *subgrp,
return next;
}

void bgp_adj_out_set_subgroup(struct bgp_dest *dest,
bool bgp_adj_out_set_subgroup(struct bgp_dest *dest,
struct update_subgroup *subgrp, struct attr *attr,
struct bgp_path_info *path)
{
Expand All @@ -517,7 +517,7 @@ void bgp_adj_out_set_subgroup(struct bgp_dest *dest,
bgp = SUBGRP_INST(subgrp);

if (DISABLE_BGP_ANNOUNCE)
return;
return false;

/* Look for adjacency information. */
adj = adj_lookup(
Expand All @@ -533,7 +533,7 @@ void bgp_adj_out_set_subgroup(struct bgp_dest *dest,
bgp_addpath_id_for_peer(peer, afi, safi,
&path->tx_addpath));
if (!adj)
return;
return false;

subgrp->pscount++;
}
Expand Down Expand Up @@ -572,7 +572,7 @@ void bgp_adj_out_set_subgroup(struct bgp_dest *dest,
* will never be able to coalesce the 3rd peer down
*/
subgrp->version = MAX(subgrp->version, dest->version);
return;
return false;
}

if (adj->adv)
Expand Down Expand Up @@ -620,6 +620,8 @@ void bgp_adj_out_set_subgroup(struct bgp_dest *dest,
bgp_adv_fifo_add_tail(&subgrp->sync->update, adv);

subgrp->version = MAX(subgrp->version, dest->version);

return true;
}

/* The only time 'withdraw' will be false is if we are sending
Expand Down Expand Up @@ -829,8 +831,9 @@ void subgroup_announce_route(struct update_subgroup *subgrp)
void subgroup_default_originate(struct update_subgroup *subgrp, int withdraw)
{
struct bgp *bgp;
struct attr attr;
struct attr attr = { 0 };
struct attr *new_attr = &attr;
struct aspath *aspath;
struct prefix p;
struct peer *from;
struct bgp_dest *dest;
Expand Down Expand Up @@ -868,6 +871,7 @@ void subgroup_default_originate(struct update_subgroup *subgrp, int withdraw)
/* make coverity happy */
assert(attr.aspath);

aspath = attr.aspath;
attr.med = 0;
attr.flag |= ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC);

Expand Down Expand Up @@ -968,18 +972,19 @@ void subgroup_default_originate(struct update_subgroup *subgrp, int withdraw)
if (dest) {
for (pi = bgp_dest_get_bgp_path_info(dest); pi;
pi = pi->next) {
if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED))
if (subgroup_announce_check(
dest, pi, subgrp,
bgp_dest_get_prefix(dest),
&attr, NULL)) {
struct attr *default_attr =
bgp_attr_intern(&attr);

bgp_adj_out_set_subgroup(
dest, subgrp,
default_attr, pi);
}
if (!CHECK_FLAG(pi->flags, BGP_PATH_SELECTED))
continue;

if (subgroup_announce_check(dest, pi, subgrp,
bgp_dest_get_prefix(
dest),
&attr, NULL)) {
if (!bgp_adj_out_set_subgroup(dest,
subgrp,
&attr, pi))
bgp_attr_flush(&attr);
} else
bgp_attr_flush(&attr);
}
bgp_dest_unlock_node(dest);
}
Expand Down Expand Up @@ -1023,7 +1028,7 @@ void subgroup_default_originate(struct update_subgroup *subgrp, int withdraw)
}
}

aspath_unintern(&attr.aspath);
aspath_unintern(&aspath);
}

/*
Expand Down
Loading