Commit Graph

5832 Commits

Author SHA1 Message Date
Donatas Abraitis
03a4765cda
Merge pull request #15841 from pguibert6WIND/dx6_support
zebra, sharpd: add srv6 End.DX6 support
2024-04-26 23:25:34 +03:00
Russ White
f19817f71d
Merge pull request #15723 from opensourcerouting/feature/extended_link_bw_refactored_v1
bgpd: Implement extended link-bandwidth
2024-04-26 14:41:05 -04:00
Philippe Guibert
f6e58d26f6 zebra, sharpd: add srv6 End.DX6 support
Add the support for adding DX6 behavior into netlink layer of zebra.
Add the necessary test in sharpd.

> ubuntu2204# sharp install seg6local-routes 1:1::1:2 nexthop-seg6local loop1 End_DX6 4:4::4:6 1
> ubuntu2204# do show ipv6 route
> [..]
> D>* 1:1::1:2/128 [150/0] is directly connected, loop1, seg6local End.DX6 nh6 4:4::4:6, weight 1, 00:00:03

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2024-04-25 13:54:25 +02:00
Donatas Abraitis
a988a0a88a *: Use uint64_t for weight down the path to Zebra
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-04-22 17:50:08 +03:00
Donald Sharp
29c1ff446e lib, zebra: Check for not being a blackhole route
In zebra_interface_nhg_reinstall zebra is checking that the
nhg is a singleton and not a blackhole nhg.  This was originally
done with checking that the nexthop is a NEXTHOP_TYPE_IFINDEX,
NEXTHOP_TYPE_IPV4_IFINDEX and NEXTHOP_TYPE_IPV6_IFINDEX.  This
was excluding NEXTHOP_TYPE_IPV4 and NEXTHOP_TYPE_IPV6.  These
were both possible to be received and maintained from the upper
level protocol for when a route is being recursively resolved.
If we have gotten to this point in zebra_interface_nhg_reinstall
the nexthop group has already been installed at least once
and we *know* that it is actually a valid nexthop.  What the
test is really trying to do is ensure that we are not reinstalling
a blackhole nexthop group( Which is not possible to even be
here by the way, but safety first! ).  So let's change
to test for that instead.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-04-22 10:44:55 -04:00
Igor Ryzhov
99a723e5a8
Merge pull request #15803 from LabNConsulting/chopps/add-missing-zif-type
yang: add missing `zif-gre` zebra interface type
2024-04-20 21:25:28 +03:00
Christian Hopps
74fb4056cb yang: add missing zif-gre zebra interface type
This was caught by the grpc_basic test which was receiving an invalid error
result, which was returned b/c inside zebra the libyang code was flagging the
value as invalid for a derived zebra interface type.

Signed-off-by: Christian Hopps <chopps@labn.net>
2024-04-20 08:04:00 -04:00
Igor Ryzhov
57811a53ba lib, zebra: fix exit commands
If a command is not marked as `YANG`-converted, the current command
batching buffer is flushed before executing the command. We shouldn't
flush the buffer when executing an `exit` command. It should only be
flushed if the next command is not `YANG`-converted, which is checked by
the command itself, not the previous `exit`.

