Commit Graph

5819 Commits

Author SHA1 Message Date
Igor Ryzhov
01be34fa34 zebra: fix default value for affinity-mode
- initialize the necessary bit when creating if_link_params
- fix CLI description to mark extended as the default mode
- correctly set mode to extended when using the "no" form of the command
- handle the "show_defaults" parameter correctly in cli_show callback

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-19 03:47:25 +02:00
Igor Ryzhov
3856ba2359 lib: make affinity-map value mandatory
There can't be an affinity map without a bit position.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-19 03:47:08 +02:00
Igor Ryzhov
670e0c0737 lib: validate affinity-map bit position using the yang model
When affinity mode is "standard", bit position cannot be greater than
31. Add a "must" statement to the YANG model to validate this, and
remove our custom validation code that does the same.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-19 03:47:05 +02:00
Igor Ryzhov
26bd685a87 lib: make affinity-map value unique in the yang model
It allows us to remove the code that does the same thing manually.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-19 03:47:02 +02:00
Igor Ryzhov
fdd834b8cc lib: validate affinity-map reference using yang model
Change the type of affinity leaf-list in frr-zebra to a leafref with
"require-instance" property set to true. This change tells libyang to
automatically check that affinity-map exists before usage and doesn't
allow it to be deleted if it's referenced. It allows us to remove all
the manual code that is doing the same thing.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-19 03:46:56 +02:00
Philippe Guibert
1420189c11 bgpd: add support of rpki in vrf configure context
Add support of RPKI commands in the VRF configure context.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-01-18 13:23:33 +01:00
Mark Stapp
31015c3ad9 lib,vtysh: add per-daemon log file config
Add a config that specifies per-deamon log file names.
Move the handy generated list of daemon names from vtysh to lib;
edit the gitignore files to match.

Signed-off-by: Mark Stapp <mjs@labn.net>
2024-01-17 16:15:07 -05:00
Christian Hopps
f2bb687426
Merge pull request #15154 from idryzhov/mgmt-get-data
mgmtd get-data request expansion
2024-01-15 07:03:34 -05:00
Igor Ryzhov
9859f308d2 lib, mgmtd: add ability to request the exact node in get-data request
RESTCONF expects to receive the exact node as a result, not the whole
data tree.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-15 10:27:33 +02:00
Igor Ryzhov
10eac0a54d lib: fix oper data leaf creation
When creating an initial tree trunk for oper data walk, if the xpath
represents a leaf, the leaf is created with an incorrect empty value.
If it doesn't actually exist in daemon's oper data, its value is not
overwritten later and an empty value is returned in the result.

For example, when requesting
`/frr-interface:lib/interface[name='eth0']/description`, the result is:
```
{
  "frr-interface:lib": {
    "interface": [
      {
        "name": "eth0",
        "description": ""
      }
    ]
  }
}
```
instead of an empty JSON that it should be.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-15 10:27:33 +02:00
Igor Ryzhov
e1cdb38ee6 lib, mgmtd: add ability to set content type in get-data request
Like in RESTCONF GET request and NETCONF get-data request, make it
possible to request state-only, config-only, or all data.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-15 10:27:33 +02:00
Igor Ryzhov
25d79af957 lib, mgmtd: add separate get-data request for the frontend
Currently it's the same as get-tree request for the backend, but it is
going to be expanded in the following commits.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-14 20:00:22 +02:00
Igor Ryzhov
2b7d9532c8 lib: fix yang_lyd_trim_xpath
We should traverse all top-level siblings, not only the first one.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-14 19:08:15 +02:00
Christian Hopps
c68246c069 yang: lib: interface MTUs can be larger than uint16
Technically changing a leaf from uint16 to uint32 is a NBC change; however,
increasing this to uint32 should not break anyone in reality.

Signed-off-by: Christian Hopps <chopps@labn.net>
2024-01-14 12:38:25 +00:00
Christian Hopps
008ba3e3fb
lib: fix coverity issue
** CID 1575595:  Null pointer dereferences  (REVERSE_INULL)

Signed-off-by: Christian Hopps <chopps@labn.net>
2024-01-12 16:37:30 +00:00
Donatas Abraitis
d2c275a793
Merge pull request #15133 from LabNConsulting/chopps/coverity-fixes
lib: fix coverity issues
2024-01-12 16:06:26 +02:00
Christian Hopps
20d0d475cb
Merge pull request #14542 from idryzhov/nb-op-cb-split
Add more northbound operation types
2024-01-12 06:07:57 -05:00
Donatas Abraitis
0f5a79af96
Merge pull request #15136 from idryzhov/ignore-cbs
lib, mgmtd: rename ignore_cbs to ignore_cfg_cbs
2024-01-12 11:56:59 +02:00
Igor Ryzhov
34721972ba lib, mgmtd: rename ignore_cbs to ignore_cfg_cbs
Setting this variable to true makes NB ignore only configuration-related
callbacks. CLI-related callbacks are still loaded and executed, so
rename the variable to make it clearer.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-11 23:47:48 +02:00
Christian Hopps
29f2a300a3 lib: fix coverity issues
** CID 1575504:  Insecure data handling  (TAINTED_SCALAR) (maybe)
** CID 1575505:  Integer handling issues  (CONSTANT_EXPRESSION_RESULT)
** CID 1575506:  Integer handling issues  (CONSTANT_EXPRESSION_RESULT)
** CID 1575507:  Null pointer dereferences  (REVERSE_INULL)

