diff options
author | Donald Sharp <sharpd@nvidia.com> | 2020-10-26 14:29:52 +0100 |
---|---|---|
committer | Donald Sharp <sharpd@nvidia.com> | 2020-10-26 14:38:33 +0100 |
commit | b467b4b462dad376cf68bda8c1fe7f26b44a1dc0 (patch) | |
tree | 3d4f77f7ed3281b073e795ad227ee27c00539349 /zebra/zebra_mpls.c | |
parent | zebra: Replace some prefix2str with %pFX (diff) | |
download | frr-b467b4b462dad376cf68bda8c1fe7f26b44a1dc0.tar.xz frr-b467b4b462dad376cf68bda8c1fe7f26b44a1dc0.zip |
zebra: Fix prefix2str buf and some invalid data output in zebra_mpls.c
There are several places where prefix2str was used to convert
a prefix but they were debug guarded and the buffer was
used for flog_err/warn. This would lead to corrupt data
being output in the failure cases if debugs were not turned
on.
Modify the code in zebra_mpls.c to not use prefix2str
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Diffstat (limited to 'zebra/zebra_mpls.c')
-rw-r--r-- | zebra/zebra_mpls.c | 43 |
1 files changed, 12 insertions, 31 deletions
diff --git a/zebra/zebra_mpls.c b/zebra/zebra_mpls.c index 66aea8936..dc4969501 100644 --- a/zebra/zebra_mpls.c +++ b/zebra/zebra_mpls.c @@ -331,7 +331,6 @@ static void fec_evaluate(struct zebra_vrf *zvrf) zebra_fec_t *fec; uint32_t old_label, new_label; int af; - char buf[BUFSIZ]; for (af = AFI_IP; af < AFI_MAX; af++) { if (zvrf->fec_table[af] == NULL) @@ -348,9 +347,6 @@ static void fec_evaluate(struct zebra_vrf *zvrf) || fec->label_index == MPLS_INVALID_LABEL_INDEX) continue; - if (IS_ZEBRA_DEBUG_MPLS) - prefix2str(&rn->p, buf, BUFSIZ); - /* Save old label, determine new label. */ old_label = fec->label; new_label = @@ -364,8 +360,8 @@ static void fec_evaluate(struct zebra_vrf *zvrf) if (IS_ZEBRA_DEBUG_MPLS) zlog_debug( - "Update fec %s new label %u upon label block", - buf, new_label); + "Update fec %pRN new label %u upon label block", + rn, new_label); fec->label = new_label; fec_update_clients(fec); @@ -494,8 +490,7 @@ static void fec_print(zebra_fec_t *fec, struct vty *vty) char buf[BUFSIZ]; rn = fec->rn; - prefix2str(&rn->p, buf, BUFSIZ); - vty_out(vty, "%s\n", buf); + vty_out(vty, "%pRN\n", rn); vty_out(vty, " Label: %s", label2str(fec->label, buf, BUFSIZ)); if (fec->label_index != MPLS_INVALID_LABEL_INDEX) vty_out(vty, ", Label Index: %u", fec->label_index); @@ -2244,7 +2239,6 @@ int zebra_mpls_fec_register(struct zebra_vrf *zvrf, struct prefix *p, { struct route_table *table; zebra_fec_t *fec; - char buf[BUFSIZ]; bool new_client; bool label_change = false; uint32_t old_label; @@ -2255,14 +2249,11 @@ int zebra_mpls_fec_register(struct zebra_vrf *zvrf, struct prefix *p, if (!table) return -1; - if (IS_ZEBRA_DEBUG_MPLS) - prefix2str(p, buf, BUFSIZ); - if (label != MPLS_INVALID_LABEL && have_label_index) { flog_err( EC_ZEBRA_FEC_LABEL_INDEX_LABEL_CONFLICT, - "Rejecting FEC register for %s with both label %u and Label Index %u specified, client %s", - buf, label, label_index, + "Rejecting FEC register for %pFX with both label %u and Label Index %u specified, client %s", + p, label, label_index, zebra_route_string(client->proto)); return -1; } @@ -2274,8 +2265,8 @@ int zebra_mpls_fec_register(struct zebra_vrf *zvrf, struct prefix *p, if (!fec) { flog_err( EC_ZEBRA_FEC_ADD_FAILED, - "Failed to add FEC %s upon register, client %s", - buf, zebra_route_string(client->proto)); + "Failed to add FEC %pFX upon register, client %s", + p, zebra_route_string(client->proto)); return -1; } @@ -2301,7 +2292,7 @@ int zebra_mpls_fec_register(struct zebra_vrf *zvrf, struct prefix *p, listnode_add(fec->client_list, client); if (IS_ZEBRA_DEBUG_MPLS) - zlog_debug("FEC %s label%s %u %s by client %s%s", buf, + zlog_debug("FEC %pFX label%s %u %s by client %s%s", p, have_label_index ? " index" : "", have_label_index ? label_index : label, new_client ? "registered" : "updated", @@ -2352,15 +2343,11 @@ int zebra_mpls_fec_unregister(struct zebra_vrf *zvrf, struct prefix *p, { struct route_table *table; zebra_fec_t *fec; - char buf[BUFSIZ]; table = zvrf->fec_table[family2afi(PREFIX_FAMILY(p))]; if (!table) return -1; - if (IS_ZEBRA_DEBUG_MPLS) - prefix2str(p, buf, BUFSIZ); - fec = fec_find(table, p); if (!fec) { flog_err(EC_ZEBRA_FEC_RM_FAILED, @@ -2372,7 +2359,7 @@ int zebra_mpls_fec_unregister(struct zebra_vrf *zvrf, struct prefix *p, listnode_delete(fec->client_list, client); if (IS_ZEBRA_DEBUG_MPLS) - zlog_debug("FEC %s unregistered by client %s", buf, + zlog_debug("FEC %pFX unregistered by client %s", p, zebra_route_string(client->proto)); /* If not a configured entry, delete the FEC if no other clients. Before @@ -2513,7 +2500,6 @@ int zebra_mpls_static_fec_add(struct zebra_vrf *zvrf, struct prefix *p, { struct route_table *table; zebra_fec_t *fec; - char buf[BUFSIZ]; mpls_label_t old_label; int ret = 0; @@ -2521,9 +2507,6 @@ int zebra_mpls_static_fec_add(struct zebra_vrf *zvrf, struct prefix *p, if (!table) return -1; - if (IS_ZEBRA_DEBUG_MPLS) - prefix2str(p, buf, BUFSIZ); - /* Update existing FEC or create a new one. */ fec = fec_find(table, p); if (!fec) { @@ -2536,7 +2519,7 @@ int zebra_mpls_static_fec_add(struct zebra_vrf *zvrf, struct prefix *p, } if (IS_ZEBRA_DEBUG_MPLS) - zlog_debug("Add fec %s label %u", buf, in_label); + zlog_debug("Add fec %pFX label %u", p, in_label); } else { fec->flags |= FEC_FLAG_CONFIGURED; if (fec->label == in_label) @@ -2546,7 +2529,7 @@ int zebra_mpls_static_fec_add(struct zebra_vrf *zvrf, struct prefix *p, /* Label change, update clients. */ old_label = fec->label; if (IS_ZEBRA_DEBUG_MPLS) - zlog_debug("Update fec %s new label %u", buf, in_label); + zlog_debug("Update fec %pFX new label %u", p, in_label); fec->label = in_label; fec_update_clients(fec); @@ -2569,7 +2552,6 @@ int zebra_mpls_static_fec_del(struct zebra_vrf *zvrf, struct prefix *p) struct route_table *table; zebra_fec_t *fec; mpls_label_t old_label; - char buf[BUFSIZ]; table = zvrf->fec_table[family2afi(PREFIX_FAMILY(p))]; if (!table) @@ -2577,9 +2559,8 @@ int zebra_mpls_static_fec_del(struct zebra_vrf *zvrf, struct prefix *p) fec = fec_find(table, p); if (!fec) { - prefix2str(p, buf, BUFSIZ); flog_err(EC_ZEBRA_FEC_RM_FAILED, - "Failed to find FEC %s upon delete", buf); + "Failed to find FEC %pFX upon delete", p); return -1; } |