Commit Graph

114 Commits

Author SHA1 Message Date
Donald Sharp
9781e6a047 zebra: Don't ignore setsockopt return
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-24 07:42:51 -04:00
Jakub Urbańczyk
97f8514460 zebra: increase netlink receive buffer size
Signed-off-by: Jakub Urbańczyk <xthaid@gmail.com>
2020-09-01 11:35:16 +02:00
Mark Stapp
5c2bb61763
Merge pull request #7017 from xThaid/netlink_fix
zebra: fix netlink batching
2020-08-28 08:20:28 -04:00
Jakub Urbańczyk
2f9dbd3ab3 zebra: fix netlink batching
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-27 22:06:14 +02:00
Jakub Urbańczyk
4efd721d1e zebra: remove fuzzing stuff
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-25 17:31:07 +02:00
Jakub Urbańczyk
d68e74b41c lib, zebra: add support for sending ARP requests
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-12 23:19:58 +02:00
Jakub Urbańczyk
531c92b82f tests: zebra netlink testcases
Signed-off-by: Jakub Urbańczyk <xthaid@gmail.com>
2020-08-10 21:57:12 +02:00
Jakub Urbańczyk
f6feb48b48 zebra: design changes in netlink batching code
Signed-off-by: Jakub Urbańczyk <xthaid@gmail.com>
2020-08-10 21:57:12 +02:00
Jakub Urbańczyk
18f60fe999 zebra: remove old kernel one-update-at-a-time api
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-10 21:57:04 +02:00
Jakub Urbańczyk
67e3369ed4 zebra: netlink message batching
Integrate existing functions with batching infrastructure.

Signed-off-by: Jakub Urbańczyk <xthaid@gmail.com>
2020-08-10 21:42:43 +02:00
Jakub Urbańczyk
e63c76228c zebra: add netlink message batching infrastructure
Add helpers to batch several messages into one single netlink datagram.

Signed-off-by: Jakub Urbańczyk <xthaid@gmail.com>
2020-08-10 21:33:00 +02:00
Jakub Urbańczyk
fef24b0339 zebra: prepare dplane for batching
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-08-10 21:32:59 +02:00
Jakub Urbańczyk
f865339348 zebra: cosmetic changes in the netlink code
Signed-off-by: Jakub Urbańczyk <xthaid@gmail.com>
2020-07-13 16:35:39 +02:00
Jakub Urbańczyk
ae6138bfd8 zebra: netlink cleanup
* Split zebra's netlink code into smaller functions to be more
   generic.

