]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: Fix "malformed communities" for accept-own-nexthop
authorAppu Joseph <apjo@kaloom.com>
Fri, 29 May 2020 14:23:36 +0000 (10:23 -0400)
committerAppu Joseph <apjo@kaloom.com>
Fri, 29 May 2020 18:36:07 +0000 (14:36 -0400)
"set community accept-own-nexthop" returns "malformed communities"
error. This is because the token matching hits an earlier "accept-own"
and leaves "-nexthop" as a separate token to be processed.
Reorder the switch cases so that both are processed correctly.

Signed-off-by: Appu Joseph <apjo@kaloom.com>
bgpd/bgp_community.c

index 0d60fbf47932525980b6869e3ef5e86d90f4c5a9..b6cc2b839f36afeb3bc69e36a8839c39652d24c0 100644 (file)
@@ -677,6 +677,14 @@ community_gettoken(const char *buf, enum community_token *token, uint32_t *val)
                        p += strlen("graceful-shutdown");
                        return p;
                }
+               if (strncmp(p, "accept-own-nexthop",
+                           strlen("accept-own-nexthop"))
+                   == 0) {
+                       *val = COMMUNITY_ACCEPT_OWN_NEXTHOP;
+                       *token = community_token_accept_own_nexthop;
+                       p += strlen("accept-own-nexthop");
+                       return p;
+               }
                if (strncmp(p, "accept-own", strlen("accept-own"))
                    == 0) {
                        *val = COMMUNITY_ACCEPT_OWN;
@@ -728,14 +736,6 @@ community_gettoken(const char *buf, enum community_token *token, uint32_t *val)
                        p += strlen("no-llgr");
                        return p;
                }
-               if (strncmp(p, "accept-own-nexthop",
-                       strlen("accept-own-nexthop"))
-                   == 0) {
-                       *val = COMMUNITY_ACCEPT_OWN_NEXTHOP;
-                       *token = community_token_accept_own_nexthop;
-                       p += strlen("accept-own-nexthop");
-                       return p;
-               }
                if (strncmp(p, "blackhole", strlen("blackhole"))
                    == 0) {
                        *val = COMMUNITY_BLACKHOLE;