Fixes #15706.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-04-16 22:18:01 +03:00
Russ White
13d598712a
Merge pull request #15616 from pguibert6WIND/srv6_seg_list_sid_order
zebra: fix static srv6 segment-list sid order
2024-04-16 07:55:05 -04:00
Igor Ryzhov
8d6f7a4397 zebra: fix encoded DNSSL length
The encoded DNSSL length is not set so the value is missing from RA
packet.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-04-15 23:31:26 +03:00
Donatas Abraitis
deef11a22b
Merge pull request #15612 from sri-mohan1/srib-24-zebra-b
zebra: changes for code maintainability
2024-04-14 21:06:28 +03:00
Jafar Al-Gharaibeh
692f916b88
Merge pull request #15688 from mjstapp/dplane_api_version
lib, zebra: Add a version scheme for the dataplane API
2024-04-11 23:54:02 -05:00
Donald Sharp
4fb336424e zebra: rtadv uses uninited data to sendmsg
valgrind is complaining about this problem.
This fixes it.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-04-10 09:24:13 -04:00
Donatas Abraitis
73a6aa6a14
Merge pull request #15708 from donaldsharp/zebra_fix_io_display
Zebra fix io display and shorten evpn zapi packet sizes
2024-04-10 08:26:02 +03:00
Donald Sharp
5d7b50d1c0
Merge pull request #15693 from anlancs/fix/zebra-label-bind
zebra: fix wrong check for mpls label
2024-04-09 18:33:29 -04:00
Donald Sharp
94516d25aa zebra: Use more appropriately sized stream packets for evpn
When sending EVPN data, let's use more appropriately sized
packets for the sending of data.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-04-09 10:08:03 -04:00
Donald Sharp
8d8f12ba8e zebra: Actually display I/O buffer sizes
An operator found a situation where zebra was
backing up in a significant way towards BGP
with EVPN changes taking up some serious amounts
of memory.  The key lines that would have clued
us in on it were behind a dev build.  Let's change
this.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-04-09 10:08:03 -04:00
Mark Stapp
9f285dd0bc zebra: add dataplane API version value
Add a version value and accessor API for the zebra dataplane;
plugins can test this to detect API changes.

Signed-off-by: Mark Stapp <mjs@cisco.com>
2024-04-09 08:59:13 -04:00
Donald Sharp
8cfa3b57e9
Merge pull request #15645 from opensourcerouting/fix/show_ip_route_vrf_all_summary_json
zebra: Fix JSON output for `show route summary json`
2024-04-08 11:12:40 -04:00
Dmytro Shytyi
8e82e2d5ed zebra: fix static srv6 segment-list sid order
When configuring a SID list by vtysh, the segment list
obtained in iproute2 is the exact opposite:
>
>vtysh:
>ipv6 route 2005::/64 eth0 segments 2001:db8:aaaa::7/2002::2/2003::3/2004::4
>
>root@r1:/# ip -6 route
>2005::/64 nhid 6  encap seg6 mode encap segs 4 [ 2004::4 2003::3 2002::2 2001:db8:aaaa::7 ] dev dummy0 proto 196 metric 20 pref medium
>

Fix this by keeping the same vtysh config and swap the
segment's order of the list in the rt_netlink.c
>
>root@r1:/# ip -6 route
>2005::/64 nhid 6  encap seg6 mode encap segs 4 [ 2001:db8:aaaa::7 2002::2 2003::3 2004::4 ] dev dummy0 proto 196 metric 20 pref medium
>

Fixes: f20cf14 ("bgpd,lib,sharpd,zebra: srv6 introduce multiple segs/SIDs in nexthop")

Signed-off-by: Dmytro Shytyi <dmytro.shytyi@6wind.com>
2024-04-08 15:45:26 +02:00
anlan_cs
cbd1f3239a zebra: fix wrong check for mpls label
Add a parameter for `zebra_mpls_fec_for_label()`, as before if it is `NULL`,
otherwise exclude what this parameter represents.

Before:
```
anlan(config)# mpls label bind 1.1.1.2/32 88
anlan(config)# mpls label bind 1.1.1.2/32 88
% Label already bound to a FEC
anlan(config)# mpls label bind 1.1.1.3/32 88
% Label already bound to a FEC
```

After:
```
anlan(config)# mpls label bind 1.1.1.2/32 88
anlan(config)# mpls label bind 1.1.1.2/32 88
anlan(config)# mpls label bind 1.1.1.3/32 88
% Label already bound to a FEC
```

Signed-off-by: anlan_cs <anlan_cs@tom.com>
2024-04-06 09:01:39 +08:00
anlan_cs
9fb31c5e24 zebra: cosmetic change for one flag
Use `CHECK_FLAG()` for readability.

Signed-off-by: anlan_cs <anlan_cs@tom.com>
2024-04-05 14:30:26 +08: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
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
Mark Stapp
498967799d
Merge pull request #15598 from louis-6wind/fix-nhg-iface
zebra: fix rejected route due to wrong nexthop-group
2024-03-26 11:49:03 -04:00
sri-mohan1
2df51c7fe3 zebra: changes for code maintainability
these changes are for improving the code maintainability and readability

