]> git.proxmox.com Git - mirror_frr.git/commitdiff
Merge pull request #13345 from donaldsharp/pim_after_dark
authorDavid Lamparter <equinox@opensourcerouting.org>
Fri, 21 Apr 2023 16:22:39 +0000 (18:22 +0200)
committerGitHub <noreply@github.com>
Fri, 21 Apr 2023 16:22:39 +0000 (18:22 +0200)
bgpd/bgp_lcommunity.c
isisd/isis_affinitymap.c
isisd/isis_flex_algo.c
isisd/isis_spf.c
isisd/isisd.c
lib/elf_py.c
ripd/rip_peer.c
tests/topotests/rip_topo1/r1/rip_status.ref
tests/topotests/rip_topo1/r2/rip_status.ref
tests/topotests/rip_topo1/r3/rip_status.ref
zebra/zebra_dplane.c

index 15bf4198681813ae12708201d11daa305fe51f05..1b8c22a5038c7458cfbf44ea16053ccde5b1315c 100644 (file)
@@ -197,12 +197,13 @@ static void set_lcommunity_string(struct lcommunity *lcom, bool make_json,
        }
 
        /* 1 space + lcom->size lcom strings + null terminator */
-       size_t str_buf_sz = BUFSIZ;
+       size_t str_buf_sz = (LCOMMUNITY_STRLEN * lcom->size) + 2;
        str_buf = XCALLOC(MTYPE_LCOMMUNITY_STR, str_buf_sz);
 
