summaryrefslogtreecommitdiff
path: root/zebra/kernel_netlink.h
AgeCommit message (Collapse)Author
2022-05-16zebra: new netlink parse utility for rtaChirag Shah
Signed-off-by: Chirag Shah <chirag@nvidia.com>
2022-02-08zebra: Make netlink buffer reads resizeable when neededDonald Sharp
Currently when the kernel sends netlink messages to FRR the buffers to receive this data is of fixed length. The kernel, with certain configurations, will send netlink messages that are larger than this fixed length. This leads to situations where, on startup, zebra gets really confused about the state of the kernel. Effectively the current algorithm is this: read up to buffer in size while (data to parse) get netlink message header, look at size parse if you can The problem is that there is a 32k buffer we read. We get the first message that is say 1k in size, subtract that 1k to 31k left to parse. We then get the next header and notice that the length of the message is 33k. Which is obviously larger than what we read in. FRR has no recover mechanism nor is there a way to know, a priori, what the maximum size the kernel will send us. Modify FRR to look at the kernel message and see if the buffer is large enough, if not, make it large enough to read in the message. This code has to be per netlink socket because of the usage of pthreads. So add to `struct nlsock` the buffer and current buffer length. Growing it as necessary. Fixes: #10404 Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-08zebra: Remove `struct nlsock` from dataplane information and use `int fd`Donald Sharp
Store the fd that corresponds to the appropriate `struct nlsock` and pass that around in the dplane context instead of the pointer to the nlsock. Modify the kernel_netlink.c code to store in a hash the `struct nlsock` with the socket fd as the key. Why do this? The dataplane context is used to pass around the `struct nlsock` but the zebra code has a bug where the received buffer for kernel netlink messages from the kernel is not big enough. So we need to dynamically grow the receive buffer per socket, instead of having a non-dynamic buffer that we read into. By passing around the fd we can look up the `struct nlsock` that will soon have the associated buffer and not have to worry about `const` issues that will arise. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-10-25include, zebra: Add recent nexthop.hDonald Sharp
Add actual recent nexthop.h file from kernel and fix up resulting fallout because FRR's original nexthop.h did not match upstream linux kernel. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-10-04zebra: Use a bool for startup indicationsDonald Sharp
Let's not pass around an int startup when all we are doing is true/falsing it. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-07-08zebra: Add nl_attr_put8 so we can put uint8_t in netlink messagesDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-12-11zebra: move from NDA_NOTIFY to NDA_FDB_EXT_ATTRSNikolay Aleksandrov
Use the new nested NDA_FDB_EXT_ATTRS attribute to control per-fdb notifications. PS: The attributes where updated as a part of the kernel upstreaming hence the change. Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com> Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-08-25zebra: remove fuzzing stuffJakub Urbańczyk
The fuzzing code that is in the master branch is outdated and unused, so it is worth to remove it to improve readablity of the code. All the code related to the fuzzing is in the `fuzz` branch. Signed-off-by: Jakub Urbańczyk <xthaid@gmail.com>
2020-08-10tests: zebra netlink testcasesJakub Urbańczyk
Signed-off-by: Jakub Urbańczyk <xthaid@gmail.com>
2020-08-10zebra: design changes in netlink batching codeJakub Urbańczyk
Signed-off-by: Jakub Urbańczyk <xthaid@gmail.com>
2020-08-10zebra: netlink message batchingJakub Urbańczyk
Integrate existing functions with batching infrastructure. Signed-off-by: Jakub Urbańczyk <xthaid@gmail.com>
2020-08-10zebra: add netlink message batching infrastructureJakub Urbańczyk
Add helpers to batch several messages into one single netlink datagram. Signed-off-by: Jakub Urbańczyk <xthaid@gmail.com>
2020-06-13zebra: clean up netlink apiJakub Urbańczyk
* Rename netlink utility functions like addattr to be less ambiguous * Replace rta_attr_* functions with nl_attr_* since they introduced inconsistencies in the code * Add helper functions for adding rtnexthop struct to the Netlink message Signed-off-by: Jakub Urbańczyk <xthaid@gmail.com>
2020-04-15zebra: Modify netlink_request to statisfy coverityDonald Sharp
The netlink_request function takes a `struct nlmsghdr *` pointer from a common pattern that we use: struct { struct nlmsghdr n; struct fib_rule_hdr frh; char buf[NL_PKT_BUF_SIZE]; } req; We were calling it `netlink_request(Socket, &req.n)` The problem here is that coverity, rightly so, sees that we access the data after the nlmsghdr in netlink_request and tells us we have an read beyond end of the structure. While we know we haven't mangled anything up here because of manual inspection coverity doesn't have this knowledge implicitly. So let's modify the code call to netlink_request to pass in the void pointer of the req structure itself, cast to the appropriate data structure in the function and do the right thing. Hopefully the coverity SA will be happy and we can move on with our life. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-03-25add cplusplus guards to all zebra headersEmanuele Di Pascale
Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
2018-10-25zebra: rebase dataplane, align with masterMark Stapp
Rebase and pick up dataplane changes on master, including renamed structs and enums. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2018-10-25zebra: start dataplane layer workMark Stapp
Reduce or eliminate use of global zebra_ns structs in a couple of netlink/kernel code paths, so that those paths can potentially be made asynch eventually. Slide netlink_talk_info into place to remove dependency on core zebra structs; add accessors for dplane context block Start init of route context from zebra core re and rn structs; start queueing and event handling for incoming route updates. Expose netlink apis that don't rely on zebra core structs; add parallel route-update code path using the dplane ctx; simplest possible event loop to process queued route' updates. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2018-09-19zebra: Start abstraction of zebra_dplane_info for context passingMark Stapp
Reduce or eliminate use of global zebra_ns structs in a couple of netlink/kernel code paths, so that those paths can potentially be made asynch eventually. Signed-off-by: Mark Stapp <mjs@voltanet.io> Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-08-25zebra: Add support for static encap mpls labelsStephen Worley
We were ignoring mpls labels encapped with static routes. Added support for single and multipath labels. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com> Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-07-24Refactor code for new fuzzing netlink flagStephen Worley
Changed the configure flag used by netlink fuzzing and refactored code accordingly. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2018-07-21zebra: Add code for fuzzing netlinkStephen Worley
This code allows you to fuzz the netlink listening socket in zebra by --enable-fuzzing and passing the -w [FILE] option when running zebra. File collection is stored in /var/run/frr/netlink_* where each number is just a counter to keep the files distinct. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2018-07-11zebra, libs: use const prefix ptrs in apisMark Stapp
Add 'const' to prefix args to several zebra route update, redistribution, and route owner notification apis. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2018-05-24zebra: Remove unnecessary function parameterDonald Sharp
The snl variable is no longer needed to be passed around, so remove it from the calling path. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-05-08zebra: Increase recvmsg buffer size for picking up netlink messagesvivek
Netlink messages from the kernel need to be received in a buffer larger than 8K in order to handle some types of info - for example, the VLAN information. Define a separate size for receive and set it to 32K, which is the value used by other netlink receivers like iproute2. Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com> Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-27*: use C99 standard fixed-width integer typesQuentin Young
The following types are nonstandard: - u_char - u_short - u_int - u_long - u_int8_t - u_int16_t - u_int32_t Replace them with the C99 standard types: - uint8_t - unsigned short - unsigned int - unsigned long - uint8_t - uint16_t - uint32_t Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-07-17*: reindentreindent-master-afterwhitespace / reindent
indent.py `git ls-files | pcregrep '\.[ch]$' | pcregrep -v '^(ldpd|babeld|nhrpd)/'` Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-05-25zebra: Format netlink requests correctlyvivek
When zebra issues read (GET) requests to the kernel using the netlink interface, it is incorrect to format all of them in a generic manner using 'struct ifinfomsg' or 'struct rtgenmsg'. Rather, messages for a particular entity (e.g., routes) should use the corresponding structure for encoding (e.g., 'struct rtmsg'). Of course, this has to correlate with what the kernel expects. In the absence of this, there is the possibility of sending extraneous information in the request which the kernel wouldn't like. Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com> Reviewed-by: David Ahern <dsa@cumulusnetworks.com>
2017-05-25zebra: New API for filling netlink attributevivek
Define addattr16(). Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2017-05-15*: make consistent & update GPLv2 file headersDavid Lamparter
The FSF's address changed, and we had a mixture of comment styles for the GPL file header. (The style with * at the beginning won out with 580 to 141 in existing files.) Note: I've intentionally left intact other "variations" of the copyright header, e.g. whether it says "Zebra", "Quagga", "FRR", or nothing. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-03-01zebra: Add knowledge of whether or not we are acting under startup conditionsDonald Sharp
The reading if unicast routes from the kernel acts subtly differently between reading in the routes from the kernel on startup and reading a new route or getting a response for a route. Add startup flag(currently ignored) so that we can start consolidating the functionality. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-01-17zebra: Fully decode mcast messagesDonald Sharp
Fully decode mcast messages from the kernel. We are not doing anything with this at the moment, but that will change. Additionally convert over to using lookup for displaying the route type. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-01-17zebra: Allow netlink_talk to choose the filter function to callDonald Sharp
The netlink_talk call sends a message to the kernel, which with netlink_talk_filter only waits for the ACK. It would be nice to have the ability to specify what the handler function would be for when we send queries about mcast S,G routes so that we can gather the data returned from the kernel. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-10-18zebra: use unsigned args for *addattrDavid Lamparter
[based on a patch by Paul Jakma changing it to size_t] Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-10-17zebra: Refactor netlink interactionsvivek
Separate core netlink functions and library functions from route-related interactions and interface-related interactions. Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com> Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com> Reviewed-by: Don Slice <dslice@cumulusnetworks.com> Ticket: CM-13199 Reviewed By: CCR-5254 Testing Done: bgp-min, ospf-min