Signed-off-by: sri-mohan1 <sri.mohan@samsung.com>
2024-03-26 10:21:45 +05:30
Mark Stapp
2313916a9e
Merge pull request #15590 from sri-mohan1/srib-24-zebra-b
zebra: changes for code maintainability
2024-03-22 08:33:52 -04:00
Mark Stapp
20e017c379
Merge pull request #15010 from tlsalmin/master
zebra: Fix crash on macvlan link down/up
2024-03-22 08:31:12 -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
Donatas Abraitis
874242f129 *: Add missing SPDX-License-Identifier for some .c/.h files
Adding them as others: GPL-2.0-or-later

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-03-21 16:46:58 +02:00
sri-mohan1
2501c3a4dc zebra: changes for code maintainability
these changes are for improving the code maintainability and readability

Signed-off-by: sri-mohan1 <sri.mohan@samsung.com>
2024-03-21 14:56:24 +05:30
Russ White
502d1937da
Merge pull request #15552 from sri-mohan1/srib-24-zebra-a
zebra: changes for code maintainability
2024-03-19 10:24:13 -04:00
Alexander Skorichenko
444ce317b2 zebra: fix route deletion during zebra shutdown
Split zebra's vrf_terminate() into disable() and delete() stages.
The former enqueues all events for the dplane thread.
Memory freeing is performed in the second stage.

Signed-off-by: Alexander Skorichenko <askorichenko@netgate.com>
2024-03-15 11:42:02 +01:00
sri-mohan1
efbf981d3f zebra: changes for code maintainability
these changes are for improving the code maintainability and readability

Signed-off-by: sri-mohan1 <sri.mohan@samsung.com>
2024-03-15 10:30:23 +05:30
Donatas Abraitis
4b512f2f07
Merge pull request #15538 from idryzhov/fix-zebra-warning
zebra: fix compilation warnings
2024-03-14 10:38:24 +02:00
Donatas Abraitis
f0686aaa2e
Merge pull request #15501 from donaldsharp/fpm_listener_send_response
Fpm listener send response
2024-03-14 09:05:32 +02:00
Donatas Abraitis
caefee3571
Merge pull request #15526 from sri-mohan1/srib-24-zebra-a
zebra: changes for code maintainability
2024-03-13 12:41:07 +02:00
Donald Sharp
cca4bb6527 zebra: Add ability to pretend routes are offloaded
In the fpm_listener add a -r option to allow for
routes to be notified back to zebra that the route
has been `offloaded` properly.

fpm_listener output:
New route 4.5.6.7/32, Prot: Static(196), Metric: 20, nhgid: 23
  Route Static(196) reflecting back
FPM message - Type: 1, Length 56
New route 169.254.0.0/16, Prot: Kernel(2), Metric: 20, nhgid: 2
FPM message - Type: 1, Length 56
New route 192.168.99.0/24, Prot: Kernel(2), Metric: 20, nhgid: 42
FPM message - Type: 1, Length 56
New route 192.168.99.1/32, Prot: Kernel(2), Metric: 20, nhgid: 42
FPM message - Type: 1, Length 56
New route 192.168.119.0/24, Prot: OSPF(188), Metric: 20, nhgid: 20
  Route OSPF(188) reflecting back

Zebra output:

2024-03-06 21:48:54.613 [DEBG] zebra: [TJXPZ-RC5XQ] default(0:254):4.5.6.7/32 Processing dplane notif ctx 0x7160b4008780
2024-03-06 21:48:54.613 [DEBG] zebra: [TJXPZ-RC5XQ] default(0:254):192.168.119.0/24 Processing dplane notif ctx 0x7160b4008780

