Commit Graph

37295 Commits

Author SHA1 Message Date
Donald Sharp
28df4462c3
Merge pull request #16583 from mjstapp/fix_all_proto_nhg
tests: add retries to nhg tests in all_proto_startup
2024-08-14 14:54:27 -04:00
Donatas Abraitis
b57cb7a8e8
Merge pull request #16574 from donaldsharp/non_json_free_ptr
bgpd: Free up non-freed json memory on function return
2024-08-14 18:44:54 +02:00
Donald Sharp
b0c86804f8 tests: Fix route_scale startup issues
Upstream CI is frequently running into a situation where
the routes are not being installed.  These routes
start at the beginning and suddenly in the middle
they start working properly.

D   1.0.15.183/32 [150/0] via 192.168.0.1, r1-eth0 inactive, weight 1, 00:10:17
                          via 192.168.1.1, r1-eth1 inactive, weight 1, 00:10:17
D   1.0.15.184/32 [150/0] via 192.168.0.1, r1-eth0 inactive, weight 1, 00:10:17
                          via 192.168.1.1, r1-eth1 inactive, weight 1, 00:10:17
D   1.0.15.185/32 [150/0] via 192.168.0.1, r1-eth0 inactive, weight 1, 00:10:17
                          via 192.168.1.1, r1-eth1 inactive, weight 1, 00:10:17
D>* 1.0.15.186/32 [150/0] via 192.168.0.1, r1-eth0, weight 1, 00:10:17
  *                       via 192.168.1.1, r1-eth1, weight 1, 00:10:17
D>* 1.0.15.187/32 [150/0] via 192.168.0.1, r1-eth0, weight 1, 00:10:17
  *                       via 192.168.1.1, r1-eth1, weight 1, 00:10:17
D>* 1.0.15.188/32 [150/0] via 192.168.0.1, r1-eth0, weight 1, 00:10:17

Turning on some debugs showed that the failed installed routes are
trying to be matched against the default route.  Thus implying
all the connected routes for the test are not yet successfully
installed.  Let's modify the test(s) on startup to just ensure
that the connected routes are installed correctly.  I am no
longer seeing the problem after this change.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-08-14 10:18:41 -04:00
Philippe Guibert
64594f8a68 bgpd: fix memory type for static->prd_pretty
A crash happens when executing the following command:

> ubuntu2204hwe# conf
> ubuntu2204hwe(config)# router bgp 65500
> ubuntu2204hwe(config-router)#  !
> ubuntu2204hwe(config-router)#  address-family ipv4 unicast
> ubuntu2204hwe(config-router-af)#   sid vpn export auto
> ubuntu2204hwe(config-router-af)#  exit-address-family
> ubuntu2204hwe(config-router)#  !
> ubuntu2204hwe(config-router)#  address-family ipv4 vpn
> ubuntu2204hwe(config-router-af)#   network 4.4.4.4/32 rd 55:55 label 556
> ubuntu2204hwe(config-router-af)#   network 5.5.5.5/32 rd 662:33 label 232
> ubuntu2204hwe(config-router-af)#  exit-address-family
> ubuntu2204hwe(config-router)# exit
> ubuntu2204hwe(config)# !
> ubuntu2204hwe(config)# no router bgp

The crash analysis indicates a memory item has been freed.

> #6  0x000076066a629c15 in mt_count_free (mt=0x56b57be85e00 <MTYPE_BGP_NAME>, ptr=0x60200038b4f0)
>     at lib/memory.c:73
> #7  mt_count_free (ptr=0x60200038b4f0, mt=0x56b57be85e00 <MTYPE_BGP_NAME>) at lib/memory.c:69
> #8  qfree (mt=mt@entry=0x56b57be85e00 <MTYPE_BGP_NAME>, ptr=0x60200038b4f0) at lib/memory.c:129
> #9  0x000056b57bb09ce9 in bgp_free (bgp=<optimized out>) at bgpd/bgpd.c:4120
> #10 0x000056b57bb0aa73 in bgp_unlock (bgp=<optimized out>) at ./bgpd/bgpd.h:2513
> #11 peer_free (peer=0x62a000000200) at bgpd/bgpd.c:1313
> #12 0x000056b57bb0aca8 in peer_unlock_with_caller (name=<optimized out>, peer=<optimized out>)
>     at bgpd/bgpd.c:1344
> #13 0x000076066a6dbb2c in event_call (thread=thread@entry=0x7ffc8cae1d60) at lib/event.c:2011
> #14 0x000076066a60aa88 in frr_run (master=0x613000000040) at lib/libfrr.c:1214
> #15 0x000056b57b8b2c44 in main (argc=<optimized out>, argv=<optimized out>) at bgpd/bgp_main.c:543

