]> git.puffer.fish Git - matthieu/frr.git/commitdiff
isisd, zebra: FIXME fixes
authorpaco <paco@voltanet.io>
Tue, 19 Jun 2018 16:22:01 +0000 (18:22 +0200)
committerpaco <paco@voltanet.io>
Tue, 19 Jun 2018 17:22:13 +0000 (19:22 +0200)
Signed-off-by: F. Aragon <paco@voltanet.io>
isisd/isis_lsp.c
zebra/zebra_rib.c

index 95fa38223e41c7f56665bfcc269292b59208ea87..bba86d4c1ff07b4375860fe3943d6927835e6a97 100644 (file)
@@ -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)
index 879e7e831769b877523da38a3563a9b816eaed08..bd00823ed82d1c63d0228e10a02107141dd1dc94 100644 (file)
@@ -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,