summaryrefslogtreecommitdiff
path: root/lib/zclient.c
AgeCommit message (Collapse)Author
2025-02-11lib: guard against padding garbage in ZAPI readDavid Lamparter
When reading in a nexthop from ZAPI, only set the fields that actually have meaning. While it shouldn't happen to begin with, we can otherwise carry padding garbage into the unused leftover union bytes. Signed-off-by: David Lamparter <equinox@opensourcerouting.org> (cherry picked from commit 4a0e1419a69d07496c7adfb744beecd00e1efef2)
2024-06-12lib: fix copy srte_color from zapi_nexthop structurePhilippe Guibert
When switching from nexthop to zapi_nexthop, the srte color is copied. Do the same in reverse. Fixes: 31f937fb43f4 ("lib, zebra: Add SR-TE policy infrastructure to zebra") Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com> (cherry picked from commit 49bc1b6c21e8da0da82746373a7257aeb2c9fa4a)
2023-09-20bgpd,lib,sharpd,zebra: srv6 introduce multiple segs/SIDs in nexthopDmytro Shytyi
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-01lib,zebra: add tx queuelen to interface structMark Stapp
Add the txqlen attribute to the common interface struct. Capture the value in zebra, and distribute it through the interface lib module's zapi messaging. Signed-off-by: Mark Stapp <mjs@labn.net>
2023-08-09pbrd: add packet mangling actions (src/dst ip-addr/port, dscp, ecn)G. Paul Ziemba
Signed-off-by: G. Paul Ziemba <paulz@labn.net>
2023-08-09pbrd: use flags to indicate active fieldsG. Paul Ziemba
Before now, PBRD used non-zero values to imply that a rule's match or action field was active. This approach was getting cumbersome for fields where 0 is a valid active value and various field-specific magic values had to be used. This commit changes PBRD to use a flag bit per field to indicate that the field is active. Signed-off-by: G. Paul Ziemba <paulz@labn.net>
2023-08-08pbrd: add explicit 'family' field for rulesG. Paul Ziemba
In the netlink-mediated kernel dataplane, each rule is stored in either an IPv4-specific database or an IPv6-specific database. PBRD opportunistically gleans each rule's address family value from its source or destination IP address match value (if either exists), or from its nexthop or nexthop-group (if it exists). The 'family' value is particularly needed for netlink during incremental rule deletion when none of the above fields remain set. Before now, this address family has been encoded by occult means in the (possibly otherwise unset) source/destination IP match fields in ZAPI and zebra. This commit documents the reasons for maintaining the 'family' field in the PBRD rule structure, adds a 'family' field in the common lib/pbr.h rule structure, and carries it explicitly in ZAPI. Signed-off-by: G. Paul Ziemba <paulz@labn.net>
2023-08-03lib, zebra: Send up whether or not v6_with_v4_nexthops are supportedDonald Sharp
After Zebra knows it's capability surrounding v6 with v4 nexthops have it send this ability up to interested parties. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-07-25lib,pbrd: clean up style issuesMark Stapp
Fix a couple of style warnings introduced by recent PR 14050. Signed-off-by: Mark Stapp <mjs@labn.net>
2023-07-20lib: zapi PBR common encode/decodeG. Paul Ziemba
bgpd, pbrd: use common pbr encoder zebra: use common pbr decoder tests: pbr_topo1: check more filter fields Purpose: 1. Reduce likelihood of zapi format mismatches when adding PBR fields due to multiple parallel encoder implementations 2. Encourage common PBR structure usage among various daemons 3. Reduce coding errors via explicit per-field enable flags Signed-off-by: G. Paul Ziemba <paulz@labn.net>
2023-06-26*: Rearrange vrf_bitmap_X api to reduce memory footprintDonald Sharp
When running all daemons with config for most of them, FRR has sharpd@janelle:~/frr$ vtysh -c "show debug hashtable" | grep "VRF BIT HASH" | wc -l 3570 3570 hashes for bitmaps associated with the vrf. This is a very large number of hashes. Let's do two things: a) Reduce the created size of the actually created hashes to 2 instead of 32. b) Delay generation of the hash *until* a set operation happens. As that no hash directly implies a unset value if/when checked. This reduces the number of hashes to 61 in my setup for normal operation. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-06-23lib: add notifications for opaque zapi messagesMark Stapp
Add a new notification zapi message type. A zapi client that uses opaque messages can register to be notified when a server for an opaque type is present. Signed-off-by: Mark Stapp <mjs@labn.net>
2023-06-23lib, zebra: include source client zapi info in opaque messagesMark Stapp
Include the sending zapi client info (proto, instance, and session id) in each opaque zapi message. Add opaque 'init' apis for clients who want to encode their opaque data inline, into the zclient's internal stream buffer. Use these init apis in the TE/link-state lib code, instead of hand-coding the zapi opaque header info. Signed-off-by: Mark Stapp <mjs@labn.net>
2023-04-14lib: fix handle seg6local routes on default vrfPhilippe Guibert
An L3VPN network can be configured on the main BGP instance, with an SRv6 SID. By declaring a network, a seg6local route is created but remains invalid. The below BGP VPN configuration the default VRF has been used: > router bgp 1 > address-family ipv6 unicast > sid vpn export auto > rd vpn export 1:30 > rt vpn both 77:77 > import vpn > export vpn > network 2001:7::/64 > exit-address-family The below seg6local route has been added: > # show ipv6 route > [..] > B 2001:db8:2:2:300::/128 [20/0] is directly connected, unknown inactive, seg6local End.DT6 table 254, seg6 ::, weight 1, 00:00:07 > When creating the seg6local route, an interface is used as nexthop. The interface index is obtained from the vrf identifier. This is true when using VRF interfaces, but is wrong when using the lo interface which usually has the '1' ifindex whereas the vrf id for the default VRF is 0. Get the appropriate index from the vrf identifier. The below seg6local route is visible: > # show ipv6 route > [..] > B>* 2001:db8:1:1:300::/128 [20/0] is directly connected, lo, seg6local End.DT6 table 254, seg6 ::, weight 1, 00:00:15 > Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-03-29lib: Ensure the safi is set to a sensible valueDonald Sharp
The safi has no 0 value which it is set to as part of the initialization. Let's just set it to a sensible value. Signed-off-by: Donald Sharp <sharpd@nvidia.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*: Convert `struct event_master` to `struct event_loop`Donald Sharp
Let's find a better name for it. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Convert THREAD_XXX macros to EVENT_XXX macrosDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Convert struct thread_master to struct event_master and it's ilkDonald Sharp
Convert the `struct thread_master` to `struct event_master` across the code base. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Convert thread_add_XXX functions to event_add_XXXDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Rename `struct thread` to `struct event`Donald Sharp
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*: 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-17Merge pull request #12780 from opensourcerouting/spdx-license-idDonald Sharp
*: convert to SPDX License identifiers
2023-02-15Merge pull request #12494 from louis-6wind/ext_admin_groupOlivier Dugeon
lib,zebra,isisd: add support for extended admin group RFC7308
2023-02-13lib: add label_type as field in zapi_nexthopStephen Worley
Add the ability to specify the label type along with the labels you are passing to zebra in zapi_nexthop. This is needed as we abstract the label code to be re-used by evpn as well as mpls. Protocols need to be able to set the type of label they have attached. Signed-off-by: Stephen Worley <sworley@nvidia.com>
2023-02-10lib,yang,zebra: add extended admin-group supportLouis Scalbert
Add the support of Extended Admin-Group (RFC7308) to the zebra interface link-params Traffic-Engineering context. Extended admin-groups can be configured with the affinity-map: > affinity-map blue bit-position 221 > int eth-rt1 > link-params > affinity blue > exit-link-params Signed-off-by: Louis Scalbert <louis.scalbert@6wind.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-31lib: Add missing enum's to switch statementDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-11-22zebra: traffic control ZAPISiger Yang
This commit adds ZAPI encoders & decoders for traffic control operations, which include tc_qdisc, tc_class and tc_filter. Signed-off-by: Siger Yang <siger.yang@outlook.com>
2022-11-14Merge pull request #12219 from cscarpitta/feature/srv6-usid-behavior-supportDonatas Abraitis
bgpd, zebra: Add support for SRv6 uSID Behaviors
2022-11-04*: Add ability to encode / decode resilence down zapiDonald Sharp
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-10-29lib,zebra: Send SRv6 locator flags over the ZAPICarmine Scarpitta
In this commit, we extend the ZAPI to support encoding and decoding the locator flags contained in the messages exchanged between zebra and the routing daemons. Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2022-10-27lib: fix coverity scan failure in zebra_interface_link_params_read()Louis Scalbert
The code was working but the coverity scan reported a failure. Clarify the code to make the coverity scan happy. Fixes: fe0a129687 ("lib,zebra: link-params are not flushed after no enable") Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2022-10-17lib,zebra: link-params are not flushed after no enableLouis Scalbert
Daemons like isisd continue to use the previous link-params after they are removed from zebra. For example, >r0# sh run zebra > (...) > interface eth-rt1 > link-params > enable > metric 100 > exit-link-params > r0# conf > r0(config)# interface eth-rt1 > r0(config-if)# link-params > r0(config-link-params)# no enable After "no enable", "sh run zebra" displays no more link-params context. The "no enable" causes the release of the "link_params" pointer within the "interface" structure. The zebra function to update daemons with a ZEBRA_INTERFACE_LINK_PARAMS zapi message is called but the function returns without doing anything because the "link_params" pointer is NULL. Therefore, the "link_params" pointers are kept in daemons. When the zebra "link_params" pointer is NULL: - Send a zapi link param message that contains no link parameters instead of sending no message. - At reception in daemons, the absence of link parameters causes the release of the "link_params" pointer. Fixes: 16f1b9e ("Update Traffic Engineering Support for OSPFD") Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2022-08-24lib: Fix memory leak in `zclient_send_localsid()`Carmine Scarpitta
Running `bgp_srv6l3vpn_to_bgp_vrf` and `bgp_srv6l3vpn_to_bgp_vrf2` topotests with `--valgrind-memleaks` gives several memory leak errors. This is due to the way FRR daemons pass local SIDs to zebra: to send a local SID to zebra, FRR daemons call the `zclient_send_localsid()` function. The `zclient_send_localsid()` function performs the following sequence of operations: * create a temporary `struct nexthop`; * call `nexthop_add_srv6_seg6local()` to fill the `struct nexthop` with the proper local SID information; * create a `struct zapi_route` and call `zapi_nexthop_from_nexthop()` to copy the information from the `struct nexthop` to the `struct zapi_route`; * send the `struct zapi_route` to zebra through the ZAPI. The `nexthop_add_srv6_seg6local()` function uses `XCALLOC()` to allocate memory for the SRv6 nexthop. This memory is never freed. Creating a temporary `struct nexthop` is unnecessary, as the local SID information can be pushed directly to the `struct zapi_route`. This patch simplifies the implementation of `zclient_send_localsid()` by avoiding using the temporary `struct nexthop`. This eliminates the need to use `nexthop_add_srv6_seg6local()` to fill the `struct nexthop` and consequently fixes the memory leak. Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2022-06-10lib, zebra, bgpd: Move route EVPN flag to nexthopXiao Liang
Multipath route may have mixed nexthops of EVPN and IP unicast. Move EVPN flag to nexthop to support such cases. Signed-off-by: Xiao Liang <shaw.leon@gmail.com>
2022-05-02*: use FRR interface name definition everywhereRafael Zalamena
Don't rely on the OS interface name length definition and use the FRR definition instead. Signed-off-by: Rafael Zalamena <rzalamena@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-03-02lib: Fix zclient.c `enum event` to `enum zclient_event`Donald Sharp
zclient.c is using `enum event` let's rename it to a better named data structure `enum zclient_event`. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-23*: Change thread->func to return void instead of intDonald Sharp
The int return value is never used. Modify the code base to just return a void instead. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-12-21*: rework renaming the default VRFIgor Ryzhov
Currently, it is possible to rename the default VRF either by passing `-o` option to zebra or by creating a file in `/var/run/netns` and binding it to `/proc/self/ns/net`. In both cases, only zebra knows about the rename and other daemons learn about it only after they connect to zebra. This is a problem, because daemons may read their config before they connect to zebra. To handle this rename after the config is read, we have some special code in every single daemon, which is not very bad but not desirable in my opinion. But things are getting worse when we need to handle this in northbound layer as we have to manually rewrite the config nodes. This approach is already hacky, but still works as every daemon handles its own NB structures. But it is completely incompatible with the central management daemon architecture we are aiming for, as mgmtd doesn't even have a connection with zebra to learn from it. And it shouldn't have it, because operational state changes should never affect configuration. To solve the problem and simplify the code, I propose to expand the `-o` option to all daemons. By using the startup option, we let daemons know about the rename before they read their configs so we don't need any special code to deal with it. There's an easy way to pass the option to all daemons by using `frr_global_options` variable. Unfortunately, the second way of renaming by creating a file in `/var/run/netns` is incompatible with the new mgmtd architecture. Theoretically, we could force daemons to read their configs only after they connect to zebra, but it means adding even more code to handle a very specific use-case. And anyway this won't work for mgmtd as it doesn't have a connection with zebra. So I had to remove this option. 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-15lib: rename bfd function to reflect real functionalityIgor Ryzhov
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-10-26Merge pull request #9854 from opensourcerouting/zapi-call-tableRuss White
*: convert zclient callbacks to table
2021-10-25lib: fix srv6 route hardcode with BGPHiroki Shirokura
zclient_send_localsid is called by various routing protocol daemons. To set the srv6 endpoint function. Fix a hard-coded error in the initial implementation. Before this PR, the srv6 function will be registered to zebra as a BGP route even if isisd executes zclient_send_localsid. Signed-off-by: Hiroki Shirokura <hiroki.shirokura@linecorp.com>
2021-10-22lib: finish fixing spelling in lib filesewlumpkin
Signed-off-by: ewlumpkin <ewlumpkin@gmail.com>
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-10-19lib: allow to create interfaces in non-existing VRFsIgor Ryzhov
It allows FRR to read the interface config even when the necessary VRFs are not yet created and interfaces are in "wrong" VRFs. Currently, such config is rejected. For VRF-lite backend, we don't care at all about the VRF of the inactive interface. When the interface is created in the OS and becomes active, we always use its actual VRF instead of the configured one. So there's no need to reject the config. For netns backend, we may have multiple interfaces with the same name in different VRFs. So we care about the VRF of inactive interfaces. And we must allow to preconfigure the interface in a VRF even before it is moved to the corresponding netns. From now on, we allow to create multiple configs for the same interface name in different VRFs and the necessary config is applied once the OS interface is moved to the corresponding netns. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-09-27lib, zebra: Send safi for rnh resolutionDonald Sharp
Pass down the safi for when we need address resolution. At this point in time we are hard coding the safi to SAFI_UNICAST. Future commits will take advantage of this. Signed-off-by: Donald Sharp <sharpd@nvidia.com>