Commit Graph

492 Commits

Author SHA1 Message Date
Jakub Urbańczyk
0be6e7d75d zebra: check for buffer boundary
* Move code encoding Netlink messages to separate functions
 * Add buffer bounds checking while creating Nelink messages

Signed-off-by: Jakub Urbańczyk <xthaid@gmail.com>
2020-06-13 22:56:25 +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
Mark Stapp
ee70f62979 zebra: convert LSP nhlfe lists to use typesafe lists
Convert the embedded lists of nhlfes and snhlfes in zebra LSPs
and SLSPs to use typesafe dlists.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-06-01 14:46:12 -04:00
Sri Mohana Singamsetty
6e19892fdf
Merge pull request #6419 from vivek-cumulus/zebra_macfdb_fixup
Zebra macfdb fixup
2020-05-19 08:18:37 -07:00
Stephen Worley
22857da1bb
Merge pull request #6351 from opensourcerouting/fpm-nh
fpm: explicit next hop groups control
2020-05-19 11:01:03 -04:00
vivek
bbd4285bc7 zebra: Install bridge FDB entries with correct VTEP IP
Fixes: zebra: adapt and export rmac netlink functions

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2020-05-15 14:01:59 -07:00
vivek
4682d1bf81 zebra: Pass correct buffer to MAC FDB netlink message build
Fixes: zebra: adapt and export rmac netlink functions

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2020-05-15 13:58:30 -07:00
Rafael Zalamena
a2072e7100 zebra: format files to make polychaeta happy
Use clang-format to make code match what polychaeta wants for
formatting.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-05-13 13:56:16 -03:00
Rafael Zalamena
b55ab92abd fpm: add toggle to enable/disable next hop groups
If you haven't migrated your FPM server to use next hop groups, it is
possible that you want to disable this feature. This commit implements
a toggle to enable/disable next hop groups usage (even if your Linux
kernel is not using it).

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-05-05 16:22:07 -03:00
Stephen Worley
002e5c4357 zebra: abstract 5549 check into a function
Abstract the 5549 ipv4 over ipv6 into a function for easier
code reuse and reading.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-05-05 15:05:30 -04:00
Rafael Zalamena
e9a1cd931b fpm: add next hop group support
Add support for the new kernel messages: `RTM_NEWNEXTHOP` and
`RTM_DELNEXTHOP`.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-05-05 10:54:06 -03:00
Mark Stapp
81ad029173
Merge pull request #6330 from sworleys/No-NHG-Install-With-VRFns
zebra: force off kernel NHG install with netns VRFs
2020-05-01 14:23:49 -04:00
Stephen Worley
d982012a0e zebra: force off kernel NHG install with netns VRFs
Force off kernel NHG install with netns-based VRFs for
now. There is not really a good solution for allowing
kernel nexthop groups in namespaced based vrfs.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-05-01 12:34:43 -04:00
Donald Sharp
2c77ddee4b zebra: Display ifindex of interface being installed on
When installing a nexthop group, dump out the ifindex of the
nexthop being installed as a bit more data for the developer.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-05-01 11:58:20 -04:00
David Lamparter
c334a16ef1
Merge pull request #6262 from qlyoung/remove-sprintf 2020-04-23 20:27:26 +02:00
Donald Sharp
9d866c07c8 zebra: Expose vrf lookup by table id out of rt_netlink.c
The function rt_netlink.c is using to lookup the vrf by
passed in table id.

I'm also going to pretend that this function is not
so awful to run when we have a large number of routes
incoming.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-04-22 10:56:06 -04:00
Quentin Young
772270f3b6 *: sprintf -> snprintf
Replace sprintf with snprintf where straightforward to do so.

- sprintf's into local scope buffers of known size are replaced with the
  equivalent snprintf call
- snprintf's into local scope buffers of known size that use the buffer
  size expression now use sizeof(buffer)
