Commit Graph

634 Commits

Author SHA1 Message Date
Stephen Worley
7d5bb02b1a zebra: Force off kernel nexthop group API for now
Force off kernel nexthop group API for now. Will re-enable
after suffient testing.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:43 -04:00
Stephen Worley
8d03bc501b zebra: Handle nhg_hash_entry encaps/more debugging
Add code for handling nexthop group hash entry encaps
and sending them to the kernel. Add some more debugging
information for the encaps and groups in general.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:42 -04:00
Stephen Worley
b7537db639 zebra: Add common netlink mpls stack building path
There was some code copypasta for mpls stack building in the
netlink install path. Reduced that to a common function.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:42 -04:00
Stephen Worley
6e72876478 zebra: TODO for hanlding blackhole attr exclusive
Add a TODO statement for handling the exclusiveness
of blackhole attributes.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:42 -04:00
Stephen Worley
bc541126e4 zebra: Use nexthop object id on route delete
When we receive a route delete from the kernel and it
contains a nexthop object id, use that to match against
route gateways with instead of explicit nexthops.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:42 -04:00
Stephen Worley
815059466c zebra: Move the supports_nh bool to a better place
Move the supports_nh bool indicating whether the kernel we are
using supports nexthop objects into the netlink kernel interface
itself. Since only linux and netlink support nexthop object APIs
for now this is fine.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:41 -04:00
Stephen Worley
9a1588c4ce zebra: Add handling for kernel del/update nexthop
Add handling for delete/update nexthop object messages from the
kernel.

If someone deletes a nexthop object we are still using, send it back
down. If the someone updates a nexthop we are using, replace that nexthop
with ours. Routes are referencing this nexthop object ID and we resolved
it ourselves, so we should force the other `someone` to submit to our
will.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:41 -04:00
Stephen Worley
38e40db1c9 zebra: Sweep our nexthop objects out on restart
On restart, if we failed to remove any nexthop objects due
to a kill -9 or such event, sweep them if we aren't using them.
Add a proto field to handle this and remove the is_kernel bool.

Add a dupicate flag that indicates this nexthop group is only
present in our ID hashtable. It is a dupicate nexthop we received
from the kernel, therefore we cannot hash on it.

Make the idcounter globally accessible so that kernel updates
increment it as soon as we receive them, not when we handle them.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:41 -04:00
Stephen Worley
428b4c0a5d zebra: Give installed nhe's the zebra proto
Give all nhg_hash_entrys we install into the kernel
as nexthop objects a defined proto matching the zebra
rib table one. This makes sense since nhe's are proto-independent
and determined exclusively in zebra.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:41 -04:00
Stephen Worley
98cda54a95 zebra: Add recursive functionality to NHE's
Add the ability to recursively resolve nexthop group hash entries
and resolve them when sending to the kernel.

When copying over nexthops into an NHE, copy resolved info as well.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:40 -04:00
Stephen Worley
de3f548819 zebra: Use NHE id on kernel route sends
If the kernel supports nexthop objects, send the route
using an nhg_hash_entry ID instead.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:40 -04:00
Stephen Worley
a6e6a6d825 zebra: Fix nhg ifindex setting and checking
We were only setting and checking the ifindex if
the nexthop had an *_IFINDEX type. However, when nexthop
active checking is done, the non-*_IFINDEX types can also
obtain a nexthop with an ifindex and are thus valid too.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:40 -04:00
Stephen Worley
e22e80010e zebra: Use a nhe context dataplane and rib metaq
We will use a nhe context for dataplane interaction with
nextho group hash entries.

New nhe's from the kernel will be put into a group array
if they are a group and queued on the rib metaq to be processed
later.

New nhe's sent to the kernel will be set on the dataplane context
with approprate ID's in the group array if needed.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:40 -04:00
Stephen Worley
ddaee0c7d3 zebra: Remove uneeded freeing helper function
Removing this function since the new paradigm
of everything just being nhg_connected structs
makes it not make a lot of sense.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:39 -04:00
Stephen Worley
7b683a96e4 zebra: Put nhe ifp setting inside alloc
Put the setting of the ifp on a nexthop group hash
entry into the zebra_nhg_alloc() function. It should
only be added if its not a group/recursive (it doesn't
have any depends) and its nexthop type has an ifindex.

This also provides functionality for proto-side ifp
setting.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:39 -04:00
Stephen Worley
bbb3940ed1 zebra: VRF ID should be null if a nexthop group
A nexthop group should not have a VRF ID. Only individual
nexthops need to be using a VRF. Fixed this both kernel and
proto side.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:39 -04:00
Stephen Worley
fe593b781d zebra: Re-organize/expose nhg_connected
Re-organize and expose the nhg_connected functions so that
it can be used outside zebra_nhg.c. And then abstract those
into zebra_nhg_depends_* and zebra_nhg_depenents_* functons.

Switch the ifp struct to use an RB tree for its dependents,
making use of the nhg_connected functions.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:39 -04:00
Stephen Worley
a15d4c0089 zebra: Abstract the RB nodes/add dependents tree
Create a nhg_depenents tree that will function as a way
to get back pointers for NHE's depending on it.

Abstract the RB nodes into nhg_connected for both depends and
dependents. This same struct is used for both.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:39 -04:00
Stephen Worley
0c8215cbab zebra,lib: Refactor depends to RB tree
Refactor the depends to use an RB tree instead of a list.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:39 -04:00
Stephen Worley
20822f9d2e zebra: Add equivalence function for nhg_depends
Add a helper function to allow us to check if two
nhg_hash_entry's dependency lists are equal.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:39 -04:00
Stephen Worley
fdee485ad0 zebra: Make kernel debug nexthop standardized
Make the the kernel debug zlog for nexthop messages from the
kernel more aligned with the route message kernel debug zlog.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:38 -04:00
Stephen Worley
2d6cd1f007 zebra: Always copy nhg and depends on nhe alloc
Changed our alloc function to just copy the nhg and
nhg_depends. This makes the zebra_nhg_find code a
little bit cleaner, hopefully preventing bugs.

The only issue with this is that it makes us have to loop
over the nexthops in a group an extra time for the copies.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:38 -04:00
Stephen Worley
565ce0d3c7 zebra: Add functionality to send groups to kernel
Add functionality to allow us to send nexthop groups
to the kernel. It creates a nexthop_grp array based on
the dependency list in the nhg_hash_entry and then shoves
that into the netlink message.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:38 -04:00
Stephen Worley
55eeb2ae7f zebra: Make nexthop group vrf VRF_DEFAULT
Nexthop groups can have nexthops in different vrf's. So,
let's make the group vrf_id just be VRF_DEFAULT for hash
lookup purposes.

Set vrf_id to be VRF_DEFAULT for every message. If its a new
nextop, set the vrf to be the appropriate thing, otherwise
its a group and can just be left as default.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:38 -04:00
Stephen Worley
8e401b251f zebra: Refactor nexthop group creation code to use allocated memory
Simplify the code for nexthop hash entry creation. I made nexthop
hash entry creation expect the nexthop group and depends to always
be allocated before lookup. Before, it was only allocated if it had
dependencies. I think it makes the code a bit more readable to go
ahead an allocate even for single nexthops as well.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:38 -04:00
Stephen Worley
85f5e76175 zebra: Read in nexthop dependencies from the kernel
Add functionality to read in a group from the kernel,
create a hash entry for it, and add its nexthops to
its dependency list.

Further, we create its nhg struct separtely from this,
copying over any nexthops it should reference directly
into it.

Thus, we have two types for representation of the nexthop group:
	nhe->nhg_depends->[nhe, nhe, nhe]

	nhe->nhg->nexthop->nexthop->nexthop

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:38 -04:00
Stephen Worley
a3267f8b6e zebra: Check if a nexthop was added to the nhg
Before doing anything with our tables, less make sure
we even added anything to the group.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:38 -04:00
Stephen Worley
e8b0e4201e zebra: Add afi value for all nexthops sent/received
Since nexthops are always going to need to be address family
specific unless they are only a group, we have to address
this when we receive and send them.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:38 -04:00
Stephen Worley
c4239c05c0 zebra: Make bad address family log message more clear
The message for an invalid address family on a nexthop gateway did
not specify that is what for the gateway specifically.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:38 -04:00
Stephen Worley
f44088c33e zebra: Fix where the flags are set for new nexthop entries
We were setting the flags in a couple different places for
nexthop entries.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:37 -04:00
Stephen Worley
2614bf8764 zebra: Add ifp to zebra-side rib_add
Add an interface pointer for an nexthop group hash entry
when we are getting a rib_add for a new route.