Actually, the BGP_NAME item has not been used at allocation for
static->prd_pretty, and this results in reaching 0 quicker at bgp
deletion.

Fix this by reassigning MTYPE_BGP_NAME to prd_pretty.

Fixes: 16600df2c4 ("bgpd: fix show run of network route-distinguisher")

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2024-08-14 15:41:40 +02:00
Donald Sharp
9356e3fdb0
Merge pull request #16579 from opensourcerouting/fix/bgpd_use_after_free_no_router_bgp
bgpd: Avoid use-after-free when doing `no router bgp` with auto created instances
2024-08-14 08:39:25 -04:00
Mark Stapp
dd146614df tests: add retries to nhg tests in all_proto_startup
The all_protocol_startup topotest needs to allow for some delay
between configuring nexthop-groups and their installation. Add
some wait periods in a couple of nhg test cases.

Signed-off-by: Mark Stapp <mjs@cisco.com>
2024-08-14 08:37:00 -04:00
Donatas Abraitis
464212db08 bgpd: Avoid use-after-free when doing no router bgp with auto created instances
```
==1145965==ERROR: AddressSanitizer: heap-use-after-free on address 0x6030007159c0 at pc 0x55ade8d962d1 bp 0x7ffec4ce74c0 sp 0x7ffec4ce74b0
READ of size 8 at 0x6030007159c0 thread T0
    0 0x55ade8d962d0 in no_router_bgp bgpd/bgp_vty.c:1701
    1 0x7efe5aed19ed in cmd_execute_command_real lib/command.c:1002
    2 0x7efe5aed1da3 in cmd_execute_command lib/command.c:1061
    3 0x7efe5aed2303 in cmd_execute lib/command.c:1227
    4 0x7efe5af6c023 in vty_command lib/vty.c:616
    5 0x7efe5af6d2d2 in vty_execute lib/vty.c:1379
    6 0x7efe5af77df2 in vtysh_read lib/vty.c:2374
    7 0x7efe5af64c9b in event_call lib/event.c:1996
    8 0x7efe5af03887 in frr_run lib/libfrr.c:1232
    9 0x55ade8cd9850 in main bgpd/bgp_main.c:555
    10 0x7efe5aa29d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    11 0x7efe5aa29e3f in __libc_start_main_impl ../csu/libc-start.c:392
    12 0x55ade8cdc314 in _start (/usr/lib/frr/bgpd+0x16f314)
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-08-14 10:16:01 +03:00
Mark Stapp
e03feca82f
Merge pull request #16575 from donaldsharp/doc_address_sanitizer_stuff
doc: Add doc to show sysctl setting for Sanitizers
2024-08-13 14:18:40 -04:00
Donald Sharp
90a50fd4af
Merge pull request #16576 from opensourcerouting/fix/free_opaque_data_of_route_entry
zebra: Do not forget to free opaque data for route entry
2024-08-13 14:14:36 -04:00
Donald Sharp
68fff49056 babeld: Free up memory on shutdown
a) call vector_delete on created vector on shutdown.
b) Call babel_clean_routing_process on shutdown

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-08-13 14:12:05 -04:00
Donald Sharp
f01205bb96 pbrd: Call vrf_terminate on shutdown
Free up vrf memory on shutdown.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-08-13 14:11:07 -04:00
Donatas Abraitis
1e288c9b55 zebra: Do not forget to free opaque data for route entry
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-08-13 18:00:30 +03:00
Donatas Abraitis
b0bb8cbfcf
Merge pull request #16559 from donaldsharp/fix_python_warning
tests: Fix bgp_duplicate_nexthop python warning
2024-08-13 16:20:27 +02:00
Donald Sharp
2de9d71a5c doc: Add doc to show sysctl setting for Sanitizers
In order to run the XXXX Sanitizers over the code as a developer
modern linux distro's require a specific sysctl.  Let's document
that so that people are aware of it.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-08-13 08:58:29 -04:00
Donald Sharp
ce4e451c5b bgpd: Free up non-freed json memory on function return
json_peers is allocated in the above if statement block
for json but is not freed in this code path.  Noticed
by running Address Sanitizer.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-08-13 08:49:01 -04:00
Donald Sharp
847d74a5b0
Merge pull request #16558 from nabahr/pim_doc
doc: Fix up pim user docs.
2024-08-13 08:47:27 -04:00
Donatas Abraitis
b4e4fb476a
Merge pull request #16557 from donaldsharp/pathd_shutdown_memory_leaks
pathd: Cleanup shutdown memory leaks
2024-08-12 23:45:32 +03:00
Donatas Abraitis
74333790e3
Merge pull request #16555 from donaldsharp/agentx_event_leak
lib: Fix memory leak in snmp on shutdown
2024-08-12 23:45:14 +03:00
Nathan Bahr
33ce5d2410 doc: Fix up pim user docs.
Signed-off-by: Nathan Bahr <nbahr@atcorp.com>
2024-08-12 18:48:02 +00:00
Donald Sharp
1563d9f9c8 tests: Fix bgp_duplicate_nexthop python warning
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-08-12 13:55:26 -04:00
Donald Sharp
c4fdc837c0
Merge pull request #16534 from opensourcerouting/fix/start_ldpd_if_unified
doc: Document on how to start specific daemons with unified config in topotests
2024-08-12 10:25:54 -04:00
Donald Sharp
33af3c0278 pathd: Cleanup shutdown memory leaks
Just some code to cleanup the shutdown memory leaks
that are in pathd.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-08-12 10:14:31 -04:00
Donald Sharp
b8b38a593c lib: Fix memory leak in snmp on shutdown
The events list is storing a `struct event *` allocated
as a MTYPE_TMP pointer, on shutdown ensure that it is
properly free'd up.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-08-12 08:51:19 -04:00
Donatas Abraitis
cc0fdd3b1d
Merge pull request #16439 from louis-6wind/fix-ipv4-mapped-ipv6
bgpd: fixes for ipv4 mapped ipv6 address
2024-08-12 15:37:36 +03:00
Donatas Abraitis
4e208087fd
Merge pull request #16545 from mjstapp/fix_isis_threeway
isisd: fix memory handling in isis_adj_process_threeway()
2024-08-12 09:39:45 +03:00
Donatas Abraitis
1d5f0a2beb
Merge pull request #16556 from donaldsharp/mgmt_ignore
mgmtd: Add to .gitignore for mgmtd_testc program
2024-08-12 09:39:22 +03:00
Donatas Abraitis
8c936d44d0
Merge pull request #16420 from pguibert6WIND/trap_rfc4382
bgpd: add bgp snmp traps rfc4382 command
2024-08-12 09:38:58 +03:00
Donatas Abraitis
263eb6d141
Merge pull request #16554 from donaldsharp/zebra_ensure_no_use_after_free
zebra: Ensure non-equal id's are not same nhg's
2024-08-12 07:59:42 +03:00
Philippe Guibert
d95f9a35d4 bgpd, doc: add bgp snmp traps rfc4382 command
Add a trap command to disable or enable the traps defined by
the RFC4382.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2024-08-11 19:28:50 +00:00
Donatas Abraitis
4ace11d010 bgpd: Move evpn_overlay to a pointer
Before this convertion:

```
	/* --- cacheline 3 boundary (192 bytes) --- */
	struct bgp_attr_encap_subtlv * encap_subtlvs;    /*   192     8 */
	struct bgp_attr_encap_subtlv * vnc_subtlvs;      /*   200     8 */
	struct bgp_route_evpn      evpn_overlay;         /*   208    36 */
