Commit graph

680 commits

Author SHA1 Message Date
Dmytro Shytyi 426f861268 zebra: add End.B6.Encaps to rt_netlink
Introduce the End.B6.Encaps in the rt_netlink code.

Signed-off-by: Dmytro Shytyi <dmytro.shytyi@6wind.com>
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2025-04-25 15:22:43 +02: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
Donald Sharp abbfcc49f9 zebra: Fix srv6 segment nexthop memory leak.
The srv6 segment was being set but never freed
on the statically allocated nexthop.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2025-02-04 15:13:48 -05:00
Donald Sharp 29dcfd415f zebra: Stop leaking labels when receiving nexthops from kernel
This leak is happening:
Direct leak of 96 byte(s) in 2 object(s) allocated from:
    0 0x7f6922eb83b7 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:77
    1 0x7f6922a38ebb in qcalloc lib/memory.c:106
    2 0x7f6922a553d6 in nexthop_add_srv6_seg6 lib/nexthop.c:652
    3 0x562825e56b38 in parse_nexthop_unicast zebra/rt_netlink.c:589
    4 0x562825e58c4a in netlink_route_change_read_unicast_internal zebra/rt_netlink.c:1291
    5 0x562825e58eef in netlink_route_change_read_unicast zebra/rt_netlink.c:1321
    6 0x562825e64921 in netlink_route_change zebra/rt_netlink.c:1494
    7 0x562825e43407 in netlink_information_fetch zebra/kernel_netlink.c:407
    8 0x562825e439b5 in netlink_parse_info zebra/kernel_netlink.c:1148
    9 0x562825e44060 in kernel_read zebra/kernel_netlink.c:510
    10 0x7f6922aeca72 in event_call lib/event.c:1984
    11 0x7f6922a19e01 in frr_run lib/libfrr.c:1246
    12 0x562825e4b0b9 in main zebra/main.c:543
    13 0x7f692250c249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58

Just check to see if it has been allocated.  The nexthop is a stack
variable so it's a bit odd.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2025-02-04 15:00:12 -05:00
David Lamparter 1d341d461e zebra: install dst-src routes without NHG
The Linux kernel doesn't support dst-src routes with NHGs as nexthop,
for some (rather dubious) caching reasons.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2025-01-28 11:10:31 +01:00
Mark Stapp 079ee236ec zebra: remove thread-unsafe debug from netlink nhg encoder
Remove use of vrf name, which isn't thread-safe.

Signed-off-by: Mark Stapp <mjs@cisco.com>
2024-12-05 09:23:53 -05:00
Mark Stapp bea4aa7b5e zebra: remove thread-unsafe debugs from netlink route encode
The netlink route message encode function accessed and used
zebra vrfs to produce debug output. That's not thread-safe, and
that encode code needs to run in (at least) the dplane pthread
and the FPM plugin pthread.

Signed-off-by: Mark Stapp <mjs@cisco.com>
2024-12-05 09:23:53 -05:00
Mark Stapp 29122bc9b8 zebra: refactor netlink route message parsing
Separate core netlink route message parsing into a new api that
uses a dplane ctx to hold the parsed attribute data. Use the new
api in two paths: the normal netlink update message parsing path,
and in the FPM plugin, which also uses netlink encoding. The FPM
route-notificatin code runs in its own pthread, and only needs
a subset of the route info that zebra ordinarily develops. This
change stops that pthread from accessing zebra's internal
data, such as vrfs and ifps, that are not thread-safe.

Signed-off-by: Mark Stapp <mjs@cisco.com>
2024-12-05 09:23:53 -05:00
Chirag Shah 97538158ba zebra: EVPN add debug trace for HREP entry
Ticket: #4139506

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2024-11-25 09:00:03 -08:00
Donald Sharp 3bff65abc7 zebra: When installing a mroute, allow it to flow
Currently the mroute code was not allowing the mroute
to be sent to the dataplane.  This leaves us with a
situation where the routes being installed where never
being set as installed and additionally nht against
the mrib would not work if the route came into existence
after the nexthop tracking was asked for.

