Commit Graph

655 Commits

Author SHA1 Message Date
Donald Sharp
dd50eeb115 lib, zebra: Remove unused flag
The NEXTHOP_FLAG_FILTERED went away when we started treating
static routes like every other route in the system.  This was
a special case for handling static route code that just didn't
get finished cleaning up.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-04-18 14:57:54 -04:00
Donald Sharp
99eabcec1a zebra: nexthop_active_update does not need set
We are effectively calling nexthop_active_update() on every
route entry being processed for installation at least 2 times.
This is a bit ridiculous.  We need to resolve the nexthops
when we know a route has changed in some manner, so do so.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-04-18 14:57:54 -04:00
Renato Westphal
e412d3b8d9 lib: move zlog() prototype back to the public logging API
zlog() should be part of the public logging API as it's useful in
the cases where the logging priority isn't known at compile time
(i.e. it depends on a variable).

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-04-18 13:15:13 -03:00
David Lamparter
7e3a1ec742 lib: ZEBRA_NUM_OF -> array_size
The latter is widely used, e.g. in the Linux kernel.

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-04-18 12:44:29 +02:00
Mark Stapp
cf363e1bd8 zebra: dataplane notifications for system route changes
Add notifications from zebra to the dataplane subsystem when
kernel or connected routes change.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-04-10 16:07:01 -04:00
Mark Stapp
f4c6e2a815 zebra: remove unused VRF_RIB_SCHEDULED flag
We don't use th vrf-level VRF_RIB_SCHEDULED flag any longer;
remove it and collapse the zebra_vrf flags' values.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-04-05 08:46:28 -04:00
Donald Sharp
a1494c250c zebra: Modify lsp processing to be invoked as needed
LSP processing was a zvrf flag based upon a connected route
coming or going.  But this did not allow us to know
that we should do lsp processing other than after the meta-queue
processing was finished.

Eventually we moved meta-queue processing of do_nht_processing
to after the dataplane sent the main pthread some results.
This of course left us with a timing hole where if a connected
route came in and we received a data plane response *before*
the meta queue was processed we would not do the work as necessary.

Move the lsp processing to a flag off of the rib_dest_t. If it
is marked then we need to process lsps.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-03-27 16:22:22 -04:00
Donald Sharp
50872b0804 zebra: Add detailed debugging command for NHT tracking
Add a detailed debugging command for NHT tracking and add
the detailed output to the log about why we make some decisions
that we are.  I tried to model this like the rib processing
detailed debugs that we added a few months back.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-03-27 16:22:22 -04:00
Donald Sharp
699dae230d zebra: Modify NHT to occur when needed.
Currently nexthop tracking is performed for all nexthops that
are being tracked after a group of contexts are passed back
from the data plane for post install processing.

This is inefficient and leaves us sending nexthop tracking
changes at an accelerated pace, when we think we've changed
a route.  Additionally every route change will cause us
to relook at all nexthops we are tracking irrelevant if
they are possibly related to the route change or not.

Let's modify the code base to track the rnh's off of the rib
table's rn, `rib_dest_t`.  So after we process a node, install
it into the data plane, in rib_process_result we can
look at the `rib_dest_t` associated with the rn and see that
a nexthop depended on this route node.  If so, refigure it.

Additionally we will store rnh's that are not resolved on the
0.0.0.0/0 nexthop tracking list.  As such when a route node
changes we can quickly walk up the rib tree and notice that
it needs to be reprocessed as well.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-03-27 16:22:22 -04:00
Donald Sharp
c86ba6c283 zebra: Add a base node for the zebra vrf tables
Add a default route_node for our routing tables.  This will allow us
to know that we can hang data off the default route for processing.

We will be hanging the nexthop tracking data structures off the rib_dest_t
so that we can know which nexthops we need to handle.  Effectively
nexthops that we are tracking that are unresolved will be stored on the
default route.  When something changes in the rib tree we can
work up the rn->parent pointer checking for nexthops we need to re-evaluate.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-03-27 16:19:28 -04:00
Donald Sharp
434434f704 zebra: Abstract the rib_dest_t creation
Abstract the creation of the rib_dest_t so that we can call it
from multiple places.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-03-27 16:19:28 -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
Donald Sharp
7a230a9d0c zebra: On route install/update failure correctly indicate in rib
When we get a route install failure from the kernel, actually
indicate in the rib the status of the routes.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-03-27 16:19:28 -04:00
Donald Sharp
9ef0c6ba87 zebra: Unset old_re as queued.
When switching routes from one route type to another actually
unset the old route as enqueued.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-03-27 16:19:28 -04:00
Quentin Young
73fb891892 Revert "Merge pull request #3982 from pacovn/Coverity_1479148_copy_paste"
This reverts commit 3a3704fe36, reversing
changes made to 5a3c6e736d.
2019-03-20 21:25:04 +00:00
F. Aragon
23fbacb455
zebra: copy-paste error (Coverity 1479148)
Signed-off-by: F. Aragon <paco@voltanet.io>
2019-03-20 16:45:32 +01:00
Donald Sharp
b900245adc zebra: System routes sometimes can not be properly selected
System Routes if received over the netlink bus in a
specific pattern that causes an update operation for that
route in zebra can leave the dest->selected_fib pointer NULL,
while having the ZEBRA_FLAG_SELECTED flag set. Specifically
one way to achieve this is to do this:

`ip addr del 4.5.6.7/32 dev swp1 ; ip addr add 4.5.6.7/32 dev swp1 metric 9`

Why is this a big deal?
Because nexthop tracking is looking at ZEBRA_FLAG_SELECTED to
know if we can use a route, while nexthop active checking uses
dest->selected_fib.

So imagine we have bgp registering a nexthop. nexthop tracking in
the above case will be able to choose the 4.5.6.7/32 route
if that is what the nexthop is, due to the ZEBRA_FLAG_SELECTED being
properly set. BGP then allows the peers connection to come up and we
install routes with a 4.5.6.7 nexthop. The rib processing for route
installation will then look at the 4.5.6.7 route see no
dest->selected_fib and then start walking up the tree to resolve
the route. In our case we could easily hit the default route and be
unable to resolve the route. Which then becomes inactive in the
rib so we never attempt to install it.

This commit fixes this problem because when the rib_process decides
that we need to update the fib( ie replace old w/ new ), the
replacement with new was not setting the `dest->selected_fib` pointer
to the new route_entry, when the route was a system route.

Ticket: CM-24203
Signed-off-by: Donald Sharp <sharpd@cumulusnetworkscom>
2019-03-15 10:02:11 -04:00
David Lamparter
d3b05897ed
Merge pull request #3869 from qlyoung/cocci-fixes
Assorted Coccinelle fixes
2019-03-06 15:54:44 +01:00
vivek
2b83602b24 *: Explicitly mark nexthop of EVPN-sourced routes as onlink
In the case of EVPN symmetric routing, the tenant VRF is associated with
a VNI that is used for routing and commonly referred to as the L3 VNI or
VRF VNI. Corresponding to this VNI is a VLAN and its associated L3 (IP)
interface (SVI). Overlay next hops (i.e., next hops for routes in the
tenant VRF) are reachable over this interface. Howver, in the model that
is supported in the implementation and commonly deployed, there is no
explicit Overlay IP address associated with the next hop in the tenant
VRF; the underlay IP is used if (since) the forwarding plane requires
a next hop IP. Therefore, the next hop has to be explicit flagged as
onlink to cause any next hop reachability checks in the forwarding plane
to be skipped.

https://tools.ietf.org/html/draft-ietf-bess-evpn-prefix-advertisement
section 4.4 provides additional description of the above constructs.

Use existing mechanism to specify the nexthops as onlink when installing
these routes from bgpd to zebra and get rid of a special flag that was
introduced for EVPN-sourced routes. Also, use the onlink flag during next
hop validation in zebra and eliminate other special checks.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>
2019-02-27 12:54:24 +00:00
Quentin Young
9f2d035447 *: remove useless return variables
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-02-25 23:00:16 +00:00
Donald Sharp
5f27bcba2a zebra: Fix use after free in rib_process_result
Running zebra after commit 888756b208
in valgrind produces this item:

==17102== Invalid read of size 8
==17102==    at 0x44D84C: rib_dest_from_rnode (rib.h:375)
==17102==    by 0x4546ED: rib_process_result (zebra_rib.c:1904)
==17102==    by 0x45436D: rib_process_dplane_results (zebra_rib.c:3295)
==17102==    by 0x4D0902B: thread_call (thread.c:1607)
==17102==    by 0x4CC3983: frr_run (libfrr.c:1011)
==17102==    by 0x4266F6: main (main.c:473)
==17102==  Address 0x83bd468 is 88 bytes inside a block of size 96 free'd
==17102==    at 0x4A35F54: free (vg_replace_malloc.c:530)
==17102==    by 0x4CCAC00: qfree (memory.c:129)
==17102==    by 0x4D03DC6: route_node_destroy (table.c:501)
==17102==    by 0x4D039EE: route_node_free (table.c:90)
==17102==    by 0x4D03971: route_node_delete (table.c:382)
==17102==    by 0x44D82A: route_unlock_node (table.h:256)
==17102==    by 0x454617: rib_process_result (zebra_rib.c:1882)
==17102==    by 0x45436D: rib_process_dplane_results (zebra_rib.c:3295)
==17102==    by 0x4D0902B: thread_call (thread.c:1607)
==17102==    by 0x4CC3983: frr_run (libfrr.c:1011)
==17102==    by 0x4266F6: main (main.c:473)
==17102==  Block was alloc'd at
==17102==    at 0x4A36FF6: calloc (vg_replace_malloc.c:752)
==17102==    by 0x4CCAA2D: qcalloc (memory.c:110)
==17102==    by 0x4D03D88: route_node_create (table.c:489)
==17102==    by 0x4D0360F: route_node_new (table.c:65)
==17102==    by 0x4D034F8: route_node_set (table.c:74)
==17102==    by 0x4D03486: route_node_get (table.c:327)
==17102==    by 0x4CFB700: srcdest_rnode_get (srcdest_table.c:243)
==17102==    by 0x4545C1: rib_process_result (zebra_rib.c:1872)
==17102==    by 0x45436D: rib_process_dplane_results (zebra_rib.c:3295)
==17102==    by 0x4D0902B: thread_call (thread.c:1607)
==17102==    by 0x4CC3983: frr_run (libfrr.c:1011)
==17102==    by 0x4266F6: main (main.c:473)
==17102==

This is happening because of this order of events:

1) Route is deleted in the main thread and scheduled for rib processing.
2) Rib garbage collection is run and we remove the route node since it
is no longer needed.
3) Data plane returns from the deletion in the kernel and we call
the srcdest_rnode_get function to get the prefix that was deleted.
This recreates a new route node.  This creates a route_node with
a lock count of 1, which we freed via the route_unlock_node call.
Then we continued to use the rn pointer.  Which leaves us with use
after frees.

The solution is, of course, to just move the unlock the node at the
end of the function if we have a route_node.

Fixes: #3854
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-02-23 20:03:48 -05:00
Mark Stapp
5c111895d6 zebra: unlock route-node in dplane results handler
Unlock the route-node struct we look up while processing
async dataplane results.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-02-21 16:15:14 -05:00
Mark Stapp
8263d1d0d9 zebra: use update semantics for routes consistently
Use 'update' semantics for route updates, to ensure that
netlink replace behavior works correctly.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-02-11 16:11:02 -05:00
David Lamparter
b7777b57c4
Merge pull request #3722 from donaldsharp/static_recursive
Zebra fixes
2019-02-07 19:22:29 +01:00
Donald Sharp
4634d02cfd
Merge pull request #3684 from mjstapp/dplane_pw
zebra: async dataplane for pseudowires
2019-02-05 18:41:12 -05:00
Donald Sharp
6c47d39902 zebra: Fix multiple levels of static recursion
Allow the nexthop-check code to figure out recursive static routes
in a logical manner.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-02-05 15:21:26 -05:00
Donald Sharp
46a4e3455b zebra: NHT was being run at least 2 times and missreporting data
With the data plane changes that were made, we are now running
nexthop tracking 2 times.  Once at the end of meta-queue insertion
and once at the end of receiving a bunch of data from the dataplane.

The Addition of the data plane code caused flags to not be set
fully for the resolved routes( since we do not know the answer yet ),
This in turn caused the nexthop tracking run after the meta-queue
to think that the route was not `good`.  This would cause it to
tell all interested parties that there was no nexthop.

After the dataplane insertion we are also no running nht code.
This was re-figuring out the nexthop correctly and also
correctly reporting to interested parties that there was a path again.

Example:
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, q - queued route, f - failed route

K>* 0.0.0.0/0 [0/103] via 10.50.11.1, enp0s3, 00:06:47
S>* 4.5.6.7/32 [1/0] via 192.168.209.1, enp0s8, 00:04:47
C>* 10.50.11.0/24 is directly connected, enp0s3, 00:06:47
C>* 192.168.209.0/24 is directly connected, enp0s8, 00:06:47
C>* 192.168.210.0/24 is directly connected, enp0s9, 00:06:47
donna.cumulusnetworks.com(config)# ip route 4.5.6.7/32 192.168.210.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, q - queued route, f - failed route

K>* 0.0.0.0/0 [0/103] via 10.50.11.1, enp0s3, 00:07:06
S>* 4.5.6.7/32 [1/0] via 192.168.209.1, enp0s8, 00:00:04
  *                  via 192.168.210.1, enp0s9, 00:00:04
C>* 10.50.11.0/24 is directly connected, enp0s3, 00:07:06
C>* 192.168.209.0/24 is directly connected, enp0s8, 00:07:06
C>* 192.168.210.0/24 is directly connected, enp0s9, 00:07:06
donna.cumulusnetworks.com(config)#

Log files for sharp, which is watching 4.5.6.7:
2019/02/04 15:20:54.844288 SHARP: Received update for 4.5.6.7/32
2019/02/04 15:20:54.844820 SHARP: Received update for 4.5.6.7/32
2019/02/04 15:20:54.844836 SHARP: 	Nexthop 192.168.209.1, type: 2, ifindex: 3, vrf: 0, label_num: 0
2019/02/04 15:20:54.844853 SHARP: 	Nexthop 192.168.210.1, type: 2, ifindex: 4, vrf: 0, label_num: 0

As you can see we have received an update with no nexthops( invalid route )
and a second update immediately after it with 2 nexthops.

What's the big deal you say?  Well we have code in other daemons that reacts
to not having a path for a nexthop.  In BGP this will cause us to tear
down the peer.  In staticd we'll remove the recursively resolved route.
In pim we'll remove all paths to the mroute.  This is not desirable.

The fix is to remove the meta-queue run of nexthop tracking.

While running after data plane notice of routes to handle is not ideal
we will be fixing this in the future with the nexthop group code, which
should know what nexthops are affected by a nexthop group change.

Fixed code debug code:
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, q - queued route, f - failed route

K>* 0.0.0.0/0 [0/103] via 10.50.11.1, enp0s3, 00:00:46
S>* 4.5.6.7/32 [1/0] via 192.168.209.1, enp0s8, 00:00:02
C>* 10.50.11.0/24 is directly connected, enp0s3, 00:00:46
C>* 192.168.209.0/24 is directly connected, enp0s8, 00:00:46
C>* 192.168.210.0/24 is directly connected, enp0s9, 00:00:46
donna.cumulusnetworks.com(config)# ip route 4.5.6.7/32 192.168.210.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, q - queued route, f - failed route

K>* 0.0.0.0/0 [0/103] via 10.50.11.1, enp0s3, 00:00:59
S>* 4.5.6.7/32 [1/0] via 192.168.209.1, enp0s8, 00:00:02
  *                  via 192.168.210.1, enp0s9, 00:00:02
C>* 10.50.11.0/24 is directly connected, enp0s3, 00:00:59
C>* 192.168.209.0/24 is directly connected, enp0s8, 00:00:59
C>* 192.168.210.0/24 is directly connected, enp0s9, 00:00:59

2019/02/04 15:26:20.656395 SHARP: Received update for 4.5.6.7/32
2019/02/04 15:26:20.656440 SHARP: 	Nexthop 192.168.209.1, type: 2, ifindex: 3, vrf: 0, label_num: 0
2019/02/04 15:26:33.688251 SHARP: Received update for 4.5.6.7/32
2019/02/04 15:26:33.688322 SHARP: 	Nexthop 192.168.209.1, type: 2, ifindex: 3, vrf: 0, label_num: 0
2019/02/04 15:26:33.688329 SHARP: 	Nexthop 192.168.210.1, type: 2, ifindex: 4, vrf: 0, label_num: 0

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-02-05 09:17:02 -05:00
Donald Sharp
2561d12e5d zebra: Remove struct zebra_t
This structure is unused anymore and does not belong in zserv.h

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-01-31 09:20:46 -05:00
Donald Sharp
ea45a4e7db zebra: Move the mq data structure to zrouter
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-01-31 09:20:46 -05:00
Donald Sharp
489a961429 zebra: Move ribq from zebrad to zrouter
The zrouter should own this data structure and it should not
be defined in zserv.h

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-01-31 09:20:46 -05:00
Donald Sharp
b3d43ff471 zebra: Move rtm_table_default to zrouter
The zrouter should own this particular piece of data.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-01-31 09:20:46 -05:00
Donald Sharp
3801e7646c zebra: Move the master thread handler to the zrouter structure
The master thread handler is really part of the zrouter structure.
So let's move it over to that.  Eventually zserv.h will only be
used for zapi messages.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-01-31 09:20:46 -05:00
David Lamparter
19b336d343
Merge pull request #3699 from donaldsharp/zebra_rib_debugs
Zebra Respect my authority
2019-01-31 01:51:52 +01:00
Donald Sharp
b9f0e5ee24 zebra: On route update context is sometimes indeterminate in post-processing
When we get into rib_process_result and the operation we are handling
is DPLANE_OP_ROUTE_UPDATE *and* the route entry being looked at
is a route replace, we currently have no way to decode to the old_re
and the re due to how we have stored context.  As such they are the
same pointer.