eva# show ip route 4.5.6.7 json
{
  "4.5.6.7/32":[
    {
      "prefix":"4.5.6.7/32",
      "prefixLen":32,
      "protocol":"static",
      "vrfId":0,
      "vrfName":"default",
      "selected":true,
      "destSelected":true,
      "distance":1,
      "metric":0,
      "installed":true,
      "offloaded":true,
....

and

eva# show ip route 192.168.119.0 json
{
  "192.168.119.0/24":[
    {
      "prefix":"192.168.119.0/24",
      "prefixLen":24,
      "protocol":"ospf",
      "vrfId":0,
      "vrfName":"default",
      "selected":true,
      "destSelected":true,
      "distance":110,
      "metric":100,
      "installed":true,
      "offloaded":true,
...

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-03-13 07:38:28 +00:00
Donald Sharp
4676c23cd8 zebra: fpm_listener start adding data about nexthops
Start some very small bit of work into the fpm_listener
about RTM_NEWNEXTHOPS.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-03-13 07:38:28 +00:00
Donald Sharp
58c53ab5ba zebra: Add some additional known protocols for fpm_listener
Just add a few more of the known protocols.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-03-13 07:38:27 +00:00
Igor Ryzhov
3280d81cc9 zebra: fix compilation warnings
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-03-13 07:08:44 +00:00
Donald Sharp
9ef76cff98 zebra: Cleanup leaked memory on shutdown from GR code
Recent commit: 6b2554b94a
Exposed, via Address Sanitation, that memory was being
leaked.  Unfortunately the CI system did not catch this.

Two pieces of memory were being lost: The zserv client
data structure as well as anything on the client->gr_info_queue.
Clean these up.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-03-12 21:18:02 -04:00
sri-mohan1
19a0211b73 zebra: changes for code maintainability
these changes are for improving the code maintainability and readability

Signed-off-by: sri-mohan1 <sri.mohan@samsung.com>
2024-03-12 12:00:12 +05:30
Donatas Abraitis
1942951ea4
Merge pull request #15523 from donaldsharp/lib_mtype_cleanup
Lib mtype cleanup
2024-03-12 07:14:10 +01:00
Donald Sharp
6b2554b94a zebra: Clean up leaked linklist data structure on shutdown
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-03-11 16:05:56 -04:00
Mark Stapp
d0afa12467
Merge pull request #15411 from raja-rajasekar/rajasekarr/backpressure_bgp_zebra_zserv
zebra: backpressure - Zebra push back on Buffer/Stream creation
2024-03-11 16:04:13 -04:00
Donald Sharp
7e058c201a
Merge pull request #15469 from LabNConsulting/chopps/keychain-yang
add ietf-key-chain YANG module support
2024-03-08 08:15:02 -05:00
Rajasekar Raja
a8efa994da zebra: backpressure - Zebra push back on Buffer/Stream creation
Currently, the way zebra works is it creates pthread per client (BGP is
of interest in this case) and this thread loops itself in zserv_read()
to check for any incoming data. If there is one, then it reads,
validates and adds it in the ibuf_fifo signalling the main thread to
process the message. The main thread when it gets a change, processes
the message, and invokes the function pointer registered in the header
command. (Ex: zserv_handlers).

Finally, if all of this was successful, this task reschedules itself and
loops in zserv_read() again

However, if there are already items on ibuf FIFO, that means zebra is
slow in processing. And with the current mechanism if Zebra main is
busy, the ibuf FIFO keeps growing holding up the memory.

Show memory zebra:(Example: 15k streams hoarding ~160 MB of data)
--- qmem libfrr ---
Stream             :       44 variable   3432352    15042 161243800

Fix:
Client IO Thread: (zserv_read)
 - Stop doing the read events when we know there are X number of items
   on the FIFO already.(X - zebra zapi-packets <1-10000> (Default-1000)

 - Determine the number of items on the zserv->ibuf_fifo. Subtract this
   from the work items and only pull the number of items off that would
   take us to X items on the ibuf_fifo again.

 - If the number of items in the ibuf_fifo has reached to the maximum
      * Either initially when zserv_read() is called (or)
      * when processing the remainders of the incoming buffer
   the client IO thread is woken by the the zebra main.

Main thread: (zserv_process_message)
If the client ibuf always schedules a wakeup to the client IO to read
more items from the socked buffer. This way we ensure
 - Client IO thread always tries to read the socket buffer and add more
   items to the ibuf_fifo (until max limit)
 - hidden config change (zebra zapi-packets <>) is taken into account

Ticket: #3390099

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Signed-off-by: Rajasekar Raja <rajasekarr@nvidia.com>
2024-03-07 15:16:33 -08:00
Russ White
ac34badf71
Merge pull request #15397 from idryzhov/zebra-oper
zebra: oper data additions
2024-03-05 11:41:35 -05:00