Also, add the interface index to the `show nexthop-group` command.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:37 -04:00
Stephen Worley
8c0a24c14e zebra: Add new nexthops to the interface nexthop hash entry list
When we get a new nexthop and find the interface associated
with it, add this nexthop to the interface's zebra interface
info nexthop hash entry list.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:37 -04:00
Stephen Worley
bbb322f292 zebra: Make route entry nexthop groups point to our hash entry
Make our route entry struct's re->ng nexthop group pointer
just point to the nhe->nhg nexthop hash entry nexthop group.
This will allow updates to the nexthop itself to propogate
to our routes immediately.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:37 -04:00
Stephen Worley
8032b71737 zebra: Update rib_add to take a nexthop ID
Add a parameter to the rib_add function so that it takes
a nexthop ID from the kernel if one is passed along
with the route.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:37 -04:00
Stephen Worley
77a44d94f8 zebra: Put unicast nexthop parsing into its own function
Move the nexthop unicast parsing into its own function
to improve code readability. It was getting a bit too
indented.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:37 -04:00
Stephen Worley
fcc89a9cfc zebra: Parse in nexthop ID information from new routes
Add parsing code for nexthop object ID's when we get a
route. When we get a new route with the new kernel, it
will come with a nexthop ID and the nexthop full info.
We should just reference by ID if it exists and point
to the nexthop hash entry that matches it.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:37 -04:00
Stephen Worley
044e54d1eb zebra: Set the INSTALLED flags on nexthop entries we receive
Add SETs to the flags on nexthop entries to mark
 installed/uninstalled from the kernel.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:37 -04:00
Stephen Worley
75f8505d2e zebra: Force re-install nexthop if still referenced
Added functionality so that when we receive a RTM_DELNEXTHOP
for a nhg_hash_entry that is still being referenced by
a route, we immediately push it back to the kernel.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:37 -04:00
Stephen Worley
60e0eaee23 zebra: Return proper status result
We were ignoring the status result interger from
the netlink request and message parsing and just
returning 0. Fixed this to return the result of the last one.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:37 -04:00
Stephen Worley
4f096395c1 zebra: Use the dest prefix for determining nexthop family
Device only nexthops still need an address family associated
with them. Decided to get this from the destination prefix on it.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:37 -04:00
Stephen Worley
e1536fce85 zebra: Add debug statement for nexthop netlink messages
Add the zebra kernel debug statement for nexthop messages
so we can see them via vtysh.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:37 -04:00
Stephen Worley
e8968ccb2b zebra: Add kernel debugging function for netlink nexthop messages
We needed a kernel debugging function for netlink nexthop
messages when people are debugging kernel zebra messages.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:36 -04:00
Stephen Worley
f820d02508 zebra: Add base functionality for nexthop processing via the dataplane
Add all the neccessary code to allow nexthops to be processed
in separate dataplane contexts with the netlink dataplane kernel
provider.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:36 -04:00
Stephen Worley
d1285db253 zebra: Add flags to nexthops received from the kernel
Added the appropriate flags that need to be set when
we receive a nexthop from the kernel. They should be
marked as ACTIVE and that they are in the FIB.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:36 -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
Donald Sharp
eecacedc3b zebra: Remove re->nexthop_num from re
The nexthop_num is not a function of the re.  It is owned
by the nexthop group.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-10-25 11:13:36 -04:00
Donald Sharp
6b46851168 zebra: Replace nexthop_group with pointer in route entry
In the route_entry we are keeping a non pointer based
nexthop group, switch the code to use a pointer for all
operations here and ensure we create and delete the memory.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-10-25 11:13:36 -04:00
Donald Sharp
f3dbec60f2 zebra: Send RTPROT_ZEBRA for netlink messages missing this data
Update neighbor entries and rule entries to have the RTPROT_ZEBRA
protocol value.  So we can tell where things come from.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-09-19 16:05:39 -04:00
Mark Stapp
478566d68b zebra: avoid using zebra datastructs in evpn dataplane path
Some netlink-facing code used for evpn/vxlan programming was
being run in the dataplane pthread, but accessing zebra core
datastructs. Move some additional data into the dataplane
context, and use it in the netlink path instead.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-09-05 12:58:58 -04:00
Mark Stapp
0bbd4ff442 zebra: move EVPN VTEP programming to dataplane
Move VTEP install/uninstall to the zebra dataplane. Remove
synch kernel-facing apis and helper functions.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-09-04 10:30:17 -04:00
Donald Sharp
c9042b2890
Merge pull request #4877 from mjstapp/dplane_neighs
zebra: move evpn neighbors to dataplane
2019-09-04 10:23:31 -04:00
Mark Stapp
1cd89e8370
Merge pull request #4849 from sworleys/Label-Append-Resolve_2
zebra: Append rparent labels when resolving nexthop
2019-08-28 15:52:27 -04:00
Mark Stapp
931fa60c09 zebra: Use dataplane for evpn neighbor changes
Move neighbor programming to the dataplane; remove
old apis; remove some ifdef'd use of direct netlink
code points, using neutral values outside of the netlink-
specific files.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-08-23 14:10:41 -04:00
Donald Sharp
ad4c7e8d4e
Merge pull request #4778 from mjstapp/dplane_macs
zebra: use dataplane for evpn macs
2019-08-21 20:26:29 -04:00
Stephen Worley
b43434ad8e zebra: Append rparent labels when resolving nexthop
When resolving a nexthop, append its labels to the one its
resolving to along with the labels that may already be present there.

Before we were ignoring labels if the resolving level was greater than
two.

Before:
```
S>  2.2.2.2/32 [1/0] via 7.7.7.7 (recursive), label 2222, 00:00:07
  *                    via 7.7.7.7, dummy1 onlink, label 1111, 00:00:07
S>  3.3.3.3/32 [1/0] via 2.2.2.2 (recursive), label 3333, 00:00:04
  *                    via 7.7.7.7, dummy1 onlink, label 1111, 00:00:04
K>* 7.7.7.7/32 [0/0] is directly connected, dummy1, label 1111, 00:00:17
C>* 192.168.122.0/24 is directly connected, ens3, 00:00:17
K>* 192.168.122.1/32 [0/100] is directly connected, ens3, 00:00:17
ubuntu_nh#
```

This patch:
```
S>  2.2.2.2/32 [1/0] via 7.7.7.7 (recursive), label 2222, 00:00:04
  *                    via 7.7.7.7, dummy1 onlink, label 1111/2222, 00:00:04
S>  3.3.3.3/32 [1/0] via 2.2.2.2 (recursive), label 3333, 00:00:02
  *                    via 7.7.7.7, dummy1 onlink, label 1111/2222/3333, 00:00:02
K>* 7.7.7.7/32 [0/0] is directly connected, dummy1, label 1111, 00:00:11
C>* 192.168.122.0/24 is directly connected, ens3, 00:00:11
K>* 192.168.122.1/32 [0/100] is directly connected, ens3, 00:00:11
ubuntu_nh#
```

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-08-19 12:28:45 -04:00
Mark Stapp
036d93c047 zebra: use dataplane for vxlan remote mac programming
Move vxlan remote MAC install and uninstall to the async
dataplane.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-08-02 14:54:16 -04:00
Donald Sharp
fe5f21af9f zebra: Fix route replace v4 semantics with new system route
When a new system route comes in and we have a pre-existing
non-system route we are not deleting the current system
route from the linux kernel.

Modify the code such that when a route replace is sent
to the kernel with a new route as a system route and
the old route as a non-system route do a delete of
the old route so it is no longer in the kernel.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-07-29 11:39:06 -04:00
Stephen Worley
822c9af230 zebra: Add a conditional guard if zvrf lookup fail
Add a conditional to guard against segfaulting on the debug
statement when zvrf lookup fails.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-07-09 11:30:49 -04:00
Donald Sharp
a56ec5c0e9 zebra: When installing route use a good proto
When installing a table route into the kernel choose
RTPROT_ZEBRA as the installing/controlling protocol.

This way we can know we installed it as well as stop
the warnings about this special case of `ip import-table XX`

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-06-25 17:49:42 -04:00
Donald Sharp
9b0369745d zebra: failed neighbor event logging was a bit too aggresive
The failed neighbor event logging that was recently added in
commit: 3acae086ba

cast a bit too broad of a stroke.  We should only inform
the user that we were ignoring the RTM_NEWNEIGH FAIL callback
when we believe it was one of our own 5549 entries.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-06-20 05:37:17 -04:00
David Lamparter
9578e35d34
Merge pull request #4531 from donaldsharp/repeaty_mcrepeat
zebra: Handle 5549 neighbor entry failure state
2019-06-21 09:05:27 +02: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
3acae086ba zebra: Handle 5549 neighbor entry failure state
If we get a neighbor entry for 5549 failure notice
from the kernel that means that something has probably
gone terribly wrong.  Let's notice and not reinstall.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-06-14 21:47:27 -04:00
Quentin Young
eab4a5c2d0 zebra: strcat -> strlcat
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-29 18:03:26 +00:00
Donald Sharp
98572489ea zebra: Switch to using monotime(NULL) for re->uptime
The re->uptime usage of time(NULL) leaves it open to
timing changes from outside influence.  Switching
to monotime allows us to ensure that we have a timestamp
that is always increasing.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-05-11 01:44:42 -04:00
Donald Sharp
3cdba47a82 zebra: Modify code so that dplane is responsible for indicating success/fail of install
We have several route types KERNEL and CONNECT that are handled via special
case in the code.  This was causing a lot of work keeping the two different
classes of route types as special(SYSTEM OR NOT).  Put the dplane
in charge of the code that sets the bits for signalling route install/failure.