Signed-off-by: Jakub Urbańczyk <xthaid@gmail.com>
2020-07-08 11:18:06 +02:00
Jakub Urbańczyk
312a6beed6 zebra: clean up netlink api
* 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-06-13 22:53:24 +02:00
Donald Sharp
fd3f8e52b6 zebra: Modify netlink_request to statisfy coverity
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-04-15 09:01:56 -04:00
Donatas Abraitis
0d6f7fd6fd *: Replace sizeof something to sizeof(something)
Satisfy checkpatch.pl requirements (check for sizeof without parenthesis)

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-03-08 21:44:53 +02:00
Donatas Abraitis
15569c58f8 *: Replace __PRETTY_FUNCTION__/__FUNCTION__ to __func__
Just keep the code cool.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-03-05 20:23:23 +02:00
Donald Sharp
40d86eba41 zebra: Actually add the NLA_F_NESTED flag to our code
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-10 15:13:36 -05:00
Russ White
9e1a733051
Merge pull request #5628 from donaldsharp/rtm_getneigh
zebra: Ignore RTM_GETNEIGH messages from the linux kernel
2020-01-07 10:47:50 -05:00
Quentin Young
67188ca253 zebra: fix undefined bitshifts in netlink stuff
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-01-04 14:12:46 -05:00
Donald Sharp
951f8bcbba zebra: Ignore RTM_GETNEIGH messages from the linux kernel
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>
2020-01-04 07:45:22 -05:00
Stephen Worley
2f65aee06a zebra: Don't error on nexthop object support check
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-25 11:13:40 -04:00
Stephen Worley
d9f5b2f50f zebra: Add functionality to parse RTM_NEWNEXTHOP and RTM_DELNEXTHOP messages
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-25 11:13:36 -04:00
Stephen Worley
79580b5ac4 zebra: Add base functionality for nexthop messages in kernel_netlink
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-25 11:13:36 -04:00
Stephen Worley
da0ad5cfc8 zebra: Add RTNLGRP_NEXTHOP group to the kernel socket
Initialize the netlink socket with the RTNLGRP_NEXTHOP
group as well to listen for.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:36 -04:00
David Lamparter
0cf6db21ec *: frr_elevate_privs -> frr_with_privs
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2019-09-03 17:18:35 +02:00
Russ White
31b653d23a
Merge pull request #4546 from donaldsharp/better_debugs
zebra: Increase debugs to understand why we rejected a kernel route
2019-06-18 10:06:54 -04:00
Donald Sharp
8c8f250b0a zebra: Increase debugs to understand why we rejected a kernel route
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-18 08:47:28 -04:00
Donald Sharp
96b43ab3ff zebra: Fuzzing code has gotten a bit out of date
Update the fuzzing code to compile again.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-06-15 08:25:25 -04:00
Donald Sharp
3c649c719f *: Convert to using frr_vtydir instead of DAEMON_VTY_DIR
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-06-04 10:37:19 -04:00
Stephen Worley
4cebb2b6f6 zebra: Fix extended ack error message parsing
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-26 01:20:29 -04:00
Quentin Young
9165c5f5ff *: remove trailing newlines from zlog messages
Zlog puts its own newlines on, and doing this makes logs look nasty.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-03-14 18:41:15 +00:00
Donald Sharp
3801e7646c zebra: Move the master thread handler to the zrouter structure
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-31 09:20:46 -05:00
Russ White
262d4dda2a
Merge pull request #3508 from chiragshah6/evpn_dev2
zebra: EVPN remote entry delete check local entry presence
2019-01-23 13:44:46 -05:00
Chirag Shah
718f9b0f88 zebra: netlink_request consolidataion
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-31 14:38:32 -08:00
Rafael Zalamena
13ec4c1d5b zebra: replace zlog_err with flog_err
Change the logging mechanism for truncated netlink error messages.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2018-12-29 07:14:14 -02:00
Rafael Zalamena
d0c893802a zebra: remove duplicated code
Remove duplicated netlink error message length check.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2018-12-26 17:06:35 -02:00
Mark Stapp
62b8bb7a17 zebra: separate netlink socket for dataplane
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-11-21 10:38:08 -05:00
Mark Stapp
8b962e7759 zebra: rebase dataplane, align with master
Rebase and pick up dataplane changes on master, including
renamed structs and enums.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2018-10-25 08:57:04 -04:00
Mark Stapp
1bcea841b1 zebra: netlink fuzzing path correction
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>
2018-10-25 08:34:30 -04:00
Mark Stapp
5709131cec zebra: resolve style issues in dplane commit
Resolve (most) style issues in the initial zebra dataplane
commit branch.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2018-10-25 08:34:30 -04:00
Mark Stapp
7cdb1a8445 zebra: start dataplane layer work
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-10-25 08:34:30 -04:00
F. Aragon
c9f7d10b8a
zebra: netlink socket check (Coverity 1472236)
Signed-off-by: F. Aragon <paco@voltanet.io>
2018-10-03 20:28:01 +02:00
Mark Stapp
85a75f1e77 zebra: Start abstraction of zebra_dplane_info for context passing
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-09-19 18:34:25 -04:00
Donald Sharp
87b5d1b098 zebra: Print out netlink message type instead of number
When we are displaying data about a netlink message
in debugs or errors, print out the message type
as a string instead of a number.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-09-14 17:48:51 -04:00
Quentin Young
1c50c1c0d6 *: style for EC replacements
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-13 19:38:57 +00:00
Quentin Young
450971aa99 *: LIB_[ERR|WARN] -> EC_LIB
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-13 19:34:28 +00:00
Quentin Young
e914ccbe9c zebra: ZEBRA_[ERR|WARN] -> EC_ZEBRA
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-13 19:23:29 +00:00
Quentin Young
9df414feeb zebra: flog_warn conversion
Convert Zebra to user error subsystem.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-06 20:56:38 +00:00