From: Philippe Guibert Date: Mon, 20 Apr 2020 16:02:46 +0000 (+0200) Subject: bgp, zebra: add some alignments with remarks from community X-Git-Tag: frr-7.5.1~109^2~4 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=c6423c31530db0e54ad90fc330c13bca81c9a80a;p=mirror_frr.git bgp, zebra: add some alignments with remarks from community align the code to remarks from community. Signed-off-by: Philippe Guibert --- diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c index a77d9467c..cac3ab1ca 100644 --- a/bgpd/bgp_attr.c +++ b/bgpd/bgp_attr.c @@ -2296,13 +2296,12 @@ bgp_attr_ipv6_ext_communities(struct bgp_attr_parser_args *args) if (length == 0) { attr->ipv6_ecommunity = NULL; - /* Empty extcomm doesn't seem to be invalid per se */ - return BGP_ATTR_PARSE_PROCEED; + return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_OPT_ATTR_ERR, + args->total); } attr->ipv6_ecommunity = - ecommunity_parse_ipv6((uint8_t *)stream_pnt(peer->curr), - length); + ecommunity_parse_ipv6(stream_pnt(peer->curr), length); /* XXX: fix ecommunity_parse to use stream API */ stream_forward_getp(peer->curr, length); diff --git a/bgpd/bgp_ecommunity.c b/bgpd/bgp_ecommunity.c index f45fa2bed..ce67abd36 100644 --- a/bgpd/bgp_ecommunity.c +++ b/bgpd/bgp_ecommunity.c @@ -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); } else { /* this is an IPv6 ext community + * first 16 bytes stands for IPv6 addres */ memcpy(&eip6.ip, pnt, 16); pnt += 16; diff --git a/bgpd/bgp_ecommunity.h b/bgpd/bgp_ecommunity.h index 4a1af0d20..fe90efe1f 100644 --- a/bgpd/bgp_ecommunity.h +++ b/bgpd/bgp_ecommunity.h @@ -94,7 +94,7 @@ /* Extended Communities value is eight octet long. */ #define ECOMMUNITY_SIZE 8 -#define IPV6_ECOMMUNITY_SIZE 20 +#define IPV6_ECOMMUNITY_SIZE 20 /* Extended Communities type flag. */ #define ECOMMUNITY_FLAG_NON_TRANSITIVE 0x40 @@ -107,7 +107,7 @@ struct ecommunity { /* Size of Each Unit of Extended Communities attribute. * to differentiate between IPv6 ext comm and ext comm */ - int unit_size; + uint8_t unit_size; /* Size of Extended Communities attribute. */ int size; diff --git a/bgpd/bgp_flowspec_vty.c b/bgpd/bgp_flowspec_vty.c index cc6d1ed45..92bec6f88 100644 --- a/bgpd/bgp_flowspec_vty.c +++ b/bgpd/bgp_flowspec_vty.c @@ -263,7 +263,7 @@ void route_vty_out_flowspec(struct vty *vty, const struct prefix *p, { struct attr *attr; 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_ecom_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 */ attr = path->attr; if (attr->ecommunity) - s = ecommunity_ecom2str(attr->ecommunity, + s1 = ecommunity_ecom2str(attr->ecommunity, ECOMMUNITY_FORMAT_ROUTE_MAP, 0); if (attr->ipv6_ecommunity) s2 = ecommunity_ecom2str(attr->ipv6_ecommunity, ECOMMUNITY_FORMAT_ROUTE_MAP, 0); - if (!s && !s2) + if (!s1 && !s2) return; if (display == NLRI_STRING_FORMAT_LARGE) - vty_out(vty, "\t%s%s%s\n", s ? s : "", - s2 && s ? " " : "", s2 ? s2 : ""); + vty_out(vty, "\t%s%s%s\n", s1 ? s1 : "", + s2 && s1 ? " " : "", s2 ? s2 : ""); 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) { json_ecom_path = json_object_new_object(); - if (s) + if (s1) json_object_string_add(json_ecom_path, - "ecomlist", s); + "ecomlist", s1); if (s2) json_object_string_add(json_ecom_path, "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", 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); if (display == NLRI_STRING_FORMAT_LARGE) { diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 191c1a561..1201b488f 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -7332,7 +7332,7 @@ DEFPY( } 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 *ecomadd; @@ -7425,10 +7425,10 @@ DEFPY (af_rd_vpn_export, int ret; afi_t afi; int idx = 0; - int yes = 1; + bool yes = true; if (argv_find(argv, argc, "no", &idx)) - yes = 0; + yes = false; if (yes) { ret = str2prefix_rd(rd_str, &prd); @@ -7486,10 +7486,10 @@ DEFPY (af_label_vpn_export, mpls_label_t label = MPLS_LABEL_NONE; afi_t afi; int idx = 0; - int yes = 1; + bool yes = true; if (argv_find(argv, argc, "no", &idx)) - yes = 0; + yes = false; /* If "no ...", squash trailing parameter */ if (!yes) @@ -7581,7 +7581,6 @@ DEFPY (af_nexthop_vpn_export, vty_out(vty, "%% Nexthop required\n"); return CMD_WARNING_CONFIG_FAILED; } - if (!sockunion2hostprefix(nexthop_su, &p)) return CMD_WARNING_CONFIG_FAILED; } @@ -7647,10 +7646,10 @@ DEFPY (af_rt_vpn_imexport, vpn_policy_direction_t dir; afi_t afi; int idx = 0; - int yes = 1; + bool yes = true; if (argv_find(argv, argc, "no", &idx)) - yes = 0; + yes = false; afi = vpn_policy_getafi(vty, bgp, false); if (afi == AFI_MAX) @@ -7665,7 +7664,7 @@ DEFPY (af_rt_vpn_imexport, vty_out(vty, "%% Missing RTLIST\n"); 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) { return ret; } @@ -7727,10 +7726,10 @@ DEFPY (af_route_map_vpn_imexport, vpn_policy_direction_t dir; afi_t afi; int idx = 0; - int yes = 1; + bool yes = true; if (argv_find(argv, argc, "no", &idx)) - yes = 0; + yes = false; afi = vpn_policy_getafi(vty, bgp, false); if (afi == AFI_MAX) @@ -7969,12 +7968,12 @@ DEFPY (bgp_imexport_vpn, afi_t afi; safi_t safi; int idx = 0; - int yes = 1; + bool yes = true; int flag; vpn_policy_direction_t dir; if (argv_find(argv, argc, "no", &idx)) - yes = 0; + yes = false; if (BGP_INSTANCE_TYPE_VRF != bgp->inst_type && BGP_INSTANCE_TYPE_DEFAULT != bgp->inst_type) { @@ -8037,15 +8036,15 @@ DEFPY (af_routetarget_import, struct ecommunity *ecom = NULL; afi_t afi; int idx = 0, idx_unused = 0; - int yes = 1; - int rt6 = 0; + bool yes = true; + bool rt6 = false; if (argv_find(argv, argc, "no", &idx)) - yes = 0; + yes = false; if (argv_find(argv, argc, "rt6", &idx_unused) || argv_find(argv, argc, "route-target6", &idx_unused)) - rt6 = 1; + rt6 = true; afi = vpn_policy_getafi(vty, bgp, false); 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 != ECOMMUNITY_SIZE) - vty_out(vty, "%*srt redirect import %s\n", + vty_out(vty, "%*srt6 redirect import %s\n", indent, "", b); else vty_out(vty, "%*srt redirect import %s\n", diff --git a/zebra/zebra_pbr.c b/zebra/zebra_pbr.c index 1bed0b48b..95d241c59 100644 --- a/zebra/zebra_pbr.c +++ b/zebra/zebra_pbr.c @@ -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, zebra_pbr_ipset_type2str(zpi->type), - zpi->family == AF_INET ? "AF_INET" : "AF_INET6"); + family2str(zpi->family)); unique.vty = vty; unique.zpi = zpi; 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, zebra_pbr_ipset_type2str(zpi->type), - zpi->family == AF_INET ? "AF_INET" : "AF_INET6"); + family2str(zpi->family)); unique.vty = vty; unique.zpi = zpi; unique.zns = zns;