Commit graph

517 commits

Author SHA1 Message Date
Mark Stapp 7c98a27f3e zebra: clean up -Wshadow compiler warnings
Clean up variable-shadowing compiler warnings.

Signed-off-by: Mark Stapp <mjs@cisco.com>
2025-04-08 14:41:27 -04:00
Dmytro Shytyi e6d08a89c7
zebra: add rtadv information output in vtysh json
Add to "show interface json" output multiple rtadv parameters.

if_dump_vty() calls => hook_call(zebra_if_extra_info, vty, ifp);

if_dump_vty_json() now do the same call, with additional parameter:
hook_call(zebra_if_extra_info, vty, json_if, ifp);

Signed-off-by: Dmytro Shytyi <dmytro.shytyi@6wind.com>
2025-03-17 11:19:58 +01:00
Donald Sharp 45e2f0fc6e zebra: malloc functions cannot fail
Let's try to remember that when using a malloc function
it can never fail and as such testing for NULL does
nothing.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2025-03-07 11:48:05 -05:00
Gabriel Goller 80e96712e4 zebra: add ZEBRA_IF_DUMMY flag for dummy interfaces
Introduce ZEBRA_IF_DUMMY interface flag to identify Linux dummy interfaces [0].
These interfaces behave similarly to loopback interfaces and can be
specially handled by daemons.

[0]: https://github.com/torvalds/linux/blob/master/drivers/net/dummy.c

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
2025-02-25 10:13:34 +01:00
Christian Hopps 80c6f98ea7 lib: if: track oper-state inline
Signed-off-by: Christian Hopps <chopps@labn.net>
2025-01-13 23:40:52 -05:00
anlan_cs 4d2ac714f0 zebra: check kernel routes when interface becomes up
Just like `link down`, check all kernel routes when interface become up.
And, they maybe will be selected as the best one by zebra.

Signed-off-by: anlan_cs <anlan_cs@126.com>
2024-12-17 16:14:30 +08:00
Donald Sharp a92854047b zebra: Remove some unused functions on linux build
The functions:
if_get_flags
if_flags_update
if_flags_mangle

are never invoked from a linux netlink build.  Put a #ifdef
around those functions so that they are not included on the
linux build as that they are not needed there.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-11-25 13:12:10 -05:00
Donald Sharp 069dff269e zebra: Add ability to know if some config is set
For interface config:
shutdown
mpls
multicast

These states were never being shown in output, let's show it.

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

Signed-off-by: Mark Stapp <mjs@cisco.com>
2024-10-29 13:49:43 -04:00
Mark Stapp d349877aa5 zebra: removing use of per-NS if_table
Remove use of the per-NS if_table from zebra/interface
module. Use new add, lookup, and iteration apis.

Signed-off-by: Mark Stapp <mjs@cisco.com>
2024-10-28 14:54:06 -04:00
Mark Stapp 1f8d81335d zebra: make a zif MTYPE internal/static
Make an MTYPE used in zifs internal/static

Signed-off-by: Mark Stapp <mjs@cisco.com>
2024-10-28 11:09:52 -04:00
anlan_cs 05e2472de7 zebra: add back one field for debug
The `flags` field is removed recently, so add back it for debug.

Signed-off-by: anlan_cs <anlan_cs@126.com>
2024-10-13 21:30:46 +08:00
Donald Sharp d528c02a20 zebra: Handle kernel routes appropriately
Current code intentionally ignores kernel routes.  Modify
zebra to allow these routes to be read in on linux.  Also
modify zebra to look to see if a route should be treated
as a connected and mark it as such.

Additionally this should properly handle some of the issues
being seen with NOPREFIXROUTE.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-08-27 06:25:34 -04:00
Carmine Scarpitta 846bbcba0d zebra: Remove duplicate #include "zebra/interface.h"
Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-07-24 23:50:02 +02:00
Rajasekar Raja c77e15710d zebra: Fix to avoid two Vrfs with same table ids
During internal testing, when the following sequence is followed, two
non default vrfs end up pointing to the same table-id

 - Initially vrf201 has table id 1002
 - ip link add dev vrf202 type vrf table 1002
 - ip link set dev vrf202 up
 - ip link set dev <intrerface> master vrf202

