Commit graph

237 commits

Author SHA1 Message Date
Mark Stapp 14b74d50ec sharpd: clean up variable-shadowing compiler warnings
Clean up -Wshadow in sharpd

Signed-off-by: Mark Stapp <mjs@cisco.com>
2025-04-08 14:41:27 -04:00
David Lamparter cda7c4ed31 sharpd: add crashme commands
This adds 2 commands, one that should just straight up SEGV, another
that should trip an ASAN warning for an use-after-free.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2025-02-14 17:31:18 +01:00
Donatas Abraitis 564a8bca2c
Merge pull request #17445 from cscarpitta/fix/sharp-use-ipv6-max-bitlen
sharpd: Convert numeric 128 into IPV6_MAX_BITLEN for prefixlen
2024-11-17 14:19:58 +02:00
Carmine Scarpitta 58b2e8c5b0 sharpd: Use IPV6_MAX_BITLEN in sharp send opaque notify
Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-11-17 08:24:44 +01:00
Carmine Scarpitta 0019ecff1b sharpd: Use IPV6_MAX_BITLEN in sharp install seg6local-routes
Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-11-17 08:24:18 +01:00
Carmine Scarpitta cf658b28b1 sharpd: Fix typo in sharp install seg6local-routes help message
Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-11-17 08:16:26 +01:00
Carmine Scarpitta 4cb6f5b875 sharpd: Fix typo in sharp install seg6-routes help message
Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-11-17 08:15:51 +01:00
Carmine Scarpitta 769751f6fc sharpd: Fix typo in sharp install routes help message
Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-11-17 08:15:00 +01:00
Donald Sharp aff8eaa4a2 sharpd: Allow sharpd to watch nexthops in the mrib
Nothing special here, just allow sharpd to ask to watch
nexthops in the mrib.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-10-28 14:10:06 -04:00
Donald Sharp 5891afb824 sharpd: Eliminate leaked list for locator-chunks
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-08-08 14:24:59 -04:00
Philippe Guibert 7f2a9114af sharpd: fix set ZAPI_MESSAGE_NEXTHOP in nhg only when nexthops used
The ZAPI_MESSAGE_NEXTHOP flag is systematically set, even if the
route message does not include any nexthops. Limit the usage of this
value only when nexthops are present.

Fixes: 8a71d93d85 ("sharpd: Add Super Happy Advanced Routing Protocol")

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2024-07-04 13:56:35 +02: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
Mark Stapp 72b31b96fc *: create a single registry of daemons' default port values
Create a single registry of default port values that daemons
are using. Most of these are vty ports, but there are some
others for features like ospfapi and zebra FPM.

Signed-off-by: Mark Stapp <mjs@labn.net>
2024-02-01 11:40:02 -05:00
David Lamparter 634f481113 *: fix frr_daemon_info indentation
clang-format doesn't understand FRR_DAEMON_INFO is a long macro where
laying out items semantically makes sense.