Turns out all the pieces where there to let this work.
Modify the code to pass it to the dplane and to send
it back up as having worked.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-10-28 15:02:39 -04:00
Donald Sharp 9f8968fc5a *: Allow 16 bit size for nexthops
Currently FRR is limiting the nexthop count to a uint8_t not a
uint16_t.  This leads to issues when the nexthop count is 256
which results in the count to overflow to 0 causing problems
in the code.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-10-08 09:26:57 -04:00
Donatas Abraitis 73d01a8e40 zebra: Send a correct size of ctx->nh6 for SRv6 SEG6_LOCAL_ACTION_END_DX6
Fixes: f6e58d26f6 ("zebra, sharpd: add srv6 End.DX6 support")

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-09-19 23:54:43 +03: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
Donald Sharp b62de7de2e zebra, tests: Connected and Local routes should have a weight of 1
All routes received by zebra from upper level protocols have a weight
of 1.  Let's just make everything extremely consistent in our code.
Lot's of tests needed to be fixed up to make this work.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-08-21 10:17:47 -04:00
Donatas Abraitis 1e288c9b55 zebra: Do not forget to free opaque data for route entry
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-08-13 18:00:30 +03:00
Russ White db1e2a094d
Merge pull request #16008 from mjstapp/show_routemap_source
zebra: include route source set by route-map in show output
2024-05-15 06:18:41 -04: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
Donald Sharp bd4fca132a zebra: Ensure multipath encodes vxlan right for fpm usage
The fpm code path for the dplane_fpm_nl module was improperly
encoding the multipath nexthop data for vxlan type routes.
Move this into the embedded nexthop encoding where it belongs.

This change makes it so that the usage of `-M dplane_fpm_nl`
is now producing the same netlink messages that `-M fpm`
produces when using vxlan based nexthops.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-05-09 11:52:51 -04:00
Donald Sharp 569f9e4394 zebra: Move fpm check to inside of netlink_route_nexthop_encap
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-05-09 11:52:51 -04:00
Donald Sharp ba5a3538e8 zebra: Move netlink_route_nexthop_encap
Move this static function earlier so we can avoid
a predecleartion.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-05-09 11:52:51 -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
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
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
Donald Sharp 7f9c5c7fa2 zebra: The dplane_fpm_nl return path leaks memory
The route entry created when using a ctx to pass route
entry data backup to the master pthread in zebra is
being leaked.  Prevent this from happening.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-12-11 13:44:06 -05: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
Philippe Guibert e91ef7727f zebra: fix wrong nexthop id debug message
When allocating big protocol level identifiers, the number range is
big, and when pushing to netlink messages, the first nexthop group
is truncated, whereas the nexthop has been installed on the kernel.

> ubuntu2204(config)# nexthop-group A
> ubuntu2204(config-nh-group)# group 1
> ubuntu2204(config-nh-group)# group 2
> ubuntu2204(config-nh-group)# exi
> ubuntu2204(config)# nexthop-group 1
> ubuntu2204(config-nh-group)# nexthop 192.0.2.130 loop1 enable-proto-nhg-control
> ubuntu2204(config-nh-group)# exi
> ubuntu2204(config)# nexthop-group 2
> ubuntu2204(config-nh-group)# nexthop 192.0.2.131 loop1 enable-proto-nhg-control
> [..]
> 2023/11/24 16:47:40 ZEBRA: [VNMVB-91G3G] _netlink_nexthop_build_group: ID (179687500): group 17968/179687502

> # ip nexthop ls
> id 179687500 group 179687501/179687502 proto 194

Fix this by increasing the buffer size when appending the first number.

Fixes: 8d03bc501b ("zebra: Handle nhg_hash_entry encaps/more debugging")

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-11-30 14:25:08 +01:00
Donatas Abraitis b9228127df
Merge pull request #14835 from donaldsharp/multipath_evpn_encap_attr
zebra: Fix fpm multipath encap addition
2023-11-21 09:08:40 +02:00
Donald Sharp 6b23ece88b zebra: Fix fpm multipath encap addition
The fpm code path in building a ecmp route for evpn has
a bug that caused it to not add the encap attribute to
the netlink message.  See #f0f7b285b99dbd971400d33feea007232c0bd4a9
for the single path case being fixed.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-11-20 09:47:31 -05:00
Mark Stapp bb3faf1b95 zebra: reduce number of switch statements with dplane opcodes
Replace several switch blocks that contain every dplane opcode
with simpler sets of if()s. In these cases the code only
uses a couple of opcodes.

Signed-off-by: Mark Stapp <mjs@labn.net>
2023-11-17 08:40:58 -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 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
Donald Sharp 4ac659fcbe zebra: Add encap type when building packet for FPM
Currently in the single nexthop case w/ evpn sending
down via the FPM the encap type is not being set
for the nexthop.

