Commit Graph

205 Commits

Author SHA1 Message Date
David Lamparter
c5d9d3bb36 lib: replace strlcpy & strlcat with glibc versions
It seems these two were at some point copied in from rsync; replace with
more recent versions that will hopefully become available in glibc as
well.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-11-15 17:35:36 +09:00
Timo Teräs
be717a0af8 zebra: kernel interface simplification
[DL: picked out from: "atomic FIB updates"]

This simplifies the OS-specific route update API into a single entry
point, kernel_route_rib(), which dispatches the various operations
internally.

Signed-off-by: Timo Teräs <timo.teras@iki.fi>
2016-10-18 08:36:21 -04:00
Timo Teräs
446bb95e0f zebra: support FIB override routes
FIB override routes are for routing protocols that establish
shortcut routes, or establish point-to-point routes that should
not be redistributed. Namely this is useful NHRP daemon to come.

Zebra is extended to select two entries from RIB the "best" entry
from routing protocols, and the FIB entry to install to kernel.
FIB override routes are never selected as best entry, and thus
are never adverticed to other routing daemons. The best FIB
override, or if it does not exist the otherwise best RIB is
selected as FIB entry to be installed.

Signed-off-by: Timo Teräs <timo.teras@iki.fi>
Acked-by: Donald Sharp <sharpd@cumulusnetworks.com>
[CF: Massage to fit cumulus tree]
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2016-09-30 12:22:01 -04:00
Donald Sharp
877a0aba09 Revert "zebra: use link scope for interface routes"
This reverts commit 72f3a8fb09.
2016-09-23 12:11:09 -04:00
Donald Sharp
510dc06033 Revert "zebra: support FIB override routes"
This reverts commit 7569ae8bb7.
2016-09-23 12:11:00 -04:00
Timo Teräs
7569ae8bb7 zebra: support FIB override routes
FIB override routes are for routing protocols that establish
shortcut routes, or establish point-to-point routes that should
not be redistributed. Namely this is useful NHRP daemon to come.

Zebra is extended to select two entries from RIB the "best" entry
from routing protocols, and the FIB entry to install to kernel.
FIB override routes are never selected as best entry, and thus
are never adverticed to other routing daemons. The best FIB
override, or if it does not exist the otherwise best RIB is
selected as FIB entry to be installed.

Signed-off-by: Timo Teräs <timo.teras@iki.fi>
Acked-by: Donald Sharp <sharpd@cumulusnetworks.com>
[CF: Massage to fit cumulus tree]
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2016-09-23 09:51:57 -04:00
Timo Teräs
72f3a8fb09 zebra: use link scope for interface routes
In linux, 'scope' is a hint of distance of the IP. And this is
evident from the fact that only lower scope can be used as recursive
via lookup result. This changes all interface routes scope to link
so kernel will allow regular routes to use it as via. Then we do
not need to use the 'onlink' attribute.

Signed-off-by: Timo Teräs <timo.teras@iki.fi>
2016-09-23 09:51:56 -04:00
Renato Westphal
ce54994727 mpls: add support for LDP LSPs
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-09-23 09:31:12 -04:00
vivek
c0f4be83a1 MPLS: Install labeled static routes
This patch installs labeled static routes in the FIB. The routes are installed
using the RTA_ENCAP (and RTA_ENCAP_TYPE) nested attributes.

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

Ticket: CM-6040
Reviewed By: CCR-3091
Testing Done: Tested in SE-1, brief manual testing now
2016-09-23 09:31:02 -04:00
vivek
939fba2741 Quagga: Fix MPLS LSP scheduling to follow nexthop route update
Fix LSP scheduling to occur only after routes are processed because
the LSP resolution depends on the nexthop route being selected. This
is similar to how NHT processing is scheduled.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com>

