Commit Graph

34898 Commits

Author SHA1 Message Date
Donald Sharp
71ea80bc47
Merge pull request #15300 from idryzhov/mgmtd-cli-callbacks
lib, mgmtd: don't register NB config callbacks in mgmtd
2024-02-05 07:33:51 -05:00
Donald Sharp
354d823763
Merge pull request #15289 from idryzhov/coverity-fixes
Coverity fixes
2024-02-05 07:32:58 -05:00
Donald Sharp
c4da71387b
Merge pull request #15293 from idryzhov/mgmt-read-config
mgmtd: disable lib code for config reading
2024-02-05 07:32:03 -05:00
Donald Sharp
015c11646d
Merge pull request #15297 from idryzhov/mgmtd--n
mgmtd: fix missing -n flag and help
2024-02-05 07:31:11 -05:00
Donatas Abraitis
ef2fad92d7
Merge pull request #15295 from idryzhov/filter-autocompletion
fixes for access-list/prefix-list autocompletion
2024-02-05 12:43:43 +02:00
Donatas Abraitis
11a6f06ebd
Merge pull request #15296 from idryzhov/doc-no
doc: remove [no] from commands
2024-02-05 12:43:08 +02:00
Donatas Abraitis
c8acc6709c bgpd: Send dynamic capability when on/off FQDN capability
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-02-05 12:23:53 +02:00
Donatas Abraitis
04e2401d20 bgpd: Do not reset the session if turning on/off FQDN capability
Allow BGP dynamic capabilities handle this gracefully.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-02-05 10:43:50 +02:00
Donatas Abraitis
3e99dcc626 bgpd: Send FQDN capability via dynamic capability if enabled
Since we have a knob to disable sending FQDN capability, it MUST be checked
before sending it using dynamic capabilities.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-02-05 08:22:46 +02:00
Igor Ryzhov
4bde9511c3 staticd: coverity fixes
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-02-04 22:28:33 +02:00
Igor Ryzhov
19631dcab5 zebra: coverity fixes
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-02-04 22:28:33 +02:00
Igor Ryzhov
3c05d53bf8 staticd: fix nht memory leak
When a static route with a gateway nexthop is created, the nexthop is
sent to zebra for NHT, and added to a local hash. When the nexthop's VRF
is deleted from kernel, nexthop still stays in the hash. This is a
memory leak, because it is never deleted from there. Even if the VRF is
recreated in kernel, it is assigned with a new `vrf_id` so the old hash
entry is not reused, and a new one is created. To fix the issue, remove
all nexthops from the hash when the corresponding VRF is deleted, do not
add nexthops to the hash if their corresponding VRF doesn't exist in
kernel and don't add the same nexthop to the hash multiple times.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-02-04 22:28:10 +02:00
Igor Ryzhov
6090b2b939 staticd: add a separate function for uninstalling nexthops
Will be used in the following commit.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-02-04 22:28:10 +02:00
Igor Ryzhov
0d9127bca1 staticd: don't send routes from disabled vrfs to zebra
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-02-04 22:28:10 +02:00
Igor Ryzhov
6da3e78ce5 staticd: fix processing nht updates
When processing an NHT update, we should go though all `static_vrf`
structures instead of regualar `vrf`, because some of `static_vrf` may
not have corresponding `vrf` and will miss the update.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-02-04 22:28:10 +02:00
Igor Ryzhov
633f019118 mgmtd: embed frr-zebra-route-map module
All used modules should be embedded to ensure work on all operating
systems.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-02-04 22:27:28 +02:00
Igor Ryzhov
066bb6dc2d lib: add ietf-yang-metadata to the list of built-in modules
We don't need to manually load built-in modules. This fixes the
following warning in mgmtd:
```
YANG model "ietf-yang-metadata@*" "*@*"not embedded, trying external file
```

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-02-04 22:27:28 +02:00
Igor Ryzhov
3c40cead5a mgmtd: disable lib code for config reading
mgmtd reads config files on its own, it doesn't need libfrr to do that.
The code is already skipped, because mgmtd uses `di->read_in` thread for
config reading and libfrr doesn't reschedule the thread, so this commit
just removes the dead code.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-02-04 22:27:11 +02:00
Igor Ryzhov
c1b4976786 *: use af-specific autocompletion for prefix-lists when possible
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-02-04 22:26:48 +02:00
Igor Ryzhov
7ef83dcf0c lib: fix autocompletion for prefix-lists
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-02-04 22:26:48 +02:00
Igor Ryzhov
9c5f0ea98d lib: fix autocompletion for access-lists
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-02-04 22:26:48 +02:00
Igor Ryzhov
f6b381ed54 doc: remove [no] from commands
The rule is to document only positive versions of commands.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-02-04 22:26:31 +02:00
Igor Ryzhov
ea6a7d3fa3 lib, mgmtd: don't register NB config callbacks in mgmtd
mgmtd is supposed to only register CLI callbacks. If configuration
callbacks are registered, they are getting called on startup when mgmtd
reads config files, and they can use infrastructure that is not
initialized on mgmtd, or allocate some memory that is never freed.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-02-04 22:25:57 +02:00
Igor Ryzhov
7c02567b4a mgmtd: fix missing -n flag and help
Only --vrfwnetns works right now, because -n was missing from short ops.
Also add the missing help.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-02-04 22:25:57 +02:00
Igor Ryzhov
f359dc8ce0 lib, mgmtd: don't register NB config callbacks in mgmtd
mgmtd is supposed to only register CLI callbacks. If configuration
callbacks are registered, they are getting called on startup when mgmtd
reads config files, and they can use infrastructure that is not
initialized on mgmtd, or allocate some memory that is never freed.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-02-04 22:25:37 +02:00
Igor Ryzhov
273356eac5
Merge pull request #15298 from donaldsharp/rcu_bites_the_bitey_thing
Rcu bites the bitey thing
2024-02-04 22:08:14 +02:00
Donald Sharp
5bc104120b bgpd: Prevent rpki from hooking multiple times into rcu code
As far as I can tell, the rpki code creates a pthread that
is used to handle the i/o associated with talking to the
remote rpki server.  The problem that we are having is that
the rpki code in FRR wants to behave like FRR code and use
the zlog_XXX functions.  These functions all depend on
the RCU code.  Which is a bit picky( and rightly so!!! )
about being started up properly and shut down properly.