- sprintf(buf + strlen(buf), ...) replaced with snprintf() into temp
  buffer followed by strlcat

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-20 19:14:33 -04: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
Rafael Zalamena
a50404aaae zebra: fix some formatting/style issues
* Break lines longer than 80 columns.
* Remove space after '('.
* Use '%pIX' instead of 'inet_ntop'.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-04-14 14:05:52 -03:00
Rafael Zalamena
f2a0ba3a50 zebra: data plane FPM add support RMAC VNI
Store VNI information in the data plane context so we can use it to
build the FPM netlink update with that information later.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-04-14 13:45:39 -03:00
Rafael Zalamena
d4d4ec1cc1 zebra: adapt and export rmac netlink functions
Those functions are going to be used by the new data plane plugin for
netlink FPM.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-04-14 13:45:39 -03:00
Rafael Zalamena
f78fe8f3d6 zebra: export netlink function and change return
Instead of retuning always `0`, lets return the amount of used bytes for
the message. This will be used by the new FPM interface to know how many
bytes we must reserve for the output buffer.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-04-14 11:44:39 -03:00
Rafael Zalamena
b9c875150b zebra: simplify netlink_route_multipath
*   Remove variable `family`;
*   Remove always false `RTM_DELROUTE` checks;

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-04-14 11:44:39 -03:00
Rafael Zalamena
9266b31568 zebra: simplify some netlink debug messages
*   Use `inet_ntop` instead of `inet_ntoa`
*   Replace function name with `__func__`
*   Inline functions

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-04-14 11:44:39 -03:00
Rafael Zalamena
e57a3fab68 zebra: generalize netlink route talk function
Generalize the netlink route message building function so it can be used
in the future by the netlink Forwarding Plane Manager (FPM) interface.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-04-14 10:40:50 -03:00
Jakub Urbańczyk
bd47f3a3b4 zebra: Add vrf name and id to debugs
In some places we log the interface but not the vfr the
interface is in. In others we only output the vrf id, which
can be difficult for human to read. This commit makes zebra
debugs more vrf aware.

Signed-off-by: Jakub Urbańczyk <xthaid@gmail.com>
2020-04-12 21:03:29 +02:00
David Lamparter
c0d4a6d852
Merge pull request #5928 from xThaid/rt_link_cleanup
zebra: make common function for RTM_NEWNEIGH calls
2020-04-08 15:38:46 +02:00
Mark Stapp
bf1626a6b1 zebra: clean up a debug and an api in netlink code
Simplify the netlink nexthop api; clean up a debug too.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-03-27 09:37:02 -04:00
Stephen Worley
13e0321ac9 zebra: remove unnecessary cmd = check
In the netlink code for determining whether to set
a src on the route, we check if the cmd=NEW_ROUTE
but its not possible for this to ever be anything
but a new route since we do a goto skip further up
if its a DEL_ROUTE cmd.

So remove this unnecessary check.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-03-26 10:39:16 -04:00
Stephen Worley
d8bfd8dc9a zebra: determine src when using nexthop objects
Determine src based on nexthop data even when we are using
kernel nexthop objects.

Before, we were entirely skipping this step and just sending the
nexthop ID, ignoring src determination.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-03-26 10:37:51 -04:00
Stephen Worley
762288f50f zebra: abstract route src determiniation into func
Abstraction the route src determination from a nexthop in the
netlink code into a function for both singlepath and mutlipath
to call.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-03-26 10:37:40 -04:00
David Lamparter
d6951e5ef9 *: remove tabs from log messages
Some logging systems are, er, "allergic" to tabs in log messages.
(RFC5424: "The syslog application SHOULD avoid octet values below 32")

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-03-24 18:47:12 +01:00
Jakub Urbańczyk
340845e2b5 zebra: make common function for RTM_NEWNEIGH calls
We currently have netlink_neigh_update_ctx,
netlink_vxlan_flood_update_ctx and netlink_macfdb_update_ctx
all of which do slightly different RTM_NEWNEIGH calls into
the kernel. After this change, there will be one common
function.

Signed-off-by: Jakub Urbańczyk <xthaid@gmail.com>
2020-03-21 19:38:18 +01:00
Donald Sharp
9a0132a577 zebra: Modify some route install debugs to allow us to understand a bit better
1) When programming a nhg id to the kernel we had no debug of that
is what we are doing.

2) Add debugs to all nexthop information to allow us to follow
which prefix we are talking about.  This is especially
useful when dealing with a large number of routes and
you want to grep out one or two too see what is going on.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-20 18:15:33 -04:00
vivek
8d27e1aaac zebra: Install nexthop's weight for IPv4 routes with IPv6 next hops
Ensure that any weight associated with the next hop is installed for
IPv4 routes with IPv6 next hops too.
Updates: lib, zebra: Allow for installation of a weighted nexthop

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2020-03-17 19:25:13 -07:00
Donald Sharp
f61182b931
Merge pull request #5985 from Naveenaidu/5984-cleanup-is_selfroute
zebra/rt_netlink.c: Clean is_selfroute function
2020-03-12 19:19:53 -04:00
Naveen Naidu
6a6d11a33b zebra/rt_netlink.c: Clean is_selfroute function
The return type of is_selfroute function is changed from int to bool.
Also remove the redundant invoking of the is_selfroute function in the
calling function netlink_route_change_read_unicast

