]> git.proxmox.com Git - mirror_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>
Tue, 29 Jun 2021 13:10:50 +0000 (16:10 +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 2f0751a5f045ed1ed98c589aa0c93761e1519b07..3a2cb4c10b5e3c1f297bc84f17588e5c654722b8 100644 (file)
@@ -1509,16 +1509,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);
 
@@ -1558,6 +1548,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)) {
@@ -1590,16 +1589,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);