Commit graph

6199 commits

Author SHA1 Message Date
Igor Ryzhov 6f214d97d1 lib, zebra: move ns context intialization to zebra
vrf->ns_ctxt is only ever used in zebra, so move its initialization to
zebra's callback. Ideally this pointer shouldn't even be a part of
library's vrf struct, and moved to zebra-specific struct, but this is
the first step.

Signed-off-by: Igor Ryzhov <idryzhov@gmail.com>
2025-01-15 23:38:27 +02:00
Igor Ryzhov 4877f2f685 lib: remove VRF_BACKEND_UNKNOWN
The backend type cannot be unknown. It is configured to VRF_LITE by
default in zebra anyway, so just init to VRF_LITE in the lib and remove
the UNKNOWN type.

Signed-off-by: Igor Ryzhov <idryzhov@gmail.com>
2025-01-15 23:38:27 +02:00
Christian Hopps 5f2a927d7b lib: northbound/mgmtd: add backend model support
Signed-off-by: Christian Hopps <chopps@labn.net>
2025-01-14 18:48:59 +00:00
Donald Sharp 5f35096123
Merge pull request #17796 from LabNConsulting/chopps/datastore-notifications
operational-state (datastore) change notifications
2025-01-14 13:47:28 -05:00
Philippe Guibert f19b8668b3 bgpd: add 'match community-count' command to restrict comm count
Add a mechanism in route-map to filter out route-map which have a list
of communities greater than the given number.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2025-01-14 13:59:42 +01:00
Christian Hopps c88b48929c lib: fix new (incorrect) CLANG SA warnings
Signed-off-by: Christian Hopps <chopps@labn.net>
2025-01-13 23:40:52 -05:00
Christian Hopps 255026c2ce mgmtd: add notify selectors to filter datastore notifications
- Additionally push the selectors down to the backends

Signed-off-by: Christian Hopps <chopps@labn.net>
2025-01-13 23:40:52 -05:00
Christian Hopps 709b2ae23f lib: notify on datastore (oper-state) changes
Signed-off-by: Christian Hopps <chopps@labn.net>
2025-01-13 23:40:52 -05:00
Christian Hopps 80c6f98ea7 lib: if: track oper-state inline
Signed-off-by: Christian Hopps <chopps@labn.net>
2025-01-13 23:40:52 -05:00
Christian Hopps e64966876c lib: vrf: track oper-state inline
Signed-off-by: Christian Hopps <chopps@labn.net>
2025-01-13 23:40:52 -05:00
Christian Hopps 8a52b69ca4 lib: northbound: add basic oper-state update functions
Signed-off-by: Christian Hopps <chopps@labn.net>
2025-01-13 23:40:52 -05:00
Donatas Abraitis a39aa3eb37 lib: Adopt Lua stuff for Lua 5.4
lua_pcall() returns LUA_ERRGCMM in 5.3 which is already deprecated.

The constant LUA_ERRGCMM was removed.
Errors in finalizers are never propagated; instead, they generate a warning.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2025-01-13 16:34:15 +02:00
Donatas Abraitis 0b48c8e134
Merge pull request #17807 from louis-6wind/fix-bgp-orf-crash
bgpd: fix crash in displaying json orf prefix-list
2025-01-09 22:57:51 +02:00
Louis Scalbert 5100d842f6 lib: remove interface dead code
Remove interface dead code.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2025-01-09 18:38:28 +01:00
Louis Scalbert 8ccf60921b bgpd: fix crash in displaying json orf prefix-list
bgpd crashes when there is several entries in the prefix-list. No
backtrace is provided because the issue was catched from a code review.

Fixes: 856ca177c4 ("Added json formating support to show-...-neighbors-... bgp commands.")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2025-01-09 18:35:18 +01:00
Louis Scalbert b7e843d7e8 bgpd: fix bgp orf prefix-list json prefix
0x<address>FX was displayed instead of the prefix.

Fixes: b219dda129 ("lib: Convert usage of strings to %pFX and %pRN")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2025-01-09 18:35:18 +01:00
Jafar Al-Gharaibeh 465d286819
Merge pull request #17798 from mjstapp/fix_remove_clear_thread
libs: remove deprecated 'clear thread' cli
2025-01-09 09:01:33 -06:00
Mark Stapp cb119907f0 libs: remove deprecated 'clear thread' cli
Remove a deprecated 'clear thread cpu' command.

Signed-off-by: Mark Stapp <mjs@cisco.com>
2025-01-08 10:17:51 -05:00
Martin Buck 59ee9d2a79 lib: Handle call to zlog_5424_cycle() without valid FD properly
In zlog_5424_cycle(), struct zlt_5424 *zlt only points to valid memory when
the passed file descriptor is >= 0 (and passing -1 seems to be a supported
use case). So we shouldn't try to compute the address of its zt member when
zlt is NULL.

Signed-off-by: Martin Buck <mb-tmp-tvguho.pbz@gromit.dyndns.org>
2025-01-08 13:30:40 +01:00
Martin Buck 9951da394a lib: Try to open 5424 log destination when changing log threshold
When changing the log threshold (prio_min) using zlog_5424_apply_meta(), try
to open the log destination using zlog_5424_open() if we haven't done so
before. Without this, we might never open the destination at all, because
when zlog_5424_apply_dst() gets called (which so far was the only initial
caller of zlog_5424_open()), chances are that prio_min is still at its
initial value of ZLOG_DISABLED, causing it to skip the call to
zlog_5424_open().

Signed-off-by: Martin Buck <mb-tmp-tvguho.pbz@gromit.dyndns.org>
2025-01-08 13:30:40 +01:00
Martin Buck 4ed9147d98 lib: Fix privs syscaps (pset_t) allocation
Don't over-allocate syscaps in zcaps2sys(): This is just a single struct
(pset_t) with a count and a pointer to an array of capabilities, not an
array. So only allocate a single pset_t, not num copies of it.

