Commit Graph

5692 Commits

Author SHA1 Message Date
Donald Sharp
c3a66e5082
Merge pull request #15173 from louis-6wind/nhrp-noarp
nhrpd: unset noarp flag using a zapi message
2024-01-24 10:53:29 -05:00
Donald Sharp
16406a31d3
Merge pull request #15196 from idryzhov/nb-leaf-list
lib: remove leaf-list xpath hack from northbound
2024-01-24 10:49:52 -05:00
Louis Scalbert
2ee43c873e lib,zebra: add zapi message to control noarp flag
Add a ZAPI message to control the setting of the IFF_NOARP flag.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-01-24 10:05:29 +01:00
Igor Ryzhov
a594cda8ce lib: remove leaf-list xpath hack from northbound
Currently, when editing a leaf-list, `nb_candidate_edit` expects to
receive it's xpath without a predicate and the value in a separate
argument, and then creates the full xpath. This hack is complicated,
because it depends on the operation and on the caller being a backend or
not. Instead, let's require to always include the predicate in a
leaf-list xpath. Update all the usages in the code accordingly.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-23 12:33:39 +02:00
Donald Sharp
a0d38a7ac6 lib, nhrpd: Move neighbor reg/unreg to lib/zclient.c
This is needed to be generic.  Let's make it so.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-01-22 12:14:59 -05:00
Donald Sharp
275edb5c16 *: Rename ZEBRA_NHRP_NEIGH_XXX to ZEBRA_NEIGH_XXX
This does not need to be nhrp specific.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-01-22 12:14:59 -05:00
Donatas Abraitis
f6178ee2e1
Merge pull request #15184 from donaldsharp/zebra_touchups
Zebra touchups
2024-01-21 17:02:26 +02:00
Donald Sharp
63816f7579 zebra: use break instead of goto
There is a goto statement that would be better served
with a break statement.  Let's try to minimize this
in the code.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-01-20 20:08:05 -05:00
Donald Sharp
af6499d052 zebra: Remove function that just calls another function
Why not just call the one function?

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-01-20 20:08:05 -05:00
Donald Sharp
daed95ddce zebra: Fix NEXTHOP_GROUP_FPM define value
The NEXTHOP_GROUP_FPM #define conflicts with
NEXTHOP_GROUP_KEEP_AROUND.  Not ideal let's fix
this.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-01-20 19:10:07 -05:00
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
733462a991 zebra: remove unnecessary checks from CLI
First, any data tree validation in CLI handler is not correct, because
this code won't be called when the change is done through any other
frontend. Second, these checks are not necessary at all, because NB
layer handles the change between admin-grp/affinity automatically.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-19 03:47:19 +02:00
Igor Ryzhov
f62e38cc36 zebra: fix link-params admin-grp config output
- it was not printed at all because of the incorrect `yang_dnode_exist`
  check
- the intended output was "admin-group" instead of "admin-grp" used in
  the actual CLI command

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-19 03:47:13 +02:00
Igor Ryzhov
a3bbe28e6d zebra: rework affinity-map update hook
Don't use config tree when updating internal daemon state. Everything
needed is already stored in internal structures.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-19 03:47:11 +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
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
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
Donald Sharp
54ed53f36f zebra: SA incorrectly believes a NULL pointer
SA has decided that old_re could be a NULL pointer
even though the zebra_redistribute_check function
checks for NULL and returns false that would
not allow a NULL pointer deref.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-01-09 13:03:43 -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
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
6d72776d62 Revert "zebra: Cleanup zrouter.stale_client_list on shutdown"
This reverts commit 71f7ecb571.
2024-01-07 13:14:54 -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
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
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
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
Carmine Scarpitta
a061ba2348 zebra: ctx has to be non NULL at this point
Fix the following coverity issue:

*** CID 1575079:  Null pointer dereferences  (REVERSE_INULL)
/zebra/zebra_dplane.c: 5950 in dplane_srv6_encap_srcaddr_set()
5944     	if (ret == AOK)
5945     		result = ZEBRA_DPLANE_REQUEST_QUEUED;
5946     	else {
5947     		atomic_fetch_add_explicit(&zdplane_info
5948     						   .dg_srv6_encap_srcaddr_set_errors,
5949     					  1, memory_order_relaxed);
     CID 1575079:  Null pointer dereferences  (REVERSE_INULL)
     Null-checking "ctx" suggests that it may be null, but it has already been dereferenced on all paths leading to the check.
5950     		if (ctx)
5951     			dplane_ctx_free(&ctx);
5952     	}
5953     	return result;
5954     }
5955

