/* Prefix contains RD, ESI, EthTag, IP length, IP, GWIP and VNI */
stream_putc(s, 8 + 10 + 4 + 1 + len + 3);
stream_put(s, prd->val, 8);
- if (attr && attr)
+ if (attr)
stream_put(s, &(attr->evpn_overlay.eth_s_id), 10);
else
stream_put(s, &temp, 10);
stream_put_ipv4(s, p_evpn_p->ip.ipaddr_v4.s_addr);
else
stream_put(s, &p_evpn_p->ip.ipaddr_v6, 16);
- if (attr && attr) {
+ if (attr) {
if (IS_IPADDR_V4(&p_evpn_p->ip))
stream_put_ipv4(s,
attr->evpn_overlay.gw_ip.ipv4.s_addr);
return CMD_WARNING;
}
- /* labeled-unicast routes live in the unicast table */
- if (safi == SAFI_LABELED_UNICAST)
- safi = SAFI_UNICAST;
-
return bgp_show(vty, peer->bgp, afi, safi, type, &peer->su, use_json);
}
return NULL;
*vni = strtoul(arg, &end, 10);
- if (*end != '\0')
+ if (*end != '\0') {
+ XFREE(MTYPE_ROUTE_MAP_COMPILED, vni);
return NULL;
+ }
return vni;
}
struct rfapi_nve_group_cfg *rfg;
VTY_DECLVAR_CONTEXT(bgp, bgp);
- if (!bgp) {
- vty_out(vty, "No BGP process is configured\n");
- return CMD_WARNING_CONFIG_FAILED;
- }
-
/* Search for name */
rfg = bgp_rfapi_cfg_match_byname(bgp, argv[1]->arg,
RFAPI_GROUP_CFG_VRF);
{
VTY_DECLVAR_CONTEXT(bgp, bgp);
- if (!bgp) {
- vty_out(vty, "No BGP process is configured\n");
- return CMD_WARNING_CONFIG_FAILED;
- }
return bgp_rfapi_delete_named_nve_group(vty, bgp, argv[2]->arg,
RFAPI_GROUP_CFG_VRF);
}
uint32_t label;
VTY_DECLVAR_CONTEXT(bgp, bgp);
- if (!bgp) {
- vty_out(vty, "No BGP process is configured\n");
- return CMD_WARNING_CONFIG_FAILED;
- }
-
/* make sure it's still in list */
if (!listnode_lookup(bgp->rfapi_cfg->nve_groups_sequential, rfg)) {
/* Not in list anymore */
int is_export_bgp = 0;
int is_export_zebra = 0;
- if (!bgp) {
- vty_out(vty, "No BGP process is configured\n");
- return CMD_WARNING_CONFIG_FAILED;
- }
-
/* make sure it's still in list */
if (!listnode_lookup(bgp->rfapi_cfg->nve_groups_sequential, rfg)) {
/* Not in list anymore */
VTY_DECLVAR_CONTEXT(bgp, bgp);
int rc;
- if (!bgp) {
- vty_out(vty, "No BGP process is configured\n");
- return CMD_WARNING_CONFIG_FAILED;
- }
-
/* make sure it's still in list */
if (!listnode_lookup(bgp->rfapi_cfg->nve_groups_sequential, rfg)) {
/* Not in list anymore */
struct listnode *node;
struct rfapi_rfg_name *rfgn;
- if (!bgp) {
- vty_out(vty, "No BGP process is configured\n");
- return CMD_WARNING_CONFIG_FAILED;
- }
-
/* make sure it's still in list */
if (!listnode_lookup(bgp->rfapi_cfg->nve_groups_sequential, rfg)) {
/* Not in list anymore */
VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg, rfg);
VTY_DECLVAR_CONTEXT(bgp, bgp);
- if (!bgp) {
- vty_out(vty, "No BGP process is configured\n");
- return CMD_WARNING_CONFIG_FAILED;
- }
-
/* make sure it's still in list */
if (!listnode_lookup(bgp->rfapi_cfg->nve_groups_sequential, rfg)) {
/* Not in list anymore */
struct rfapi_l2_group_cfg *rfg;
VTY_DECLVAR_CONTEXT(bgp, bgp);
- if (!bgp) {
- vty_out(vty, "No BGP process is configured\n");
- return CMD_WARNING_CONFIG_FAILED;
- }
-
/* Search for name */
rfg = rfapi_l2_group_lookup_byname(bgp, argv[1]->arg);
{
VTY_DECLVAR_CONTEXT(bgp, bgp);
- if (!bgp) {
- vty_out(vty, "No BGP process is configured\n");
- return CMD_WARNING_CONFIG_FAILED;
- }
return bgp_rfapi_delete_named_l2_group(vty, bgp, argv[3]->arg);
}
VTY_DECLVAR_CONTEXT_SUB(rfapi_l2_group_cfg, rfg);
VTY_DECLVAR_CONTEXT(bgp, bgp);
- if (!bgp) {
- vty_out(vty, "No BGP process is configured\n");
- return CMD_WARNING_CONFIG_FAILED;
- }
-
/* make sure it's still in list */
if (!listnode_lookup(bgp->rfapi_cfg->l2_groups, rfg)) {
/* Not in list anymore */
VTY_DECLVAR_CONTEXT(bgp, bgp);
struct list *ll;
- if (!bgp) {
- vty_out(vty, "No BGP process is configured\n");
- return CMD_WARNING_CONFIG_FAILED;
- }
-
/* make sure it's still in list */
if (!listnode_lookup(bgp->rfapi_cfg->l2_groups, rfg)) {
/* Not in list anymore */
VTY_DECLVAR_CONTEXT(bgp, bgp);
struct list *ll;
- if (!bgp) {
- vty_out(vty, "No BGP process is configured\n");
- return CMD_WARNING_CONFIG_FAILED;
- }
-
/* make sure it's still in list */
if (!listnode_lookup(bgp->rfapi_cfg->l2_groups, rfg)) {
/* Not in list anymore */
vty_out(vty, "Unknown option, %s\n", argv[1]->arg);
return CMD_ERR_NO_MATCH;
}
- if (!bgp) {
- vty_out(vty, "No BGP process is configured\n");
- return CMD_WARNING_CONFIG_FAILED;
- }
/* make sure it's still in list */
if (!listnode_lookup(bgp->rfapi_cfg->l2_groups, rfg)) {
default:
/* not expected */
+ zlog_err("%s: bad safi %d", __func__, safi);
return NULL;
}
- zlog_err("%s: bad safi %d", __func__, safi);
- return NULL;
}
void rfapiProcessUpdate(struct peer *peer,
"Next hop address\n"
"IP address of next hop\n")
{
- int idx;
+ int idx = 0;
VTY_DECLVAR_CONTEXT(route_map_index, index);
const char *arg = NULL;
char prefixstr[PREFIX2STR_BUFFER], nexthopstr[128];
prefix2str((struct prefix *)&api.prefix, prefixstr,
sizeof(prefixstr));
- if (nexthop)
- inet_ntop(AF_INET6, nexthop, nexthopstr,
- sizeof(nexthopstr));
- else
- snprintf(nexthopstr, sizeof(nexthopstr), "::");
+ inet_ntop(AF_INET6, nexthop, nexthopstr, sizeof(nexthopstr));
zlog_debug(
"Zebra Receive route %s: %s %s nexthop %s ifindex %ld tag %" ROUTE_TAG_PRI,
if (ntohs(OspfMplsTE.router_addr.header.type) != 0)
show_vty_router_addr(vty,
&OspfMplsTE.router_addr.header);
- else if (vty != NULL)
+ else
vty_out(vty, " N/A\n");
}
return CMD_SUCCESS;
struct cmsghdr *ptr;
char adata[1024];
+ memset(&msg, 0, sizeof(msg));
msg.msg_name = (void *)from;
msg.msg_namelen = sizeof(struct sockaddr_in);
msg.msg_iov = &iov;
addr.sin6_port = htons(RIPNG_PORT_DEFAULT);
}
+ memset(&msg, 0, sizeof(msg));
msg.msg_name = (void *)&addr;
msg.msg_namelen = sizeof(struct sockaddr_in6);
msg.msg_iov = &iov;
char adata[1024];
/* Fill in message and iovec. */
+ memset(&msg, 0, sizeof(msg));
msg.msg_name = (void *)from;
msg.msg_namelen = sizeof(struct sockaddr_in6);
msg.msg_iov = &iov;
memset(&ifdata, 0, sizeof(ifdata));
/* set interface name */
- strcpy(ifdata.ifr_name, ifname);
+ strlcpy(ifdata.ifr_name, ifname, sizeof(ifdata.ifr_name));
/* initialize ethtool interface */
memset(&ecmd, 0, sizeof(ecmd));
if (!CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_ACTIVE)) {
SET_FLAG(ifp->status, ZEBRA_INTERFACE_ACTIVE);
- if (if_data && if_data->shutdown == IF_ZEBRA_SHUTDOWN_ON) {
+ if (if_data->shutdown == IF_ZEBRA_SHUTDOWN_ON) {
if (IS_ZEBRA_DEBUG_KERNEL)
zlog_debug(
"interface %s vrf %u index %d is shutdown. "
/* clear and set interface name string */
void ifreq_set_name(struct ifreq *ifreq, struct interface *ifp)
{
- strncpy(ifreq->ifr_name, ifp->name, IFNAMSIZ);
+ strlcpy(ifreq->ifr_name, ifp->name, sizeof(ifreq->ifr_name));
}
/* call ioctl system call */
char adata[CMSG_SPACE(SOPT_SIZE_CMSG_PKTINFO_IPV4())];
int ret;
+ memset(&msg, 0, sizeof(msg));
msg.msg_name = (void *)0;
msg.msg_namelen = 0;
msg.msg_iov = &iov;
if (IS_ZEBRA_DEBUG_KERNEL) {
struct interface *ifp;
- strcpy(sbuf, inet_ntoa(m->sg.src));
- strcpy(gbuf, inet_ntoa(m->sg.grp));
+ strlcpy(sbuf, inet_ntoa(m->sg.src), sizeof(sbuf));
+ strlcpy(gbuf, inet_ntoa(m->sg.grp), sizeof(gbuf));
for (count = 0; count < oif_count; count++) {
ifp = if_lookup_by_index(oif[count], vrf);
char temp[256];
int kernel_route_rib(struct prefix *p, struct prefix *src_p,
struct route_entry *old, struct route_entry *new)
{
+ assert(old || new);
+
if (!old && new)
return netlink_route_multipath(RTM_NEWROUTE, p, src_p, new, 0);
if (old && !new)
char adata[1024];
/* Fill in message and iovec. */
+ memset(&msg, 0, sizeof(msg));
msg.msg_name = (void *)from;
msg.msg_namelen = sizeof(struct sockaddr_in6);
msg.msg_iov = &iov;
zebra_lsp_t *lsp;
lsp = (zebra_lsp_t *)backet->data;
- lsp_processq_add(lsp);
+ (void)lsp_processq_add(lsp);
}
/*
for (ALL_LIST_ELEMENTS_RO(slsp_list, node, slsp)) {
for (snhlfe = slsp->snhlfe_list; snhlfe;
snhlfe = snhlfe->next) {
- char buf[INET6_ADDRSTRLEN];
+ char buf[BUFSIZ];
char lstr[30];
- snhlfe2str(snhlfe, buf, BUFSIZ);
+ snhlfe2str(snhlfe, buf, sizeof(buf));
switch (snhlfe->out_label) {
case MPLS_V4_EXP_NULL_LABEL:
case MPLS_V6_EXP_NULL_LABEL:
char sbuf[40];
char gbuf[40];
- strcpy(sbuf, inet_ntoa(mroute.sg.src));
- strcpy(gbuf, inet_ntoa(mroute.sg.grp));
+ strlcpy(sbuf, inet_ntoa(mroute.sg.src), sizeof(sbuf));
+ strlcpy(gbuf, inet_ntoa(mroute.sg.grp), sizeof(gbuf));
zlog_debug("Asking for (%s,%s) mroute information", sbuf, gbuf);
}
if (!pw)
return CMD_SUCCESS;
zebra_pw_del(zvrf, pw);
+ return CMD_SUCCESS;
}
if (!pw)
RB_FOREACH(vrf, vrf_name_head, &vrfs_by_name)
{
zvrf = vrf->info;
- if (!zvrf || strcmp(zvrf_name(zvrf), VRF_DEFAULT_NAME)) {
+ if (strcmp(zvrf_name(zvrf), VRF_DEFAULT_NAME)) {
vty_out(vty, "vrf %s\n", zvrf_name(zvrf));
vty_out(vty, "!\n");
}
tag = strtoul(argv[idx + 1]->arg, NULL, 10);
else if (argv_find(argv, argc, "A.B.C.D/M", &idx)) {
- str2prefix(argv[idx]->arg, &p);
+ if (str2prefix(argv[idx]->arg, &p) <= 0) {
+ vty_out(vty, "%% Malformed prefix\n");
+ return CMD_WARNING;
+ }
longer_prefixes = true;
}
tag = strtoul(argv[idx + 1]->arg, NULL, 10);
else if (argv_find(argv, argc, "X:X::X:X/M", &idx)) {
- str2prefix(argv[idx]->arg, &p);
+ if (str2prefix(argv[idx]->arg, &p) <= 0) {
+ vty_out(vty, "%% Malformed prefix\n");
+ return CMD_WARNING;
+ }
longer_prefixes = true;
}
vty_out(vty,
"Invalid routing table ID, %d. Must be in range 1-252\n",
table_id);
+ if (rmap)
+ XFREE(MTYPE_ROUTE_MAP_NAME, rmap);
return CMD_WARNING;
}
vty_out(vty,
"Invalid routing table ID, %d. Must be non-default table\n",
table_id);
+ if (rmap)
+ XFREE(MTYPE_ROUTE_MAP_NAME, rmap);
return CMD_WARNING;
}
zlog_err(
"%u:Failed to add neighbor %s MAC %s intf %s(%u) -> VNI %u",
ifp->vrf_id, ipaddr2str(ip, buf2, sizeof(buf2)),
- prefix_mac2str(macaddr, NULL,
- ETHER_ADDR_STRLEN),
+ prefix_mac2str(macaddr, buf, sizeof(buf)),
ifp->name, ifp->ifindex, zvni->vni);
return -1;
}
struct zebra_vrf *zvrf = NULL;
zebra_neigh_t *n = NULL;
zebra_mac_t *mac = NULL;
+ char buf1[ETHER_ADDR_STRLEN];
char buf2[INET6_ADDRSTRLEN];
zvrf = vrf_info_lookup(zvni->vxlan_if->vrf_id);
/* mac entry should be present */
mac = zvni_mac_lookup(zvni, &n->emac);
- if (!mac)
- zlog_err("%u: MAC %s doesnt exsists for neigh %s on VNI %u",
+ if (!mac) {
+ zlog_err("%u: MAC %s doesnt exists for neigh %s on VNI %u",
ifp->vrf_id,
- prefix_mac2str(&n->emac, NULL, ETHER_ADDR_STRLEN),
+ prefix_mac2str(&n->emac, buf1, sizeof(buf1)),
ipaddr2str(ip, buf2, sizeof(buf2)), zvni->vni);
+ return -1;
+ }
/* If the entry is not local nothing to do*/
if (!CHECK_FLAG(n->flags, ZEBRA_NEIGH_LOCAL))
zlog_debug(
"%u:SVI %s(%u) VNI %u, sending GW MAC %s IP %s del to BGP",
ifp->vrf_id, ifp->name, ifp->ifindex, zvni->vni,
- prefix_mac2str(&(n->emac), NULL, ETHER_ADDR_STRLEN),
+ prefix_mac2str(&(n->emac), buf1, sizeof(buf1)),
ipaddr2str(ip, buf2, sizeof(buf2)));
/* Remove neighbor from BGP. */