Ticket: CM-6743
Reviewed By: CCR-3233
Testing Done: Verified the failed test multiple times.
2016-09-23 09:30:59 -04:00
vivek
40c7bdb0c9 Quagga: Install label forwarding entries for statically configured LSPs
Install the statically configured LSPs into the FIB (kernel). This is done
using the new attributes and definitions for MPLS in the kernel -
RTA_VIA, RTA_NEWDST and AF_MPLS.

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

Ticket:  CM-4804
Reviewed By: CCR-3088
Testing Done: Manual in SE-1
2016-09-23 09:30:56 -04:00
David Lamparter
4a1ab8e405 *: split & distribute memtypes and stop (re|ab)using lib/ MTYPEs
This is a rather large mechanical commit that splits up the memory types
defined in lib/memtypes.c and distributes them into *_memory.[ch] files
in the individual daemons.

The zebra change is slightly annoying because there is no nice place to
put the #include "zebra_memory.h" statement.

bgpd, ospf6d, isisd and some tests were reusing MTYPEs defined in the
library for its own use.  This is bad practice and would break when the
memtype are made static.

Acked-by: Vincent JARDIN <vincent.jardin@6wind.com>
Acked-by: Donald Sharp <sharpd@cumulusnetworks.com>
[CF: rebased for cmaster-next]
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2016-09-19 16:31:04 -04:00
Donald Sharp
f86a2b82fe zebra: Pass in vrf to rib_match_ipv4_multicast
Pass around the vrf_id to rib_match_ipv4_multicast
so that proper lookup can be maintained.  Not really
needed yet, but future fixing now.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-09-14 15:34:25 -04:00
Donald Sharp
d71f1c4e6f zebra: Fix broken rib_match
rib_match is broken because the prefix is being
treated as a char * pointer instead of the
correct data type.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
(cherry picked from commit 8b5d6c95781b7c55faa957a2d3edf00c1ecb5c5a)
2016-09-14 15:27:35 -04:00
Christian Franke
bab85d4fcb zebra: assorted parts of 0abf6796c
Author: Timo Teräs <timo.teras@iki.fi>
    Date:   Fri Jan 15 17:36:29 2016 +0200

        zebra: atomic FIB updates

        This commit updates the kernel API so that route changes are
        atomically updated using change/replaces messages instead
        of first sending a withdraw followed with update.

        Same for zclient updates, changes are sent as single ADD
        instead of DELETE + ADD.

        Signed-off-by: Timo Teräs <timo.teras@iki.fi>
2016-09-09 12:15:13 -04:00
Donald Sharp
b4c034b033 zebra: refactor rib_add_ipv[4|6]_multipath
The rib_add_ipv[4|6]_multipath functions are functionally
equivalent.  Refactor to 1 function.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-09-01 07:20:18 -04:00
Donald Sharp
3b1098beed zebra: Refactor rib_add_ipv[4|6] to a common function
rib_add_ipv[4|6] both were essentially the same function
combine and refactor everywhere.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-09-01 07:20:18 -04:00
Donald Sharp
616368ed1e zebra: Refactor rib_delete_ipv[4|6]
These two functions are essentially the same.
Refactor.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-09-01 07:20:18 -04:00
Donald Sharp
14364a3180 zebra: Refactor rib_match_ipv[4|6]
the rib_match_ipv4 and rib_match_ipv6 functions were
the same.  Refactor to 1 function.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-09-01 07:20:18 -04:00
Donald Sharp
28f6dde859 zebra: Create zebra_static.[ch] to isolate code
Isolate the zebra static_XXX functions from zebra_rib.c
This is the first in a series of changes to clean up
the zebra code a bit more.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-09-01 07:20:02 -04:00
Timo Teräs
c50ca33acf zebra: implement per-route mtu handling
This commits allow overriding MTU using netlink attributes on
per-route basis. This is useful for routing protocols that can
advertice prefix specific MTUs between routers (e.g. NHRP).