(Also use only one `FRR_DAEMON_INFO(` in isisd so editors don't get
confused with the mismatching `( ( )`.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-01-27 19:02:51 +01:00
Donald Sharp 3d97d2679f sharpd: Add ability to turn off watching of redistribution
Wanted to do some testing of redistribute without having
to restart sharpd over and over.  Added ability to
turn off the `sharp watch redistribute XX` functionality.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-01-26 09:26:30 -05:00
Donald Sharp 2703f331e2 sharpd: Fix coverity issues
New commits had an assignment instead of a comparison
option.  Coverity wisely found it.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-01-23 10:28:30 -05:00
Donald Sharp 01cb1fb82c sharpd: Allow sharpd to listen to neighbor events
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-01-22 12:19:20 -05:00
Russ White d5a0a70bbf
Merge pull request #15001 from pguibert6WIND/zebra_nexthop_rework
Zebra nexthop rework
2024-01-09 10:11:35 -05:00
Donald Sharp d69ac58c65 lib, sharpd: Move sys/resource.h to where it is used
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-01-04 14:43:46 -05:00
Philippe Guibert d8477d4bb5 bgpd, lib: add zapi_route_set_nhg_id() support
There is no function that both sets the nhg id, and sets
the ZAPI_MESSAGE_NHG flag if the nhg id is valid.
Create a ZAPI API to do this, and apply the changes wherever
needed.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-12-18 10:08:45 +01:00
Philippe Guibert f806ec101f sharpd: fix avoid twice sending NHG_DEL for a nexthop-group
After removing the nexthop of a nexthop group, when the nexthop group
is removed, a nhg removal failure happens:

> ubuntu2204(config)# nexthop-group CCC
> ubuntu2204(config-nh-group)#  nexthop 192.0.2.211 loop1
> ubuntu2204(config-nh-group)# no  nexthop 192.0.2.211 loop1
> [..]
> 2023/12/05 08:59:22 SHARP: [H3QKG-WH8ZV] Removed nhg 179687505
> ubuntu2204(config-nh-group)# exi
> ubuntu2204(config)# no nexthop-group CCC
> [..]
> 2023/12/05 08:59:27 SHARP: [N030J-V0SFN] Failed removal of nhg 179687505

The NHG_DEL message is sent twice at the nexthop deletion, and at the
nexthop-group deletion. Avoid sending it twice.

Fixes: 82beaf6ae5 ("sharpd: fix deleting nhid when suppressing nexthop from nh group")

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-12-05 10:06:12 +01:00
Philippe Guibert 82c1d82d77 sharpd: fix deleting nhid when suppressing nexthop from nh group
When no nexthops are in a nexthop group, two successive events are
sent: NHG_DEL and NHG_ADD, but only the NHG_DEL one is necessary.
Fixes this by returning in the nhg_add() function.

Fixes: 82beaf6ae5 ("sharpd: fix deleting nhid when suppressing nexthop from nh group")

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-12-05 08:20:24 +01:00
Philippe Guibert 82beaf6ae5 sharpd: fix deleting nhid when suppressing nexthop from nh group
When removing the last nexthop from a nexthop-group, the nexthop
group remains in the zebra contexts:

> ubuntu2204(config)# nexthop-group gdgd
> 2023/11/23 14:06:36 SHARP: [Q5NBA-GN1BG] NHG ID assigned: 179687502
> ubuntu2204(config-nh-group)# nexthop 192.0.2.7 loop1
> ubuntu2204(config-nh-group)# 2023/11/23 14:06:38 ZEBRA: [VNMVB-91G3G] _netlink_nexthop_build_group: ID (179687502): group 338
> 2023/11/23 14:06:38 ZEBRA: [R43C6-KYHWT] netlink_nexthop_msg_encode: RTM_NEWNEXTHOP, id=179687502
> 2023/11/23 14:06:38 ZEBRA: [HYEHE-CQZ9G] nl_batch_send: netlink-dp (NS 0), batch size=44, msg cnt=1
> 2023/11/23 14:06:38 SHARP: [JWRCN-N9K90] Installed nhg 179687502
>
> ubuntu2204(config-nh-group)# no nexthop 192.0.2.7 loop1
> 2023/11/23 14:06:47 SHARP: [Y2G2F-ZTW6M] nhg_add: nhg 179687502 not sent: no valid nexthops
> ubuntu2204(config-nh-group)# do show nexthop-group rib 179687502
> ID: 179687502 (sharp)
>      RefCnt: 1
>      Uptime: 00:00:23
>      VRF: default
>      Valid, Installed
>      Depends: (338)
>            via 192.0.2.7, loop1 (vrf default), weight 1

Fix this by sending an NHG_DEL message when no nexthops are attached,
and when the id was already installed.

Fixes: 5a9c0931aa ("sharpd: don't send invalid nexthop-groups to zebra")

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-11-30 14:17:46 +01:00
David Lamparter adf7b9efd3 sharpd: replace receive_notify with request
Send `ZEBRA_ROUTE_NOTIFY_REQUEST` rather than relying on the options
field in zclient startup.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-11-23 14:57:58 +01:00
David Lamparter 94fc9c04fc sharpd: use zclient->nexthop_update
Same as above.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-11-20 11:24:28 +01:00
Keelan10 9dd86deaa7 sharpd: Set Callback Function for Memory Cleanup
Implement a callback function for memory cleanup of sharp_nh_tracker.
Specifically, set `sharp_nh_tracker_free` as the deletion function for the `sg.nhs` list.
This ensures proper cleanup of resources when elements are removed.

The ASan leak log for reference:

```
***********************************************************************************
Address Sanitizer Error detected in zebra_nht_resolution.test_verify_nh_resolution/r1.asan.sharpd.32320

=================================================================
==32320==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 64 byte(s) in 1 object(s) allocated from:
    #0 0x7f4ee812ad28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
    #1 0x7f4ee7b291cc in qcalloc lib/memory.c:105
    #2 0x5582be672011 in sharp_nh_tracker_get sharpd/sharp_nht.c:36
    #3 0x5582be680b42 in watch_nexthop_v4_magic sharpd/sharp_vty.c:139
    #4 0x5582be680b42 in watch_nexthop_v4 sharpd/sharp_vty_clippy.c:192
    #5 0x7f4ee7aac0b1 in cmd_execute_command_real lib/command.c:978
    #6 0x7f4ee7aac575 in cmd_execute_command lib/command.c:1036
    #7 0x7f4ee7aac9f4 in cmd_execute lib/command.c:1203
    #8 0x7f4ee7bd50bb in vty_command lib/vty.c:594
    #9 0x7f4ee7bd5566 in vty_execute lib/vty.c:1357
    #10 0x7f4ee7bdde37 in vtysh_read lib/vty.c:2365
    #11 0x7f4ee7bc8dfa in event_call lib/event.c:1965
    #12 0x7f4ee7b0c3bf in frr_run lib/libfrr.c:1214
    #13 0x5582be671252 in main sharpd/sharp_main.c:188
    #14 0x7f4ee6f1bc86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)

SUMMARY: AddressSanitizer: 64 byte(s) leaked in 1 allocation(s).
***********************************************************************************
```

Signed-off-by: Keelan Cannoo <keelan.cannoo@icloud.com>
2023-11-15 11:59:02 +04:00
Donald Sharp b01738f4d3 sharpd: Clean up memory leaks on shutdown
a) The cleanup of zclient on shutdown was not being
done
b) Cleanup vrf shutdown
c) Cleanup some lists

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

