mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-07 19:10:35 +00:00
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>
This commit is contained in:
parent
2919eea86a
commit
b467b4b462
@ -331,7 +331,6 @@ static void fec_evaluate(struct zebra_vrf *zvrf)
|
|||||||
zebra_fec_t *fec;
|
zebra_fec_t *fec;
|
||||||
uint32_t old_label, new_label;
|
uint32_t old_label, new_label;
|
||||||
int af;
|
int af;
|
||||||
char buf[BUFSIZ];
|
|
||||||
|
|
||||||
for (af = AFI_IP; af < AFI_MAX; af++) {
|
for (af = AFI_IP; af < AFI_MAX; af++) {
|
||||||
if (zvrf->fec_table[af] == NULL)
|
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)
|
|| fec->label_index == MPLS_INVALID_LABEL_INDEX)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (IS_ZEBRA_DEBUG_MPLS)
|
|
||||||
prefix2str(&rn->p, buf, BUFSIZ);
|
|
||||||
|
|
||||||
/* Save old label, determine new label. */
|
/* Save old label, determine new label. */
|
||||||
old_label = fec->label;
|
old_label = fec->label;
|
||||||
new_label =
|
new_label =
|
||||||
@ -364,8 +360,8 @@ static void fec_evaluate(struct zebra_vrf *zvrf)
|
|||||||
|
|
||||||
if (IS_ZEBRA_DEBUG_MPLS)
|
if (IS_ZEBRA_DEBUG_MPLS)
|
||||||
zlog_debug(
|
zlog_debug(
|
||||||
"Update fec %s new label %u upon label block",
|
"Update fec %pRN new label %u upon label block",
|
||||||
buf, new_label);
|
rn, new_label);
|
||||||
|
|
||||||
fec->label = new_label;
|
fec->label = new_label;
|
||||||
fec_update_clients(fec);
|
fec_update_clients(fec);
|
||||||
@ -494,8 +490,7 @@ static void fec_print(zebra_fec_t *fec, struct vty *vty)
|
|||||||
char buf[BUFSIZ];
|
char buf[BUFSIZ];
|
||||||
|
|
||||||
rn = fec->rn;
|
rn = fec->rn;
|
||||||
prefix2str(&rn->p, buf, BUFSIZ);
|
vty_out(vty, "%pRN\n", rn);
|
||||||
vty_out(vty, "%s\n", buf);
|
|
||||||
vty_out(vty, " Label: %s", label2str(fec->label, buf, BUFSIZ));
|
vty_out(vty, " Label: %s", label2str(fec->label, buf, BUFSIZ));
|
||||||
if (fec->label_index != MPLS_INVALID_LABEL_INDEX)
|
if (fec->label_index != MPLS_INVALID_LABEL_INDEX)
|
||||||
vty_out(vty, ", Label Index: %u", fec->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;
|
struct route_table *table;
|
||||||
zebra_fec_t *fec;
|
zebra_fec_t *fec;
|
||||||
char buf[BUFSIZ];
|
|
||||||
bool new_client;
|
bool new_client;
|
||||||
bool label_change = false;
|
bool label_change = false;
|
||||||
uint32_t old_label;
|
uint32_t old_label;
|
||||||
@ -2255,14 +2249,11 @@ int zebra_mpls_fec_register(struct zebra_vrf *zvrf, struct prefix *p,
|
|||||||
if (!table)
|
if (!table)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (IS_ZEBRA_DEBUG_MPLS)
|
|
||||||
prefix2str(p, buf, BUFSIZ);
|
|
||||||
|
|
||||||
if (label != MPLS_INVALID_LABEL && have_label_index) {
|
if (label != MPLS_INVALID_LABEL && have_label_index) {
|
||||||
flog_err(
|
flog_err(
|
||||||
EC_ZEBRA_FEC_LABEL_INDEX_LABEL_CONFLICT,
|
EC_ZEBRA_FEC_LABEL_INDEX_LABEL_CONFLICT,
|
||||||
"Rejecting FEC register for %s with both label %u and Label Index %u specified, client %s",
|
"Rejecting FEC register for %pFX with both label %u and Label Index %u specified, client %s",
|
||||||
buf, label, label_index,
|
p, label, label_index,
|
||||||
zebra_route_string(client->proto));
|
zebra_route_string(client->proto));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -2274,8 +2265,8 @@ int zebra_mpls_fec_register(struct zebra_vrf *zvrf, struct prefix *p,
|
|||||||
if (!fec) {
|
if (!fec) {
|
||||||
flog_err(
|
flog_err(
|
||||||
EC_ZEBRA_FEC_ADD_FAILED,
|
EC_ZEBRA_FEC_ADD_FAILED,
|
||||||
"Failed to add FEC %s upon register, client %s",
|
"Failed to add FEC %pFX upon register, client %s",
|
||||||
buf, zebra_route_string(client->proto));
|
p, zebra_route_string(client->proto));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2301,7 +2292,7 @@ int zebra_mpls_fec_register(struct zebra_vrf *zvrf, struct prefix *p,
|
|||||||
listnode_add(fec->client_list, client);
|
listnode_add(fec->client_list, client);
|
||||||
|
|
||||||
if (IS_ZEBRA_DEBUG_MPLS)
|
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 ? " index" : "",
|
||||||
have_label_index ? label_index : label,
|
have_label_index ? label_index : label,
|
||||||
new_client ? "registered" : "updated",
|
new_client ? "registered" : "updated",
|
||||||
@ -2352,15 +2343,11 @@ int zebra_mpls_fec_unregister(struct zebra_vrf *zvrf, struct prefix *p,
|
|||||||
{
|
{
|
||||||
struct route_table *table;
|
struct route_table *table;
|
||||||
zebra_fec_t *fec;
|
zebra_fec_t *fec;
|
||||||
char buf[BUFSIZ];
|
|
||||||
|
|
||||||
table = zvrf->fec_table[family2afi(PREFIX_FAMILY(p))];
|
table = zvrf->fec_table[family2afi(PREFIX_FAMILY(p))];
|
||||||
if (!table)
|
if (!table)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (IS_ZEBRA_DEBUG_MPLS)
|
|
||||||
prefix2str(p, buf, BUFSIZ);
|
|
||||||
|
|
||||||
fec = fec_find(table, p);
|
fec = fec_find(table, p);
|
||||||
if (!fec) {
|
if (!fec) {
|
||||||
flog_err(EC_ZEBRA_FEC_RM_FAILED,
|
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);
|
listnode_delete(fec->client_list, client);
|
||||||
|
|
||||||
if (IS_ZEBRA_DEBUG_MPLS)
|
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));
|
zebra_route_string(client->proto));
|
||||||
|
|
||||||
/* If not a configured entry, delete the FEC if no other clients. Before
|
/* 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;
|
struct route_table *table;
|
||||||
zebra_fec_t *fec;
|
zebra_fec_t *fec;
|
||||||
char buf[BUFSIZ];
|
|
||||||
mpls_label_t old_label;
|
mpls_label_t old_label;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
@ -2521,9 +2507,6 @@ int zebra_mpls_static_fec_add(struct zebra_vrf *zvrf, struct prefix *p,
|
|||||||
if (!table)
|
if (!table)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (IS_ZEBRA_DEBUG_MPLS)
|
|
||||||
prefix2str(p, buf, BUFSIZ);
|
|
||||||
|
|
||||||
/* Update existing FEC or create a new one. */
|
/* Update existing FEC or create a new one. */
|
||||||
fec = fec_find(table, p);
|
fec = fec_find(table, p);
|
||||||
if (!fec) {
|
if (!fec) {
|
||||||
@ -2536,7 +2519,7 @@ int zebra_mpls_static_fec_add(struct zebra_vrf *zvrf, struct prefix *p,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (IS_ZEBRA_DEBUG_MPLS)
|
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 {
|
} else {
|
||||||
fec->flags |= FEC_FLAG_CONFIGURED;
|
fec->flags |= FEC_FLAG_CONFIGURED;
|
||||||
if (fec->label == in_label)
|
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. */
|
/* Label change, update clients. */
|
||||||
old_label = fec->label;
|
old_label = fec->label;
|
||||||
if (IS_ZEBRA_DEBUG_MPLS)
|
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->label = in_label;
|
||||||
fec_update_clients(fec);
|
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;
|
struct route_table *table;
|
||||||
zebra_fec_t *fec;
|
zebra_fec_t *fec;
|
||||||
mpls_label_t old_label;
|
mpls_label_t old_label;
|
||||||
char buf[BUFSIZ];
|
|
||||||
|
|
||||||
table = zvrf->fec_table[family2afi(PREFIX_FAMILY(p))];
|
table = zvrf->fec_table[family2afi(PREFIX_FAMILY(p))];
|
||||||
if (!table)
|
if (!table)
|
||||||
@ -2577,9 +2559,8 @@ int zebra_mpls_static_fec_del(struct zebra_vrf *zvrf, struct prefix *p)
|
|||||||
|
|
||||||
fec = fec_find(table, p);
|
fec = fec_find(table, p);
|
||||||
if (!fec) {
|
if (!fec) {
|
||||||
prefix2str(p, buf, BUFSIZ);
|
|
||||||
flog_err(EC_ZEBRA_FEC_RM_FAILED,
|
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;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user