summaryrefslogtreecommitdiff
path: root/zebra/kernel_netlink.c
AgeCommit message (Collapse)Author
2021-01-26zebra: debug messages go under conditionalsMark Stapp
Move a couple of unprotected debug calls in the netlink code under DEBUG_KERNEL. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2021-01-19Merge pull request #7723 from AnuradhaKaruppiah/fdb-ext-attrsPatrick Ruddy
zebra: move from NDA_NOTIFY to NDA_FDB_EXT_ATTRS
2020-12-14Merge pull request #7162 from opensourcerouting/zebra-human-netlinkStephen Worley
zebra: human readable netlink dumps
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-10-26zebra: dplane APIs for programming evpn-mh access port attributesAnuradha Karuppiah
This includes - 1. non-DF block filter 2. List of es-peers that need to be blocked per-access port (for split horizon filtering) 3. Backup nexthop group to failover local-es via the VxLAN overlay Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-10-23Merge pull request #7382 from sworleys/Fix-Msg-BuffMark Stapp
zebra: fix unitialized msg header reading at startup
2020-10-23zebra: fix unitialized msg header reading at startupStephen Worley
Fixes the valgrind error we were seeing on startup due to initializing the msg header struct: ``` ==2534283== Thread 3 zebra_dplane: ==2534283== Syscall param recvmsg(msg) points to uninitialised byte(s) ==2534283== at 0x4D616DD: recvmsg (in /usr/lib64/libpthread-2.31.so) ==2534283== by 0x43107C: netlink_recv_msg (kernel_netlink.c:744) ==2534283== by 0x4330E4: nl_batch_read_resp (kernel_netlink.c:1070) ==2534283== by 0x431D12: nl_batch_send (kernel_netlink.c:1201) ==2534283== by 0x431E8B: kernel_update_multi (kernel_netlink.c:1369) ==2534283== by 0x46019B: kernel_dplane_process_func (zebra_dplane.c:3979) ==2534283== by 0x45EB7F: dplane_thread_loop (zebra_dplane.c:4368) ==2534283== by 0x493F5CC: thread_call (thread.c:1585) ==2534283== by 0x48D3450: fpt_run (frr_pthread.c:303) ==2534283== by 0x48D3D41: frr_pthread_inner (frr_pthread.c:156) ==2534283== by 0x4D56431: start_thread (in /usr/lib64/libpthread-2.31.so) ==2534283== by 0x4E709D2: clone (in /usr/lib64/libc-2.31.so) ==2534283== Address 0x85cd850 is on thread 3's stack ==2534283== in frame #2, created by nl_batch_read_resp (kernel_netlink.c:1051) ==2534283== ==2534283== Syscall param recvmsg(msg.msg_control) points to unaddressable byte(s) ==2534283== at 0x4D616DD: recvmsg (in /usr/lib64/libpthread-2.31.so) ==2534283== by 0x43107C: netlink_recv_msg (kernel_netlink.c:744) ==2534283== by 0x4330E4: nl_batch_read_resp (kernel_netlink.c:1070) ==2534283== by 0x431D12: nl_batch_send (kernel_netlink.c:1201) ==2534283== by 0x431E8B: kernel_update_multi (kernel_netlink.c:1369) ==2534283== by 0x46019B: kernel_dplane_process_func (zebra_dplane.c:3979) ==2534283== by 0x45EB7F: dplane_thread_loop (zebra_dplane.c:4368) ==2534283== by 0x493F5CC: thread_call (thread.c:1585) ==2534283== by 0x48D3450: fpt_run (frr_pthread.c:303) ==2534283== by 0x48D3D41: frr_pthread_inner (frr_pthread.c:156) ==2534283== by 0x4D56431: start_thread (in /usr/lib64/libpthread-2.31.so) ==2534283== by 0x4E709D2: clone (in /usr/lib64/libc-2.31.so) ==2534283== Address 0xa0 is not stack'd, malloc'd or (recently) free'd ==2534283== ``` Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-10-23*: unify thread/event cancel macrosMark Stapp
Replace all lib/thread cancel macros, use thread_cancel() everywhere. Only the THREAD_OFF macro and thread_cancel() api are supported. Also adjust thread_cancel_async() to NULL caller's pointer (if present). Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-09-24zebra: Don't ignore setsockopt returnDonald Sharp
When attempting to limit the amount of data sent from the kernel to FRR, some kernels we can run against may not have this ability in which case the setsockopt will fail. Notice that in the log. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-09-23zebra: human readable netlink dumpsRafael Zalamena
Add new compile option to enable human readable netlink dumps with `debug zebra kernel msgdump`. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-09-01zebra: increase netlink receive buffer sizeJakub Urbańczyk
Signed-off-by: Jakub Urbańczyk <xthaid@gmail.com>
2020-08-28Merge pull request #7017 from xThaid/netlink_fixMark Stapp
zebra: fix netlink batching
2020-08-27zebra: fix netlink batchingJakub Urbańczyk
It was wrongly assumed that the kernel is replying in batches when multiple requests fail. The kernel sends one error message at a time, so we can simply keep reading data from the socket as long as possible. Signed-off-by: Jakub Urbańczyk <xthaid@gmail.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-12lib, zebra: add support for sending ARP requestsJakub Urbańczyk
We can make the Linux kernel send an ARP/NDP request by adding a neighbour with the 'NUD_INCOMPLETE' state and the 'NTF_USE' flag. This commit adds new dataplane operation as well as new zapi message to allow other daemons send ARP/NDP requests. 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: remove old kernel one-update-at-a-time apiJakub Urbańczyk
The old one is replaced by the api that is suitable for the batching. 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-08-10zebra: prepare dplane for batchingJakub Urbańczyk
Extend kernel interface to allow the data plane to send many kernel updates at once. Signed-off-by: Jakub Urbańczyk <xthaid@gmail.com>
2020-07-13zebra: cosmetic changes in the netlink codeJakub Urbańczyk
Signed-off-by: Jakub Urbańczyk <xthaid@gmail.com>
2020-07-08zebra: netlink cleanupJakub Urbańczyk
* Split zebra's netlink code into smaller functions to be more generic. 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>
2020-03-08*: Replace `sizeof something` to sizeof(something)Donatas Abraitis
Satisfy checkpatch.pl requirements (check for sizeof without parenthesis) Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
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>
2020-01-10zebra: Actually add the NLA_F_NESTED flag to our codeDonald Sharp
The existing usage of the rta_nest and addattr_nest functions were not adding the NLA_F_NESTED flag to the type. As such the new nexthop functionality was actually looking for this flag, while apparently older code did not. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-01-07Merge pull request #5628 from donaldsharp/rtm_getneighRuss White
zebra: Ignore RTM_GETNEIGH messages from the linux kernel
2020-01-04zebra: fix undefined bitshifts in netlink stuffQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-01-04zebra: Ignore RTM_GETNEIGH messages from the linux kernelDonald Sharp
The linux kernel will occassionally send RTM_GETNEIGH when it expects user space to help in resolution of an ARP entry. See linux kernel commit: commit 3e25c65ed085b361cc91a8f02e028f1158c9f255 Author: Tim Gardner <tim.gardner@canonical.com> Date: Thu Aug 29 06:38:47 2013 -0600 net: neighbour: Remove CONFIG_ARPD Since we don't care about this, let's just safely ignore this message for the moment. I imagine in the future we might care when we implement neighbor managment in the system. Reported By: Stefan Priebe <s.priebe@profihost.ag> Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-10-25zebra: Don't error on nexthop object support checkStephen Worley
On startup when we are requesting all nexthop objects from the kernel and it doesn't support that, we should not produce an error message. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25zebra: Add functionality to parse RTM_NEWNEXTHOP and RTM_DELNEXTHOP messagesStephen Worley
Add the functionality to parse new nexthop group messages from the kernel and insert them into the appropriate hash tables. Parsing is done at startup between interface and interface address lookup. Add functionality to parse changes to nexthops we already have. Add functionality to parse delete nexthop messages from the kernel and remove them from our table. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25zebra: Add base functionality for nexthop messages in kernel_netlinkStephen Worley
Add some base functionality so we can verify we are getting messages about nexthops from the kernel. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25zebra: Add RTNLGRP_NEXTHOP group to the kernel socketStephen Worley
Initialize the netlink socket with the RTNLGRP_NEXTHOP group as well to listen for. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-09-03*: frr_elevate_privs -> frr_with_privsDavid Lamparter
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2019-06-18Merge pull request #4546 from donaldsharp/better_debugsRuss White
zebra: Increase debugs to understand why we rejected a kernel route
2019-06-18zebra: Increase debugs to understand why we rejected a kernel routeDonald Sharp
Add a bit of extra code to indicate to the operator why we intentionally rejected a kernel route from being used. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-06-15zebra: Fuzzing code has gotten a bit out of dateDonald Sharp
Update the fuzzing code to compile again. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-06-04*: Convert to using frr_vtydir instead of DAEMON_VTY_DIRDonald Sharp
In a variety of places we are using DAEMON_VTY_DIR, convert to use frr_vtydir. This will allow us in a future commit to have the -N namespace option be automatically used. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-03-26zebra: Fix extended ack error message parsingStephen Worley
Fix the macros for reading NLA attribute info from an extended error ack. We were processing the data using route attributes (rtattr) which is identical in size to nlattr but probably should not be used. Further, we were incorrectly calculating the length of the inner netlink message that cause the error. We have to read passed that in order to access all the nlattr's. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-03-14*: remove trailing newlines from zlog messagesQuentin Young
Zlog puts its own newlines on, and doing this makes logs look nasty. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-01-31zebra: Move the master thread handler to the zrouter structureDonald Sharp
The master thread handler is really part of the zrouter structure. So let's move it over to that. Eventually zserv.h will only be used for zapi messages. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-01-23Merge pull request #3508 from chiragshah6/evpn_dev2Russ White
zebra: EVPN remote entry delete check local entry presence
2018-12-31zebra: netlink_request consolidataionChirag Shah
Make netlink_request api generic where it can be used for dump or querying specific information request. nelink request nlm flags (NLM_F_ROOT | NLM_F_MATCH) are used to dump purpose, if client wants to query spcific MAC or IP using netlink_request does not require to set them. nlm struct is passed by the caller of netlink_request, it can also set the nlm request flags. Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2018-12-29zebra: replace zlog_err with flog_errRafael Zalamena
Change the logging mechanism for truncated netlink error messages. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2018-12-26zebra: remove duplicated codeRafael Zalamena
Remove duplicated netlink error message length check. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2018-11-21zebra: separate netlink socket for dataplaneMark Stapp
Use a separate netlink socket for the dataplane's updates, to avoid races between the dataplane pthread and the zebra main pthread. Revise zebra shutdown so that the dataplane netlink socket is cleaned-up later, after all shutdown-time dataplane work has been done. Signed-off-by: Mark Stapp <mjs@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: netlink fuzzing path correctionMark Stapp
Correct use of netlink_parse_info() in the netlink fuzzing path. Also clarify a couple of comments about pthreads. Signed-off-by: Mark Stapp <mjs@voltanet.io>