As such the route replace for the same route type is causing the re
to set the installed flag and then immediately unset the installed
flag, leaving us in a state where the kernel has the route but
the rib thinks we are not installed.

Since the true old_re( the one being replaced by the update operation )
is going away( as that it zebra deletes the old one for us already )
this fix is not optimal but will get us moving forward.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-01-30 09:52:13 -05:00
Donald Sharp
058c16b7e2 zebra: Trust kernel and System routes
If we receive a valid message from the kernel that
is either a kernel or system route, we should trust
that the route is legit and just use it.

Old behavior:

K * 172.22.0.0/15 [0/0] via 172.22.2.254, eva_dummy1 inactive, 00:00:16

New Behavior:

K>* 172.22.0.0/15 [0/0] via 172.22.2.254, eva_dummy1, 00:02:35

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-01-29 21:45:02 -05:00
Donald Sharp
2da33d6b3a zebra: Convert route entry id number to string in debugs
The route entry being displayed in debugs was displaying
the originating route type as a number.  While numbers
are cool, I for one am not terribly interested in
memorizing them.  Modify the (type %d) to a (%s) to
just list the string type of the route.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-01-29 21:35:07 -05:00
Russ White
2538f1dad7
Merge pull request #3681 from donaldsharp/onlink
*: The onlink attribute should be owned by the nexthop not the route.
2019-01-29 10:09:44 -05:00
Donald Sharp
fe85601c96 *: The onlink attribute should be owned by the nexthop not the route.
The onlink attribute was being passed from upper level protocols
as an attribute of the route *not* the individual nexthop.  When
we pass this data to the kernel, we treat the onlink as a attribute
of the nexthop.  This commit modifies the code base to allow
us to pass the ONLINK attribute as an attribute of the nexthop.

This commit also fixes static routes that have multiple nexthops
some onlink and some not.

ip route 4.5.6.7/32 192.168.41.1 eveth1 onlink
ip route 4.5.6.7/32 192.168.42.2

S>* 4.5.6.7/32 [1/0] via 192.168.41.1, eveth1 onlink, 00:03:04
  *                  via 192.168.42.2, eveth2, 00:03:04

sharpd@robot ~/frr2> sudo ip netns exec EVA ip route show
4.5.6.7 proto 196 metric 20
	nexthop via 192.168.41.1 dev eveth1 weight 1 onlink
	nexthop via 192.168.42.2 dev eveth2 weight 1

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-01-26 21:02:26 -05:00
Donald Sharp
60f98b236e zebra: Keep track of when routes are queued/dequeued from the dataplane
When we process the dataplane data, keep track of whether or not a route
is in transit or not.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-01-25 20:16:15 -05:00
Donald Sharp
677c1dd5cb zebra: Use ROUTE_ENTRY_INSTALLED as decision for route is installed
zebra is using NEXTHOP_FLAG_FIB as the basis of whether or not
a route_entry is installed.  This is problematic in that we plan
to separate out nexthop handling from route installation.  So modify
the code to keep track of whether or not a route_entry is installed/failed.

This basically means that every place we set/unset NEXTHOP_FLAG_FIB, we
actually also set/unset ROUTE_ENTRY_INSTALLED on the route_entry.
Additionally where we check for route installed via NEXTHOP_FLAG_FIB
switch over to checking if the route think's it is installed.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-01-25 20:16:15 -05:00
Mark Stapp
9bd9717bb2 zebra: add handler for pw install errors
Add handler for async error results from the dataplane for
pseudowire installation attempts.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-01-25 10:45:57 -05:00
Donald Sharp
313731ac92
Merge pull request #3630 from opensourcerouting/fix-show-import-check
zebra: fix the "show ip import-check" command
2019-01-22 20:10:56 -05:00
Mark Stapp
d37f4d6c61 zebra: move LSP updates into dataplane subsystem
Start performing LSP updates through the async dataplane
subsystem. This is plumbed through for linux/netlink.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-01-22 13:56:48 -05:00
Renato Westphal
73bf60a06b zebra: consolidate how we indentify address-families in the NHT code
Favor usage of the afi_t enumeration to identify address-families
over using the classic AF_INET[6] constants for that. The choice to
use either of the two seems to be mostly arbitrary throughout our
code base, which leads to confusion and bugs like the one fixed by
commit 6f95d11a1. To address this problem, favor usage of the afi_t
enumeration whenever possible, since 1) it's an enumeration (helps
the compilers to catch some bugs), 2) has a safi_t sibling and 3)
can be used to index static arrays. AF_INET[6] should then be used
only when interfacing with the kernel or external libraries like
libc. The family2afi() and afi2family() functions can be used to
convert between the two different representations back and forth.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-01-21 13:26:36 -02:00
Donald Sharp
12e7fe3aa0 zebra: Add a switch statement for rib_process_after
Future commits are going to introduce more rigor in
state setting in the case of received results from
the data plane.  So let us move the DPLANE_OP_ROUTE_DELETE
state check to the same spot as the rest of the code that
is handling a particular operation.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-01-11 11:48:14 -05:00
Donald Sharp
f52ed67796 zebra: Limit meta_queue insertion to one time.
Modify the meta_queue insertion such that we only enqueue
the route_node into one meta_queue instead of several.

Suppose we have multiple route_entries associated with
a particular node from rip, bgp, staticd.  If we receive a
route update from rip, we would enqueue the route_node into
the 1, 2, 3 meta-nodes.  Which means that we would run
the entire process of figuring out a route 3 times, while
nothing would change the second two times.

Modify the code to choose the lowest meta-queue and
install it into that one for processing.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-01-11 11:48:14 -05:00
Donald Sharp
9d5a82a5c2
Merge pull request #3526 from mjstapp/dplane_lists
zebra: pass lists of results from dataplane to zebra
2019-01-10 19:20:35 -05:00
Mark Stapp
4c206c8f74 zebra: pass lists of results from dataplane to zebra
Pass lists of results back to zebra from the dataplane subsystem
(and pthread). This helps reduce the lock/unlock cycles when
zebra is busy. Also remove a couple of typedefs that made their
way into the dataplane header file - those violate the FRR style
guidelines.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-01-10 13:24:13 -05:00
Donald Sharp
73547a754e zebra: Consolidate meta_queue_map into route_info
The route_info data structure already had a mapping of route type
to admin distance.  Consolidate the meta_queue_map information
into this route_info data structure.  This is to reduce the number
of places we need to remember to touch when adding a new routing
protocol.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-01-02 09:15:30 -05:00
Donald Sharp
85c3d6005e
Merge pull request #3464 from mjstapp/wq_event
libs,zebra: support timeout for workqueue retries, use for rib
2018-12-14 10:00:49 -05:00
Donald Sharp
dba52387b7 zebra: On route removal failure return proper message
When a route removal failure happens return to the installing
protocol that the route deletion failed.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-12-13 20:00:33 -05:00
Mark Stapp
6dd7b84894 zebra: use a small retry timeout for the rib workqueue
In the zebra rib processing workqueue, set a small timeout
so that we will wait a short time if the queue into the
async dataplane is full. This helps avoid a situation where
the zebra main pthread constantly retries rib work without
giving the dataplane pthread a chance to make progress.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2018-12-13 14:15:27 -05:00
Russ White
f4aaa03907
Merge pull request #3477 from donaldsharp/multipath_respect
zebra: Allow zebra to only mark up to multipath_num nexthops as ACTIVE
2018-12-13 10:41:26 -05:00
Russ White
eefe8ab766
Merge pull request #3467 from donaldsharp/kernel_socket_cleanup
Kernel socket cleanup
2018-12-13 10:32:09 -05: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
Donald Sharp
c626d369fd zebra: Remove rib_lookup_ipv4_route
The rib_lookup_ipv4_route function is only used in a debug path.
Is only used for v4 and only checks to make sure that the rib
and fib are in sync( which is not needed/used/supported on other
platforms ).  So let's just remove it.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-12-12 11:54:12 -05:00
Donald Sharp
0dddbf72ec zebra: Convert nexthop_active functions to use bool
The set value was only being used as a bool, formalize this
in the call chain.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-12-10 10:21:41 -05:00
Mark Stapp
68b375e059 zebra: revise dplane dequeue api
Change the dataplane context dequeue api used by zebra to make the
purpose a bit clearer.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2018-11-21 10:38:08 -05:00
Mark Stapp
c831033fff zebra: dataplane provider enhancements
Limit the number of updates processed from the incoming queue;
add more stats. Fill out apis for dataplane providers; convert
route update processing to provider model; move dataplane
status enum

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2018-11-21 10:37:54 -05:00
Donald Sharp
effcfaeb3d zebra: Carry onlink if set from resolving nexthop
When resolving a nexthop, carry the onlink flag if it
is set to the new nexthop.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-11-07 11:28:01 -05:00
Mark Stapp
258c07e4e2 zebra: only uninstall once, when closing rib table
When the rib code is informed that a table is closing/
going away, only try once to uninstall associated routes from
the fib/dataplane. The close path can be called multiple times
in some cases - zebra shutdown, e.g.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2018-10-30 09:41:55 -04:00
Donald Sharp
69c19e1def
Merge pull request #2946 from mjstapp/dplane_2
Zebra: async dataplane, phase 1
2018-10-28 16:10:45 -04:00
Mark Stapp
8b962e7759 zebra: rebase dataplane, align with master
Rebase and pick up dataplane changes on master, including
renamed structs and enums.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2018-10-25 08:57:04 -04:00
Mark Stapp
91f1681258 zebra: limit queued route updates
Impose a configurable limit on the number of route updates
that can be queued towards the dataplane subsystem.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2018-10-25 08:57:04 -04: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
1bcea841b1 zebra: netlink fuzzing path correction
Correct use of netlink_parse_info() in the netlink fuzzing path.
Also clarify a couple of comments about pthreads.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2018-10-25 08:34:30 -04:00
Mark Stapp
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
5af4b34689 zebra: ensure redist of system routes
We need a bit of special handling for system routes, which need
to be offered for redistribution even though they won't be
passing through the dplane system.

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
8cb41cd624 zebra: set SELECTED flag in rib_process
Set SELECTED re immediately in rib_process, without expecting
that fib install has completed. Remove premature redistribute
call also.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2018-10-25 08:34:30 -04:00
Mark Stapp
97f5b44182 zebra: use async dplane route updates
Enqueue updates to the dplane system; add a couple of stats.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2018-10-25 08:34:30 -04:00
Mark Stapp
e5ac2adf17 zebra: wip: early version of dplane result handler
Early try at a result handler for async dplane route updates

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
Donald Sharp
89272910f7 zebra: Start breakup of zns into zrouter and zns
The `struct zebra_ns` data structure is being used
for both router information as well as support for
the vrf backend( as appropriate ).  This is a confusing
state.  Start the movement of `struct zebra_ns` into
2 things `struct zebra_router` and `struct zebra_ns`.