This looks like the result of some code reorg for the
nexthop happened but the fpm failed to be accounted for.
Let's just move the encap type encoding to where it
will happen.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-10-28 10:03:39 -04:00
Igor Ryzhov 7d67b9ff28 build: add -Wimplicit-fallthrough
Also:
- replace all /* fallthrough */ comments with portable fallthrough;
pseudo keyword to accomodate both gcc and clang
- add missing break; statements as required by older versions of gcc
- cleanup some code to remove unnecessary fallthrough

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-10-12 21:23:18 +03:00
Dmytro Shytyi f20cf1457d bgpd,lib,sharpd,zebra: srv6 introduce multiple segs/SIDs in nexthop
Append zebra and lib to use muliple SRv6 segs SIDs, and keep one
seg SID for bgpd and sharpd.

Note: bgpd and sharpd compilation relies on the lib and zebra files,
i.e if we separate this: lib or zebra or bgpd or sharpd in different
commits - this will not compile.

Signed-off-by: Dmytro Shytyi <dmytro.shytyi@6wind.com>
2023-09-20 15:07:15 +02:00
Russ White 986dfa5e5d
Merge pull request #14348 from opensourcerouting/fpm-rr
zebra: support route replace semantic in FPM
2023-09-12 08:45:14 -04:00
Russ White 48d6039e14
Merge pull request #13724 from cscarpitta/feature/isisd-srv6-support
isisd: Add support for SRv6 uSID (RFC 9352)
2023-09-12 08:33:42 -04:00
Carmine Scarpitta d890515194 zebra: Encode SRv6 flavors in Netlink messages
Encode SRv6 flavors information when building a seg6local nexthop.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2023-09-11 17:35:04 +02:00
Carmine Scarpitta 2417b4add8 zebra: Resolve default values for SRv6 flavor attr
When zebra receives a Netlink message containing a seg6local nexthop,
let's use the default values for optional attributes `lcblock_len` and
`lcnode_fn_len`, if they are not specified.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2023-09-11 17:35:04 +02:00
Carmine Scarpitta c9f0452a14 zebra: Resolve default values for SRv6 flavor attr
When zebra receives a Netlink message containing a seg6local nexthop,
let's use the default values for optional attributes `lcblock_len` and
`lcnode_fn_len`, if they are not specified.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2023-09-11 17:35:03 +02:00
Carmine Scarpitta f4d2d9ba0a zebra: Extend rt_netlink.c to parse SRv6 flavors
Extend the `parse_encap_seg6local` function to parse SRv6 flavors
information contained in the Netlink message.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2023-09-11 17:35:02 +02:00
Rafael Zalamena 6374aeab80 zebra: support route replace semantics in FPM
Set `NLM_F_REPLACE` instead of adding and removing the same route for an
update.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2023-09-04 15:38:03 -03:00
Martin Pels 4d96ce1b4d zebra: Make main routing table (RT_TABLE_MAIN) configurable
Signed-off-by: Martin Pels <mpels@ripe.net>
2023-08-22 15:29:07 +02:00
Donald Sharp a014450441 zebra: Add code to get/set interface to pass up from dplane
1) Add a bunch of get/set functions and associated data
structure in zebra_dplane to allow the setting and retrieval
of interface netlink data up into the master pthread.

2) Add a bit of code to breakup startup into stages.  This is
because FRR currently has a mix of dplane and non dplane interactions
and the code needs to be paused before continuing on.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-07-05 13:03:14 -04:00
Donald Sharp 6a3ae11c9b zebra: Rename vrf_lookup_by_tableid to zebra_vrf_lookup..
Rename the vrf_lookup_by_id function to zebra_vrf_lookup_by_id
and move to zebra_vrf.c where it nominally belongs, as that
we need zebra specific data to find this vrf_id and as such
it does not belong in vrf.c

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-07-05 11:49:36 -04:00
Donald Sharp 24a58196dd *: Convert event.h to frrevent.h
We should probably prevent any type of namespace collision
with something else.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp cb37cb336a *: Rename thread.[ch] to event.[ch]
This is a first in a series of commits, whose goal is to rename
the thread system in FRR to an event system.  There is a continual
problem where people are confusing `struct thread` with a true
pthread.  In reality, our entire thread.c is an event system.

In this commit rename the thread.[ch] files to event.[ch].

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:16 -04:00
Donatas Abraitis 933282787c
Merge pull request #12811 from Avineus/frr_neighlog_5884
Fix for "Debugs For RFC 5549 Neighbor Creation #5884"
2023-03-01 09:59:01 +02:00
Kavitha 55da97df50 zebra: neigh update netlink log
Added debug log in netlink_neigh_update(), with
ifindex, ifname, ipaddress and mac address.

Signed-off-by: Kavitha <kavirhene@gmail.com>
2023-02-27 18:45:03 +05:30