Commit Graph

5569 Commits

Author SHA1 Message Date
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
Donald Sharp
59c3a49166 Revert "bgpd: store bgp link-state prefixes"
This reverts commit 39a8d354c1.
2023-10-10 16:45:00 -04:00
Donald Sharp
8b3e765d19 Revert "bgpd, lib: extend the size of the prefix string buffer"
This reverts commit bdb3fa3b92.
2023-10-10 16:44:34 -04:00
David Lamparter
829f3a0bd5 lib: remove unused connected_add prototype
This function is not implemented anywhere.  Not sure it ever existed.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-10-10 07:54:15 +10:00
Rafael Zalamena
4a60045688
Merge pull request #10733 from anlancs/zebra-remove-update
zebra: remove ZEBRA_INTERFACE_VRF_UPDATE
2023-10-08 10:52:54 -03:00
anlan_cs
b580c52698 *: remove ZEBRA_INTERFACE_VRF_UPDATE
Currently when one interface changes its VRF, zebra will send these messages to
all daemons in *order*:
    1) `ZEBRA_INTERFACE_DELETE` ( notify them delete from old VRF )
    2) `ZEBRA_INTERFACE_VRF_UPDATE` ( notify them move from old to new VRF )
    3) `ZEBRA_INTERFACE_ADD` ( notify them added into new VRF )

When daemons deal with `VRF_UPDATE`, they use
`zebra_interface_vrf_update_read()->if_lookup_by_name()`
to check the interface exist or not in old VRF. This check will always return
*NULL* because `DELETE` ( deleted from old VRF ) is already done, so can't
find this interface in old VRF.

Send `VRF_UPDATE` is redundant and unuseful. `DELETE` and `ADD` are enough,
they will deal with RB tree, so don't send this `VRF_UPDATE` message when
vrf changes.

Since all daemons have good mechanism to deal with changing vrf, and don't
use this `VRF_UPDATE` mechanism.  So, it is safe to completely remove
all the code with `VRF_UPDATE`.

Signed-off-by: anlan_cs <anlan_cs@tom.com>
2023-10-07 10:06:39 +08:00
Igor Ryzhov
a962f2949f mgmt: delete candidate scratch buffer
The code doesn't work at all. It tries to use libyang operation
metadata in a regular (not diff) data tree, and regular data trees
don't provide this data. Also, for destroy operations, it searches
for nodes in the running config, which may not have the deleted nodes
if we're not using implicit commits.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-10-06 21:18:33 +03:00
Russ White
c97c31c55f
Merge pull request #14472 from opensourcerouting/plist-dup
lib: fix route map duplicated prefix removal evaluation
2023-10-03 10:28:52 -04:00
Russ White
d6a9c7ec87
Merge pull request #13814 from pguibert6WIND/comm_list_expanded_match_no_exact
bgpd: add match community "any" to match any incoming community
2023-10-03 08:55:30 -04:00
Donatas Abraitis
4d087a71d3
Merge pull request #14508 from LabNConsulting/chopps/darr-use-frrmemfunc
lib: use XREALLOC over realloc avoid coverity warning
2023-10-03 10:34:27 +03:00
Philippe Guibert
aa511000e0 bgpd: add 'match community-list any' function
There is no match mechanism to match one community from the
incoming community-list. Add the 'any' keyword to the 'match
route-map' command of communit-list and large-community-list.