+       len = 0;
        for (i = 0; i < lcom->size; i++) {
                if (i > 0)
-                       strlcat(str_buf, " ", str_buf_sz);
+                       len = strlcat(str_buf, " ", str_buf_sz);
 
                pnt = lcom->val + (i * LCOMMUNITY_SIZE);
                pnt = ptr_get_be32(pnt, &global);
@@ -215,11 +216,22 @@ static void set_lcommunity_string(struct lcommunity *lcom, bool make_json,
                snprintf(lcsb, sizeof(lcsb), "%u:%u:%u", global, local1,
                         local2);
 
+               /*
+                * Aliases can cause havoc, if the alias length is greater
+                * than the LCOMMUNITY_STRLEN for a particular item
+                * then we need to realloc the memory associated
+                * with the string so that it can fit
+                */
                const char *com2alias =
                        translate_alias ? bgp_community2alias(lcsb) : lcsb;
+               size_t individual_len = strlen(com2alias);
+               if (individual_len + len > str_buf_sz) {
+                       str_buf_sz = individual_len + len + 1;
+                       str_buf = XREALLOC(MTYPE_LCOMMUNITY_STR, str_buf,
+                                          str_buf_sz);
+               }
 
                len = strlcat(str_buf, com2alias, str_buf_sz);
-               assert((unsigned int)len < str_buf_sz);
 
                if (make_json) {
                        json_string = json_object_new_string(com2alias);
index e681e820be8723cad9964464d85d795a6931b263..41bad0a7d9343da5d278dc40d7059b3195b4237a 100644 (file)
@@ -20,6 +20,9 @@ static bool isis_affinity_map_check_use(const char *affmap_name)
        struct affinity_map *map;
        uint16_t pos;
 
+       if (!isis)
+               return false;
+
        map = affinity_map_get(affmap_name);
        pos = map->bit_position;
 
@@ -46,6 +49,9 @@ static void isis_affinity_map_update(const char *affmap_name, uint16_t old_pos,
        struct flex_algo *fa;
        bool changed;
 
+       if (!isis)
+               return;
+
        for (ALL_LIST_ELEMENTS_RO(isis->area_list, area_node, area)) {
                changed = false;
                for (ALL_LIST_ELEMENTS_RO(area->flex_algos->flex_algos, fa_node,
index 742a862fcdfe48700a7fabb5bdbc7560beee8abd..0efc519eaba6f1d5643182806a6cfb9c8dbd0047 100644 (file)
@@ -243,8 +243,6 @@ bool isis_flex_algo_constraint_drop(struct isis_spftree *spftree,
 {
        bool ret;
        struct isis_ext_subtlvs *subtlvs = reach->subtlvs;
-       uint8_t lspid_orig[ISIS_SYS_ID_LEN + 2];
-       uint8_t lspid_neigh[ISIS_SYS_ID_LEN + 2];
        struct isis_router_cap_fad *fad;
        struct isis_asla_subtlvs *asla;
        struct listnode *node;
@@ -286,15 +284,11 @@ bool isis_flex_algo_constraint_drop(struct isis_spftree *spftree,
        if (link_admin_group && link_ext_admin_group) {
                link_ext_admin_group_bitmap0 =
                        admin_group_get_offset(link_ext_admin_group, 0);
-               if (*link_admin_group != link_ext_admin_group_bitmap0) {
-                       memcpy(lspid_orig, lsp->hdr.lsp_id,
-                              ISIS_SYS_ID_LEN + 2);
-                       memcpy(lspid_neigh, reach->id, ISIS_SYS_ID_LEN + 2);
+               if (*link_admin_group != link_ext_admin_group_bitmap0)
                        zlog_warn(
-                               "ISIS-SPF: LSP from %pLS neighbor %pLS. Admin-group 0x%08x differs from ext admin-group 0x%08x.",
-                               lspid_orig, lspid_neigh, *link_admin_group,
+                               "ISIS-SPF: LSP from %pPN neighbor %pPN. Admin-group 0x%08x differs from ext admin-group 0x%08x.",
+                               lsp->hdr.lsp_id, reach->id, *link_admin_group,
                                link_ext_admin_group_bitmap0);
-               }
        }
 
        /*
index 732853796aab88b39f08b438381146b15d47c129..466e96b3a2cc3e7161354c966d6958fe91896d20 100644 (file)
@@ -2884,7 +2884,8 @@ static void show_isis_route_common(struct vty *vty, int levels,
                                        spftree = area->spftree[SPFTREE_IPV4]
                                                               [level - 1];
 
-                               isis_print_spftree(vty, spftree);
+                               if (!json)
+                                       isis_print_spftree(vty, spftree);
 
                                isis_print_routes(vty, spftree,
                                                  json ? &json_val : NULL,
@@ -2905,7 +2906,8 @@ static void show_isis_route_common(struct vty *vty, int levels,
                                        spftree = area->spftree[SPFTREE_IPV6]
                                                               [level - 1];
 
-                               isis_print_spftree(vty, spftree);
+                               if (!json)
+                                       isis_print_spftree(vty, spftree);
 
                                isis_print_routes(vty, spftree,
                                                  json ? &json_val : NULL,
@@ -2927,7 +2929,8 @@ static void show_isis_route_common(struct vty *vty, int levels,
                                        spftree = area->spftree[SPFTREE_DSTSRC]
                                                               [level - 1];
 
-                               isis_print_spftree(vty, spftree);
+                               if (!json)
+                                       isis_print_spftree(vty, spftree);
                                isis_print_routes(vty, spftree,
                                                  json ? &json_val : NULL,
                                                  prefix_sid, backup);
index f65d21405b5b0014e015168cc43290e73fbde318..4b01a18ecdc7f447c236abdd1385f233b7e92e4e 100644 (file)
@@ -3144,7 +3144,7 @@ static void area_resign_level(struct isis_area *area, int level)
                for (ALL_LIST_ELEMENTS_RO(area->flex_algos->flex_algos, node,
                                          fa)) {
                        data = fa->data;
-                       if (data->spftree[level - 1]) {
+                       if (data->spftree[tree][level - 1]) {
                                isis_spftree_del(
                                        data->spftree[tree][level - 1]);
                                data->spftree[tree][level - 1] = NULL;
index 05f5aef766fb4080fbc52d7e61d37103d49e824b..d473dc10cbf0ece5eeb465f419bec8a768e5d235 100644 (file)
@@ -1140,7 +1140,8 @@ static PyObject *elffile_load(PyTypeObject *type, PyObject *args,
        fd = open(filename, O_RDONLY | O_NOCTTY);
        if (fd < 0 || fstat(fd, &st)) {
                PyErr_SetFromErrnoWithFilename(PyExc_OSError, filename);
-               close(fd);
+               if (fd > 0)
+                       close(fd);
                goto out;
        }
        w->len = st.st_size;
index 9410ef380ecc723de5beafb65a415fe2ee67d175..c1ab5b14aa63f1854daeed4ec0a3ff6fabbc54e4 100644 (file)
@@ -136,7 +136,7 @@ void rip_peer_display(struct vty *vty, struct rip *rip)
        char timebuf[RIP_UPTIME_LEN];
 
        for (ALL_LIST_ELEMENTS(rip->peer_list, node, nnode, peer)) {
-               vty_out(vty, "    %-16pI4 %9d %9d %9d   %s\n",
+               vty_out(vty, "    %-17pI4 %9d %9d %9d %11s\n",
                        &peer->addr, peer->recv_badpackets,
                        peer->recv_badroutes, ZEBRA_RIP_DISTANCE_DEFAULT,
                        rip_peer_uptime(peer, timebuf, RIP_UPTIME_LEN));
index 31ad46ab2ecafbfe2bc062351af3f5f56be35a9b..19fff1a8289e2b8fb6eb5315725b2be0d0df26b1 100644 (file)
@@ -18,5 +18,5 @@ Routing Protocol is "rip"
     r1-eth3
   Routing Information Sources:
     Gateway          BadPackets BadRoutes  Distance Last Update
-    193.1.1.2                0         0       120   XX:XX:XX
+    193.1.1.2                 0         0       120    XX:XX:XX
   Distance: (default is 120)
index 99841a62b0ed921d7378a70fc425834d660a9af1..468b7aece85ff6f1085a6632406f1ddce517e9f4 100644 (file)
@@ -14,6 +14,6 @@ Routing Protocol is "rip"
     193.1.2.0/24
   Routing Information Sources:
     Gateway          BadPackets BadRoutes  Distance Last Update
-    193.1.1.1                0         0       120   XX:XX:XX
-    193.1.2.2                0         0       120   XX:XX:XX
+    193.1.1.1                 0         0       120    XX:XX:XX
+    193.1.2.2                 0         0       120    XX:XX:XX
   Distance: (default is 120)
index 040d3c32a1a0a23cb713501382bdb9722447f149..f423e83f24de25ff20c72b82935e92c1ab5fff84 100644 (file)
@@ -12,5 +12,5 @@ Routing Protocol is "rip"
     193.1.2.0/24
   Routing Information Sources:
     Gateway          BadPackets BadRoutes  Distance Last Update
-    193.1.2.1                0         0       120   XX:XX:XX
+    193.1.2.1                 0         0       120    XX:XX:XX
   Distance: (default is 120)
index e821572c5d7b18f88b8b000cd13864b5600850dd..f6c1fdd78e43a9f6a24744f28d60d286c9278610 100644 (file)
@@ -5380,8 +5380,7 @@ dplane_gre_set(struct interface *ifp, struct interface *ifp_link,
                atomic_fetch_add_explicit(
                        &zdplane_info.dg_gre_set_errors, 1,
                        memory_order_relaxed);
-               if (ctx)
-                       dplane_ctx_free(&ctx);
+               dplane_ctx_free(&ctx);
                result = ZEBRA_DPLANE_REQUEST_FAILURE;
        }
        return result;