Signed-off-by: Timo Teräs <timo.teras@iki.fi>
(cherry picked from commit b11f3b54c842117e22e2f5cf1561ea34eee8dfcc)
2016-08-21 13:11:42 -04:00
Donald Sharp
2b50b6031c zebra: Fix cherry-pick of ZEBRA_FLAG_CHANGED
When cherrypicking I did not notice the move of the flag
from flags -> status.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-08-21 13:10:10 -04:00
Timo Teräs
2f97fa65ff zebra: make ZEBRA_FLAG_CHANGED internal status
This flag is used internally in zebra only. And it makes no sense
to expose it over the zclient API, as having it set from client
could corrupt the internal state.

Signed-off-by: Timo Teräs <timo.teras@iki.fi>
Acked-by: Donald Sharp <sharpd@cumulusnetworks.com>
(cherry picked from commit 7eb6136b2732d4782360f9f376336c6d4f667ff0)
2016-08-19 16:30:47 -04:00
Paul Jakma
b892f1ddfe *: use an ifindex_t type, defined in lib/if.h, for ifindex values
(cherry picked from commit 9099f9b2a66e86f8a90d7fe18f61bd2bb1bc6744)
2016-08-18 07:35:38 -04:00
Renato Westphal
8f500a1cf1 *: fix trivial build errors on *BSD
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-08-07 21:05:26 -04:00
Don Slice
633e504d0a zebra: Eliminate use of imported arp entries as next-hops for other routes
Ticket: CM-8228
Signed-off-by: Donald Slice
Reviewed By:
Testing Done: Manual testing succesful. bgp-min and ospf-smoke successful. redistribute-neighbor-smoke
has the same failures as the base image.

Problem was due to considering imported /32 arp entries as elible next-hops for other routes
(in this case a static route.)  This confuses the rib since this next-hop is considered both
recursive and  onlink.  Disallowed the use of this imported arp entry in next-hop determination.
2016-07-15 06:33:48 -07:00
Timo Teräs
35d921cc20 zebra: use prefix2str for logging where possible
This makes code more robust, consice and readable.

Signed-off-by: Timo Teräs <timo.teras@iki.fi>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
(cherry picked from commit be6335d682c5ee1b6930345193eda875705fbab2)
2016-06-09 09:08:05 -04:00
David Lamparter
6c4f4e6e6a *: use void * for printing pointers
On higher warning levels, compilers expect %p printf arguments to be
void *.  Since format string / argument warnings can be useful
otherwise, let's get rid of this noise by sprinkling casts to void *
over printf calls.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-05-29 21:27:26 -04:00
Everton Marques
22afbf9446 zebra_rib: Revert work-around for zebra marking recursive static route as inactive. 2016-05-29 20:59:38 -04:00
Everton Marques
8f26ef2c68 zebra_rib: Revert debug hooks. 2016-05-29 20:58:42 -04:00
Balaji
7498d58d56 zebra: MBGP routes should not be installed in the kernel
MBGP routes are used only for PIM RPF checks and hence should
not be installed in the kernel's FIB. Ignore route node set to Multicast
SAFI.

Signed-off-by: Balaji.G <balajig81@gmail.com>
Acked-by: Everton Marques <everton.marques@gmail.com>
[pushed down rn->table->info assignment below assert]
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>

(cherry picked from commit 9511633e08ff15c23608983fdc1bc735d427332e)

Conflicts:
	zebra/zebra_rib.c
2016-05-26 20:42:53 +00:00
David Lamparter
4623d89737 zebra: make MRIB lookup behaviour switchable
depending on the usage scenario (and availability of multitopology IGP
protocols, which is currently zero in Quagga), different approaches of
Multicast RPF lookups are useful.

Reference behaviours from commercial vendors are urib-only/mrib-only
(Juniper, depending on inet.2 availability) and lowest-distance (Cisco).
As we are currently without MT IGP support, mrib-first seems the most
useful default for Quagga.