Signed-off-by: Christian Hopps <chopps@labn.net>
2024-01-11 18:14:58 +00:00
Christian Hopps
7b7725f7b8
lib: change type of inner to struct lyd_node *, cleaner code
Signed-off-by: Christian Hopps <chopps@labn.net>
2024-01-11 13:51:23 +00:00
Christian Hopps
32a4c4019e lib: implement missing YANG choice/case statements.
Signed-off-by: Christian Hopps <chopps@labn.net>
2024-01-11 13:38:57 +00:00
Igor Ryzhov
7e48299c58 lib: explain semantics of northbound operations
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-11 15:06:53 +02:00
Igor Ryzhov
d726114790 mgmt, lib: implement REPLACE operation
Replace operation removes the current data node configuration and sets
the provided value. As current northbound code works only with one
xpath at a time, the operation only makes sense to clear the config of
a container without deleting it itself. However, the next step is to
allow passing JSON-encoded complex values to northbound operations which
will make replace operation much more useful.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-11 15:06:53 +02:00
Igor Ryzhov
fe0d4dc2cb lib: move dnode creation into a separate function
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-11 15:06:53 +02:00
Igor Ryzhov
3c2598a26f mgmt, lib: differentiate DELETE and REMOVE operations
Currently, there's a single operation type which doesn't return error
if the object doesn't exists. To be compatible with NETCONF/RESTCONF,
we should support differentiate between DELETE (fails when object
doesn't exist) and REMOVE (doesn't fail if the object doesn't exist).

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-11 15:06:53 +02:00
Igor Ryzhov
76e4eb84dd mgmtd, lib: implement CREATE_EXCL operation
Currently, there's no difference between CREATE and MODIFY operations.
To be compatible with NETCONF/RESTCONF, add new CREATE_EXCL operation
that throws an error if the configuration data already exists.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-11 15:06:53 +02:00
Igor Ryzhov
5d1a314038 lib: split nb_operation into two types
Currently, nb_operation enum means two different things - edit operation
type (frontend part), and callback type (backend part). These types
overlap, but they are not identical. We need to add more operation
types to support NETCONF/RESTCONF integration, so it's better to have
separate enums to identify different entities.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-11 15:06:50 +02:00
Donatas Abraitis
67e8ef293f
Merge pull request #15098 from donaldsharp/lib_zebra_h_cleanup_2
Lib zebra h cleanup 2
2024-01-11 14:50:21 +02:00
Edwin Brossette
9e06f93df1 lib: use snmp's large fd sets for agentx
The maximum number of file descriptors in an fd set is limited by
FD_SETSIZE. This limitation is important because the libc macros
FD_SET(), FD_CLR() and FD_ISSET() will invoke a sigabort if the size of
the fd set given to them is above FD_SETSIZE.

We ran into such a sigabort with bgpd because snmp can return an fd set
of size higher than FD_SETSIZE when calling snmp_select_info(). An
unfortunate FD_ISSET() call later causes the following abort:

Received signal 6 at 1701115534 (si_addr 0xb94, PC 0x7ff289a16a7c); aborting...
/lib/x86_64-linux-gnu/libfrr.so.0(zlog_backtrace_sigsafe+0xb3) [0x7ff289d62bba]
/lib/x86_64-linux-gnu/libfrr.so.0(zlog_signal+0x1b4) [0x7ff289d62a1f]
/lib/x86_64-linux-gnu/libfrr.so.0(+0x102860) [0x7ff289da4860]
/lib/x86_64-linux-gnu/libc.so.6(+0x42520) [0x7ff2899c2520]
/lib/x86_64-linux-gnu/libc.so.6(pthread_kill+0x12c) [0x7ff289a16a7c]
/lib/x86_64-linux-gnu/libc.so.6(raise+0x16) [0x7ff2899c2476]
/lib/x86_64-linux-gnu/libc.so.6(abort+0xd3) [0x7ff2899a87f3]
/lib/x86_64-linux-gnu/libc.so.6(+0x896f6) [0x7ff289a096f6]
/lib/x86_64-linux-gnu/libc.so.6(__fortify_fail+0x2a) [0x7ff289ab676a]
/lib/x86_64-linux-gnu/libc.so.6(+0x1350c6) [0x7ff289ab50c6]
/lib/x86_64-linux-gnu/libc.so.6(+0x1366ab) [0x7ff289ab66ab]
/lib/x86_64-linux-gnu/libfrrsnmp.so.0(+0x36f5) [0x7ff2897736f5]
/lib/x86_64-linux-gnu/libfrrsnmp.so.0(+0x3c27) [0x7ff289773c27]
/lib/x86_64-linux-gnu/libfrr.so.0(thread_call+0x1c2) [0x7ff289dbe105]
/lib/x86_64-linux-gnu/libfrr.so.0(frr_run+0x257) [0x7ff289d56e69]
/usr/bin/bgpd(main+0x4f4) [0x560965c40488]
/lib/x86_64-linux-gnu/libc.so.6(+0x29d90) [0x7ff2899a9d90]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x80) [0x7ff2899a9e40]
/usr/bin/bgpd(_start+0x25) [0x560965c3e965]
in thread agentx_timeout scheduled from /build/make-pkg/output/_packages/cp-routing/src/lib/agentx.c:122 agentx_events_update()

Also, the following error is logged by snmp just before the abort:
snmp[err]: Use snmp_sess_select_info2() for processing large file descriptors

snmp uses a custom struct netsnmp_large_fd_set to work above the limit
imposed by FD_SETSIZE. It is noteworthy that, when calling
snmp_select_info() instead of snmp_select_info2(), snmp uses the same
code working with its custom, large structs, and copy/paste the result
to a regular, libc compatible fd_set. So there should be no downside
working with snmp_select_info2() instead of snmp_select_info().

Replace every use of the libc file descriptors sets by snmp's extended
file descriptors sets in agentx to acommodate for the high number of
file descriptors that can come out of snmp. This should prevent the
abort seen above.

Signed-off-by: Edwin Brossette <edwin.brossette@6wind.com>
2024-01-10 17:01:59 +01:00
Donatas Abraitis
4c875482a5
Merge pull request #15123 from LabNConsulting/chopps/fix-oper-state-memleak
lib: fix oper-state memleak
2024-01-10 12:16:37 +02:00
Christian Hopps
5519c0fbe6
lib: fix oper-state memleak
Fix memleak when a key-ed query was done for which the key didn't exist.

Signed-off-by: Christian Hopps <chopps@labn.net>
2024-01-09 21:52:41 +00:00
Donald Sharp
c402a0bdc1 lib: limits.h is not needed by zebra.h
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-01-09 12:50:40 -05:00
Donald Sharp
f982bddebd zebra: Nothing is using errno.h
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-01-09 12:50:40 -05:00
Donald Sharp
7c1a8f7a9e lib: string.h was only used by vector.c make it better
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-01-09 12:50:40 -05:00
Donald Sharp
68eca30c58 lib: stdbool.h is not being used by zebra.h
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-01-09 12:50:40 -05:00
Donald Sharp
8049f74fc6 lib: zebra.h is not using signal.h
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-01-09 12:50:40 -05:00
Donald Sharp
b6f1a4089f lib: zebra.h uses pwd.h when it should not
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-01-09 12:50:40 -05:00
Donald Sharp
c6d94a7056 *: zebra.h should not have fcntl.h
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-01-09 12:50:40 -05:00
Donald Sharp
33744ae4fc lib: zebra.h was including compiler.h two times
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-01-09 12:50:40 -05:00
Donald Sharp
7f3d9ea47d lib: remove net/route.h it is not used
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-01-09 12:50:40 -05:00
Donald Sharp
848dcf3d03 *: remove sys/stat.h from zebra.h
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-01-09 12:39:23 -05:00
Donald Sharp
7497d33f2f lib: select.h is not being used by anyone
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-01-09 12:39:23 -05:00
Donald Sharp
22b439090c
Merge pull request #15103 from LabNConsulting/chopps/oper-filter
Implement full XPath 1.0 functionality
2024-01-09 12:31:36 -05:00
Russ White
d5a0a70bbf
Merge pull request #15001 from pguibert6WIND/zebra_nexthop_rework
Zebra nexthop rework
2024-01-09 10:11:35 -05:00
Christian Hopps
1e4229fc1f lib: use libyang functions if they are present
Add configure.ac tests for libyang functions, if not present supply the
functionality ourselves in yang.[ch]

Signed-off-by: Christian Hopps <chopps@labn.net>
2024-01-07 15:17:56 +00:00
Christian Hopps
cf67a7e265 lib: mgmtd: implement full XPath 1.0 predicate functionality
Allow user to specify full YANG compatible XPath 1.0 predicates. This
allows for trimming results of generic queries using functions and other
non-key predicates from XPath 1.0

