From 36228974c2af1288b39bdffdd1890c5e0caf22a4 Mon Sep 17 00:00:00 2001 From: paco Date: Tue, 19 Jun 2018 18:22:01 +0200 Subject: [PATCH] isisd, zebra: FIXME fixes Signed-off-by: F. Aragon --- isisd/isis_lsp.c | 17 ++++++++--------- zebra/zebra_rib.c | 10 ++++------ 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/isisd/isis_lsp.c b/isisd/isis_lsp.c index 95fa38223e..bba86d4c1f 100644 --- a/isisd/isis_lsp.c +++ b/isisd/isis_lsp.c @@ -55,9 +55,6 @@ #include "isisd/isis_mt.h" #include "isisd/isis_tlvs.h" -/* staticly assigned vars for printing purposes */ -char lsp_bits_string[200]; /* FIXME: enough ? */ - static int lsp_l1_refresh(struct thread *thread); static int lsp_l2_refresh(struct thread *thread); static int lsp_l1_refresh_pseudo(struct thread *thread); @@ -608,13 +605,16 @@ static void lspid_print(uint8_t *lsp_id, uint8_t *trg, char dynhost, char frag) } /* Convert the lsp attribute bits to attribute string */ -static const char *lsp_bits2string(uint8_t lsp_bits) +static const char *lsp_bits2string(uint8_t lsp_bits, char *buf, size_t buf_size) { - char *pos = lsp_bits_string; + char *pos = buf; if (!lsp_bits) return " none"; + if (buf_size < 2 * 3) + return " error"; + /* we only focus on the default metric */ pos += sprintf(pos, "%d/", ISIS_MASK_LSP_ATT_DEFAULT_BIT(lsp_bits) ? 1 : 0); @@ -624,9 +624,7 @@ static const char *lsp_bits2string(uint8_t lsp_bits) pos += sprintf(pos, "%d", ISIS_MASK_LSP_OL_BIT(lsp_bits) ? 1 : 0); - *(pos) = '\0'; - - return lsp_bits_string; + return buf; } /* this function prints the lsp on show isis database */ @@ -634,6 +632,7 @@ void lsp_print(struct isis_lsp *lsp, struct vty *vty, char dynhost) { uint8_t LSPid[255]; char age_out[8]; + char b[200]; lspid_print(lsp->hdr.lsp_id, LSPid, dynhost, 1); vty_out(vty, "%-21s%c ", LSPid, lsp->own_lsp ? '*' : ' '); @@ -646,7 +645,7 @@ void lsp_print(struct isis_lsp *lsp, struct vty *vty, char dynhost) vty_out(vty, "%7s ", age_out); } else vty_out(vty, " %5" PRIu16 " ", lsp->hdr.rem_lifetime); - vty_out(vty, "%s\n", lsp_bits2string(lsp->hdr.lsp_bits)); + vty_out(vty, "%s\n", lsp_bits2string(lsp->hdr.lsp_bits, b, sizeof(b))); } void lsp_print_detail(struct isis_lsp *lsp, struct vty *vty, char dynhost) diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index 879e7e8317..bd00823ed8 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -2542,12 +2542,10 @@ void rib_delete(afi_t afi, safi_t safi, vrf_id_t vrf_id, int type, rn, vrf_id, "via %s ifindex %d type %d " "doesn't exist in rib", - inet_ntop( - family2afi(afi), - &nh->gate, buf2, - INET_ADDRSTRLEN), /* FIXME - */ - nh->ifindex, type); + inet_ntop(afi2family(afi), + &nh->gate, buf2, + sizeof(buf2)), + nh->ifindex, type); else rnode_debug( rn, vrf_id, -- 2.39.5