Skip to content

Commit

Permalink
bgpd: Ignore Prefix-SID attribute via EBGP
Browse files Browse the repository at this point in the history
Also, allow filtering this attribute via `path-attribute discard/treat-as-widthraw`.

Signed-off-by: Donatas Abraitis <[email protected]>
  • Loading branch information
ton31337 committed Aug 24, 2024
1 parent 05c17ef commit 53bf734
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion bgpd/bgp_attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -3300,6 +3300,22 @@ enum bgp_attr_parse_ret bgp_attr_prefix_sid(struct bgp_attr_parser_args *args)
size_t headersz = sizeof(type) + sizeof(length);
size_t psid_parsed_length = 0;

/* A BGP speaker receiving a BGP Prefix-SID attribute from an
* External BGP (EBGP) neighbor residing outside the boundaries
* of the SR domain MUST discard the attribute unless it is
* configured to accept the attribute from the EBGP neighbor.
* A BGP speaker SHOULD log an error for further analysis when
* discarding an attribute.
*/
if (peer->sort == BGP_PEER_EBGP && peer->sub_sort != BGP_PEER_EBGP_OAD) {
zlog_warn("%pBP received Prefix-SID attribute via eBGP, ignoring",
peer);
goto prefix_sid_ignore;
}

if (peer->discard_attrs[args->type] || peer->withdraw_attrs[args->type])
goto prefix_sid_ignore;

while (STREAM_READABLE(peer->curr) > 0
&& psid_parsed_length < args->length) {

Expand Down Expand Up @@ -3346,7 +3362,10 @@ enum bgp_attr_parse_ret bgp_attr_prefix_sid(struct bgp_attr_parser_args *args)

SET_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_PREFIX_SID));

return BGP_ATTR_PARSE_PROCEED;
prefix_sid_ignore:
stream_forward_getp(peer->curr, args->length);

return bgp_attr_ignore(peer, args->type);
}

/* PMSI tunnel attribute (RFC 6514)
Expand Down

0 comments on commit 53bf734

Please sign in to comment.