Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bgpd: fix no bgp as-path access-list issue #15385

Closed

Conversation

fdumontet6WIND
Copy link
Contributor

router bgp 65001
no bgp ebgp-requires-policy
neighbor 192.168.1.2 remote-as external
neighbor 192.168.1.2 timers 3 10
address-family ipv4 unicast
neighbor 192.168.1.2 route-map r2 in
exit-address-family
!
ip prefix-list p1 seq 5 permit 172.16.255.31/32
!
route-map r2 permit 10
match ip address prefix-list p1
set as-path exclude 65003
route-map r2 permit 20
set as-path exclude all
!

we make the following commands

bgp as-path access-list FIRST permit ^65
bgp as-path access-list SECOND permit 2
route-map r2 permit 6
set as-path exclude as-path-access-list SECOND

and then

no bgp as-path access-list SECOND permit 2
clear bgp *

we have the following crash in bgp

           Stack trace of thread 536083:
            #0  0x00007f87f8aacfe1 raise (libpthread.so.0 + 0x12fe1)
            https://github.com/FRRouting/frr/pull/1  0x00007f87f8cf6870 core_handler (libfrr.so.0 +
	    0xf6870)
            https://github.com/FRRouting/frr/issues/2  0x00007f87f8aad140 __restore_rt (libpthread.so.0 +
	    0x13140)
            https://github.com/FRRouting/frr/issues/3  0x00007f87f89a5122 __GI___regexec (libc.so.6 +
	    0xdf122)
            https://github.com/FRRouting/frr/issues/4  0x000055d7f198b4a7 aspath_filter_exclude_acl (bgpd +
	    0x2054a7)
            https://github.com/FRRouting/frr/pull/5  0x000055d7f1902187 route_set_aspath_exclude (bgpd +
	    0x17c187)
            https://github.com/FRRouting/frr/pull/6  0x00007f87f8ce54b0 route_map_apply_ext (libfrr.so.0
	    + 0xe54b0)
            https://github.com/FRRouting/frr/pull/7  0x000055d7f18da925 bgp_input_modifier (bgpd +
	    0x154925)
            https://github.com/FRRouting/frr/pull/8  0x000055d7f18e0647 bgp_update (bgpd + 0x15a647)
            https://github.com/FRRouting/frr/issues/9  0x000055d7f18e4772 bgp_nlri_parse_ip (bgpd +
	    0x15e772)
            https://github.com/FRRouting/frr/pull/10 0x000055d7f18c38ae bgp_nlri_parse (bgpd + 0x13d8ae)
            https://github.com/FRRouting/frr/issues/11 0x000055d7f18c6b7a bgp_update_receive (bgpd +
	    0x140b7a)
            https://github.com/FRRouting/frr/pull/12 0x000055d7f18c8ff3 bgp_process_packet (bgpd +
	    0x142ff3)
            https://github.com/FRRouting/frr/pull/13 0x00007f87f8d0dce0 thread_call (libfrr.so.0 +
	    0x10dce0)
            https://github.com/FRRouting/frr/issues/14 0x00007f87f8cacb28 frr_run (libfrr.so.0 + 0xacb28)
            https://github.com/FRRouting/frr/pull/15 0x000055d7f18435da main (bgpd + 0xbd5da)
            https://github.com/FRRouting/frr/issues/16 0x00007f87f88e9d0a __libc_start_main (libc.so.6 +
	    0x23d0a)
            https://github.com/FRRouting/frr/issues/17 0x000055d7f18415fa _start (bgpd + 0xbb5fa)

analysis

crash is due to the fact that there were always a pointer from
as-path exclude to deleted as-path access list.

fix
we add a backpointer mechanism to manage the dependency beetween
as-path access-list and aspath exclude.

@frrbot frrbot bot added bgp bugfix tests Topotests, make check, etc labels Feb 16, 2024
donaldsharp and others added 5 commits February 16, 2024 16:15
SA finds this:

error	14-Feb-2024 14:52:24	ospfd/ospf_te.c:3962:2: warning: Value stored to 'sub' is never read [deadcode.DeadStores]
error	14-Feb-2024 14:52:24	        sub = 0;
error	14-Feb-2024 14:52:24	        ^     ~
error	14-Feb-2024 14:52:24	1 warning generated.

Signed-off-by: Donald Sharp <[email protected]>
SA Reports:

bgpd/bgp_rpki.c:1085:24: warning: Value stored to 'group' during its initialization is never read [deadcode.DeadStores]
        struct rtr_mgr_group *group = get_connected_group(rpki_vrf);
                              ^~~~~   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Donald Sharp <[email protected]>
Set static router-id for OSPF, because otherwise it depends on timing of
router-id updates received from zebra and may differ between test runs.

Signed-off-by: Igor Ryzhov <[email protected]>
adding a tests about:
"no bgp as-path access-list" command.

