mirror_frr/zebra
Donald Sharp c32c32c931 zebra: Ensure zebra_nhg_sweep_table accounts for double deletes
I'm seeing this crash in various forms:
Program terminated with signal SIGSEGV, Segmentation fault.
50 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
[Current thread is 1 (Thread 0x7f418efbc7c0 (LWP 3580253))]
(gdb) bt
(gdb) f 4
267 (*func)(hb, arg);
(gdb) p hb
$1 = (struct hash_bucket *) 0x558cdaafb250
(gdb) p *hb
$2 = {len = 0, next = 0x0, key = 0, data = 0x0}
(gdb)

I've also seen a crash where data is 0x03.

My suspicion is that hash_iterate is calling zebra_nhg_sweep_entry which
does delete the particular entry we are looking at as well as possibly other
entries when the ref count for those entries gets set to 0 as well.

Then we have this loop in hash_iterate.c:

   for (i = 0; i < hash->size; i++)
            for (hb = hash->index[i]; hb; hb = hbnext) {
                    /* get pointer to next hash bucket here, in case (*func)
                     * decides to delete hb by calling hash_release
                     */
                    hbnext = hb->next;
                    (*func)(hb, arg);
            }
Suppose in the previous loop hbnext is set to hb->next and we call
zebra_nhg_sweep_entry. This deletes the previous entry and also
happens to cause the hbnext entry to be deleted as well, because of nhg
refcounts. At this point in time the memory pointed to by hbnext is
not owned by the pthread anymore and we can end up on a state where
it's overwritten by another pthread in zebra with data for other incoming events.