```

After this convertion:

```
	/* --- cacheline 3 boundary (192 bytes) --- */
	struct bgp_attr_encap_subtlv * encap_subtlvs;    /*   192     8 */
	struct bgp_attr_encap_subtlv * vnc_subtlvs;      /*   200     8 */
	struct bgp_route_evpn *    evpn_overlay;         /*   208     8 */
```

Saving 28 bytes when EVPN is not used.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-08-11 13:59:13 +03:00
Donatas Abraitis
3901cfea23 doc: Document on how to run specific daemons with unified config in topotests
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-08-11 13:47:08 +03:00
Donatas Abraitis
79cbde8095 tests: Convert self.unified_config to boolean
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-08-11 13:32:11 +03:00
Donatas Abraitis
423e8076b5
Merge pull request #16542 from donaldsharp/vtysh_stupidly_large
lib: Don't print warning if not a daemon
2024-08-11 11:43:46 +03:00
Donald Sharp
0ec96ab525 mgmtd: Add to .gitignore for mgmtd_testc program
This program, mgmtd_testc, is built with the
--enable-mgmtd-test-be-client configure option
but it is not .gitignore'd.  Let's fix that

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-08-10 20:21:27 -04:00
Donald Sharp
3875588ece
Merge pull request #16548 from opensourcerouting/fix/reduce_attr_a_bit
Shrink a couple bytes of struct attr
2024-08-10 19:51:10 -04:00
Donald Sharp
c79599e497
Merge pull request #16551 from idryzhov/distrib-del
lib: fix distribute-list deletion
2024-08-10 19:50:26 -04:00
Donald Sharp
5a1b61aeba zebra: Ensure non-equal id's are not same nhg's
The function zebra_nhg_hash_equal is only used
as a hash function for storage of NHG's and retrieval.
If you have say two nhg's:

31 (25/26)
32 (25/26)

This function would return them as being equal.  Which
of course leads to the problem when you attempt to
hash_release 32 but release 31 from the hash.  Then later
when you attempt to do hash comparisons 32 has actually
been freed leaving to use after free situations and shit
goes down hill fast.

This hash is only used as part of the hash comparison
function for nexthop group storage.  Since this is so
let's always return the 31/32 nhg's are not equal at all.

We possibly have a different problem where we are creating
31 and 32 ( when 31 should have just been used instead of 32 )
but we need to prevent any type of hash release problem at all.
This supercedes any other issue( that should be tracked down
on it's own ).  Since you can have use after free situation
that leads to a crash -vs- some possible nexthop group duplication
which is very minor in comparison.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-08-10 19:49:35 -04:00
Christian Hopps
8cc83201fc
Merge pull request #16529 from idryzhov/fix-load-config
mgmtd: don't add implicit state data when reading config from file
2024-08-10 04:10:34 -04:00
Christian Hopps
64ac03c90b
Merge pull request #16511 from oplklum/master
Fix LYD_NEW_PATH_OUTPUT issue to support libyang v3.x
2024-08-10 03:46:11 -04:00
Lu.Mao
87c9060f90 lib: Fix LYD_NEW_PATH_OUTPUT issue to support libyang v3.x
Fix the LYD_NEW_PATH_OUTPUT undeclared error to support the latest libyang v3.x version,
and also compatible with old version.

Signed-off-by: Lu Mao <lu.mao@molex.com>
2024-08-09 17:32:37 -07:00
Igor Ryzhov
8fad4f317e lib: fix distribute-list deletion
When a whole distribute-list is deleted (can be done only using API),
all its children must be cleaned up manually.

Fixes #16538

Signed-off-by: Igor Ryzhov <idryzhov@gmail.com>
2024-08-10 01:36:15 +03:00
Donatas Abraitis
5c84cddab8 bgpd: Shrink rmap_change_flags to 2-bytes
4 bytes is not needed for this thing clearly.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-08-09 21:33:50 +03:00
Donatas Abraitis
8b66a236e8 bgpd: Reduce encap_tunneltype to 1 byte
It's not used as a bitmask, no point to use it as 2 bytes.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-08-09 21:33:46 +03:00
Mark Stapp
3eb7d16411 isisd: fix memory handling in isis_adj_process_threeway()
The adj_process_threeway() api may call the adj_state_change()
api, which may delete the adj struct being examined. Change the
signature so that callers pass a ptr-to-ptr so that they will
see that deletion.

Signed-off-by: Mark Stapp <mjs@cisco.com>
2024-08-09 10:08:21 -04:00
Donatas Abraitis
927be7a50e
Merge pull request #16539 from donaldsharp/tests_memory_shut
Tests memory shut
2024-08-09 13:30:30 +03:00
Donatas Abraitis
536d478049
Merge pull request #16535 from pguibert6WIND/srv6_nexthop_context
lib: add seg6localContext json attribute in nexthop information
2024-08-08 22:39:34 +03:00
Donald Sharp
cecf5716d5 lib: Don't print warning if not a daemon
vtysh will print out the `stupidly large FD limit` upon
every run of the program if the ulimit is set stupidly
large.  Prevent this from being displayed for vtysh.

Fixes: #16516
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-08-08 15:26:41 -04:00
Donald Sharp
7b8ca3e2ed
Merge pull request #16531 from idryzhov/fix-rip-show-distrib
ripd: fix show run output for distribute-list
2024-08-08 14:28:32 -04:00
Donald Sharp
208c53c90e isisd, lib: Cleanup linked list associated with snmp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-08-08 14:24:59 -04:00
Donald Sharp
db986aded4 lib: Cleanup memory associated with modules on shutdown
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-08-08 14:24:59 -04:00