This greatly simplifies the code calling path and makes all route types
be handled exactly the same.  Additionaly code that we want to run
post data plane install can just work as per normal then, instead
of having to know we need to run it when we have a special type
of route.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com.
2019-03-27 16:19:28 -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
6ac9718a2a
Merge pull request #3893 from mjstapp/dplane_pw_nexthops
zebra: include nexthop info when installing pseudowires
2019-03-12 12:44:42 -04:00
Donald Sharp
28bd0652ac zebra: Add some debugs to neighbor entry processing
When we get a neighbor entry in zebra we start processing it.
Let's add some additional debugs to the processing so that when
it bails out and we don't use the data, we know the reason.
This should help in debugging the problems from why bgp does
not appear to have data associated with a neighbor entry
in the kernel.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-03-08 10:46:55 -05:00
Donald Sharp
2ec19f003c zebra: Remove duplicate NUD_PERMANENT check
The check for an entry being NUD_PERMANENT has already been done
there is no need to do it twice.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-03-08 10:31:32 -05:00
Mark Stapp
81793ac145 zebra: use const in dplane pw nhlfe accessors
Use const in the accessors for pseudowire nhlfe data; pull
that through the kernel-facing apis that use that data.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-03-07 15:06:36 -05:00
Stephen Worley
140d2d7ff5 zebra: Remove unused sockaddr variable
This variable does nothing, removing it.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-03-06 10:53:49 -05:00
Donald Sharp
334734a8b6 zebra: When installing a new route always use REPLACE
When we install a new route into the kernel always use
REPLACE.  Else if the route is already there it can
be translated into an append with the flags we are
using.

This is especially true for the way we handle pbr
routes as that we are re-installing the same route
entry from pbr at the moment.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-03-01 13:56:12 -05:00
Russ White
37a5432422
Merge pull request #3688 from chiragshah6/evpn_dev
zebra: EVPN probe local inactive neigh/arp entry upon mac mobility
2019-02-05 10:48:33 -05:00
Renato Westphal
3524352154
Merge pull request #3698 from donaldsharp/netlink_is_serious_business
Netlink is serious business
2019-02-05 11:52:33 -02:00
Donald Sharp
6cae47ed38 zebra: When the kernel passes up a onlink route respect those flags
Read the onlink flag from the kernel for routes and pass them
up and through to zebra so that we are consistent with what
the kernel is telling us.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-01-29 22:01:03 -05:00
Donald Sharp
275565fb5a zebra: some v4 attributes were being written 2 times
When the nexthop->type is NEXTHOP_TYPE_IPV4_IFINDEX we
were writing the RTA_PREFSRC 2 times for the build_singlepath
and build_multipath functions.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-01-29 20:41:18 -05:00
Donald Sharp
e405df7e78 zebra: some v6 attributes were being written twice
Some v6 attributes for the netlink_route_build_singlepath
code were being written two times for the NEXTHOP_TYPE_IPV6_IFINDEX
nexthop type.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-01-29 20:40:41 -05:00
Chirag Shah
6fe2b0e67f zebra: add kernel neigh update api
The kernel neigh update api helps update neighbor entry,
using changing state and flags parameters.

Ticket:CM-22864
Reviewed By:
Testing Done:

Signed-off-by:Chirag Shah <chirag@cumulusnetworks.com>
2019-01-29 08:02:29 -08: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
Mark Stapp
fc60837278 zebra: openbsd LSP update code
Finish the LSP update code for the async dataplane for
the openbsd platform. Remove synch apis now that we've
converted to the async code path.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-01-22 15:07:24 -05:00
Mark Stapp
16c628de99 zebra: infra for LSP updates using dplane
Adding infra to zebra dplane to support LSP updates. Add
kernel api for LSP updates that uses a dataplane context; add
stub apis for netlink, bsd, and 'null' kernel paths. Add
version of netlink mpls update code that takes a dplane
context struct instead of a zebra lsp struct.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-01-22 12:02:20 -05:00
Donald Sharp
62819462b7 zebra: Cleanup unnecessary check
We self include the enum that has the RTA_EXPIRES in it,
as such this will always be true.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-01-15 08:55:34 -05:00
Chirag Shah
67fb9374dc zebra: evpn remote delete fetch local entry
An EVPN type-2 entry is in freeze state during remote update,
remote VTEP can send typ-2 withdraw update,
upon receiving an entry delete (withdraw), first check
kernel has in local reachable state. Upon
unfreeze use the local entry to advertise to peers.
Fetch is for both MAC and IP, delete can come for
only MAC or MAC-IP combined route.

The specific entry fetch only required request flag to be set,
dump flag is not required.

Testing Done:
Simulate two VTEPs to do M1, IP1 mobility sequence,
freeze MAC during remote MAC update, subsequently send
withdraw type-2 route from origintating VTEP.
This results in read apis to invoke for local reachable entry.
Zebra updates its cache and upon unfreeze originates type-2.

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2018-12-31 14:40:31 -08: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
Donald Sharp
220f0f4245 zebra: Allow zebra to only mark up to multipath_num nexthops as ACTIVE
NEXTHOP_FLAG_ACTIVE currently means that the nexthop is considered
good enough to be installed. With current ecmp restrictions this
translation from multipath_num is enforced in the data plane.
The problem with this is of course that every data plane now
becomes concerned about the multipath num and must enforce it
independently.  Currently *bsd does not honor multipath_num at
all and linux marks all nexthops as being installed even when
it honors a multipath_num that is less than the total.

This code change moves the multipath_num enforcement from a dataplane
decision to a zebra nexthop decision.  Thus dataplanes now can
just install those nexthops marked as NEXTHOP_FLAG_ACTIVE
without having to worry about multipath_num.

*BSD will now respect multipath_num and Linux now properly notes
which routes are actually installed or not:

sharpd@donna ~/f/t/topotests> ps -ef | grep frr
frr       6261  1556  0 09:12 ?        00:00:00 /usr/lib/frr/zebra -e 2 --daemon -A 127.0.0.1
frr       6279  1556  0 09:12 ?        00:00:00 /usr/lib/frr/staticd --daemon -A 127.0.0.1

donna.cumulusnetworks.com(config)# do show ip route
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
       F - PBR, f - OpenFabric,
       > - selected route, * - FIB route

K>* 0.0.0.0/0 [0/106] via 10.0.2.2, enp0s3, 00:00:45
S>* 4.4.4.4/32 [1/0] via 10.0.2.1, enp0s3, 00:00:02
  *                  via 192.168.209.1, enp0s8, 00:00:02
                     via 192.168.210.1, enp0s9 inactive, 00:00:02
C>* 10.0.2.0/24 is directly connected, enp0s3, 00:00:45
C>* 192.168.209.0/24 is directly connected, enp0s8, 00:00:45
C>* 192.168.210.0/24 is directly connected, enp0s9, 00:00:45
donna.cumulusnetworks.com(config)#

sharpd@donna ~/f/t/topotests> ip route show
default via 10.0.2.2 dev enp0s3 proto dhcp metric 106
4.4.4.4 proto 196 metric 20
	nexthop via 10.0.2.1 dev enp0s3 weight 1
	nexthop via 192.168.209.1 dev enp0s8 weight 1
10.0.2.0/24 dev enp0s3 proto kernel scope link src 10.0.2.15 metric 106
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 linkdown
192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 linkdown
192.168.209.0/24 dev enp0s8 proto kernel scope link src 192.168.209.2 metric 105
192.168.210.0/24 dev enp0s9 proto kernel scope link src 192.168.210.2 metric 103
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-12-13 09:21:26 -05:00
Don Slice
f17b99ed17 zebra: handle neighbor delete from kernel for ipv4 link-local
Problem reported that kernel neighbor entries could end up in "FAILED"
state when the neighbor entry was deleted.  This fix handles the
notification of the event from netlink messages and re-inserts the
deleted entry.

Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2018-11-29 22:01:47 +01:00
Mark Stapp
78e54ded79 zebra: Fix netlink installation of recursive ecmp routes
Recursive multipath nexthops were broken by the initial async
dataplane - we were trying to install an extra, invalid
nexthop.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2018-11-13 10:21:16 -05:00
Mark Stapp
2577906481 zebra: revise struct names to resolve review comments
Use standard type naming and remove use of typedef to resolve
some review comments.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2018-10-25 08:57:04 -04:00
Mark Stapp
14c8b173d2 zebra: remove old apis after new dplane work
Replaced or out-grew a few zebra internal apis during async
dataplane work; removing them.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2018-10-25 08:57:04 -04:00
Mark Stapp
f183e380fa zebra: add handy res2str utility
Add a 2str utility for dplane result codes; use it in
a debug or two.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2018-10-25 08:57:04 -04:00
Mark Stapp
fe2c53d4ea zebra: Fix style issues
Clean up a couple of checkstyle reports in the dataplane
commit.

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
3659007663
zebra: dead code (Coverity 1473593)
Conditional code in netlink_macfdb_update() introduced in 2232a77c used
the 'dst_present' variable because not all cases were covered. Now it is
not necessary.