Signed-off-by: Christian Hopps <chopps@labn.net>
2024-01-07 15:17:30 +00:00
Christian Hopps
00138ffb47 lib: fix clang SA warnings
Signed-off-by: Christian Hopps <chopps@labn.net>
2024-01-07 15:04:18 +00:00
Donatas Abraitis
e0422df53b vtysh: Rename show thread ... to show event ...
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-01-07 14:43:38 +02:00
Donatas Abraitis
d2fe1936d9
Merge pull request #15105 from donaldsharp/event_thread_mishap
lib: Use event name instead of thread
2024-01-07 13:27:02 +02:00
Donald Sharp
5146ba710b lib: Use event name instead of thread
The thread system has been renamed, let's use the proper
terminology now in the show commands.  Also realign
output a tiny bit for stuff that was missing.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-01-06 20:43:22 -05:00
Christian Hopps
43331c0d78
Merge pull request #15092 from donaldsharp/lib_zebra_h_cleanup
Lib zebra h cleanup
2024-01-05 09:40:56 -05:00
Donald Sharp
96067c7d9d
Merge pull request #15089 from pguibert6WIND/asan_sharpd_fix
lib: fix memory leak when disabling nexthop_hold contexts
2024-01-05 09:27:33 -05:00
Donald Sharp
4038b6db3a
Merge pull request #15097 from louis-6wind/cleanup_vrf_update
lib: remove zebra_interface_vrf_update_read()
2024-01-05 09:25:41 -05:00
Donald Sharp
d04349e7f6
Merge pull request #15086 from LabNConsulting/chopps/remove-old-oper-iter-code
lib: remove unused/replaced oper-state iteration code
2024-01-05 09:24:23 -05:00
Louis Scalbert
c6fe42f64d lib: remove zebra_interface_vrf_update_read()
zebra_interface_vrf_update_read is orphan. Remove it.

Fixes: b580c52698 ("*: remove ZEBRA_INTERFACE_VRF_UPDATE")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-01-05 11:08:55 +01:00
Christian Hopps
ae1d854abf
lib: fix initializer warning on centos 7.
Signed-off-by: Christian Hopps <chopps@labn.net>
2024-01-05 06:45:34 +00:00
Donald Sharp
496d87c14f lib: sys/utsname.h is not needed in zebra.h
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-01-04 15:34:22 -05:00
Donald Sharp
cbc187867c lib: zebra.h does not need to include syslog.h
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-01-04 15:34:22 -05:00
Donald Sharp
0b4ff79063 *: sys/uio.h does not need to be in zebra.h
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-01-04 15:34:22 -05:00
Donald Sharp
d69ac58c65 lib, sharpd: Move sys/resource.h to where it is used
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-01-04 14:43:46 -05:00
Donald Sharp
2700519cb3 *: Remove sys/ioctl.h from zebra.h
Practically no-one uses this and ioctls are pretty much
wrappered.  Further wrappering could make this even better.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-01-04 14:42:17 -05:00
Donald Sharp
88f8c90073 lib, vtysh: Remove inclusion of grp.h for everyone
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-01-04 14:34:41 -05:00
Donald Sharp
1b1fc14ffc lib: Remove in_systm.h it is never used
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-01-04 14:32:32 -05:00
Donald Sharp
75b3e82dfa *: Remove cost of including netinet/icmp.h everywhere
This file inclusion is only used in 3 places move
the includes to those spots.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-01-04 14:26:33 -05:00
Donald Sharp
ca54540576 lib: Remove inclusion of various MAXINT from zebra.h
All modern systems should have these defined.  Let's stop
paying the cost of this compilation.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-01-04 14:24:01 -05:00
Donald Sharp
fbc31156f0 lib: HAVE_GLIBC_BACKTRACE does not belong in zebra.h
The backtrace functionality has been abstracted over
to zlog_backtrace().  Now that every place uses this
move the inclusion for HAVE_GLIBC_BACKTRACE into
the appropriate files instead of having everyone
pay for this costly include.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-01-04 14:20:40 -05:00
Donald Sharp
78690deaf2 lib: Move some priviledge headers to file they are used.
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-01-04 14:04:36 -05:00
Donald Sharp
2bf051a577 *: Remove Crypto openSSL define from zebra.h
Only a couple of places use this.  Move these to a better
spot.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-01-04 14:02:34 -05:00
Donald Sharp
10387101fe lib: Breakout sendmmsg into it's own header
The only 2 places sendmmsg is used is in zlog_5424.c
and zlog_live.c.  Why is the rest of the entire system
paying for this compilation?

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-01-04 13:56:09 -05:00
Philippe Guibert
e266c44345 lib: fix memory leak when disabling nexthop_hold contexts
A memory leak is detected when stopping the sharpd daemon
with a nexthop group configuration that includes nexthops.

The nexthop_hold structure and its attributes are not
freed. Fix it by adding the missing free function.

Fixes: 98cbbaea91 ("lib: Handle if up/down and vrf enable/disable events")
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2024-01-04 17:12:36 +01:00
Christian Hopps
87a0e1f52b lib: remove unused/replaced oper-state iteration code
Signed-off-by: Christian Hopps <chopps@labn.net>
2024-01-04 06:33:43 +00:00
Russ White
54c2d327d3
Merge pull request #12261 from cscarpitta/srv6-encap-src-addr
zebra: Add the support of the Source Addr param of the SRv6 Encapsulation
2024-01-02 10:37:34 -05:00
Donald Sharp
de01b61b32
Merge pull request #15070 from LabNConsulting/chopps/fix-coverity-errors
chopps/fix coverity errors
2024-01-02 10:09:03 -05:00
Donald Sharp
60f099657f
Merge pull request #15073 from LabNConsulting/chopps/fix-yang-key-queries
lib: fix specific entry queries
2024-01-02 10:06:22 -05:00
Christian Hopps
412eec1bed
lib: don't count on scheme key nodes being first children
Heard back from libyang folks that this is not something they consider part of
the API and/or are going to guarantee. So we cannot count on it. Expect keys at
any location on the child sibling list.

Signed-off-by: Christian Hopps <chopps@labn.net>
2024-01-02 11:34:34 +00:00
Christian Hopps
7e6595698b
lib: fix specific entry queries
- fix key leaf queries
- fix specific list entry with non-key leaf top element

Signed-off-by: Christian Hopps <chopps@labn.net>
2024-01-02 09:47:15 +00:00
Christian Hopps
39e0f331d2 lib: mgmtd: increase soft-max msg size to 64K
- remove unused mgmt client/server constants

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-12-30 16:03:45 +00:00
Christian Hopps
1a7b50a00a lib: fix coverity CID 1574981
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-12-30 16:03:45 +00:00
Christian Hopps
b28cd405c8 lib: fix coverity CID 1574979
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-12-30 16:03:45 +00:00
Christian Hopps
db11968a3d lib: fix coverity CID 1574977
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-12-30 16:03:45 +00:00
Christian Hopps
b8b5290105 lib: fixes required after rebasing
lib: fix checkpatch warnings
lib: darr: disable check
mgmtd: fix initialization

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-12-28 18:17:24 +00:00
Christian Hopps
d266b1cc9c zebra: support yielding between oper state routes query
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-12-28 17:53:40 +00:00
Christian Hopps
4e0147a05e lib: add dedicated API functions for native msgs
- reorg native message header

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-12-28 17:53:40 +00:00
Christian Hopps
ad1ccb6e62 lib: northbound: add yielding and batching to oper-state queries
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-12-28 17:52:57 +00:00
Christian Hopps
b7db6b2675 lib: darr: add ability to set MTYPE for dynamic arrays
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-12-28 17:52:57 +00:00
Christian Hopps
356c01b121 lib: yang: add yang_get_node_keys() function
- comment out unused mem-leaking function.
- improve yang_dnode_get_path return type

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-12-28 17:52:57 +00:00
Christian Hopps
408ee24e41 lib: create and use libyang tree during oper-state walk
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-12-28 17:52:57 +00:00
Christian Hopps
d58653a5ba lib: northbound: improve xpath functionality
Allow user to leave keys off of a list entry node at the end of the xpath. This
will return all list entries. Previously there was no way to just get the list
entries. One had to leave off the last list entry node which would then return
all list nodes as well as all the siblings at the same level.

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-12-28 17:52:57 +00:00
Christian Hopps
db0211d48a lib: yang: add new functions
- yang_get_key_preds
- yang_lyd_new_list