In this new regime `struct zebra_router` is purely
for handling data about the router.  It has no knowledge
of the underlying representation of the Data Plane.

`struct zebra_ns` becomes a linux specific bit of code
that allows us to handle the vrf backend and is allowed
to have knowledge about underlying data plane constructs.

When someone implements a *bsd backend the zebra_vrf data
structure will need to be abstracted to take advantage of this
instead of relying on zebra_ns.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-10-24 06:52:07 -04:00
David Lamparter
cd5f56bb4e Merge branch 'pull/3165'
...with an additional comment.

Signed-off-by: David Lamparter <equinox@diac24.net>
2018-10-23 12:42:42 +02:00
David Lamparter
ef57f35f41 zebra: add comment about Linux ifdown handling
Signed-off-by: David Lamparter <equinox@diac24.net>
2018-10-23 12:42:06 +02:00
Donald Sharp
7939ff769f zebra: Add some missing breadcrumbs
During a debugging session last night I discovered that I was
still having some `fun` figuring out why zebra was not making
a route's nexthop active.  After some debugging I figured out
that I was missing some states that we could end up in that
didn't have debug information about what happened in nexthop_active.

Add the missing breadcrumbs for nexthop resolution.  In addition
add a bit of code to notice the ebgp state without recursion turned
on and to let the user know about it.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-10-18 09:13:18 -04:00
Philippe Guibert
212df1de28 zebra: remove kernel routes that are suppressed
on some cases, kernel routes are not selected, because the kernel
suppressed it without informing the netlink layer that the route has
been suppressed ( for instance, when an interface goes down, the route
never goes back when interface goes up again). This commit intends to
suppress that entry from zebra.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-10-17 23:01:10 +02:00
vishaldhingra
6d53d7b1af zebra: vrf aware routmap is missing in Zebra #2802(Part 2 of 4)
Function parameter replacement of using zvrf instead of vrf_id

Signed-off-by: vishaldhingra vdhingra@vmware.com
2018-10-11 10:46:55 -07:00
vishaldhingra
ac6eebce50 zebra: vrf aware routmap is missing in Zebra #2802(Part 1 of 4)
Work to handle the route-maps, namely the header changes in zebra_vrf.h
 and the mapping of using that everywhere

 Signed-off-by: vishaldhingra vdhingra@vmware.com
2018-10-11 10:44:55 -07:00
David Lamparter
6a154c8812 *: list_delete_and_null() -> list_delete()
Signed-off-by: David Lamparter <equinox@diac24.net>
2018-10-02 11:40:52 +02:00
Renato Westphal
38ca1c9256
Merge pull request #3081 from donaldsharp/table_table_table
bgpd, lib, zebra: Wrapper get/set of table->info pointer
2018-09-24 23:32:50 -03:00
Donald Sharp
6ca30e9ec6 bgpd, lib, zebra: Wrapper get/set of table->info pointer
Wrapper the get/set of the table->info pointer so that
people are not directly accessing this data.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-09-23 20:04:39 -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
Quentin Young
1c50c1c0d6 *: style for EC replacements
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-13 19:38:57 +00:00
Quentin Young
e914ccbe9c zebra: ZEBRA_[ERR|WARN] -> EC_ZEBRA
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-13 19:23:29 +00: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
Donald Sharp
714e135429
Merge pull request #2875 from opensourcerouting/fabricd
OpenFabric support
2018-09-08 13:48:48 -04:00
Donald Sharp
34815ea334 zebra: Modify nexthop checks to report inactive a bit more
Debugging inactive nexthops in zebra can be quite difficult
and non-obvious what has gone wrong.  Add detailed rib
debugs for the cases where we decide that a nexthop is
inactive so that we can more easily debug a reason
for the failure.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-09-06 20:24:00 -04: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
Donald Sharp
2d68a0f2da zebra: Fix _route_entry_dump to handle nexthop family as appropriate
The _route_entry_dump function was not handling the nexthop as passed
in from an upper level protocol appropriate and as such not displaying
the v4/v6 nexthop right in the case where we have both going.

