Commit graph

37295 commits

Author SHA1 Message Date
Jafar Al-Gharaibeh ba60b39f13
Merge pull request #17154 from donaldsharp/connected_coverity
zebra: Fix possible null deref discovered by coverity
2024-10-17 15:32:46 -05:00
Liam Brady 1b38f33041 tests: logger masked in topotest.py
a local logger masks the global logger and prevents errors from being
gracefully handled within topotest.py

Signed-off-by: Liam Brady <lbrady@labn.net>
2024-10-17 13:36:39 -04:00
Donald Sharp d11ad98ffb lib: Correctly handle ppoll pfds.events == 0
The frrevent system is spitting out this message in bgpd:
20:40:15 mem1-roc-f2-b1-r5-t2-d4 bgpd[13166]: [XETTR-D5MR0][EC 100663316] Attempting to process an I/O event but for fd: 214(8) no thread to handle this!

This is because as each io event is processed, it is possible that a
.events is set to 0.  This can leave a situation where we ask
ppoll to handle anything that happens on a fd with a .events of 0,
in this situation ppoll can return POLLERR, which indicates that
something bad has happened on the fd.

Let's set the ppoll fds.fd value to -1 when there are no more
events to be processed.  ppoll specifically calls out that
it will just skip this particular one.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-10-17 11:07:55 -04:00
David Lamparter b3e4007197 lib: refactor memstats logging, fix ACTIVEATEXIT
Move the various destinations handling into lib/memory.c, include
"normal" logging as target, and make `ACTIVEATEXIT` properly non-error
as it was intended to be.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-10-17 13:58:57 +02:00
David Lamparter f177663631 lib: do not log_memstats() in crash handler
`log_memstats()` is not AS-safe.  It can hang the crash handler (or set
your PC on fire, or cause the sun to go supernova - according to POSIX
specs, anyway.)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-10-17 13:58:57 +02:00
David Lamparter e95fbc1d8c lib: zlog stays running on shutdown
No `zlog_fini()`, please.  Getting log messages until the end is more
important than leaking memory allocated for zlog targets.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-10-17 13:58:57 +02:00
David Lamparter b7420c46de lib: actually propagate MGROUP args
Well, this was only checked for exit status, which we didn't really
observe... so, uh, yeah, not particularly noticeable it wasn't even
wired up...

clang-format off/on added to not get formatting wrecked on this.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-10-17 13:58:39 +02:00
Donald Sharp 5a2a9e3b89 zebra: Fix possible null deref discovered by coverity
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-10-17 07:42:47 -04:00
Donald Sharp 466efab870
Merge pull request #17136 from opensourcerouting/clang-sa-19
*: fix clang-19 SA
2024-10-17 07:38:28 -04:00
Shbinging 71aa5ab7f6 ospfd: update ospf_asbr_status when using no_area_nssa command
In the processing of nssa, if the number of areas that need to be translated is greater than 0, then abr will be regarded as asbr, and it will be marked (0x3) in the flag of router lsa. When a certain area is set from nssa to a normal area, the areas that need to be translated may be reduced. The asbr should be re-interpreted as abr when the translated area is 0.

Signed-off-by: Shbinging <bingshui@smail.nju.edu.cn>
2024-10-17 06:37:21 +00:00
Donatas Abraitis 5fecb1f425
Merge pull request #17065 from Shbinging/fix_some_ospf_commands
ospfd: fix some ospf commands
2024-10-17 09:01:30 +03:00
Donatas Abraitis 8d894e5df0
Merge pull request #17091 from enkechen-panw/aigp-fix1
bgpd: fix several issues in sourcing AIGP attribute
2024-10-17 08:55:03 +03:00
Enke Chen 51612593f7 tests: add a new topotest to bgp_aigp
Add a new topotest for getting the aigp from the "igp-metric"
for a redistributed route (ospf route in the test).

Signed-off-by: Enke Chen <enchen@paloaltonetworks.com>
2024-10-16 11:19:28 -07:00
Enke Chen f65356d8bb bgpd: fix several issues in sourcing AIGP attribute
Fix several issues in sourcing AIGP attribute:

1) AIGP should not be set as default for a redistributed route or a
   static network. It should be set by config instead.

2) AIGP sourced by "set aigp-metric igp-metric" in a route-map does
   not set the correct value for a redistributed route.

3) When redistribute a connected route like loopback, the AGIP (with
   value 0) is sourced by "set aigp-metric igp-metric", but the
   attribute is not propagated as the attribute flag is not set.

