Merge pull request #1521 from donaldsharp/bufsiz

Cleanup Some Code Issues
This commit is contained in:
Rafael Zalamena 2017-12-14 11:21:40 -02:00 committed by GitHub
commit beab6ff7f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 263 additions and 342 deletions

View File

@ -226,7 +226,7 @@ static void bgp_evpn_show_route_header(struct vty *vty, struct bgp *bgp,
static void display_vni(struct vty *vty, struct bgpevpn *vpn, json_object *json) static void display_vni(struct vty *vty, struct bgpevpn *vpn, json_object *json)
{ {
char buf1[INET6_ADDRSTRLEN]; char buf1[RD_ADDRSTRLEN];
char *ecom_str; char *ecom_str;
struct listnode *node, *nnode; struct listnode *node, *nnode;
struct ecommunity *ecom; struct ecommunity *ecom;
@ -241,7 +241,7 @@ static void display_vni(struct vty *vty, struct bgpevpn *vpn, json_object *json)
is_vni_live(vpn) ? "Yes" : "No"); is_vni_live(vpn) ? "Yes" : "No");
json_object_string_add( json_object_string_add(
json, "rd", json, "rd",
prefix_rd2str(&vpn->prd, buf1, RD_ADDRSTRLEN)); prefix_rd2str(&vpn->prd, buf1, sizeof(buf1)));
json_object_string_add(json, "originatorIp", json_object_string_add(json, "originatorIp",
inet_ntoa(vpn->originator_ip)); inet_ntoa(vpn->originator_ip));
json_object_string_add(json, "advertiseGatewayMacip", json_object_string_add(json, "advertiseGatewayMacip",
@ -253,7 +253,7 @@ static void display_vni(struct vty *vty, struct bgpevpn *vpn, json_object *json)
vty_out(vty, "\n"); vty_out(vty, "\n");
vty_out(vty, " RD: %s\n", vty_out(vty, " RD: %s\n",
prefix_rd2str(&vpn->prd, buf1, RD_ADDRSTRLEN)); prefix_rd2str(&vpn->prd, buf1, sizeof(buf1)));
vty_out(vty, " Originator IP: %s\n", vty_out(vty, " Originator IP: %s\n",
inet_ntoa(vpn->originator_ip)); inet_ntoa(vpn->originator_ip));
vty_out(vty, " Advertise-gw-macip : %s\n", vty_out(vty, " Advertise-gw-macip : %s\n",
@ -419,7 +419,7 @@ static void show_vni_entry(struct hash_backet *backet, void *args[])
json_object *json_export_rtl; json_object *json_export_rtl;
struct bgpevpn *vpn = (struct bgpevpn *)backet->data; struct bgpevpn *vpn = (struct bgpevpn *)backet->data;
char buf1[10]; char buf1[10];
char buf2[INET6_ADDRSTRLEN]; char buf2[RD_ADDRSTRLEN];
char rt_buf[25]; char rt_buf[25];
char *ecom_str; char *ecom_str;
struct listnode *node, *nnode; struct listnode *node, *nnode;
@ -446,11 +446,11 @@ static void show_vni_entry(struct hash_backet *backet, void *args[])
inet_ntoa(vpn->originator_ip)); inet_ntoa(vpn->originator_ip));
json_object_string_add( json_object_string_add(
json_vni, "rd", json_vni, "rd",
prefix_rd2str(&vpn->prd, buf2, RD_ADDRSTRLEN)); prefix_rd2str(&vpn->prd, buf2, sizeof(buf2)));
} else { } else {
vty_out(vty, "%-1s %-10u %-15s %-21s", buf1, vpn->vni, vty_out(vty, "%-1s %-10u %-15s %-21s", buf1, vpn->vni,
inet_ntoa(vpn->originator_ip), inet_ntoa(vpn->originator_ip),
prefix_rd2str(&vpn->prd, buf2, RD_ADDRSTRLEN)); prefix_rd2str(&vpn->prd, buf2, sizeof(buf2)));
} }
for (ALL_LIST_ELEMENTS(vpn->import_rtl, node, nnode, ecom)) { for (ALL_LIST_ELEMENTS(vpn->import_rtl, node, nnode, ecom)) {
@ -2093,7 +2093,7 @@ static void evpn_unset_advertise_all_vni(struct bgp *bgp)
static void write_vni_config(struct vty *vty, struct bgpevpn *vpn) static void write_vni_config(struct vty *vty, struct bgpevpn *vpn)
{ {
char buf1[INET6_ADDRSTRLEN]; char buf1[RD_ADDRSTRLEN];
char *ecom_str; char *ecom_str;
struct listnode *node, *nnode; struct listnode *node, *nnode;
struct ecommunity *ecom; struct ecommunity *ecom;
@ -2102,7 +2102,7 @@ static void write_vni_config(struct vty *vty, struct bgpevpn *vpn)
vty_out(vty, " vni %d\n", vpn->vni); vty_out(vty, " vni %d\n", vpn->vni);
if (is_rd_configured(vpn)) if (is_rd_configured(vpn))
vty_out(vty, " rd %s\n", vty_out(vty, " rd %s\n",
prefix_rd2str(&vpn->prd, buf1, RD_ADDRSTRLEN)); prefix_rd2str(&vpn->prd, buf1, sizeof(buf1)));
if (is_import_rt_configured(vpn)) { if (is_import_rt_configured(vpn)) {
for (ALL_LIST_ELEMENTS(vpn->import_rtl, node, nnode, for (ALL_LIST_ELEMENTS(vpn->import_rtl, node, nnode,

View File

@ -166,8 +166,7 @@ char *prefix_rd2str(struct prefix_rd *prd, char *buf, size_t size)
struct rd_as rd_as; struct rd_as rd_as;
struct rd_ip rd_ip; struct rd_ip rd_ip;
if (size < RD_ADDRSTRLEN) assert(size >= RD_ADDRSTRLEN);
return NULL;
pnt = prd->val; pnt = prd->val;
@ -197,5 +196,7 @@ char *prefix_rd2str(struct prefix_rd *prd, char *buf, size_t size)
return buf; return buf;
} }
#endif #endif
return NULL;
snprintf(buf, size, "Unknown Type: %d", type);
return buf;
} }

View File

@ -7388,7 +7388,7 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct prefix *p,
vty_out(vty, " Imported from %s:%s\n", vty_out(vty, " Imported from %s:%s\n",
prefix_rd2str( prefix_rd2str(
(struct prefix_rd *)&prn->p, (struct prefix_rd *)&prn->p,
buf1, RD_ADDRSTRLEN), buf1, sizeof(buf1)),
buf2); buf2);
} }
} }
@ -7601,7 +7601,7 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct prefix *p,
json_peer, "routerId", json_peer, "routerId",
inet_ntop(AF_INET, inet_ntop(AF_INET,
&binfo->peer->remote_id, buf1, &binfo->peer->remote_id, buf1,
BUFSIZ)); sizeof(buf1)));
if (binfo->peer->hostname) if (binfo->peer->hostname)
json_object_string_add( json_object_string_add(
@ -7655,7 +7655,7 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct prefix *p,
inet_ntop( inet_ntop(
AF_INET, AF_INET,
&binfo->peer->remote_id, &binfo->peer->remote_id,
buf1, BUFSIZ)); buf1, sizeof(buf1)));
} }
} }
@ -8447,13 +8447,10 @@ int bgp_show_table_rd(struct vty *vty, struct bgp *bgp, safi_t safi,
continue; continue;
if (rn->info != NULL) { if (rn->info != NULL) {
struct prefix_rd prd; struct prefix_rd prd;
char rd[BUFSIZ]; char rd[RD_ADDRSTRLEN];
memcpy(&prd, &(rn->p), sizeof(struct prefix_rd)); memcpy(&prd, &(rn->p), sizeof(struct prefix_rd));
if (prefix_rd2str(&prd, rd, BUFSIZ) == NULL) prefix_rd2str(&prd, rd, sizeof(rd));
sprintf(rd,
"Unknown Type: %u",
decode_rd_type(prd.val));
bgp_show_table(vty, bgp, safi, rn->info, type, bgp_show_table(vty, bgp, safi, rn->info, type,
output_arg, use_json, output_arg, use_json,
rd, next == NULL, rd, next == NULL,
@ -8539,7 +8536,7 @@ void route_vty_out_detail_header(struct vty *vty, struct bgp *bgp,
struct prefix *p; struct prefix *p;
struct peer *peer; struct peer *peer;
struct listnode *node, *nnode; struct listnode *node, *nnode;
char buf1[INET6_ADDRSTRLEN]; char buf1[RD_ADDRSTRLEN];
char buf2[INET6_ADDRSTRLEN]; char buf2[INET6_ADDRSTRLEN];
#if defined(HAVE_CUMULUS) #if defined(HAVE_CUMULUS)
char buf3[EVPN_ROUTE_STRLEN]; char buf3[EVPN_ROUTE_STRLEN];
@ -8573,7 +8570,7 @@ void route_vty_out_detail_header(struct vty *vty, struct bgp *bgp,
#if defined(HAVE_CUMULUS) #if defined(HAVE_CUMULUS)
if (safi == SAFI_EVPN) if (safi == SAFI_EVPN)
vty_out(vty, "BGP routing table entry for %s%s%s\n", vty_out(vty, "BGP routing table entry for %s%s%s\n",
prd ? prefix_rd2str(prd, buf1, RD_ADDRSTRLEN) prd ? prefix_rd2str(prd, buf1, sizeof(buf1))
: "", : "",
prd ? ":" : "", prd ? ":" : "",
bgp_evpn_route2str((struct prefix_evpn *)p, bgp_evpn_route2str((struct prefix_evpn *)p,
@ -8582,7 +8579,7 @@ void route_vty_out_detail_header(struct vty *vty, struct bgp *bgp,
vty_out(vty, "BGP routing table entry for %s%s%s/%d\n", vty_out(vty, "BGP routing table entry for %s%s%s/%d\n",
((safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP) ((safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP)
? prefix_rd2str(prd, buf1, ? prefix_rd2str(prd, buf1,
RD_ADDRSTRLEN) sizeof(buf1))
: ""), : ""),
safi == SAFI_MPLS_VPN ? ":" : "", safi == SAFI_MPLS_VPN ? ":" : "",
inet_ntop(p->family, &p->u.prefix, buf2, inet_ntop(p->family, &p->u.prefix, buf2,
@ -8597,7 +8594,7 @@ void route_vty_out_detail_header(struct vty *vty, struct bgp *bgp,
vty_out(vty, "BGP routing table entry for %s%s%s/%d\n", vty_out(vty, "BGP routing table entry for %s%s%s/%d\n",
((safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP ((safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP
|| safi == SAFI_EVPN) || safi == SAFI_EVPN)
? prefix_rd2str(prd, buf1, RD_ADDRSTRLEN) ? prefix_rd2str(prd, buf1, sizeof(buf1))
: ""), : ""),
((safi == SAFI_MPLS_VPN) || (safi == SAFI_EVPN)) ? ":" ((safi == SAFI_MPLS_VPN) || (safi == SAFI_EVPN)) ? ":"
: "", : "",
@ -10569,12 +10566,17 @@ DEFUN (show_bgp_afi_vpn_rd_route,
afi_t afi = AFI_MAX; afi_t afi = AFI_MAX;
int idx = 0; int idx = 0;
(void)argv_find_and_parse_afi(argv, argc, &idx, &afi); if (!argv_find_and_parse_afi(argv, argc, &idx, &afi)) {
vty_out(vty, "%% Malformed Address Family\n");
return CMD_WARNING;
}
ret = str2prefix_rd(argv[5]->arg, &prd); ret = str2prefix_rd(argv[5]->arg, &prd);
if (!ret) { if (!ret) {
vty_out(vty, "%% Malformed Route Distinguisher\n"); vty_out(vty, "%% Malformed Route Distinguisher\n");
return CMD_WARNING; return CMD_WARNING;
} }
return bgp_show_route(vty, NULL, argv[6]->arg, afi, SAFI_MPLS_VPN, &prd, return bgp_show_route(vty, NULL, argv[6]->arg, afi, SAFI_MPLS_VPN, &prd,
0, BGP_PATH_ALL, use_json(argc, argv)); 0, BGP_PATH_ALL, use_json(argc, argv));
} }
@ -11139,7 +11141,7 @@ static void bgp_config_write_network_vpn(struct vty *vty, struct bgp *bgp,
prd = (struct prefix_rd *)&prn->p; prd = (struct prefix_rd *)&prn->p;
/* "network" configuration display. */ /* "network" configuration display. */
prefix_rd2str(prd, rdbuf, RD_ADDRSTRLEN); prefix_rd2str(prd, rdbuf, sizeof(rdbuf));
label = decode_label(&bgp_static->label); label = decode_label(&bgp_static->label);
vty_out(vty, " network %s/%d rd %s", vty_out(vty, " network %s/%d rd %s",
@ -11196,7 +11198,7 @@ static void bgp_config_write_network_evpn(struct vty *vty, struct bgp *bgp,
prd = (struct prefix_rd *)&prn->p; prd = (struct prefix_rd *)&prn->p;
/* "network" configuration display. */ /* "network" configuration display. */
prefix_rd2str(prd, rdbuf, RD_ADDRSTRLEN); prefix_rd2str(prd, rdbuf, sizeof(rdbuf));
if (p->u.prefix_evpn.route_type == 5) { if (p->u.prefix_evpn.route_type == 5) {
char local_buf[PREFIX_STRLEN]; char local_buf[PREFIX_STRLEN];
uint8_t family = IS_EVPN_PREFIX_IPADDR_V4((struct prefix_evpn *)p) uint8_t family = IS_EVPN_PREFIX_IPADDR_V4((struct prefix_evpn *)p)

View File

@ -170,12 +170,12 @@ struct rfapi_nve_group_cfg *bgp_rfapi_cfg_match_group(struct rfapi_cfg *hc,
#if BGP_VNC_DEBUG_MATCH_GROUP #if BGP_VNC_DEBUG_MATCH_GROUP
{ {
char buf[BUFSIZ]; char buf[PREFIX_STRLEN];
prefix2str(vn, buf, BUFSIZ); prefix2str(vn, buf, sizeof(buf));
vnc_zlog_debug_verbose("%s: vn prefix: %s", __func__, buf); vnc_zlog_debug_verbose("%s: vn prefix: %s", __func__, buf);
prefix2str(un, buf, BUFSIZ); prefix2str(un, buf, sizeof(buf));
vnc_zlog_debug_verbose("%s: un prefix: %s", __func__, buf); vnc_zlog_debug_verbose("%s: un prefix: %s", __func__, buf);
vnc_zlog_debug_verbose( vnc_zlog_debug_verbose(
@ -3884,8 +3884,7 @@ int bgp_rfapi_cfg_write(struct vty *vty, struct bgp *bgp)
} }
if (rfg->rd.prefixlen) { if (rfg->rd.prefixlen) {
char buf[BUFSIZ]; char buf[RD_ADDRSTRLEN];
buf[0] = buf[BUFSIZ - 1] = 0;
if (AF_UNIX == rfg->rd.family) { if (AF_UNIX == rfg->rd.family) {
@ -3898,18 +3897,10 @@ int bgp_rfapi_cfg_write(struct vty *vty, struct bgp *bgp)
vty_out(vty, " rd auto:nh:%d\n", vty_out(vty, " rd auto:nh:%d\n",
value); value);
} else { } else
vty_out(vty, " rd %s\n",
if (!prefix_rd2str(&rfg->rd, buf, prefix_rd2str(&rfg->rd, buf,
BUFSIZ) sizeof(buf)));
|| !buf[0] || buf[BUFSIZ - 1]) {
vty_out(vty,
"!Error: Can't convert rd\n");
} else {
vty_out(vty, " rd %s\n", buf);
}
}
} }
if (rfg->rt_import_list && rfg->rt_export_list if (rfg->rt_import_list && rfg->rt_export_list
@ -4107,8 +4098,7 @@ int bgp_rfapi_cfg_write(struct vty *vty, struct bgp *bgp)
vty_out(vty, " vnc defaults\n"); vty_out(vty, " vnc defaults\n");
if (hc->default_rd.prefixlen) { if (hc->default_rd.prefixlen) {
char buf[BUFSIZ]; char buf[RD_ADDRSTRLEN];
buf[0] = buf[BUFSIZ - 1] = 0;
if (AF_UNIX == hc->default_rd.family) { if (AF_UNIX == hc->default_rd.family) {
uint16_t value = 0; uint16_t value = 0;
@ -4121,18 +4111,11 @@ int bgp_rfapi_cfg_write(struct vty *vty, struct bgp *bgp)
vty_out(vty, " rd auto:vn:%d\n", vty_out(vty, " rd auto:vn:%d\n",
value); value);
} else { } else
vty_out(vty, " rd %s\n",
if (!prefix_rd2str(&hc->default_rd, buf, prefix_rd2str(&hc->default_rd,
BUFSIZ) buf,
|| !buf[0] || buf[BUFSIZ - 1]) { sizeof(buf)));
vty_out(vty,
"!Error: Can't convert rd\n");
} else {
vty_out(vty, " rd %s\n", buf);
}
}
} }
if (hc->default_response_lifetime) { if (hc->default_response_lifetime) {
vty_out(vty, " response-lifetime "); vty_out(vty, " response-lifetime ");
@ -4187,38 +4170,26 @@ int bgp_rfapi_cfg_write(struct vty *vty, struct bgp *bgp)
vty_out(vty, " vnc nve-group %s\n", rfg->name); vty_out(vty, " vnc nve-group %s\n", rfg->name);
if (rfg->vn_prefix.family && rfg->vn_node) { if (rfg->vn_prefix.family && rfg->vn_node) {
char buf[BUFSIZ]; char buf[PREFIX_STRLEN];
buf[0] = buf[BUFSIZ - 1] = 0;
prefix2str(&rfg->vn_prefix, buf, prefix2str(&rfg->vn_prefix, buf,
BUFSIZ); sizeof(buf));
if (!buf[0] || buf[BUFSIZ - 1]) {
vty_out(vty,
"!Error: Can't convert prefix\n");
} else {
vty_out(vty, " prefix %s %s\n", vty_out(vty, " prefix %s %s\n",
"vn", buf); "vn", buf);
} }
}
if (rfg->un_prefix.family && rfg->un_node) { if (rfg->un_prefix.family && rfg->un_node) {
char buf[BUFSIZ]; char buf[PREFIX_STRLEN];
buf[0] = buf[BUFSIZ - 1] = 0;
prefix2str(&rfg->un_prefix, buf, prefix2str(&rfg->un_prefix, buf,
BUFSIZ); sizeof(buf));
if (!buf[0] || buf[BUFSIZ - 1]) {
vty_out(vty,
"!Error: Can't convert prefix\n");
} else {
vty_out(vty, " prefix %s %s\n", vty_out(vty, " prefix %s %s\n",
"un", buf); "un", buf);
} }
}
if (rfg->rd.prefixlen) { if (rfg->rd.prefixlen) {
char buf[BUFSIZ]; char buf[RD_ADDRSTRLEN];
buf[0] = buf[BUFSIZ - 1] = 0;
if (AF_UNIX == rfg->rd.family) { if (AF_UNIX == rfg->rd.family) {
@ -4233,21 +4204,12 @@ int bgp_rfapi_cfg_write(struct vty *vty, struct bgp *bgp)
" rd auto:vn:%d\n", " rd auto:vn:%d\n",
value); value);
} else { } else
if (!prefix_rd2str(&rfg->rd,
buf, BUFSIZ)
|| !buf[0]
|| buf[BUFSIZ - 1]) {
vty_out(vty,
"!Error: Can't convert rd\n");
} else {
vty_out(vty, vty_out(vty,
" rd %s\n", " rd %s\n",
buf); prefix_rd2str(&rfg->rd,
} buf,
} sizeof(buf)));
} }
if (rfg->flags & RFAPI_RFG_RESPONSE_LIFETIME) { if (rfg->flags & RFAPI_RFG_RESPONSE_LIFETIME) {
vty_out(vty, " response-lifetime "); vty_out(vty, " response-lifetime ");

View File

@ -363,15 +363,11 @@ void del_vnc_route(struct rfapi_descriptor *rfd,
afi_t afi; /* of the VN address */ afi_t afi; /* of the VN address */
struct bgp_node *bn; struct bgp_node *bn;
struct bgp_info *bi; struct bgp_info *bi;
char buf[BUFSIZ]; char buf[PREFIX_STRLEN];
char buf2[BUFSIZ]; char buf2[RD_ADDRSTRLEN];
struct prefix_rd prd0; struct prefix_rd prd0;
prefix2str(p, buf, BUFSIZ); prefix2str(p, buf, sizeof(buf));
buf[BUFSIZ - 1] = 0; /* guarantee NUL-terminated */
prefix_rd2str(prd, buf2, BUFSIZ);
buf2[BUFSIZ - 1] = 0;
afi = family2afi(p->family); afi = family2afi(p->family);
assert(afi == AFI_IP || afi == AFI_IP6); assert(afi == AFI_IP || afi == AFI_IP6);
@ -386,7 +382,8 @@ void del_vnc_route(struct rfapi_descriptor *rfd,
vnc_zlog_debug_verbose( vnc_zlog_debug_verbose(
"%s: peer=%p, prefix=%s, prd=%s afi=%d, safi=%d bn=%p, bn->info=%p", "%s: peer=%p, prefix=%s, prd=%s afi=%d, safi=%d bn=%p, bn->info=%p",
__func__, peer, buf, buf2, afi, safi, bn, __func__, peer, buf,
prefix_rd2str(prd, buf2, sizeof(buf2)), afi, safi, bn,
(bn ? bn->info : NULL)); (bn ? bn->info : NULL));
for (bi = (bn ? bn->info : NULL); bi; bi = bi->next) { for (bi = (bn ? bn->info : NULL); bi; bi = bi->next) {
@ -464,11 +461,9 @@ void del_vnc_route(struct rfapi_descriptor *rfd,
rfapiProcessWithdraw(peer, rfd, p, prd, NULL, afi, safi, type, kill); rfapiProcessWithdraw(peer, rfd, p, prd, NULL, afi, safi, type, kill);
if (bi) { if (bi) {
char buf[BUFSIZ]; char buf[PREFIX_STRLEN];
prefix2str(p, buf, BUFSIZ);
buf[BUFSIZ - 1] = 0; /* guarantee NUL-terminated */
prefix2str(p, buf, sizeof(buf));
vnc_zlog_debug_verbose( vnc_zlog_debug_verbose(
"%s: Found route (safi=%d) to delete at prefix %s", "%s: Found route (safi=%d) to delete at prefix %s",
__func__, safi, buf); __func__, safi, buf);
@ -593,8 +588,8 @@ void add_vnc_route(struct rfapi_descriptor *rfd, /* cookie, VPN UN addr, peer */
uint32_t label_val; uint32_t label_val;
struct bgp_attr_encap_subtlv *encaptlv; struct bgp_attr_encap_subtlv *encaptlv;
char buf[BUFSIZ]; char buf[PREFIX_STRLEN];
char buf2[BUFSIZ]; char buf2[RD_ADDRSTRLEN];
#if 0 /* unused? */ #if 0 /* unused? */
struct prefix pfx_buf; struct prefix pfx_buf;
#endif #endif
@ -650,9 +645,7 @@ void add_vnc_route(struct rfapi_descriptor *rfd, /* cookie, VPN UN addr, peer */
else else
label_val = MPLS_LABEL_IMPLICIT_NULL; label_val = MPLS_LABEL_IMPLICIT_NULL;
prefix_rd2str(prd, buf2, BUFSIZ); prefix_rd2str(prd, buf2, sizeof(buf2));
buf2[BUFSIZ - 1] = 0;
afi = family2afi(p->family); afi = family2afi(p->family);
assert(afi == AFI_IP || afi == AFI_IP6); assert(afi == AFI_IP || afi == AFI_IP6);
@ -907,8 +900,7 @@ void add_vnc_route(struct rfapi_descriptor *rfd, /* cookie, VPN UN addr, peer */
} }
prefix2str(p, buf, BUFSIZ); prefix2str(p, buf, sizeof(buf));
buf[BUFSIZ - 1] = 0; /* guarantee NUL-terminated */
/* /*
* At this point: * At this point:
@ -1611,11 +1603,10 @@ rfapi_query_inner(void *handle, struct rfapi_ip_addr *target,
} }
{ {
char buf[BUFSIZ]; char buf[PREFIX_STRLEN];
char *s; char *s;
prefix2str(&p, buf, BUFSIZ); prefix2str(&p, buf, sizeof(buf));
buf[BUFSIZ - 1] = 0; /* guarantee NUL-terminated */
vnc_zlog_debug_verbose("%s(rfd=%p, target=%s, ppNextHop=%p)", vnc_zlog_debug_verbose("%s(rfd=%p, target=%s, ppNextHop=%p)",
__func__, rfd, buf, ppNextHopEntry); __func__, rfd, buf, ppNextHopEntry);
@ -2434,10 +2425,9 @@ int rfapi_register(void *handle, struct rfapi_ip_prefix *prefix,
{ {
char buf[BUFSIZ]; char buf[PREFIX_STRLEN];
prefix2str(&p, buf, BUFSIZ); prefix2str(&p, buf, sizeof(buf));
buf[BUFSIZ - 1] = 0; /* guarantee NUL-terminated */
vnc_zlog_debug_verbose( vnc_zlog_debug_verbose(
"%s(rfd=%p, pfx=%s, lifetime=%d, opts_un=%p, opts_vn=%p, action=%s)", "%s(rfd=%p, pfx=%s, lifetime=%d, opts_un=%p, opts_vn=%p, action=%s)",
__func__, rfd, buf, lifetime, options_un, options_vn, __func__, rfd, buf, lifetime, options_un, options_vn,
@ -3841,12 +3831,10 @@ int rfapi_set_autord_from_vn(struct prefix_rd *rd, struct rfapi_ip_addr *vn)
4); /* low order 4 bytes */ 4); /* low order 4 bytes */
} }
{ {
char buf[BUFSIZ]; char buf[RD_ADDRSTRLEN];
buf[0] = 0;
prefix_rd2str(rd, buf, BUFSIZ);
buf[BUFSIZ - 1] = 0;
vnc_zlog_debug_verbose("%s: auto-RD is set to %s", __func__, vnc_zlog_debug_verbose("%s: auto-RD is set to %s", __func__,
buf); prefix_rd2str(rd, buf, sizeof(buf)));
} }
return 0; return 0;
} }

View File

@ -41,6 +41,7 @@
#include "bgpd/bgp_route.h" #include "bgpd/bgp_route.h"
#include "bgpd/bgp_mplsvpn.h" /* prefix_rd2str() */ #include "bgpd/bgp_mplsvpn.h" /* prefix_rd2str() */
#include "bgpd/bgp_vnc_types.h" #include "bgpd/bgp_vnc_types.h"
#include "bgpd/bgp_rd.h"
#include "bgpd/rfapi/rfapi.h" #include "bgpd/rfapi/rfapi.h"
#include "bgpd/rfapi/bgp_rfapi_cfg.h" #include "bgpd/rfapi/bgp_rfapi_cfg.h"
@ -645,10 +646,9 @@ rfapiMonitorMoveShorter(struct route_node *original_vpn_node, int lockoffset)
#if DEBUG_MONITOR_MOVE_SHORTER #if DEBUG_MONITOR_MOVE_SHORTER
{ {
char buf[BUFSIZ]; char buf[PREFIX_STRLEN];
prefix2str(&original_vpn_node->p, buf, BUFSIZ); prefix2str(&original_vpn_node->p, buf, sizeof(buf));
buf[BUFSIZ - 1] = 0;
vnc_zlog_debug_verbose("%s: called with node pfx=%s", __func__, vnc_zlog_debug_verbose("%s: called with node pfx=%s", __func__,
buf); buf);
} }
@ -779,10 +779,9 @@ rfapiMonitorMoveShorter(struct route_node *original_vpn_node, int lockoffset)
#if DEBUG_MONITOR_MOVE_SHORTER #if DEBUG_MONITOR_MOVE_SHORTER
{ {
char buf[BUFSIZ]; char buf[PREFIX_STRLEN];
prefix2str(&par->p, buf, BUFSIZ); prefix2str(&par->p, buf, sizeof(buf));
buf[BUFSIZ - 1] = 0;
vnc_zlog_debug_verbose("%s: moved to node pfx=%s", __func__, vnc_zlog_debug_verbose("%s: moved to node pfx=%s", __func__,
buf); buf);
} }
@ -1594,10 +1593,9 @@ static int rfapiNhlAddNodeRoutes(
} }
if (!skiplist_search(seen_nexthops, &pfx_vn, NULL)) { if (!skiplist_search(seen_nexthops, &pfx_vn, NULL)) {
#if DEBUG_RETURNED_NHL #if DEBUG_RETURNED_NHL
char buf[BUFSIZ]; char buf[PREFIX_STRLEN];
prefix2str(&pfx_vn, buf, BUFSIZ); prefix2str(&pfx_vn, buf, sizeof(buf));
buf[BUFSIZ - 1] = 0; /* guarantee NUL-terminated */
vnc_zlog_debug_verbose( vnc_zlog_debug_verbose(
"%s: already put VN/nexthop %s, skip", __func__, "%s: already put VN/nexthop %s, skip", __func__,
buf); buf);
@ -1760,10 +1758,9 @@ struct rfapi_next_hop_entry *rfapiRouteNode2NextHopList(
#if DEBUG_RETURNED_NHL #if DEBUG_RETURNED_NHL
{ {
char buf[BUFSIZ]; char buf[PREFIX_STRLEN];
prefix2str(&rn->p, buf, BUFSIZ); prefix2str(&rn->p, buf, sizeof(buf));
buf[BUFSIZ - 1] = 0;
vnc_zlog_debug_verbose("%s: called with node pfx=%s", __func__, vnc_zlog_debug_verbose("%s: called with node pfx=%s", __func__,
buf); buf);
} }
@ -2136,10 +2133,12 @@ static void rfapiItBiIndexAdd(struct route_node *rn, /* Import table VPN node */
assert(bi->extra); assert(bi->extra);
{ {
char buf[BUFSIZ]; char buf[RD_ADDRSTRLEN];
prefix_rd2str(&bi->extra->vnc.import.rd, buf, BUFSIZ);
vnc_zlog_debug_verbose("%s: bi %p, peer %p, rd %s", __func__, vnc_zlog_debug_verbose("%s: bi %p, peer %p, rd %s", __func__,
bi, bi->peer, buf); bi, bi->peer,
prefix_rd2str(&bi->extra->vnc.import.rd,
buf, sizeof(buf)));
} }
sl = RFAPI_RDINDEX_W_ALLOC(rn); sl = RFAPI_RDINDEX_W_ALLOC(rn);
@ -2173,18 +2172,15 @@ static void rfapiItBiIndexDump(struct route_node *rn)
for (rc = skiplist_next(sl, (void **)&k, (void **)&v, &cursor); !rc; for (rc = skiplist_next(sl, (void **)&k, (void **)&v, &cursor); !rc;
rc = skiplist_next(sl, (void **)&k, (void **)&v, &cursor)) { rc = skiplist_next(sl, (void **)&k, (void **)&v, &cursor)) {
char buf[BUFSIZ]; char buf[RD_ADDRSTRLEN];
char buf_aux_pfx[BUFSIZ]; char buf_aux_pfx[PREFIX_STRLEN];
prefix_rd2str(&k->extra->vnc.import.rd, buf, BUFSIZ); prefix_rd2str(&k->extra->vnc.import.rd, buf, sizeof(buf));
buf_aux_pfx[0] = 0;
if (k->extra->vnc.import.aux_prefix.family) { if (k->extra->vnc.import.aux_prefix.family) {
prefix2str(&k->extra->vnc.import.aux_prefix, prefix2str(&k->extra->vnc.import.aux_prefix,
buf_aux_pfx, BUFSIZ); buf_aux_pfx, sizeof(buf_aux_pfx));
} else { } else
strncpy(buf_aux_pfx, "(none)", BUFSIZ); strncpy(buf_aux_pfx, "(none)", PREFIX_STRLEN);
buf_aux_pfx[BUFSIZ - 1] = 0;
}
vnc_zlog_debug_verbose("bi %p, peer %p, rd %s, aux_prefix %s", vnc_zlog_debug_verbose("bi %p, peer %p, rd %s, aux_prefix %s",
k, k->peer, buf, buf_aux_pfx); k, k->peer, buf, buf_aux_pfx);
@ -2208,19 +2204,19 @@ static struct bgp_info *rfapiItBiIndexSearch(
#if DEBUG_BI_SEARCH #if DEBUG_BI_SEARCH
{ {
char buf[BUFSIZ]; char buf[RD_ADDRSTRLEN];
char buf_aux_pfx[BUFSIZ]; char buf_aux_pfx[PREFIX_STRLEN];
prefix_rd2str(prd, buf, BUFSIZ);
if (aux_prefix) { if (aux_prefix) {
prefix2str(aux_prefix, buf_aux_pfx, BUFSIZ); prefix2str(aux_prefix, buf_aux_pfx,
} else { sizeof(buf_aux_pfx));
strncpy(buf_aux_pfx, "(nil)", BUFSIZ - 1); } else
buf_aux_pfx[BUFSIZ - 1] = 0; strncpy(buf_aux_pfx, "(nil)", sizeof(buf_aux_pfx));
}
vnc_zlog_debug_verbose("%s want prd=%s, peer=%p, aux_prefix=%s", vnc_zlog_debug_verbose("%s want prd=%s, peer=%p, aux_prefix=%s",
__func__, buf, peer, buf_aux_pfx); __func__,
prefix_rd2str(prd, buf, sizeof(buf)),
peer, buf_aux_pfx);
rfapiItBiIndexDump(rn); rfapiItBiIndexDump(rn);
} }
#endif #endif
@ -2235,12 +2231,14 @@ static struct bgp_info *rfapiItBiIndexSearch(
bi_result = bi_result->next) { bi_result = bi_result->next) {
#if DEBUG_BI_SEARCH #if DEBUG_BI_SEARCH
{ {
char buf[BUFSIZ]; char buf[RD_ADDRSTRLEN];
prefix_rd2str(&bi_result->extra->vnc.import.rd,
buf, BUFSIZ);
vnc_zlog_debug_verbose( vnc_zlog_debug_verbose(
"%s: bi has prd=%s, peer=%p", __func__, "%s: bi has prd=%s, peer=%p", __func__,
buf, bi_result->peer); prefix_rd2str(&bi_result->extra->vnc.import.rd,
buf,
sizeof(buf)),
bi_result->peer);
} }
#endif #endif
if (peer == bi_result->peer if (peer == bi_result->peer
@ -2303,10 +2301,12 @@ static void rfapiItBiIndexDel(struct route_node *rn, /* Import table VPN node */
int rc; int rc;
{ {
char buf[BUFSIZ]; char buf[RD_ADDRSTRLEN];
prefix_rd2str(&bi->extra->vnc.import.rd, buf, BUFSIZ);
vnc_zlog_debug_verbose("%s: bi %p, peer %p, rd %s", __func__, vnc_zlog_debug_verbose("%s: bi %p, peer %p, rd %s", __func__,
bi, bi->peer, buf); bi, bi->peer,
prefix_rd2str(&bi->extra->vnc.import.rd,
buf, sizeof(buf)));
} }
sl = RFAPI_RDINDEX(rn); sl = RFAPI_RDINDEX(rn);
@ -3671,9 +3671,9 @@ void rfapiBgpInfoFilteredImportVPN(
rfapiCopyUnEncap2VPN(ern->info, info_new); rfapiCopyUnEncap2VPN(ern->info, info_new);
route_unlock_node(ern); /* undo lock in route_note_match */ route_unlock_node(ern); /* undo lock in route_note_match */
} else { } else {
char buf[BUFSIZ]; char buf[PREFIX_STRLEN];
prefix2str(&vn_prefix, buf, sizeof(buf)); prefix2str(&vn_prefix, buf, sizeof(buf));
buf[BUFSIZ - 1] = 0;
/* Not a big deal, just means VPN route got here first */ /* Not a big deal, just means VPN route got here first */
vnc_zlog_debug_verbose("%s: no encap route for vn addr %s", vnc_zlog_debug_verbose("%s: no encap route for vn addr %s",
__func__, buf); __func__, buf);
@ -4433,10 +4433,10 @@ static void rfapiDeleteRemotePrefixesIt(
#if DEBUG_L2_EXTRA #if DEBUG_L2_EXTRA
{ {
char buf_pfx[BUFSIZ]; char buf_pfx[PREFIX_STRLEN];
if (p) { if (p) {
prefix2str(p, buf_pfx, BUFSIZ); prefix2str(p, buf_pfx, sizeof(buf_pfx));
} else { } else {
buf_pfx[0] = '*'; buf_pfx[0] = '*';
buf_pfx[1] = 0; buf_pfx[1] = 0;
@ -4469,11 +4469,11 @@ static void rfapiDeleteRemotePrefixesIt(
struct bgp_info *next; struct bgp_info *next;
if (VNC_DEBUG(IMPORT_DEL_REMOTE)) { if (VNC_DEBUG(IMPORT_DEL_REMOTE)) {
char p1line[BUFSIZ]; char p1line[PREFIX_STRLEN];
char p2line[BUFSIZ]; char p2line[PREFIX_STRLEN];
prefix2str(p, p1line, BUFSIZ); prefix2str(p, p1line, sizeof(p1line));
prefix2str(&rn->p, p2line, BUFSIZ); prefix2str(&rn->p, p2line, sizeof(p2line));
vnc_zlog_debug_any("%s: want %s, have %s", vnc_zlog_debug_any("%s: want %s, have %s",
__func__, p1line, p2line); __func__, p1line, p2line);
} }
@ -4482,8 +4482,9 @@ static void rfapiDeleteRemotePrefixesIt(
continue; continue;
{ {
char buf_pfx[BUFSIZ]; char buf_pfx[PREFIX_STRLEN];
prefix2str(&rn->p, buf_pfx, BUFSIZ);
prefix2str(&rn->p, buf_pfx, sizeof(buf_pfx));
vnc_zlog_debug_verbose("%s: rn pfx=%s", vnc_zlog_debug_verbose("%s: rn pfx=%s",
__func__, buf_pfx); __func__, buf_pfx);
} }

View File

@ -839,7 +839,7 @@ void rfapiMonitorItNodeChanged(
struct bgp *bgp = bgp_get_default(); struct bgp *bgp = bgp_get_default();
afi_t afi = family2afi(rn->p.family); afi_t afi = family2afi(rn->p.family);
#if DEBUG_L2_EXTRA #if DEBUG_L2_EXTRA
char buf_prefix[BUFSIZ]; char buf_prefix[PREFIX_STRLEN];
#endif #endif
assert(bgp); assert(bgp);
@ -848,7 +848,7 @@ void rfapiMonitorItNodeChanged(
nves_seen = skiplist_new(0, NULL, NULL); nves_seen = skiplist_new(0, NULL, NULL);
#if DEBUG_L2_EXTRA #if DEBUG_L2_EXTRA
prefix2str(&it_node->p, buf_prefix, BUFSIZ); prefix2str(&it_node->p, buf_prefix, sizeof(buf_prefix));
vnc_zlog_debug_verbose("%s: it=%p, it_node=%p, it_node->prefix=%s", vnc_zlog_debug_verbose("%s: it=%p, it_node=%p, it_node->prefix=%s",
__func__, import_table, it_node, buf_prefix); __func__, import_table, it_node, buf_prefix);
#endif #endif
@ -926,22 +926,20 @@ void rfapiMonitorItNodeChanged(
assert(!skiplist_insert(nves_seen, assert(!skiplist_insert(nves_seen,
m->rfd, NULL)); m->rfd, NULL));
{ char buf_attach_pfx[PREFIX_STRLEN];
char buf_attach_pfx[BUFSIZ]; char buf_target_pfx[PREFIX_STRLEN];
char buf_target_pfx[BUFSIZ];
prefix2str(&m->node->p, prefix2str(&m->node->p,
buf_attach_pfx, buf_attach_pfx,
BUFSIZ); sizeof(buf_attach_pfx));
prefix2str(&m->p, prefix2str(&m->p,
buf_target_pfx, buf_target_pfx,
BUFSIZ); sizeof(buf_target_pfx));
vnc_zlog_debug_verbose( vnc_zlog_debug_verbose(
"%s: update rfd %p attached to pfx %s (targ=%s)", "%s: update rfd %p attached to pfx %s (targ=%s)",
__func__, m->rfd, __func__, m->rfd,
buf_attach_pfx, buf_attach_pfx,
buf_target_pfx); buf_target_pfx);
}
/* /*
* update its RIB * update its RIB
@ -1271,8 +1269,9 @@ static void rfapiMonitorEthDetachImport(
assert(rn); assert(rn);
#if DEBUG_L2_EXTRA #if DEBUG_L2_EXTRA
char buf_prefix[BUFSIZ]; char buf_prefix[PREFIX_STRLEN];
prefix2str(&rn->p, buf_prefix, BUFSIZ);
prefix2str(&rn->p, buf_prefix, sizeof(buf_prefix));
#endif #endif
/* /*

View File

@ -342,7 +342,7 @@ rfapiRibStartTimer(struct rfapi_descriptor *rfd, struct rfapi_info *ri,
{ {
struct thread *t = ri->timer; struct thread *t = ri->timer;
struct rfapi_rib_tcb *tcb = NULL; struct rfapi_rib_tcb *tcb = NULL;
char buf_prefix[BUFSIZ]; char buf_prefix[PREFIX_STRLEN];
if (t) { if (t) {
tcb = t->arg; tcb = t->arg;
@ -363,7 +363,7 @@ rfapiRibStartTimer(struct rfapi_descriptor *rfd, struct rfapi_info *ri,
UNSET_FLAG(tcb->flags, RFAPI_RIB_TCB_FLAG_DELETED); UNSET_FLAG(tcb->flags, RFAPI_RIB_TCB_FLAG_DELETED);
} }
prefix2str(&rn->p, buf_prefix, BUFSIZ); prefix2str(&rn->p, buf_prefix, sizeof(buf_prefix));
vnc_zlog_debug_verbose("%s: rfd %p pfx %s life %u", __func__, rfd, vnc_zlog_debug_verbose("%s: rfd %p pfx %s life %u", __func__, rfd,
buf_prefix, ri->lifetime); buf_prefix, ri->lifetime);
ri->timer = NULL; ri->timer = NULL;
@ -852,7 +852,7 @@ static void process_pending_node(struct bgp *bgp, struct rfapi_descriptor *rfd,
struct list *lPendCost = NULL; struct list *lPendCost = NULL;
struct list *delete_list = NULL; struct list *delete_list = NULL;
int printedprefix = 0; int printedprefix = 0;
char buf_prefix[BUFSIZ]; char buf_prefix[PREFIX_STRLEN];
int rib_node_started_nonempty = 0; int rib_node_started_nonempty = 0;
int sendingsomeroutes = 0; int sendingsomeroutes = 0;
@ -863,7 +863,7 @@ static void process_pending_node(struct bgp *bgp, struct rfapi_descriptor *rfd,
#endif #endif
assert(pn); assert(pn);
prefix2str(&pn->p, buf_prefix, BUFSIZ); prefix2str(&pn->p, buf_prefix, sizeof(buf_prefix));
vnc_zlog_debug_verbose("%s: afi=%d, %s pn->info=%p", __func__, afi, vnc_zlog_debug_verbose("%s: afi=%d, %s pn->info=%p", __func__, afi,
buf_prefix, pn->info); buf_prefix, pn->info);
@ -913,8 +913,8 @@ static void process_pending_node(struct bgp *bgp, struct rfapi_descriptor *rfd,
while (0 while (0
== skiplist_first(slRibPt, NULL, (void **)&ri)) { == skiplist_first(slRibPt, NULL, (void **)&ri)) {
char buf[BUFSIZ]; char buf[PREFIX_STRLEN];
char buf2[BUFSIZ]; char buf2[PREFIX_STRLEN];
listnode_add(delete_list, ri); listnode_add(delete_list, ri);
vnc_zlog_debug_verbose( vnc_zlog_debug_verbose(
@ -932,8 +932,8 @@ static void process_pending_node(struct bgp *bgp, struct rfapi_descriptor *rfd,
ri->timer = NULL; ri->timer = NULL;
} }
prefix2str(&ri->rk.vn, buf, BUFSIZ); prefix2str(&ri->rk.vn, buf, sizeof(buf));
prefix2str(&ri->un, buf2, BUFSIZ); prefix2str(&ri->un, buf2, sizeof(buf2));
vnc_zlog_debug_verbose( vnc_zlog_debug_verbose(
"%s: put dl pfx=%s vn=%s un=%s cost=%d life=%d vn_options=%p", "%s: put dl pfx=%s vn=%s un=%s cost=%d life=%d vn_options=%p",
__func__, buf_prefix, buf, buf2, __func__, buf_prefix, buf, buf2,
@ -1123,7 +1123,7 @@ static void process_pending_node(struct bgp *bgp, struct rfapi_descriptor *rfd,
} else { } else {
char buf_rd[BUFSIZ]; char buf_rd[RD_ADDRSTRLEN];
/* not found: add new route to RIB */ /* not found: add new route to RIB */
ori = rfapi_info_new(); ori = rfapi_info_new();
@ -1402,13 +1402,14 @@ callback:
ri->last_sent_time = rfapi_time(NULL); ri->last_sent_time = rfapi_time(NULL);
#if DEBUG_RIB_SL_RD #if DEBUG_RIB_SL_RD
{ {
char buf_rd[BUFSIZ]; char buf_rd[RD_ADDRSTRLEN];
prefix_rd2str(&ri->rk.rd,
buf_rd,
sizeof(buf_rd));
vnc_zlog_debug_verbose( vnc_zlog_debug_verbose(
"%s: move route to recently deleted list, rd=%s", "%s: move route to recently deleted list, rd=%s",
__func__, buf_rd); __func__,
prefix_rd2str(&ri->rk.rd,
buf_rd,
sizeof(buf_rd)));
} }
#endif #endif
@ -1592,7 +1593,7 @@ void rfapiRibUpdatePendingNode(
afi_t afi; afi_t afi;
uint32_t queued_flag; uint32_t queued_flag;
int count = 0; int count = 0;
char buf[BUFSIZ]; char buf[PREFIX_STRLEN];
vnc_zlog_debug_verbose("%s: entry", __func__); vnc_zlog_debug_verbose("%s: entry", __func__);
@ -1605,7 +1606,7 @@ void rfapiRibUpdatePendingNode(
prefix = &it_node->p; prefix = &it_node->p;
afi = family2afi(prefix->family); afi = family2afi(prefix->family);
prefix2str(prefix, buf, BUFSIZ); prefix2str(prefix, buf, sizeof(buf));
vnc_zlog_debug_verbose("%s: prefix=%s", __func__, buf); vnc_zlog_debug_verbose("%s: prefix=%s", __func__, buf);
pn = route_node_get(rfd->rib_pending[afi], prefix); pn = route_node_get(rfd->rib_pending[afi], prefix);
@ -1811,9 +1812,9 @@ int rfapiRibFTDFilterRecentPrefix(
#if DEBUG_FTD_FILTER_RECENT #if DEBUG_FTD_FILTER_RECENT
{ {
char buf_pfx[BUFSIZ]; char buf_pfx[PREFIX_STRLEN];
prefix2str(&it_rn->p, buf_pfx, BUFSIZ); prefix2str(&it_rn->p, buf_pfx, sizeof(buf_pfx));
vnc_zlog_debug_verbose("%s: prefix %s", __func__, buf_pfx); vnc_zlog_debug_verbose("%s: prefix %s", __func__, buf_pfx);
} }
#endif #endif
@ -1975,14 +1976,15 @@ rfapiRibPreload(struct bgp *bgp, struct rfapi_descriptor *rfd,
#if DEBUG_NHL #if DEBUG_NHL
{ {
char str_vn[BUFSIZ]; char str_vn[PREFIX_STRLEN];
char str_aux_prefix[BUFSIZ]; char str_aux_prefix[PREFIX_STRLEN];
str_vn[0] = 0; str_vn[0] = 0;
str_aux_prefix[0] = 0; str_aux_prefix[0] = 0;
prefix2str(&rk.vn, str_vn, BUFSIZ); prefix2str(&rk.vn, str_vn, sizeof(str_vn));
prefix2str(&rk.aux_prefix, str_aux_prefix, BUFSIZ); prefix2str(&rk.aux_prefix, str_aux_prefix,
sizeof(str_aux_prefix));
if (!rk.aux_prefix.family) { if (!rk.aux_prefix.family) {
} }
@ -2072,11 +2074,11 @@ rfapiRibPreload(struct bgp *bgp, struct rfapi_descriptor *rfd,
route_unlock_node(trn); route_unlock_node(trn);
{ {
char str_pfx[BUFSIZ]; char str_pfx[PREFIX_STRLEN];
char str_pfx_vn[BUFSIZ]; char str_pfx_vn[PREFIX_STRLEN];
prefix2str(&pfx, str_pfx, BUFSIZ); prefix2str(&pfx, str_pfx, sizeof(str_pfx));
prefix2str(&rk.vn, str_pfx_vn, BUFSIZ); prefix2str(&rk.vn, str_pfx_vn, sizeof(str_pfx_vn));
vnc_zlog_debug_verbose( vnc_zlog_debug_verbose(
"%s: added pfx=%s nh[vn]=%s, cost=%u, lifetime=%u, allowed=%d", "%s: added pfx=%s nh[vn]=%s, cost=%u, lifetime=%u, allowed=%d",
__func__, str_pfx, str_pfx_vn, nhp->prefix.cost, __func__, str_pfx, str_pfx_vn, nhp->prefix.cost,
@ -2111,9 +2113,9 @@ void rfapiRibPendingDeleteRoute(struct bgp *bgp, struct rfapi_import_table *it,
{ {
struct rfapi_descriptor *rfd; struct rfapi_descriptor *rfd;
struct listnode *node; struct listnode *node;
char buf[BUFSIZ]; char buf[PREFIX_STRLEN];
prefix2str(&it_node->p, buf, BUFSIZ); prefix2str(&it_node->p, buf, sizeof(buf));
vnc_zlog_debug_verbose("%s: entry, it=%p, afi=%d, it_node=%p, pfx=%s", vnc_zlog_debug_verbose("%s: entry, it=%p, afi=%d, it_node=%p, pfx=%s",
__func__, it, afi, it_node, buf); __func__, it, afi, it_node, buf);
@ -2287,21 +2289,21 @@ static int print_rib_sl(int (*fp)(void *, const char *, ...), struct vty *vty,
for (rc = skiplist_next(sl, NULL, (void **)&ri, &cursor); !rc; for (rc = skiplist_next(sl, NULL, (void **)&ri, &cursor); !rc;
rc = skiplist_next(sl, NULL, (void **)&ri, &cursor)) { rc = skiplist_next(sl, NULL, (void **)&ri, &cursor)) {
char str_vn[BUFSIZ]; char str_vn[PREFIX_STRLEN];
char str_un[BUFSIZ]; char str_un[PREFIX_STRLEN];
char str_lifetime[BUFSIZ]; char str_lifetime[BUFSIZ];
char str_age[BUFSIZ]; char str_age[BUFSIZ];
char *p; char *p;
char str_rd[BUFSIZ]; char str_rd[RD_ADDRSTRLEN];
++routes_displayed; ++routes_displayed;
prefix2str(&ri->rk.vn, str_vn, BUFSIZ); prefix2str(&ri->rk.vn, str_vn, sizeof(str_vn));
p = index(str_vn, '/'); p = index(str_vn, '/');
if (p) if (p)
*p = 0; *p = 0;
prefix2str(&ri->un, str_un, BUFSIZ); prefix2str(&ri->un, str_un, sizeof(str_un));
p = index(str_un, '/'); p = index(str_un, '/');
if (p) if (p)
*p = 0; *p = 0;
@ -2322,8 +2324,7 @@ static int print_rib_sl(int (*fp)(void *, const char *, ...), struct vty *vty,
str_rd[0] = 0; /* start empty */ str_rd[0] = 0; /* start empty */
#if DEBUG_RIB_SL_RD #if DEBUG_RIB_SL_RD
str_rd[0] = ' '; prefix_rd2str(&ri->rk.rd, str_rd, sizeof(str_rd));
prefix_rd2str(&ri->rk.rd, str_rd + 1, BUFSIZ - 1);
#endif #endif
fp(out, " %c %-20s %-15s %-15s %-4u %-8s %-8s %s\n", fp(out, " %c %-20s %-15s %-15s %-4u %-8s %-8s %s\n",
@ -2349,13 +2350,13 @@ static void rfapiRibShowRibSl(void *stream, struct prefix *pfx,
const char *vty_newline; const char *vty_newline;
int nhs_displayed = 0; int nhs_displayed = 0;
char str_pfx[BUFSIZ]; char str_pfx[PREFIX_STRLEN];
int printedprefix = 0; int printedprefix = 0;
if (rfapiStream2Vty(stream, &fp, &vty, &out, &vty_newline) == 0) if (rfapiStream2Vty(stream, &fp, &vty, &out, &vty_newline) == 0)
return; return;
prefix2str(pfx, str_pfx, BUFSIZ); prefix2str(pfx, str_pfx, sizeof(str_pfx));
nhs_displayed += nhs_displayed +=
print_rib_sl(fp, vty, out, sl, 0, str_pfx, &printedprefix); print_rib_sl(fp, vty, out, sl, 0, str_pfx, &printedprefix);
@ -2415,7 +2416,7 @@ void rfapiRibShowResponses(void *stream, struct prefix *pfx_match,
rn = route_next(rn)) { rn = route_next(rn)) {
struct skiplist *sl; struct skiplist *sl;
char str_pfx[BUFSIZ]; char str_pfx[PREFIX_STRLEN];
int printedprefix = 0; int printedprefix = 0;
if (!show_removed) if (!show_removed)
@ -2469,7 +2470,7 @@ void rfapiRibShowResponses(void *stream, struct prefix *pfx_match,
str_un, str_un,
BUFSIZ)); BUFSIZ));
} }
prefix2str(&rn->p, str_pfx, BUFSIZ); prefix2str(&rn->p, str_pfx, sizeof(str_pfx));
// fp(out, " %s\n", buf); /* prefix */ // fp(out, " %s\n", buf); /* prefix */
routes_displayed++; routes_displayed++;

View File

@ -1527,11 +1527,9 @@ void rfapiPrintRfapiIpPrefix(void *stream, struct rfapi_ip_prefix *p)
void rfapiPrintRd(struct vty *vty, struct prefix_rd *prd) void rfapiPrintRd(struct vty *vty, struct prefix_rd *prd)
{ {
char buf[BUFSIZ]; char buf[RD_ADDRSTRLEN];
buf[0] = 0;
prefix_rd2str(prd, buf, BUFSIZ); prefix_rd2str(prd, buf, BUFSIZ);
buf[BUFSIZ - 1] = 0;
vty_out(vty, "%s", buf); vty_out(vty, "%s", buf);
} }
@ -1599,7 +1597,7 @@ void rfapiPrintDescriptor(struct vty *vty, struct rfapi_descriptor *rfd)
int rc; int rc;
afi_t afi; afi_t afi;
struct rfapi_adb *adb; struct rfapi_adb *adb;
char buf[BUFSIZ]; char buf[PREFIX_STRLEN];
vty_out(vty, "%-10p ", rfd); vty_out(vty, "%-10p ", rfd);
rfapiPrintRfapiIpAddr(vty, &rfd->un_addr); rfapiPrintRfapiIpAddr(vty, &rfd->un_addr);
@ -1651,8 +1649,7 @@ void rfapiPrintDescriptor(struct vty *vty, struct rfapi_descriptor *rfd)
if (family != adb->u.s.prefix_ip.family) if (family != adb->u.s.prefix_ip.family)
continue; continue;
prefix2str(&adb->u.s.prefix_ip, buf, BUFSIZ); prefix2str(&adb->u.s.prefix_ip, buf, sizeof(buf));
buf[BUFSIZ - 1] = 0; /* guarantee NUL-terminated */
vty_out(vty, " Adv Pfx: %s%s", buf, HVTYNL); vty_out(vty, " Adv Pfx: %s%s", buf, HVTYNL);
rfapiPrintAdvertisedInfo(vty, rfd, SAFI_MPLS_VPN, rfapiPrintAdvertisedInfo(vty, rfd, SAFI_MPLS_VPN,
@ -1664,8 +1661,7 @@ void rfapiPrintDescriptor(struct vty *vty, struct rfapi_descriptor *rfd)
rc == 0; rc = skiplist_next(rfd->advertised.ip0_by_ether, NULL, rc == 0; rc = skiplist_next(rfd->advertised.ip0_by_ether, NULL,
(void **)&adb, &cursor)) { (void **)&adb, &cursor)) {
prefix2str(&adb->u.s.prefix_eth, buf, BUFSIZ); prefix2str(&adb->u.s.prefix_eth, buf, sizeof(buf));
buf[BUFSIZ - 1] = 0; /* guarantee NUL-terminated */
vty_out(vty, " Adv Pfx: %s%s", buf, HVTYNL); vty_out(vty, " Adv Pfx: %s%s", buf, HVTYNL);

View File

@ -437,14 +437,11 @@ static void vnc_direct_bgp_vpn_enable_ce(struct bgp *bgp, afi_t afi)
continue; continue;
{ {
char prefixstr[BUFSIZ]; char prefixstr[PREFIX_STRLEN];
prefixstr[0] = 0; prefix2str(&rn->p, prefixstr, sizeof(prefixstr));
inet_ntop(rn->p.family, &rn->p.u.prefix, prefixstr, vnc_zlog_debug_verbose("%s: checking prefix %s",
BUFSIZ); __func__, prefixstr);
vnc_zlog_debug_verbose("%s: checking prefix %s/%d",
__func__, prefixstr,
rn->p.prefixlen);
} }
for (ri = rn->info; ri; ri = ri->next) { for (ri = rn->info; ri; ri = ri->next) {
@ -1856,14 +1853,13 @@ void vnc_direct_bgp_rh_vpn_enable(struct bgp *bgp, afi_t afi)
continue; continue;
{ {
char prefixstr[BUFSIZ]; char prefixstr[PREFIX_STRLEN];
prefixstr[0] = 0; prefix2str(&rn->p, prefixstr,
inet_ntop(rn->p.family, &rn->p.u.prefix, sizeof(prefixstr));
prefixstr, BUFSIZ);
vnc_zlog_debug_verbose( vnc_zlog_debug_verbose(
"%s: checking prefix %s/%d", __func__, "%s: checking prefix %s", __func__,
prefixstr, rn->p.prefixlen); prefixstr);
} }
/* /*

View File

@ -205,15 +205,15 @@ static void print_rhn_list(const char *tag1, const char *tag2)
/* XXX uses secret knowledge of skiplist structure */ /* XXX uses secret knowledge of skiplist structure */
for (p = sl->header->forward[0]; p; p = p->forward[0]) { for (p = sl->header->forward[0]; p; p = p->forward[0]) {
char kbuf[BUFSIZ]; char kbuf[PREFIX_STRLEN];
char hbuf[BUFSIZ]; char hbuf[PREFIX_STRLEN];
char ubuf[BUFSIZ]; char ubuf[PREFIX_STRLEN];
pb = p->value; pb = p->value;
prefix2str(p->key, kbuf, BUFSIZ); prefix2str(p->key, kbuf, sizeof(kbuf));
prefix2str(&pb->hpfx, hbuf, BUFSIZ); prefix2str(&pb->hpfx, hbuf, sizeof(hbuf));
prefix2str(&pb->upfx, ubuf, BUFSIZ); prefix2str(&pb->upfx, ubuf, sizeof(ubuf));
vnc_zlog_debug_verbose( vnc_zlog_debug_verbose(
"RHN Entry %d (q=%p): kpfx=%s, upfx=%s, hpfx=%s, ubi=%p", "RHN Entry %d (q=%p): kpfx=%s, upfx=%s, hpfx=%s, ubi=%p",
@ -259,14 +259,11 @@ static void vnc_rhnck(char *tag)
* pfx */ * pfx */
assert(!vnc_prefix_cmp(&pb->hpfx, pkey)); assert(!vnc_prefix_cmp(&pb->hpfx, pkey));
if (vnc_prefix_cmp(&pb->hpfx, &pfx_orig_nexthop)) { if (vnc_prefix_cmp(&pb->hpfx, &pfx_orig_nexthop)) {
char str_onh[BUFSIZ]; char str_onh[PREFIX_STRLEN];
char str_nve_pfx[BUFSIZ]; char str_nve_pfx[PREFIX_STRLEN];
prefix2str(&pfx_orig_nexthop, str_onh, BUFSIZ); prefix2str(&pfx_orig_nexthop, str_onh, sizeof(str_onh));
str_onh[BUFSIZ - 1] = 0; prefix2str(&pb->hpfx, str_nve_pfx, sizeof(str_nve_pfx));
prefix2str(&pb->hpfx, str_nve_pfx, BUFSIZ);
str_nve_pfx[BUFSIZ - 1] = 0;
vnc_zlog_debug_verbose( vnc_zlog_debug_verbose(
"%s: %s: FATAL: resolve_nve_nexthop list item bi nexthop %s != nve pfx %s", "%s: %s: FATAL: resolve_nve_nexthop list item bi nexthop %s != nve pfx %s",
@ -529,10 +526,9 @@ static void vnc_import_bgp_add_route_mode_resolve_nve_one_rd(
return; return;
{ {
char str_nh[BUFSIZ]; char str_nh[PREFIX_STRLEN];
prefix2str(ubi_nexthop, str_nh, BUFSIZ); prefix2str(ubi_nexthop, str_nh, sizeof(str_nh));
str_nh[BUFSIZ - 1] = 0;
vnc_zlog_debug_verbose("%s: ubi_nexthop=%s", __func__, str_nh); vnc_zlog_debug_verbose("%s: ubi_nexthop=%s", __func__, str_nh);
} }
@ -574,18 +570,16 @@ static void vnc_import_bgp_add_route_mode_resolve_nve(
/*debugging */ /*debugging */
if (VNC_DEBUG(VERBOSE)) { if (VNC_DEBUG(VERBOSE)) {
char str_pfx[BUFSIZ]; char str_pfx[PREFIX_STRLEN];
char str_nh[BUFSIZ]; char str_nh[PREFIX_STRLEN];
struct prefix nh; struct prefix nh;
prefix2str(prefix, str_pfx, BUFSIZ); prefix2str(prefix, str_pfx, sizeof(str_pfx));
str_pfx[BUFSIZ - 1] = 0;
nh.prefixlen = 0; nh.prefixlen = 0;
rfapiUnicastNexthop2Prefix(afi, info->attr, &nh); rfapiUnicastNexthop2Prefix(afi, info->attr, &nh);
if (nh.prefixlen) { if (nh.prefixlen) {
prefix2str(&nh, str_nh, BUFSIZ); prefix2str(&nh, str_nh, sizeof(str_nh));
str_nh[BUFSIZ - 1] = 0;
} else { } else {
str_nh[0] = '?'; str_nh[0] = '?';
str_nh[1] = 0; str_nh[1] = 0;
@ -718,11 +712,9 @@ static void vnc_import_bgp_add_route_mode_plain(struct bgp *bgp,
uint32_t *med = NULL; uint32_t *med = NULL;
{ {
char buf[BUFSIZ]; char buf[PREFIX_STRLEN];
buf[0] = 0; prefix2str(prefix, buf, sizeof(buf));
prefix2str(prefix, buf, BUFSIZ);
buf[BUFSIZ - 1] = 0;
vnc_zlog_debug_verbose("%s(prefix=%s) entry", __func__, buf); vnc_zlog_debug_verbose("%s(prefix=%s) entry", __func__, buf);
} }
@ -789,11 +781,9 @@ static void vnc_import_bgp_add_route_mode_plain(struct bgp *bgp,
} }
if (VNC_DEBUG(IMPORT_BGP_ADD_ROUTE)) { if (VNC_DEBUG(IMPORT_BGP_ADD_ROUTE)) {
char buf[BUFSIZ]; char buf[PREFIX_STRLEN];
buf[0] = 0; prefix2str(vn_pfx, buf, sizeof(buf));
prefix2str(vn_pfx, buf, BUFSIZ);
buf[BUFSIZ - 1] = 0;
vnc_zlog_debug_any("%s vn_pfx=%s", __func__, buf); vnc_zlog_debug_any("%s vn_pfx=%s", __func__, buf);
} }
@ -867,11 +857,9 @@ static void vnc_import_bgp_add_route_mode_plain(struct bgp *bgp,
} }
if (VNC_DEBUG(IMPORT_BGP_ADD_ROUTE)) { if (VNC_DEBUG(IMPORT_BGP_ADD_ROUTE)) {
char buf[BUFSIZ]; char buf[PREFIX_STRLEN];
buf[0] = 0; rfapiRfapiIpAddr2Str(&vnaddr, buf, sizeof(buf));
rfapiRfapiIpAddr2Str(&vnaddr, buf, BUFSIZ);
buf[BUFSIZ - 1] = 0;
vnc_zlog_debug_any("%s: setting vnaddr to %s", __func__, buf); vnc_zlog_debug_any("%s: setting vnaddr to %s", __func__, buf);
} }
@ -910,11 +898,9 @@ vnc_import_bgp_add_route_mode_nvegroup(struct bgp *bgp, struct prefix *prefix,
uint32_t local_pref; uint32_t local_pref;
{ {
char buf[BUFSIZ]; char buf[PREFIX_STRLEN];
buf[0] = 0; prefix2str(prefix, buf, sizeof(buf));
prefix2str(prefix, buf, BUFSIZ);
buf[BUFSIZ - 1] = 0;
vnc_zlog_debug_verbose("%s(prefix=%s) entry", __func__, buf); vnc_zlog_debug_verbose("%s(prefix=%s) entry", __func__, buf);
} }
@ -997,11 +983,9 @@ vnc_import_bgp_add_route_mode_nvegroup(struct bgp *bgp, struct prefix *prefix,
} }
if (VNC_DEBUG(IMPORT_BGP_ADD_ROUTE)) { if (VNC_DEBUG(IMPORT_BGP_ADD_ROUTE)) {
char buf[BUFSIZ]; char buf[PREFIX_STRLEN];
buf[0] = 0; prefix2str(vn_pfx, buf, sizeof(buf));
prefix2str(vn_pfx, buf, BUFSIZ);
buf[BUFSIZ - 1] = 0;
vnc_zlog_debug_any("%s vn_pfx=%s", __func__, buf); vnc_zlog_debug_any("%s vn_pfx=%s", __func__, buf);
} }
@ -1298,11 +1282,9 @@ static void vnc_import_bgp_del_route_mode_resolve_nve_one_rd(
return; return;
{ {
char str_nh[BUFSIZ]; char str_nh[PREFIX_STRLEN];
prefix2str(ubi_nexthop, str_nh, BUFSIZ);
str_nh[BUFSIZ - 1] = 0;
prefix2str(ubi_nexthop, str_nh, sizeof(str_nh));
vnc_zlog_debug_verbose("%s: ubi_nexthop=%s", __func__, str_nh); vnc_zlog_debug_verbose("%s: ubi_nexthop=%s", __func__, str_nh);
} }
@ -1478,11 +1460,11 @@ void vnc_import_bgp_add_vnc_host_route_mode_resolve_nve(
sizeof(struct prefix)); /* keep valgrind happy */ sizeof(struct prefix)); /* keep valgrind happy */
if (VNC_DEBUG(IMPORT_BGP_ADD_ROUTE)) { if (VNC_DEBUG(IMPORT_BGP_ADD_ROUTE)) {
char hbuf[BUFSIZ]; char hbuf[PREFIX_STRLEN];
char ubuf[BUFSIZ]; char ubuf[PREFIX_STRLEN];
prefix2str(&pb->hpfx, hbuf, BUFSIZ); prefix2str(&pb->hpfx, hbuf, sizeof(hbuf));
prefix2str(&pb->upfx, ubuf, BUFSIZ); prefix2str(&pb->upfx, ubuf, sizeof(ubuf));
vnc_zlog_debug_any( vnc_zlog_debug_any(
"%s: examining RHN Entry (q=%p): upfx=%s, hpfx=%s, ubi=%p", "%s: examining RHN Entry (q=%p): upfx=%s, hpfx=%s, ubi=%p",
@ -1510,14 +1492,12 @@ void vnc_import_bgp_add_vnc_host_route_mode_resolve_nve(
* Sanity check * Sanity check
*/ */
if (vnc_prefix_cmp(&pfx_unicast_nexthop, prefix)) { if (vnc_prefix_cmp(&pfx_unicast_nexthop, prefix)) {
char str_unh[BUFSIZ]; char str_unh[PREFIX_STRLEN];
char str_nve_pfx[BUFSIZ]; char str_nve_pfx[PREFIX_STRLEN];
prefix2str(&pfx_unicast_nexthop, str_unh, BUFSIZ); prefix2str(&pfx_unicast_nexthop, str_unh,
str_unh[BUFSIZ - 1] = 0; sizeof(str_unh));
prefix2str(prefix, str_nve_pfx, sizeof(str_nve_pfx));
prefix2str(prefix, str_nve_pfx, BUFSIZ);
str_nve_pfx[BUFSIZ - 1] = 0;
vnc_zlog_debug_verbose( vnc_zlog_debug_verbose(
"%s: FATAL: resolve_nve_nexthop list item bi nexthop %s != nve pfx %s", "%s: FATAL: resolve_nve_nexthop list item bi nexthop %s != nve pfx %s",
@ -1536,9 +1516,9 @@ void vnc_import_bgp_add_vnc_host_route_mode_resolve_nve(
#if DEBUG_RHN_LIST #if DEBUG_RHN_LIST
/* debug */ /* debug */
{ {
char pbuf[BUFSIZ]; char pbuf[PREFIX_STRLEN];
prefix2str(prefix, pbuf, BUFSIZ); prefix2str(prefix, pbuf, sizeof(pbuf));
vnc_zlog_debug_verbose( vnc_zlog_debug_verbose(
"%s: advancing past RHN Entry (q=%p): with prefix %s", "%s: advancing past RHN Entry (q=%p): with prefix %s",
@ -1566,10 +1546,9 @@ void vnc_import_bgp_del_vnc_host_route_mode_resolve_nve(
int rc; int rc;
{ {
char str_pfx[BUFSIZ]; char str_pfx[PREFIX_STRLEN];
prefix2str(prefix, str_pfx, BUFSIZ); prefix2str(prefix, str_pfx, sizeof(str_pfx));
str_pfx[BUFSIZ - 1] = 0;
vnc_zlog_debug_verbose("%s(bgp=%p, nve prefix=%s)", __func__, vnc_zlog_debug_verbose("%s(bgp=%p, nve prefix=%s)", __func__,
bgp, str_pfx); bgp, str_pfx);
@ -1637,14 +1616,12 @@ void vnc_import_bgp_del_vnc_host_route_mode_resolve_nve(
* Sanity check * Sanity check
*/ */
if (vnc_prefix_cmp(&pfx_unicast_nexthop, prefix)) { if (vnc_prefix_cmp(&pfx_unicast_nexthop, prefix)) {
char str_unh[BUFSIZ]; char str_unh[PREFIX_STRLEN];
char str_nve_pfx[BUFSIZ]; char str_nve_pfx[PREFIX_STRLEN];
prefix2str(&pfx_unicast_nexthop, str_unh, BUFSIZ); prefix2str(&pfx_unicast_nexthop, str_unh,
str_unh[BUFSIZ - 1] = 0; sizeof(str_unh));
prefix2str(prefix, str_nve_pfx, sizeof(str_nve_pfx));
prefix2str(prefix, str_nve_pfx, BUFSIZ);
str_nve_pfx[BUFSIZ - 1] = 0;
vnc_zlog_debug_verbose( vnc_zlog_debug_verbose(
"%s: FATAL: resolve_nve_nexthop list item bi nexthop %s != nve pfx %s", "%s: FATAL: resolve_nve_nexthop list item bi nexthop %s != nve pfx %s",
@ -2093,11 +2070,9 @@ void vnc_import_bgp_exterior_add_route_interior(
/*debugging */ /*debugging */
{ {
char str_pfx[BUFSIZ]; char str_pfx[PREFIX_STRLEN];
prefix2str(&rn_interior->p, str_pfx, BUFSIZ);
str_pfx[BUFSIZ - 1] = 0;
prefix2str(&rn_interior->p, str_pfx, sizeof(str_pfx));
vnc_zlog_debug_verbose("%s: interior prefix=%s, bi type=%d", vnc_zlog_debug_verbose("%s: interior prefix=%s, bi type=%d",
__func__, str_pfx, bi_interior->type); __func__, str_pfx, bi_interior->type);
} }
@ -2338,11 +2313,10 @@ void vnc_import_bgp_exterior_add_route_interior(
(void **)&pfx_exterior, &cursor)) { (void **)&pfx_exterior, &cursor)) {
struct prefix pfx_nexthop; struct prefix pfx_nexthop;
char buf[BUFSIZ]; char buf[PREFIX_STRLEN];
afi_t afi_exterior = family2afi(pfx_exterior->family); afi_t afi_exterior = family2afi(pfx_exterior->family);
prefix2str(pfx_exterior, buf, sizeof(buf)); prefix2str(pfx_exterior, buf, sizeof(buf));
buf[sizeof(buf) - 1] = 0;
vnc_zlog_debug_verbose( vnc_zlog_debug_verbose(
"%s: checking exterior orphan at prefix %s", __func__, "%s: checking exterior orphan at prefix %s", __func__,
buf); buf);
@ -2481,10 +2455,9 @@ void vnc_import_bgp_exterior_del_route_interior(
/*debugging */ /*debugging */
{ {
char str_pfx[BUFSIZ]; char str_pfx[PREFIX_STRLEN];
prefix2str(&rn_interior->p, str_pfx, BUFSIZ); prefix2str(&rn_interior->p, str_pfx, sizeof(str_pfx));
str_pfx[BUFSIZ - 1] = 0;
vnc_zlog_debug_verbose("%s: interior prefix=%s, bi type=%d", vnc_zlog_debug_verbose("%s: interior prefix=%s, bi type=%d",
__func__, str_pfx, bi_interior->type); __func__, str_pfx, bi_interior->type);
@ -2640,12 +2613,12 @@ void vnc_import_bgp_add_route(struct bgp *bgp, struct prefix *prefix,
if (VNC_DEBUG(VERBOSE)) { if (VNC_DEBUG(VERBOSE)) {
struct prefix pfx_nexthop; struct prefix pfx_nexthop;
char buf[BUFSIZ]; char buf[PREFIX_STRLEN];
char buf_nh[BUFSIZ]; char buf_nh[PREFIX_STRLEN];
prefix2str(prefix, buf, BUFSIZ); prefix2str(prefix, buf, sizeof(buf));
rfapiUnicastNexthop2Prefix(afi, info->attr, &pfx_nexthop); rfapiUnicastNexthop2Prefix(afi, info->attr, &pfx_nexthop);
prefix2str(&pfx_nexthop, buf_nh, BUFSIZ); prefix2str(&pfx_nexthop, buf_nh, sizeof(buf_nh));
vnc_zlog_debug_verbose("%s: pfx %s, nh %s", __func__, buf, vnc_zlog_debug_verbose("%s: pfx %s, nh %s", __func__, buf,
buf_nh); buf_nh);
@ -2710,12 +2683,12 @@ void vnc_import_bgp_del_route(struct bgp *bgp, struct prefix *prefix,
{ {
struct prefix pfx_nexthop; struct prefix pfx_nexthop;
char buf[BUFSIZ]; char buf[PREFIX_STRLEN];
char buf_nh[BUFSIZ]; char buf_nh[PREFIX_STRLEN];
prefix2str(prefix, buf, BUFSIZ); prefix2str(prefix, buf, sizeof(buf));
rfapiUnicastNexthop2Prefix(afi, info->attr, &pfx_nexthop); rfapiUnicastNexthop2Prefix(afi, info->attr, &pfx_nexthop);
prefix2str(&pfx_nexthop, buf_nh, BUFSIZ); prefix2str(&pfx_nexthop, buf_nh, sizeof(buf_nh));
vnc_zlog_debug_verbose("%s: pfx %s, nh %s", __func__, buf, vnc_zlog_debug_verbose("%s: pfx %s, nh %s", __func__, buf,
buf_nh); buf_nh);

View File

@ -170,9 +170,11 @@ void eigrp_reply_receive(struct eigrp *eigrp, struct ip *iph,
*/ */
if (!dest) { if (!dest) {
char buf[PREFIX_STRLEN]; char buf[PREFIX_STRLEN];
zlog_err("%s: Received prefix %s which we do not know about", zlog_err("%s: Received prefix %s which we do not know about",
__PRETTY_FUNCTION__, __PRETTY_FUNCTION__,
prefix2str(&dest_addr, buf, strlen(buf))); prefix2str(&dest_addr, buf, sizeof(buf)));
eigrp_IPv4_InternalTLV_free(tlv);
continue; continue;
} }