Additionally dump the nexthop vrf as well.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-09-05 21:02:18 -04:00
Christian Franke
103e4a718f zebra: add a ZEBRA_FLAG_ONLINK so that routes bypass the is-unnumbered check
For OpenFabric operation, we need to be able to install routes via
interfaces without any IPv4 addresses configured. Introduce a flag
ZEBRA_FLAG_ONLINK which upper protocols can set on a route they send
towards zebra, to force the nexthops to be considered onlink.

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2018-09-05 11:38:13 +02:00
Don Slice
fec4ca191e zebra: if multiple connecteds, select loopback or vrf if present
Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2018-08-23 18:49:48 +00:00
Donald Sharp
dca5ef3053
Merge pull request #2818 from kssoman/rmap_fix
Zebra does not properly track which route-maps are changed (#2493)
2018-08-22 07:50:14 -04:00
kssoman
d5b8c21628 zebra : Zebra does not properly track which route-maps are changed (#2493)
* Check for the modified routemap in zebra_route_map_process_update_cb()
* Added zebra_rib_table_rm_update() for RIB routemap processing
* Added zebra_nht_rm_update() for NHT routemap processing

Signed-off-by: kssoman <somanks@vmware.com>
2018-08-17 08:47:48 -07:00
Quentin Young
af4c27286d *: rename zlog_fer -> flog_err
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-08-14 20:02:05 +00:00
Quentin Young
43e52561b4 zebra, lib: error references for zebra
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-08-14 20:02:05 +00:00
Renato Westphal
4373435488 zebra: remove unguarded debugging leftovers
These debug messages were committed by accident.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-08-13 18:53:45 -03:00
Donald Sharp
0ce1ca805d *: ALLOC calls cannot fail
There is no need to check for failure of a ALLOC call
as that any failure to do so will result in a assert
happening.  So we can safely remove all of this code.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-08-11 17:14:58 +02: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
Donald Sharp
7e24fdf333 staticd: Start the addition of a staticd
This is the start of separating out the static
handling code from zebra -> staticd.  This will
help simplify the zebra code and isolate static
route handling to it's own code base.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-07-29 12:37:24 -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
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
paco
0cfbff749e
zebra: flow control (Coverity 1462467 1465497)
Signed-off-by: F. Aragon <paco@voltanet.io>
2018-06-21 17:09:04 +02:00
paco
36228974c2
isisd, zebra: FIXME fixes
Signed-off-by: F. Aragon <paco@voltanet.io>
2018-06-19 19:22:13 +02: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
Donald Sharp
633a66a586 zebra: Add 'match source-instance' to allow finer grained control
Add to zebra route-maps the ability to match on a source-instance

route-map FOO deny 55
 match source-instance 5
route-map FOO permit 60

ip protocol any route-map FOO

This will match any protocol route installation with a source-instance of 5.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-05-17 10:57:59 -04:00
vivek
a317a9b9a4 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-04-26 07:50:34 -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
Renato Westphal
15da01e92d
Merge pull request #1973 from donaldsharp/static_nh_vrf
Static nh vrf
2018-04-10 17:27:57 -03:00
Donald Sharp
b8faa875f7 zebra: Notice when our route is deleted and re-install.
The code to reinstall self originated routes was not behaving
correctly.  For some reason we were looking for self originated
routes from the kernel to be of type KERNEL.  This was probably
missed when we started installing the route types.  We should
depend on the self originated flag that we determine from
the callback from the kernel.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com.
2018-04-09 07:54:57 -04:00
Donald Sharp
9713497ff4 zebra: Properly deregister static nexthops
There were a few cases where we were not properly de-registering
the static nexthops passed to us.  This was important when
the static route was being removed for whatever reason that
we did not leave slag for the nexthop tracking.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-27 15:51:53 -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
18febdb05a
Merge pull request #1913 from LabNConsulting/working/master/bgp-vpn-leak-cli
bgpd: new vpn-policy CLI
2018-03-20 13:26:48 -04:00
G. Paul Ziemba
b9c7bc5ab0 bgpd: new vpn-policy CLI
PR #1739 added code to leak routes between (default VRF) VPN safi and unicast RIBs in any VRF. That set of changes included temporary CLI including vpn-policy blocks to specify RD/RT/label/&c. After considerable discussion, we arrived at a consensus CLI shown below.

The code of this PR implements the vpn-specific parts of this syntax:

router bgp <as> [vrf <FOO>]
    address-family <afi> unicast
        rd (vpn|evpn) export (AS:NN | IP:nn)
        label (vpn|evpn) export (0..1048575)
        rt (vpn|evpn) (import|export|both) RTLIST...
        nexthop vpn (import|export) (A.B.C.D | X:X::X:X)
        route-map (vpn|evpn|vrf NAME) (import|export) MAP

        [no] import|export [vpn|evpn|evpn8]
        [no] import|export vrf NAME

User documentation of the vpn-specific parts of the above syntax is in PR #1937

Signed-off-by: G. Paul Ziemba <paulz@labn.net>
2018-03-19 22:13:43 -07:00
Donald Sharp
ea7637ccd4 zebra: Cleanup dead function rib_weed_table
the rib_wib_table function was uncalled by anyone remove
and additionally remove it's static function it called.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-16 10:20:32 -04:00
Donald Sharp
95a29032bc zebra: Read in on startup arbitrary tables
When we receive an arbitrary table over the netlink bus
save it for later perusal and sweep any routes that
we may have created from an earlier run.

The current redistribute code is limited to
ZEBRA_KERNEL_TABLE_MAX.  I left this alone for the
moment because I believe it needs to be converted
to a RB tree instead of a flat array.  Which is more
work for the future.  Additionally this proposed
change might necessitate some cli changes or rethinks.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-16 10:18:58 -04:00
Donald Sharp
47a08aa968 zebra: Upon client disconnect remove routes from all tables
It is possible for clients to install routes into tables
that they desire.  Modify the code to delete these routes
from these tables as well.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-16 10:18:07 -04:00
Donald Sharp
010c5efac0
Merge pull request #1739 from LabNConsulting/working/master/bgp-vpn-vrf-leaking
bgpd: vpn - vrf route leaking
2018-03-15 09:01:27 -04:00
Donald Sharp
32391affcc zebra: Add some additional vrf info to debugs
There were several places where when I am attempting
to debug zebra functionality that I would really
like to have the ability to know what vrf I think
I am operating on.

Add the vrf_id to a bunch of zlog_debug messages
to help figure out issues when they happen.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-14 20:14:36 -04:00
paulzlabn
3f1224cd1a
Merge branch 'master' into working/master/bgp-vpn-vrf-leaking 2018-03-14 13:31:58 -07:00
vivek
4e262455a2 Merge branch 'master' of https://github.com/frrouting/frr into evpn-ipv6-tenant-routing
Conflicts:
	bgpd/bgp_evpn.c
2018-03-10 04:03:41 +00:00
G. Paul Ziemba
ff954ba48b zebra: add BGP VPN route type to meta_queue_map
Signed-off-by: G. Paul Ziemba <paulz@labn.net>
2018-03-09 16:42:40 -05: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
Donald Sharp
5e54c60269 *: Add code to notify on route removal status
If a interested party removes one of it's routes let
it know that it has happened as asked for.

Add a ZAPI_ROUTE_REMOVED to the send of the route_notify_owner
Add a ZAPI_ROUTE_REMOVE_FAIL to the send of the route_notify_owner

Add code in sharpd to notice this and to allow it to keep
track of routes removed for that invocation and give timing
results.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-08 19:50:06 -05:00
vivek
bfd498f0da Merge branch 'master' of https://github.com/frrouting/frr into evpn-ipv6-tenant-routing
Conflicts:
	zebra/zserv.c
2018-03-06 22:19:24 +00: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
vivek
1ec31309bb *: EVPN symmetric routing for IPv6 tenant routes
Implement support for EVPN symmetric routing for IPv6 routes. The next hop
for EVPN routes is the IP address of the remote VTEP which is only an IPv4
address. This means that for IPv6 symmetric routing, there will be IPv6
destinations with IPv4 next hops. To make this work, the IPv4 next hops are
converted into IPv4-mapped IPv6 addresses.

As part of support, ensure that "L3" route-targets are not announced with
IPv6 link-local addresses so that they won't be installed in the routing
table.

Signed-off-by: Vivek Venkatraman vivek@cumulusnetworks.com
Reviewed-by: Mitesh Kanjariya mitesh@cumulusnetworks.com
Reviewed-by: Donald Sharp sharpd@cumulusnetworks.com
2018-02-28 02:07:23 +00:00
Russ White
5cfb017a67
Merge pull request #1776 from dslicenc/static-inactive-cm19675
zebra: fix rnh deleting nht entry
2018-02-27 08:51:33 -05:00
Russ White
8bc92a3ec7
Merge pull request #1799 from donaldsharp/route_notify_owner
Route notify owner
2018-02-27 08:32:42 -05:00
Donald Sharp
4e8b02f4df *: Rename ZEBRA_FLAG_INTERNAL -> ZEBRA_FLAG_ALLOW_RECURSION
The ZEBRA_FLAG_INTERNAL flag is used to signal to zebra that
the route being added, the nexthops for it can be recursively
resolved.  This name keeps throwing me off when I read it
so let's rename to something that allows the developer to
understand what is going on.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-02-26 21:26:33 -05:00
Donald Sharp
9a9f89267a zebra: Fix situation where we would notify the owner it lost due to admin distance
The 'struct route_entry *old' and 'struct route_entry *new' can sometimes
be the same route type( for a route replace ), so when we are checking
to see if a new owner has taken over, don't tell the owner it is
replacing it self.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com.
2018-02-23 14:45:57 -05:00
Donald Sharp
28610f7e44 *: Add tableid the route entry was sent to
Add for the southbound pass back the route entries tableid
used for installation.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-02-23 14:45:57 -05:00
Donald Sharp
a031a7e4c9 zebra: On shutdown don't count removals
Some of the tables are no longer stored in the zvrf
and in the zns now.  On shutdown zns is cleaned up
after vrf( and rightly so!) As such we should not
attempt to count the information if we don't have
a zvrf.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-02-23 07:08:36 -05:00
Don Slice
b43444f53a zebra: fix rnh deleting nht entry
Problem seen when a prefix was learned with nexthops from multiple
route sources (static and ospf in this case) and the link to that
nexthop flaps.  The nht entry was incorrectly deleted so when the
link came back up the static was not re-installed correctly.

Ticket: CM-19675
Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2018-02-21 10:47:21 -08:00
Martin Winter
74a75bdbad
Merge pull request #1701 from donaldsharp/zapi_vrf_label
Zapi vrf label
2018-02-13 19:05:42 -08:00
Donald Sharp
44bdf1590d lib, zebra: Move nh_resolve_via_default to appropriate header
The nh_resolve_via_default function is an accessor function
for NHT in zebra.  Let's move this function to it's proper
place.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-02-08 19:36:18 -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
400a663bf2 zebra: sharp protocol needs a default admin distance.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-02-08 19:30:34 -05:00
Donald Sharp
2eb07de3d6 zebra: Fix crash when dereferencing dest->selected_fib
When a rib_unlink() event is directly called for a
route_entry we need to see if the dest->selected_fib
is the same and just unset the dest->selected_fib.

This was happening for redistributed table 10 routes
into BGP.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-01-29 17:52:15 -05:00
Donald Sharp
ed216282b6 zebra: Move selected_fib assignment
The dest->selected_fib assignment needs to happen
after the install and should be controlled by
the southbound api return of success or failure.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-01-24 17:51:09 -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
Renato Westphal
f674dfe234 zebra: implement recursive MPLS labels
When a nexthop is resolved via a label based nexthop, copy
the labels into the newly created recursive nexthop.

Please note that this does not fix the case where we
have a label based nexthop that is recursively resolved
through *another* nexthop that is also label based.
In this case we need to create a new label stack
for those routes.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-01-22 11:55:22 -05:00
Donald Sharp
5bdd34db69 zebra: Allow static non interface based routes to leak
Allow this to work:

vrf DONNA
  ip route 4.3.2.1/32 192.168.1.5 nexthop-vrf EVA

The static route code was not properly telling the
nexthop resolution code what vrf to use.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-01-12 09:26:42 -05:00
Donald Sharp
007dbee65c zebra: When handling nexthops use the correct vrf
When we are handling nexthops in zebra, use the appropriate
vrf to figure out if the nexthops are active or not.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-01-12 09:20:36 -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
99b9d9609f zebra: Use the correct vrf id to lookup the ifp pointer
Use the nexthop vrf_id to properly lookup the ifp pointer
for display purposes.

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
Donald Sharp
607425e554 zebra: Fix dest dereference
The rn can not have an rn->info pointer and as
such the dest may be NULL.  Don't assign
the old_fib pointer if so.  This is ok
because we know RNODE_FOREACH... will not
iterate if dest is NULL.

Fixes: #1575
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-01-02 09:12:07 -05:00
Renato Westphal
fb6f7c2c25
Merge pull request #1515 from donaldsharp/selected_to_front1
Store selected_fib as a pointer off of rib_dest_t
2017-12-19 14:09:03 -02:00
Mitesh Kanjariya
90264d64ef bgpd: process evpn type-5 routes received from peers
Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2017-12-14 10:57:08 -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
Mitesh Kanjariya
19a847a9cd bgpd: set evpn rvtep nexthops as active by default
Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2017-12-14 10:57:05 -08:00
mitesh
d3135ba31d bgpd: program mac-ip routes in matching vrfs
Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2017-12-14 10:57:05 -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
5f7a4718e2 zebra: Replace SELECTED_FIB flag with a rib_dest_t pointer
The SELECTED_FIB flag was placed upon the entry that we
have inserted into the kernel.  Remove this flag and replace
with a `rib_dest_t` *selected_fib.  Just keep track of the
selected_fib as we modify it.  This removes allot of
FOREACH_RE loops as that we do not need to find the
entry anymore.

At this point in time I think this is a very minor performance
boost.  Most `rib_dest_t` structures do not typically carry
more than 1 route_entry, but the minute you start having more
than one entry you can and will start having significant processing
time spent finding the selected_fib.

A future commit may re-order the route entries and possibly
keep more pointers on `rib_dest_t` to avoid lookup.  This
is a bit tricky because of the FIB_OVERRIDE code.

Signed-off-by Donald Sharp <sharpd@cumulusnetworks.com>
2017-12-05 17:26:32 -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
019a82cbbc zebra: Allow zebra_find_client to match on instance as well
zebra_find_client needs to match on instance as well so
protocols like ospfd will work correctly for notification.

Modify the zebra_find_client code to accept the instance
number and to pass it in appropriately.

Signed-off-by: Doanld Sharp <sharpd@cumulusnetworks.com>
2017-11-27 09:25:32 -05:00
Donald Sharp
2063a81497 zebra: Add notification for Route Install events
When we are installing into the kernel, not the
change points for notification to a higher level
protocol and make it happen

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-11-27 09:09:36 -05:00
Renato Westphal
67f1e3aa18
Merge pull request #1434 from dslicenc/zebra-nexthop-cm8192
zebra: fix resolving nexthop through itself
2017-11-23 10:13:18 -02:00
Donald Sharp
d6792f9d7d zebra: When uninstalling a non-unicast route mark it so
The rib_uninstall_kernel for non-UNICAST routes when
it is marking a route as no-longer installed should
actually mark it as uninstalled.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-11-19 19:47:32 -05:00
Don Slice
fd7fd9e5c4 zebra: fix resolving nexthop through itself
Problems reported with zebra nht oscillating when a nexthop is resolved
using the same address to reach the  nexthop (for example, 10.0.0.8 is
resolved via 10.0.0.8/32.)  This fix removes this attempt to resolve
thru itself unless the route being resolved is also a host route.
This fix also walks up the tree looking for a less specific route to
reach the nexthop if needed.  Smoke testing completed successfully.

Ticket: CM-8192
Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
Reviewed-by: CCR-6583
Testing done: Manual testing successful, bgp-min completed successfully
l3-smoke completed with two test changes required.
2017-11-09 10:15:02 -08:00
Donald Sharp
3a30f50f3f zebra: Allow user to specify work-queue processing hold time
Allow the user to modify the work-queue processing hold time
from 10ms to a value from (0-10000).  Make the command hidden
as that it's a semi-dangerous command and it could cause
issues.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-25 10:59:05 -04:00
Renato Westphal
d855d11fad zebra: use a switch statement in nexthop_set_resolved()
This makes the function much easier to read, and also faster.

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
Donald Sharp
affe9e9983 *: Convert list_delete(struct list *) to ** to allow nulling
Convert the list_delete(struct list *) function to use
struct list **.  This is to allow the list pointer to be nulled.

I keep running into uses of this list_delete function where we
forget to set the returned pointer to NULL and attempt to use
it and then experience a crash, usually after the developer
has long since left the building.

Let's make the api explicit in it setting the list pointer
to null.

Cynical Prediction:  This code will expose a attempt
to use the NULL'ed list pointer in some obscure bit
of code.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-05 10:53:13 -04:00
Renato Westphal
c00ad29fc4 Merge pull request #1236 from donaldsharp/interface_startup
zebra: Do not allow same rib_dest_t be queued multiple times to meta …
2017-09-28 22:04:02 -03: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
Renato Westphal
8a38c34b5a Merge pull request #1235 from chiragshah6/ospf_vrf_dev
zebra: Nexthop APIs to use correct vrf_id
2017-09-26 00:34:04 -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
fd289fc83e zebra: Make admin distance a uint8_t
While u_char is technically a uint8_t in size I would
like to treat and think about the admin distance
as an actual integer value from 0-255, instead
of a char.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-09-25 08:41:33 -04:00
Donald Sharp
1ca60f2c3e zebra: Do not allow same rib_dest_t be queued multiple times to meta queue
If we have already scheduled a node to be on the meta_queue, there is no
need to schedule it up again.

On startup we are calling rib_update() multiple times per connected route.
Due to the multiple ways we can get callbacks for adding a connected route
I decided it was best to just improve meta_queue performance as opposed
to trying to figure out all the different ways across all the platforms
that we can decide that a connected route has changed.  This appears
to solve the issue with a very large # of interfaces coming up
at the same time on startup.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-09-25 08:10:24 -04:00
Chirag Shah
eec2e59276 zebra: Nexthop APIs to use correct vrf_id
For unnumbered interface lookup vrf aware interface
info.
Pass vrf aware interface info for route entry's nexthop
ifindex in route add path.

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2017-09-24 18:05:12 -07:00
Renato Westphal
66af68454b zebra: make rib_add() a simple wrapper for rib_add_multipath()
Both function were very similar, and as we know code duplication is not
good. As an example, in the past couple of weeks some fixes were made
on rib_add() but not on rib_add_multipath(), causing known bugs to still
exist in a different form.

Instead of merging the two functions into one, let's make rib_add()
call rib_add_multipath() with the appropriate parameters. This way we
remove the code duplication but still keep the easy-to-use rib_add()
function for single-path routes.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-09-21 13:27:50 -03:00
Renato Westphal
844b3a8748 zebra: fix detection of duplicate kernel routes (ECMP version)
Fixes the following bug:
% ip route add 50.0.0.0/8 nexthop via 10.0.1.2 nexthop via 10.0.2.2
% ip route replace 50.0.0.0/8 nexthop via 10.0.1.3 nexthop via 10.0.2.3
% ip route replace 50.0.0.0/8 nexthop via 10.0.1.4 nexthop via 10.0.2.4
%
% vtysh -c "show ip route"
[snip]
K * 50.0.0.0/8 [0/0] via 10.0.1.4, rt1-eth1, 00:00:00
  *                  via 10.0.2.4, rt1-eth2, 00:00:00
K * 50.0.0.0/8 [0/0] via 10.0.1.3, rt1-eth1, 00:00:10
  *                  via 10.0.2.3, rt1-eth2, 00:00:10
K>* 50.0.0.0/8 [0/0] via 10.0.1.2, rt1-eth1, 00:00:24
  *                  via 10.0.2.2, rt1-eth2, 00:00:24

Commit a3d18ce6 fixed a similar problem for single-path routes.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-09-21 13:27:50 -03:00
Renato Westphal
eb327fa590 zebra: pay attention to metric from kernel (ECMP version)
Commit f19435a8 fixed rib_add() but didn't fix rib_add_multipath().

While here, remove the unnecessary 'same->table == re->table' check as
it always evaluate to true.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-09-21 13:27:50 -03:00
Renato Westphal
7865c65d23 zebra: plug memory leak in rib_add_multipath()
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
Donald Sharp
60c2286880 Merge pull request #1160 from opensourcerouting/admin_distance
Admin distance
2017-09-21 07:55:08 -04: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
Russ White
dcc4574ae6 Merge pull request #1163 from donaldsharp/deduplicate_nexthops
zebra: deduplicate nexthops
2017-09-13 16:18:41 -04: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
Renato Westphal
0492eea08e zebra: fix administrative distance issues
* Reuse route_distance() on rib_add_multipath() and on rib_add();
* Set the admin distance of LDP and BGP MPLS LSPs.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-09-12 11:02:25 -03:00
Donald Sharp
c710b277cf zebra: Fix up default admin distance for some route types
Set the default admin distance for some route types
more appropriately.  The route_distance function
would return 0 for array items not configured, which
is not the right thing to do.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-09-12 10:59:07 -03:00
Donald Sharp
59693377a9 zebra: Allow recursive nexthop resolution to consider blackholes
When we get a route install for a route that needs to be recursively
resolved allow the blackhole to be considered and used if it is
available.

This allows bgp to install a route that will be blackholed.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-09-12 08:33:37 -04:00
Donald Sharp
0a16efff9b zebra: Fix rib_update_table
We should only be operating RIB_UPDATE_IF_CHANGE on
types that zebra has control of.  We assume that
the calling routing protocol is going to take care
of their own route changes based upon the interface
state change.

Also try to re-organize the code a tiny bit to allow
it to fit better within a tabed world.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-09-11 13:35:26 -04:00
Donald Sharp
c9abf5584a zebra: Small performance improvement for garbage collection
There is no need to retrieve the zvrf *unless* we are doing
debugs.  So move the retrieval under the debug statement.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-09-11 11:12:03 -04:00
Renato Westphal
c2713b2acb zebra: allow multiple connected routes for the same prefix
With unnumbered interfaces on Linux we have the same IP address configured
on several different interfaces and hence multiple connected routes for
the same prefix.

With that said, add an exception in rib_add() to allow zebra to keep
track of all connected routes. We don't need to worry about the bugs
reported in a3d18ce because connected routes are always added from the
connected_up() function, and connected_update() already takes care of
handling duplicate addresses per interface.

Fixes #1112.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-09-07 15:00:42 -03: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
5f20552d51 zebra: add an exception for link-local connected routes
Link-local routes are unique in the sense that they all have the same
prefix but have different nexthops (local interfaces). Add an exception
in rib_add() to allows us to keep track of all of them.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-09-01 11:44:22 -03:00
Renato Westphal
a3d18ce6b0 zebra: fix detection of duplicate system routes
Fixes the following bugs:

1)
% ip -6 route add 5000::/64 via 3000::2
% ip -6 route replace 5000::/64 via 3000::2
% ip -6 route replace 5000::/64 via 3000::2
% ip -6 route replace 5000::/64 via 3000::2
% ip -6 route replace 5000::/64 via 3000::2
%
% vtysh -c "show ipv6 route"
[snip]
K * 5000::/64 [0/1024] via 3000::2, rt1-eth0
K * 5000::/64 [0/1024] via 3000::2, rt1-eth0
K * 5000::/64 [0/1024] via 3000::2, rt1-eth0
K * 5000::/64 [0/1024] via 3000::2, rt1-eth0
K>* 5000::/64 [0/1024] via 3000::2, rt1-eth0

2)
% ip -6 route add 7000::/64 via 3000::2
% ip -6 route replace 7000::/64 via 3000::3
% ip -6 ro | grep 7000
7000::/64 via 3000::3 dev rt1-eth0 metric 1024  pref medium
%
% vtysh -c "show ipv6 route"
[snip]
K * 7000::/64 [0/1024] via 3000::3, rt1-eth0
K>* 7000::/64 [0/1024] via 3000::2, rt1-eth0