A function like new_list was added recently to libyang,
this is a compat version.

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-12-28 17:52:57 +00:00
Christian Hopps
f3d6edc7ee lib: darr: add new access and str functions
- darr_last(), and darr_strdup_cap().
- strcat, strdup, strlen, strnul equivs.

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-12-28 17:52:57 +00:00
Christian Hopps
9cd8693363 mgmtd: step 6: remove old unfinished get-data code
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-12-28 10:41:54 +00:00
Christian Hopps
be2424a875 mgmtd: step 4: FE adapter get-tree functionality
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-12-28 10:41:54 +00:00
Christian Hopps
4fee273e9c lib: step 2: mgmtd: BE client code for get-tree functionality
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-12-28 10:41:54 +00:00
Christian Hopps
772f6c07c7 lib: step 1: mgmtd: add FE get-tree functionality
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-12-28 10:41:54 +00:00
Christian Hopps
80cac370d0 lib: yang: add tree "printing" utility functions
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-12-26 08:34:56 -05:00
Christian Hopps
8790457c46 lib: add simplified native msg support
This is intended to replace protobuf use in mgmtd.

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-12-26 08:34:56 -05:00
Donald Sharp
09fbf2e56d lib: Keychain.c was using free
This is a bit of a bummer that this slipped through
for so long.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-12-21 17:01:56 -05:00
Philippe Guibert
d8477d4bb5 bgpd, lib: add zapi_route_set_nhg_id() support
There is no function that both sets the nhg id, and sets
the ZAPI_MESSAGE_NHG flag if the nhg id is valid.
Create a ZAPI API to do this, and apply the changes wherever
needed.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-12-18 10:08:45 +01:00
Donald Sharp
f38687b8f5 lib, bgpd, nhrpd: Cleanup memory in lib/resolver on shutdown
This memory was not being cleaned up on shutdown.  Fix this.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-12-16 09:18:41 -05:00
Carmine Scarpitta
69bff19c43 zebra, lib, vtysh: Add CLI cmd to set/unset SRv6 encap source address
- Add a new node `SRV6_ENCAP_NODE` to the CLI graph. This node allows
users to configure encapsulation parameters for SRv6, including the
source address of the outer encapsulating IPv6 header.

- Install a new CLI command `source-address` under the
`SRV6_ENCAP_NODE` node. This command is used to configure the source
address of the outer encapsulating IPv6 header.

- Install a new CLI command `no source-address` under the
`SRV6_ENCAP_NODE` node. This command is used to unset the
source address of the outer encapsulating IPv6 header and restore the
default source address.

Examples:

```
router# segment-routing
router(sr)# srv6
router(srv6)# encapsulation
router(srv6-encap)# source-address fc00:0:1::1
```

```
router# segment-routing
router(sr)# srv6
router(srv6)# encapsulation
router(srv6-encap)# no source-address
```

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2023-12-14 14:58:33 +01:00
Donatas Abraitis
f17cd4587d
Merge pull request #14985 from donaldsharp/zebra_delete_memory_problems
Zebra delete memory problems
2023-12-12 16:31:52 +02:00
Christian Hopps
29340e6b06 lib: fix the ASAN OneDefinitionRule violation.
Rename global client pointer variables and make the linkage static.

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-12-11 19:53:03 -05:00
Donald Sharp
3d1f0c467b zebra: On shutdown properly free up ns memory
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-12-11 15:44:26 -05:00
Donald Sharp
2df4683af0
Merge pull request #14936 from LabNConsulting/chopps/mgmt-dbg-improve
Chopps/mgmt dbg improve
2023-12-07 11:20:54 -05:00
Donald Sharp
8a574840a4 zebra: Add connected with noprefixroute
Add ability for the connected routes to know
if they are a prefix route or not.

sharpd@eva:/work/home/sharpd/frr1$ ip addr show dev dummy1
13: dummy1: <BROADCAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default qlen 1000
    link/ether aa:93:ce:ce:3f:62 brd ff:ff:ff:ff:ff:ff
    inet 192.168.55.1/24 scope global noprefixroute dummy1
       valid_lft forever preferred_lft forever
    inet 192.168.56.1/24 scope global dummy1
       valid_lft forever preferred_lft forever
    inet6 fe80::a893:ceff:fece:3f62/64 scope link
       valid_lft forever preferred_lft forever

sharpd@eva:/work/home/sharpd/frr1$ sudo vtysh -c "show int dummy1"
Interface dummy1 is up, line protocol is up
  Link ups:       0    last: (never)
  Link downs:     0    last: (never)
  vrf: default
  index 13 metric 0 mtu 1500 speed 0 txqlen 1000
  flags: <UP,BROADCAST,RUNNING,NOARP>
  Type: Ethernet
  HWaddr: aa:93:ce:ce:3f:62
  inet 192.168.55.1/24 noprefixroute
  inet 192.168.56.1/24
  inet6 fe80::a893:ceff:fece:3f62/64
  Interface Type Other
  Interface Slave Type None
  protodown: off

sharpd@eva:/work/home/sharpd/frr1$ sudo vtysh -c "show ip route"
Codes: K - kernel route, C - connected, L - local, S - static,
       R - RIP, O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
       F - PBR, f - OpenFabric, t - Table-Direct,
       > - selected route, * - FIB route, q - queued, r - rejected, b - backup
       t - trapped, o - offload failure

K>* 0.0.0.0/0 [0/100] via 192.168.119.1, enp13s0, 00:00:08
K>* 169.254.0.0/16 [0/1000] is directly connected, virbr2 linkdown, 00:00:08
L>* 192.168.44.1/32 is directly connected, dummy2, 00:00:08
L>* 192.168.55.1/32 is directly connected, dummy1, 00:00:08
C>* 192.168.56.0/24 is directly connected, dummy1, 00:00:08
L>* 192.168.56.1/32 is directly connected, dummy1, 00:00:08
L>* 192.168.119.205/32 is directly connected, enp13s0, 00:00:08

sharpd@eva:/work/home/sharpd/frr1$ ip route show
default via 192.168.119.1 dev enp13s0 proto dhcp metric 100
169.254.0.0/16 dev virbr2 scope link metric 1000 linkdown
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 linkdown
192.168.45.0/24 dev virbr2 proto kernel scope link src 192.168.45.1 linkdown
192.168.56.0/24 dev dummy1 proto kernel scope link src 192.168.56.1
192.168.119.0/24 dev enp13s0 proto kernel scope link src 192.168.119.205 metric 100
192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 linkdown

sharpd@eva:/work/home/sharpd/frr1$ ip route show table 255
local 127.0.0.0/8 dev lo proto kernel scope host src 127.0.0.1
local 127.0.0.1 dev lo proto kernel scope host src 127.0.0.1
broadcast 127.255.255.255 dev lo proto kernel scope link src 127.0.0.1
local 172.17.0.1 dev docker0 proto kernel scope host src 172.17.0.1
broadcast 172.17.255.255 dev docker0 proto kernel scope link src 172.17.0.1 linkdown
local 192.168.44.1 dev dummy2 proto kernel scope host src 192.168.44.1
broadcast 192.168.44.255 dev dummy2 proto kernel scope link src 192.168.44.1
local 192.168.45.1 dev virbr2 proto kernel scope host src 192.168.45.1
broadcast 192.168.45.255 dev virbr2 proto kernel scope link src 192.168.45.1 linkdown
local 192.168.55.1 dev dummy1 proto kernel scope host src 192.168.55.1
broadcast 192.168.55.255 dev dummy1 proto kernel scope link src 192.168.55.1
local 192.168.56.1 dev dummy1 proto kernel scope host src 192.168.56.1
broadcast 192.168.56.255 dev dummy1 proto kernel scope link src 192.168.56.1
local 192.168.119.205 dev enp13s0 proto kernel scope host src 192.168.119.205
broadcast 192.168.119.255 dev enp13s0 proto kernel scope link src 192.168.119.205
local 192.168.122.1 dev virbr0 proto kernel scope host src 192.168.122.1
broadcast 192.168.122.255 dev virbr0 proto kernel scope link src 192.168.122.1 linkdown