This will ideally lead to zebra exit since this is a misconfiguration as
expected.

However if we perform a restart frr.service at this point, we end up
having two vrfs pointing to same table-id and bad things can happen.
This is because in the interface_vrf_change, we incorrectly check for
vrf_lookup_by_id() to evaluate if there is a misconfig. This works well
for a non restart case but not for the startup case.

root@mlx-3700-20:mgmt:/var/log/frr# sudo vtysh -c "sh vrf"
vrf mgmt id 37 table 1001
vrf vrf201 id 46 table 1002
vrf vrf202 id 59 table 1002 >>>>

Fix: in all cases of misconfiguration, exit zebra as expected.

Ticket :#3970414

Signed-off-by: Donald Sharp <sharpd@nvidia.com>

Signed-off-by: Rajasekar Raja <rajasekarr@nvidia.com>
2024-07-12 14:25:33 -07:00
Chirag Shah e4d843b438 zebra: fix evpn mh bond member proto reinstall
In case of EVPN MH bond, a member port going in
protodown state due to external reason (one case being linkflap),
frr updates the state correctly but upon manually
clearing external reason trigger FRR to reinstate
protodown without any reason code.

Fix is to ensure if the protodown reason was external
and new state is to have protodown 'off' then do no reinstate
protodown.

Ticket: #3947432
Testing:
switch:#ip link show swp1
4: swp1: <NO-CARRIER,BROADCAST,MULTICAST,SLAVE,UP> mtu 9216 qdisc
   pfifo_fast master bond1 state DOWN mode DEFAULT group default qlen
   1000
       link/ether 1c:34:da:2c:aa:68 brd ff:ff:ff:ff:ff:ff protodown on
       protodown_reason <linkflap>

switch:#ip link set swp1 protodown off protodown_reason linkflap off
switch:#ip link show swp1
 4: swp1: <NO-CARRIER,BROADCAST,MULTICAST,SLAVE,UP> mtu 9216 qdisc
    pfifo_fast master bond1 state DOWN mode DEFAULT group default qlen
    1000
        link/ether 1c:34:da:2c:aa:68 brd ff:ff:ff:ff:ff:ff

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2024-06-20 09:09:21 -07:00
Mark Stapp 75ef259b1d zebra: don't deref vxlan-vni array
Null-check the vxlan-vni array info coming into zebra from
the dataplane.

Signed-off-by: Mark Stapp <mjs@cisco.com>
2024-04-01 13:00:04 -04:00
Louis Scalbert 2a13b47185 zebra: fix rejected route due to wrong nexthop-group
A specific sequence of actions involving the addition and removal of IP
routes and network interfaces can lead to a route installation failure.
The issue occurs under the following conditions:

 - Initially, there is no route present via the ens3 interface.
 - Adds a route: ip route 10.0.0.0/24 192.168.0.100 ens3
 - Removes the same route: no ip route 10.0.0.0/24 192.168.0.100 ens3
 - Removes the ens3 interface.
 - Re-adds the ens3 interface.
 - Again adds the same route: ip route 10.0.0.0/24 192.168.0.100 ens3
 - And again removes it: no ip route 10.0.0.0/24 192.168.0.100 ens3
 - Shuts down the ens3 interface
 - Reactivates the interface
 - Adds the route once more: ip route 10.0.0.0/24 192.168.0.100 ens3

The route appears to be rejected.
> # show ip route nexthop
> S>r 10.0.0.0/24 [1/0] (6) via 192.168.0.100, ens3, weight 1, 00:00:01

The commit 35729f38fa ("zebra: Add a timer to nexthop group deletion")
introduced a feature to keep a nexthop-group in Zebra for a certain
period even when it is no longer in use. But if a nexthop-group
interface is removed during this period, the association between the
nexthop-group and the interface is lost in zebra memory. If the
interface is later added back and a route is re-established, the
nexthop-group interface dependency is not correctly reestablished.
As a consequence, the nexthop-group flags remain unset when the
interface is down. Upon the interface's reactivation, zebra does not
reinstall the nexthop-group in the kernel because it is marked as valid
and installed, but in reality, it does not exist in the kernel (it was
removed when the interface was down). Thus, attempts to install a route
via this nexthop-group ID fail.