Fixes: https://github.com/FRRouting/frr/issues/5984

Signed-off-by: Naveen Naidu <naveennaidu479@gmail.com>
2020-03-12 00:37:21 +05:30
vivek
4b3f26f4c9 zebra: Readd special flood MAC upon del notification
Readd the special MAC that represents the flood (head-end replication) entry
for EVPN-VxLAN upon getting a delete notification for it.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Chirag Shah <chirag@cumulusnetworks.com>

Ticket:  CM-25797
Ticket: CM-26238
Testing Done:
1. evpn-min, evpn-smoke - results summarized in CM-25798
2020-03-10 10:02:43 -04:00
Chirag Shah
7c26c12106 zebra: add debug in specific neigh fetch
add debug trace in specific neigh request send api
to help debug an issue where synchronous response parse
returns with NLMSG_DONE where there is no ipv6 neigh received.
the count value is set to 1 because the request contained
a spcific neigh.

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2020-03-10 09:59: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
Donatas Abraitis
975a328e2e *: Replace s_addr 0 => INADDR_ANY
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-02-06 09:00:12 +02:00
Russ White
05d0c66d8f
Merge pull request #5737 from mjstapp/zebra_disable_kern_nhs
zebra: add config to disable use of kernel nexthops
2020-02-04 08:12:34 -05:00
Donald Sharp
88cafda739 zebra: nexthop groups vrf's are only a function of namespaces
Nexthop groups as a whole do not make sense to have a vrf'ness
As that you can have a arbitrary number of nexthops that point
to separate vrf's.

Modify the code to make this distinction, by clearly delineating
the line between the nhg and the nexthop a bit better.
Nexthop groups having a vrf_id only make sense if you are using
network namespaces to represent them.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-01-31 08:45:51 -05:00
Mark Stapp
7c99d51beb zebra: add config to disable use of kernel nexthops
Add a config that disables use of kernel-level nexthop ids.
Currently, zebra always uses nexthop ids if the kernel supports
them.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-01-28 11:00:42 -05:00
Donald Sharp
946de1b95a bgpd, ospfd, zebra: Do not use 0 as VRF_DEFAULT
Explicitly spell out what we are trying to do.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-01-15 08:29:36 -05:00
Hiroki Shirokura
760f39dc08 zebra: fix kernel-route's deletion on vrf
zebra can catch the kernel's route deletion by netlink.
but current FRR can't delete kernel-route on vrf(l3mdev)
when kernel operator delete the route on out-side of FRR.
It looks problem about kernel-route deletion.

This problem is caused around _nexthop_cmp_no_labels(nh1,nh2)
that checks the each nexthop's member 'vrf_id'.
And _nexthop_cmp_no_labels's caller doesn't set the vrf_id
of nexthop structure. This commit fix that case.

Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2019-12-23 15:25:12 +09:00
Stephen Worley
62d2ecb2f2 zebra: set RTNH_F_ONLINK in nexthop creation
We were not setting the RTNH_F_ONLINK flag where appropriate
when creating nexthop objects in the kernel.

Set it on the nhmsg.nh_flags netlink message.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-12-17 14:24:22 -05:00
Donald Sharp
df7fb5800b lib, zebra: Allow for installation of a weighted nexthop
Linux has the idea of allowing a weight to be sent
down as part of a nexthop group to allow the kernel
to weight particular nexthop paths a bit more or less
than others.

See:
http://tldp.org/HOWTO/Adv-Routing-HOWTO/lartc.rpdb.multiple-links.html

Allow for installation into the kernel using the weight attribute
associated with the nexthop.

This code is foundational in that it just sets up the ability
to do this, we do not use it yet.  Further commits will
allow for the pass through of this data from upper level protocols.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-12-09 13:37:37 -05:00
Donald Sharp
e302caaa81
Merge pull request #5416 from mjstapp/re_nhe_pointer
lib,zebra: use shared nexthop-group in route_entry
2019-12-04 14:11:04 -05:00