Fixes: #14952
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-12-06 09:27:52 -05:00
Christian Hopps
c37c19a9ec lib: mgmtd: enable conn debugs when user enables client debug
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-12-05 13:39:40 -05:00
Russ White
edb1cb8dab
Merge pull request #14947 from pguibert6WIND/nexthop_num_no_recurse_static
lib: fix nexthop_group_nexthop_num_no_recurse() is static
2023-12-05 11:55:21 -05:00
Russ White
0a79e117d6
Merge pull request #12600 from donaldsharp/local_routes
*: Introduce Local Host Routes to FRR
2023-12-05 11:00:44 -05:00
Philippe Guibert
66f08b3e15 lib: fix nexthop_group_nexthop_num_no_recurse() is static
No need to declare 'nexthop_group_nexthop_num_no_recurse()' as external.

Fixes: 98cda54a95 ("zebra: Add recursive functionality to NHE's")

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-12-05 13:59:25 +01:00
Donald Sharp
6be9452e50
Merge pull request #14885 from pguibert6WIND/misc_nhg_fixes
various nexthop group fixes
2023-12-04 07:31:14 -05:00
Igor Ryzhov
aa6934bc5e
Merge pull request #14911 from LabNConsulting/chopps/speed-xpath-up
lib: all: remove './' from xpath 22% speedup
2023-12-01 13:32:32 +02:00
Philippe Guibert
0c34fa2cc6 lib: fix nexthop node entry from nhg_list
When stopping a VRF, the linked list entries must be
removed too.

Fixes: 98cbbaea91 ("lib: Handle if up/down and vrf enable/disable events")

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-11-30 14:25:08 +01:00
Philippe Guibert
2ff41dd690 lib: remove useless nexthop_group_active_nexthop_num_no_recurse()
The nexthop_group_active_nexthop_num_no_recurse() function is no more
used. Let us remove the function call.

Fixes: 148813c22a ("zebra: zebra_nhg check each nexthop for active, not just number")

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-11-30 14:25:08 +01:00
Donatas Abraitis
3ed1bc81be
Merge pull request #14907 from Keelan10/bgp_srv6-leak
bgpd: Free Memory for SRv6 Functions and Locator Chunks
2023-11-30 09:22:57 +02:00
Christian Hopps
2c01083d35 lib: all: remove './' from xpath 22% speedup
fixes #8299

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-11-29 14:37:23 -05:00
Keelan10
8e7044ba3b bgpd: Free Memory for SRv6 Functions and Locator Chunks
Implement proper memory cleanup for SRv6 functions and locator chunks to prevent potential memory leaks.
The list callback deletion functions have been set.

The ASan leak log for reference:

```
***********************************************************************************
Address Sanitizer Error detected in bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.asan.bgpd.4180

=================================================================
==4180==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 544 byte(s) in 2 object(s) allocated from:
    #0 0x7f8d176a0d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
    #1 0x7f8d1709f238 in qcalloc lib/memory.c:105
    #2 0x55d5dba6ee75 in sid_register bgpd/bgp_mplsvpn.c:591
    #3 0x55d5dba6ee75 in alloc_new_sid bgpd/bgp_mplsvpn.c:712
    #4 0x55d5dba6f3ce in ensure_vrf_tovpn_sid_per_af bgpd/bgp_mplsvpn.c:758
    #5 0x55d5dba6fb94 in ensure_vrf_tovpn_sid bgpd/bgp_mplsvpn.c:849
    #6 0x55d5dba7f975 in vpn_leak_postchange bgpd/bgp_mplsvpn.h:299
    #7 0x55d5dba7f975 in vpn_leak_postchange_all bgpd/bgp_mplsvpn.c:3704
    #8 0x55d5dbbb6c66 in bgp_zebra_process_srv6_locator_chunk bgpd/bgp_zebra.c:3164
    #9 0x7f8d1716f08a in zclient_read lib/zclient.c:4459
    #10 0x7f8d1713f034 in event_call lib/event.c:1974
    #11 0x7f8d1708242b in frr_run lib/libfrr.c:1214
    #12 0x55d5db99d19d in main bgpd/bgp_main.c:510
    #13 0x7f8d160c5c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)

Direct leak of 296 byte(s) in 1 object(s) allocated from:
    #0 0x7f8d176a0d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
    #1 0x7f8d1709f238 in qcalloc lib/memory.c:105
    #2 0x7f8d170b1d5f in srv6_locator_chunk_alloc lib/srv6.c:135
    #3 0x55d5dbbb6a19 in bgp_zebra_process_srv6_locator_chunk bgpd/bgp_zebra.c:3144
    #4 0x7f8d1716f08a in zclient_read lib/zclient.c:4459
    #5 0x7f8d1713f034 in event_call lib/event.c:1974
    #6 0x7f8d1708242b in frr_run lib/libfrr.c:1214
    #7 0x55d5db99d19d in main bgpd/bgp_main.c:510
    #8 0x7f8d160c5c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)
***********************************************************************************

```

Signed-off-by: Keelan Cannoo <keelan.cannoo@icloud.com>
2023-11-29 18:38:49 +04:00
Christian Hopps
e7064647b9
Merge pull request #14838 from idryzhov/mgmtd-cli-out
Output configuration of mgmtd-converted daemons from mgmtd
2023-11-29 14:50:16 +01:00
Donatas Abraitis
36547f400e
Merge pull request #9012 from dlqs/lua-poly
Refactor decoder for Lua hook system
2023-11-29 15:14:46 +02:00
Christian Hopps
bb6fe6beb9
Merge pull request #14811 from donaldsharp/zebra_final_shutdown_finally
Zebra final shutdown finally
2023-11-28 20:14:42 +01:00
Russ White
a526795144
Merge pull request #14856 from opensourcerouting/show-rm
lib: fix show route map JSON display
2023-11-28 08:46:53 -05:00
Russ White
1fcc3d26c4
Merge pull request #14819 from opensourcerouting/feature/bgp_debug_updates_with_route-map
bgpd: Add an ability to filter UPDATEs using neighbor with prefix-list
2023-11-28 08:40:07 -05:00
Donald Sharp
0dc7704fd5
Merge pull request #14867 from opensourcerouting/zclient-options-cleanup
*: clean up `zclient` options
2023-11-25 09:15:07 -05:00
Rafael Zalamena
570fdc55fd lib,vtysh: fix show route map JSON output
Move the command from 'lib' to 'vtysh' so we can properly format the
JSON output in a correct manner.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2023-11-24 10:00:25 -03:00
David Lamparter
5a40f2b0e7 lib, bgp/vnc: add .auxiliary zclient option
Avoids calling VRF/interface/... handlers in library code more than
once.  It's kinda surprising that this hasn't been blowing up already
for the VNC code, luckily these handlers are (mostly?) idempotent.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-11-23 15:42:59 +01:00
David Lamparter
cc90c54b36 *: add zclient_options_sync
... and use it instead of fiddling with the `.synchronous` field.

