Hi Lou,

Seems this is causing a crash with Martin's tests. (The good news is this is the final commit causing any issues in r8 on his tests). Martin has a reproducer tool, that leads to this:

*** Error in `/home/paul/code/quagga/bgpd/.libs/lt-bgpd': double free or corruption (fasttop): 0x00000000008c1b40 ***
...
(gdb) bt
#0  0x00007ffff6e9c6f5 in raise () from /lib64/libc.so.6
#1  0x00007ffff6e9e2fa in abort () from /lib64/libc.so.6
#2  0x00007ffff6edd600 in __libc_message () from /lib64/libc.so.6
#3  0x00007ffff6ee5d4a in _int_free () from /lib64/libc.so.6
#4  0x00007ffff6ee92ac in free () from /lib64/libc.so.6
#5  0x00000000004504ee in bgp_unlink_nexthop (path=path@entry=0x8f2dc0)
    at bgp_nht.c:89
#6  0x000000000041dccd in bgp_info_free (binfo=0x8f2dc0) at bgp_route.c:137
#7  bgp_info_unlock (binfo=0x8f2dc0) at bgp_route.c:165
#8  0x000000000041dd71 in bgp_info_reap (rn=rn@entry=0x8f2d40,
    ri=ri@entry=0x8f2dc0) at bgp_route.c:211
#9  0x000000000041e0fe in bgp_best_selection (bgp=bgp@entry=0x8aebc0,
    rn=rn@entry=0x8f2d40, result=result@entry=0x7fffffffdf60,
    afi=afi@entry=AFI_IP, safi=safi@entry=1 '\001') at bgp_route.c:1407
#10 0x000000000041e45f in bgp_process_main (wq=<optimized out>,
    data=<optimized out>) at bgp_route.c:1600
#11 0x00007ffff7bb09a0 in work_queue_run (thread=0x7fffffffe198)
    at workqueue.c:299
#12 0x00007ffff7b9c090 in thread_call (thread=thread@entry=0x7fffffffe198)
    at thread.c:1358
#13 0x0000000000406cda in main (argc=7, argv=0x7fffffffe328) at bgp_main.c:489

A double-free.

Valgrind:

# ip netns exec quagga-test libtool --mode=execute valgrind ./bgpd/bgpd -f /tmp/bgpd.conf -z /tmp/zserv.test.api -i /tmp/bgpd-test.pid
==14497== Memcheck, a memory error detector
==14497== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al. ==14497== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info ==14497== Command: /home/paul/code/quagga/bgpd/.libs/lt-bgpd -f /tmp/bgpd.conf -z /tmp/zserv.test.api -i /tmp/bgpd-test.pid
==14497==
==14497== Invalid read of size 4
==14497==    at 0x45047E: path_nh_map (bgp_nht.c:548)
==14497==    by 0x45047E: bgp_unlink_nexthop (bgp_nht.c:76)
==14497==    by 0x41DCCC: bgp_info_free (bgp_route.c:137)
==14497==    by 0x41DCCC: bgp_info_unlock (bgp_route.c:165)
==14497==    by 0x41DD70: bgp_info_reap (bgp_route.c:211)
==14497==    by 0x41E0FD: bgp_best_selection (bgp_route.c:1407)
==14497==    by 0x41E45E: bgp_process_main (bgp_route.c:1600)
==14497==    by 0x4E7199F: work_queue_run (workqueue.c:299)
==14497==    by 0x4E5D08F: thread_call (thread.c:1358)
==14497==    by 0x406CD9: main (bgp_main.c:489)
==14497== Address 0x6fe9a08 is 56 bytes inside a block of size 64 free'd
==14497==    at 0x4C2CCF0: free (vg_replace_malloc.c:530)
==14497==    by 0x45058A: bgp_drop_peer_nexthop (bgp_nht.c:126)
==14497==    by 0x410FE4: bgp_stop (bgp_fsm.c:460)
==14497==    by 0x411412: bgp_stop_with_error (bgp_fsm.c:603)
==14497==    by 0x412403: bgp_event (bgp_fsm.c:1180)
==14497==    by 0x4E5D08F: thread_call (thread.c:1358)
==14497==    by 0x406CD9: main (bgp_main.c:489)
==14497==  Block was alloc'd at
==14497==    at 0x4C2D988: calloc (vg_replace_malloc.c:711)
==14497==    by 0x4E5E985: zcalloc (memory.c:89)
==14497==    by 0x43AB40: bnc_new (bgp_nexthop.c:80)
==14497==    by 0x450685: bgp_find_or_add_nexthop (bgp_nht.c:165)
==14497==    by 0x421488: bgp_update_main (bgp_route.c:2400)
==14497==    by 0x421620: bgp_update (bgp_route.c:2466)
==14497==    by 0x423597: bgp_nlri_parse_ip (bgp_route.c:3353)
==14497==    by 0x433DB0: bgp_update_receive (bgp_packet.c:1863)
==14497==    by 0x434AAF: bgp_read (bgp_packet.c:2610)
==14497==    by 0x4E5D08F: thread_call (thread.c:1358)
==14497==    by 0x406CD9: main (bgp_main.c:489)
==14497==
==14497== Invalid read of size 8
==14497==    at 0x450481: bgp_unlink_nexthop (bgp_nht.c:78)
==14497==    by 0x41DCCC: bgp_info_free (bgp_route.c:137)
==14497==    by 0x41DCCC: bgp_info_unlock (bgp_route.c:165)
==14497==    by 0x41DD70: bgp_info_reap (bgp_route.c:211)
==14497==    by 0x41E0FD: bgp_best_selection (bgp_route.c:1407)
==14497==    by 0x41E45E: bgp_process_main (bgp_route.c:1600)
==14497==    by 0x4E7199F: work_queue_run (workqueue.c:299)
==14497==    by 0x4E5D08F: thread_call (thread.c:1358)
==14497==    by 0x406CD9: main (bgp_main.c:489)
==14497== Address 0x6fe9a00 is 48 bytes inside a block of size 64 free'd
==14497==    at 0x4C2CCF0: free (vg_replace_malloc.c:530)
==14497==    by 0x45058A: bgp_drop_peer_nexthop (bgp_nht.c:126)
==14497==    by 0x410FE4: bgp_stop (bgp_fsm.c:460)
==14497==    by 0x411412: bgp_stop_with_error (bgp_fsm.c:603)
==14497==    by 0x412403: bgp_event (bgp_fsm.c:1180)
==14497==    by 0x4E5D08F: thread_call (thread.c:1358)
==14497==    by 0x406CD9: main (bgp_main.c:489)
==14497==  Block was alloc'd at
==14497==    at 0x4C2D988: calloc (vg_replace_malloc.c:711)
==14497==    by 0x4E5E985: zcalloc (memory.c:89)
==14497==    by 0x43AB40: bnc_new (bgp_nexthop.c:80)
==14497==    by 0x450685: bgp_find_or_add_nexthop (bgp_nht.c:165)
==14497==    by 0x421488: bgp_update_main (bgp_route.c:2400)
==14497==    by 0x421620: bgp_update (bgp_route.c:2466)
==14497==    by 0x423597: bgp_nlri_parse_ip (bgp_route.c:3353)
==14497==    by 0x433DB0: bgp_update_receive (bgp_packet.c:1863)
==14497==    by 0x434AAF: bgp_read (bgp_packet.c:2610)
==14497==    by 0x4E5D08F: thread_call (thread.c:1358)
==14497==    by 0x406CD9: main (bgp_main.c:489)
==14497==
==14497== Invalid write of size 8
==14497==    at 0x45047B: path_nh_map (bgp_nht.c:547)
==14497==    by 0x45047B: bgp_unlink_nexthop (bgp_nht.c:76)
==14497==    by 0x41DCCC: bgp_info_free (bgp_route.c:137)
==14497==    by 0x41DCCC: bgp_info_unlock (bgp_route.c:165)
==14497==    by 0x41DD70: bgp_info_reap (bgp_route.c:211)
==14497==    by 0x41E0FD: bgp_best_selection (bgp_route.c:1407)
==14497==    by 0x41E45E: bgp_process_main (bgp_route.c:1600)
==14497==    by 0x4E7199F: work_queue_run (workqueue.c:299)
==14497==    by 0x4E5D08F: thread_call (thread.c:1358)
==14497==    by 0x406CD9: main (bgp_main.c:489)
==14497== Address 0x6fe9a00 is 48 bytes inside a block of size 64 free'd
==14497==    at 0x4C2CCF0: free (vg_replace_malloc.c:530)
==14497==    by 0x45058A: bgp_drop_peer_nexthop (bgp_nht.c:126)
==14497==    by 0x410FE4: bgp_stop (bgp_fsm.c:460)
==14497==    by 0x411412: bgp_stop_with_error (bgp_fsm.c:603)
==14497==    by 0x412403: bgp_event (bgp_fsm.c:1180)
==14497==    by 0x4E5D08F: thread_call (thread.c:1358)
==14497==    by 0x406CD9: main (bgp_main.c:489)
==14497==  Block was alloc'd at
==14497==    at 0x4C2D988: calloc (vg_replace_malloc.c:711)
==14497==    by 0x4E5E985: zcalloc (memory.c:89)
==14497==    by 0x43AB40: bnc_new (bgp_nexthop.c:80)
==14497==    by 0x450685: bgp_find_or_add_nexthop (bgp_nht.c:165)
==14497==    by 0x421488: bgp_update_main (bgp_route.c:2400)
==14497==    by 0x421620: bgp_update (bgp_route.c:2466)
==14497==    by 0x423597: bgp_nlri_parse_ip (bgp_route.c:3353)
==14497==    by 0x433DB0: bgp_update_receive (bgp_packet.c:1863)
==14497==    by 0x434AAF: bgp_read (bgp_packet.c:2610)
==14497==    by 0x4E5D08F: thread_call (thread.c:1358)
==14497==    by 0x406CD9: main (bgp_main.c:489)
==14497==
==14497== Invalid read of size 8
==14497==    at 0x450490: bgp_unlink_nexthop (bgp_nht.c:78)
==14497==    by 0x41DCCC: bgp_info_free (bgp_route.c:137)
==14497==    by 0x41DCCC: bgp_info_unlock (bgp_route.c:165)
==14497==    by 0x41DD70: bgp_info_reap (bgp_route.c:211)
==14497==    by 0x41E0FD: bgp_best_selection (bgp_route.c:1407)
==14497==    by 0x41E45E: bgp_process_main (bgp_route.c:1600)
==14497==    by 0x4E7199F: work_queue_run (workqueue.c:299)
==14497==    by 0x4E5D08F: thread_call (thread.c:1358)
==14497==    by 0x406CD9: main (bgp_main.c:489)
==14497== Address 0x6fe99f8 is 40 bytes inside a block of size 64 free'd
==14497==    at 0x4C2CCF0: free (vg_replace_malloc.c:530)
==14497==    by 0x45058A: bgp_drop_peer_nexthop (bgp_nht.c:126)
==14497==    by 0x410FE4: bgp_stop (bgp_fsm.c:460)
==14497==    by 0x411412: bgp_stop_with_error (bgp_fsm.c:603)
==14497==    by 0x412403: bgp_event (bgp_fsm.c:1180)
==14497==    by 0x4E5D08F: thread_call (thread.c:1358)
==14497==    by 0x406CD9: main (bgp_main.c:489)
==14497==  Block was alloc'd at
==14497==    at 0x4C2D988: calloc (vg_replace_malloc.c:711)
==14497==    by 0x4E5E985: zcalloc (memory.c:89)
==14497==    by 0x43AB40: bnc_new (bgp_nexthop.c:80)
==14497==    by 0x450685: bgp_find_or_add_nexthop (bgp_nht.c:165)
==14497==    by 0x421488: bgp_update_main (bgp_route.c:2400)
==14497==    by 0x421620: bgp_update (bgp_route.c:2466)
==14497==    by 0x423597: bgp_nlri_parse_ip (bgp_route.c:3353)
==14497==    by 0x433DB0: bgp_update_receive (bgp_packet.c:1863)
==14497==    by 0x434AAF: bgp_read (bgp_packet.c:2610)
==14497==    by 0x4E5D08F: thread_call (thread.c:1358)
==14497==    by 0x406CD9: main (bgp_main.c:489)
==14497==
==14497== Invalid read of size 1
==14497==    at 0x4504C2: unregister_nexthop (bgp_nht.c:459)
==14497==    by 0x4504C2: bgp_unlink_nexthop (bgp_nht.c:86)
==14497==    by 0x41DCCC: bgp_info_free (bgp_route.c:137)
==14497==    by 0x41DCCC: bgp_info_unlock (bgp_route.c:165)
==14497==    by 0x41DD70: bgp_info_reap (bgp_route.c:211)
==14497==    by 0x41E0FD: bgp_best_selection (bgp_route.c:1407)
==14497==    by 0x41E45E: bgp_process_main (bgp_route.c:1600)
==14497==    by 0x4E7199F: work_queue_run (workqueue.c:299)
==14497==    by 0x4E5D08F: thread_call (thread.c:1358)
==14497==    by 0x406CD9: main (bgp_main.c:489)
==14497== Address 0x6fe99e8 is 24 bytes inside a block of size 64 free'd
==14497==    at 0x4C2CCF0: free (vg_replace_malloc.c:530)
==14497==    by 0x45058A: bgp_drop_peer_nexthop (bgp_nht.c:126)
==14497==    by 0x410FE4: bgp_stop (bgp_fsm.c:460)
==14497==    by 0x411412: bgp_stop_with_error (bgp_fsm.c:603)
==14497==    by 0x412403: bgp_event (bgp_fsm.c:1180)
==14497==    by 0x4E5D08F: thread_call (thread.c:1358)
==14497==    by 0x406CD9: main (bgp_main.c:489)
==14497==  Block was alloc'd at
==14497==    at 0x4C2D988: calloc (vg_replace_malloc.c:711)
==14497==    by 0x4E5E985: zcalloc (memory.c:89)
==14497==    by 0x43AB40: bnc_new (bgp_nexthop.c:80)
==14497==    by 0x450685: bgp_find_or_add_nexthop (bgp_nht.c:165)
==14497==    by 0x421488: bgp_update_main (bgp_route.c:2400)
==14497==    by 0x421620: bgp_update (bgp_route.c:2466)
==14497==    by 0x423597: bgp_nlri_parse_ip (bgp_route.c:3353)
==14497==    by 0x433DB0: bgp_update_receive (bgp_packet.c:1863)
==14497==    by 0x434AAF: bgp_read (bgp_packet.c:2610)
==14497==    by 0x4E5D08F: thread_call (thread.c:1358)
==14497==    by 0x406CD9: main (bgp_main.c:489)
==14497==
==14497== Invalid read of size 8
==14497==    at 0x4504D5: bgp_unlink_nexthop (bgp_nht.c:87)
==14497==    by 0x41DCCC: bgp_info_free (bgp_route.c:137)
==14497==    by 0x41DCCC: bgp_info_unlock (bgp_route.c:165)
==14497==    by 0x41DD70: bgp_info_reap (bgp_route.c:211)
==14497==    by 0x41E0FD: bgp_best_selection (bgp_route.c:1407)
==14497==    by 0x41E45E: bgp_process_main (bgp_route.c:1600)
==14497==    by 0x4E7199F: work_queue_run (workqueue.c:299)
==14497==    by 0x4E5D08F: thread_call (thread.c:1358)
==14497==    by 0x406CD9: main (bgp_main.c:489)
==14497== Address 0x6fe99f0 is 32 bytes inside a block of size 64 free'd
==14497==    at 0x4C2CCF0: free (vg_replace_malloc.c:530)
==14497==    by 0x45058A: bgp_drop_peer_nexthop (bgp_nht.c:126)
==14497==    by 0x410FE4: bgp_stop (bgp_fsm.c:460)
==14497==    by 0x411412: bgp_stop_with_error (bgp_fsm.c:603)
==14497==    by 0x412403: bgp_event (bgp_fsm.c:1180)
==14497==    by 0x4E5D08F: thread_call (thread.c:1358)
==14497==    by 0x406CD9: main (bgp_main.c:489)
==14497==  Block was alloc'd at
==14497==    at 0x4C2D988: calloc (vg_replace_malloc.c:711)
==14497==    by 0x4E5E985: zcalloc (memory.c:89)
==14497==    by 0x43AB40: bnc_new (bgp_nexthop.c:80)
==14497==    by 0x450685: bgp_find_or_add_nexthop (bgp_nht.c:165)
==14497==    by 0x421488: bgp_update_main (bgp_route.c:2400)
==14497==    by 0x421620: bgp_update (bgp_route.c:2466)
==14497==    by 0x423597: bgp_nlri_parse_ip (bgp_route.c:3353)
==14497==    by 0x433DB0: bgp_update_receive (bgp_packet.c:1863)
==14497==    by 0x434AAF: bgp_read (bgp_packet.c:2610)
==14497==    by 0x4E5D08F: thread_call (thread.c:1358)
==14497==    by 0x406CD9: main (bgp_main.c:489)
==14497==
==14497== Invalid write of size 8
==14497==    at 0x4504D9: bgp_unlink_nexthop (bgp_nht.c:87)
==14497==    by 0x41DCCC: bgp_info_free (bgp_route.c:137)
==14497==    by 0x41DCCC: bgp_info_unlock (bgp_route.c:165)
==14497==    by 0x41DD70: bgp_info_reap (bgp_route.c:211)
==14497==    by 0x41E0FD: bgp_best_selection (bgp_route.c:1407)
==14497==    by 0x41E45E: bgp_process_main (bgp_route.c:1600)
==14497==    by 0x4E7199F: work_queue_run (workqueue.c:299)
==14497==    by 0x4E5D08F: thread_call (thread.c:1358)
==14497==    by 0x406CD9: main (bgp_main.c:489)
==14497== Address 0x6fe9960 is 64 bytes inside a block of size 112 free'd
==14497==    at 0x4C2CCF0: free (vg_replace_malloc.c:530)
==14497==    by 0x4E5F9A7: route_node_free (table.c:78)
==14497==    by 0x4E5F9A7: route_node_delete (table.c:380)
==14497==    by 0x4E5F9A7: route_unlock_node (table.c:202)
==14497==    by 0x450592: bgp_unlock_node (bgp_table.h:138)
==14497==    by 0x450592: bgp_drop_peer_nexthop (bgp_nht.c:129)
==14497==    by 0x410FE4: bgp_stop (bgp_fsm.c:460)
==14497==    by 0x411412: bgp_stop_with_error (bgp_fsm.c:603)
==14497==    by 0x412403: bgp_event (bgp_fsm.c:1180)
==14497==    by 0x4E5D08F: thread_call (thread.c:1358)
==14497==    by 0x406CD9: main (bgp_main.c:489)
==14497==  Block was alloc'd at
==14497==    at 0x4C2D988: calloc (vg_replace_malloc.c:711)
==14497==    by 0x4E5E985: zcalloc (memory.c:89)
==14497==    by 0x4E5F7C7: route_node_new (table.c:57)
==14497==    by 0x4E5F7C7: route_node_set (table.c:66)
==14497==    by 0x4E5FB92: route_node_get (table.c:312)
==14497==    by 0x450676: bgp_node_get (bgp_table.h:191)
==14497==    by 0x450676: bgp_find_or_add_nexthop (bgp_nht.c:161)
==14497==    by 0x421488: bgp_update_main (bgp_route.c:2400)
==14497==    by 0x421620: bgp_update (bgp_route.c:2466)
==14497==    by 0x423597: bgp_nlri_parse_ip (bgp_route.c:3353)
==14497==    by 0x433DB0: bgp_update_receive (bgp_packet.c:1863)
==14497==    by 0x434AAF: bgp_read (bgp_packet.c:2610)
==14497==    by 0x4E5D08F: thread_call (thread.c:1358)
==14497==    by 0x406CD9: main (bgp_main.c:489)
==14497==
==14497== Invalid read of size 4
==14497==    at 0x4E5F8DE: route_unlock_node (table.c:198)
==14497==    by 0x4504E5: bgp_unlock_node (bgp_table.h:138)
==14497==    by 0x4504E5: bgp_unlink_nexthop (bgp_nht.c:88)
==14497==    by 0x41DCCC: bgp_info_free (bgp_route.c:137)
==14497==    by 0x41DCCC: bgp_info_unlock (bgp_route.c:165)
==14497==    by 0x41DD70: bgp_info_reap (bgp_route.c:211)
==14497==    by 0x41E0FD: bgp_best_selection (bgp_route.c:1407)
==14497==    by 0x41E45E: bgp_process_main (bgp_route.c:1600)
==14497==    by 0x4E7199F: work_queue_run (workqueue.c:299)
==14497==    by 0x4E5D08F: thread_call (thread.c:1358)
==14497==    by 0x406CD9: main (bgp_main.c:489)
==14497== Address 0x6fe9958 is 56 bytes inside a block of size 112 free'd
==14497==    at 0x4C2CCF0: free (vg_replace_malloc.c:530)
==14497==    by 0x4E5F9A7: route_node_free (table.c:78)
==14497==    by 0x4E5F9A7: route_node_delete (table.c:380)
==14497==    by 0x4E5F9A7: route_unlock_node (table.c:202)
==14497==    by 0x450592: bgp_unlock_node (bgp_table.h:138)
==14497==    by 0x450592: bgp_drop_peer_nexthop (bgp_nht.c:129)
==14497==    by 0x410FE4: bgp_stop (bgp_fsm.c:460)
==14497==    by 0x411412: bgp_stop_with_error (bgp_fsm.c:603)
==14497==    by 0x412403: bgp_event (bgp_fsm.c:1180)
==14497==    by 0x4E5D08F: thread_call (thread.c:1358)
==14497==    by 0x406CD9: main (bgp_main.c:489)
==14497==  Block was alloc'd at
==14497==    at 0x4C2D988: calloc (vg_replace_malloc.c:711)
==14497==    by 0x4E5E985: zcalloc (memory.c:89)
==14497==    by 0x4E5F7C7: route_node_new (table.c:57)
==14497==    by 0x4E5F7C7: route_node_set (table.c:66)
==14497==    by 0x4E5FB92: route_node_get (table.c:312)
==14497==    by 0x450676: bgp_node_get (bgp_table.h:191)
==14497==    by 0x450676: bgp_find_or_add_nexthop (bgp_nht.c:161)
==14497==    by 0x421488: bgp_update_main (bgp_route.c:2400)
==14497==    by 0x421620: bgp_update (bgp_route.c:2466)
==14497==    by 0x423597: bgp_nlri_parse_ip (bgp_route.c:3353)
==14497==    by 0x433DB0: bgp_update_receive (bgp_packet.c:1863)
==14497==    by 0x434AAF: bgp_read (bgp_packet.c:2610)
==14497==    by 0x4E5D08F: thread_call (thread.c:1358)
==14497==    by 0x406CD9: main (bgp_main.c:489)
==14497==
==14497==
==14497== Process terminating with default action of signal 6 (SIGABRT)
==14497==    at 0x5A1B6F5: raise (in /usr/lib64/libc-2.23.so)
==14497==    by 0x5A1D2F9: abort (in /usr/lib64/libc-2.23.so)
==14497==    by 0x4E68CCB: _zlog_assert_failed (log.c:669)
==14497==    by 0x4E5F935: route_node_delete (table.c:352)
==14497==    by 0x4E5F935: route_unlock_node (table.c:202)
==14497==    by 0x4504E5: bgp_unlock_node (bgp_table.h:138)
==14497==    by 0x4504E5: bgp_unlink_nexthop (bgp_nht.c:88)
==14497==    by 0x41DCCC: bgp_info_free (bgp_route.c:137)
==14497==    by 0x41DCCC: bgp_info_unlock (bgp_route.c:165)
==14497==    by 0x41DD70: bgp_info_reap (bgp_route.c:211)
==14497==    by 0x41E0FD: bgp_best_selection (bgp_route.c:1407)
==14497==    by 0x41E45E: bgp_process_main (bgp_route.c:1600)
==14497==    by 0x4E7199F: work_queue_run (workqueue.c:299)
==14497==    by 0x4E5D08F: thread_call (thread.c:1358)
==14497==    by 0x406CD9: main (bgp_main.c:489)
==14497==
==14497== HEAP SUMMARY:
==14497==     in use at exit: 1,665,640 bytes in 36,621 blocks
==14497== total heap usage: 43,079 allocs, 6,458 frees, 3,260,645 bytes allocated
==14497==
==14497== LEAK SUMMARY:
==14497==    definitely lost: 0 bytes in 0 blocks
==14497==    indirectly lost: 0 bytes in 0 blocks
==14497==      possibly lost: 36 bytes in 1 blocks
==14497==    still reachable: 1,665,604 bytes in 36,620 blocks
==14497==         suppressed: 0 bytes in 0 blocks
==14497== Rerun with --leak-check=full to see details of leaked memory
==14497==
==14497== For counts of detected and suppressed errors, rerun with: -v
==14497== ERROR SUMMARY: 12 errors from 8 contexts (suppressed: 0 from 0)

Aborted


On Mon, 1 Aug 2016, Lou Berger wrote:

---
bgpd/bgp_fsm.c |  3 +++
bgpd/bgp_nht.c | 39 +++++++++++++++++++++++++++++++++++++++
bgpd/bgp_nht.h |  8 ++++++++
3 files changed, 50 insertions(+)

diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c
index d84a865..8001e3b 100644
--- a/bgpd/bgp_fsm.c
+++ b/bgpd/bgp_fsm.c
@@ -457,6 +457,8 @@ bgp_stop (struct peer *peer)
      BGP_EVENT_FLUSH (peer);
    }

+  bgp_drop_peer_nexthop(family2afi(peer->su.sa.sa_family), peer);
+
  /* Increment Dropped count. */
  if (peer->status == Established)
    {
@@ -721,6 +723,7 @@ bgp_start (struct peer *peer)

  bgp_find_or_add_nexthop(family2afi(peer->su.sa.sa_family), NULL, peer,
                          connected);
+
  status = bgp_connect (peer);

  switch (status)
diff --git a/bgpd/bgp_nht.c b/bgpd/bgp_nht.c
index 34b5fd1..2549e9e 100644
--- a/bgpd/bgp_nht.c
+++ b/bgpd/bgp_nht.c
@@ -90,6 +90,45 @@ bgp_unlink_nexthop (struct bgp_info *path)
    }
}

+void
+bgp_drop_peer_nexthop (afi_t afi, struct peer *peer)
+{
+  struct bgp_node *rn;
+  struct prefix p;
+
+  if (peer == NULL)
+    return;
+
+  if (afi == AFI_IP)
+    {
+      p.family = AF_INET;
+      p.prefixlen = IPV4_MAX_BITLEN;
+      p.u.prefix4 = peer->su.sin.sin_addr;
+    }
+  else if (afi == AFI_IP6)
+    {
+      p.family = AF_INET6;
+      p.prefixlen = IPV6_MAX_BITLEN;
+      p.u.prefix6 = peer->su.sin6.sin6_addr;
+    }
+  else
+    return;                     /* unknown AFI */
+
+  rn = bgp_node_get (bgp_nexthop_cache_table[afi], &p);
+
+  if (rn->info)
+    {
+      struct bgp_nexthop_cache *bnc;
+      bnc = rn->info;
+      unregister_nexthop(bnc);
+      bnc->node->info = NULL;
+      bgp_unlock_node(bnc->node);
+      bnc_free(bnc);
+    }
+
+  bgp_unlock_node (rn);
+}
+
int
bgp_find_or_add_nexthop (afi_t afi, struct bgp_info *ri, struct peer *peer,
                         int connected)
diff --git a/bgpd/bgp_nht.h b/bgpd/bgp_nht.h
index 2bced7f..08e7019 100644
--- a/bgpd/bgp_nht.h
+++ b/bgpd/bgp_nht.h
@@ -55,4 +55,12 @@ extern int bgp_find_or_add_nexthop(afi_t a, struct bgp_info 
*p,
 */
extern void bgp_unlink_nexthop(struct bgp_info *p);

+/**
+ * bgp_unlink_nexthop() - Drop the nexthop object based on a peer.
+ * ARGUMENTS:
+ *   a - afi: AFI_IP or AF_IP6
+ *   peer - The BGP peer associated with this NHT
+ */
+extern void bgp_drop_peer_nexthop(afi_t afi, struct peer *peer);
+
#endif /* _BGP_NHT_H */


--
Paul Jakma | [email protected] | @pjakma | Key ID: 0xD86BF79464A2FF6A
Fortune:
You know it's going to be a bad day when you want to put on the clothes
you wore home from the party and there aren't any.

_______________________________________________
Quagga-dev mailing list
[email protected]
https://lists.quagga.net/mailman/listinfo/quagga-dev

Reply via email to