bgp, zebra: add some alignments with remarks from community

align the code to remarks from community.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
This commit is contained in:
Philippe Guibert 2020-04-20 18:02:46 +02:00
parent e764d5faab
commit c6423c3153
6 changed files with 35 additions and 35 deletions

View File

@ -2296,13 +2296,12 @@ bgp_attr_ipv6_ext_communities(struct bgp_attr_parser_args *args)
if (length == 0) { if (length == 0) {
attr->ipv6_ecommunity = NULL; attr->ipv6_ecommunity = NULL;
/* Empty extcomm doesn't seem to be invalid per se */ return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_OPT_ATTR_ERR,
return BGP_ATTR_PARSE_PROCEED; args->total);
} }
attr->ipv6_ecommunity = attr->ipv6_ecommunity =
ecommunity_parse_ipv6((uint8_t *)stream_pnt(peer->curr), ecommunity_parse_ipv6(stream_pnt(peer->curr), length);
length);
/* XXX: fix ecommunity_parse to use stream API */ /* XXX: fix ecommunity_parse to use stream API */
stream_forward_getp(peer->curr, length); stream_forward_getp(peer->curr, length);

View File

@ -792,6 +792,7 @@ static int ecommunity_rt_soo_str_internal(char *buf, size_t bufsz,
len = snprintf(buf, bufsz, "%s%u:%u", prefix, eas.as, eas.val); len = snprintf(buf, bufsz, "%s%u:%u", prefix, eas.as, eas.val);
} else { } else {
/* this is an IPv6 ext community /* this is an IPv6 ext community
* first 16 bytes stands for IPv6 addres
*/ */
memcpy(&eip6.ip, pnt, 16); memcpy(&eip6.ip, pnt, 16);
pnt += 16; pnt += 16;

View File

@ -94,7 +94,7 @@
/* Extended Communities value is eight octet long. */ /* Extended Communities value is eight octet long. */
#define ECOMMUNITY_SIZE 8 #define ECOMMUNITY_SIZE 8
#define IPV6_ECOMMUNITY_SIZE 20 #define IPV6_ECOMMUNITY_SIZE 20
/* Extended Communities type flag. */ /* Extended Communities type flag. */
#define ECOMMUNITY_FLAG_NON_TRANSITIVE 0x40 #define ECOMMUNITY_FLAG_NON_TRANSITIVE 0x40
@ -107,7 +107,7 @@ struct ecommunity {
/* Size of Each Unit of Extended Communities attribute. /* Size of Each Unit of Extended Communities attribute.
* to differentiate between IPv6 ext comm and ext comm * to differentiate between IPv6 ext comm and ext comm
*/ */
int unit_size; uint8_t unit_size;
/* Size of Extended Communities attribute. */ /* Size of Extended Communities attribute. */
int size; int size;

View File

@ -263,7 +263,7 @@ void route_vty_out_flowspec(struct vty *vty, const struct prefix *p,
{ {
struct attr *attr; struct attr *attr;
char return_string[BGP_FLOWSPEC_STRING_DISPLAY_MAX]; char return_string[BGP_FLOWSPEC_STRING_DISPLAY_MAX];
char *s = NULL, *s2 = NULL; char *s1 = NULL, *s2 = NULL;
json_object *json_nlri_path = NULL; json_object *json_nlri_path = NULL;
json_object *json_ecom_path = NULL; json_object *json_ecom_path = NULL;
json_object *json_time_path = NULL; json_object *json_time_path = NULL;
@ -311,23 +311,23 @@ void route_vty_out_flowspec(struct vty *vty, const struct prefix *p,
/* Print attribute */ /* Print attribute */
attr = path->attr; attr = path->attr;
if (attr->ecommunity) if (attr->ecommunity)
s = ecommunity_ecom2str(attr->ecommunity, s1 = ecommunity_ecom2str(attr->ecommunity,
ECOMMUNITY_FORMAT_ROUTE_MAP, 0); ECOMMUNITY_FORMAT_ROUTE_MAP, 0);
if (attr->ipv6_ecommunity) if (attr->ipv6_ecommunity)
s2 = ecommunity_ecom2str(attr->ipv6_ecommunity, s2 = ecommunity_ecom2str(attr->ipv6_ecommunity,
ECOMMUNITY_FORMAT_ROUTE_MAP, 0); ECOMMUNITY_FORMAT_ROUTE_MAP, 0);
if (!s && !s2) if (!s1 && !s2)
return; return;
if (display == NLRI_STRING_FORMAT_LARGE) if (display == NLRI_STRING_FORMAT_LARGE)
vty_out(vty, "\t%s%s%s\n", s ? s : "", vty_out(vty, "\t%s%s%s\n", s1 ? s1 : "",
s2 && s ? " " : "", s2 ? s2 : ""); s2 && s1 ? " " : "", s2 ? s2 : "");
else if (display == NLRI_STRING_FORMAT_MIN) else if (display == NLRI_STRING_FORMAT_MIN)
vty_out(vty, "%s%s", s ? s : "", s2 ? s2 : ""); vty_out(vty, "%s%s", s1 ? s1 : "", s2 ? s2 : "");
else if (json_paths) { else if (json_paths) {
json_ecom_path = json_object_new_object(); json_ecom_path = json_object_new_object();
if (s) if (s1)
json_object_string_add(json_ecom_path, json_object_string_add(json_ecom_path,
"ecomlist", s); "ecomlist", s1);
if (s2) if (s2)
json_object_string_add(json_ecom_path, json_object_string_add(json_ecom_path,
"ecom6list", s2); "ecom6list", s2);
@ -357,7 +357,8 @@ void route_vty_out_flowspec(struct vty *vty, const struct prefix *p,
vty_out(vty, "\tNLRI NH %s\n", vty_out(vty, "\tNLRI NH %s\n",
local_buff); local_buff);
} }
XFREE(MTYPE_ECOMMUNITY_STR, s); XFREE(MTYPE_ECOMMUNITY_STR, s1);
XFREE(MTYPE_ECOMMUNITY_STR, s2);
} }
peer_uptime(path->uptime, timebuf, BGP_UPTIME_LEN, 0, NULL); peer_uptime(path->uptime, timebuf, BGP_UPTIME_LEN, 0, NULL);
if (display == NLRI_STRING_FORMAT_LARGE) { if (display == NLRI_STRING_FORMAT_LARGE) {

View File

@ -7332,7 +7332,7 @@ DEFPY(
} }
static int set_ecom_list(struct vty *vty, int argc, struct cmd_token **argv, static int set_ecom_list(struct vty *vty, int argc, struct cmd_token **argv,
struct ecommunity **list, int is_rt6) struct ecommunity **list, bool is_rt6)
{ {
struct ecommunity *ecom = NULL; struct ecommunity *ecom = NULL;
struct ecommunity *ecomadd; struct ecommunity *ecomadd;
@ -7425,10 +7425,10 @@ DEFPY (af_rd_vpn_export,
int ret; int ret;
afi_t afi; afi_t afi;
int idx = 0; int idx = 0;
int yes = 1; bool yes = true;
if (argv_find(argv, argc, "no", &idx)) if (argv_find(argv, argc, "no", &idx))
yes = 0; yes = false;
if (yes) { if (yes) {
ret = str2prefix_rd(rd_str, &prd); ret = str2prefix_rd(rd_str, &prd);
@ -7486,10 +7486,10 @@ DEFPY (af_label_vpn_export,
mpls_label_t label = MPLS_LABEL_NONE; mpls_label_t label = MPLS_LABEL_NONE;
afi_t afi; afi_t afi;
int idx = 0; int idx = 0;
int yes = 1; bool yes = true;
if (argv_find(argv, argc, "no", &idx)) if (argv_find(argv, argc, "no", &idx))
yes = 0; yes = false;
/* If "no ...", squash trailing parameter */ /* If "no ...", squash trailing parameter */
if (!yes) if (!yes)
@ -7581,7 +7581,6 @@ DEFPY (af_nexthop_vpn_export,
vty_out(vty, "%% Nexthop required\n"); vty_out(vty, "%% Nexthop required\n");
return CMD_WARNING_CONFIG_FAILED; return CMD_WARNING_CONFIG_FAILED;
} }
if (!sockunion2hostprefix(nexthop_su, &p)) if (!sockunion2hostprefix(nexthop_su, &p))
return CMD_WARNING_CONFIG_FAILED; return CMD_WARNING_CONFIG_FAILED;
} }
@ -7647,10 +7646,10 @@ DEFPY (af_rt_vpn_imexport,
vpn_policy_direction_t dir; vpn_policy_direction_t dir;
afi_t afi; afi_t afi;
int idx = 0; int idx = 0;
int yes = 1; bool yes = true;
if (argv_find(argv, argc, "no", &idx)) if (argv_find(argv, argc, "no", &idx))
yes = 0; yes = false;
afi = vpn_policy_getafi(vty, bgp, false); afi = vpn_policy_getafi(vty, bgp, false);
if (afi == AFI_MAX) if (afi == AFI_MAX)
@ -7665,7 +7664,7 @@ DEFPY (af_rt_vpn_imexport,
vty_out(vty, "%% Missing RTLIST\n"); vty_out(vty, "%% Missing RTLIST\n");
return CMD_WARNING_CONFIG_FAILED; return CMD_WARNING_CONFIG_FAILED;
} }
ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom, 0); ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom, false);
if (ret != CMD_SUCCESS) { if (ret != CMD_SUCCESS) {
return ret; return ret;
} }
@ -7727,10 +7726,10 @@ DEFPY (af_route_map_vpn_imexport,
vpn_policy_direction_t dir; vpn_policy_direction_t dir;
afi_t afi; afi_t afi;
int idx = 0; int idx = 0;
int yes = 1; bool yes = true;
if (argv_find(argv, argc, "no", &idx)) if (argv_find(argv, argc, "no", &idx))
yes = 0; yes = false;
afi = vpn_policy_getafi(vty, bgp, false); afi = vpn_policy_getafi(vty, bgp, false);
if (afi == AFI_MAX) if (afi == AFI_MAX)
@ -7969,12 +7968,12 @@ DEFPY (bgp_imexport_vpn,
afi_t afi; afi_t afi;
safi_t safi; safi_t safi;
int idx = 0; int idx = 0;
int yes = 1; bool yes = true;
int flag; int flag;
vpn_policy_direction_t dir; vpn_policy_direction_t dir;
if (argv_find(argv, argc, "no", &idx)) if (argv_find(argv, argc, "no", &idx))
yes = 0; yes = false;
if (BGP_INSTANCE_TYPE_VRF != bgp->inst_type && if (BGP_INSTANCE_TYPE_VRF != bgp->inst_type &&
BGP_INSTANCE_TYPE_DEFAULT != bgp->inst_type) { BGP_INSTANCE_TYPE_DEFAULT != bgp->inst_type) {
@ -8037,15 +8036,15 @@ DEFPY (af_routetarget_import,
struct ecommunity *ecom = NULL; struct ecommunity *ecom = NULL;
afi_t afi; afi_t afi;
int idx = 0, idx_unused = 0; int idx = 0, idx_unused = 0;
int yes = 1; bool yes = true;
int rt6 = 0; bool rt6 = false;
if (argv_find(argv, argc, "no", &idx)) if (argv_find(argv, argc, "no", &idx))
yes = 0; yes = false;
if (argv_find(argv, argc, "rt6", &idx_unused) || if (argv_find(argv, argc, "rt6", &idx_unused) ||
argv_find(argv, argc, "route-target6", &idx_unused)) argv_find(argv, argc, "route-target6", &idx_unused))
rt6 = 1; rt6 = true;
afi = vpn_policy_getafi(vty, bgp, false); afi = vpn_policy_getafi(vty, bgp, false);
if (afi == AFI_MAX) if (afi == AFI_MAX)
@ -14594,7 +14593,7 @@ static void bgp_vpn_policy_config_write_afi(struct vty *vty, struct bgp *bgp,
if (bgp->vpn_policy[afi].import_redirect_rtlist->unit_size if (bgp->vpn_policy[afi].import_redirect_rtlist->unit_size
!= ECOMMUNITY_SIZE) != ECOMMUNITY_SIZE)
vty_out(vty, "%*srt redirect import %s\n", vty_out(vty, "%*srt6 redirect import %s\n",
indent, "", b); indent, "", b);
else else
vty_out(vty, "%*srt redirect import %s\n", vty_out(vty, "%*srt redirect import %s\n",

View File

@ -1051,7 +1051,7 @@ static int zebra_pbr_show_ipset_walkcb(struct hash_bucket *bucket, void *arg)
vty_out(vty, "IPset %s type %s family %s\n", zpi->ipset_name, vty_out(vty, "IPset %s type %s family %s\n", zpi->ipset_name,
zebra_pbr_ipset_type2str(zpi->type), zebra_pbr_ipset_type2str(zpi->type),
zpi->family == AF_INET ? "AF_INET" : "AF_INET6"); family2str(zpi->family));
unique.vty = vty; unique.vty = vty;
unique.zpi = zpi; unique.zpi = zpi;
unique.zns = zns; unique.zns = zns;
@ -1098,7 +1098,7 @@ void zebra_pbr_show_ipset_list(struct vty *vty, char *ipsetname)
} }
vty_out(vty, "IPset %s type %s family %s\n", ipsetname, vty_out(vty, "IPset %s type %s family %s\n", ipsetname,
zebra_pbr_ipset_type2str(zpi->type), zebra_pbr_ipset_type2str(zpi->type),
zpi->family == AF_INET ? "AF_INET" : "AF_INET6"); family2str(zpi->family));
unique.vty = vty; unique.vty = vty;
unique.zpi = zpi; unique.zpi = zpi;
unique.zns = zns; unique.zns = zns;