(Make it const while at it.)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-11-23 15:20:13 +01:00
David Lamparter
a13d2933b7 zebra, lib: remove notify field from hello message
This is no longer used.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-11-23 15:20:11 +01:00
David Lamparter
25a1dccc56 lib: remove .receive_notify zclient option
This should just be set with `ZEBRA_ROUTE_NOTIFY_REQUEST` instead.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-11-23 15:05:10 +01:00
David Lamparter
6e7465c54e lib: remove distribute_{in,out} from interface
Both of these fields are just straight up completely unused.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-11-22 23:00:30 +01:00
David Lamparter
8b23c0b0bd *: convert struct interface->connected to DLIST
Replace `struct list *` with `DLIST(if_connected, ...)`.

NB: while converting this, I found multiple places using connected
prefixes assuming they were IPv4 without checking:

- vrrpd/vrrp.c: vrrp_socket()
- zebra/irdp_interface.c: irdp_get_prefix(), irdp_if_start(),
  irdp_advert_off()

(these fixes are really hard to split off into separate commits as that
would require going back and reapplying the change but with the old list
handling)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-11-22 23:00:30 +01:00
Christian Hopps
79b7b8df1f
Merge pull request #14815 from idryzhov/lib-mgmt-deps
Remove lib dependency on mgmtd
2023-11-22 10:51:40 +01:00
Donatas Abraitis
b84476e0bb
Merge pull request #14850 from donaldsharp/IFNAMSIZ_GET_YOUR_SHIT_TOGETHER
*: Let's use the native IFNAMSIZ instead of INTERFACE_NAMSIZ
2023-11-22 09:13:58 +02:00
Donatas Abraitis
9d8e384d12 lib: Print debug config in files after we have prefix-lists
Without this if we enter something like `debug bgp updates in x.x.x.x prefix-list y`,
prefix-list can't be lookup up, because when we read the config, debug does not know
anything about this prefix-list.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-11-22 08:20:01 +02:00
Donald Sharp
88a54b123d *: Cleanup keychain on shutdown
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-11-21 12:41:18 -05:00
Donald Sharp
01af05fbd5
Merge pull request #14834 from opensourcerouting/zclient-nexthop-update
*: move common NHT update decoding bits into lib/
2023-11-21 10:56:47 -05:00
Donald Sharp
07b91ca096 *: Let's use the native IFNAMSIZ instead of INTERFACE_NAMSIZ
INTERFACE_NAMSIZ is just a redefine of IFNAMSIZ and IFNAMSIZ
is the standard for interface name length on all platforms
that FRR currently compiles on.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-11-21 08:08:29 -05:00
Igor Ryzhov
a22f5a5289 mgmtd: add node for writing configuration
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-11-21 13:13:05 +02:00
Igor Ryzhov
0d2e1985a8 lib: load nb callbacks even with ignore_cbs set
Don't skip NB callbacks loading when ignore_cbs is set for a YANG
module. It allows us to use cli_show, cli_show_end and cli_cmp callbacks
in mgmtd and output configuration directly from it instead of backend
daemons.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-11-21 13:13:05 +02:00
Donald Lee
fca8ee275c lib: Update int and ll decoders with new MTYPE
In the master branch a new MTYPE_SCRIPT_RES was created for
frrscript_get_results, lua_to decoders should use that

Signed-off-by: Donald Lee <dlqs@gmx.com>
2023-11-20 20:45:02 -05:00
Donald Lee
d2acf63f16 lib: Create encoders for int and rename stuff
Create encoders/decoders for int and rename current int encoders
/decoders to long long.

Signed-off-by: Donald Lee <dlqs@gmx.com>
2023-11-20 20:45:02 -05:00
Donald Lee
ac91b343d6 lib: Remove old noop decoders
Co-authored-by: Quentin Young <qlyoung@qlyoung.net>
Signed-off-by: Quentin Young <qlyoung@qlyoung.net>
Signed-off-by: Donald Lee <dlqs@gmx.com>
2023-11-20 20:45:02 -05:00
Donald Lee
ac3fdc60df lib: Add more Lua types to encoder/decoder
Signed-off-by: Donald Lee <dlqs@gmx.com>
2023-11-20 20:45:01 -05:00
Donald Lee
2faab06ed3 lib: Add polymorphic noop macro
Co-authored-by: Quentin Young <qlyoung@qlyoung.net>
Signed-off-by: Quentin Young <qlyoung@qlyoung.net>
Signed-off-by: Donald Lee <dlqs@gmx.com>
2023-11-20 20:44:57 -05:00
David Lamparter
03c4375a4a lib: make zapi_nexthop_update_decode private
zapi_nexthop_update_decode() is no longer called externally.

Also move the comment to zclient->nexthop_update where it now belongs.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-11-20 11:28:39 +01:00
David Lamparter
b951e59300 lib: add common NHT update decode callback
All users of `ZEBRA_NEXTHOP_UPDATE` check the VRF and then call into
`zapi_nexthop_update_decode` before further processing.  Begin moving
this into common code in lib/.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-11-20 11:24:21 +01:00
David Lamparter
75a7b5b6b6 lib: use LYD_VALIDATE_MULTI_ERROR only if available
LYD_VALIDATE_MULTI_ERROR was added in libyang 2.1.36.  The currently
enforced minimum of libyang is 2.0.0.  Stick an #ifdef around it.

Fixes: 51a2a4b3f4 ("lib: print all errors when validating a config")
Cc: Igor Ryzhov <iryzhov@nfware.com>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-11-20 10:32:52 +01:00
Christian Hopps
94659cf9e5
Merge pull request #14657 from idryzhov/mgmtd-remove-batch-ids
mgmtd, lib: remove batch ids from all messages
2023-11-18 05:59:44 +01:00
Igor Ryzhov
057f442309 lib, mgmtd: remove function duplication
And also remove lib dependency on mgmtd.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-11-17 11:27:03 +01:00
Igor Ryzhov
c0568d4f9e lib, mgmtd: move common header to lib
The common header included from lib and other daemons should be located
in lib, not in mgmt directory.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-11-17 11:27:03 +01:00
Donald Sharp
520bb404f5
Merge pull request #14800 from idryzhov/nb-validate-errors
Print all errors when validating NB configuration
2023-11-15 13:19:11 -05:00
Igor Ryzhov
51a2a4b3f4 lib: print all errors when validating a config
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-11-15 14:17:29 +01:00
Donatas Abraitis
3a109ef215
Merge pull request #14796 from donaldsharp/ospf_bsd_double_whammy_no_whammy
lib: Prevent infinite loop in ospf
2023-11-15 09:39:31 +02:00
Igor Ryzhov
81cb39a934 lib: fix printing multiple yang errors
When printing multiple YANG errors, we should print paths for all of
them, not only for the last one.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-11-15 03:27:32 +01:00
Donald Sharp
1c0f3b61c9 lib: Prevent infinite loop in ospf
For some series of calls in FREEBSD setting the SO_RCVBUF size will
always fail under freebsd.  This is no bueno since the
setsockopt_so_recvbuf call goes into an infinite loop.