Remove the pointer check for `ctx`. At this point in the
function it has to be non null since we deref'ed it.
Additionally the alloc function that creates it cannot
fail.

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-01-04 11:13:31 +01:00
Russ White
2e69afd9da
Merge pull request #15055 from opensourcerouting/fix/zebra_ipv6_ll_configured
zebra: Push all configured IP addresses when the interface comes up
2024-01-02 10:42:08 -05: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
Donatas Abraitis
e684b4236b
Merge pull request #15066 from chiragshah6/mdev1
bgpd: revamp evpn debugs nexthop and l3vni
2024-01-02 10:40:14 +02:00
Christian Hopps
d0f71a90da zebra: fix cleanup of mgmt backend state
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-12-28 18:17:24 +00:00
Christian Hopps
c521d45b37 zebra: fix oper-state walk bug
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-12-28 17:53:40 +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
ef91d34f01 zebra: add zebra to mgmtd oper-state
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-12-28 17:53:40 +00:00
Chirag Shah
fa00a2f765 bgpd: revamp evpn debugs nexthop and l3vni
Add nexthop fied when import/unimport evpn route in vrf,
print bgp vrf instance name which contains "VRF" keyword.

Include pathcount which is list of paths linked to nexthop.

add and delete l3vni to keep symmetric "L3VNI" keyword as
used in other debug statements.

Ticket: #3671288
Testing Done:

2023/12/27 05:10:03.339616 BGP: [HPE1G-3H7F2] ... new pi VRF vrf2
dest 0x55663e8372c0 (l 2) pi 0x55663e8374d0 (l 1, f 0x4010) nh 6.0.0.1

2023/12/27 05:58:56.650116 BGP: [MC0JJ-7ZYQB] ... delete pi VRF vrf2
dest 0x55663e885110 (l 5) pi 0x55663e8851e0 (l 1, f 0x4098) nh 6.0.0.1

2023/12/27 05:10:03.339581 BGP: [P4TBX-3W31N] evpn VRF vrf2 nh
6.0.0.1 rmac 00:02:00:00:00:04 add to zebra

2023/12/27 06:13:12.685906 BGP: [SWSCZ-2Z6M4] evpn vrf VRF vrf1 nh
6.0.0.1 del to zebra

2023/12/27 05:10:03.339603 BGP: [Y2EAK-4N7FV] path 60.1.1.111/32 linked
to VRF vrf2 nh 6.0.0.1 pathcount 0

2023/12/27 05:58:56.650125 BGP: [GVE17-CSNTB] path 81.1.1.0/24 unlinked
from VRF vrf2 nh 6.0.0.1 pathcount 16

2023/12/27 05:08:10.108038 ZEBRA: [Q8ZEK-CT776] Send L3VNI ADD 104001
VRF vrf1 RMAC 00:04:ba:10:10:62 VRR 1c:34:da:19:59:62 local-ip 6.0.0.31
filter none to bgp

2023/12/27 05:08:26.043121 ZEBRA: [R43YF-2MKZ3] Send L3VNI DEL 104001
VRF vrf1 to bgp

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2023-12-27 16:13:13 -08:00
Donatas Abraitis
cb777f9576 zebra: Show IPv6 link-local interfaces under show interface brief output
Despite if it's managed by FRR or the kernel, show it. If the system has only
link-local addresses, we should show it unless it's a secondary one.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-12-21 22:57:11 +02:00
Donatas Abraitis
f95479b150 zebra: Show IPv6 link-local interfaces under show interface output
Despite if it's managed by FRR or the kernel, show it.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-12-21 16:32:15 +02:00
Donatas Abraitis
02f8cf7769 zebra: Push all configured IP addresses when the interface comes up
Let's say we this:

```
$ ip link set down dev r1-eth0
$ ip link set up dev r1-eth0
```

But at the same time we have this interface configured by the FRR too:

```
interface r1-eth0
 ipv6 address fe80:1::1/64
exit
```

We never re-add fe80:1::1/64, when the interface comes up, and we have a
strange situation where NHT stops working and other stuff depending on NHT
stops too (BGP peering, etc.).

