align the code to remarks from community.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
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);
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;
/* 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
/* 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;
{
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;
/* 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);
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) {
}
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;
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);
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)
vty_out(vty, "%% Nexthop required\n");
return CMD_WARNING_CONFIG_FAILED;
}
-
if (!sockunion2hostprefix(nexthop_su, &p))
return CMD_WARNING_CONFIG_FAILED;
}
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)
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;
}
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)
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) {
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)
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",
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;
}
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;