(gdb) bt
 0  setsockopt () at setsockopt.S:4
 1  0x0000000083065870 in setsockopt_so_recvbuf (sock=15, size=0) at lib/sockopt.c:26
 2  0x00000000002bd200 in ospf_ifp_sock_init (ifp=<optimized out>, ifp@entry=0x8d1dd500) at ospfd/ospf_network.c:290
 3  0x00000000002ad1e0 in ospf_if_new (ospf=0x8eefc000, ifp=0x8d1dd500, p=0x8eecf1c0) at ospfd/ospf_interface.c:276
 4  0x0000000000304ee0 in add_ospf_interface (co=0x8eecbe10, area=0x8d192100) at ospfd/ospfd.c:1115
 5  0x00000000003050fc in ospf_network_run_interface (ospf=0x8eefc000, ifp=0x8d1dd500, p=0x80ff63f8, given_area=0x8d192100)
    at ospfd/ospfd.c:1460
 6  ospf_network_run (p=0x80ff63f8, area=0x8d192100) at ospfd/ospfd.c:1474
 7  ospf_network_set (ospf=ospf@entry=0x8eefc000, p=p@entry=0x80ff63f8, area_id=..., df=<optimized out>) at ospfd/ospfd.c:1247
 8  0x00000000002e876c in ospf_network_area (self=<optimized out>, vty=0x8eef3180, argc=<optimized out>, argv=<optimized out>)
    at ospfd/ospf_vty.c:560
 9  0x0000000083006f24 in cmd_execute_command_real (vline=vline@entry=0x8eee9100, vty=vty@entry=0x8eef3180, cmd=<optimized out>,
    cmd@entry=0x0, up_level=<optimized out>) at lib/command.c:978
 10 0x0000000083006b30 in cmd_execute_command (vline=0x8eee9100, vty=vty@entry=0x8eef3180, cmd=cmd@entry=0x0, vtysh=vtysh@entry=0)
    at lib/command.c:1037
 11 0x0000000083007044 in cmd_execute (vty=vty@entry=0x8eef3180, cmd=cmd@entry=0x8eefb000 "network 192.168.64.0/24 area 0.0.0.0",
    matched=0x0, vtysh=0) at lib/command.c:1203
 12 0x000000008307e9cc in vty_command (vty=0x8eef3180, buf=0x8eefb000 "network 192.168.64.0/24 area 0.0.0.0") at lib/vty.c:594
 13 vty_execute (vty=vty@entry=0x8eef3180) at lib/vty.c:1357
 14 0x000000008307ce40 in vtysh_read (thread=<optimized out>) at lib/vty.c:2365
 15 0x0000000083073db0 in event_call (thread=thread@entry=0x80ff88a0) at lib/event.c:1965
 16 0x000000008302c604 in frr_run (master=0x8d188140) at lib/libfrr.c:1214
 17 0x000000000029c330 in main (argc=6, argv=<optimized out>) at ospfd/ospf_main.c:252
(gdb)

Force the setsockopt function to quit when the value we are passing no
longer makes any sense.

Fixes: #14790
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-11-14 12:02:30 -05:00
Russ White
44df1677cc
Merge pull request #14725 from donaldsharp/event_io_smoothing
Event io smoothing
2023-11-14 11:15:54 -05:00
Donald Sharp
c62c0181f0
Merge pull request #14768 from idryzhov/mgmtd-base-xpath
lib, mgmtd: respect base xpath in mgmtd
2023-11-13 09:19:07 -05:00
Igor Ryzhov
5dcd9f65e3
Merge pull request #14772 from LabNConsulting/fix-darr-memory-acct 2023-11-13 05:47:36 +02:00
Igor Ryzhov
8fb5596742
Merge pull request #14771 from LabNConsulting/fix-mgmtd-client-memleaks
lib: mgmtd: fix debug cli commands and memleaks
2023-11-12 20:46:04 +02:00
Igor Ryzhov
b8a2efbf2f lib, mgmtd: respect base xpath in mgmtd
`nb_cli_apply_changes` can be called with base xpath which should be
prepended to xpaths of every change in a transaction. This base xpath is
respected by regular northbound CLI but not by mgmtd. This commit fixes
the problem.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-11-12 20:28:08 +02:00
Donatas Abraitis
2c0c2c773e
Merge pull request #14767 from idryzhov/fix-change-value-free
lib: fix possible freeing of libyang data
2023-11-12 20:16:19 +02:00
Igor Ryzhov
b3b5951ee7 mgmtd, lib: remove batch ids from all messages
Batch IDs are only used to verify that all messages were received and
processed by a backend. It's not necessary to do that as we use reliable
stream transport - messages can't be dropped or received out of order.

This commit also fixes possible race condition that can happen if
one backend process messages slower than other backends.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-11-12 03:20:54 +02:00
Christian Hopps
d8042cb3c1 lib: free the log file resources created at startup and config
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-11-11 20:31:13 +01:00
Christian Hopps
a6c8e08ecd lib: darr needs to use memory.h for both alloc and free
Was using XREALLOC() and then free(). instant "memleaks".

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-11-11 20:30:02 +01:00
Christian Hopps
59beac5013 lib: mgmtd: fix debug cli commands and memleaks
- Cannot have 2 cmd_node's with same .node number. Install the mgmtd
client library debug nodes (client frontend and client backend) using
new unique node numbers. Fixes memleaks.

- Fix "debug mgmt client backend" to generate correct config (and not
for frontend).

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-11-11 19:25:03 +01:00
Igor Ryzhov
814b9fb772 lib: fix possible freeing of libyang data
mgmtd frees all non-NULL change->value variables at the end of every
commit. We shouldn't assign change->value with data returned by libyang
to prevent freeing of library-allocated memory.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-11-11 02:18:24 +02:00
Donald Sharp
57ea8ac8c3 lib: Modify event system to treat fd access more fairly
Keep track of the last starting spot of where fd's were
being handled for read operations.  Modify the io read
handler to cycle through the list of fd's that need
to be handled such that fd's at the front do not take
precedence for being handled all the time.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-11-08 15:32:56 -05:00
Donald Sharp
6b19e40730 lib: Create a helper function for io read operations
Currently when io is ready inside of the event system
the first FD received is always preferred as the ones
that are handled first.  This leads to results where
events associated with these first FD's are always handled
first.

In anticipation of a change to make this more fair
let's abstract the function handler.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-11-08 15:31:28 -05:00
Igor Ryzhov
448f75e56d
Merge pull request #14525 from LabNConsulting/chopps/mgmtd-simplify-xpaths
chopps/mgmtd simplify xpaths
2023-11-08 16:30:46 +02:00
Donald Sharp
85a80ba5aa
Merge pull request #14544 from idryzhov/mgmt-scratch-buffer
mgmt: delete candidate scratch buffer
2023-11-08 09:18:27 -05:00
Donald Sharp
6de9f7fbf5 *: Move distance related defines into their own header
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-11-07 06:47:51 -05:00
Donald Sharp
42ddcf71e5 *: Remove APPLE #defines from build
We cannot build on apple machines at all due
to our usage of some gcc extensions that will
probably never see the light of day again.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-11-07 06:46:19 -05:00
Donald Sharp
315aa6cde4 *: Remove netlink headers from lib/zebra.h
The headers associated with netlink code
really only belong in those that need it.
Move these headers out of lib/zebra.h and
into more appropriate places.  bgp's usage
of the RT_TABLE_XXX defines are probably not
appropriate and will be cleaned up in future
commits.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-11-07 06:46:19 -05:00
Christian Hopps
3184f63a90 lib: yang: restore old API use now that it's fixed
This also avoids a bug in the workaround function if the set variable
wasn't set to NULL the Debug version of libyang would sigsegv.

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-11-06 17:44:58 -05:00
Christian Hopps
a65cda16b2 mgmtd: simplify xpath registries
- move from client id indexed array of uints for register info
  per client to a u64 bitmask.