Cc: Everton Marques <everton.marques@gmail.com>
Cc: Balaji G <balajig81@gmail.com>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-05-25 20:38:31 -04:00
David Lamparter
33550aa869 zebra: return route_node from rib_match_ipv4_safi
The multicast code needs to know the route_node in addition to the rib
entry in order to perform distance or prefix-length comparisons.  Add it
as optional "out" pointer parameter.

Cc: Everton Marques <everton.marques@gmail.com>
Cc: Balaji G <balajig81@gmail.com>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-05-25 20:38:31 -04:00
David Lamparter
416ec78d3a zebra: dummy kernel "install" multicast routes
This is a followup to 9511633 ("zebra: MBGP routes should not be
installed in the kernel"), which was correct in disabling MRIB routes
being installed in the kernel, yet broke the MRIB since now routes were
never marked as active.

Hence, push down the check into the kernel install functions, so that
the routes are still marked active.  At the same time, the FPM calls get
a check each since otherwise we'd bump the FPM interface on MRIB
updates.

Fixes: 9511633 ("zebra: MBGP routes should not be installed in the kernel")
Cc: Everton Marques <everton.marques@gmail.com>
Cc: Balaji G <balajig81@gmail.com>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-05-25 20:38:31 -04:00
Everton Marques
b78a80d742 zebra: mrib: static route support
With the MRIB being independent from the Unicast RIB, there's currently
now way to add static routes to the MRIB.  Address that by adding a
separate set of commands for MRIB static routes.

Combines these original patches:
- zebra: mrib: ip mroute command to add unicast route to MRIB for multicast RPF.
- zebra: mrib: no ip mroute: Fix removal of static multicast RPF route.
- zebra: mrib: remove unused static_add/delete_ipv4
- zebra: Cleanups to zebra_rib.
- pimd: Merge pim-only branch.

Cc: Everton Marques <everton.marques@gmail.com>
Cc: Balaji G <balajig81@gmail.com>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-05-25 20:38:31 -04:00
Everton Marques
492dadb218 zebra: add rib_match_ipv4_safi()
This is the same as rib_lookup_ipv4(), without the SAFI hardcoded.

Cc: Balaji G <balajig81@gmail.com>
Cc: Everton Marques <everton.marques@gmail.com>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-05-25 20:38:31 -04:00
David Lamparter
cb65349115 zebra: identify MRIB on debug messages
since the same code handles both URIB and MRIB, the debug messages can
get rather confusing if the RIB isn't identified.  Mark the MRIB in
debug messages so we can distinguish that.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-05-25 20:38:31 -04:00
David Lamparter
2263a41286 zebra: factor out rib debug logs
Introduces a logging function that takes a struct route_node * argument,
and prefixes log output with that node's prefix.  While this removes
some duplication, it will also later be useful for srcdest route nodes.

Behaviour before and after the patch should be exactly identical.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-05-25 20:38:31 -04:00
Don Slice
8902474bd3 zebra: Add route-map support to ip import-table
Added the ability to supply a route-map to the ip import-table command,
which greatly improves filtering between the kernel prefixes in a
non-default table that are imported into the zebra rib.

Ticket:CM-8168
Signed-off-by: Donald Slice
Reviewed By: Donald Sharp
2016-05-12 20:22:53 -04:00
Donald Sharp
fb02523bf3 Fix unprotected debugs to warns and fix
In the case of a route replace failing we
saw two issues with the logging:

1) The route replace was a debug instead of a warn
  -> In this case change code to zlog_warn
2) The buf in the route replace was not being initialized
because buf initialization was protected by a debug check.
  -> In this case move the buf initialization to inside
the failure case.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2016-05-12 13:20:07 -04:00
Donald Sharp
a3d21ef32e zebra: Fix interface based static routes
This commit fixes interface based static routes.

static routes are now stored and if an interface
comes up it finds the route and installs it.

Ticket: CM-10869
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Don Slice <dslice@cumulusnetworks.com>
2016-05-10 15:07:04 -04:00
Donald Sharp
fb148af4a1 zebra: Add code to add/remove statics from the rib
On enable/disable of static routes add and remove them
from the rib as appropriate.

