Merge pull request #12067 from NeoRaider/wifidog-build-dir
[feed/packages.git] / net / frr / patches / 025-7.3_backports.patch
1 From 7cc9f2c7953d48cfb70b7e0c1b0c57e45ae68ce8 Mon Sep 17 00:00:00 2001
2 From: Stephen Worley <sworley@cumulusnetworks.com>
3 Date: Wed, 1 Apr 2020 15:31:40 -0400
4 Subject: [PATCH] zebra: free unhashable (dup) NHEs via ID table cleanup
5
6 Free unhashable (duplicate NHEs from the kernel) via ID table
7 cleanup. Since the NHE ID hash table contains extra entries,
8 that's the one we need to be calling zebra_nhg_hash_free()
9 on, otherwise we will never free the unhashable NHEs.
10
11 This was found via a memleak:
12
13 ==1478713== HEAP SUMMARY:
14 ==1478713== in use at exit: 10,267 bytes in 46 blocks
15 ==1478713== total heap usage: 76,810 allocs, 76,764 frees, 3,901,237 bytes allocated
16 ==1478713==
17 ==1478713== 208 (88 direct, 120 indirect) bytes in 1 blocks are definitely lost in loss record 35 of 41
18 ==1478713== at 0x483BB1A: calloc (vg_replace_malloc.c:762)
19 ==1478713== by 0x48E35E8: qcalloc (memory.c:110)
20 ==1478713== by 0x451CCB: zebra_nhg_alloc (zebra_nhg.c:369)
21 ==1478713== by 0x453DE3: zebra_nhg_copy (zebra_nhg.c:379)
22 ==1478713== by 0x452670: nhg_ctx_process_new (zebra_nhg.c:1143)
23 ==1478713== by 0x4523A8: nhg_ctx_process (zebra_nhg.c:1234)
24 ==1478713== by 0x452A2D: zebra_nhg_kernel_find (zebra_nhg.c:1294)
25 ==1478713== by 0x4326E0: netlink_nexthop_change (rt_netlink.c:2433)
26 ==1478713== by 0x427320: netlink_parse_info (kernel_netlink.c:945)
27 ==1478713== by 0x432DAD: netlink_nexthop_read (rt_netlink.c:2488)
28 ==1478713== by 0x41B600: interface_list (if_netlink.c:1486)
29 ==1478713== by 0x457275: zebra_ns_enable (zebra_ns.c:127)
30
31 Repro with:
32 ip next add id 1 blackhole
33 ip next add id 2 blackhole
34
35 valgrind /usr/lib/frr/zebra
36
37 Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
38 (cherry picked from commit c25c3ea57a3dcd3b36d86ba76dd34961bcb662f0)
39 ---
40 zebra/zebra_router.c | 7 ++++---
41 1 file changed, 4 insertions(+), 3 deletions(-)
42
43 diff --git a/zebra/zebra_router.c b/zebra/zebra_router.c
44 index a891ffb76a..ea2b6752b3 100644
45 --- a/zebra/zebra_router.c
46 +++ b/zebra/zebra_router.c
47 @@ -223,10 +223,11 @@ void zebra_router_terminate(void)
48 zebra_vxlan_disable();
49 zebra_mlag_terminate();
50
51 - hash_clean(zrouter.nhgs, zebra_nhg_hash_free);
52 - hash_free(zrouter.nhgs);
53 - hash_clean(zrouter.nhgs_id, NULL);
54 + /* Free NHE in ID table only since it has unhashable entries as well */
55 + hash_clean(zrouter.nhgs_id, zebra_nhg_hash_free);
56 hash_free(zrouter.nhgs_id);
57 + hash_clean(zrouter.nhgs, NULL);
58 + hash_free(zrouter.nhgs);
59
60 hash_clean(zrouter.rules_hash, zebra_pbr_rules_free);
61 hash_free(zrouter.rules_hash);