Commit graph

679 commits

Author SHA1 Message Date
Mark Stapp 1ca756f315
Merge pull request #18497 from krishna-samy/show-metaq-counters
zebra: show command to display metaq info
2025-04-16 09:16:40 -04:00
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
Krishnasamy 751ae76648 zebra: show command to display metaq info
Display below info from metaq and sub queues
1. Current queue size
2. Max/Highwater size
3. Total number of events received fo so far

r1# sh zebra metaq
MetaQ Summary
Current Size    : 0
Max Size        : 9
Total           : 20
 |------------------------------------------------------------------|
 | SubQ                             | Current  | Max Size  | Total  |
 |----------------------------------+----------+-----------+--------|
 | NHG Objects                      | 0        | 0         | 0      |
 |----------------------------------+----------+-----------+--------|
 | EVPN/VxLan Objects               | 0        | 0         | 0      |
 |----------------------------------+----------+-----------+--------|
 | Early Route Processing           | 0        | 8         | 11     |
 |----------------------------------+----------+-----------+--------|
 | Early Label Handling             | 0        | 0         | 0      |
 |----------------------------------+----------+-----------+--------|
 | Connected Routes                 | 0        | 6         | 9      |
 |----------------------------------+----------+-----------+--------|
 | Kernel Routes                    | 0        | 0         | 0      |
 |----------------------------------+----------+-----------+--------|
 | Static Routes                    | 0        | 0         | 0      |
 |----------------------------------+----------+-----------+--------|
 | RIP/OSPF/ISIS/EIGRP/NHRP Routes  | 0        | 0         | 0      |
 |----------------------------------+----------+-----------+--------|
 | BGP Routes                       | 0        | 0         | 0      |
 |----------------------------------+----------+-----------+--------|
 | Other Routes                     | 0        | 0         | 0      |
 |----------------------------------+----------+-----------+--------|
 | Graceful Restart                 | 0        | 0         | 0      |
 |------------------------------------------------------------------|

Signed-off-by: Krishnasamy <krishnasamyr@nvidia.com>
2025-04-01 09:32:46 +00:00
Pooja Jagadeesh Doijode 8c6489bc56 zebra: Return error if v6 prefix is passed to show ip route
Return error if IPv6 address or prefix is passed as an argument
to "show ip route" command.

UT:
r1# show ip route 2::3/128
% Cannot specify IPv6 address/prefix for IPv4 table
r1#
r1# show ip route 2::3
% Cannot specify IPv6 address/prefix for IPv4 table
r1#

Signed-off-by: Pooja Jagadeesh Doijode <pdoijode@nvidia.com>
2025-01-22 10:09:03 -08:00
Nathan Bahr 8983d24282 zebra: Improve multicast safi route show commands
Add `mrib` flag to existing "show ip route" commands which then use
the multicast safi rather than the unicast safi. Updated the vty output
to include the AFI and SAFI string when printing the table.
Deprecate `show ip rpf` command, aliased to `show ip route mrib`.
Removed `show ip rpf A.B.C.D`.

Signed-off-by: Nathan Bahr <nbahr@atcorp.com>
2024-12-12 13:50:31 +00:00
Nathan Bahr bf8728dcf6 zebra,yang: Completely remove multicast mode from zebra
Multicast mode belongs in PIM, so removing it completely from zebra.
Modified `show (ip|ipv6) rpf ADDRESS` to always lookup from SAFI_MULTICAST.
This means this command is now specific to the multicast table and does
not necessarily reflect the PIM RPF lookup, but that should be implemented
in PIM instead.

Signed-off-by: Nathan Bahr <nbahr@atcorp.com>
2024-12-12 13:50:31 +00:00
Donald Sharp e88cbd65dd zebra: Remove large indentation level in do_show_route_helper
CI is complaining about the large level of indentation.
Make it a bit better.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-11-04 13:02:36 -05:00
Donald Sharp f51d2a6b97 zebra: Don't display the vrf if not using namespace based vrfs
Currently when doing a `show ip route table XXXX`, zebra is displaying
the current default vrf as the vrf we are in.  We are displaying a
table not a vrf.  This is only true if you are not using namespace
based vrf's, so modify the output to display accordingly.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-11-04 12:14:47 -05:00
Nathan Bahr be2a7ed6af zebra: Add ability to import alternate tables into the MRIB
Expanded the cli command to include an mrib flag for importing to
the main table MRIB instead of the main table URIB.
Piped through specifying the safi through the import table functions
rather than hardcoding to SAFI_UNICAST.
Import still only import routes from the URIB subtable, only added the
ability to import into the main table MRIB.