This commit is fixing the problem of shutdown.  From
playing with the rpki code, I was able to experimentally
determine that the rpki_create_socket callback function
can be called multiple times per pthread.  Additionally
I was able to clearly see multiple *different* pthreads
actually be created.  This leaves the possiblity
that each time it is called it might be hooking into the
RCU code.  Which makes the rcu code unhappy on shutdown.

Let's address the issue by checking to see if this pthread
has already hooked into the RCU code or not.  If so
then don't do this again.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-02-03 23:10:19 -05:00
Donald Sharp
5ddf2aaa52 lib: Actually create the rcu and save it before using it
In a non-controlled startup, the rcu data structures were
not being created until after logging could happen.  This
is bad.  Move it so that the rcu data structures are
created first, before logging( HA! ) can happen.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-02-03 23:08:20 -05:00
ali-aqrabawi
cfe1b5b684
lib: set change errmsg in sysrepo session
this will enable sysrepo based cli users to know what went wrong
when config change fails

Signed-off-by: ali-aqrabawi <aaqrabaw@okdanetworks.com>
2024-02-03 23:57:13 +03:00
Donald Sharp
3a6c3129dd
Merge pull request #15265 from louis-6wind/fix-rpki-logs
bgpd,lib: fix logging from rpki_create_socket()
2024-02-03 08:40:27 -05:00
Donatas Abraitis
8629700bc8
Merge pull request #15192 from fdumontet6WIND/capa_nego
bgpd: add [no]neighbor capability fqdn
2024-02-03 12:19:53 +02:00
Donald Sharp
3d57f04395
Merge pull request #10151 from pguibert6WIND/ensure_routing_protocols_good_bw
zebra: avoid having speed set to UINT32_MAX
2024-02-02 12:51:35 -05:00
Jafar Al-Gharaibeh
080054686f
Merge pull request #15216 from donaldsharp/zebra_opaque_mem_leak
zebra: Fix opaque memory leak in rare situation
2024-02-02 10:54:20 -06:00
Donald Sharp
22b79197bb
Merge pull request #15279 from idryzhov/staticd-fixes
several fixes for staticd configuration
2024-02-02 11:51:03 -05:00
Donatas Abraitis
4650d5aa5a
Merge pull request #15278 from idryzhov/fix-no-vrf
lib: fix "no vrf" command
2024-02-02 15:23:49 +02:00
Donatas Abraitis
4ec8522ed4
Merge pull request #15282 from donaldsharp/poll_info
lib: Warn operator when fd limit is set too large
2024-02-02 13:09:49 +02:00
Amjad Daraiseh
70fba89306 doc: sysrepo plugin doc update with tested commands
Signed-off-by: Amjad Daraiseh <adaraiseh@okdanetworks.com>
2024-02-02 05:41:04 -05:00
Francois Dumontet
d034d1954a doc: add neighbor PEER capability fqdn command
improve bgp doc

