Merge pull request #12187 from mjstapp/mjs_fix_bgp_allowas

bgpd: fix unconfig of allowas_in; add to show output
This commit is contained in:
Russ White 2022-10-25 11:26:06 -04:00 committed by GitHub
commit bcc6ffbd7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 7 deletions

View File

@ -4000,6 +4000,7 @@ int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
bool force_evpn_import = false;
safi_t orig_safi = safi;
bool leak_success = true;
int allowas_in = 0;
if (frrtrace_enabled(frr_bgp, process_update)) {
char pfxprint[PREFIX2STR_BUFFER];
@ -4045,6 +4046,10 @@ int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
&& peer != bgp->peer_self)
bgp_adj_in_set(dest, peer, attr, addpath_id);
/* Update permitted loop count */
if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_ALLOWAS_IN))
allowas_in = peer->allowas_in[afi][safi];
/* Check previously received route. */
for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next)
if (pi->peer == peer && pi->type == type
@ -4054,8 +4059,8 @@ int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
/* AS path local-as loop check. */
if (peer->change_local_as) {
if (peer->allowas_in[afi][safi])
aspath_loop_count = peer->allowas_in[afi][safi];
if (allowas_in)
aspath_loop_count = allowas_in;
else if (!CHECK_FLAG(peer->flags,
PEER_FLAG_LOCAL_AS_NO_PREPEND))
aspath_loop_count = 1;
@ -4078,11 +4083,10 @@ int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
/* AS path loop check. */
if (do_loop_check) {
if (aspath_loop_check(attr->aspath, bgp->as)
> peer->allowas_in[afi][safi]
|| (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)
&& aspath_loop_check(attr->aspath, bgp->confed_id)
> peer->allowas_in[afi][safi])) {
if (aspath_loop_check(attr->aspath, bgp->as) > allowas_in ||
(CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) &&
(aspath_loop_check(attr->aspath, bgp->confed_id) >
allowas_in))) {
peer->stat_pfx_aspath_loop++;
reason = "as-path contains our own AS;";
goto filtered;

View File

@ -12282,6 +12282,16 @@ static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi,
json_addr,
"privateAsNumsRemovedInUpdatesToNbr");
if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_ALLOWAS_IN)) {
if (CHECK_FLAG(p->af_flags[afi][safi],
PEER_FLAG_ALLOWAS_IN_ORIGIN))
json_object_boolean_true_add(json_addr,
"allowAsInOrigin");
else
json_object_int_add(json_addr, "allowAsInCount",
p->allowas_in[afi][safi]);
}
if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE)
json_object_boolean_true_add(
json_addr,
@ -12598,6 +12608,17 @@ static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi,
vty_out(vty,
" Private AS numbers removed in updates to this neighbor\n");
if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_ALLOWAS_IN)) {
if (CHECK_FLAG(p->af_flags[afi][safi],
PEER_FLAG_ALLOWAS_IN_ORIGIN))
vty_out(vty,
" Local AS allowed as path origin\n");
else
vty_out(vty,
" Local AS allowed in path, %d occurrences\n",
p->allowas_in[afi][safi]);
}
if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE)
vty_out(vty, " %s\n",
bgp_addpath_names(p->addpath_type[afi][safi])