the folloxing "clear bgp *" command leads to the
crash exhibited above.

a sleep had been added to capture the crash befor the end of scenario.

50	../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
[Current thread is 1 (Thread 0x7f5f05cbb9c0 (LWP 1371086))]
(gdb) bt
    context=0x7ffcf2c216c0) at lib/sigevent.c:248
    acl_list=0x55c976ec03c0) at bgpd/bgp_aspath.c:1688
    dummy=0x7ffcf2c22340, object=0x7ffcf2c21e70) at bgpd/bgp_routemap.c:2401
    match_object=0x7ffcf2c21e70, set_object=0x7ffcf2c21e70, pref=0x0)
    at lib/routemap.c:2687
    attr=0x7ffcf2c220b0, afi=AFI_IP, safi=SAFI_UNICAST, rmap_name=0x0, label=0x0,
    num_labels=0, dest=0x55c976ebeaf0) at bgpd/bgp_route.c:1807
    addpath_id=0, attr=0x7ffcf2c22450, afi=AFI_IP, safi=SAFI_UNICAST, type=10,
    sub_type=0, prd=0x0, label=0x0, num_labels=0, soft_reconfig=0, evpn=0x0)
    at bgpd/bgp_route.c:4424
    packet=0x7ffcf2c22410) at bgpd/bgp_route.c:6266
    packet=0x7ffcf2c22410, mp_withdraw=false) at bgpd/bgp_packet.c:341
    peer=0x55c976e89ed0, size=43) at bgpd/bgp_packet.c:2414
    at bgpd/bgp_packet.c:3899

Signed-off-by: Francois Dumontet <[email protected]>
router bgp 65001
 no bgp ebgp-requires-policy
 neighbor 192.168.1.2 remote-as external
 neighbor 192.168.1.2 timers 3 10
 address-family ipv4 unicast
  neighbor 192.168.1.2 route-map r2 in
 exit-address-family
!
ip prefix-list p1 seq 5 permit 172.16.255.31/32
!
route-map r2 permit 10
 match ip address prefix-list p1
 set as-path exclude 65003
route-map r2 permit 20
 set as-path exclude all
!

we make the following commands

bgp as-path access-list FIRST permit ^65
bgp as-path access-list SECOND permit 2
 route-map r2 permit 6
  set as-path exclude as-path-access-list SECOND

and then

no bgp as-path access-list SECOND permit 2
clear bgp *

we have the following crash in bgp

               Stack trace of thread 536083:
                #0  0x00007f87f8aacfe1 raise (libpthread.so.0 + 0x12fe1)
                FRRouting#1  0x00007f87f8cf6870 core_handler (libfrr.so.0 +
		    0xf6870)
                FRRouting#2  0x00007f87f8aad140 __restore_rt (libpthread.so.0 +
		    0x13140)
                FRRouting#3  0x00007f87f89a5122 __GI___regexec (libc.so.6 +
		    0xdf122)
                FRRouting#4  0x000055d7f198b4a7 aspath_filter_exclude_acl (bgpd +
		    0x2054a7)
                FRRouting#5  0x000055d7f1902187 route_set_aspath_exclude (bgpd +
		    0x17c187)
                FRRouting#6  0x00007f87f8ce54b0 route_map_apply_ext (libfrr.so.0
		    + 0xe54b0)
                FRRouting#7  0x000055d7f18da925 bgp_input_modifier (bgpd +
		    0x154925)
                FRRouting#8  0x000055d7f18e0647 bgp_update (bgpd + 0x15a647)
                FRRouting#9  0x000055d7f18e4772 bgp_nlri_parse_ip (bgpd +
		    0x15e772)
                FRRouting#10 0x000055d7f18c38ae bgp_nlri_parse (bgpd + 0x13d8ae)
                FRRouting#11 0x000055d7f18c6b7a bgp_update_receive (bgpd +
		    0x140b7a)
                FRRouting#12 0x000055d7f18c8ff3 bgp_process_packet (bgpd +
		    0x142ff3)
                FRRouting#13 0x00007f87f8d0dce0 thread_call (libfrr.so.0 +
		    0x10dce0)
                FRRouting#14 0x00007f87f8cacb28 frr_run (libfrr.so.0 + 0xacb28)
                FRRouting#15 0x000055d7f18435da main (bgpd + 0xbd5da)
                FRRouting#16 0x00007f87f88e9d0a __libc_start_main (libc.so.6 +
		    0x23d0a)
                FRRouting#17 0x000055d7f18415fa _start (bgpd + 0xbb5fa)

analysis

crash is due to the fact that there were always a pointer from
as-path exclude to deleted as-path access list.

fix
we add a backpointer mechanism to manage the dependency beetween
as-path access-list  and aspath exclude.

signed-off-by: Francois Dumontet <[email protected]>
@fdumontet6WIND fdumontet6WIND deleted the aspath_exclude_bp branch February 16, 2024 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants