]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: Parse as withdrawal if AS-PATH contains 0 within the path
authorDonatas Abraitis <donatas.abraitis@gmail.com>
Tue, 29 Jun 2021 13:10:50 +0000 (16:10 +0300)
committerDonatas Abraitis <donatas.abraitis@gmail.com>
Wed, 7 Jul 2021 20:32:12 +0000 (23:32 +0300)
Process this a bit later instead of bgp_attr_parse() which is causing
the session to be shutdown upon receiving a prefix with AS number 0 inside.

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

index 71e4b56a0021a2868a4528a7b280cba175334d46..0fde644408ac17f862b874b4a1a9d1dde746b7f0 100644 (file)
@@ -1487,16 +1487,6 @@ static int bgp_attr_aspath(struct bgp_attr_parser_args *args)
                                          0);
        }
 
-       /* Codification of AS 0 Processing */
-       if (aspath_check_as_zero(attr->aspath)) {
-               flog_err(
-                       EC_BGP_ATTR_MAL_AS_PATH,
-                       "Malformed AS path, AS number is 0 in the path from %s",
-                       peer->host);
-               return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_MAL_AS_PATH,
-                                         0);
-       }
-
        /* Set aspath attribute flag. */
        attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_AS_PATH);
 
@@ -1536,6 +1526,15 @@ static bgp_attr_parse_ret_t bgp_attr_aspath_check(struct peer *const peer,
                }
        }
 
+       /* Codification of AS 0 Processing */
+       if (peer->sort == BGP_PEER_EBGP && aspath_check_as_zero(attr->aspath)) {
+               flog_err(
+                       EC_BGP_ATTR_MAL_AS_PATH,
+                       "Malformed AS path, AS number is 0 in the path from %s",
+                       peer->host);
+               return BGP_ATTR_PARSE_WITHDRAW;
+       }
+
        /* local-as prepend */
        if (peer->change_local_as
            && !CHECK_FLAG(peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) {
@@ -1568,16 +1567,6 @@ static int bgp_attr_as4_path(struct bgp_attr_parser_args *args,
                                          0);
        }
 
-       /* Codification of AS 0 Processing */
-       if (aspath_check_as_zero(*as4_path)) {
-               flog_err(
-                       EC_BGP_ATTR_MAL_AS_PATH,
-                       "Malformed AS path, AS number is 0 in the path from %s",
-                       peer->host);
-               return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_MAL_AS_PATH,
-                                         0);
-       }
-
        /* Set aspath attribute flag. */
        attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_AS4_PATH);