Signed-off-by: Francois Dumontet <francois.dumontet@6wind.com>
2024-02-02 11:31:47 +01:00
Francois Dumontet
220c0635a8 tests: improve topotest bgp_dont_capability_negotiate
add some steps for testing of add [no]neighbor capability fqdn
command support.

Signed-off-by: Francois Dumontet <francois.dumontet@6wind.com>
2024-02-02 11:31:47 +01:00
Francois Dumontet
e146ea53ef bgpd: add [no]neighbor capability fqdn command
cisco routers are not dealing fairly whith unsupported capabilities.
When a cisco router receive an unsupported capabilities it reset the
negociation without notifying the unmatching capability as described in
RFC2842.
Cisco suggest the use of
neighbor x.x.x.x capability fqdn
to avoid the use of fqdn in open message.

this new command is to remove the use of fqdn capability in the
open message with the peer "x.x.x.x".

Link: https://www.cisco.com/c/en/us/support/docs/ip/border-gateway-protocol-bgp/116189-problemsolution-technology-00.pdf

Signed-off-by: Francois Dumontet <francois.dumontet@6wind.com>
2024-02-02 11:31:47 +01:00
Louis Scalbert
fdaf08bb46 bgpd: fix logging from rpki_create_socket()
Fix the following crash when logging from rpki_create_socket():

> #0  raise (sig=<optimized out>) at ../sysdeps/unix/sysv/linux/raise.c:50
> #1  0x00007f6e21723798 in core_handler (signo=6, siginfo=0x7f6e1e502ef0, context=0x7f6e1e502dc0) at lib/sigevent.c:248
> #2  <signal handler called>
> #3  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
> #4  0x00007f6e2144e537 in __GI_abort () at abort.c:79
> #5  0x00007f6e2176348e in _zlog_assert_failed (xref=0x7f6e2180c920 <_xref.16>, extra=0x0) at lib/zlog.c:670
> #6  0x00007f6e216b1eda in rcu_read_lock () at lib/frrcu.c:294
> #7  0x00007f6e21762da8 in vzlog_notls (xref=0x0, prio=2, fmt=0x7f6e217afe50 "%s:%d: %s(): assertion (%s) failed", ap=0x7f6e1e504248) at lib/zlog.c:425
> #8  0x00007f6e217632fb in vzlogx (xref=0x0, prio=2, fmt=0x7f6e217afe50 "%s:%d: %s(): assertion (%s) failed", ap=0x7f6e1e504248) at lib/zlog.c:627
> #9  0x00007f6e217621f5 in zlog (prio=2, fmt=0x7f6e217afe50 "%s:%d: %s(): assertion (%s) failed") at lib/zlog.h:73
> #10 0x00007f6e21763596 in _zlog_assert_failed (xref=0x7f6e2180c920 <_xref.16>, extra=0x0) at lib/zlog.c:687
> #11 0x00007f6e216b1eda in rcu_read_lock () at lib/frrcu.c:294
> #12 0x00007f6e21762da8 in vzlog_notls (xref=0x7f6e21a50040 <_xref.68>, prio=4, fmt=0x7f6e21a4999f "getaddrinfo: debug", ap=0x7f6e1e504878) at lib/zlog.c:425
> #13 0x00007f6e217632fb in vzlogx (xref=0x7f6e21a50040 <_xref.68>, prio=4, fmt=0x7f6e21a4999f "getaddrinfo: debug", ap=0x7f6e1e504878) at lib/zlog.c:627
> #14 0x00007f6e21a3f774 in zlog_ref (xref=0x7f6e21a50040 <_xref.68>, fmt=0x7f6e21a4999f "getaddrinfo: debug") at ./lib/zlog.h:84
> #15 0x00007f6e21a451b2 in rpki_create_socket (_cache=0x55729149cc30) at bgpd/bgp_rpki.c:1337
> #16 0x00007f6e2120e7b7 in tr_tcp_open (tr_socket=0x5572914d1520) at rtrlib/rtrlib/transport/tcp/tcp_transport.c:111
> #17 0x00007f6e2120e212 in tr_open (socket=0x5572914b5e00) at rtrlib/rtrlib/transport/transport.c:16
> #18 0x00007f6e2120faa2 in rtr_fsm_start (rtr_socket=0x557290e17180) at rtrlib/rtrlib/rtr/rtr.c:130
> #19 0x00007f6e218b7ea7 in start_thread (arg=<optimized out>) at pthread_create.c:477
> #20 0x00007f6e21527a2f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

