]> git.proxmox.com Git - mirror_frr.git/commitdiff
bgpd: add missing ecommunity flowspec to display
authorPhilippe Guibert <philippe.guibert@6wind.com>
Thu, 17 May 2018 07:30:28 +0000 (09:30 +0200)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Fri, 25 May 2018 13:49:38 +0000 (15:49 +0200)
On some cases, the ecommunity flowspec for redirect vrf is not displayed
in all cases. On top of that, display the values if ecom can no be
decoded.
Also, sub_type and type are changed from int to u_int8_t, because the
values contains match the type and sub type of extended communities.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
bgpd/bgp_ecommunity.c

index 99fe80f055497d5ebe0fec3050404a5f3340b210..eff6f0f81aaf8915afba02416af9e13775a7894b 100644 (file)
@@ -642,8 +642,8 @@ char *ecommunity_ecom2str(struct ecommunity *ecom, int format, int filter)
 {
        int i;
        uint8_t *pnt;
-       int type = 0;
-       int sub_type = 0;
+       uint8_t type = 0;
+       uint8_t sub_type = 0;
 #define ECOMMUNITY_STR_DEFAULT_LEN  27
        int str_size;
        int str_pnt;
@@ -750,10 +750,25 @@ char *ecommunity_ecom2str(struct ecommunity *ecom, int format, int filter)
                                        "FS:redirect IP 0x%x", *(pnt+5));
                        } else
                                unk_ecom = 1;
-               } else if (type == ECOMMUNITY_ENCODE_TRANS_EXP) {
+               } else if (type == ECOMMUNITY_ENCODE_TRANS_EXP ||
+                          type == ECOMMUNITY_EXTENDED_COMMUNITY_PART_2 ||
+                          type == ECOMMUNITY_EXTENDED_COMMUNITY_PART_3) {
                        sub_type = *pnt++;
+                       if (sub_type == ECOMMUNITY_REDIRECT_VRF) {
+                               char buf[16];
 
-                       if (sub_type == ECOMMUNITY_TRAFFIC_ACTION) {
+                               memset(buf, 0, sizeof(buf));
+                               ecommunity_rt_soo_str(buf, (uint8_t *)pnt,
+                                                     type &
+                                                     ~ECOMMUNITY_ENCODE_TRANS_EXP,
+                                                     ECOMMUNITY_ROUTE_TARGET,
+                                                     ECOMMUNITY_FORMAT_DISPLAY);
+                               len = snprintf(str_buf + str_pnt,
+                                              str_size - len,
+                                              "FS:redirect VRF %s", buf);
+                       } else if (type != ECOMMUNITY_ENCODE_TRANS_EXP)
+                               unk_ecom = 1;
+                       else if (sub_type == ECOMMUNITY_TRAFFIC_ACTION) {
                                char action[64];
                                char *ptr = action;
 
@@ -782,30 +797,20 @@ char *ecommunity_ecom2str(struct ecommunity *ecom, int format, int filter)
                                len = sprintf(
                                        str_buf + str_pnt,
                                        "FS:rate %f", data.rate_float);
-                       } else if (sub_type == ECOMMUNITY_REDIRECT_VRF) {
-                               char buf[16];
-
-                               memset(buf, 0, sizeof(buf));
-                               ecommunity_rt_soo_str(buf, (uint8_t *)pnt,
-                                               type &
-                                               ~ECOMMUNITY_ENCODE_TRANS_EXP,
-                                               ECOMMUNITY_ROUTE_TARGET,
-                                               ECOMMUNITY_FORMAT_DISPLAY);
-                               len = snprintf(
-                                       str_buf + str_pnt,
-                                       str_size - len,
-                                       "FS:redirect VRF %s", buf);
                        } else if (sub_type == ECOMMUNITY_TRAFFIC_MARKING) {
                                len = sprintf(
                                        str_buf + str_pnt,
                                        "FS:marking %u", *(pnt+5));
                        } else
                                unk_ecom = 1;
-               } else
+               } else {
+                       sub_type = *pnt++;
                        unk_ecom = 1;
+               }
 
                if (unk_ecom)
-                       len = sprintf(str_buf + str_pnt, "?");
+                       len = sprintf(str_buf + str_pnt, "UNK:%d, %d",
+                                     type, sub_type);
 
                str_pnt += len;
                first = 0;