> match community-list AAA any
> match large-community-list AAA any

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-10-02 15:24:18 +02:00
Donatas Abraitis
02d8b80ce4 *: Do not cast to the same type as the destination is
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-09-29 10:24:16 +03:00
Christian Hopps
53511f252d lib: use XREALLOC over realloc avoid coverity warning
I believe coverity is complaining that the current code does not handle the
realloc fail case, in which case the original pointer is not freed, but NULL is
returned. The code assert()s it's not failed but that is not strong enough it
needs to abort which XREALLOC does and is a better integration into FRR-inrfa
anyway.

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-09-29 01:19:53 -04:00
Donatas Abraitis
0af4541576
Merge pull request #14498 from idryzhov/fix-conf-t-file-lock
Fixes for `file-lock` mode of configuration node
2023-09-28 10:03:06 +03:00
Igor Ryzhov
d3aa9adb8d vty: fix working in file-lock mode
When the configuration node is entered in file-lock mode, candidate
and running datastores are locked. Any configuration change is followed
by an implicit commit which leads to a crash of mgmtd, because double
lock is prohibited by an assert. When working in file-lock mode, we
shouldn't do implicit commits which is disabled by allowing pending
configuration changes.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-09-28 02:41:16 +03:00
Igor Ryzhov
b8ebb7fc62 vty: fix configure terminal argument descriptions
"terminal" and "file-lock" description are mixed up.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-09-27 23:34:53 +03:00
Donald Sharp
bb308b1efc
Merge pull request #14482 from opensourcerouting/fix/walltime_threshold_disable
lib: Drop deprecated enable-time-check, enable-cpu-time compile options
2023-09-27 06:32:11 -04:00
Russ White
8e755a03a3
Merge pull request #12649 from louis-6wind/bgp-link-state
bgpd: add basic support of BGP Link-State RFC7752
2023-09-26 10:07:02 -04:00
David Lamparter
ee5dd0a081 lib: assert for VTY_PASSFD expectations
Coverity is complaining that vty->state could be VTY_PASSFD here.  It
can't, it really shouldn't, and if it actually is then something went
seriously wrong somewhere earlier so assert()ing out is the best thing
to do.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-09-24 20:14:37 +02:00
Donatas Abraitis
fd0fe0bb6a lib: Drop deprecated enable-time-check, enable-cpu-time compile options
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-09-24 20:41:24 +03:00
Rafael Zalamena
aed94c8096 lib: don't announce prefix delete for duplicates
When deleting a duplicated prefix list entry don't announce the change
to route map listeners, otherwise they will be removing rules that
shouldn't be removed causing the prefix that still exist in the
prefix-list to be not evaluated anymore.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2023-09-22 13:03:28 -03:00
Rafael Zalamena
71fb99d22e Revert "lib : fix duplicate prefix list delete"
This reverts commit 394ed767e7.
2023-09-22 12:24:16 -03:00
Donald Sharp
cd3bd19314
Merge pull request #14454 from opensourcerouting/coverity-20230920
lib: fix a bunch of coverity nits
2023-09-21 06:31:58 -04:00
David Lamparter
448d690a35 lib: random make-coverity-happy nits
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-09-20 16:07:24 +02:00
Dmytro Shytyi
74fb8a2d18 lib: adapt nexthop_cmp to handle multiple segs SIDs
Extend nexthop_cmp function to process multiple segs
SIDs.

Signed-off-by: Dmytro Shytyi <dmytro.shytyi@6wind.com>
2023-09-20 15:07:15 +02:00
Dmytro Shytyi
857945ad1a lib: update del_srv6_seg6_local to handle seg6_segs
Adapt de_srv6_seg6local to handle seg6_segs structure.

Signed-off-by: Dmytro Shytyi <dmytro.shytyi@6wind.com>
2023-09-20 15:07:15 +02:00
Dmytro Shytyi
d5e7dffeae lib: nexthop, free the multiple seg6_segs
Adapt the function that fees srv6 nexthop to handle multiple segs.

Signed-off-by: Dmytro Shytyi <dmytro.shytyi@6wind.com>
2023-09-20 15:07:15 +02:00
Dmytro Shytyi
fac0392506 lib: in nexthop adaptation pass the number of segs to jhash
Adapt nexthop file to handle hash of multiple segments

Signed-off-by: Dmytro Shytyi <dmytro.shytyi@6wind.com>
2023-09-20 15:07:15 +02:00
Dmytro Shytyi
f20cf1457d bgpd,lib,sharpd,zebra: srv6 introduce multiple segs/SIDs in nexthop
Append zebra and lib to use muliple SRv6 segs SIDs, and keep one
seg SID for bgpd and sharpd.

Note: bgpd and sharpd compilation relies on the lib and zebra files,
i.e if we separate this: lib or zebra or bgpd or sharpd in different
commits - this will not compile.