rpki_create_socket() is a hook function called from the rtrlib library.
The issue arises because rtrlib initiates its own separate pthread in which
it runs the hook, which does not establish an FRR RCU context. Consequently,
this leads to failures in the logging mechanism that relies on RCU.

Initialize a new FRR pthread context from the rtrlib pthread with a
valid RCU context to allow logging from the rpki_create_socket() and
dependent functions.

Link: https://github.com/FRRouting/frr/issues/15260
Fixes: a951752d4a ("bgpd: create cache server socket in vrf")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-02-02 10:35:10 +01:00
Louis Scalbert
73f72c5266 lib: add ability to log from external pthread
External libraries can re-enter the FRR code through a hook function. A
crash occurs when logging from this hook function if the library has
initiated a new pthread, as the FRR RCU context is not initialized for
this thread.

Add frr_pthread_non_controlled_startup() function to initialize a valid
RCU context within a FRR pthread context, originating from an external
pthread.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-02-02 10:25:05 +01:00
Donald Sharp
d023a0ceec lib: Warn operator when fd limit is set too large
It's unlikely that an operator will ever set a fd
limit of over 100k.  Let's warn the operator that
things are in a bit of a wonky state.

Fixes: #15280
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-02-01 21:23:56 -05:00
Donald Sharp
a4f222292b
Merge pull request #15275 from opensourcerouting/fix/one_more_memory_optimization_attr_struct
bgpd: One more attr struct memory optimization
2024-02-01 20:46:09 -05:00
Igor Ryzhov
75662912e3 lib: fix "no vrf" command
Remove operational data check from CLI command. It never works in mgmtd
and it is not needed in backend daemons because it's done in
`lib_vrf_destroy` callback.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-02-02 01:22:50 +02:00
Igor Ryzhov
cb781f6097 staticd: fix NB dependency hack
Currently, staticd configuration is tightly coupled with VRF existence.
Because of that, it has to use a hack in NB infrastructure to create a
VRF configuration when at least one static route is configured for this
VRF. This hack is incompatible with mgmtd, because mgmtd doesn't execute
configuration callbacks. Because of that, the configuration may become
out of sync between mgmtd and staticd. There are two main cases:

1. Create static route in a VRF. The VRF data node will be created
   automatically in staticd by the NB hack, but not in mgmtd.
2. Delete VRF which has some static routes configured. The static route
   configuration will be deleted from staticd by the NB hack, but not
   from mgmtd.

To fix the problem, decouple configuration of static routes from VRF
configuration. Now it is possible to configure static routes even if the
VRF doesn't exist yet. Once the VRF is created, staticd applies all the
preconfigured routes.

This change also fixes the problem with static routes being preserved in
the system when staticd "control-plane-protocol" container is deleted
but the VRF is still configured.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-02-02 00:57:59 +02:00
Igor Ryzhov
5dfa36b6a7 staticd: fix nexthops without interface
When interface is not set in "ip route" command, CLI passes "(null)" as
an interface name instead of an empty string. The actual code in turn
uses "nh->ifname[0] != 0" to check if the interface name was set. Fix
the problem by changing the "(null)" string into an empty string when
populating the nexthop structure.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-02-02 00:25:15 +02:00
Igor Ryzhov
d205208f57 Revert "staticd: Accept full blackhole typed keywords for ip_route_cmd"
This reverts commit 76b2bc97e7.

This change is wrong for several reasons:
- it is backwards incompatible - previously it was always possible to
  create blackhole/reject routes using shortened versions of the words
  and it suddenly became impossible if there's an interface in the
  system with the same name
- it uses operational data for validation which is prohibited
- it doesn't really solve the problem with inability to create routes
  using interface names like `bla` or `rej`
2024-02-02 00:25:15 +02:00
Donald Sharp
9d8fd14b56
Merge pull request #15276 from mjstapp/port_registry
*: create a single registry of daemons' default port values
2024-02-01 16:07:11 -05:00
Donald Sharp
e24f43e64e
Merge pull request #15272 from LabNConsulting/chopps/mgmtd-notif-test
tests: add mgmtd backend notification test
2024-02-01 14:56:07 -05:00