What to do?  Let's change the sweep function to a hash_walk and have
it stop iterating and to start over if there is a possible double
delete operation.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
(cherry picked from commit 07b9ebca65)
2022-02-09 10:46:33 +00:00
..
.gitignore *: cleanup .gitignore files 2018-09-08 21:30:42 +02:00
connected.c *: cleanup ifp->vrf_id 2021-11-22 20:47:23 +03:00
connected.h lib,zebra: use more const 2021-09-14 10:31:45 -04:00
debug_nl.c zebra: debug_nl.c ensure we can read RTM_NEWNEIGH bridge nested attrs 2021-10-28 08:16:49 -04:00
debug.c zebra: debug zebra kernel msgdump is linux specific 2021-08-06 10:04:40 -04:00
debug.h zebra: add 'detail' mpls debug setting 2021-04-05 15:53:48 -04:00
dplane_fpm_nl.c zebra: Convert vty_out to vty_json for JSON 2021-11-25 17:49:46 +02:00
if_ioctl.c *: cleanup ifp->vrf_id 2021-11-22 20:47:23 +03:00
if_netlink.c zebra: fix vrf deletion 2022-01-24 01:51:10 +03:00
if_netlink.h zebra: intf address handler is platform-neutral 2021-09-14 11:07:30 -04:00
if_sysctl.c zebra: kill zebra_memory.h, use MTYPE_STATIC 2021-03-22 20:02:17 +01:00
interface.c *: do not print vrf name for interface config when using vrf-lite 2022-01-24 14:44:05 +03:00
interface.h *: Rename quagga_timestamp with frr_timestamp 2021-11-11 14:41:27 -05:00
ioctl.c *: cleanup ifp->vrf_id 2021-11-22 20:47:23 +03:00
ioctl.h *: Remove solaris from FRR 2020-09-21 10:02:20 -04:00
ipforward_proc.c zebra: Cleanup set but unused variables 2020-02-27 09:41:58 -05:00
ipforward_sysctl.c *: Remove solaris from FRR 2020-09-21 10:02:20 -04:00
ipforward.h add cplusplus guards to all zebra headers 2019-03-25 16:05:27 +01:00
irdp_interface.c zebra: kill zebra_memory.h, use MTYPE_STATIC 2021-03-22 20:02:17 +01:00
irdp_main.c zebra: Do not explicitly set the thread pointer to NULL 2021-10-04 19:23:55 +03:00
irdp_packet.c zebra: Do not explicitly set the thread pointer to NULL 2021-10-04 19:23:55 +03:00
irdp.h *: strip trailing whitespace 2019-09-30 16:44:43 +00:00
kernel_netlink.c zebra: Fix v6 route replace failure turned into success 2022-02-07 20:46:24 +00:00
kernel_netlink.h include, zebra: Add recent nexthop.h 2021-10-25 14:11:37 -04:00
kernel_socket.c *: Cleanup some documentation from quagga->frr 2021-11-11 14:41:27 -05:00
kernel_socket.h add cplusplus guards to all zebra headers 2019-03-25 16:05:27 +01:00
label_manager.c Merge pull request #7756 from pjdruddy/bgplu-fixes 2021-01-09 15:48:22 -05:00
label_manager.h zebra: expose label-manager util-funcs 2021-01-05 18:19:44 +00:00
main.c *: rework renaming the default VRF 2021-12-21 22:09:29 +03:00
Makefile
redistribute.c zebra: Add table and instance data to debugs for redistribute_delete 2022-01-18 08:39:41 -05:00
redistribute.h zebra: Fix redistribute.h up to our standards 2022-01-18 08:39:40 -05:00
rib.h zebra: fix cleanup of meta queues on vrf disable 2022-02-02 13:35:51 +00:00
router-id.c *: cleanup ifp->vrf_id 2021-11-22 20:47:23 +03:00
router-id.h zebra: add IPv6 router-id 2020-07-17 17:39:05 +02:00
rt_netlink.c *: cleanup ifp->vrf_id 2021-11-22 20:47:23 +03:00
rt_netlink.h zebra: use more const 2021-07-19 10:36:12 -04:00
rt_socket.c zebra: new dplane action to set gre link interface 2021-04-30 10:33:18 +02:00
rt.h zebra: use the dataplane to read netlink intf addr changes 2021-09-14 11:07:30 -04:00
rtadv.c *: cleanup ifp->vrf_id 2021-11-22 20:47:23 +03:00
rtadv.h zebra: rework RA handling for vrf-lite 2021-06-08 15:05:43 -04:00
rtread_netlink.c zebra: use more const 2021-07-19 10:36:12 -04:00
rtread_sysctl.c zebra: use more const 2021-07-19 10:36:12 -04:00
rule_netlink.c zebra: Use a bool for startup indications 2021-10-04 20:26:38 -04:00
rule_netlink.h zebra: netlink message batching 2020-08-10 21:42:43 +02:00
rule_socket.c zebra: convert ip rule installation to use dplane thread 2020-06-10 16:18:45 +02:00
sample_plugin.c *: require semicolon after FRR_DAEMON_INFO & co. 2021-03-17 06:18:39 +01:00
subdir.am zebra: Add encoders/decoders for zebra 2021-10-20 00:56:00 +08:00
table_manager.c zebra: fix memleak on shutdown 2021-11-16 12:42:32 +03:00
table_manager.h zebra: extend table manager per vrf, add vty configuration 2021-09-21 18:37:30 +02:00
testrib.conf
zapi_msg.c zebra: Fix EVPN route nexthop config order 2022-01-28 20:51:10 +08:00
zapi_msg.h zebra: Modify route_notify_internal to use a route_node 2022-01-18 08:39:41 -05:00
zebra_dplane.c zebra: Fix v6 route replace failure turned into success 2022-02-07 20:46:24 +00:00
zebra_dplane.h zebra: Fix v6 route replace failure turned into success 2022-02-07 20:46:24 +00:00
zebra_errors.c zebra: ZAPI add new api to manipulate srv6-locator (step2) 2021-06-02 10:24:47 -04:00
zebra_errors.h zebra: ZAPI add new api to manipulate srv6-locator (step2) 2021-06-02 10:24:47 -04:00
zebra_evpn_mac.c zebra: cleanup checking zebra_evpn_mac_add function's return value 2021-12-22 21:13:26 -05:00
zebra_evpn_mac.h zebra: Convert to struct zebra_mac as per our internal standard 2021-09-02 10:33:22 -04:00
zebra_evpn_mh.c *: Remove redundand braces for single statement blocks 2021-11-27 11:20:59 +02:00
zebra_evpn_mh.h zebra: defer local MAC dataplane install on an ES till the ES-EVI is created 2021-10-15 10:43:41 -07:00
zebra_evpn_neigh.c zebra: cleanup checking zebra_evpn_mac_add function's return value 2021-12-22 21:13:26 -05:00
zebra_evpn_neigh.h zebra: Convert to struct zebra_neigh as per our internal standard 2021-09-02 10:33:23 -04:00
zebra_evpn_vxlan.h *: cleanup ifp->vrf_id 2021-11-22 20:47:23 +03:00
zebra_evpn.c *: cleanup ifp->vrf_id 2021-11-22 20:47:23 +03:00
zebra_evpn.h zebra: Convert to struct zebra_vtep as per our internal standard 2021-09-02 10:33:22 -04:00
zebra_fpm_dt.c zebra: replace inet_ntoa 2020-10-22 13:37:25 -04:00
zebra_fpm_netlink.c zebra: add inbound netlink socket for dataplane 2021-09-14 10:31:45 -04:00
zebra_fpm_private.h zebra: Fix IPv4 routes with IPv6 link local next hops install in FPM 2021-09-13 08:39:43 -07:00
zebra_fpm_protobuf.c *: Do not cast to the same type 2020-04-08 17:15:06 +03:00
zebra_fpm.c zebra: Fix ignored return value from inet_pton 2021-09-20 09:20:46 -04:00
zebra_gr.c *: Add FOREACH_AFI_SAFI_NSF(afi, safi) macro to reduce nesting 2022-01-13 14:29:54 +02:00
zebra_l2.c *: cleanup ifp->vrf_id 2021-11-22 20:47:23 +03:00
zebra_l2.h zebra: refresh vxlan evpn contexts, when bridge interface goes up 2021-09-17 10:25:38 +02:00
zebra_mlag_private.c build: make builddir include path consistent 2021-04-21 15:42:33 +02:00
zebra_mlag_vty.c zebra: Do not build mlag protobuf support if version 3 is not avail 2019-12-15 09:37:51 -05:00
zebra_mlag_vty.h lib, zebra: add missing extern "C" {} blocks to new header files 2020-04-22 23:49:22 -03:00
zebra_mlag.c zebra: Give extra space and stop processing if we run out of space 2021-06-09 06:43:28 -04:00
zebra_mlag.h *: require semicolon after DEFINE_HOOK & co. 2021-03-17 06:18:17 +01:00
zebra_mpls_netlink.c zebra: dplane FPM handle LSP install/update/delete 2020-11-27 16:32:01 +00:00
zebra_mpls_null.c zebra: convert PW updates to async dataplane 2019-01-25 10:45:57 -05:00
zebra_mpls_openbsd.c zebra: Convert to struct zebra_nhlfe as per our internal standard 2021-09-02 10:33:23 -04:00
zebra_mpls_vty.c zebra: fix wrong check of mpls command 2021-08-18 19:34:03 -04:00
zebra_mpls.c zebra: Convert vty_out to vty_json for JSON 2021-11-25 17:49:46 +02:00
zebra_mpls.h zebra: Convert to struct zebra_fec as per our internal standard 2021-09-02 10:33:23 -04:00
zebra_mroute.c pimd, zebra: explicit cast int netlink val to uint 2021-04-28 11:43:50 -04:00
zebra_mroute.h add cplusplus guards to all zebra headers 2019-03-25 16:05:27 +01:00
zebra_nb_config.c zebra: Convert to struct zebra_l3nvi as per our internal standard 2021-09-02 10:33:22 -04:00
zebra_nb_rpcs.c zebra: display rpc error msg to vtysh 2020-10-05 13:57:54 -07:00
zebra_nb_state.c zebra: make ribs config false 2021-03-16 17:25:49 +03:00
zebra_nb.c zebra: North-bound implementation for zebra rmaps 2021-03-30 22:58:42 +03:00
zebra_nb.h zebra: North-bound implementation for zebra rmaps 2021-03-30 22:58:42 +03:00
zebra_netns_id.c Merge pull request #7148 from pguibert6WIND/fix_fd_not_closed 2020-09-23 07:40:14 -04:00
zebra_netns_id.h zebra: dynamically detect vxlan link interfaces in other netns 2020-09-11 18:26:23 +02:00
zebra_netns_notify.c *: rework renaming the default VRF 2021-12-21 22:09:29 +03:00
zebra_netns_notify.h add cplusplus guards to all zebra headers 2019-03-25 16:05:27 +01:00
zebra_nhg_private.h lib, zebra: add missing extern "C" {} blocks to new header files 2020-04-22 23:49:22 -03:00
zebra_nhg.c zebra: Ensure zebra_nhg_sweep_table accounts for double deletes 2022-02-09 10:46:33 +00:00
zebra_nhg.h Merge pull request #8488 from mjstapp/more_workqueue 2021-04-27 11:59:33 -04:00
zebra_ns.c *: rework renaming the default VRF 2021-12-21 22:09:29 +03:00
zebra_ns.h *: rework renaming the default VRF 2021-12-21 22:09:29 +03:00
zebra_opaque.c zebra: kill zebra_memory.h, use MTYPE_STATIC 2021-03-22 20:02:17 +01:00
zebra_opaque.h zebra: add zebra opaque module 2020-06-02 08:20:54 -04:00
zebra_pbr.c zebra: return void for dplane_ctx_get_pbr_ipset_entry 2021-11-17 07:46:36 -05:00
zebra_pbr.h zebra: update dataplane flowspec address family in ipset_info 2021-11-03 17:17:08 +01:00
zebra_ptm_redistribute.c zebra: kill zebra_memory.h, use MTYPE_STATIC 2021-03-22 20:02:17 +01:00
zebra_ptm_redistribute.h add cplusplus guards to all zebra headers 2019-03-25 16:05:27 +01:00
zebra_ptm.c bfdd: correct one spelling error of comment 2021-12-31 05:32:49 -05:00
zebra_ptm.h zebra: add "json" option to "show interface" 2021-08-02 17:19:45 -03:00
zebra_pw.c zebra: Convert vty_out to vty_json for JSON 2021-11-25 17:49:46 +02:00
zebra_pw.h *: require semicolon after DEFINE_QOBJ & co. 2021-03-17 06:18:37 +01:00
zebra_rib.c zebra: fix cleanup of meta queues on vrf disable 2022-02-02 13:35:51 +00:00
zebra_rnh.c lib, zebra: Send safi for rnh resolution 2021-09-27 15:26:05 -04:00
zebra_rnh.h zebra: Start carrying safi for rnh processing 2021-09-27 12:38:08 -04:00
zebra_routemap_nb_config.c zebra: remove checks for src address existence when using "set src" 2021-08-02 18:35:30 +03:00
zebra_routemap_nb.c *: make sure config.h or zebra.h is first 2021-04-23 12:06:35 +02:00
zebra_routemap_nb.h zebra: North-bound implementation for zebra rmaps 2021-03-30 22:58:42 +03:00
zebra_routemap.c zebra: Start carrying safi for rnh processing 2021-09-27 12:38:08 -04:00
zebra_routemap.h zebra: North-bound implementation for zebra rmaps 2021-03-30 22:58:42 +03:00
zebra_router.c zebra: Prevent thread usage of data after it being freed 2021-11-29 15:51:45 -05:00
zebra_router.h zebra: Prevent thread usage of data after it being freed 2021-11-29 15:51:45 -05:00
zebra_script.c zebra: Recent Merge broke --enable-werror 2021-10-27 08:53:43 -04:00
zebra_script.h zebra: Add encoders/decoders for zebra 2021-10-20 00:56:00 +08:00
zebra_snmp.c build: make builddir include path consistent 2021-04-21 15:42:33 +02:00
zebra_srte.c lib, zebra: Send safi for rnh resolution 2021-09-27 15:26:05 -04:00
zebra_srte.h zebra: Convert to struct zebra_lsp as per our internal standard 2021-09-02 10:33:23 -04:00
zebra_srv6_vty.c Merge pull request #9899 from Drumato/zebra-srv6-locator-detail-json-support 2021-12-14 09:11:36 +02:00
zebra_srv6_vty.h *: new cli-nodes for SRv6 manager (step2) 2021-06-02 10:24:47 -04:00
zebra_srv6.c zebra: elliminate srv6 locator auto allocation by zlicnet request 2021-09-07 12:54:39 +00:00
zebra_srv6.h *: fix code format accourding to checkpatch 2021-06-02 10:24:48 -04:00
zebra_vrf.c zebra: fix cleanup of meta queues on vrf disable 2022-02-02 13:35:51 +00:00
zebra_vrf.h lib: move zebra-only netns stuff to zebra 2021-10-19 00:16:10 +03:00
zebra_vty.c Merge pull request #9644 from opensourcerouting/ospf-opaque-attrs 2022-01-18 09:08:38 -05:00
zebra_vxlan_private.h zebra: Convert to struct zebra_l3nvi as per our internal standard 2021-09-02 10:33:22 -04:00
zebra_vxlan.c zebra: correct one spell error 2021-12-19 20:47:01 -05:00
zebra_vxlan.h zebra: handle bridge mac address update in evpn contexts 2021-09-17 10:25:35 +02:00
zserv.c zebra: Expand v4/v6 route space 2021-11-17 07:47:28 -05:00
zserv.h zebra: link layer config and notification, implementation in zebra 2021-04-09 18:29:58 +02:00