sharpd: Cleanup shutdown of vrf and some lists

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-11-13 09:16:09 -05:00
David Lamparter d889055d8e lib: convert if_zapi_callbacks into actual hooks
...so that multiple functions can be subscribed.

The create/destroy hooks are renamed to real/unreal because that's what
they *actually* signal.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-11-02 17:10:43 -07:00
Donatas Abraitis 02d8b80ce4 *: Do not cast to the same type as the destination is
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-09-29 10:24:16 +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
Mark Stapp 89ff272d38 sharpd: allow sharpd to install non-recursive routes
Add a config option so that sharpd can install routes without
the ALLOW_RECURSION flag, matching IGP behavior.
The default remains 'recursion'.

Signed-off-by: Mark Stapp <mjs@labn.net>
2023-07-10 16:43:53 -04:00
Mark Stapp f6700b3491 sharpd: support opaque zapi notifications
Add cli and support to sharpd to exercise the zapi opaque
'notification' features.

Signed-off-by: Mark Stapp <mjs@labn.net>
2023-06-23 08:57:37 -04:00
Philippe Guibert 7b343a9ed5
Merge pull request #12933 from Orange-OpenSource/link_state
lib: Update edge key in link state database
2023-04-20 18:33:21 +02:00
Olivier Dugeon f2dcaf3555 sharpd: Update TE to new Link State Edge key
Following the modification of the edge key in link state database
this patch updates the sharp_vty.c file to replace the old uint64_t edge key by
the new ls_edge_key structure when searching for an edge.

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2023-04-07 16:40:26 +02:00
Donald Sharp b589466918 *: Use a struct prefix *p instead of a struct prefix in functions
When passing a prefix into a function let's pass by address instead
of pass by value.  Let's save our stack space.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-04-06 18:00:09 -04:00
Keelan10 5aa36ff77b sharpd: Fix sharpd memory leak
Free path

Signed-off-by: Keelan Cannoo <keelan.cannoo@icloud.com>
2023-04-03 17:51:48 +04:00
Olivier Dugeon b10e5cf28e sharpd: Adjust TED builder
Following correction of IS-IS subnet creation, this patch adjust the way the
TED is created in sharpd to automatically adjust subnet deletion.

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2023-03-30 18:19:32 +02: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 cd9d053741 *: Convert struct event_master to struct event_loop
Let's find a better name for it.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp 2453d15dbf *: Convert struct thread_master to struct event_master and it's ilk
Convert the `struct thread_master` to `struct event_master`
across the code base.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp 907a2395f4 *: Convert thread_add_XXX functions to event_add_XXX
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp e6685141aa *: Rename struct thread to struct event
Effectively a massive search and replace of
`struct thread` to `struct event`.  Using the
term `thread` gives people the thought that
this event system is a pthread when it is not

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
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
Stephen Worley 5b59f4a16c sharpd: clang-format style fix
clang-format style fix

Signed-off-by: Stephen Worley <sworley@nvidia.com>
2023-02-13 18:12:05 -05:00
Stephen Worley 90aaed169f lib,sharpd: add ability for sharpd to install vni labels
Add the ability for sharpd to install vni labels for testing.

This patch is just for testing/dev work purposes with evpn.
It adds some code to vty for nexthop-groups so we can explicitly
add a label to nexthops and then let sharpd encode them to zebra.

Signed-off-by: Stephen Worley <sworley@nvidia.com>
2023-02-13 18:12:05 -05:00
David Lamparter acddc0ed3c *: auto-convert to SPDX License IDs
Done with a combination of regex'ing and banging my head against a wall.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-02-09 14:09:11 +01:00
Siger Yang 04bc334e7a
sharpd: traffic control PoC
This commit adds a command to sharpd to validate the proof of concept for
traffic control on specific interface with specific filters.

Signed-off-by: Siger Yang <siger.yang@outlook.com>
2022-11-22 22:35:35 +08:00
Donald Sharp ca2b346783 *: Add ability to encode / decode resilence down zapi
At this point add abilty for the encode/decode of the
resilience down ZAPI to zebra.  Just hookup sharpd
at this point in time.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-11-04 13:34:27 -04:00
Donald Sharp f3c6dd49f4 *: Add ability for daemons to notice resilience changes
This patch just introduces the callback mechanism for the
resilient nexthop changes so that upper level daemons
can take advantage of the change.  This does nothing
at this point but just call some code.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-11-04 13:34:27 -04:00