Signed-off-by: F. Aragon <paco@voltanet.io>
2018-09-25 16:56:08 +02:00
Russ White
a1b32de24e
Merge pull request #3052 from donaldsharp/dplane_2
Dplane 2
2018-09-24 10:54:16 -04: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
Mark Stapp
ea1c14f680 zebra: Create zebra_dplane.c and .h
Add first sketchy 'dplane' files.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-09-19 18:29:55 -04:00
vivek
a37f4598d7 zebra: Use boolean for certain VxLAN-EVPN flags
Use boolean variables instead of unsigned int for certain VxLAN-EVPN
flags which are really used as boolean.

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

Ticket: CM-22288
Reviewed By: CCR-7832
Testing Done:
Along with a subsequent, related commit
2018-09-18 10:41:53 -04:00
vivek
d63c1b18b4 zebra: Remove unused parameter in MAC delete
When a MAC moves from local to remote, a replace is allowed, EVPN
no longer has to delete the local MAC before installing the remote
MAC.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
Reviewed-by:   Chirag Shah <chirag@cumulusnetworks.com>
2018-09-18 10:41:53 -04:00
Donald Sharp
5523c15692 zebra: Send correct default vrf tableid for MROUTE stats
So the linux kernel uses the RT_TABLE_MAIN for the table
id used for ip routing.  The multicast routing tables use
RT_TABLE_DEFAULT.  We changed the internal code of zebra_vrf
a few months back to use RT_TABLE_MAIN as the tableid to
use.  This caused the pim sg stats to stop working because
of the kernel bug where it uses a different table
for ip routing and ip multicast.

Put a bit of a special case in to do the right thing.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-09-17 09:22:31 -04:00
Donald Sharp
c25e2f1ad1 zebra: Newer kernels send data about mroute changes
Newer linux kernels apparently send data down the netlink
bus for the creation of mroutes.  Add a bit of code
to notice this and to handle it appropriately( ie do
nothing at this point in time ) as that the correct
place to do this is in the pim socket in pimd.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-09-14 17:54:11 -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
e914ccbe9c zebra: ZEBRA_[ERR|WARN] -> EC_ZEBRA
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-13 19:23:29 +00:00
Donald Sharp
6efca3442f
Merge pull request #3007 from pacovn/static_analysis__shadow_variables2
lib vtysh zebra: variable shadowing fixes
2018-09-13 08:38:32 -04:00
David Lamparter
e991eff5b5 Merge remote-tracking branch 'frr/master' into warnings
Conflicts:
	zebra/if_ioctl_solaris.c
	zebra/rtread_getmsg.c

Signed-off-by: David Lamparter <equinox@diac24.net>
2018-09-12 21:58:39 +02:00
F. Aragon
c683bd446c
lib vtysh zebra: variable shadowing fixes
Signed-off-by: F. Aragon <paco@voltanet.io>
2018-09-12 12:27:38 +02:00
Quentin Young
364fed6b07 zebra: fix includes
Add and remove error related includes as necessary.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-06 20:56:41 +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
Christian Franke
da82f6b42a zebra: add RTPROT_FABRICD route type 197
Add an iproute2 route type for fabricd

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2018-09-05 11:38:12 +02:00
Donald Sharp
5b4256ca42 zebra: Fix crash in mroute debug
There exists a possibility that the ifindex we are passed
does not exist and as such we should check for it not
resolving as part of the debug.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-08-28 10:35:35 -04: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
Martin Winter
09890489cc
Merge pull request #2122 from donaldsharp/zebra_nhs
Create Staticd
2018-08-08 08:07:24 -07:00
Renato Westphal
c3d098ab30
Merge pull request #2726 from sworleys/Netlink-Filter-AFI
zebra: Ignore AF_ETHERNET and AF_MPLS in route change as well
2018-08-06 20:26:46 -03:00
Donald Sharp
51c4ed0a0e staticd, zebra: Fix up code warnings
CI found a couple of warnings that needed to be cleaned up.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-07-29 13:06:49 -04:00
Donald Sharp
40ecd8e46d lib, zebra: Allow protocols to use Distance as part of RR semantics
Allow protocols to specify to zebra that they would like zebra
to use the distance passed down as part of determine sameness for
Route Replace semantics.

This will be used by the static daemon to allow it to have
backup static routes with greater distances.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-07-29 12:43:23 -04:00
Stephen Worley
2e2b0fb3c2
Merge branch 'master' into Netlink-Prefix-Len-Check 2018-07-26 15:34:56 -04:00
Stephen Worley
e17d9b2dfe zebra: Make prefix length check return error
Prefix length validation checks should be returning an error
rather than 0. Switch to that and make them error messages.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2018-07-26 15:10:53 -04:00
Stephen Worley
8122787440 zebra: Format log for address family check
Switched the address family check to use unsigned format.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2018-07-25 14:08:24 -04:00
Stephen Worley
de1cd6b913 zebra: Ignore AF_ETHERNET and AF_MPLS in route_change as well
Remove AF_ETHERNET and AF_MPLS as valid address families for route
changes.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2018-07-25 14:02:00 -04:00
Russ White
4dbd617abd
Merge pull request #2704 from sworleys/Netlink-Nexthop-Hang
zebra: Add check for nexthop loop to prevent hanging
2018-07-24 19:42:11 -04:00
Russ White
bbc7adf1b4
Merge pull request #2665 from chiragshah6/evpn_dev
bgpd: support evpn nd ext community
2018-07-24 11:55:08 -04:00
Stephen Worley
758297039c Change log statements to use unsigned format
Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2018-07-24 11:14:07 -04:00
Christian Franke
1f610a1fb3 zebra: do not ignore ipv6 srcdest routes
Commit a2ca67d1d2 consolidated IPv4 and IPv6 handling. It also applied
our ignorance for IPv4 srcdest routes onto IPv6.

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2018-07-24 14:09:17 +02:00
Stephen Worley
3c04071d99 zebra: Add check for nexthop loop to prevent hanging
Bad nexthop messages from netlink were causing zebra
to hang here. Added a check to verify the length
of the nexthop so it doesn't keep trying to read.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2018-07-23 18:51:26 -04:00
Stephen Worley
adac720d77 Remove not needed filters and fix typos
Some more address family filters we can safely ignore
as well as typos in logger. Added AF_MPLS as filterable.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2018-07-23 15:08:37 -04:00
Stephen Worley
930571d24f zebra: Add check for prefix length from kernel messages
Zebra needed a check that varifies the prefix length
of an address is a valid length when receiving route
changes and interface address changes.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2018-07-23 14:21:59 -04:00
Stephen Worley
8a1b681cba zebra: Add address family filters
The zebra netlink socket was attempting to read netlink
messages with invalid address families in a couple areas.
Added filters and warn messages.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2018-07-23 12:11:02 -04:00
Chirag Shah
68e331515e bgpd: support evpn nd ext community
EVPN ND ext community support NA flag R-bit, to have proxy ND.

Set R-bit in EVPN NA if a given router is default gateway or there is a
local
router attached, which can be determine based on local neighbor entry.

Implement BGP ext community attribute to generate and parse  R-bit and
pass along zebra to program neigh entry in kernel.

Upon receiving MAC/IP update with community type 0x06 and sub_type 0x08,
pass the R-bit to zebra to program neigh entry.

Set NTF_ROUTER in neigh entry and inform kernel to do proxy NA for EVPN.

Ref:
https://tools.ietf.org/html/draft-ietf-bess-evpn-na-flags-01

Ticket:CM-21712, CM-21711
Reviewed By:
Testing Done:
Configure Local vni enabled L3 Gateway, which would act as router,
checked
show evpn arp-cache vni x ip <ip of svi> on originated and remote VTEPs.
"Router" flag is set.

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2018-07-17 13:06:41 -07:00
Donald Sharp
51034b787f
Merge pull request #2595 from pguibert6WIND/fix_netlink_rx_route_vrfnetns
zebra: upon RTM_NEWROUTE/DELROUTE, find appropriate interface
2018-07-12 22:22:34 -04:00
Mark Stapp
86391e5659 zebra, libs: use const prefix ptrs in apis
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-07-11 09:22:49 -04:00
Philippe Guibert
fac4d51eea zebra: upon RTM_NEWROUTE/DELROUTE, find appropriate interface
The interface lookup algorithm is different according to if we are on
netns vrf or not. If we are on the former case, then we only have to
parse the interfaces of the netns, while if we are on the other case, we
have to parse all the interfaces of all the vrfs ( since index is not
overlapping in the latter case).

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-07-10 17:32:23 +02:00
Donald Sharp
9bdf861803 zebra: Add error messages in places where we have a decode problem
When we receive a netlink message from the kernel we have
handler functions for when we send a netlink command, if these
return a failure ( < 0 ) then we output that we had a parse
issue.  But if all we get is:

2018-06-21T23:47:45.298156+00:00 qct-ix1-08 zebra[1484]: netlink-cmd (NS 0) filter function error

Then it is not very useful to figure out *where* the error happened.

Add more error code when in a decode path to hopefully allow us
to figure out where this message is coming from.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-06-25 10:02:48 -04:00
Donald Sharp
1e88567226 zebra: Add a result from dataplane request
Add a bit of code to allow return of data plane
request messages.