The allocation size of syscaps->caps then needs to be based on the number of
Linux capabilities (count), but that is already handled properly a few lines
below.

Note that this fix is mostly cosmetic and for correctness. There was no
potential for memory corruption, because num is guaranteed to be nonzero. So
at least the one required pset_t was always allocated (but potentially much
more).

Signed-off-by: Martin Buck <mb-tmp-tvguho.pbz@gromit.dyndns.org>
2025-01-08 10:38:56 +01:00
Donald Sharp cc07a4a200
Merge pull request #17772 from LabNConsulting/chopps/fix-oper-walk
improve error handling of operational state walk callback
2025-01-07 13:52:37 -05:00
Donald Sharp 96ab6ae32b
Merge pull request #17781 from LabNConsulting/chopps/fix-keyless-list-query
fix xpath query on keyless list with positional predicate
2025-01-07 13:17:37 -05:00
Donald Sharp 0a52c233d3
Merge pull request #17782 from LabNConsulting/chopps/new-notify-msg-fmt
New YANG notify msg fmt
2025-01-07 13:15:40 -05:00
Donald Sharp 1a7923e7bc
Merge pull request #17783 from LabNConsulting/chopps/new-oper-get-callback
Add new oper state get callback
2025-01-07 13:11:26 -05:00
Russ White 7f2be9a595
Merge pull request #17474 from sougata-github-nvidia/rib_ip_protocol_cleanup
zebra: Fix ip protocol route-map issue.
2025-01-07 08:45:07 -05:00
Christian Hopps 4379066fdd lib: if.c use new get() oper callback
Signed-off-by: Christian Hopps <chopps@labn.net>
2025-01-07 06:59:15 -05:00
Christian Hopps 0ca710bb5f lib: add impl of NOTIF message ops (notif, replace, delete, patch)
- needed for supporting backend datastore notifications

Signed-off-by: Christian Hopps <chopps@labn.net>
2025-01-07 05:34:09 -05:00
Christian Hopps 30777991c0 lib: add NOTIF message ops (notification, replace, delete, patch)
- needed for supporting backend datastore notifications

Signed-off-by: Christian Hopps <chopps@labn.net>
2025-01-07 05:34:06 -05:00
Christian Hopps 36f25da612 lib: northbound: add new get() callback to add lyd_node direclty
This allows eliminating the superfluous yang_data object (which
is getting created used to call lyd_new_term then deleted). Instead
just call lyd_new_term() in the callback directly.

Signed-off-by: Christian Hopps <chopps@labn.net>
2025-01-07 05:33:28 -05:00
Christian Hopps 2fb6519c52 lib: northbound oper: fix keyless position predicate queries
- i.e., `show /foos/foo[1]`

Signed-off-by: Christian Hopps <chopps@labn.net>
2025-01-07 01:24:14 -05:00
Christian Hopps 9aa2b04874 lib: change and improve walk finish callback function API
Signed-off-by: Christian Hopps <chopps@labn.net>
2025-01-06 08:07:41 -05:00
Sougata Barik 86b294698f zebra: Fix ip protocol route-map issue.
"ip/ipv6 protocol any route-map <route map>" cli is setting
wrong route type ( ZEBRA_ROUTE_MAX ), It should set route type
ZEBRA_ROUTE_ALL.

Ticket: #4101560

Signed-off-by: Sougata Barik <sougatab@nvidia.com>
2025-01-06 17:02:21 +05:30
Jafar Al-Gharaibeh e62c2f10bc
Merge pull request #17684 from opensourcerouting/fix/json_time_no_newline
bgpd, lib: Use frrstr_time() when using ctime_r()
2024-12-21 22:59:58 -06:00
Jafar Al-Gharaibeh c5123ff2b0
Merge pull request #17672 from raja-rajasekar/rajasekarr/batch_huge_cfg
lib: Fix to optimize the time taken while batching huge configs
2024-12-20 14:00:02 -06:00
Mark Stapp abefc604f7
Merge pull request #17648 from LabNConsulting/fix-darr-sprintf
Fix 2 darr (dynamic-array) bugs
2024-12-20 11:10:18 -05:00
Donatas Abraitis b3e1ceaf88 lib: Add a wrapper for time_to_string() to print time in JSON outputs
newline is not expected to be printed in JSON outputs, e.g.:

```
"lastUpdate":{"epoch":1734490463,"string":"Wed Dec 18 04:54:23 2024\n"
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-12-20 17:12:12 +02:00
Rajasekar Raja 6f132af67b lib: Fix to optimize the time taken while batching huge configs
Issue: When the incoming config has say 30K entries of a prefix-lists,
current implementation is to schedule the configs to be batched and
only after batching the entire config, the processing of the configs
take place. As part of batching this config, we perform string
concatenation to save all the configs in the buffer which over time
results in taking longer time.

Ex: Imagine each line of config is 50 chars. With a delimiter of ‘- ‘ we end
up adding 52 chars to buffer for each command i.e. 52*30000 = 156K of chars.
Strlcat is an expensive operation and every time we strlcat, we have to
traverse at end of string to append new char.
Because of this, we end up adding extra 6-8 secs for accepting the config.

Fix: The idea here is to bring back something similar to the backoff
count implemented as part of 20e9a402 (lib: introduce configuration
back-off timer for YANG-modeled commands).

Essentially we keep a cap of 5000 per batch. So once 5000k config
commands are batched, we process them, clear the buffer, set the count
to 0 and then continue processing the rest of the config.

option1 file has 30K entries of prefix-list
Without Fix:
root@mlx-3700-20:mgmt:/var/log/raja/frr# time sudo vtysh -f option1
<SNIP>..............
Waiting for children to finish applying config...
[25191|staticd] done
[25189|watchfrr] done
[25178|ospfd] done
[25190|pbrd] done
[25181|bgpd] done
[25175|zebra] done

real    0m20.123s
user    0m9.384s
sys     0m2.403s

With Fix:
root@mlx-3700-20:mgmt:/var/log/raja/frr# time sudo vtysh -f option1
<SNIP>..............
Waiting for children to finish applying config...
[19887|staticd] done
[19885|watchfrr] done
[19886|pbrd] done
[19874|ospfd] done
[19877|bgpd] done
[19871|zebra] done

real	0m12.168s
user	0m7.511s
sys	0m1.981s

Issue: 3589101

Ticket# 3589101

Signed-off-by: Rajasekar Raja <rajasekarr@nvidia.com>
2024-12-18 11:53:06 -08:00
Russ White acea7d5d7d
Merge pull request #17615 from opensourcerouting/fix/ip_prefix_list_show_prefix
lib: Take ge/le into consideration when checking the prefix with the prefix-list
2024-12-17 11:30:01 -05:00
Christian Hopps fb85d18f59 lib: darr: fix bug with nested macro use
- WHen declaring macro scoped variables, can run into problem if the macro
variable passed in has the same name as the new variable introduced in the inner
scope. We don't get a warning and the uses will be wrong.

e.g.,

```

{
    int __len = 10;
    foo(__len); // => 10 and not 15 as we wanted.
}
```

Signed-off-by: Christian Hopps <chopps@labn.net>
2024-12-15 22:01:56 -05:00
Christian Hopps a65cdb60a3 lib: mgmtd: use less common macro scoped variable names
- ran into problem with darr macros and nested macros using the same name
variables as passed in variables in an out scope. Make these macro scoped
variables more unique as well.

Signed-off-by: Christian Hopps <chopps@labn.net>
2024-12-15 22:01:56 -05:00
Christian Hopps 73e54e4168 lib: darr: use the FRR printf formatter
Signed-off-by: Christian Hopps <chopps@labn.net>
2024-12-15 21:51:27 -05:00
Nathan Bahr 4250eae00d zebra,pimd,lib: Modify ZEBRA_NEXTHOP_LOOKUP_MRIB
Modified ZEBRA_NEXTHOP_LOOKUP_MRIB to include the SAFI from which to do the lookup.
This generalizes the API away from MRIB specifically and allows the user to decide how it should do lookups.
Rename ZEBRA_NEXTHOP_LOOKUP_MRIB to ZEBRA_NEXTHOP_LOOKUP now that it is more generalized.
This change is in preperation to remove multicast lookup mode completely from zebra.

Signed-off-by: Nathan Bahr <nbahr@atcorp.com>
2024-12-12 13:50:31 +00:00
Donatas Abraitis dd4c2acc2e lib: Take ge/le into consideration when checking the prefix with the prefix-list
Without the fix:

```
show ip prefix-list test_1 10.20.30.96/27 first-match
 <no result>

show ip prefix-list test_2 192.168.1.2/32 first-match
 <no result>
```

With the fix:

```
ip prefix-list test_1 seq 10 permit 10.20.30.64/26 le 27
!
end
donatas# show ip prefix-list test_1 10.20.30.96/27
   seq 10 permit 10.20.30.64/26 le 27 (hit count: 1, refcount: 0)
donatas# show ip prefix-list test_1 10.20.30.64/27
   seq 10 permit 10.20.30.64/26 le 27 (hit count: 2, refcount: 0)
donatas# show ip prefix-list test_1 10.20.30.64/28
donatas# show ip prefix-list test_1 10.20.30.126/26
   seq 10 permit 10.20.30.64/26 le 27 (hit count: 3, refcount: 0)
donatas# show ip prefix-list test_1 10.20.30.126/30
donatas#
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-12-10 16:28:26 +02:00
Jafar Al-Gharaibeh e814b000c3
Merge pull request #17585 from donaldsharp/zclient_speedup
lib: Speed up reconnection attempts for zapi
2024-12-04 21:59:33 -06:00
Donald Sharp fe180581bd lib: Speed up reconnection attempts for zapi
Currently the zapi reconnection is once every 10 seconds
for the first 3 times and then once every 60 seconds from then
on out.  We are seeing interesting behavior under loaded systems
where zebra is just slow to come up and daemons are spending a long
time waiting to connect.  Let's just make things a bit more aggressive.

Change the code to attempt to reconnect once every second for 30 seconds
and then change to once every 5 seconds from then on out.

This should help with non-integrated configuration on system startup.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-12-04 16:14:34 -05:00
Russ White f1ab0a0c2f
Merge pull request #17556 from opensourcerouting/fix/add_route_map_action_reason
lib: Print the reason why the route-map and/or the index parsing is done
2024-12-04 08:09:48 -05:00
Donatas Abraitis 75e9b1b090
Merge pull request #17571 from donaldsharp/fix_bsd_sockopt_problem
Fix bsd sockopt problem
2024-12-04 14:46:08 +02:00
Donatas Abraitis 5b976f00f6 lib: Print the reason why the route-map and/or the index parsing is done
This would give more details why at some point we return deny, no match, etc.