Signed-off-by: Enke Chen <enchen@paloaltonetworks.com>
2024-10-16 11:15:28 -07:00
Russ White 75e34c032b
Merge pull request #16452 from louis-6wind/fix-ipv4-mapped-ipv6-display
lib, test: fix display ipv4 mapped ipv6 addresses
2024-10-16 13:01:52 -04:00
Donatas Abraitis 1ce225d7e4
Merge pull request #17076 from donaldsharp/rnh_and_redistribution_nexthop_num_fix
*: Fix up improper handling of nexthops for nexthop tracking
2024-10-16 16:34:08 +03:00
Donald Sharp cc63dbb68f
Merge pull request #17020 from pguibert6WIND/asan_shutdown
zebra: fix heap-use-after free on ns shutdown
2024-10-16 09:15:06 -04:00
Russ White 80dc863d92
Merge pull request #16946 from opensourcerouting/fix/match_src-peer
bgpd: Implement match src-peer ... command
2024-10-16 07:51:20 -04:00
Louis Scalbert 3c430cd4e0 tests: update fuzz after ipv4 mapped ipv6 print change
Update IS-IS fuzz test to match corrected output after change in the
display of IPv4 mapped IPv6 address.

The update was performed using wuschl [1] like this:

$ wuschl rebuild tests/isisd/test_fuzz_isis_tlv
$ gzip -9 tests/isisd/test_fuzz_isis_tlv_tests.h

[1] https://pypi.org/project/wuschl/

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-10-16 13:45:54 +02:00
Louis Scalbert 84ab0213fc lib, test: fix display ipv4 mapped ipv6 addresses
Display ipv4 mapped ipv6 addresses in the format ::ffff:A.B.C.D.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-10-16 13:45:46 +02:00
David Lamparter b5f196c35a bgpd: hide read() call from clang-SA
Sigh. clang-SA doesn't want you to call read() while holding a mutex.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-10-16 13:30:25 +02:00
David Lamparter e6cb1a90f2 zebra: check dirfd() result
`dirfd()` can theoretically return an error.  Call it once and check the
result.

clang-SA: technically correct™.  Ain't that the best kind of correct?

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-10-16 13:30:25 +02:00
David Lamparter 67b0a457ed zebra: don't misappropriate errno
`errno` has its own semantics.  Sometimes it is correct to write to it.
This is not one of those cases - just use a separate `nl_errno`.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-10-16 13:30:25 +02:00
David Lamparter 1350f8d1c1 zebra: don't try to read past EOF
`FILE *` objects are theoretically in an invalid state if you try to use
them past their reporting EOF.  Adjust the code to make it correct.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-10-16 13:30:25 +02:00
David Lamparter e8006bc2cb vtysh: make clang-SA happy about reusing stdin
While the logic here is perfectly fine, clang-SA doesn't understand that
the fopen() and fclose() match up with each other.  Just use a separate
variable to make clang-SA happy.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-10-16 13:30:25 +02:00
David Lamparter 42d468800d vtysh: remove duplicate nonblocking handling
non-blocking retries are already handled in `vtysh_client_receive()`.
And by the point we're back in `vtysh_client_run()`, errno may have been
overwritten by the close() call in vtysh_client_receive().

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-10-16 13:30:25 +02:00
David Lamparter 74b9f0ae74 ldpd: free previous config if it wasn't applied
If a create-config command is received, but the config is never applied,
the config will be leaked on the next create-config command.  This
should theoretically never happen, but let's fix it anyway.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-10-16 13:30:25 +02:00
David Lamparter 4a3843e8d2 pimd: MLD packets always have an interface
If a packet doesn't have an interface, we're gonna crash 2 lines below.
An assert is a little more useful... and makes clang-SA not complain
about it.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-10-16 13:30:25 +02:00
David Lamparter 6476f9deac pimd: mark rest-of-packet ignored in C-RP parse
The `buf` pointer is being updated as the parse goes along.  It's not
used after the last update, but I'd rather keep this in for consistency.
Just make a note of it being unused.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-10-16 13:30:25 +02:00
David Lamparter 3ce0fe0e08 pimd: initialize prefix value in Auto-RP
clang-SA complains that it's only partially initialized (because it's
used with IPv4 only).  The code later calls some AF-generic code,
prompting clang-SA to complain that the non-IPv4 parts are used without
being set.  While this shouldn't happen, just initialize it fully.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-10-16 13:30:25 +02:00
David Lamparter 17f512c10d lib: fix invalid use of errno in PTM
errno is only valid if there was an actual error.  A zero return value
isn't an error, it's either EOF or an empty datagram depending on
context.  Fix the logic.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-10-16 13:30:25 +02:00
David Lamparter a67df2a17f lib: guard close() in netns code
clang-SA complains that ns->fd could be invalid.  Add a guard.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-10-16 13:30:25 +02:00
David Lamparter 40d4a47c0e lib: make clang-SA not choke on defun_lex.l
The flex-generated code is disabled for clang-SA builds already, but
that means that function prototypes are missing too.  Just add dummy
function prototypes so clang-SA can process the file.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-10-16 13:30:25 +02:00
David Lamparter c071b4370d *: clang-SA switch-enum initializer workarounds
In these cases the value assigned by the switch block is used directly
rather than returned.  Mark the initial/default value as used so
clang-SA doesn't complain about it.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-10-16 13:30:25 +02:00
David Lamparter 49cf311d46 *: clang-SA friendly switch-enum-return-string
clang-19's SA complains about unused initializers for this kind of
"switch (enum) { return string }" kind of code.  Use direct string
return values to avoid the issue.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-10-16 13:00:11 +02:00
Donatas Abraitis 40dce0be6a
Merge pull request #17114 from Jafaral/getenv
vtysh: fix SA warning, no need to call getenv() twice
2024-10-16 10:50:02 +03:00
Donatas Abraitis c32bdc2469
Merge pull request #17116 from enkechen-panw/zfix-2
zebra: unlock node only after operation in zebra_free_rnh()
2024-10-16 08:12:28 +03:00
Donatas Abraitis e17bc281ef
Merge pull request #17126 from donaldsharp/ospf_lsa_declarations
ospfd: Fixup ospf_lsa.[ch] to properly spell out parameters for funct…
2024-10-16 08:10:27 +03:00
Shbinging 774788d4c8 ospfd: fix no area shortcut MODE command, MODE can be default
Signed-off-by: Shbinging <bingshui@smail.nju.edu.cn>
2024-10-16 04:39:20 +00:00
Jafar Al-Gharaibeh df482a0f79
Merge pull request #17107 from donaldsharp/actuallY_call_the_command
tests: iproute2_check_path_selection call the actual command
2024-10-15 21:24:33 -05:00
Donald Sharp 573d807adf ospfd: Fixup ospf_lsa.[ch] to properly spell out parameters for functions
Our standard says when in a .h file and declaring a function all parameters
must have their variables spelled out.  Let's do this for ospf_lsa.h