Add the ability to pass the result back to callers
of kernel_route_rib.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-05-30 08:03:13 -04:00
Donald Sharp
215181cbf1 zebra: Rename SOUTHBOUND_XXX to DP_XXX
The SOUTHBOUND_XXX enum was named a bit poorly.
Let's use a bit better name for what we are trying to do.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-05-30 08:00:55 -04:00
Russ White
e73f79ac4c
Merge pull request #2283 from donaldsharp/ignore_some_more
zebra: netlink cleanups
2018-05-27 11:02:15 -04:00
Donald Sharp
6ab5222f78 zebra: Add a breadcrumb for when we ignore a route
When we receive a route that we think we own and we
are not in startup conditions, then add a small debug
to help debug the issue when this happens, instead
of silently just ignoring the route.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-05-26 08:46:13 +02:00
Donald Sharp
d4d71f1133 tools, zebra: Use different protocol value for our statics
The re-use of RTPROT_STATIC has caused too many collisions
where other legitimate route sources are causing us to
believe we are the originator of the route.  Modify
the code so that if another protocol inserts RTPROT_STATIC
we will assume it's a Kernel Route.

Fixes: #2293
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-05-26 08:46:13 +02:00
Donald Sharp
2414abd3b0 zebra: Remove unnecessary function parameter
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-24 09:14:43 -04:00
Donald Sharp
6b093863ec zebra: Allow runtime determination of v6 RR semantics
The linux kernel is getting the same Route Replace semantics
for v6 that v4 uses.  Allow the end-user to know if their
kernel has this ability and if so to specify it so zebra
can take advantage of this.

Why not do auto-detection?  Because you would have to write
code in zebra to add a route then add the same route again
with different nexthops to see if which semantics it is using.
It sure is easier to just add a cli that allows the user to
do it.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-05-18 15:42:17 -04:00
Donald Sharp
5605ecfc1f zebra: memset buf to prevent uninited writes into kernel
Setup the buf used for extra data passed into kernel such
that we are cleaning it out before writing data to it,
so we can avoid writing uninited data.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-05-17 18:46:14 -04:00
vivek
6c0a605355 bgpd: Fix VRF route leaking for multipath routes
Ensure that the next hop of the leaked VRF is not overwritten when the
route is being imported into the target VRF from the VPN table. Also, in
the case of multipath routes, ensure that the nexthop's ifindex is not
inadvertently reset.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2018-05-08 19:24:15 -04:00
vivek
22e63104d2 bgpd, zebra: Handle EVPN router MAC per next hop
Ensure that when EVPN routes are installed into zebra, the router MAC
is passed per next hop and appropriately handled. This is required for
proper multipath operation.

Ticket: CM-18999
Reviewed By:
Testing Done: Verified failed scenario, other manual tests
Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2018-05-08 19:24:15 -04:00
Donald Sharp
0761368af0 zebra: Add PBR and SHARP handling
We are missing some handling of PBR and SHARP protocols
for netlink operations w/ the linux kernel.

Additionally add a bread crumb for new developers( or existing )
to know to fixup the rt_netlink.c when we start handling new
route types to hand to the kernel.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-04-27 14:59:52 -04:00
Quentin Young
bf094f6975 zebra: clean up zapi organization
zserv.c has become something of a dumping ground for everything vaguely
related to ZAPI and really needs some love. This change splits out the
code fo building and consuming ZAPI messages into a separate source
file, leaving the actual session and client lifecycle code in zserv.c.

Unfortunately since the #include situation in Zebra has not been paid
much attention I was forced to fix the headers in a lot of other source
files. This is a net improvement overall though.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-04-22 22:50:24 -04:00
Russ White
ea1c08342f
Merge pull request #2072 from donaldsharp/blackhole_this
zebra: Allow blackhole route deletion for prefixes
2018-04-20 07:58:03 -04:00
Donald Sharp
c766824c62 zebra: Allow blackhole route deletion for prefixes
With the recent change to just pass the prefix in
for the RTM_DELROUTE, for blackhole routes we
had stopped modifying the req.rtm_type to
be the appropriate type for blackhole routes.

Since we are just deleting on the route, and
zebra is never going to really install the same
route multiple times then we do not need
to specify the req.r.rtm_type for the deletion
command.

Ticket: CM-20616
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-04-16 18:42:40 -04:00
Mitesh Kanjariya
e9d2cbdebf zebra: add EVPN learned neighbors as NUD_NOARP
EVPN owns the remote neigh entries which are programed in the kernel.
This entries should not age out and the only way to delete should be
from EVPN. We should program these entries with NUD_NOARP instead of
NUD_REACHABLE to avoid aging of this macs.

Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2018-04-12 09:07:43 -04:00
Mitesh Kanjariya
ee69da278d zebra: act on kernel notifications for remote neighbors as well
There can be a race condition between kernel and frr as follows.
Frr sends remote neigh notification.
At the (almost) same time kernel might send a notification saying
neigh is local.
After processing this notifications, the state in frr is local while
state in kernel is remote. This causes kernel and frr to be out of sync.
This problem will be avoided if FRR acts on the kernel notifications for
remote neighbors. When FRR sees a remote neighbor notification for a
neighbor which it thinks is local, FRR will change the neigh state to remote.

Ticket: CM-19923/CM-18830
Review: CCR-7222
Testing: Manual

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2018-04-12 09:07:43 -04:00
Renato Westphal
0742ce0a86
Merge pull request #2043 from donaldsharp/v6_shenanigans
V6 shenanigans
2018-04-10 17:38:00 -03:00
Donald Sharp
c1d63a9346 zebra: Only send down pertinent information on RTM_DELROUTE
Background:

v6 does not have route replace semantics.  If you want to add a nexthop
to an existing route, you just send RTM_NEWROUTE and the new nexthop.
If you want to delete a nexthop you should just send RTM_DELROUTE
with the removed nexthop.

This leads to situations where if zebra is processing a route
and has lost track of intermediate nexthops( yes this sucks )
then v6 routes will get out of sync when we try to implement
route replace semantics.

So notice when we are doing a route delete and the route is
not being updated, just send the prefix and tell it too delete.

Ticket: CM-20391
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-04-09 14:16:00 -04:00
Donald Sharp
45df4e9667 zebra: Cleanup debugs and add a bit more info
This commit does 2 things:

1) When receiving a route from the kernel, display the incoming
table as part of the debug, to facilatate knowing what we are
talking about as part of the debug.

2) When displaying nexthop information for routes we were sending
to the kernel, no need to display the route information every time
Display the route then the individual nexthops for what we are doing.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-04-09 14:09:35 -04:00
Donald Sharp
20089ae2e4 zebra: Notice when our neighbor entry is removed and fight back
Notice when someone deletes a neighbor entry we've put in for
rfc-5549 gets deleted by some evil evil person.  When this happens
notice and push it back in, immediately.

Ticket: CM-18612
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-04-09 08:04:39 -04:00
Donald Sharp
7556c3fda8 zebra: Add table and nexthop vrf information to netlink debug
Add some additional debug information to the netlink debug
messages so we can see the table we are installing to as
well as the nexthop's vrf.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-29 08:58:45 -04:00
Quentin Young
d7c0a89a3a
*: use C99 standard fixed-width integer types
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>
2018-03-27 15:13:34 -04:00
Donald Sharp
7ee30f288e lib: Isolate nexthop_group functions to nexthop_group.c
Also modify `struct route_entry` to use nexthop_groups.
Move ALL_NEXTHOPS loop to nexthop_group.h

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-09 11:07:41 -05:00
Lou Berger
996c93142d *: conform with COMMUNITY.md formatting rules, via 'make indent'
Signed-off-by: Lou Berger <lberger@labn.net>
2018-03-06 14:04:32 -05:00
Philippe Guibert
009f8ad5f3 zebra: retrieve zns context from zvrf when netlink discovery
So as to get the correct NETNS where some discovery must be done and
populated, the zns pointer is directly retrieved from zvrf, instead of
checking that the VRF is a backend NETNS or not.
In the case where the interfaces are discovered before the VRF is enabled
( VRF-lite populate), then the default NS is retrieved.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-02-27 11:11:24 +01:00
Philippe Guibert
5895d33f40 zebra: ipv6 operations stick to namespace
All ipv6 operations stick to namespace.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-02-27 11:11:24 +01:00
Philippe Guibert
9a76375f39 zebra: route configuration fix for vrf when applied to namespaces
For each route to be added or deleted, instead of applying directly to
default namespaces, when a vrf is mapped to a namespace, then the
correct zns must be found out.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-02-27 11:11:24 +01:00
Philippe Guibert
78dd30b263 zebra: add a runtime flag to enable vrf with netns
The netns backend is chosen by VRF if a runtime flag named vrfwnetns is
selected when running zebra.
In the case the NETNS backend is chosen, in some case the VRFID value is
being assigned the value of the NSID. Within the perimeter of that work,
this is why the vrf_lookup_by_table function is extended with a new
parameter.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-02-27 11:10:41 +01:00
Renato Westphal
fa71296396 zebra: implement recursive MPLS labels
When a BGP-labeled route is resolved into an LDP-labeled IGP route,
zebra would install it with no labels in the kernel. This patch implements
recursive MPLS labels, i.e. make zebra install all labels from the route's
nexthop chain (the labels from the top-level nexthop being installed in
the top of the MPLS label stack). Multiple recursion levels are supported.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-02-19 13:22:57 -05:00
Donald Sharp
70e98a7fe7 *: Make code use a consisten definition of labels
Turns out we had 3 different ways to define labels
all of them overlapping with the same meanings.
Consolidate to 1.  This one choosen is consistent
naming wise with what the *bsd and linux kernels
use.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-02-08 20:31:37 -05:00
Donald Sharp
4a7371e9e2 *: Track vrfs per nexthop not per route entry
Track the vfrs on a per nexthop basis instead
of on a per route entry basis.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-02-08 19:35:53 -05:00
Donald Sharp
7d974ba3b7 zebra: Modify southbound interface to pass struct route_node
The route_node that we are working on is going to be interesting
to the kernel_route_rib_pass_fail.  So I am setting up the
code to allow me to pass it.  This will be done in a subsuquent
commit.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-01-24 08:22:57 -05:00
Philippe Guibert
d6fed38109
Merge pull request #1618 from donaldsharp/zebra_startup_ordering
zebra route-leaking for static routes
2018-01-23 08:25:01 +01:00
Donald Sharp
8ecdb26ec0 lib, zebra: Rename and place appropriately the label stack
Fix and rename the label stack to be better named.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-01-22 11:55:22 -05:00
Donald Sharp
5e21052204 zebra: Encode the ifindex over netlink
In order for routes to be leaked the ifindex must be sent
down into the kernel over the netlink protocol.  So
send it( we always figure it out ) when we add the
route.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-01-12 09:26:42 -05:00
Donald Sharp
8795f90448 zebra: Add nh_vrf_id to rib_add
Add to the rib_add function the ability to pass in the nexthops
vrf.

