]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: Use strict AS4 capability when processing parsing/generating pkts
authorDonatas Abraitis <donatas.abraitis@gmail.com>
Sun, 1 Aug 2021 06:29:31 +0000 (09:29 +0300)
committerDonatas Abraitis <donatas.abraitis@gmail.com>
Sun, 1 Aug 2021 06:56:48 +0000 (09:56 +0300)
PeerA sets `dont-capability-negotiate` for PeerB. It does not send any
capabilities to PeerB. This leads to situation when PeerA received AS4 cap,
while it doesn't send AS4 to PeerB and tries parsing AS_PATH using 32bits.

[GTTPK-RX2GP][EC 33554436] Malformed AS path from 192.168.0.2, length is 4
[SM0KX-WXMGK] bgp_attr_malformed: attributes: , origin ?
[P7TRR-4J6XT][EC 33554487] 192.168.0.2: Attribute AS_PATH, parse error - treating as withdrawal
[WX70K-6XXVF][EC 33554454] 192.168.0.2 rcvd UPDATE with errors in attr(s)!! Withdrawing route.
[Z2KFR-ZGJC8] 192.168.0.2 rcvd UPDATE w/ attr: , origin ?
[P9VY3-5B6NX] 192.168.0.2 rcvd UPDATE wlen 0 attrlen 80 alen 73
[QMZ79-K2DH7][EC 33554454] 192.168.0.2 [Error] Update packet error (wrong prefix length 64 for afi 1)
[P9SYB-54XRZ][EC 33554454] 192.168.0.2 [Error] Error parsing NLRI
[V1CHF-JSGRR] %NOTIFICATION: sent to neighbor 192.168.0.2 3/10 (UPDATE Message Error/Invalid Network Field) 0 bytes
[HTHRX-GQYGJ][EC 33554454] bgp_process_packet: BGP UPDATE receipt failed for peer: 192.168.0.2

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
bgpd/bgp_attr.c

index adf408220e036c3aec05c63f3c4adbbb76dd2cc8..0870748f7e24b167ae8f777c41353571bf6314d7 100644 (file)
@@ -1497,8 +1497,10 @@ static int bgp_attr_aspath(struct bgp_attr_parser_args *args)
         * peer with AS4 => will get 4Byte ASnums
         * otherwise, will get 16 Bit
         */
-       attr->aspath = aspath_parse(peer->curr, length,
-                                   CHECK_FLAG(peer->cap, PEER_CAP_AS4_RCV));
+       attr->aspath = aspath_parse(
+               peer->curr, length,
+               CHECK_FLAG(peer->cap, PEER_CAP_AS4_RCV)
+                       && CHECK_FLAG(peer->cap, PEER_CAP_AS4_ADV));
 
        /* In case of IBGP, length will be zero. */
        if (!attr->aspath) {
@@ -3745,7 +3747,8 @@ bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *peer,
        struct aspath *aspath;
        int send_as4_path = 0;
        int send_as4_aggregator = 0;
-       bool use32bit = CHECK_FLAG(peer->cap, PEER_CAP_AS4_RCV);
+       bool use32bit = CHECK_FLAG(peer->cap, PEER_CAP_AS4_RCV)
+                       && CHECK_FLAG(peer->cap, PEER_CAP_AS4_ADV);
 
        if (!bgp)
                bgp = peer->bgp;