Signed-off-by: Dmytro Shytyi <dmytro.shytyi@6wind.com>
2023-09-20 15:07:15 +02:00
David Lamparter
592011b251 lib: clippy ELF: check existence of string table
Mostly to make coverity happy, no compiler/linker should produce broken
ELF files like this (and if it does we can't process it anyway...)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-09-20 14:49:22 +02:00
David Lamparter
e408a915a3 lib: straight return on error on log open fail
I think I originally had some other code at the tail end of that
function, but that's not the case anymore, and dropping out of the
function with a straight "return -1" is more useful than trucking on
with an invalid fd.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-09-20 14:46:10 +02:00
David Lamparter
5ce8577bd7 lib: add dup() error check in logging code
Mostly to make coverity happy, if dup() fails we're f*cked already.
(Still useful to have a better error message...)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-09-20 14:35:55 +02:00
David Lamparter
e7737c89eb lib: constrain hash table "tabshift" both ways
The previous change to assume() did address the coverity warning about
one direction of the shift in HASH_KEY, let's constrain the other in
HASH_SIZE as well.

To be fair, the hash table *will* break at 1G entries, but at that point
we have other problems RAM-wise.  (Could bump the thing to 64-bit, but
then we need better item hash functions too on every single user.)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-09-19 21:09:17 +02:00
Louis Scalbert
bdb3fa3b92 bgpd, lib: extend the size of the prefix string buffer
BGP Link-State prefixes are special prefixes that contains a lot of
data.

Extend the length of the prefix string buffer in order to display
properly this type of prefixes with the next commits.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2023-09-18 14:57:03 +02:00
Louis Scalbert
39a8d354c1 bgpd: store bgp link-state prefixes
Add the ability to store link-state prefixes in the BGP table.
Store a raw copy of the BGP link state NLRI TLVs as received in the
packet in 'p.u.prefix_linkstate.ptr'.

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2023-09-18 14:57:03 +02:00
Louis Scalbert
c8172af682 lib: add link-state prefixes
Add to the library the link-state type of prefixes.

Link-state prefixes contain much more data than the current prefixes and
they only make sense for BGP Link-State. Storing all the data in "struct
prefix" is not relevant because it would increase the memory usage of
all daemons. Instead a pointer to a structure that contains all the
information is used. Printing link-state prefixes can be delegated to a
hook function.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2023-09-18 14:42:26 +02:00
Louis Scalbert
ae2f3bb5b4 bgpd: add bgp link-state address-family configuration context
Add the bgp link-state configuration context cli:

> router bgp 65001
>  address-family link-state link-state
>   neighbor 192.0.2.2 activate
>  exit-address-family

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2023-09-18 14:39:56 +02:00
Louis Scalbert
1642a68d60 lib: register bgp link-state afi/safi
Register BGP Link-State AFI/SAFI values from RFC7752.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2023-09-18 14:22:51 +02:00
David Lamparter
71510e531d lib: another attempt at Coverity false positives
Typesafe hash tables do this:

	assume((tabshift) >= 2 && (tabshift) <= 33);
	(val) >> (33 - (tabshift));

Sadly, Coverity currently ignores assume() and says:
	[...] right shifting by more than 31 bits has undefined behavior.
	The shift amount, "33 - h->hh.tabshift", is 33.

Let's see if Coverity understands this can't happen...

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-09-14 11:46:50 +02:00
Mark Stapp
bf4e97c632
Merge pull request #14365 from opensourcerouting/typesafe-const-declutter
Revert "lib: add a frr_each_const macro"
2023-09-12 11:20:50 -04:00
Russ White
48d6039e14
Merge pull request #13724 from cscarpitta/feature/isisd-srv6-support
isisd: Add support for SRv6 uSID (RFC 9352)
2023-09-12 08:33:42 -04:00
Carmine Scarpitta
899ec39ee5 lib: Add CLI node for SRv6 Node MSD
Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2023-09-11 22:11:49 +02:00
Carmine Scarpitta
79e37f0ded lib: Define default values for SRv6 flavors attrs
When installing a local SID in the Linux kernel, `lcblock_len` and
`lcnode_fn_len` Netlink attributes are optional. When omitted, the
kernel uses the default values: lcblock_len=32 and lcnode_fn_len=16.
Let's use the same default values in FRR.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2023-09-11 17:35:03 +02:00
Carmine Scarpitta
f26becb27a lib: Add SRv6 flavors manipulation macros
`struct seg6local_context` contains a `struct seg6local_flavors_info`
that carries SRv6 flavors information. The `seg6local_flavors_info`
data structure contains a field `flv_ops` that indicates which flavors
are enabled for the `seg6local` nexthop. `flv_ops` is a bit-map where
each bit indicates if a particular SRv6 flavor is enabled (bit set to
1) or not (bit set to 0).

This commit defines some macros that can be used to manipulate the SRv6
flavors bit-map:
* CHECK_SRV6_FLV_OP(OPS,OP) - check if a particular flavor is enabled;
* SET_SRV6_FLV_OP(OPS,OP) - enable a particular flavor (OP);
* UNSET_SRV6_FLV_OP(OPS,OP) - disable a particular flavor (OP);
* RESET_SRV6_FLV_OP(OPS) - disable all SRv6 flavors.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2023-09-11 17:35:02 +02:00
Carmine Scarpitta
164bcddab7 lib: Add SRv6 flavors info to seg6local nexthop
The RFC 8986 defines the SRv6 Network Programming concept and specifies
the base set of SRv6 behaviors that enables the creation of
interoperable overlays with underlay optimization. In addition, the RFC
8986 introduces the concept of "flavors", additional operations that can
modify or extend the existing SRv6 behaviors.

In the Linux kernel and in FRR, an SRv6 SID is implemented as a route
associated with a `seg6local` nexthop. A `seg6local` nexthop represents
an SRv6 behavior bound to a SID.

The Linux kernel already supports the ability to add a set of flavors
to a `seg6local` nexthop to modify or extend the associated behavior.

This commit aligns the `seg6local` nexthop implementation of FRR to the
Linux kernel. It extends the `seg6local` nexthop implementation by
adding a struct `seg6local_flavors_info` that encodes the SRv6
flavors information.

Currently, the `seg6local_flavors_info` data structure has three
members:
- `tlv_ops` indicates which flavors are enabled for the `seg6local`
  nexthop;
- `lcblock_len`is the length of the Locator-Block part of the SID;
- `lcnode_func_len` is the length of the combined Node and Function
  parts of the SID.

`lcblock_len` and `lcnode_func_len` define the SID structure. They are
required for some behaviors (e.g. NEXT-C-SID and REPLACE-C-SID). For
other flavors (e.g. PSP, USP, USD) these parameters are not required and
can be omitted.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2023-09-11 17:35:02 +02:00
Carmine Scarpitta
bf386acb93 lib: Add new enum for seg6local flavor operations
The RFC 8986 defines the SRv6 Network Programming concept and specifies
the base set of SRv6 behaviors that enables the creation of
interoperable overlays with underlay optimization. In addition, the RFC
8986 introduces the concept of "flavors", additional operations that can
modify or extend the existing SRv6 behaviors.

This commit adds a new enum type `seg6local_flavor_op` to represent the
SRv6 flavors operations. Currently we define the following flavor
operations:
- PSP (defined in RFC 8986 section #4.16.1)
- USP (defined in RFC 8986 section #4.16.2)
- USD (defined in RFC 8986 section #4.16.3)
- NEXT-C-SID (defined in draft-ietf-spring-srv6-srh-compression-03 #4.1)

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2023-09-11 17:35:01 +02:00
Carmine Scarpitta
d48f265e15 lib: Add SRv6 behavior codepoints needed for IS-IS
Add more SRv6 endpoint behaviors that are required for implementing
IS-IS SRv6 extensions (RFC 9352).

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2023-09-11 17:35:01 +02:00
Donald Sharp
edd243280c
Merge pull request #14364 from opensourcerouting/event-fix-delete-during-hash_iterate
lib: fix delete during hash_iterate() in event_*
2023-09-11 11:02:01 -04:00
Donald Sharp
36f78525cf lib: fixup prefix.h to our standards
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-09-08 09:50:21 -04:00
David Lamparter
3d1a678e24 lib: fix delete during hash_iterate() in event_*
... by converting the hash table to a typesafe hash.

Honestly I was just looking around for things to convert to the typesafe
hash table code, but then I noticed that cpu_record_clear() deletes
items from inside the hash_iterate() callback :(

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-09-07 17:19:39 +02:00
David Lamparter
3ea3f34213 lib: add inline comment about _const iteration
This is noted in doc/developer/lists.rst, but judging by the previous
commit that's not where people look for this thing.  Let's try a comment
in the header file.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-09-07 17:11:52 +02:00