Additionally when we decode the netlink message from the linux
kernel, properly figure out the nexthops vrf_id.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-01-12 09:20:36 -05:00
Donald Sharp
8f43b4d886 zebra: Add nh_vrf_id to 'struct route_entry`
With VRF route-leaking we need to know what vrf
the nexthops are in compared to this vrf.  This
code adds the nh_vrf_id to the route entry and
sets it up correctly for the non-route-leaking
case.

The assumption here is that future commits
will make the nh_vrf_id *different* than
the vrf_id.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-01-12 09:20:30 -05:00
Mitesh Kanjariya
9bb77a5b3d
Merge branch 'master' into evpn-symmetric-routing 2018-01-11 09:00:23 -08:00
mitesh
6134fd82a0 zebra: proper refcounting for rmac/nh entries
Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.comy>
2017-12-14 10:57:06 -08:00
Kaloyan Kovachev
4e40b6d615 zebra: Add ability to support tags -> realms in linux
Linux has the ability to support a concept of 'realms'.
This concept allows you to mark routes with a realm id
value of 1-255.  If you have marked the realm
of a route then you can use the tc program to
apply policy to the routes.

This commit adds the ability of FRR to interpret
a tag from (1-255) as a realm when installing into
the kernel.  Please note that at this point in time
there is no way to set policy from within FRR.  This
must be done outside of it.

The normal methodology for setting tags is valid here
via a route-map.

Finally this is only applied if the --enable-realms configure
option is applied.

Signed-off-by: Kaloyan Kovachev <kkovachev@varna.net>
2017-12-14 09:44:44 -05:00
Donald Sharp
4a83e7a04a zebra: Fix lsp add/del from kernel using SETFLAG
Setup a interface such that the add/del of lsp's from
the kernel can have a callback for success/failure.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-11-29 13:01:00 -05:00
Donald Sharp
0c555cc6a5 zebra: Implement call back for route install/delete success/fail
When a route is installed or deleted into the kernel allow a
callback mechanism to handle the success/failure of
the kernel call.

This separation is to allow us to do these things:

1) In the future create a true pthread to handle route
install/deletes.  This way we can schedule these
events in a smarter fashion

2) Allow us to use a common southbound api for route
install and deletion.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-11-29 12:56:34 -05:00
Donald Sharp
8a71d93d85 sharpd: Add Super Happy Advanced Routing Protocol
Add a daemon that will allow us to test the zapi
as well as test route install/removal times from
the kernel.

The current commands are:

install route <starting ip address> nexthop <nexthop> (1-1000000)

This command starts installing at <starting ip address>/32
(1-100000) routes that it auto-increments by 1
Installation start time is noted in the log and finish
time is noted as well.

remove routes <starting ip address> (1-1000000)

This command removes routes at <starting ip address>/32
and removes (1-100000) routes created by the install route
command.

This code can be considered experimental and *is not*
something that should be run in a production environment.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-11-27 09:16:30 -05:00
Donald Sharp
e7fcb84341 zebra: V6 does not have route replace semantics
The v6 linux kernel netlink code doees not have
route replace semantics.  So if we are in that
situation, do a delete/add to get the correct
results.

Fixes: #1461
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-11-17 11:13:01 -05:00
Donald Sharp
3d468f6604 zebra: Move clear_nhlfe_installed to calling functions
The function clear_nhlfe_installed is to be called
when we get a install failure of some sort for
a lsp change.  Since an install failure can happen
in both linux and openBSD moving the function call
northbound is a good idea.

I've also added it to the kernel_del_lsp for completeness
on failure as well, even though neither linux or openBSD
currently can fail a uninstall.

This still leaves the hole where if we have multiple
nhlfes and have an install failure we are not quite
doing the right thing by just blanketly calling
clear_nhlfe_installed.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-27 10:41:07 -04:00
Donald Sharp
f7d9ebf4da Merge pull request #1356 from opensourcerouting/linux-headers
build: include our own copies of some linux kernel headers
2017-10-27 10:12:43 -04:00
Don Slice
8dc8a4b693 zebra: only pass mpls proto type if doing install
Problem reported with not deleting LSPs from the zebra kernal mpls table
when a delete occurred in bgp.  Found that we were exiting the delete
process incorrectly due to not being able to derive the route_type from
the best_nhlre on the lsp while deleting. Since this info was only
needed for route installation, removed this early exit in the case of
deleting the lsp.

Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
Ticket: CM-18309
Reviewed By: CCR-6781
Testing Done:  Manual testing looks good.  mpls tests successful
2017-10-25 08:19:22 -04:00
Renato Westphal
ba7773964c build: include our own copies of some linux kernel headers
This is the definitive solution to avoid build issues on old Linux
systems, where the system kernel headers might not contain some constants
or macros used by FRR (e.g. MPLS_IPTUNNEL_DST, introduced on 2015).

This is the same strategy adopted by other projects, like iproute2,
libnl, lldpd, strongswan, etc. These header files don't need to be in
sync with upstream, they only need to be updated when necessary (e.g. if
we want to use a new feature introduced by a recent kernel).

Fixes #962 using the solution suggested by David Lamparter.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-10-24 09:20:12 -02:00
Donald Sharp
5d920111b9 Merge pull request #1210 from opensourcerouting/misc-mpls-bgp-lu-fixes
Misc BGP-LU fixes
2017-10-10 12:19:37 -04:00
Renato Westphal
e56ab0e971 Merge pull request #1301 from donaldsharp/zebra_vxlan
Zebra vxlan
2017-10-10 09:00:44 -03:00
Renato Westphal
9a62e84b5b zebra: fix logging of MPLS labels
* use %u instead of %d, we don't want to print negative labels;
* increase the size of label_buf to accommodate the worst case scenarios;
* use strlcat() instead of strcat() as a security best practice.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-10-09 20:15:14 -03:00
Renato Westphal
09d0f308ce Merge pull request #1237 from donaldsharp/distance_special
zebra: Modify metric read to be admin distance and metric
2017-10-09 20:11:39 -03:00
Vincent JARDIN
792fa92ec1 zebra: fix clang warning
Set to 0 to avoid "Branch condition evaluates to a garbage value".

Signed-off-by: Vincent Jardin <vincent.jardin@6wind.com>
2017-10-08 23:47:43 +02:00
vivek
2853fed67a zebra: Handle L3 multi-tenancy correctly for EVPN
Fix following flaws that resulted in EVPN with L3 multi-tenancy (i.e.,
EVPN dealing with VxLAN routing in the presence of tenant VRFs) not
working properly:

1. EVPN enable ("advertise-all-vni") is a global command, ensure it is
accordingly processed. The config is maintained against the default VRF.
2. There was an incorrect attempt to derive the L3 VRF for L2 interfaces
- the VRF only applies for L3 interfaces, though the code may initialize
to the default value in other cases.
3. Functions to map (port, VLAN) to SVI or vice versa were incorrect -
particularly, zvni_map_svi() since it was looking in the L3 VRF for
"matching" L2 interface which it would never find. Fix.

In addition, since the 'zebra_vrf *' parameter is not relevant in most
places, it has been removed.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Mitesh Kanjariya <mitesh@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>