NOTE: the check for ROUTE_ENTRY_REMOVED was redundant as it was already
performed at the beginning of the loop.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-08-31 22:13:14 -03:00
Renato Westphal
cc54cfee3a zebra: remove refcnt from the route_entry structure
This reference counter was introduced in 2001, apparently to solve a
problem with connected routes being added/removed multiple times. The RIB
code changed a lot since then, and giving the current callers of rib_add()
and rib_delete() it's safe to assume that we don't need this anymore.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-08-31 21:17:11 -03: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
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
Donald Sharp
1e9f448fe1 zebra: Coverity Code Cleanup
1) Various socket close issues
2) Ensure afi passed is usable
3) Fix some reads beyond buffer and reads after free
4) Ensure some failure modes are handled properly
5) Memory Leak(s) fix
6) There is no 6.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-08-25 11:37:07 -04:00
Jorge Boncompte
19aad877b7 lib: optimize IPV4_ADDR_[SAME|COPY]()
Change all callers of IPV4_ADDR_SAME() to pass a pointer to a struct in_addr

Use assignment and comparison instead of memcpy() and memcmp(). Avoids function
calls. Faster.

Signed-off-by: Jorge Boncompte <jbonor@gmail.com>
2017-08-17 17:58:35 +02:00
Jorge Boncompte
f104f6c1a6 lib: cleanup the work queue implementation
Convert the work queue implementation to not use the generic linked list
to mantain the item list and use instead a simple queue from queue.h that
does not allocate memory for each node.

