From: Philippe Guibert Date: Thu, 17 May 2018 07:30:28 +0000 (+0200) Subject: bgpd: add missing ecommunity flowspec to display X-Git-Tag: frr-5.0~3^2~19 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=485849c6001e291a7262940e5a89905ace188be1;p=matthieu%2Ffrr.git bgpd: add missing ecommunity flowspec to display 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 --- diff --git a/bgpd/bgp_ecommunity.c b/bgpd/bgp_ecommunity.c index 85b9ffd8ca..3d14a76132 100644 --- a/bgpd/bgp_ecommunity.c +++ b/bgpd/bgp_ecommunity.c @@ -637,8 +637,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; @@ -745,10 +745,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; @@ -777,30 +792,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;