Ticket: CM-17840
Reviewed By: CCR-6685
Testing Done: evpn-smoke, various manual tests
2017-10-06 09:59:43 -04:00
Renato Westphal
310f64be93 Merge pull request #1240 from donaldsharp/allow_self_delete
zebra: Do not allow delete of route from kernel in non-startup case
2017-09-27 09:11:11 -03:00
Donald Sharp
5dfeba1904 zebra: Do not allow delete of route from kernel in non-startup case
This is a continuation of 915902cb82.  Basically the netlink
read of messages up from the kernel is now noticing the proper
owner of the route.  As such when rib_delete was being called
as part of the upcall from the kernel we were not noticing that
we were the originator and not diss-allowing the rib_delete
from happening.  This restores this behavior that we were getting
pre-915902cb82cfd

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-09-25 12:28:39 -04:00
Donald Sharp
25715c7e50 zebra: Modify metric read to be admin distance and metric
For ZEBRA_ROUTE_KERNEL types:

The metric/priority of the route received from the kernel
is a 32 bit number.  We are going to interpret the high
order byte as the Admin Distance and the low order 3 bytes
as the metric.

This will allow us to do two things:
1) Allow the creation of kernel routes that can be
   overridden by zebra.
2) Allow the old behavior for 'most' kernel route types
   if a user enters 'ip route ...' v4 routes get a metric
   of 0 and v6 routes get a metric of 1024.  Both of these
   values will end up with a admin distance of 0, which
   will cause them to win for the purposes of zebra.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-09-25 08:37:04 -04:00
Renato Westphal
8b1450b94d zebra: fix multihop/multipath confusion
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-09-21 13:27:50 -03:00
Renato Westphal
805444ce72 zebra: install MPLS LSPs with appropriate protocol type
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-09-21 13:27:50 -03:00
Renato Westphal
7990990e54 zebra: use the afi parameter in rib_add_multipath()
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-09-21 13:27:50 -03:00
Jafar Al-Gharaibeh
b1cebe20cd Merge pull request #1157 from donaldsharp/recursive_blackhole
Recursive blackhole resolution
2017-09-21 11:16:35 -05:00
Renato Westphal
a2addae8fe *: use clang's 'ForEachMacros' format style option
This fixes the broken indentation of several foreach loops throughout
the code.

From clang's documentation[1]:
  ForEachMacros: A vector of macros that should be interpreted as foreach
  loops instead of as function calls.

[1] http://clang.llvm.org/docs/ClangFormatStyleOptions.html

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-09-15 14:53:46 -03:00
David Lamparter
25b9cb0cc8 zebra: deduplicate nexthops
There exists situations where it is possible to have duplicate
nexthops passed from a higher level protocol into zebra.

This code notices this duplication of nexthops and marks
the duplicates as DUPLICATE so we don't attempt to install
it into the kernel.

This is important on *BSD as I understand it because passing
duplicate nexthops will cause the route to be rejected.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-09-12 10:05:07 -04:00
Donald Sharp
1f1d24a8f1 zebra: Allow recursively resolved blackhole routes to be installed
So the current code for a blackhole route assumed that you
would never want a recursively resolved blackhole to work.
Suppose you have this setup:

1) ip route 192.0.2.1/32 Null0
2) BGP installed with a route-map that rewrites the
   nexthop to 192.0.2.1.

Zebra will end up with a recursive nexthop that resolves
to the blackhole.

The original rib install function assumed that we would never
want the ability to recursively resolve a blackhole route.
Instead just handle the blackhole as part of the nexthop_num = 1
case.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-09-12 08:33:37 -04:00
Donald Sharp
915902cb82 zebra: Allow zebra to delete self originated routes
With the change to make zebra pass routes to the kernel
with the 'correct' proto name, it caused zebra to
not properly recognize them on startup again
the next time such that the route would not
be deleted.

Modify rt_netlink.c to notice that we have a
self originated route and to properly mark
the type of route it was.

Modify rib_table_sweep to mark the nexthops
as active so that when we go to delete the
self originated routes it would properly
delete from the kernel.

Fixes: #1061
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-09-05 18:56:36 -04:00
Renato Westphal
8ba5bd58aa zebra: allow blackhole routes from the kernel to be deleted
Fixes the following bug:
% ip -6 route add unreachable 4000::/64
% ip -6 route del unreachable 4000::/64
% vtysh -c "show ipv6 route"
[snip]
K>* 4000::/64 [0/1024] unreachable (ICMP unreachable)

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-08-31 22:14:48 -03:00
Renato Westphal
1dca2eaa5b zebra: fix compiler error introduced by previous commit
Lesson learned: always wait for the CI tests to finish before merging :)

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-08-31 20:58:16 -03:00
Donald Sharp
af760ec192 zebra: Allow bh_type to override nexthop selection
If we've set the bh_type to something besides BLACKHOLE_UNSPEC
due to the received route type being RTN_BLACKHOLE,
RTN_UNREACHABLE or RTN_PROHIBIT then just trust that
the nexthop is just what it is and set accordingly.

Fixes: #1082
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-08-31 19:36:06 -04:00
Renato Westphal
b3c18264e4 Merge pull request #1079 from qlyoung/fix-style-a
*: fix style
2017-08-31 13:22:55 -03:00
Jafar Al-Gharaibeh
959768e8d0 Merge pull request #1044 from donaldsharp/combination
Coverity Cleanup of Stuff
2017-08-31 10:25:55 -05:00
Quentin Young
60466a63f2
*: fix style
Fixes style nits introduced by recent pull requests.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-08-30 11:27:11 -04:00
David Lamparter
14f6aefe43 Merge pull request #998 from mkanjari/dev-master
Dev master
2017-08-29 20:03:48 +02:00
David Lamparter
e655a03c18 zebra: netlink: get blackhole routes from kernel
support processing of RTN_BLACKHOLE et al. from kernel and dump them
into appropriate blackhole rib entries.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-28 05:07:54 +02:00
David Lamparter
a830942228 zebra: cleanup blackhole support
blackhole support was horribly broken. cleanup by removing blackhole
stuff from ZEBRA_FLAG_*

introduces support for "prohibit" routes (Linux/netlink only)
also clean up blackhole options on "ip route" vty commands.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-28 05:07:51 +02:00
David Lamparter
fd36be7e15 zebra: rib: use nexthop ptr in rib_add/delete
This simplifies the API for the following blackhole rework.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-28 04:17:22 +02:00
Renato Westphal
0af35d90a1 *: fix assorted issues detected by Coverity Scan
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-08-24 21:49:39 -03:00
Mitesh Kanjariya
71349e0358 zebra: lookup link by ifindex
Frr has an assumption that when interface A links to B,
we already know about B. But that might be true always.
It is probably purely depends on the configuration
and how the interfaces are hashed in Kernel.
FRR seems to sometimes get "A is linked to B" before it knows about B,
in that case, the linkage between the data structure for A & B won't be proper.

Ticket: CM-17679
Review: ccr-6628
Testing: Manual

Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2017-08-20 06:10:38 -07:00
Donald Sharp
f19435a8b4 zebra: Pay attention to metric from kernel
When the linux kernel adds/deletes routes, the
metric is important, but our routing protocols
add/delete in a slightly different manner,
so allow kernel metrics to match so that our
rib matches the kernel's fib.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-08-09 09:17:20 -04:00
David Lamparter
c053ff8bff Merge pull request #899 from donaldsharp/ETH_ALEN
Fix Crash and Convert to ETH_ALEN
2017-08-05 05:19:01 +02:00
Donald Sharp
ff8b7eb870 zebra: Switch to using ETH_ALEN
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-08-04 09:06:14 -04:00
Jorge Boncompte
df0b13cf23 zebra: fix compilation in 32bit platform
RTA_PAYLOAD() return value depends on the platform bits.

make[5]: Nothing to be done for 'all-am'.
Making all in zebra
  CC       rt_netlink.o
../../zebra/rt_netlink.c: In function 'netlink_macfdb_change':
../../zebra/rt_netlink.c:1695:63: error: format '%ld' expects argument of type 'long int', but argument 7 has type 'unsigned int' [-Werror=format=]
    "%s family %s IF %s(%u) brIF %u - LLADDR is not MAC, len %ld",
                                                               ^
../../zebra/rt_netlink.c: In function 'netlink_ipneigh_change':
../../zebra/rt_netlink.c:2024:57: error: format '%ld' expects argument of type 'long int', but argument 6 has type 'unsigned int' [-Werror=format=]
      "%s family %s IF %s(%u) - LLADDR is not MAC, len %ld",
                                                         ^