- add bit walking FOREACH macro

Walk the client IDs whose bits are set in a mask.

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-11-06 17:44:58 -05:00
David Lamparter
bf098b4a11 lib: add a transparent union for sockaddrs
As with "prefixptr"/"prefixconstptr", this allows function prototypes to
say "just give me any sockaddr" typing-wise, without having the compiler
complain that a "struct sockaddr_in" is not a "struct sockaddr".

(Split off from other changes that start using this.)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-11-05 18:19:52 +01:00
David Lamparter
19cbc31579 lib: rename prefixtype to uniontype
About to use this for sockunion, which is not a prefix.  `uniontype`
makes more sense, the macros are for defining transparent unions after
all.

(clang-format off thrown in as it otherwise wrecks formatting.)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-11-05 18:19:09 +01:00
Donatas Abraitis
4bdba57861
Merge pull request #14724 from donaldsharp/workqueue_cleanup
Workqueue cleanup
2023-11-04 13:58:55 +02:00
Donald Sharp
2a65f05d77 lib: Remove unused WQ_RETRY_XXX enums
These enum's have been around since 2005 and FRR
still does not have any users of these particular
values.  After almost 20 years, let's simplify the
code slightly and remove them.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-11-03 18:06:01 +00:00
Donald Sharp
b14f755408 lib: Cleanup some header files in lib
buffer.h  -> Bring up to our standard
if.h -> Bring up to our standard
workqueue.h -> expand documentation slightly

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-11-03 18:05:59 +00:00
Donald Sharp
a553bd6d68 lib: Move workqueue private functions into workqueue.c
Some Functions are not used outside of workqueue.c.
Move them inside of workqueue.c to limit scope.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-11-03 17:54:55 +00:00
David Lamparter
d889055d8e lib: convert if_zapi_callbacks into actual hooks
...so that multiple functions can be subscribed.

The create/destroy hooks are renamed to real/unreal because that's what
they *actually* signal.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-11-02 17:10:43 -07:00
Donald Sharp
d4aa24ba7d *: Introduce Local Host Routes to FRR
Create Local routes in FRR:

S   0.0.0.0/0 [1/0] via 192.168.119.1, enp39s0, weight 1, 00:03:46
K>* 0.0.0.0/0 [0/100] via 192.168.119.1, enp39s0, 00:03:51
O   192.168.119.0/24 [110/100] is directly connected, enp39s0, weight 1, 00:03:46
C>* 192.168.119.0/24 is directly connected, enp39s0, 00:03:51
L>* 192.168.119.224/32 is directly connected, enp39s0, 00:03:51
O   192.168.119.229/32 [110/100] via 0.0.0.0, enp39s0 inactive, weight 1, 00:03:46
C>* 192.168.119.229/32 is directly connected, enp39s0, 00:03:46

Create ability to redistribute local routes.

Modify tests to support this change.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-11-01 17:13:06 -04:00
Donald Sharp
8e3a96e846
Merge pull request #14546 from adrianomarto/ospf6-point-to-multipoint
OSPF6 point to multipoint
2023-10-31 18:20:04 -04:00
Russ White
644386fe48
Merge pull request #14388 from pguibert6WIND/redistribute_table_bgp_2
Redistribute table bgp without copying data to the default routing table
2023-10-31 13:23:57 -04:00
Christian Hopps
49a09ca2b1 lib: mgmt_msg: fix a valgrind memleak
- Free the outbound stream on destroy.

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-10-30 04:03:12 -04:00
Donatas Abraitis
73914a3e73
Merge pull request #13576 from chiragshah6/mdev1
zebra:returns empty dict when evpn is disabled II
2023-10-30 08:55:49 +02:00
Chirag Shah
43443e828a *: modify empty json helper function
Modify empty json object to take input obj
instead of allocating always one.

There are situation where in error condition or no data
case print empty json (`{}`) with already allocated

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2023-10-29 11:20:37 -07:00
Christian Hopps
a709218b53
Merge pull request #14609 from idryzhov/cfg-apply-remove-batches
mgmtd, lib: remove batch ids from cfg apply reply
2023-10-25 13:43:44 -04:00
Igor Ryzhov
a041d3169b lib: remove incorrect comment from northbound
This was true when we had only a CLI for configuration. Now mgmtd has a
public frontend interface that can be used by external applications, and
they can send invalid requests that lead to errors.

This is still true for CLI though, so the same comment still stays in
`nb_cli_apply_changes_internal`.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-10-21 13:09:00 +03:00
Philippe Guibert
a61f49ab36 lib: fix RT_TABLE_LOCAL for bsd builds
The routing table numbers are specific to linux builds, and the
RT_TABLE_xxx are usually defined in linux headers. The bsd builds
do not benefit from this definition: some RT_TABLE_xxx defines
are missing for those builds.

Fix this by appending RT_TABLE_LOCAL define for bsd headers.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-10-20 13:28:52 +02:00
Philippe Guibert
07a459ac25 lib: add support for new redistribute table-direct element
Add a new kind of redistributed route that helps to import entries
that are not copied in the default routing table. Contrary to the
'redistribute table' feature, the entries are directly obtained from
the zebra appropriate routing table.

The 'table-direct' naming expresses the direct redistribution of
the routes, without having to copy the route entries in the default
routing table.

The distance value for this route is 14. Such route entries will
be prioritary compared to 'table' and 'ebgp' route entries type.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-10-20 13:28:52 +02:00
Igor Ryzhov
d2977d57c8 mgmtd, lib: remove batch ids from cfg apply reply
The config is always applied fully, all batches are included. There's no
need to pass a list of applied batches as it always contains all of
them.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-10-17 15:06:13 +03:00
Donald Sharp
02cbd97801
Merge pull request #14561 from idryzhov/implicit-fallthrough
build: add -Wimplicit-fallthrough
2023-10-13 11:51:11 -04:00
Igor Ryzhov
7d67b9ff28 build: add -Wimplicit-fallthrough
Also:
- replace all /* fallthrough */ comments with portable fallthrough;
pseudo keyword to accomodate both gcc and clang
- add missing break; statements as required by older versions of gcc
- cleanup some code to remove unnecessary fallthrough

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-10-12 21:23:18 +03:00
Christian Hopps
11e8c906a9 lib: msg: make short-circuit connections guaranteed
When short circuiting is requested the caller can count on that
being the connection type they get.

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-10-12 10:25:30 -04:00
Donald Sharp
ac78d70bb8
Merge pull request #14563 from opensourcerouting/fix/cpuwarning_starvation
lib: Suppress HOB/STARVATION warnings when running in vtysh
2023-10-11 07:21:43 -04:00
Donatas Abraitis
3ff671b830 lib: Suppress HOB/STARVATION warnings when running in vtysh
Running ping/traceroute/etc. (any kind of commands that use execute_command()
suffer with this kind of warnings.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-10-11 09:52:19 +03:00
Donald Sharp
0dc12c9003 Revert "lib: register bgp link-state afi/safi"
This reverts commit 1642a68d60.
2023-10-10 16:45:57 -04:00
Donald Sharp
ddd96b51b0 Revert "bgpd: add bgp link-state address-family configuration context"
This reverts commit ae2f3bb5b4.
2023-10-10 16:45:32 -04:00
Donald Sharp
bbe3163a1b Revert "lib: add link-state prefixes"
This reverts commit c8172af682.
2023-10-10 16:45:11 -04:00