Stop maintaining a nexthop-group when its associated interface is no
longer present.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-03-22 11:29:38 +01:00
Donald Sharp e28162b215 zebra: Move nhg reinstallation into if_up proper
The function call in to zebra_interface_nhg_reinstall
is an action that takes place on interface up events
*not* when the connected addresses are added to
a system.  this will prevent this function being
called when new connected interfaces come alive
that is an independent operation of the interface
coming up.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-02-08 12:22:09 -05:00
Donald Sharp fbce9231d1 zebra: Remove function abstraction in interface.c
zebra_if_nhg_dependents_XXX were just simple wrapper
functions that inited/deleted data structures.
These were already function calls themselves.  Let's
remove the abstraction and make the code simpler.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-02-08 12:05:05 -05:00
Donald Sharp 2934127547 zebra: Remove ifp_nhg_XXX functions completely
These functions provided a level of abstraction that forced
us to call multiple functions when a simple data structure
change was all that is needed.  Let's consolidate down
and make things a bit simpler.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-02-08 11:56:40 -05:00
Donald Sharp b9130ab51b zebra: Remove helper function if_nhg_dependents_is_empty
Let's just let the function figure this out.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-02-08 11:49:08 -05:00
Philippe Guibert 51cb6aee4b zebra: fix speed set to UINT32_MAX
get_iflink_speed() returns UINT32_MAX when the speeds is unknown.
Routing daemons (at least ospfd) interprets it as the high value.

Return errors in get_iflink_speed() to avoid the confusion.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-01-29 14:52:32 +01:00
Igor Ryzhov 15514b6d28 lib, mgmtd, zebra: cleanup of zebra conversion to mgmtd
- use `apply_finish` callback when possible to avoid multiple applies per commit
- move table range working to the CLI handler
- remove unnecessary conditional compilation
- remove unnecessary boolean conversion

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-28 23:46:38 +02:00
Igor Ryzhov 3900813298 zebra: convert to mgmtd
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-28 23:28:40 +02:00
Igor Ryzhov 218b5017ee zebra: convert interface configuration output to NB
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-28 23:28:40 +02:00
Igor Ryzhov 7c6e41ecff zebra: convert interface evpn mh es-df-pref command to NB
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-28 23:28:39 +02:00
Igor Ryzhov be712fc697 zebra: convert interface link-params packet-loss command to NB
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-28 23:28:39 +02:00
Igor Ryzhov 0a5b944aef zebra: convert interface link-params delay commands to NB
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-28 23:28:39 +02:00
Igor Ryzhov 217b65e5bf zebra: convert interface link-params neighbor command to NB
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-28 23:28:39 +02:00
Igor Ryzhov 93744dbe88 zebra: convert interface link-params bandwidth commands to NB
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-28 23:28:39 +02:00
Igor Ryzhov 59e3ce08fa zebra: convert interface link-params metric command to NB
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-28 23:28:39 +02:00
Igor Ryzhov b688eb7e9e zebra: convert interface link-params command to NB
Make link-params a presence container and activate it when entering the
node. The "enable" command is not necessary anymore but kept hidden for
backwards compatibility.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-28 23:28:39 +02:00
Igor Ryzhov 7fc02c462c zebra: mark interface mpls command as yang
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-28 23:28:39 +02:00
Igor Ryzhov fa500fd8ec zebra: convert interface ip/ipv6 address commands to NB
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-28 23:28:39 +02:00
Igor Ryzhov 0c2c01c151 zebra: convert interface bandwidth command to NB
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-28 23:28:39 +02:00
Igor Ryzhov edd3c63170 zebra: convert interface shutdown command to NB
Replace "shutdown" leaf with "enabled" leaf in frr-zebra YANG module
to make it in line with standard YANG models.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-28 23:28:39 +02:00
Igor Ryzhov df296d54ae zebra: convert interface link-detect command to NB
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-28 23:28:39 +02:00
Igor Ryzhov efa18c6c6f zebra: convert inteface multicast command to NB
Introduce new "[no] multicast <enable|disable>" command to be able to
remove the configuration. Current "[no] multicast" command cannot be
removed. Current command is hidden but still works for backwards
compatibility.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-28 23:28:39 +02:00
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
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 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
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
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
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