Signed-off-by: Jorge Boncompte <jbonor@gmail.com>
2017-08-04 10:19:36 +02:00
Donald Sharp
0ecfe5bf38 Merge branch 'master' into PIM_VRF 2017-08-02 09:39:38 -04:00
David Lamparter
ddfeb48652 build: zebra: remove *_method Makefile hacks
replace with preprocessor checks in source files.  Much simpler...

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-31 23:03:30 +02:00
Donald Sharp
bd8b9272b4 zebra: Convert get_stats to use new kernel interface
Convert the XXX_get_stats functions to use the new
kernel interface.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-24 13:52:57 -04:00
Donald Sharp
e0ae31b886 lib, pimd, zebra: Allow pim to set pimregX into appropriate vrf
The pimregX devices when created by the kernel are put into
the default vrf.  When pim gets the callback that the device
exists, check to see if it is a pimregX device and if so
move it into the appropriate vrf.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-24 13:51:39 -04:00
Donald Sharp
43b5cc5ee6 zebra: Allow S,G lookup to use RTNL_FAMILY_IPMR
This current implementation unfortunately must
ask the kernel for all mroutes because vrf's
do not have the ability to request a single
mroute at this time.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-24 13:51:39 -04:00
whitespace / reindent
d62a17aede *: reindent
indent.py `git ls-files | pcregrep '\.[ch]$' | pcregrep -v '^(ldpd|babeld|nhrpd)/'`

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-17 14:04:07 +02:00
Donald Sharp
da571b7a6c Merge remote-tracking branch 'origin/master' into evpn_plus_struct_attr 2017-07-14 08:11:05 -04:00
Donald Sharp
eef83e96f7 Merge pull request #762 from bingen/mutiple_nh_recursive_levels
Allow for more than 1 NH recursion level
2017-07-14 07:44:02 -04:00
Donald Sharp
d5424e5356 lib: Fix some defines for older platforms
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-12 15:07:54 -04:00
vivek
c85c03c7f9 bgpd, zebra: Support for sticky MACs
Implement support for sticky (static) MACs. This includes the following:

- Recognize MAC is static (using NUD_NOARP flag) and inform BGP
- Construct MAC mobility extended community for sticky MACs as per
RFC 7432 section 15.2
- Inform to zebra that remote MAC is sticky, where appropriate
- Install sticky MACs into the kernel with the right flag
- Appropriate handling in route selection

Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by:   Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-12 14:37:14 -04:00
vivek
2232a77c2b zebra: MAC and Neighbor (ARP/ND) handling
Implement handling of MACs and Neighbors (ARP/ND entries) in zebra:
- MAC and Neighbor database handlers
- Read MACs and Neighbors from the kernel, when needed and create
entries in zebra's MAC and Neighbor databases.
- Handle add/update/delete notifications from the kernel for MACs and
Neighbors and update zebra's database appropriately
- Inform locally learnt MACs and Neighbors to client
- Handle MACIP add/delete from client and install appriporiate entries
into the kernel
- Since Neighbor entries will be installed on an SVI, implement the
needed mappings

NOTE: kernel interface is only implemented for Linux/netlink

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-12 12:29:25 -04:00
vivek
13d60d351c zebra: VNI and VTEP handling
Implement fundamental handling for VNIs and VTEPs:
- Handle EVPN enable/disable by client (advertise-all-vni)
- Create/update/delete VNIs based on VxLAN interface events and inform
client
- Handle VTEP add/delete from client and install into kernel
- New debug command for VxLAN/EVPN
- kernel interface (Linux/netlink only)

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-12 12:26:02 -04:00
David Lamparter
21bb7c8774 Merge commit '3d22338f04d9554fa' into evpn-prep
Conflicts:
	lib/Makefile.am

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-10 22:15:19 +02:00
ßingen
8e688dbd58 Rename ALL_NEXTHOPS_RO to ALL_NEXTHOPS 2017-07-10 21:14:59 +02:00
ßingen
f9e1b38e1a Allow for more than 1 NH recursion level
Before, only one level of recursive resolution was supported.

Signed-off-by: ßingen <bingen@voltanet.io>
2017-06-28 21:32:18 +02:00
David Lamparter
e885ed85bb Merge pull request #624 "Babel"
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-06-13 16:11:32 +02:00
David Lamparter
5da670a08b Merge pull request #703 from donaldsharp/nl_pid
zebra: When calling netlink, set the nl_pid as appropriate
2017-06-13 10:08:43 +02:00
David Lamparter
063221b5ad Merge pull request #700 "Coverity high"
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-06-13 10:05:51 +02:00
David Lamparter
97bd5c48de Merge remote-tracking branch 'frr/master' into pull-624 2017-06-13 09:18:14 +02:00
Donald Sharp
a55ba23ff7 zebra: When calling netlink, set the nl_pid as appropriate
This will allow us to further know that we originated the message.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-06-12 13:38:51 -04:00
Donald Sharp
43cb4d1106 zebra: Fix uninitialized memory access with src_p
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-06-10 16:36:32 -04:00
Donald Sharp
40078ccb05 tools, zebra: Allow zebra to insert babel routes as babel
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-06-08 08:56:36 -04:00
Donald Sharp
1f047d8d2c tools, zebra: Fix netlink notification of who owns the routes
For NHRP, EIGRP and LDP( This is for consistency as opposed to correctness )
assign some new values to routes to be installed into the kernel
so we can know who owns them later.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-06-08 08:51:25 -04:00
Donald Sharp
f0f77c9a59 zebra: Refactor 'struct rib' to be 'struct route_entry'
The 'struct rib' data structure is missnamed.  It really
is a 'struct route_entry' as part of the 'struct route_node'.
We have 1 'struct route_entry' per route src.  As such
1 route node can have multiple route entries if multiple
protocols attempt to install the same route.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-06-01 08:00:05 -04:00
Renato Westphal
6a2ef37ad0 zebra: fix installation of ipv4 labeled unicast routes
Rearrange the _netlink_route_build*() functions so the labels of the
nexthops are always installed, even for IPv4 routes with IPv6 nexthops.

Fixes Labeled Unicast with BGP Unnumbered.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-05-29 19:59:48 -03:00
Donald Sharp
66d4272752 zebra: Remove string operations from non-debug path
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-05-25 21:22:03 -04:00
Donald Sharp
8755598a08 zebra: Store commonly used values instead of regenerating
the ipv4_ll address used for 5549 routes does not need
to be figured out every single time that we attempt
to install/remove a route of that type.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-05-25 21:11:24 -04:00
vivek
289602d73d zebra: Format netlink requests correctly
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-25 10:20:03 -07:00
David Lamparter
896014f4bc *: make consistent & update GPLv2 file headers
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-05-15 16:37:41 +02:00
Dinesh G Dutt
23b1f33451 Add source of route as protocol string in ip route pushed into kernel
Ticket: CM-14313
Reviewed By:
Testing Done: bgpmin, ospfmin, bgp_kitchen_sink_test

'ip route show' displays all routes as belonging to protocol zebra.
The user has to run an additional command (in vtysh) to get the actual
source of a route (bgp/ospf/static etc.). This patch addresses that by
pushing the appropriate protocol string into the protocol field of the
netlink route update message. Now you can see routes with the correct
origin as well as filter on them (ip route show proto ospf).

'ospf' is used for both IPv4 and IPv6 routes, even though the OSPF
version is different in both cases.

Sample output (old):
9.9.12.13 via 69.254.2.38 dev swp3.2  proto zebra  metric 20
9.9.13.3  proto zebra  metric 20
        nexthop via 69.254.2.30  dev swp1.2 weight 1
        nexthop via 69.254.2.34  dev swp2.2 weight 1
        nexthop via 69.254.2.38  dev swp3.2 weight 1

Sample output (new):
9.9.12.13 via 69.254.2.38 dev swp3.2  proto bgp  metric 20
9.9.13.3  proto bgp  metric 20
        nexthop via 69.254.2.30  dev swp1.2 weight 1
        nexthop via 69.254.2.34  dev swp2.2 weight 1
        nexthop via 69.254.2.38  dev swp3.2 weight 1
2017-04-20 21:24:31 -04:00
Donald Sharp
7e2b760345 *: Remove non-vrf based ifindex lookup
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-03-15 10:26:53 -04:00
Renato Westphal
83456d1438 Merge pull request #233 from donaldsharp/ecmp1
bgpd, zebra: Allow setting ecmp from daemon cli
2017-03-03 12:42:52 -03:00
Donald Sharp
2f8685a255 zebra: Allow multiple rib deletes from linux kernel
The kernel can send a DELROUTE with a individual
nexthop.  Technically this is meant to delete that
individual nexthop from the route but zebra
has no way to do this currently.  So we just delete
the route.

V4 -> Never sends a DELROUTE with multiple nexthops
as a way to modify the rib.  It sends a a NEWROUTE
with RTM_REPLACE with the new appropriate route.

V6 -> Sends a DELROUTE with multiple nexthops
which is supposed to be interpreted as a
subtraction from the route.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-03-01 08:30:55 -05:00
Donald Sharp
a2ca67d1d2 zebra: Add multipath parsing to V6
In the near future it will be possible to recieve v6 multipath netlink
messages.  This code change is in prep for it.  In the meantime the
v6 code path will continue to work as per normal.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-03-01 08:30:50 -05:00
Donald Sharp
89a9069abb zebra: Refactor netlink_route_change and netlink_route_change_read_unicast
These two functions were basically the same.  Refactor to be
one function.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-03-01 08:08:05 -05:00
Donald Sharp
936ebf0a2d zebra: Add knowledge of whether or not we are acting under startup conditions
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-03-01 08:08:05 -05:00