Modified ospf_lsa.c to also use event instead of thread, and uint8_t instead
of unsigned short.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-10-15 18:32:14 -04:00
Russ White de02471a8d
Merge pull request #17038 from opensourcerouting/feature/bgp_set_metric_internal
bgpd: Derive and set MED from IGP or AIGP
2024-10-15 17:58:05 -04:00
Jafar Al-Gharaibeh b2eaf86fb5
Merge pull request #15586 from donaldsharp/nht_explain_doc
zebra: Attempt to explain the rnh tracking code better
2024-10-15 14:25:35 -05:00
Jafar Al-Gharaibeh b23bbb885a
Merge pull request #17088 from donaldsharp/connected_kernel_fun
zebra: Prevent a kernel route from being there when a connected should
2024-10-15 14:04:51 -05:00
Russ White 5b5756911c
Merge pull request #17073 from louis-6wind/fix-ipv6-ll-nexthop-reflector
bgpd, tests: don't send local nexthop from rr client
2024-10-15 14:18:49 -04:00
Enke Chen 5b6ff51b8a zebra: unlock node only after operation in zebra_free_rnh()
Move route_unlock_node() after rnh_list_del().

Signed-off-by: Enke Chen <enchen@paloaltonetworks.com>
2024-10-15 10:25:46 -07:00
Donald Sharp 24296c6cde
Merge pull request #17104 from opensourcerouting/frr-format-array-crash
tools/gcc-plugins: don't crash on array parameters
2024-10-15 13:22:54 -04:00
Donald Sharp 28237d73ad zebra: Attempt to explain the rnh tracking code better
I got asked today what was going on in the rnh code.  I
had to take time off of what I was doing and rewrap my
head around this code, since it's been a long time.
As that this question may come up again in the future
I am trying to document this better so that someone
coming behind us will be able to read this and get
a better idea of what the algorithm is attempting
to do.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-10-15 12:42:17 -04:00
Jafar Al-Gharaibeh 38661a6aa5 vtysh: fix SA warning, no need to call getenv() twice
Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
2024-10-15 11:11:03 -05:00
Donald Sharp 645a9e4f83 *: Fix up improper handling of nexthops for nexthop tracking
Currently FRR needs to send a uint16_t value for the number
of nexthops as well it needs the ability to properly decode
all of this.  Find and handle all the places that this happens.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-10-15 11:57:23 -04:00