Commit Graph

97 Commits

Author SHA1 Message Date
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
Stephen Worley
87da6a6019 zebra: Add support for static encap mpls labels
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-08-25 13:19:07 -04:00
David Lamparter
8d2dcc85dd zebra: fix warnings from frr_elevate_privs()
Signed-off-by: David Lamparter <equinox@diac24.net>
2018-08-14 20:02:05 +00:00
David Lamparter
6bb30c2cba *: use frr_elevate_privs() (2/2: manual)
Signed-off-by: David Lamparter <equinox@diac24.net>
2018-08-14 20:02:05 +00:00
David Lamparter
01b9e3fd0d *: use frr_elevate_privs() (1/2: coccinelle)
Signed-off-by: David Lamparter <equinox@diac24.net>
2018-08-14 20:02:05 +00:00
Quentin Young
09c866e34d *: rename ferr_zlog -> flog_err_sys
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-08-14 20:02:05 +00:00
Quentin Young
af4c27286d *: rename zlog_fer -> flog_err
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-08-14 20:02:05 +00:00
Quentin Young
43e52561b4 zebra, lib: error references for zebra
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-08-14 20:02:05 +00:00
Donald Sharp
174482ef37 bgpd, lib, zebra: Convert LIB_ERR_PRIVILEGES
For all the places we zlog_err about raising/lowering privileges, use
zlog_ferr.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-08-14 20:02:05 +00:00
F. Aragon
e940478c02
zebra: socket fd check (Coverity 1472236)
Signed-off-by: F. Aragon <paco@voltanet.io>
2018-08-03 18:16:09 +02:00
Russ White
155d6d4415
Merge pull request #2696 from sworleys/Netlink-Fuzz
zebra: Add code for fuzzing netlink
2018-07-29 08:33:43 -04:00
Stephen Worley
e6a0e0d141 zebra: Check for netlink message next fault
NLMSG_NEXT decrements the buffer length (status) by
the header msg length (nlmsg_len) everytime its called.
If nlmsg_len isn't accurate and set to be larger than
what it should represent, it will cause status to
decrement passed 0. This makes NLMSG_NEXT return a
pointer that references an inaccessible address.
When that is passed to NLMSG_OK, it segfaults.

Add a check to verify that there is still something to read
before we try to.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2018-07-26 16:46:57 -04:00
Stephen Worley
29bf7b0b67 Style, don't initialize netlink_read flag
Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2018-07-26 14:34:28 -04:00
Stephen Worley
ef593eff00 zebra: Make fuzzer code use default netlink socket
Change the fuzzing code so that it fakes data from
the listening socket rather than using its own pseudo one.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2018-07-26 14:32:50 -04:00
Stephen Worley
acfa8927f9 Refactor code for new fuzzing netlink flag
Changed the configure flag used by netlink fuzzing
and refactored code accordingly.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2018-07-24 13:39:25 -04:00
Stephen Worley
bd7891fd70 Style for Add code for fuzzing netlink
Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2018-07-23 11:25:31 -04:00
Stephen Worley
81a2f870dd zebra: Add code for fuzzing netlink
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-21 00:06:38 -04:00
Donald Sharp
8c85e8ea92 zebra: Remove need for ACK for netlink messages
Kernel requests via netlink are synchronous.

Therefore we do not need to specify a need for a ACK and
we can make the netlink_cmd NONBLOCKING

1) If the netlink message is going to cause an error
we will still get one.  Since results from the kernel
are synchronous we will get the error message on the
netlink_cmd socket and handle it

2) If the netlink message is going to send more than
one packet we will still get them all.  Since the results
from the kernel are synchronous we will receive all data.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-07-12 22:43:06 -04:00