Ticket: CM-10139
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by: Don Slice <dslice@cumulusnetworks.com>
2016-05-06 10:41:28 -04:00
Donald Sharp
b9f1114e38 zebra: Stop passing around vrf_id for static_XXX functions
The static zebra functions are passing around the vrf_id
At the crunchy edges gather the zvrf from passed in
vrf name and pass that around instead.

Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-05-02 13:17:00 -04:00
Donald Sharp
01bb6d5798 zebra: Refactor zebra_vrf_static_table
We were passing in the vrf_id pass in the zvrf
instead.

Signed-off-by: donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Don Slice <dslice@cumulusnetworks.com>
2016-05-02 13:16:45 -04:00
vivek
3e5c6e00cb zebra: Implement recovery for route install failure
Quagga does not have proper recovery for route install failure (in
the kernel). The lack of this may not be a significant issue if the
failure is only an exception. However, the introduction of route
replace presents a new failure scenario which was not there earlier.
Before replace, the update operation involved a delete followed by
add; the failure of add would not leave hanging route entries in the
kernel as they would've got deleted first. With route replace, if
the replace fails, recovery action to delete the route is needed, else
the route remains hanging in the kernel.

In particular, with VRFs and in the presence of ECMP/multipath, a
failure mode exists where Quagga thinks that routes have been cleaned
up and deleted from the kernel but the kernel continues to retain them.
This happens when multiple VRF interfaces are moved from one VRF to
another.

This patch addresses this scenario by implementing proper recovery for
route install failure.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Dinesh Dutt <ddutt@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>

Ticket: CM-10361
Reviewed By: CCR-4566
Testing Done: bgp-min, ospf-min, bgp-smoke, ospf-smoke and manual

Note: There are some test failures and results aren't consistent across
runs; Daniel has resolved many of these through other fixes.
2016-04-28 22:09:17 -07:00
Daniel Walton
f857321ea9 BGP peers remain in active while rdnbrd is running.
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>

Ticket: CM-7789, CM-8806

If the route-map for an "ip import-table" denied a route it only flagged
the nexthop as inactive, it did not actually delete the route. This
breaks all directly connected EBGP peers that peer via IPv4 because NHT
finds this /32 with an inactive nexthop.
2016-04-25 20:19:08 +00:00
Donald Sharp
7c5519562e zebra: Refactor zebra_vrf
Move zebra_vrf_XXX functionality into it's own
file so that we can isolate a bit the api edges

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Don Slice <dslice@cumulusnetworks.com>
Reviewed-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2016-04-14 20:57:04 -04:00
Donald Sharp
44e9909db4 zebra: Refactor struct zebra_t
We were including 'extern struct zebra_t zebrad;' all
over the place.  This made no sense.  Refactor
into zserv.h where the definition was and remove resulting
unnecessary code.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Don Slice <dslice@cumulusnetworks.com>
Reviewed-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2016-04-14 20:56:45 -04:00
Donald Sharp
58255d3440 lib, zebra: Refactor vrf creation a bit more
Create the idea of a VRF_UNKNOWN, this is for a vrf where we don't
yet have the vrf_id for it yet.

Refactor the vrf_create code out of existence.  We had two code
paths vrf_create and vrf_get.  We should use vrf_get to create
the new vrf since XXX_get() creates the data structures now.

Signed-off-by: Donald Sharp
Reviewed-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2016-04-12 20:19:28 -04:00
vivek
154caaed00 Zebra: Fix VRF-id and table for BGP unnumbered (RFC 5549)
In the case of BGP unnumbered RFC 5549 (IPv4 routes with IPv6 nexthop), the
zebra code to handle routes was not initializing the correct VRF id and
locating the correct routing table, resulting in the routes not getting
installed. Fixed with this change.

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

Ticket: CM-10247
Reviewed By: CCR-4429
Testing Done: Manual verification
2016-04-06 14:07:05 -07:00