Before this we have sometimes (I don't know why), e.g.:

```
Route-map: null, prefix: 192.168.2.0/24, result: deny
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-12-04 08:27:13 +02:00
Donald Sharp 959dbe27cd lib,vtysh: Use backoff setsockopt option for freebsd
Commit: 9112fb367b

Introduced the idea of setting the socket buffer
send/receive sizes.  BSD's in general have the fun
issue of not allowing nearly as large as a size as
linux.  Since the above commit was developed on linux
and not run on bsd it was never tested.  Modify the
codebase to use the backoff setsockopt that we have
in the code base and use the returned values to allow
us to notice what was set and respond appropriately.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-12-03 18:49:59 -05:00
Donald Sharp d5615fd6f8 lib: Allow setsockopt functions to return size set
When finding a send/receive buffer size that is usable
let's report how big we were able to set it.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-12-03 18:38:59 -05:00
Donald Sharp 2c6fcbdf84 lib: Fix session re-establishment
Currently if you have this sequence of events:

a) BGP starts
b) BGP reads cli that has bfd configuration
c) BGP attempts to install bfd configuration but fails because
zebra is not connected to yet
d) BGP connects to zebra
e) BGP receives resend bfd code from bfdd
f) BGP was not sending down the unsent data to bfd, never causing
the bfd session to be established.

So effectively bfd was attempting to install but failed
and then when it was asked to replay everything it decided
that the bfd information for a particular peer was actually
installed and does not need to be resent.  Modify the code
such that the bfd code now tracks failed installation and
allows the resend of data to bfdd.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-12-03 12:08:12 -05:00
Donald Sharp 67526c4b8c lib: Remove route_node_match_ipv[4|6] not being used
These functions are not being used.  Let's just remove
them from our code base.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-11-25 13:12:10 -05:00
Donald Sharp cb6f7b153e lib, zebra: Do not have duplicate memory type problems
In zebra_mpls.c it has a usage of MTYPE_NH_LABEL which is
defined in both lib/nexthop.c and zebra/zebra_mpls.c.  The
usage in zebra_mpls.c is a realloc.  This leads to a crash:

(gdb) bt
0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=126487246404032) at ./nptl/pthread_kill.c:44
1  __pthread_kill_internal (signo=6, threadid=126487246404032) at ./nptl/pthread_kill.c:78
2  __GI___pthread_kill (threadid=126487246404032, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
3  0x0000730a1b442476 in __GI_raise (sig=6) at ../sysdeps/posix/raise.c:26
4  0x0000730a1b94fb18 in core_handler (signo=6, siginfo=0x7ffeed1e07b0, context=0x7ffeed1e0680) at lib/sigevent.c:268
5  <signal handler called>
6  __pthread_kill_implementation (no_tid=0, signo=6, threadid=126487246404032) at ./nptl/pthread_kill.c:44
7  __pthread_kill_internal (signo=6, threadid=126487246404032) at ./nptl/pthread_kill.c:78
8  __GI___pthread_kill (threadid=126487246404032, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
9  0x0000730a1b442476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
10 0x0000730a1b4287f3 in __GI_abort () at ./stdlib/abort.c:79
11 0x0000730a1b9984f5 in _zlog_assert_failed (xref=0x730a1ba59480 <_xref.16>, extra=0x0) at lib/zlog.c:789
12 0x0000730a1b8f8908 in mt_count_free (mt=0x576e0edda520 <MTYPE_NH_LABEL>, ptr=0x576e36617b80) at lib/memory.c:74
13 0x0000730a1b8f8a59 in qrealloc (mt=0x576e0edda520 <MTYPE_NH_LABEL>, ptr=0x576e36617b80, size=16) at lib/memory.c:112
14 0x0000576e0ec85e2e in nhlfe_out_label_update (nhlfe=0x576e368895f0, nh_label=0x576e3660e9b0) at zebra/zebra_mpls.c:1462
15 0x0000576e0ec833ff in lsp_install (zvrf=0x576e3655fb50, label=17, rn=0x576e366197c0, re=0x576e3660a590) at zebra/zebra_mpls.c:224
16 0x0000576e0ec87c34 in zebra_mpls_lsp_install (zvrf=0x576e3655fb50, rn=0x576e366197c0, re=0x576e3660a590) at zebra/zebra_mpls.c:2215
17 0x0000576e0ecbb427 in rib_process_update_fib (zvrf=0x576e3655fb50, rn=0x576e366197c0, old=0x576e36619660, new=0x576e3660a590) at zebra/zebra_rib.c:1084
18 0x0000576e0ecbc230 in rib_process (rn=0x576e366197c0) at zebra/zebra_rib.c:1480
19 0x0000576e0ecbee04 in process_subq_route (lnode=0x576e368e0270, qindex=8 '\b') at zebra/zebra_rib.c:2661
20 0x0000576e0ecc0711 in process_subq (subq=0x576e3653fc80, qindex=META_QUEUE_BGP) at zebra/zebra_rib.c:3226
21 0x0000576e0ecc07f9 in meta_queue_process (dummy=0x576e3653fae0, data=0x576e3653fb80) at zebra/zebra_rib.c:3265
22 0x0000730a1b97d2a9 in work_queue_run (thread=0x7ffeed1e3f30) at lib/workqueue.c:282
23 0x0000730a1b96b039 in event_call (thread=0x7ffeed1e3f30) at lib/event.c:1996
24 0x0000730a1b8e4d2d in frr_run (master=0x576e36277e10) at lib/libfrr.c:1232
25 0x0000576e0ec35ca9 in main (argc=7, argv=0x7ffeed1e4208) at zebra/main.c:536

Clearly replacing a label stack is an operation that should be owned by
lib/nexthop.c.  So lets move this function into there and have
zebra_mpls.c just call the function to replace the label stack.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-11-22 11:02:15 -05:00
Donald Sharp 172a2aa533
Merge pull request #17156 from opensourcerouting/eradicate-strncpy
*: remove remaining `strncpy()` users
2024-11-19 09:42:39 -05:00
Donald Sharp ac6314d380
Merge pull request #17297 from mjstapp/mjs_ifp_table
zebra, lib: use internal rbtree for per-NS tree of ifps
2024-11-12 15:12:07 -05:00
Donatas Abraitis f47ae0218b lib: Initialize mbefore for route_map_apply_ext()
CID 1601478: Uninitialized variables  (UNINIT)
Using uninitialized value "mbefore.real.tv_usec" when calling "event_consumed_time".

Fixes: 3e3a666331 ("lib: Add ability to track time in individual routemaps")

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-11-08 09:00:34 +02:00
Donald Sharp 3e3a666331 lib: Add ability to track time in individual routemaps
Add the abilty to track how much time is spent in routemaps.
Example of the new output:

eva# show route-map
ZEBRA:
route-map: FOO Invoked: 1000000 (323 milliseconds total) Optimization: enabled Processed Change: false
 deny, sequence 10 Invoked 1000000 (320 milliseconds total)
  Match clauses:
  Set clauses:
  Call clause:
  Action:
    Exit routemap

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-11-05 12:33:05 -05:00
Donatas Abraitis a69f66176d
Merge pull request #17312 from donaldsharp/remove_in6addr_cmp
Remove in6addr cmp
2024-11-01 18:06:04 +02:00
Donatas Abraitis 4411ee9865
Merge pull request #17280 from donaldsharp/remove_event_master_free_unused
Remove event master free unused
2024-11-01 18:03:44 +02:00
Russ White 77632a7ec3
Merge pull request #17194 from LabNConsulting/aceelindem/ospf-ls-refresh-interval-fix
ospfd: Fix opaque LSA refresh interval and modify LSA cmds.
2024-11-01 11:37:32 -04:00
Donald Sharp cd80fa0af4 lib: Remove counter and a function
The `alloc` counter was tracking the current active
number of events in the system and if it went to
0 when freeing a new one it would assert.  This
assert is a duplicate of what would happen with the
XFREE in the same situation.  As such it is not
necessary.

Also remove the `event_master_free_unused` function
from the system.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-10-31 14:07:04 -04:00
Donald Sharp 97c17c1e8b lib: Remove wheel name it is no longer used
With commit:
60a3efec24

The ability for the wheel code to display the name of what
wheel was actually being run was removed from the system.
Since we can no longer do this and it's been 4 years since it's
been in, let's just remove this bit of dead code.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-10-31 13:55:48 -04:00
Donald Sharp ff9781ebf5 lib: In sockunion.c convert v6 memcmp's to IPV6_ADDR_CMP
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-10-31 11:13:34 -04:00
Donald Sharp 1cb6b71b40 lib, tests: Remove in6addr_cmp function from the system
This function should just be memcmp.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-10-31 10:04:19 -04:00
Donald Sharp 7ebda3892c lib: Replace usage of in6addr_cmp with memcmp
memcmp will return and act exactly the same as in6addr_cmp
but it does it significantly faster than how in6addr_cmp
does it.  Let this be a lesson for implementing something
that is a duplicate of what is provided by the c library.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-10-31 10:04:19 -04:00
Mark Stapp c1160538ea lib,zebra: remove table node from ifp struct
Finish removing the table route_node from the ifp struct.

Signed-off-by: Mark Stapp <mjs@cisco.com>
2024-10-29 13:49:43 -04:00
Jafar Al-Gharaibeh f11421d4ec
Merge pull request #17160 from opensourcerouting/fix/keep_zebra_on-rib-process_in_frr.conf
lib, zebra: Keep `zebra on-rib-process script` in frr.conf
2024-10-27 18:23:36 -05:00
Acee Lindem c735f25abb ospfd: Fix opaque LSA refresh interval and modify LSA cmds.
The configured OSPF refresh interval was not being used for opaque LSA (it always used the constant). Also, modified the timers lsa min-arrival command to have a maximum of 5000 msecs as well as providing a path for backward command compatibility.

Added missing user documentation for both timers lsa min-arrival and timers throttle lsa all.

Signed-off-by: Acee Lindem <acee@lindem.com>
2024-10-25 14:31:10 +00:00
Donald Sharp 274c98628f
Merge pull request #17155 from opensourcerouting/memstats-zlog
lib: `debug memstats-at-exit` improvements
2024-10-24 21:07:09 -04:00
Donald Sharp 6a36b9ef49 Revert "lib: Attach stdout to child only if --log=stdout and stdout FD is a tty"
This reverts commit 0e3c5e8e59.
2024-10-22 11:13:07 -04:00
David Lamparter 4606612abe lib: remove strncpy() use
`checkpatch` has sufficiently annoyed me to fix this.

Includes free overflow guard in CSV code.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-10-22 14:51:25 +02:00
Donatas Abraitis 1fe1f8d87c lib, zebra: Keep zebra on-rib-process script in frr.conf
After the change:

```
$ grep on-rib-process /etc/frr/frr.conf
zebra on-rib-process script script4

$ systemctl restart frr

$ vtysh -c 'show run' | grep on-rib-process
zebra on-rib-process script script4
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-10-18 15:36:52 +03: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 466efab870
Merge pull request #17136 from opensourcerouting/clang-sa-19
*: fix clang-19 SA
2024-10-17 07:38:28 -04: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
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 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 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
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
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
Russ White 884e183f4a
Merge pull request #17058 from opensourcerouting/fix/apply_route_maps_earlier
lib: Apply and generate route-map commands earlier before any other protocol
2024-10-15 11:15:41 -04:00
Donatas Abraitis e94f48498d bgpd: Implement set metric aigp command
Same as `set metric igp`, but in this case accumulated IGP metric is being
sent as MED attribute.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-10-15 17:42:52 +03:00
Donatas Abraitis f677fc8db3 bgpd: Implement set metric igp command
Set metric automatically from the path info (IGP protocol).

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-10-15 17:36:51 +03:00
Donatas Abraitis b9a9be492e bgpd: Move some non BGP-specific route-map functions to lib
They are managed under `frr-route-map`, not under `frr-bgp-route-map`.

Fixes: https://github.com/FRRouting/frr/issues/17055

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-10-10 16:52:57 +03:00
Donatas Abraitis 310ca4f33d lib: Apply and generate route-map commands earlier before any other protocol
If e.g. BGP neighbor is using a route-map at the boot, that is not yet created,
then the log is spammed with `The route-map 'X' does not exist`.

Processing earlier, should do the trick.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-10-10 16:24:24 +03:00
Igor Ryzhov c10e4d336b
Merge pull request #17015 from LabNConsulting/chopps/load-internal-ietf-yang-library
lib: add flag to have libyang load internal ietf-yang-library module
2024-10-07 20:33:23 +03:00
Christian Hopps e8648a0c72 lib: add flag to have libyang load internal ietf-yang-library module
Mgmtd makes use of libyang's internal ietf-yang-library module to add
support for said module to FRR management. Previously, mgmtd was loading
this module explicitly; however, that required that libyang's
`ietf-yang-library.yang` module definition file be co-located with FRR's
yang files so that it (and ietf-datastore.yang) would be found when
searched for by libyang using FRRs search path. This isn't always the
case depending on how the user compiles and installs libyang so mgmtd
was failing to run in some cases.

Instead of doing it the above way we simply tell libyang to load it's
internal version of ietf-yang-library when we initialize the libyang
context.

This required adding a boolean to a couple of the init functions which
is why so many files are touched (although all the changes are minimal).

Signed-off-by: Christian Hopps <chopps@labn.net>
2024-10-07 03:32:44 +00:00
Donna Sharp f62dfc5d53 lib,zebra: remove unused ZEBRA_VRF_UNREGISTER
Signed-off-by: Donna Sharp <dksharp5@gmail.com>
2024-10-06 19:40:49 -04:00
Louis Scalbert db7b9a5a70 lib: remove unused bfd defines
Remove unused bfd defines

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-10-03 13:37:55 +02:00
Donald Sharp 0bc79f5e51 lib: nexthop code should use uint16_t for nexthop counting
It's possible to specify via the cli and configure how many
nexthops that are allowed on the system.  If you happen to
have > 255 then things are about to get interesting otherwise.

Let's allow up to 65k nexthops (ha!)

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-10-01 15:38:14 -04:00
Rafael Zalamena 660146b57a lib: fix calloc warning on recent compiler
Fix the following compiler warning:
```
lib/elf_py.c: In function _elffile_load_:
lib/elf_py.c:1310:34: warning: _calloc_ sizes specified with _sizeof_ in the earlier argument and not in the later argument [-Wcalloc-transposed-args]
 1310 |         w->sects = calloc(sizeof(PyObject *), w->ehdr->e_shnum);
      |                                  ^~~~~~~~
lib/elf_py.c:1310:34: note: earlier argument should specify number of elements, later size of each element
```

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2024-09-30 11:31:56 -03:00
Donatas Abraitis 5d3da70ba3 bgpd: Implement match src-peer ... command
To match source peer on the outgoing direction.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-09-27 23:01:06 +03:00
Jafar Al-Gharaibeh 2203dc4777
Merge pull request #16909 from donaldsharp/help
lib: Help text correction
2024-09-24 21:23:03 -05:00
Donald Sharp d722e99075 lib: Removed unused RFP_DEFAULTS_NODE
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-09-24 16:11:43 -04:00
Donald Sharp e54261e20d lib, zebra: TABLE_NODE is not used
No-one is using this, remove

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-09-24 16:05:54 -04:00
Donald Sharp 4e12ba08c4 lib: Help text correction
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-09-24 15:25:49 -04:00
Donatas Abraitis 4b0f4f96ac lib: Load built-in Lua functions
We can't use even `string()` function because built-in functions are not
loaded.

Testing with:

```
$ cat /etc/frr/scripts/zebra.lua
function on_rib_process_dplane_results(ctx)
	log.warn(string.upper("testas"))
	return {}
end
```

This results to "TESTAS" in the logs.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-09-24 13:13:50 +03:00
Donatas Abraitis 74f12853c6
Merge pull request #16738 from odivlad/fix-stdout-fork
lib: Attach stdout to child only if --log=stdout and stdout FD is a tty
2024-09-19 22:24:19 +02:00
Christian Hopps c5df98aece mgmtd: add ietf-yang-library support
Signed-off-by: Christian Hopps <chopps@labn.net>
2024-09-17 22:27:36 -04:00
Christian Hopps b097a966cb lib: mgmtd: add changed and created to edit-reply msg
- This is used for various return values in RESTCONF

Signed-off-by: Christian Hopps <chopps@labn.net>
2024-09-17 05:31:00 -04:00
Christian Hopps 96db155acd lib: mgmtd: cleanup error value for native messaging
- Now if positive it's libyang LY_ERR, otherwise it's `-errno` value.

Signed-off-by: Christian Hopps <chopps@labn.net>
2024-09-17 03:04:59 -04:00
Christian Hopps 0913d9fc0e lib: constify yang_resolve_snode_xpath results
Signed-off-by: Christian Hopps <chopps@labn.net>

ang
2024-09-17 03:04:59 -04:00
Carmine Scarpitta 04025514ed lib: Include SID structure in seg6local nexthop
Include SID structure information in seg6local nexthop data structure.

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-09-15 17:23:34 +02:00
Vladislav Odintsov 0e3c5e8e59 lib: Attach stdout to child only if --log=stdout and stdout FD is a tty
Prior to this commit stdout of a process started in a daemon mode was
attached to a calling process.
As a result a calling process hung for infinity.

Signed-off-by: Vladislav Odintsov <vlodintsov@k2.cloud>
2024-09-10 19:06:13 +03:00
Russ White add56c61dd
Merge pull request #15259 from dmytroshytyi-6WIND/nexthop_resolution
zebra: add LSP entry to nexthop via recursive (part 2)
2024-09-10 10:04:08 -04:00
Christian Hopps 035843705b lib: fix clang SA warnings
Also, cleanup some unreachable code in `nb_op_sib_next()`.

Signed-off-by: Christian Hopps <chopps@labn.net>
2024-09-07 22:12:03 -04:00
Donald Sharp d97c535c1e *: Create termtable specific temp memory
When trying to track down a MTYPE_TMP memory leak
it's harder to search for it when you happen to
have some usage of ttable_dump.  Let's just give
it it's own memory type so that we can avoid
confusion in the future.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-09-01 13:07:46 -04:00
Jafar Al-Gharaibeh 77e1a26faa
Merge pull request #16664 from mjstapp/igor_debug_simplify
*: simplify frrlib debug
2024-08-29 11:51:53 -04:00
Mark Stapp 79e0c6a2e0
Merge pull request #16672 from raja-rajasekar/vty_out_mem_spike_srujana
lib: Memory spike reduction for sh cmds at scale
2024-08-28 15:29:23 -04:00
Donatas Abraitis a0a2a35ed3 lib: Add a helper function to dump Lua stack
Very handy for debugging.

In Lua script just use "log.trace(table)":

```
function on_rib_process_dplane_results(ctx)
	log.trace(ctx.rinfo.zd_ng)
end
```

You will get something like:

```
Aug 28 17:04:36 donatas-laptop zebra[3782199]: [GCZ7N-MM9D9] {
                                                 1: {
                                                   type: 2
                                                   weight: 1
                                                   flags: 5
                                                   backup_idx: 0
                                                   vrf_id: 0
                                                   nh_encap_type: 0
                                                   gate: {
                                                     value: 5.87967e+08
                                                     string: "192.168.11.35"
                                                   }
                                                   nh_label_type: 0
                                                   srte_color: 0
                                                   ifindex: 0
                                                   backup_num: 0
                                                 }
                                                 2: {
                                                   type: 3
                                                   weight: 1
                                                   flags: 3
                                                   backup_idx: 0
                                                   vrf_id: 0
                                                   nh_encap_type: 0
                                                   nh_label_type: 0
                                                   srte_color: 0
                                                   ifindex: 4
                                                   backup_num: 0
                                                 }
                                               }
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-08-28 17:08:45 +03:00
Donatas Abraitis b1012b693f lib: Start from 1, not 0 when creating Lua tables for nexthops
Lua technically enumerates arrays from 1, not 0.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-08-28 15:31:47 +03:00
Srujana 9112fb367b lib: Memory spike reduction for sh cmds at scale
The output buffer vty->obuf is a linked list where
each element is of 4KB.
Currently, when a huge sh command  like <show ip route json>
is executed on a large scale, all the vty_outs are
processed and the entire data is accumulated.
After the entire vty execution, vtysh_flush proceeses
and puts this data in the socket (131KB at a time).

Problem here is the memory spike for such heavy duty
show commands.

The fix here is to chunkify the output on VTY shell by
flushing it intermediately for every 128 KB of output
accumulated and free the memory allocated for the buffer data.

This way, we achieve ~25-30% reduction in the memory spike.

Fixes: #16498
Note: This is a continuation of MR #16498

Signed-off-by: Srujana <skanchisamud@nvidia.com>

Signed-off-by: Rajasekar Raja <rajasekarr@nvidia.com>
2024-08-27 12:47:00 -07:00
Igor Ryzhov 830972cab2 lib: common debug status output
Implement common code for debug status output and remove daemon-specific
code that is duplicated everywhere.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-08-27 09:53:02 -04:00
Igor Ryzhov 82e52e0f21 lib: common debug config output
Implement common code for debug config output and remove daemon-specific
code that is duplicated everywhere.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-08-27 09:53:02 -04:00
Igor Ryzhov 5dac696154 lib: rework debug init
The debug library allows to register a `debug_set_all` callback which
should enable all debugs in a daemon. This callback is implemented
exactly the same in each daemon. Instead of duplicating the code, rework
the lib to allow registration of each debug type, and implement the
common code only once in the lib.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-08-27 09:53:02 -04:00
Mark Stapp b4dae97381
Merge pull request #16609 from donaldsharp/singleton_no_weight
Reduce the number of Singleton objects when using weight for NHG's
2024-08-23 16:19:29 -04:00
Donald Sharp a04cca6f74
Merge pull request #16633 from Jafaral/fix-version-build
config: fix missing case when reporting version 'configured with'
2024-08-23 14:45:33 -04:00
Jafar Al-Gharaibeh 4b050cb080 config: fix missing case when reporting version 'configured with'
Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
2024-08-22 14:28:49 -05:00
Donald Sharp 286e6f8871 lib: Ensure SA that root cannot be NULL
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-08-22 13:53:47 -04:00
Donald Sharp b8e24a0ad0 lib, zebra: Modify nexthop_cmp to allow you to use weight or not
Currently nexthop weight is a discriminator on whether or not
a nexthop matches.  There is a need to no use the weight as
part of this comparison function so let's add a boolean to
allow us to say use this or not.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-08-22 13:22:06 -04:00
Donald Sharp c5fd6ba2dc
Merge pull request #16602 from LabNConsulting/chopps/fix-warnings
mgmtd: fix a couple compilation warnings.
2024-08-18 15:22:33 -04:00
Carmine Scarpitta 075899dee0 lib: Fix compilation warning
Don't store unnecessary `len` returned by snprintf and snprintfrr function.

Fixes the following compilation warnings:

```
error	15-Aug-2024 13:54:10	In file included from lib/bfd.c:16:
error	15-Aug-2024 13:54:10	In file included from ./lib/zclient.h:22:
error	15-Aug-2024 13:54:10	In file included from ./lib/nexthop.h:14:
error	15-Aug-2024 13:54:10	./lib/srv6.h:338:3: warning: Value stored to 'len' is never read [deadcode.DeadStores]
error	15-Aug-2024 13:54:10	                len += snprintf(str + len, size - len, " USP");
error	15-Aug-2024 13:54:10	                ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error	15-Aug-2024 13:54:10	./lib/srv6.h:343:3: warning: Value stored to 'len' is never read [deadcode.DeadStores]
error	15-Aug-2024 13:54:10	                len += snprintfrr(str + len, size - len, " nh6 %pI6", &ctx->nh6);
error	15-Aug-2024 13:54:10	                ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error	15-Aug-2024 13:54:10	./lib/srv6.h:347:3: warning: Value stored to 'len' is never read [deadcode.DeadStores]
error	15-Aug-2024 13:54:10	                len += snprintfrr(str + len, size - len, " nh4 %pI4", &ctx->nh4);
error	15-Aug-2024 13:54:10	                ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error	15-Aug-2024 13:54:10	./lib/srv6.h:354:3: warning: Value stored to 'len' is never read [deadcode.DeadStores]
error	15-Aug-2024 13:54:10	                len += snprintf(str + len, size - len, " vrf_id %u",
error	15-Aug-2024 13:54:10	                ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error	15-Aug-2024 13:54:10	./lib/srv6.h:367:3: warning: Value stored to 'len' is never read [deadcode.DeadStores]
error	15-Aug-2024 13:54:10	                len += snprintf(str + len, size - len, " unknown(%s)", __func__);
error	15-Aug-2024 13:54:10	                ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-08-18 13:03:04 +02:00
Christian Hopps e7fc74aa14 mgmtd: fix a couple compilation warnings.
Also an empty (thus non-replace) notify selectors message shouldn't
clear the selectors, it should just do nothing.

Signed-off-by: Christian Hopps <chopps@labn.net>
2024-08-18 05:33:29 -05:00
Donald Sharp baa0a1df5b *: Fix spelling errors found
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-08-15 09:19:37 -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 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 c79599e497
Merge pull request #16551 from idryzhov/distrib-del
lib: fix distribute-list deletion
2024-08-10 19:50:26 -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 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 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
Philippe Guibert 5d027fc791 lib: add seg6localContext json attribute in nexthop information
Some srv6 behaviors have a context attached that is visible if
no json is requested:

> # show ipv6 route
> [..]
> B>* 2001:db8:1:1:100::/128 [20/0] is directly connected, vrf10, seg6local End.DT6 table 10, weight 1, 00:00:14
> B>* 2001:db8:1:1:200::/128 [20/0] is directly connected, vrf20, seg6local End.DT6 table 20, weight 1, 00:00:14
>

The json does not dump this attribute:
> # show ipv6 route 2001:db8:1:1:100::/128 json
> [..]
>      "nexthops":[
>        {
>          "flags":3,
>          "fib":true,
>          "directlyConnected":true,
>          "interfaceIndex":6,
>          "interfaceName":"vrf10",
>          "active":true,
>          "weight":1,
>          "seg6local":{
>            "action":"End.DT6"
>          },
>        }
>

Add the json support for this.

>      "nexthops":[
>        {
>          "flags":3,
>          "fib":true,
>          "directlyConnected":true,
>          "interfaceIndex":6,
>          "interfaceName":"vrf10",
>          "active":true,
>          "weight":1,
>          "seg6local":{
>            "action":"End.DT6"
>          },
>          "seg6localContext":{
>            "table":10
>          }
>        }
>

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2024-08-08 11:36:01 +02:00
Igor Ryzhov 2b12d62e38 lib: fix crash on distribute-list delete
The destroy callback must be executed only once on APPLY stage.

Fixes #16528

Signed-off-by: Igor Ryzhov <idryzhov@gmail.com>
2024-08-08 01:17:11 +03:00
David Lamparter 4bc41193e8 vtysh, lib: preprocess CLI graphs
Store a parsed and built graph of the CLI nodes in vtysh, rather than
parsing and building that graph every time vtysh starts up.

This provides a 3x to 5x reduction in vtysh startup overhead:

`vtysh -c 'configure' -c 'interface lo' -c 'do show version'`

- before: 92.9M cycles, 1114 samples
- after: 16.5M cycles, 330 samples

This improvement is particularly visible for users scripting `vtysh -c`
calls, which notably includes topotests.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-07-31 08:08:53 -04:00
David Lamparter e26c580588 vtysh: de-conditionalize and reorder install_node
There is entirely no point to these being conditional.  And pull them up
so the upcoming pre-parse code can work on a clean slate.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-07-31 08:08:53 -04:00
David Lamparter ece3132471 lib/clippy: add CMD_ELEMENT_TKN
The command graph has its tail end nodes pointing at the
`struct cmd_element` rather than a `struct cmd_token`.  This is a bit
weird to begin with, but becomes very annoying for the python bindings
where there is just no `struct cmd_element`.

Create a `CMD_ELEMENT_TKN` type for `cmd_token` instead, and replace the
tail end token in the python bindings with an instance of that.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-07-31 08:08:53 -04:00