Signed-off-by: Jorge Boncompte <jbonor@gmail.com>
2017-08-17 17:47:07 +02: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
Jorge Boncompte
8628fc612b zebra: cleanup, use RIB_SYSTEM_ROUTE() define where appropiate
Signed-off-by: Jorge Boncompte <jbonor@gmail.com>
2017-08-04 10:19:36 +02:00
Jorge Boncompte
3ce588804a zebra: do not treat kernel routes as implicit withdraws
Kernel does not send the best route after adding or deleting routes, if
we treat routes for an existing prefix as implicit withdraw the zebra RIB
goes out of sync with FIB and can announce wrong route to protocols.

host:~# vtysh -c 'show ip route'
S>* 0.0.0.0/0 [0/0] via 192.168.1.1, eth0
C>* 192.168.1.0/24 is directly connected, eth0

host:~# ip route add 192.0.2.0/24 via 192.168.1.101 metric 100
host:~# vtysh -c 'show ip route'
S>* 0.0.0.0/0 [0/0] via 192.168.1.1, eth0
K>* 192.0.2.0/24 via 192.168.1.101, eth0
C>* 192.168.1.0/24 is directly connected, eth0

host:~# ip route add 192.0.2.0/24 via 192.168.1.102 metric 50
host:~# vtysh -c 'show ip route'
S>* 0.0.0.0/0 [0/0] via 192.168.1.1, eth0
K>* 192.0.2.0/24 via 192.168.1.102, eth0
C>* 192.168.1.0/24 is directly connected, eth0

host:~# ip route del 192.0.2.0/24 via 192.168.1.102 metric 50
host:~# vtysh -c 'show ip route'
S>* 0.0.0.0/0 [0/0] via 192.168.1.1, eth0
C>* 192.168.1.0/24 is directly connected, eth0
host:~# ip route show 192.0.2.0/24
192.0.2.0/24 via 10.10.1.101 dev eth0 metric 100

Signed-off-by: Jorge Boncompte <jbonor@gmail.com>
2017-08-04 10:19:36 +02:00
Jorge Boncompte
43e3130587 zebra: copy MTU from non static routes into nexthop
Some routing protocols advertise route MTU (e.g. NHRP), with this patch
installed routes in the kernel have the advertised MTU.

Signed-off-by: Jorge Boncompte <jbonor@gmail.com>
2017-08-04 10:19:36 +02:00
David Lamparter
9d303b37d7 Revert "*: reindent pt. 2"
This reverts commit c14777c6bf.

