mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-08 12:49:18 +00:00
Merge pull request #15466 from donaldsharp/bgp_filter_fun
Bgp filter fun
This commit is contained in:
commit
d1d79f4fa5
@ -122,8 +122,9 @@ static void bgp_conditional_adv_routes(struct peer *peer, afi_t afi,
|
|||||||
if (update_type == UPDATE_TYPE_ADVERTISE &&
|
if (update_type == UPDATE_TYPE_ADVERTISE &&
|
||||||
subgroup_announce_check(dest, pi, subgrp, dest_p,
|
subgroup_announce_check(dest, pi, subgrp, dest_p,
|
||||||
&attr, &advmap_attr)) {
|
&attr, &advmap_attr)) {
|
||||||
bgp_adj_out_set_subgroup(dest, subgrp, &attr,
|
if (!bgp_adj_out_set_subgroup(dest, subgrp,
|
||||||
pi);
|
&attr, pi))
|
||||||
|
bgp_attr_flush(&attr);
|
||||||
} else {
|
} else {
|
||||||
/* If default originate is enabled for
|
/* If default originate is enabled for
|
||||||
* the peer, do not send explicit
|
* the peer, do not send explicit
|
||||||
|
@ -2979,7 +2979,7 @@ void subgroup_process_announce_selected(struct update_subgroup *subgrp,
|
|||||||
{
|
{
|
||||||
const struct prefix *p;
|
const struct prefix *p;
|
||||||
struct peer *onlypeer;
|
struct peer *onlypeer;
|
||||||
struct attr attr;
|
struct attr attr = { 0 }, *pattr = &attr;
|
||||||
struct bgp *bgp;
|
struct bgp *bgp;
|
||||||
bool advertise;
|
bool advertise;
|
||||||
|
|
||||||
@ -3007,26 +3007,30 @@ void subgroup_process_announce_selected(struct update_subgroup *subgrp,
|
|||||||
advertise = bgp_check_advertise(bgp, dest, safi);
|
advertise = bgp_check_advertise(bgp, dest, safi);
|
||||||
|
|
||||||
if (selected) {
|
if (selected) {
|
||||||
if (subgroup_announce_check(dest, selected, subgrp, p, &attr,
|
if (subgroup_announce_check(dest, selected, subgrp, p, pattr,
|
||||||
NULL)) {
|
NULL)) {
|
||||||
/* Route is selected, if the route is already installed
|
/* Route is selected, if the route is already installed
|
||||||
* in FIB, then it is advertised
|
* in FIB, then it is advertised
|
||||||
*/
|
*/
|
||||||
if (advertise) {
|
if (advertise) {
|
||||||
if (!bgp_check_withdrawal(bgp, dest, safi)) {
|
if (!bgp_check_withdrawal(bgp, dest, safi)) {
|
||||||
struct attr *adv_attr =
|
if (!bgp_adj_out_set_subgroup(dest,
|
||||||
bgp_attr_intern(&attr);
|
subgrp,
|
||||||
|
pattr,
|
||||||
bgp_adj_out_set_subgroup(dest, subgrp,
|
selected))
|
||||||
adv_attr,
|
bgp_attr_flush(pattr);
|
||||||
selected);
|
} else {
|
||||||
} else
|
|
||||||
bgp_adj_out_unset_subgroup(
|
bgp_adj_out_unset_subgroup(
|
||||||
dest, subgrp, 1, addpath_tx_id);
|
dest, subgrp, 1, addpath_tx_id);
|
||||||
}
|
bgp_attr_flush(pattr);
|
||||||
} else
|
}
|
||||||
|
} else
|
||||||
|
bgp_attr_flush(pattr);
|
||||||
|
} else {
|
||||||
bgp_adj_out_unset_subgroup(dest, subgrp, 1,
|
bgp_adj_out_unset_subgroup(dest, subgrp, 1,
|
||||||
addpath_tx_id);
|
addpath_tx_id);
|
||||||
|
bgp_attr_flush(pattr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If selected is NULL we must withdraw the path using addpath_tx_id */
|
/* If selected is NULL we must withdraw the path using addpath_tx_id */
|
||||||
@ -6006,10 +6010,10 @@ bool bgp_outbound_policy_exists(struct peer *peer, struct bgp_filter *filter)
|
|||||||
if (peer->sort == BGP_PEER_IBGP)
|
if (peer->sort == BGP_PEER_IBGP)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (peer->sort == BGP_PEER_EBGP
|
if (peer->sort == BGP_PEER_EBGP &&
|
||||||
&& (ROUTE_MAP_OUT_NAME(filter) || PREFIX_LIST_OUT_NAME(filter)
|
(ROUTE_MAP_OUT_NAME(filter) || PREFIX_LIST_OUT_NAME(filter) ||
|
||||||
|| FILTER_LIST_OUT_NAME(filter)
|
FILTER_LIST_OUT_NAME(filter) || DISTRIBUTE_OUT_NAME(filter) ||
|
||||||
|| DISTRIBUTE_OUT_NAME(filter)))
|
UNSUPPRESS_MAP_NAME(filter)))
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -441,7 +441,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,
|
extern void bgp_adj_out_remove_subgroup(struct bgp_dest *dest,
|
||||||
struct bgp_adj_out *adj,
|
struct bgp_adj_out *adj,
|
||||||
struct update_subgroup *subgrp);
|
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 update_subgroup *subgrp,
|
||||||
struct attr *attr,
|
struct attr *attr,
|
||||||
struct bgp_path_info *path);
|
struct bgp_path_info *path);
|
||||||
|
@ -520,7 +520,7 @@ bgp_advertise_clean_subgroup(struct update_subgroup *subgrp,
|
|||||||
return next;
|
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 update_subgroup *subgrp, struct attr *attr,
|
||||||
struct bgp_path_info *path)
|
struct bgp_path_info *path)
|
||||||
{
|
{
|
||||||
@ -540,7 +540,7 @@ void bgp_adj_out_set_subgroup(struct bgp_dest *dest,
|
|||||||
bgp = SUBGRP_INST(subgrp);
|
bgp = SUBGRP_INST(subgrp);
|
||||||
|
|
||||||
if (DISABLE_BGP_ANNOUNCE)
|
if (DISABLE_BGP_ANNOUNCE)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
/* Look for adjacency information. */
|
/* Look for adjacency information. */
|
||||||
adj = adj_lookup(
|
adj = adj_lookup(
|
||||||
@ -556,7 +556,7 @@ void bgp_adj_out_set_subgroup(struct bgp_dest *dest,
|
|||||||
bgp_addpath_id_for_peer(peer, afi, safi,
|
bgp_addpath_id_for_peer(peer, afi, safi,
|
||||||
&path->tx_addpath));
|
&path->tx_addpath));
|
||||||
if (!adj)
|
if (!adj)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
subgrp->pscount++;
|
subgrp->pscount++;
|
||||||
}
|
}
|
||||||
@ -595,7 +595,7 @@ void bgp_adj_out_set_subgroup(struct bgp_dest *dest,
|
|||||||
* will never be able to coalesce the 3rd peer down
|
* will never be able to coalesce the 3rd peer down
|
||||||
*/
|
*/
|
||||||
subgrp->version = MAX(subgrp->version, dest->version);
|
subgrp->version = MAX(subgrp->version, dest->version);
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (adj->adv)
|
if (adj->adv)
|
||||||
@ -643,6 +643,8 @@ void bgp_adj_out_set_subgroup(struct bgp_dest *dest,
|
|||||||
bgp_adv_fifo_add_tail(&subgrp->sync->update, adv);
|
bgp_adv_fifo_add_tail(&subgrp->sync->update, adv);
|
||||||
|
|
||||||
subgrp->version = MAX(subgrp->version, dest->version);
|
subgrp->version = MAX(subgrp->version, dest->version);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The only time 'withdraw' will be false is if we are sending
|
/* The only time 'withdraw' will be false is if we are sending
|
||||||
@ -852,8 +854,9 @@ void subgroup_announce_route(struct update_subgroup *subgrp)
|
|||||||
void subgroup_default_originate(struct update_subgroup *subgrp, bool withdraw)
|
void subgroup_default_originate(struct update_subgroup *subgrp, bool withdraw)
|
||||||
{
|
{
|
||||||
struct bgp *bgp;
|
struct bgp *bgp;
|
||||||
struct attr attr;
|
struct attr attr = { 0 };
|
||||||
struct attr *new_attr = &attr;
|
struct attr *new_attr = &attr;
|
||||||
|
struct aspath *aspath;
|
||||||
struct prefix p;
|
struct prefix p;
|
||||||
struct peer *from;
|
struct peer *from;
|
||||||
struct bgp_dest *dest;
|
struct bgp_dest *dest;
|
||||||
@ -891,6 +894,7 @@ void subgroup_default_originate(struct update_subgroup *subgrp, bool withdraw)
|
|||||||
/* make coverity happy */
|
/* make coverity happy */
|
||||||
assert(attr.aspath);
|
assert(attr.aspath);
|
||||||
|
|
||||||
|
aspath = attr.aspath;
|
||||||
attr.med = 0;
|
attr.med = 0;
|
||||||
attr.flag |= ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC);
|
attr.flag |= ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC);
|
||||||
|
|
||||||
@ -991,18 +995,19 @@ void subgroup_default_originate(struct update_subgroup *subgrp, bool withdraw)
|
|||||||
if (dest) {
|
if (dest) {
|
||||||
for (pi = bgp_dest_get_bgp_path_info(dest); pi;
|
for (pi = bgp_dest_get_bgp_path_info(dest); pi;
|
||||||
pi = pi->next) {
|
pi = pi->next) {
|
||||||
if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED))
|
if (!CHECK_FLAG(pi->flags, BGP_PATH_SELECTED))
|
||||||
if (subgroup_announce_check(
|
continue;
|
||||||
dest, pi, subgrp,
|
|
||||||
bgp_dest_get_prefix(dest),
|
|
||||||
&attr, NULL)) {
|
|
||||||
struct attr *default_attr =
|
|
||||||
bgp_attr_intern(&attr);
|
|
||||||
|
|
||||||
bgp_adj_out_set_subgroup(
|
if (subgroup_announce_check(dest, pi, subgrp,
|
||||||
dest, subgrp,
|
bgp_dest_get_prefix(
|
||||||
default_attr, pi);
|
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);
|
bgp_dest_unlock_node(dest);
|
||||||
}
|
}
|
||||||
@ -1046,7 +1051,7 @@ void subgroup_default_originate(struct update_subgroup *subgrp, bool withdraw)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
aspath_unintern(&attr.aspath);
|
aspath_unintern(&aspath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user