Signed-off-by: Nathan Bahr <nbahr@atcorp.com>
2024-10-29 20:17:59 +00:00
Jafar Al-Gharaibeh f11421d4ec
Merge pull request #17160 from opensourcerouting/fix/keep_zebra_on-rib-process_in_frr.conf
lib, zebra: Keep `zebra on-rib-process script` in frr.conf
2024-10-27 18:23:36 -05:00
Louis Scalbert 6cdc82b21b zebra: fix showing nexthop vrf for ipv6 blackhole
For some reasons the Linux kernel associates the ipv6 blackhole of non
default table the lo interface.

> root@r1# ip -6 route show table 100
> root@r1# ip -6 route add unreachable default metric 4278198272 table 100
> root@r1# ip -6 route show table 100
> unreachable default dev lo metric 4278198272 pref medium

As a consequence, the VRF default that owns the lo interface is shown as
the nexthop VRF:

> r1# show ipv6 route table 20
> Table 20:
> K>* ::/0 [255/8192] unreachable (ICMP unreachable) (vrf default), 00:18:12

Do not display the nexthop VRF of a blackhole. It does not make sense
for a blackhole and it was not displayed in the past.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-10-18 14:45:50 +02:00
Donatas Abraitis 1fe1f8d87c lib, zebra: Keep zebra on-rib-process script in frr.conf
After the change:

```
$ grep on-rib-process /etc/frr/frr.conf
zebra on-rib-process script script4

$ systemctl restart frr

$ vtysh -c 'show run' | grep on-rib-process
zebra on-rib-process script script4
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-10-18 15:36:52 +03:00
Donald Sharp e54261e20d lib, zebra: TABLE_NODE is not used
No-one is using this, remove

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-09-24 16:05:54 -04:00
Donald Sharp d97c535c1e *: Create termtable specific temp memory
When trying to track down a MTYPE_TMP memory leak
it's harder to search for it when you happen to
have some usage of ttable_dump.  Let's just give
it it's own memory type so that we can avoid
confusion in the future.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-09-01 13:07:46 -04:00
Donald Sharp 0c72a78930 zebra: Allow for initial deny of installation of nhe's
Currently the FRR code will receive both kernel and
connected routes that do not actually have an underlying
nexthop group at all.  Zebra turns around and creates
a `matching` nexthop hash entry and installs it.
For connected routes, this will create 2 singleton
nexthops in the dplane per interface (v4 and v6).
For kernel routes it would just create 1 singleton
nexthop that might be used or not.

This is bad because the dplane has a limited amount
of space available for nexthop entries and if you
happen to have a large number of interfaces then
all of a sudden you have 2x(# of interfaces) singleton
nexthops.

Let's modify the code to delay creation of these singleton
nexthops until they have been used by something else in the
system.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-08-30 08:23:48 -04:00
Donald Sharp c10cdcd79a zebra: Display afi of the nexthop hash entry
Let's display the afi of the nexthop hash entry.  Right
now it is impossible to tell the difference between v4 or
v6 nexthops, especially since it is important for the kernel.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-08-29 14:49:36 -04:00
Donald Sharp 184dccca60 zebra: Move prefix lookup to outside re loop
Move the prefix lookup/comparison to outside the re loop
and into the rn loop, since that is where the code should
actually be.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-08-28 13:18:00 -04:00
Donald Sharp 266b061994 zebra: Properly note that a nhg's nexthop has gone down
Current code when a link is set down is to just mark the
nexthop group as not properly setup.  Leaving situations
where when an interface goes down and show output is
entered we see incorrect state.  This is true for anything
that would be checking those flags at that point in time.

Modify the interface down nexthop group code to notice the
nexthops appropriately ( and I mean set the appropriate flags )
and to allow a `show ip route` command to actually display
what is going on with the nexthops.

eva# show ip route 1.0.0.0
Routing entry for 1.0.0.0/32
  Known via "sharp", distance 150, metric 0, best
  Last update 00:00:06 ago
  * 192.168.44.33, via dummy1, weight 1
  * 192.168.45.33, via dummy2, weight 1

sharpd@eva:~/frr1$ sudo ip link set dummy2 down

eva# show ip route 1.0.0.0
Routing entry for 1.0.0.0/32
  Known via "sharp", distance 150, metric 0, best
  Last update 00:00:12 ago
  * 192.168.44.33, via dummy1, weight 1
    192.168.45.33, via dummy2 inactive, weight 1

Notice now that the 1.0.0.0/32 route now correctly
displays the route for the nexthop group entry.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-07-03 09:34:55 -04:00
vivek b5682ffbf0 *: Add and use option for graceful (re)start
Add a new start option "-K" to libfrr to denote a graceful start,
and use it in zebra and bgpd.

zebra will use this option to denote a planned FRR graceful restart
(supporting only bgpd currently) to wait for a route sync completion
from bgpd before cleaning up old stale routes from the FIB. An optional
timer provides an upper-bounds for this cleanup.

bgpd will use this option to denote either a planned FRR graceful
restart or a bgpd-only graceful restart, and this will drive the BGP
GR restarting router procedures.

Signed-off-by: Vivek Venkatraman <vivek@nvidia.com>
2024-07-01 13:02:52 -07:00
Louis Scalbert 85eb60ffd6 zebra: fix show route memory consumption
When displaying a route table in JSON, a table JSON object is storing
all the prefix JSON objects containing the prefix information. This
results in excessive memory allocation for JSON objects, potentially
leading to an out-of-memory error on the machine with large routing
tables.

To Fix the memory consumption issue for the "show ip[v6] route [vrf XX]
json" command, display the prefixes one by one and free the memory of
each JSON object after it has been displayed.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-06-07 10:13:32 +02:00
Louis Scalbert cb440058f2 zebra: fix show route vrf all memory consumption
0e2fc3d67f ("vtysh, zebra: Fix malformed json output for multiple vrfs
in command 'show ip route vrf all json'") has been reverted in the
previous commit. Although the fix was correct, it was consuming too muca
memory when displaying large route tables.

A root JSON object was storing all the JSON objects containing the route
tables, each containing their respective prefixes in JSON objects. This
resulted in excessive memory allocation for JSON objects, potentially
leading to an out-of-memory error on the machine.

To Fix the memory consumption issue for the "show ip[v6] route vrf all
json" command, display the tables one by one and free the memory of each
JSON object after it has been displayed.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-06-07 10:13:32 +02:00
Louis Scalbert 0c6f14ec14 Revert "vtysh, zebra: Fix malformed json output for multiple vrfs in command 'show ip route vrf all json'"
This reverts commit 0e2fc3d67f.

This fix was correct but not optimal for memory consumption at scale.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-06-07 10:12:42 +02:00
Mark Stapp d6835df9cc zebra: include route source set by route-map in show output
Include the prefix source address when set by a route-map in
show output for routes, in various formats.
Add some debugs when encoding netlink route messages with
a source address.

Signed-off-by: Mark Stapp <mjs@cisco.com>
2024-05-14 10:28:17 -04:00
Igor Ryzhov 58a8ebc1fc lib: rework northbound RPC callback
Change input/output arguments of the RPC callback from lists of
(xpath/value) tuples to YANG data trees.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-04-22 16:36:22 +03:00
Donatas Abraitis ca13121849 zebra: Fix JSON output for show route summary json
Before:
```
{
  "routes":[
    {
      "fib":1,
      "rib":1,
      "fibOffLoaded":0,
      "fibTrapped":0,
      "type":"connected"
    },
    {
      "fib":1,
      "rib":1,
      "fibOffLoaded":0,
      "fibTrapped":0,
      "type":"local"
    },
    {
      "fib":2,
      "rib":2,
      "fibOffLoaded":0,
      "fibTrapped":0,
      "type":"static"
    }
  ],
  "routesTotal":4,
  "routesTotalFib":4
}
{
  "routes":[
    {
      "fib":2,
      "rib":2,
      "fibOffLoaded":0,
      "fibTrapped":0,
      "type":"connected"
    },
    {
      "fib":2,
      "rib":2,
      "fibOffLoaded":0,
      "fibTrapped":0,
      "type":"local"
    },
    {
      "fib":2,
      "rib":2,
      "fibOffLoaded":0,
      "fibTrapped":0,
      "type":"static"
    }
  ],
  "routesTotal":6,
  "routesTotalFib":6
}
```

After:
```
{
  "ISR":{
    "routes":[
      {
        "fib":1,
        "rib":1,
        "fibOffLoaded":0,
        "fibTrapped":0,
        "type":"connected"
      },
      {
        "fib":1,
        "rib":1,
        "fibOffLoaded":0,
        "fibTrapped":0,
        "type":"local"
      },
      {
        "fib":2,
        "rib":2,
        "fibOffLoaded":0,
        "fibTrapped":0,
        "type":"static"
      }
    ],
    "routesTotal":4,
    "routesTotalFib":4
  },
  "default":{
    "routes":[
      {
        "fib":2,
        "rib":2,
        "fibOffLoaded":0,
        "fibTrapped":0,
        "type":"connected"
      },
      {
        "fib":2,
        "rib":2,
        "fibOffLoaded":0,
        "fibTrapped":0,
        "type":"local"
      },
      {
        "fib":2,
        "rib":2,
        "fibOffLoaded":0,
        "fibTrapped":0,
        "type":"static"
      }
    ],
    "routesTotal":6,
    "routesTotalFib":6
  }
}
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-03-30 23:04:10 +02:00
Piotr Suchy 0e2fc3d67f vtysh, zebra: Fix malformed json output for multiple vrfs in command 'show ip route vrf all json'
Command 'show ip route vrf <vrf_name> json' returns a valid json object,
however if instead of <vrf_name> we specify 'all', we get an invalid json
object, like:

{//vrf1 routes}{//vrf2 routes}{vrf3 routes}

After the fix:

{"vrf1":{//vrf1 routes},"vrf2:{//vrf2 routes},"vrf3":{//vrf3 routes}}

Which is a valid json object, that can be parsed effectively using built-in
modules. The rest of the commands remains unaffected and behave the same.

Signed-off-by: Piotr Suchy <psuchy@akamai.com>
2024-03-29 14:01:21 +01:00
Donald Sharp b2ade8e3d2 zebra: When reinstalling a NHG, set REINSTALL flag
The current code is unsetting the fact that the
NHG is installed.  It is installed but we are
reinstalling it.  Let's note this in the code
appropriately as REINSTALL and not remove the
INSTALLED FLAG.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-02-08 12:32:26 -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
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 741d1d0090 zebra: convert vrf configuration output to NB
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-28 23:28:40 +02:00
Igor Ryzhov 86855aed78 zebra: convert table range command to NB
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-28 23:28:40 +02:00
Igor Ryzhov 2117faf1cf zebra: convert resolve-via-default commands to NB
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-28 23:28:40 +02:00
Igor Ryzhov 1f2b7c1058 zebra: fix vni NB conversion
- unnecessary command duplication
- usage of oper data during validation
- unnecessary checks for things that can't happen

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
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
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 7e1b56ba98 zebra: When using Nexthop groups, use v6 RR semantics
The nexthop group route replace operation was made consistent
across all versions of the kernel.  A v6 route replacement
does not need to do a delete than add when using nexthop
groups

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-11-06 08:56:50 -05:00
Donald Sharp 7fe9333dd7 zebra: Move v6_rr_semantics to be part of zrouter structure
Move global variable v6_rr_semantics from a global data structure
into the zrouter data structure.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-11-06 08:42:30 -05:00
Donald Sharp 4e996e98ec zebra: Add v6_rr_semantics status to show zebra
The v6_rr_semantics variable was being set but never
reported and had to be inferred from watching netlink
messages to the kernel.  Let's add a bit of code
to `show zebra` so that we can know how it is being
used.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-11-06 08:12:04 -05: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
Donatas Abraitis d02fae5836 zebra: Show NHT resolve via default status on/off
```
donatas-laptop# show ip nht
VRF default:
 Resolve via default: on
192.168.10.123
 resolved via connected
 is directly connected, wlp82s0 (vrf default)
 Client list: bgp(fd 21)
donatas-laptop# show ip nht json
{
  "default":{
    "ipv4":{
      "resolveViaDefault":true,
      "192.168.10.123":{
        "nhtConnected":false,
        "clientList":[
          {
            "protocol":"bgp",
            "socket":21,
            "protocolFiltered":"none"
          }
        ],
        "nexthops":[
          {
            "flags":3,
            "fib":true,
            "directlyConnected":true,
            "interfaceIndex":3,
            "interfaceName":"wlp82s0",
            "vrf":"default",
            "active":true
          }
        ],
        "resolvedProtocol":"connected"
      }
    }
  }
}
donatas-laptop# show ip nht vrf all

VRF default:
 Resolve via default: on
192.168.10.123
 resolved via connected
 is directly connected, wlp82s0 (vrf default)
 Client list: bgp(fd 21)
donatas-laptop# show ip nht vrf all json
{
  "default":{
    "ipv4":{
      "resolveViaDefault":true,
      "192.168.10.123":{
        "nhtConnected":false,
        "clientList":[
          {
            "protocol":"bgp",
            "socket":21,
            "protocolFiltered":"none"
          }
        ],
        "nexthops":[
          {
            "flags":3,
            "fib":true,
            "directlyConnected":true,
            "interfaceIndex":3,
            "interfaceName":"wlp82s0",
            "vrf":"default",
            "active":true
          }
        ],
        "resolvedProtocol":"connected"
      }
    }
  }
}
donatas-laptop#
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-08-17 21:45:55 +03:00
Donald Sharp 1f5611c06d zebra: Allow zebra cli to accept v6 routes with v4 nexthops
add --v6-with-v4-nexthop cli to zebra to allow operator to
specify that this functionality is allowed.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-08-03 08:25:20 -04:00
Sindhu Parvathi Gopinathan 1c67c0951b zebra: non pretty json output for show ip route
Currently, json output of show ip route command are no pretty format.
This is an extremely expensive operation at high scale
(with high number of routes with many paths).

Zebra json non-pretty command support added:

```
show ip route json
```

Ticket:#3513256

Issue:3513256

Testing: UT done

Signed-off-by: Sindhu Parvathi Gopinathan's <sgopinathan@nvidia.com>
2023-07-21 10:15:11 -07:00
anlan_cs f8d94e8a62 zebra: remove unnecessary check for default vrf
The default vrf is generally non-NULL, except when shutdown. So, most
of the time it is not necessary to check if it is NULL, we should
remove the useless checks for it.

Searched them with exact match:
```
grep -rI "zebra_vrf_lookup_by_id(VRF_DEFAULT)" | wc -l
31
```

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2023-07-12 17:00:27 +08:00
Donald Sharp 9a7d1e7427 zebra: Use zebra_vrf_lookup_by_id when we can
Let's make this as consistent as is possible.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-28 15:49:50 -04:00
Donald Sharp 5f6eaa9b96 *: Convert a bunch of thread_XX to event_XX
Convert these functions:

thread_getrusage
thread_cmd_init
thread_consumed_time
thread_timer_to_hhmmss
thread_is_scheduled
thread_ignore_late_timer

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Russ White 12906cb1c8
Merge pull request #12798 from donaldsharp/rib_match_multicast
Rib match multicast
2023-02-21 11:40:36 -05:00
Donald Sharp 8383d53e43
Merge pull request #12780 from opensourcerouting/spdx-license-id
*: convert to SPDX License identifiers
2023-02-17 09:43:05 -05:00
Donald Sharp e6174ae2cb doc: Add show ipv6 rpf X:X::X:X command to docs
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-02-16 07:52:35 -05:00
Donald Sharp 312e29b060 zebra: Remove code duplication for v4 and v6 versions of rib_match_multicast
a) Consolidate v4 and v6 versions of rib_match_multicast
b) Improve debug to show what we matched against as well.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-02-16 07:52:35 -05:00