clang 5 is not widely available enough for people to indent with.  This
is particularly problematic when rebasing/adjusting branches.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-22 14:52:33 +02:00
whitespace / reindent
c14777c6bf
*: reindent pt. 2
w/ clang 5

* reflow comments
* struct members go 1 per line
* binpack algo was adjusted
2017-07-17 15:26:02 -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
ßingen
7414ebd6c4 zebra: Fix compilation warning
Signed-off-by: ßingen <bingen@voltanet.io>
2017-07-13 15:09:38 +02:00
Christian Franke
8050720788 zebra: use copy_nexthops in route_entry_copy_nexthops
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2017-07-12 18:28:05 +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
Rafael Zalamena
45926e5874 lib: improve the RB implementation
Switch the RB tree implementation completely to the new dlg@'s version
that uses pre-declared functions instead of macros for tree functions.

Original e-mail/diff:
https://marc.info/?l=openbsd-tech&m=147087487111068&w=2

Pros:

* Reduces the amount of code that the usage of those macros generate
* Allows the compiler to do a better compile-time check job
* Might have better i-cache utilization since the tree code is shared

Con:

* dlg@ benchmarks shows it has 'very slightly slower' insertions
* imported RB_* code must adapt the following calls:
  RB_INIT(), RB_GENERATE(), RB_ROOT(), RB_EMPTY(), make compare
  functions use 'const' (if not already) and maybe others.
2017-06-16 10:44:31 -03:00
David Lamparter
fb82c3dbb2 Merge pull request #687 (nexthop refactoring)
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-06-13 16:22:29 +02:00
David Lamparter
97bd5c48de Merge remote-tracking branch 'frr/master' into pull-624 2017-06-13 09:18:14 +02:00
Donald Sharp
8dab78d7d4 zebra: Add babel routes to the proper meta-Q for processing
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-06-07 15:57:25 -04:00
Donald Sharp
43cf4ba452 zebra: Fix the metaq to be aware of all routing protocols we could see
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-06-07 15:43:23 -04:00
Donald Sharp
c87bdd2b0f zebra: Clean up indentation level in nexthop_active
Clean up the while loop indentation level to be a bit more
readable.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-06-07 07:39:35 -04:00
Donald Sharp
4491a88f9e zebra: Refactor nexthop_active to remove duplicate code
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-06-07 07:34:16 -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
Donald Sharp
57282a31cf zebra: Add code to track kernel interactions
Allow zebra to track kernel interactions.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-05-18 13:14:18 -04: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
Daniel Walton
71e04b9f7c zebra: zebra_mpls_lsp_uninstall was not being called
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>

Old entries were not being removed from the MPLS table.
2017-05-12 13:34:51 +00:00
Don Slice
a64448baa6 zebra: labeled unicast handling
Support install of labeled-unicast routes by a client. This would be
BGP, in order to install routes corresponding to AFI/SAFI 1/4 (IPv4)
or 2/4 (IPv6). Convert labeled-unicast routes into label forwarding
entries (i.e., transit LSPs) when there is a static label binding.

Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2017-04-06 10:29:19 -04:00
David Lamparter
4f8ea50c0d zebra: fpm: convert into module
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-03-25 08:52:36 +01:00
Donald Sharp
baaea325e6 *: Refactor ifindex2ifname to be VRF aware
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-03-15 10:43:21 -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
David Lamparter
deaa50db47 lib: hide away logging internals
... no need to have struct zlog generally-exposed.

A few files get to include log_int.h because they use zlog/vzlog.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-03-08 00:15:40 +01:00
David Lamparter
bb85d700d5 lib: ditch struct zlog * argument on zlog/vzlog()
It's completely useless...

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-03-08 00:15:39 +01:00
Timo Teräs
2fb975da77 nhrpd: implement next hop resolution protocol
This provides DMVPN support and integrates to strongSwan. Please read
README.nhrpd and README.kernel for more details.

[DL: cherry-picked from dafa05e65fe4b3b3ed5525443f554215ba14f42c]
[DL: merge partially resolved, this commit will not build.]
Signed-off-by: Timo Teräs <timo.teras@iki.fi>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-03-07 16:20:29 +01:00
vivek
78b81eaa44 lib: Enhance prefix dump for EVPN prefixes
This commit is also taking into account changes related to srcdes
feature introduction in zebra folder.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>

Ticket: CM-12262
Reviewed By: CCR-5065
Testing Done: Manual

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2017-02-14 13:58:58 +01:00
Christian Franke
e322dbc73a Merge branch 'master' into feature/zebra-srcdest 2017-01-31 16:22:54 +01:00
Donald Sharp
6bcc7f4b7e zebra: Do not force NEXTHOP_TYPE to XXX_IFINDEX
The original goal of the zebra change was to force all:
NEXTHOP_TYPE_IPV4 -> NEXTHOP_TYPE_IPV4_IFINDEX
NEXTHOP_TYPE_IPV6 -> NEXTHOP_TYPE_IPV6_IFINDEX

This causes issues in routes being installed into the kernel
backing this out until I can get time to fully understand
what is going wrong.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-01-31 08:07:27 -05:00
Donald Sharp
265d5b9d51 zebra: Cleanup dead code and unused return value
We had a large block of #if 0 code.  Since it's
been that way for like 8 months now, lets go ahead
and just remove it.

Additionally the rib_delete function was returning
a return code that was summarily ignored.  Let's
clean up the expectation of returning anything.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-01-30 11:48:38 -05:00
Donald Sharp
b153b01010 zebra: Consolidate nexthop_active_ipv4 and _ipv6
Both of these functions are identical.  Consolidate
to 1 function.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-01-30 11:48:38 -05:00
Christian Franke
0573778371 zebra: add srcdest support to rib
Add srcdest support to the zebra rib and to the kernel
and redistribution interfaces.

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2017-01-30 13:54:46 +01:00
David Lamparter
3c7c91d0bd zebra: receive ZAPI IPv6 source prefix
Check and read the IPv6 source prefix on ZAPI messages, and pass it down
to the RIB functions (which do nothing with it yet.)  Since the RIB
functions now all have a new extra argument, this also updates the
kernel route read functions to supply NULL.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-01-30 13:47:04 +01:00
vivek
7b25dca6b7 zebra: Perform safe walk of RIB entries in rib_process()
There is a scenario where a RIB entry is unlinked and freed during RIB
processing. However, the walk of the entries is not being performed in
a safe manner. Fix the code to do this correctly.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>

Ticket: CM-13393
Reviewed By: Trivial
Testing Done: Basic manual test
2017-01-17 18:43:35 -05:00
Renato Westphal
e3edd1d1d4 zebra: remove unused variable
It looks like 'nexthop_fib_num' has been lingering around since 2003
without any use. Remove it.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-12-23 13:27:55 +07:00
Renato Westphal
949ae9ba15 zebra: fix FIB route updates on *BSD
On *BSD, we update a route in the FIB by removing the old one and then
installing the new version.

With that said, on kernel_route_rib() we need to provide a pointer to
both the old version and the new version of the route.

We were, however, passing a pointer to the new version to both the
'old' and 'new' parameters. This is not a problem on Linux, which uses
NLM_F_REPLACE to update routes, but it breaks route updates on *BSD
because the 'old' parameter points to a route that is not installed in
the kernel. The kernel_route_rib() function then fails to uninstall the
supposedly 'old' route and can fail to install the new version as well if
the kernel doesn't support ECMP (e.g. FreeBSD with default configuration).

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-12-23 13:27:03 +07:00
David Lamparter
8ab22cd4be Merge branch '-renato' into stable/2.0
This contains bgp memory leak fixes as well as cleanups to VRF/namespace
handling and has been run through extended testing in Cumulus' testbed:

Tested-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-12-05 16:23:28 +01:00
Renato Westphal
5a8dfcd891 zebra: plug more memory leaks
Try to free all memory explicitly on exit. This should help to detect
new memory leaks in the future with tools like valgrind.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-11-28 16:18:35 -02:00
Renato Westphal
661512bf05 zebra/lib: remove redundant fields from zebra_vrf
There's no need to duplicate the 'vrf_id' and 'name' fields from the 'vrf'
structure into the 'zebra_vrf' structure. Instead of that, add a back
pointer in 'zebra_vrf' that should point to the associated 'vrf' structure.

Additionally, modify the vrf callbacks to pass the whole vrf structure
as a parameter. This allow us to make further simplifications in the code.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-11-28 16:18:35 -02:00
Renato Westphal
5f3d1bdf3c *: rename two vrf functions
Since VRFs can be searched by vrf_id or name, make this explicit in the
helper functions.

s/vrf_lookup/vrf_lookup_by_id/
s/zebra_vrf_lookup/zebra_vrf_lookup_by_id/

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-11-28 16:18:35 -02:00
Renato Westphal
1a1a70655c lib: convert vrf code to use red-black trees as well
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-11-28 16:18:35 -02:00