Closes: https://github.com/FRRouting/frr/issues/15050

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-12-21 16:32:14 +02:00
Donatas Abraitis
1332be595e zebra: Drop ipv6_address_configured() function
Not used.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-12-21 15:25:27 +02:00
Donald Sharp
61af06c813 zebra: Use event_add_event instead of _timer
The t_dequeue was being enqueued with a timer of 0
this is really an event instead of a timer.  Let's
use that instead.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-12-14 09:14:00 -05:00
Donald Sharp
3209ca4b08 zebra: Prevent possible wedged fpm write
An operator is reporting that the dplane_fpm_nl connection has
started to accumulate contexts.  One such path that could cause
this is that the obuf used is full and stays full.  This would
imply that what ever is on the receiving end has gotten wedged
and is not reading from the stream of data being sent it's way.
If after 15 seconds of no response, let's declare the connection
dead and reset it.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-12-14 09:12:46 -05:00
Carmine Scarpitta
223d4534cd zebra: Fetch actual SRv6 encap src addr on startup
When zebra is started, someone may have configured an SRv6 encap source
address different from the default address ( :: ) in the kernel.

On startup, zebra should not assume that the actual SRv6 encap source
address is the default address ( :: ), but should retrieve the actual
source address from the kernel and put it in zebra configuration. In
other words, on startup we expect the actual SRv6 encap source
address and the configured one to be the same.

This commit makes the necessary changes to support the above.

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2023-12-14 14:58:35 +01:00
Carmine Scarpitta
6a0956169b zebra: Add encap source address to SRv6 config write function
When writing the SRv6 config from zebra, we must also include the source
address of outer encapsulating IPv6 header.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2023-12-14 14:58:35 +01:00
Carmine Scarpitta
0c9b491035 zebra: Add CLI command to verify SRv6 Manager
Add a new CLI command `show segment-routing srv6 manager [json]` to
verify the overall SRv6 state. The current output displays only the
configured source address of outer encapsulating IPv6 header. The output
can be extended in the future to show more information, including
summary SRv6 information and supported capabilities.

Example:

```
r1# show segment-routing srv6 manager
Parameters:
  Encapsulation:
    Source Address:
      Configured: fc00:0:1::1

r1# show segment-routing srv6 manager json
{
  "parameters":{
    "encapsulation":{
      "sourceAddress":{
        "configured":"fc00:0:1::1"
      }
    }
  }
}
```

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2023-12-14 14:58:35 +01: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
Carmine Scarpitta
8d0b4745a1 zebra: Add code to set SRv6 encap source addr in dplane
Add a bunch of set functions and associated data structure in
zebra_dplane to allow the configuration of the source address for SRv6
encap in the data plane.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2023-12-14 14:56:44 +01:00
Carmine Scarpitta
959267f7c2 zebra: Add function to resolve Generic Netlink family
Generic Netlink is an extension of Netlink meant for kernel-user space
communications. It supports the dynamic allocation of communication
channels. Kernel and user space applications register their services
with a Generic Netlink controller. The Generic Netlink controller is
responsible for assigning a unique channel number with each service.
Clients who want to use a service query the controller to see if
the service exists and to determine the correct channel number. The
channel number is used to access the requested service.

This commit adds the base functionality to get the channel number
assigned to a specific service. More precisely, this commit adds a
function `genl_resolve_family()` that takes the service name (called
family in the Generic Netlink terminology) as an input parameter and
queries the Generic Netlink controller to get the channel number
assigned with the requested service.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2023-12-14 14:56:44 +01:00
Carmine Scarpitta
e14d1dcdbc zebra: Add Generic Netlink socket
zebra already supports several Netlink sockets which allow it to
communicate with the kernel. Each Netlink socket has a specific purpose:
we have a socket for incoming events from the kernel, a socket for
programming the dataplane, a socket for the kernel messages, a socket
used as the command channel. All the currently supported sockets are
based on the `NETLINK_ROUTE` protocol.

This commit adds a new Netlink socket that allows zebra to send
commands to the kernel using the `Generic Netlink` protocol.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2023-12-14 14:56:44 +01:00
Carmine Scarpitta
f998057fb3 zebra: Abstract the netlink_socket() API
The `netlink_socket()` function is used in many places to create and
initialize Netlink sockets. Currently, it can only create
`NETLINK_ROUTE` Netlink sockets.

This commit generalizes the behavior of the `netlink_socket()` function,
enabling it to generate Netlink sockets of any type. Specifically, it
extends the `netlink_socket()` function with a new argument `nl_family`,
which allows developers to specify the Netlink family of the socket to
be created.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2023-12-14 14:56:44 +01:00
Donald Sharp
8fcacf6803 zebra: Don't leak memory in rtadv.c code on shutdown
The adata variable was being leaked on shutdown since
it was calloc'ed.  There is no need to make this dynamic
memory.  Just choose a size and use that.  Add a bit
of code to ensure that if it's not large enough,
it will just stop and the developer will fix it.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-12-12 13:29:47 -05:00