summaryrefslogtreecommitdiff
path: root/staticd/static_zebra.c
AgeCommit message (Collapse)Author
2024-07-15zebra: fix missing static routesanlan_cs
Use `vtysh` with this input file: ``` ip route A nh1 ip route A nh2 ip route B nh1 ip route B nh2 ``` When running "ip route B" with "nh1" and "nh2", the procedure maybe is: 1) Create the two nexthops: "nh1" and "nh2". 2) Register "nh1" with `static_zebra_nht_register()`, then the states of both "nh1" and "nht2" are set to "STATIC_SENT_TO_ZEBRA". 3) Register "nh2" with `static_zebra_nht_register()`, then only the routes with nexthop of "STATIC_START" will be sent to zebra. So, send the routes with the nexthop of "STATIC_SENT_TO_ZEBRA" to zebra. Signed-off-by: anlan_cs <vic.lan@pica8.com> (cherry picked from commit 4518d386f7683289b079708fcdb0c42ced4754d9)
2024-02-08Merge pull request #15285 from idryzhov/staticd-nexthop-refcounterDonald Sharp
staticd: fix nexthop tracking memory leak and add a topotest for VRFs
2024-02-04staticd: coverity fixesIgor Ryzhov
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-02-04staticd: don't send routes from disabled vrfs to zebraIgor Ryzhov
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-02-02staticd: fix NB dependency hackIgor Ryzhov
Currently, staticd configuration is tightly coupled with VRF existence. Because of that, it has to use a hack in NB infrastructure to create a VRF configuration when at least one static route is configured for this VRF. This hack is incompatible with mgmtd, because mgmtd doesn't execute configuration callbacks. Because of that, the configuration may become out of sync between mgmtd and staticd. There are two main cases: 1. Create static route in a VRF. The VRF data node will be created automatically in staticd by the NB hack, but not in mgmtd. 2. Delete VRF which has some static routes configured. The static route configuration will be deleted from staticd by the NB hack, but not from mgmtd. To fix the problem, decouple configuration of static routes from VRF configuration. Now it is possible to configure static routes even if the VRF doesn't exist yet. Once the VRF is created, staticd applies all the preconfigured routes. This change also fixes the problem with static routes being preserved in the system when staticd "control-plane-protocol" container is deleted but the VRF is still configured. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-11-23staticd: replace `receive_notify` with requestDavid Lamparter
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-20staticd: use `zclient->nexthop_update`David Lamparter
Same as before. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-11-02lib: convert if_zapi_callbacks into actual hooksDavid Lamparter
...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-09-20staticd: zebra, modify nexthop to support multiple srv6 segs SIDsDmytro Shytyi
Adapt the nexthop from 1 to multiple srv6 seg SIDs Signed-off-by: Dmytro Shytyi <dmytro.shytyi@6wind.com>
2023-03-24*: Convert event.h to frrevent.hDonald Sharp
We should probably prevent any type of namespace collision with something else. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Rename thread.[ch] to event.[ch]Donald Sharp
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-02-09*: auto-convert to SPDX License IDsDavid Lamparter
Done with a combination of regex'ing and banging my head against a wall. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-01-24lib: remove concurrent nexthop zapi (un)registrationLouis Scalbert
Daemons like staticd already implement nexthop zapi (un)registration. b7ca809d1c ("lib: BFD automatic source selection") has implemented a concurrent nexthop (un)registration. Some nexthop could be unregistred by the bfd whereas they were still needed by the daemon. Let the deamons deal with nexthop zapi (un)registration. Fixes: b7ca809d1c ("lib: BFD automatic source selection") Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2023-01-24lib: do not reopen a zclient socket for bfdLouis Scalbert
b7ca809d1c ("lib: BFD automatic source selection") has added a dedicated zclient socket for nht tracking. Since the bfd lib is used by daemons that already has a zclient socket, those daemons has now a second zclient socket. However, zebra does not distinguish the two zclient sessions. For example, the interfaces are asked a second via zebra_message_send(zclient, ZEBRA_INTERFACE_ADD, VRF_DEFAULT) in zclient_start(). As a result, callbacks functions like bgp_ifp_create() are called a second time, which causes some processing overhead and might cause bugs. Re-use the existing zclient socket for nht tracking. Note that BFD automatic source selection is only currently implemented in staticd. Other daemons will require to add the following in their ZEBRA_NEXTHOP_UPDATE callback function: > if (zclient->bfd_integration) > bfd_nht_update(&matched, &nhr); Fixes: b7ca809d1c ("lib: BFD automatic source selection") Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2023-01-13staticd: BFD integration northbound supportRafael Zalamena
Implement all BFD integration northbound callbacks and integrate BFD with `staticd` route installation procedure. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2022-12-16lib, staticd: return values even after an assertDonald Sharp
When compiling with -fsanitize=thread. I started getting this error: staticd/static_zebra.c: In function ‘static_zebra_nht_get_prefix’: staticd/static_zebra.c:316:1: error: control reaches end of non-void function [-Werror=return-type] 316 | } | ^ Just to make future efforts still work, let's just make the compiler happy. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-04-24staticd: redo VRF_DEFAULT NHT registers on connectDavid Lamparter
Other VRFs get VRF_ADD notifications from zebra which triggers static_fixup_vrf_ids, but since the default VRF is implicit we need to make that same call on connect. This should fix problems with staticd being started before (or concurrent with and thus racing) zebra. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-04-24staticd: merge NHT register & update, reorganizeDavid Lamparter
nh_update is only called in two places and both precede a matching follow-up nht_register call. Fold the update into register, and make register do the right thing™ for all cases (i.e. update refcounts as needed, and retry zebra NHT registration if it failed before). Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-04-24staticd: use double pointer for NHT decrefDavid Lamparter
Since this is a free()-type function, clear the caller's pointer to NULL to aid static analysis and prevent UAF bugs. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-04-24staticd: minor refactor NHT register codeDavid Lamparter
Put static_nexthop -> prefix code into a small helper, remove extra prefix variable, and grab AFI from prefix. This commit should not result in any functional change. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-04-02*: Fix spelling of IntefaceDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-03-27staticd: track nexthops per-SAFIDavid Lamparter
This stops intermixing SAFI_UNICAST NHT into SAFI_MULTICAST static routes. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-03-27staticd: use inline prefix in NHT dataDavid Lamparter
No need to waste malloc overhead on this. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-03-27staticd: use typesafe static_nht_hashDavid Lamparter
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-03-27*: add SAFI argument to zclient_send_rnhDavid Lamparter
Just pushing that SAFI_UNICAST up 1 level to the caller. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-03-12*: When matching against a nexthop send and process what it matched againstDonald Sharp
Currently the nexthop tracking code is only sending to the requestor what it was requested to match against. When the nexthop tracking code was simplified to not need an import check and a nexthop check in b8210849b8ac1abe2d5d9a5ab2459abfde65efa5 for bgpd. It was not noticed that a longer prefix could match but it would be seen as a match because FRR was not sending up both the resolved route prefix and the route FRR was asked to match against. This code change causes the nexthop tracking code to pass back up the matched requested route (so that the calling protocol can figure out which one it is being told about ) as well as the actual prefix that was matched to. Fixes: #10766 Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-28Merge pull request #10678 from donaldsharp/staticd_make_check_fixJafar Al-Gharaibeh
staticd: Fix `make check` failures
2022-02-28staticd: Fix `make check` failuresDonald Sharp
Recent commit: abc246e19345cbd2bc74c7dc50dac0b9cf2addf8 Has broken `make check` with recently new compilers: /usr/bin/ld: staticd/libstatic.a(static_nb_config.o): warning: relocation against `zebra_ecmp_count' in read-only section `.text' CCLD tests/bgpd/test_peer_attr CCLD tests/bgpd/test_packet /usr/bin/ld: staticd/libstatic.a(static_zebra.o): in function `static_zebra_capabilities': /home/sharpd/frr5/staticd/static_zebra.c:208: undefined reference to `zebra_ecmp_count' /usr/bin/ld: staticd/libstatic.a(static_zebra.o): in function `static_zebra_route_add': /home/sharpd/frr5/staticd/static_zebra.c:418: undefined reference to `zebra_ecmp_count' /usr/bin/ld: staticd/libstatic.a(static_nb_config.o): in function `static_nexthop_create': /home/sharpd/frr5/staticd/static_nb_config.c:174: undefined reference to `zebra_ecmp_count' /usr/bin/ld: /home/sharpd/frr5/staticd/static_nb_config.c:175: undefined reference to `zebra_ecmp_count' /usr/bin/ld: warning: creating DT_TEXTREL in a PIE collect2: error: ld returned 1 exit status make: *** [Makefile:8679: tests/lib/test_grpc] Error 1 make: *** Waiting for unfinished jobs.... Essentially the newly introduced variable zebra_ecmp_count is not available in the libstatic.a compiled and make check has code that compiles against it. The fix is to just move the variable to the library. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-28staticd: Don't register existing nexthop to zebraXiao Liang
Zebra sends a nexthop-update message on registeration, which will cause existing routes to be reconfigured even no changes actually happened. Don't register the nexthop again if it's already done. Signed-off-by: Xiao Liang <shaw.leon@gmail.com>
2022-02-17staticd: reject route config with too many nexthopsMark Stapp
Restrict the number of nexthops for a route to the compiled-in limit. Be careful with the zapi route struct's array of nexthops too. Signed-off-by: Mark Stapp <mstapp@nvidia.com>
2022-02-17staticd: capture zebra's advertised ECMP limitMark Stapp
Capture the ECMP limit advertised by zebra (via zapi). Signed-off-by: Mark Stapp <mstapp@nvidia.com>
2021-11-23staticd: remove unnecessary function callIgor Ryzhov
When the VRF interface is coming up, we don't need to fixup VRF ids - it was already done in static_vrf_enable when the interface was created. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-11-22*: cleanup ifp->vrf_idIgor Ryzhov
Since f60a1188 we store a pointer to the VRF in the interface structure. There's no need anymore to store a separate vrf_id field. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-11-17*: clean up ifp-by-local-address function(s)David Lamparter
Most users of if_lookup_address_exact only cared about whether the address is any local address. Split that off into a separate function. For the users that actually need the ifp - which I'm about to add a few of - change it to prefer returning interfaces that are UP. (Function name changed due to slight change in behavior re. UP state, to avoid possible bugs from this change.) Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-10-20*: convert zclient callbacks to tableDavid Lamparter
This removes a giant `switch { }` block from lib/zclient.c and harmonizes all zclient callback function types to be the same (some had a subset of the args, some had a void return, now they all have ZAPI_CALLBACK_ARGS and int return.) Apart from getting rid of the giant switch, this is a minor security benefit since the function pointers are now in a `const` array, so they can't be overwritten by e.g. heap overflows for code execution anymore. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-09-27*: Add resolve via default flagDonald Sharp
2021-07-09staticd: simplify the northbound codeIgor Ryzhov
Add a couple of back pointers to static route/path/nexthop structures to simplify the NB code and save ~200 lines. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-06-06tests: add grpc unit testChristian Hopps
Test uses staticd which required some C++ header protections. Additionally, the test also runs in the ubuntu20 docker container as grpc is supported there by the packaging system. Signed-off-by: Christian Hopps <chopps@labn.net>
2020-11-15*: Convert all usage of zclient_send_message to new enumDonald Sharp
The `enum zclient_send_status` enum needs to be extended throughout the code base to use the new states and to fix up places where we tested against the return value being non zero. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-11-06bgpd: Advertise FIB installed routes to bgp peers (Part 1)Soman K S
Issue: The bgp routes learnt from peers which are not installed in kernel are advertised to peers. This can cause routers to send traffic to these destinations only to get dropped. The fix is to provide a configurable option "bgp suppress-fib-pending". When the option is enabled, bgp will advertise routes only if it these are successfully installed in kernel. Fix (Part1) : * Added message ZEBRA_ROUTE_NOTIFY_REQUEST used by client to request FIB install status for routes * Added AFI/SAFI to ZAPI messages * Modified the functions zapi_route_notify_decode(), zsend_route_notify_owner() and route_notify_internal() to include AFI, SAFI as parameters Signed-off-by: kssoman <somanks@gmail.com>
2020-10-22:* Convert prefix2str to %pFXDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-10-02Merge pull request #6882 from vishaldhingra/staticDonald Sharp
staticd : Added the warning log for route when VRF is not ready.
2020-09-30*: make failure to decode nht update an errorQuentin Young
This should never happen; no need to debug guard it and it's not a warning, if this isn't working then NHT is not working at all. Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-08-31staticd : Added the warning log for route when VRF is not ready.vdhingra
During the yangification of staticd, refactoring of code around static_hold_route data struct has been done, In this context warning log message when VRF is not ready had been removed. This should not be removed, adding it back. I have missed one MPLS validation too, adding it back. Signed-off-by: vishaldhingra <vdhingra@vmware.com>
2020-08-12staticd: add support for SR PoliciesSebastien Merle
Configuration example: ip route 9.9.9.9/32 6.6.6.6 color 123 The SR Policy to be chosen is uniquely identified by the policy endpoint (6.6.6.6) and the SR-TE color (123). Traffic will be augmented with an MPLS label stack according to the active candidate path of that particular policy. Co-authored-by: GalaxyGorilla <sascha@netdef.org> Signed-off-by: Sebastien Merle <sebastien@netdef.org>
2020-07-16staticd : Configuration northbound implementationvdhingra
1. Modifies the data structs to make the distance, tag and table-id property of a route, i.e created a hireachical data struct to save route and nexthop information. 2. Backend northbound implementation Signed-off-by: VishalDhingra <vdhingra@vmware.com>
2020-07-07staticd,zebra: use ALLOW_RECURSION for static routesMark Stapp
Remove a special-case clause for static routes - it was the same as the clause for other recursive routes. Have staticd just tell zebra that recursion is allowed. Update topotest that was aware of this 'internal' flag. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-03-05*: Replace __PRETTY_FUNCTION__/__FUNCTION__ to __func__Donatas Abraitis
Just keep the code cool. Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2019-12-06*: revise zapi nexthop encodingMark Stapp
Use a per-nexthop flag to indicate the presence of labels; add some utility zapi encode/decode apis for nexthops; use the zapi apis more consistently. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-11-02*: Convert connected_free to a double pointerDonald Sharp
Set the connected pointer to set the pointer to NULL. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>