forked from Mirror/frr
bgpd: fix Prefix-SID parsing failure case
Prefix-SID path attribute Label-index TLV (type-1) is used by SR-MPLS. And Label-index TLV MUST ignored if that path attribute is append on non-Labeled-unicast UPDATE message described on [ref1]. There is a problem case exist arround this implementation. This commit fix that. Before this commit, unfortunally, setting Label-Index value is skipped at somecases. because, Label-Index TLV implementation check the AFI/SAFI pair. by mp_update variable that is set by bgp_mp_reach_parse function. if MP_REACH_NLRI is present after PREFIX_SID, bgp_attr_psid_sub function can't understand AFI/SAFI pair. and the order of each path attributes is never no-deterministic thing for receiver.[ref2] In this commit, I re-located checking code of AFI/SAFI pair after path-attr loop. [ref1](https://tools.ietf.org/html/draft-ietf-idr-bgp-prefix-sid-27#section-3.2) > The Originator SRGB TLV may only appear in a BGP Prefix-SID attribute > attached to IPv4/IPv6 Labeled Unicast prefixes ([RFC8277]). It MUST > be ignored when received for other BGP AFI/SAFI combinations. [ref2](https://tools.ietf.org/html/rfc4271#section-5) > The sender of an UPDATE message SHOULD order path attributes within > the UPDATE message in ascending order of attribute type. The > receiver of an UPDATE message MUST be prepared to handle path > attributes within UPDATE messages that are out of order. Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
This commit is contained in:
parent
38774fc5e6
commit
e5d4cda0a7
|
@ -2382,15 +2382,6 @@ static bgp_attr_parse_ret_t bgp_attr_psid_sub(uint8_t type, uint16_t length,
|
||||||
/* Store label index; subsequently, we'll check on
|
/* Store label index; subsequently, we'll check on
|
||||||
* address-family */
|
* address-family */
|
||||||
attr->label_index = label_index;
|
attr->label_index = label_index;
|
||||||
|
|
||||||
/*
|
|
||||||
* Ignore the Label index attribute unless received for
|
|
||||||
* labeled-unicast
|
|
||||||
* SAFI.
|
|
||||||
*/
|
|
||||||
if (!mp_update->length
|
|
||||||
|| mp_update->safi != SAFI_LABELED_UNICAST)
|
|
||||||
attr->label_index = BGP_INVALID_LABEL_INDEX;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Placeholder code for the IPv6 SID type */
|
/* Placeholder code for the IPv6 SID type */
|
||||||
|
@ -3078,6 +3069,17 @@ bgp_attr_parse_ret_t bgp_attr_parse(struct peer *peer, struct attr *attr,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* draft-ietf-idr-bgp-prefix-sid-27#section-3:
|
||||||
|
* About Prefix-SID path attribute,
|
||||||
|
* Label-Index TLV(type1) and The Originator SRGB TLV(type-3)
|
||||||
|
* may only appear in a BGP Prefix-SID attribute attached to
|
||||||
|
* IPv4/IPv6 Labeled Unicast prefixes ([RFC8277]).
|
||||||
|
* It MUST be ignored when received for other BGP AFI/SAFI combinations.
|
||||||
|
*/
|
||||||
|
if (!attr->mp_nexthop_len || mp_update->safi != SAFI_LABELED_UNICAST)
|
||||||
|
attr->label_index = BGP_INVALID_LABEL_INDEX;
|
||||||
|
|
||||||
/* Check final read pointer is same as end pointer. */
|
/* Check final read pointer is same as end pointer. */
|
||||||
if (BGP_INPUT_PNT(peer) != endp) {
|
if (BGP_INPUT_PNT(peer) != endp) {
|
||||||
flog_warn(EC_BGP_ATTRIBUTES_MISMATCH,
|
flog_warn(EC_BGP_ATTRIBUTES_MISMATCH,
|
||||||
|
|
Loading…
Reference in a new issue