Commit Graph

444 Commits

Author SHA1 Message Date
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
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
Don Slice
6678277c70 zebra: close all tables when quagga is stopped
When signalled to stop quagga, iterate through any "other_tables" that may have
been imported and close them all before stopping.

Ticket: CM-9386
Signed-off-by: Don Slice
Reviewed-by: Donald Sharp
2016-04-01 16:12:33 -07:00
vivek
ca46a78e87 Zebra: Fix handling of larger table-ids
Zebra code was not handling larger table-ids correctly. There were 2 issues:

a) In the netlink interface, RTA_TABLE was never sent or processed. This
pretty much limited the table-ids that zebra could understand to < 255.

b) In the interface into the zebra RIB (in particular for protocols), there
were some incorrect checks that again assumed the table id should be < 252
or be "main". This is valid only for the Default VRF (for now), for other
VRFs, the table-id should be the value learnt from the kernel.

These two issues are addressed with this change.

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

Ticket: CM-10087, CM-10091
Reviewed By: CCR-4359
Testing Done: Manual
2016-03-24 22:38:40 -07:00
vivek
d82ae0dedc Zebra: Fix static NHT to work properly in a VRF
Implement VRF support for static nexthop resolution (NHT). This is
achieved by ensuring the correct VRF is passed as a parameter to
the NHT functions and is stored in the registered nexthop data
structure.

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

Ticket: CM-9457
Reviewed By: CCR-4185
Testing Done: Manual verification
2016-02-26 19:13:34 +00:00
vivek
9ec6b0bb0e Zebra: Perform NHT evaluation for VRFs
NHT evaluation was not being triggered for any VRF after RIB processing. Fix
this and attempt to schedule only those VRFs for which RIB processing was
scheduled.

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

Ticket: CM-9175
Reviewed By: CCR-4149
Testing Done: Manual verification
2016-02-23 03:42:19 +00:00
dslice
99a654bd0c zebra: fix creation of "other table" for rdnbrd
zebra: add the creation of the alternative table for rdnbrd in the context of vrfs

When rdnbrd pulls arp entries into table 10, which are then sent into quagga via netlink, the entries were incorrectly being added to the main table.  This fix creates or uses the alternative table if the table-id is not default but the vrf-id is default.  Tested manually and also run successfully in the /tests/l3/ospf_ebgp_redist_comprehensive_test.py:TestBasicEndToEndPing , which consistently failed bafore this fix was applied.

Signed-off-by: Don Slice
Reviewed-by: Donald Sharp
2016-02-18 08:19:42 -08:00
Daniel Walton
41d9cc6a65 quagga: remove babel
Ticket: CM-9274
Reviewed By: sharpd@cumulusnetworks.com
Testing Done:

<DETAILED DESCRIPTION (REPLACE)>
2016-02-11 08:55:24 -08:00
Donald Sharp
12f6fb9731 lib, zebra: The Bulk of the conversion over to NS and VRF
Convert the rest of zebra over to use a Namespae and VRF.

Signed-off-by: Vipin Kumar <vipin@cumulusnetworks.com>
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-02-01 10:55:42 -08:00
vivek
3d63d59fd1 Merge branch 'cmaster' of ssh://stash.cumulusnetworks.com:7999/quag/quagga into cmaster 2015-12-08 17:01:20 -08:00
vivek
1c8481370f Zebra: Schedule RIB processing based on trigger event
Currently, when RIB processing is initiated (i.e., by calling rib_update()),
all routes are queued for processing. This is not desirable in all situations
because, sometimes the protocol may have an alternate path. In addition,
with NHT tracking nexthops, there are situations when NHT should be kicked
off first and that can trigger subsequent RIB processing.

This patch addresses this by introducing the notion of a trigger event. This
is only for the situation when the entire RIB is walked. The current triggers
- based on when rib_update() is invoked - are "interface change" and "route-
map change". In the former case, only the relevant routes are walked and
scheduled, in the latter case, currently all routes are scheduled for
processing.

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

Ticket: CM-7662
Reviewed By: CCR-3905

Note: The initial defect in this area was CM-7420. This was addressed in
2.5.4 with an interim change that only walked static routes upon interface
down. The change was considered a bit risky to do for interface up etc. Also,
this did not address scenarios like CM-7662. The current fix addresses CM-7662.
2015-12-08 16:55:43 -08:00
Donald Sharp
ef16372d77 Merge branch 'cmaster' of ssh://stash.cumulusnetworks.com:7999/quag/quagga into cmaster 2015-12-08 15:26:56 -08:00
vivek
2bf26d4184 Zebra: Eliminate unnecessary del-add upon static route addition
When static routes are added, they get processed and potentially installed
in the RIB once. Subsequently, NHT is invoked and ends up scheduling the
route for processing again because this is the first time the nexthop is
resolved for NHT. This used to result in a del-add earlier (as noted in
the defect), but is a replace now. This change eliminates the unnecessary
replace by ensuring NHT is invoked first if the static route has a nexthop
that will be tracked by NHT.

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

Ticket: CM-4573
Reviewed By: CCR-3903
Testing Done: Manual and bgpsmoke

Note: Updates/improves static route NHT patch(es).
2015-12-08 15:04:48 -08:00
Donald Sharp
3ee39b5ba0 ZEBRA: Remove NEXTHOP_TYPE_XXX_IFNAME
The NEXTHOP_TYPE_XXX_IFNAME types were never being used.  Remove them
and the code associated with them.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2015-12-04 10:44:37 -08:00
Donald Sharp
ba77924165 zebra: Remove STATIC_XXX_IFNAME and use _IFINDEX
When we get a static route through an interface convert the interface
name to an ifindex and pass it through to zebra_rib.c. zebra_rib.c
should not care about the ifname.

This code change will allow us to collapse some of the NEXTHOP_XXX types.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2015-12-04 10:29:58 -08:00
Donald Sharp
cbdee2350a Merge branch 'cmaster' of ssh://stash.cumulusnetworks.com:7999/quag/quagga into cmaster 2015-11-27 08:58:52 -08:00
Donald Sharp
b3d439f347 Merge branch 'cmaster' of ssh://stash.cumulusnetworks.com:7999/quag/quagga into cmaster 2015-11-27 08:47:38 -08:00
Donald Sharp
a399694f39 Quagga: Nexthop refactoring
Upstream wanted some nexthop code to be refactored.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2015-11-27 08:46:54 -08:00
Donald Sharp
4690c7d74c Quagga: prefix2str fixup
During CR for nexthop upstream it was noticed that usage
of prefix2str was not consistent.  This fixes this problem

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2015-11-23 13:31:11 -08:00
vivek
41ec92223a Zebra: Cleanup RIB debugs
Some of the changes include:
- ensuring IPv6 addresses are printed correctly
- say 'updating' or 'deleting' etc. only when that is actually done
- say 'queuing' or 'dequeuing' only when that is actually done
- print useful info for 'detailed' debug - that now subsumes 'rib queue'
- delete various useless logs
- VRF-specific - print VRF id in RIB debugs prior to prefix
  (e.g., 4:37.1.1.0/28)

Ticket: CM-8110
Reviewed By: CCR-3765
Testing Done: Manual testing (2.5-br)
2015-11-20 08:48:32 -08:00
vivek
0b560feb23 Zebra: Fix replace route for uninstall scenario
When a Quagga route that is currently installed is superceded by a
kernel route (connected or static route to same destination), the
Quagga route is not uninstalled from the kernel. Fix by ensuring
this case is handled correctly.

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

Ticket: CM-7152
Reviewed By: CCR-3476
Testing Done: Manual tests and verify failed test.

Fixes: Replace route implementation (IPv4 and IPv6)
2015-11-19 12:48:02 -08:00
vivek
dccc522572 Zebra: Implement route replace for IPv6
Zebra currently performs a delete followed by add when a route needs to be
modified. Change this to use the replace semantics of netlink so that the
operation can possibly be atomic.

Note: This patch handles IPv6 routes, IPv4 already performs a replace.

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

Ticket: CM-5597
Reviewed By: CCR-3407
Testing Done: Manual testing of various scearnios (Vivek, Satish)

Note: This is an import of patch zebra-ipv6-route-replace.patch from 2.5-br.
2015-11-19 12:22:55 -08:00
Donald Sharp
9c2bf1cf39 zebra: Fix non usage of VRF_DEFAULT
A vrf_id was being set to 0 instead of VRF_DEFAULT

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2015-11-19 04:23:59 -08:00
Donald Sharp
d44ca835fc Zebra: Remove reliance on NEXTHOP_TYPE_IPV4_ONLINK
Zebra already knows if an interface is unnumbered or not.  This
is communicated to OSPF.
OSPF would only send a NEXTHOP_TYPE_IPV4_ONLINK *if* the path
was unnumbered, which it learns from Zebra.

As such, Have OSPF use the normal NEXTHOP_TYPE_IPV4_IFINDEX
type for unnumbered paths.  In Zebra, if the ifindex recieved
is unnumbered then assume that the link is NEXTHOP_FLAG_ONLINK.

Ticket: CM-8145
Reviewed-by: CCR-3771
Testing: See bug

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2015-11-16 12:48:07 -08:00
vivek
a219b2952a Zebra: Ensure correct route is used for redistribute delete.
After the optimization introduced by patch zebra-redist-update-fix.patch
which implements "replace" semantics for redistributed routes instead of
a delete followed by add, the code was passing an incorrect route for
redistribute deletion in one case. This is mainly inconsequential as of
now as the deletion process primarily cares about only the destination, but
the code needs to be corrected and that is done here.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
Fixes: zebra-redist-update-fix.patch

Ticket: CM-8112
Reviewed By: CCR-3760
Testing Done: Trivial

Note:
1. Needs changes after IPv6 route replace patches are included.
2. Imported from 2.5-br patch zebra-redist-delete-fix.patch
2015-11-15 07:36:50 -08:00
Donald Sharp
6f20b80d88 Zebra: Remove dependency on rib_bogus_ipv6
rib_bogus_ipv6 was removed upstream.  We need to do the same thing
and ensure that our ipv6 multipath still works

Ticket: CM-8152
Reviewed by: CCR-3775
Testing: Ran all multipath tests

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2015-11-09 17:02:26 -08:00
Donald Sharp
be5e48abec Merge branch 'cmaster' of ssh://stash.cumulusnetworks.com:7999/quag/quagga into cmaster
Conflicts:
	zebra/rib.h
	zebra/zebra_rib.c
	zebra/zebra_vty.c
2015-10-30 05:52:29 -07:00
Vipin Kumar
92955671de zebra_vrf lookup fix in upstream VRF patches
Ticket:
Reviewed By:
Testing Done:

<DETAILED DESCRIPTION (REPLACE)>
2015-10-30 02:12:14 -07:00
Feng Lu
8f7d9fc088 zebra, lib/memtypes.c: the netlink sockets work per VRF
This patch lets the netlink sockets work per VRF.

* The definition of "struct nlsock" is moved into zebra/rib.h.

* The previous global variables "netlink" and "netlink_cmd" now
  become the members of "struct zebra_vrf", and are initialized
  in zebra_vrf_alloc().

* All relative functions now work for a specific VRF, by adding
  a new parameter which specifies the working VRF, except those
  functions in which the VRF ID can be obtained from the interface.

* kernel_init(), interface_list() and route_read() are now also
  working per VRF, and moved from main() to zebra_vrf_enable().

* A new function kernel_terminate() is added to release the
  netlink sockets. It is called from zebra_vrf_disable().

* Correct VRF ID, instead of the previous VRF_DEFAULT, are now
  passed to the functions of processing interfaces or route
  entries.

Signed-off-by: Feng Lu <lu.feng@6wind.com>
Reviewed-by: Alain Ritoux <alain.ritoux@6wind.com>
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Acked-by: Donald Sharp <sharpd@cumulusnetworks.com>

Conflicts:
	lib/memtypes.c
	zebra/rib.h
	zebra/rt_netlink.c

Conflicts:
	zebra/if_netlink.c
	zebra/if_sysctl.c
	zebra/kernel_null.c
	zebra/rib.h
	zebra/rt_netlink.c
	zebra/rt_netlink.h
2015-10-30 01:45:21 -07:00
Feng Lu
a31c5886dd zebra: add hooks upon enabling / disabling a VRF
zebra_vrf_enable() is the callback for VRF_ENABLE_HOOK.
It presently needs do nothing.

zebra_vrf_disable() is the callback for VRF_DISABLE_HOOK.
It presently withdraws routes, shuts down interfaces, and
clears the router-id candidates in that VRF.

Signed-off-by: Feng Lu <lu.feng@6wind.com>
Reviewed-by: Alain Ritoux <alain.ritoux@6wind.com>
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Acked-by: Vincent JARDIN <vincent.jardin@6wind.com>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2015-10-30 00:32:56 -07:00
Feng Lu
8f527c5e7e zebra: configure static routes in any VRF
Introduce new commands to configure static routes in any VRF, by
appending the old static route commands with a new parameter
"vrf N".

A new parameter "const char *vrf_id_str" is added to the functions
zebra_static_ipv4() and static_ipv6_func() to get the configured
VRF ID.

A new member "vrf_id" is added to the "struct static_ipv4" and
"struct static_ipv6", indicating which VRF this static route is
configured in.

But till now, no interface can exist in any non-default VRF. So
these static routes in non-default VRFs are kept inactive.

Signed-off-by: Feng Lu <lu.feng@6wind.com>
Reviewed-by: Alain Ritoux <alain.ritoux@6wind.com>
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Acked-by: Vincent JARDIN <vincent.jardin@6wind.com>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>

Conflicts:
	zebra/zebra_rib.c
	zebra/zebra_vty.c
2015-10-30 00:12:52 -07:00
Feng Lu
0032dd59cd zebra: let the route-map rule "match interface" work for VRFs
Introduce a new "struct nexthop_vrfid" to specify a nexthop together
with the VRF ID it belongs to.

Thus in route_match_interface(), we can lookup the interface from
the correct VRF.

Signed-off-by: Feng Lu <lu.feng@6wind.com>
Reviewed-by: Alain Ritoux <alain.ritoux@6wind.com>
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Acked-by: Vincent JARDIN <vincent.jardin@6wind.com>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>

Conflicts:
	zebra/zebra_rib.c
	zebra/zebra_routemap.c
2015-10-29 23:52:37 -07:00
Feng Lu
78104b9bad zebra: let FIB stand for its respective VRF
A new member "vrf_id" is added to "struct rib", reflecting the VRF
which it belongs to.

A new parameter "vrf_id" is added to the relative functions where
need, except those:
- which already have the parameter "vrf_id"; or
- which have a parameter in type of "struct rib"; or
- which have a parameter in type of "struct interface".

All incoming routes are set to default VRF.

In fact, all routes in FIB are kept in default VRF. And the logic
is not changed.

Signed-off-by: Feng Lu <lu.feng@6wind.com>
Reviewed-by: Alain Ritoux <alain.ritoux@6wind.com>
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Acked-by: Vincent JARDIN <vincent.jardin@6wind.com>
[DL: conflicts fixed + compile warning fix]
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>

Conflicts:
	zebra/connected.c
	zebra/kernel_socket.c
	zebra/rib.h
	zebra/rt_netlink.c
	zebra/zebra_rib.c
	zebra/zserv.c

Conflicts:
	zebra/connected.c
	zebra/interface.c
	zebra/kernel_socket.c
	zebra/rib.h
	zebra/rt_netlink.c
	zebra/rtread_getmsg.c
	zebra/zebra_rib.c
	zebra/zebra_vty.c
	zebra/zserv.c
2015-10-29 23:38:03 -07:00
Feng Lu
b72ede27fd lib, zebra: move "struct vrf" to be a lib module
Previously "struct vrf" is defined locally in zebra. Now it is moved
to be a lib module.

This is the first step to support multi-VRF in quagga. The
implementation is splitted into small patches for the purpose of
easy review.

* lib:
    "struct vrf" with basic members is defined in vrf.c. The member
    "void *info" is for user data.

    Some basic functions are defined in vrf.c for adding/deleting/
    looking up a VRF, scanning the VRF table and initializing the
    VRF module.

    The type "vrf_id_t" is defined specificly for VRF ID.

* zebra:
    The previous "struct vrf" is re-defined as "struct zebra_vrf";
    and previous "vrf" variables are renamed to "zvrf".

    The previous "struct vrf" related functions are removed from
    zbera_rib.c. New functions are defined to maintain the new
    "struct zebra_vrf".

    The names vrf_xxx are reserved for the functions in VRF module.
    So:
    - the previous vrf_table() are renamed to zebra_vrf_table();
    - the previous vrf_static_table() are renamed to
      zebra_vrf_static_table().

    The main logic is not changed.

    BTW: Add a statement to zebra_snmp.c telling that the SNMP is
         running only for the MIBs in the default VRF.

Signed-off-by: Feng Lu <lu.feng@6wind.com>
Reviewed-by: Alain Ritoux <alain.ritoux@6wind.com>
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Acked-by: Vincent JARDIN <vincent.jardin@6wind.com>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>

Conflicts:
	lib/Makefile.am
	zebra/zebra_rib.c
	zebra/zebra_vty.c

Conflicts:
	lib/Makefile.am
	lib/memtypes.c
	zebra/rib.h
	zebra/zebra_rib.c
	zebra/zebra_rnh.c
	zebra/zebra_rnh.h
	zebra/zebra_vty.c
2015-10-29 16:45:10 -07:00
Donald Sharp
526e172845 zebra: Fix change of distance on ipv6 route creating duplicate routes
If you enter:

ipv6 route 2002:44:44:44::44/128 swp1 4
ipv6 route 2002:44:44:44::44/128 swp1 99

You get:

host-111# show ipv6 route
Codes: K - kernel route, C - connected, S - static, R - RIPng,
O - OSPFv6, I - IS-IS, B - BGP, A - Babel, T - Table,
> - selected route, * - FIB route
S 2002:44:44:44::44/128 [99/0] is directly connected, swp1
S>* 2002:44:44:44::44/128 [4/0] is directly connected, swp1

This problem is fixed in the ipv4 code path.  Copying the same
code from the ipv4 into the ipv6 code path fixes the issue.

With the fix:

host-111(config)# ipv6 route 2002:44:44:44::44/128 swp1 4
host-111(config)# do show ipv6 route
Codes: K - kernel route, C - connected, S - static, R - RIPng,
       O - OSPFv6, I - IS-IS, B - BGP, A - Babel, T - Table,
       > - selected route, * - FIB route

S>* 2002:44:44:44::44/128 [4/0] is directly connected, swp1
C * fe80::/64 is directly connected, swp1
C>* fe80::/64 is directly connected, eth0
host-111(config)# ipv6 route 2002:44:44:44::44/128 swp1 99
host-111(config)# do show ipv6 route
Codes: K - kernel route, C - connected, S - static, R - RIPng,
       O - OSPFv6, I - IS-IS, B - BGP, A - Babel, T - Table,
       > - selected route, * - FIB route

S>* 2002:44:44:44::44/128 [99/0] is directly connected, swp1
C * fe80::/64 is directly connected, swp1
C>* fe80::/64 is directly connected, eth0
host-111(config)#

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2015-10-23 17:48:27 -07:00
Donald Sharp
b8a1effadd zebra: Combine static_uninstall_ipv[4|6] into one function
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2015-10-22 17:58:59 -07:00
Donald Sharp
f2b49ed05e zebra: combine static_ipv[4|6]_nexthop_same into one function
Combine the static_ipv[4|6]_nexthop_same into static_nexthop_same.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2015-10-22 17:19:34 -07:00
Donald Sharp
bcd548ffa2 zebra: Combine static_install_ipv[4|6]
Combine the static_install_ipv[4|6] function calls into
static_install_route.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2015-10-22 17:19:34 -07:00
Donald Sharp
6ea317e85c zebra: Remove HAVE_IPV6 from rib.h and zebra_rib.c
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2015-10-22 17:19:34 -07:00
Donald Sharp
c0551cbbaf zebra: Collapse struct static_ipv[4|6] into struct static_route
The 'struct static_ipv4' and 'struct static_ipv6' structures
are essentially the same.  Collapse them into one data structure
'struct static_route'.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2015-10-22 17:19:27 -07:00
vivek
b84c725326 Zebra: On a link down, schedule static routes only.
Ticket: CM-7420
Reviewed By: Vivek, Donald
Testing Done: UT, verification of the fix + ospf and bgp smoke

On a link delete/down event, schedule only the prefixes which have a
static RIB too.

Signed-off-by: Vipin Kumar <vipin@cumulusnetworks.com>
Reviewed-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
2015-10-20 22:37:32 -07:00
vivek
c41fc67b25 Zebra: Redistribute replace handling corner cases
Ticket: CM-7309
Reviewed By: CCR-3448
Testing Done: passing route_ospf_route_thrash, the new redist test

When zebra was modified to have redistributed routes follow a replace
logic instead of the del-add, one case was missed. When a route is
replaced with a change only to the source protocol (say from static
to bgp), its possible that the new source protocol is not selected
for redistribution by a client. Since we did not delete the route
initially, if the add is not allowed for the new source protocol
for a client, we need to send a delete of that redistributed route.
This is what the patch fixes.

Signed-off-by: Dinesh G Dutt <ddutt@cumulusnetworks.com>
Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2015-10-20 21:52:52 -07:00
vivek
5048fe1444 Zebra: Make redistribute do replace instead of del/add for better convergence
Ticket: CM-6768
Reviewed By: CCR-3207
Testing Done: bgpsmoke, smoke, topo to create failure

Redistributing routes goes through a del/add cycle whenever a redistributed
is updated. This del/add cycle causes disruption by causing traffic loss
for brief/long periods of time(6-8 s in case of OSPF). The modifications in
this patch remove the del/add cycle to ensure that this disruption doesn't
happen.

Also fixed sending no forwarding address when announcing IPv4 routes with IPv6
nexthops, and sending nexthop only when there is a single path.

Signed-off-by: Dinesh G Dutt <ddutt@cumulusnetworks.com>
Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2015-10-20 21:38:38 -07:00
vivek
fb5d585cec Zebra: Fix setting source for 5549-learnt routes via ip protocol
Ticket: CM-6854
Reviewed By: CCR-3297
Testing Done: bgpsmoke, bgpclos to verify setting source (in 2.5-br)

Two pieces prevented the user from specifying a route-map with set src on
IPv4 routes learnt via BGP's RFC 5549 model (v4 prefix with v6 nexthop):
   - There was code missing in the section specific to 5549 in setting
     the src in the netlink message
   - During RIB processing, route-map processing was ignored when the NH
     was v6 and the route itself was v4.

As per the code, all route-map processing that uses nexthop validates the
NH type before applying the route-map and so there should be no errors
as a consequence of relaxing bullet 2 above.

Signed-off-by: Dinesh G Dutt <ddutt@cumulusnetworks.com>
Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
2015-10-20 14:32:12 -07:00
Dinesh G Dutt
0aabccc0a8 Zebra: Add IPv6 protocol filtering support & Setting Src of IPv6 routes
Ticket:
Reviewed By: CCR-3335
Testing Done: bgpsmoke, ENHE tests etc.

    Add support for filtering routes from upper layer protocols to zebra
    via route-maps for IPv6. The same functionality already existed for
    IPv4.

    In addition, add support for setting source of routes via IPv6 protocol
    map.

    Signed-off-by: Dinesh G Dutt <ddutt@cumulusnetworks.com>
    Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
    Reviewed-by: Vivek Venkataraman <vivek@cumulusnetworks.com>
    Reviewed-by: Vipin Kumar <vipin@cumulusnetworks.com>
2015-09-15 23:48:00 -07:00
vivek
deee6b32ee Zebra: Fix log related to delete notification for IPv6 route
Ticket: CM-7204
Reviewed By: CCR-3449
Testing Done: Verified the log manually

Port of patch zebra-fix-ipv6-route-delete-log.patch from 2.5-br
2015-09-02 16:43:33 -07:00
Donald Sharp
6baf7bb88b Create override for quagga reinstall of originated routes
Ticket: CM-7026
Reviewed by: CCR-3315
Testing: See bug

Quagga-dev suggested these changes for the quagga override of originated routes.
2015-08-26 05:21:40 -07:00
Donald Sharp
88177fe3ed Fixup of warnings in the code
Ticket: None
Reviewed by: Trivial
Testing:

A bunch of warnings have crept in to the code base.  This
fixes the issue
2015-07-25 15:55:47 -07:00
Donald Sharp
5c610fafc4 2015-06-11 09:19:59 -07:00
Donald Sharp
8a92a8a00c bgpd, zebra: rfc-5549-generic.patch
This adds support for BGP RFC 5549 (Extended Next Hop Encoding capability)

     * send and receive of the capability
     * processing of IPv4->IPv6 next-hops
     * for resolving these IPv6 next-hops, itsworks with the current
       next-hop-tracking support
     * added a new message type between BGP and Zebra for such route
       install/uninstall
     * zserv side of changes to process IPv4 prefix ->IPv6 next-hops
     * required show command changes for IPv4 prefix having IPv6 next-hops

Few points to note about the implementation:

     * It does an implicit next-hop-self when a [IPv4 prefix -> IPv6 LL next-hop]
       is to be considered for advertisement to IPv4 peering (or IPv6 peering
       without Extended next-hop capability negotiated)

     * Currently feature is off by default, enable it by configuring
       'neighbor <> capability extended-nexthop'

     * Current support is for IPv4 Unicast prefixes only.

IMPORTANT NOTE:

     This patch alone isn't enough to have IPv4->IPv6 routes installed into
     the kernel. A separate patch is needed for that to work for the netlink
     interface.

Signed-off-by: Vipin Kumar <vipin@cumulusnetworks.com>
Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com>
             Vivek Venkatraman <vivek@cumulusnetworks.com>
             Donald Sharp <sharpd@cumulusnetworks.com>
2015-06-11 09:19:12 -07:00
Donald Sharp
8733ba725d The CHANGED flag may be set for a route (RIB entry) due to change in
interface or nexthop status. However, this route may not be selected as
the best and may not be the prior best. The flag needs to be reset
after evaluating the route as not doing so may prevent future nexthop
validation for this route.
2015-06-11 09:11:12 -07:00
Donald Sharp
6ae24471cb Zebra: Implement route replace semantics.
Zebra currently performs a delete followed by add when a route needs to be
modified. Change this to use the replace semantics of netlink so that the
operation can possibly be atomic.

Note: Only implemented for IPv4 currently.
2015-06-11 09:11:12 -07:00
Donald Sharp
94ad353dfd Zebra: Optimize static route path deletion.
When a path of a static route is deleted, there is no need to reschedule and
run the RIB selection again, it is sufficient to just delete this path.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by:   Satish Ashok <sashok@cumulusnetworks.com>
2015-06-11 09:11:12 -07:00
Donald Sharp
18ff3eddcc Zebra: Don't resolve nexthops over default route unless explicitly allowed.
Ensure that resolution of a nexthop using a default route is not done in the
nexthop validation/update code in zebra_rib.c also. This is an addition to
the zebra-nht-no-default.patch which made the checks only in the NHT code. In
the case of scenarios like interface down, this nexthop update code will kick
in first to update the route before the NHT code comes into play; without the
additional fix, this code could incorrectly resolve the nexthop over a default
route, even when disallowed by the administrator.
2015-06-11 09:11:12 -07:00
Donald Sharp
4e3afb1472 zebra: zebra-warnings.patch
Remove compiled warnings for the zebra directory
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by:
2015-05-19 18:04:26 -07:00
Donald Sharp
078430f609 bgpd-nht-import-check-fix.patch
BGP: Fix network import check use with NHT instead of scanner

When next hop tracking was implemented and the bgp scanner was eliminated,
the "network import-check" command got broken. This patch fixes that
issue. NHT is used to not just track nexthops, but also the static routes
that are announced as part of BGP's network command. The routes are
registered only when import-check is enabled. To optimize performance,
we register static routes only when import-check is enabled.

Signed-off-by: Dinesh G Dutt <ddutt@cumulusnetworks.com>
2015-05-19 18:04:20 -07:00
Donald Sharp
ca657c652d Zebra: Static NHT fixes
When NHT calls rib_process() to be invoked for a prefix, the RIB has already
been marked as having NH changes. The first call to nexthop_active_update
clears this flag and attempts to re-determine if there are any NH changes for
a prefix. However, when the NH is recurisve, this fails. Furthermore, since
NHT has already determined that this RIB has NH changes, there's no need to
ascertain that again. The original patch used static route as the proxy to
skip this call which was incorrect since rib_process can be invoked for
static routes for reasons other than NHT. So, this patch removes the check
for static route and directly checks if the NH changed flag has been set.

Signed-off-by: Dinesh G Dutt <ddutt@cumulusnetworks.com>
Reviewed-by:   Vivek Venkataraman <vivek@cumulusnetworks.com>
2015-05-19 18:04:15 -07:00
Donald Sharp
70c0f18432 Zebra: Fix multiple RNH deletes
The code is structured in a way that ends up invoking zebra_delete_rnh()
multiple times which can lead to crashes and asserts. This patch fixes
the issue by setting a flag when an RNH structure is being deleted and
ignores any further attempts to delete the structure.
2015-05-19 18:04:10 -07:00
Donald Sharp
f44f6668ea Zebra: Add onlink attribute even for recursive routes
When a route is resolved recursively, and the recursively resolved nexthop
has the onlink attribute, the route is not programmed with the nexthop with
the onlink attribute. This patch addresses that.
2015-05-19 18:04:10 -07:00
Donald Sharp
ca84c8efc3 Add support for filtering by tag in a route-map when installing routes in the kernel 2015-05-19 18:03:44 -07:00
Donald Sharp
7a4bb9c54e zebra-redistribute-table.patch
Zebra: Redistribute routes from non-main kernel table to main.

This can be the basis for many interesting features such as variations
of redistribute ARP, using zebra as the RIB in the presence of multiple
routing protocol stacks etc. The code only supports IPv4 for now, but
the infrastructure is in place for IPv6.

Usage:
There is a new route type introduced by this model: TABLE. Routes
imported from alternate kernel tables will have their protocol type set to
TABLE.

Routes from alternate kernel tables MUST be first imported into the main
table via "ip import-table <table id>". They can then be redistributed via
a routing protocol via the "redistribute table" command. Each imported table
can an optional administrative distance specified. In Zebra, a route with a
lower distance is chosen over routes with a higher distance. So, distance
is how the user can choose to prioritize routes from a particular table over
routes from other tables or routes learnt another way in zebra.

Route maps for imported tables are specified via "ip protocol" command in
zebra. Route maps for redistributed routes within a routing protocol are
subject to the route map options supported by the protocol. The
"match source-protocol" option in route maps can match against "table"
to filter routes learnt from alternate kernel routing tables.

Signed-off-by: Dinesh G Dutt <ddutt@cumulusnetworks.com>
2015-05-19 18:03:42 -07:00
Donald Sharp
7c8ff89e93 Multi-Instance OSPF Summary
——————————————-------------

- etc/init.d/quagga is modified to support creating separate ospf daemon
  process for each instance. Each individual instance is monitored by
  watchquagga just like any protocol daemons.(requires initd-mi.patch).

- Vtysh is modified to able to connect to multiple daemons of the same
  protocol (supported for OSPF only for now).

- ospfd is modified to remember the Instance-ID that its invoked with. For
  the entire life of the process it caters to any command request that
  matches that instance-ID (unless its a non instance specific command).
  Routes/messages to zebra are tagged with instance-ID.

- zebra route/redistribute mechanisms are modified to work with
  [protocol type + instance-id]

- bgpd now has ability to have multiple instance specific redistribution
  for a protocol (OSPF only supported/tested for now).

- zlog ability to display instance-id besides the protocol/daemon name.

- Changes in other daemons are to because of the needed integration with
  some of the modified APIs/routines. (Didn’t prefer replicating too many
  separate instance specific APIs.)

- config/show/debug commands are modified to take instance-id argument
  as appropriate.

Guidelines to start using multi-instance ospf
---------------------------------------------

The patch is backward compatible, i.e for any previous way of single ospf
deamon(router ospf <cr>) will continue to work as is, including all the
show commands etc.

To enable multiple instances, do the following:

     1. service quagga stop
     2. Modify /etc/quagga/daemons to add instance-ids of each desired
        instance in the following format:
        ospfd=“yes"
        ospfd_instances="1,2,3"
	assuming you want to enable 3 instances with those instance ids.
     3. Create corresponding ospfd config files as ospfd-1.conf, ospfd-2.conf
        and ospfd-3.conf.
     4. service quagga start/restart
     5. Verify that the deamons are started as expected. You should see
        ospfd started with -n <instance-id> option.
     	ps –ef | grep quagga
     	With that /var/run/quagga/ should have ospfd-<instance-id>.pid and
	ospfd-<instance-id>/vty to each instance.
     6. vtysh to work with instances as you would with any other deamons.
     7. Overall most quagga semantics are the same working with the instance
     	deamon, like it is for any other daemon.

NOTE:
     To safeguard against errors leading to too many processes getting invoked,
     a hard limit on number of instance-ids is in place, currently its 5.
     Allowed instance-id range is <1-65535>
     Once daemons are up, show running from vtysh should show the instance-id
     of  each daemon as 'router ospf <instance-id>’  (without needing explicit
     configuration)
     Instance-id can not be changed via vtysh, other router ospf configuration
     is allowed as before.

Signed-off-by: Vipin Kumar <vipin@cumulusnetworks.com>
Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by: Dinesh G Dutt <ddutt@cumulusnetworks.com>
2015-05-19 18:03:42 -07:00
Donald Sharp
c8a1cb5c9d onlink commit from Quagga-RE branch 2015-05-19 17:58:13 -07:00
Donald Sharp
c52ef59fed zebra-set-src-routemap.patch
Honor setting source via route map and pushing that to the kernel.

With recursive routes, the ability to set the source IP address of a route
via a routemap has been broken. This patch fixes that.

To allow route map to set a source and then to unapply the route map and
have the source be taken out, I've introduced a new field in the nexthop
data structure called rmap_src. This field is zero'd before invoking the
route map apply function.

Today, no protocol daemon specifies the src in its route update to zebra.
If that happens, I didn't want to stomp on it and so have left the src
field intact instead of reusing that for the routemap to play with.

Signed-off-by: Dinesh G Dutt <ddutt@cumulusnetworks.com>
2015-05-19 17:47:24 -07:00
Donald Sharp
04b02fda9f zebra: zebra-client-info-detail.patch
Zebra: Gather and display detailed info about clients of Zebra

The display of zebra client info is rather paltry: just the name and the FD.
For troubleshooting and general helpfulness, its useful to gather more info
about each client and display that. This patch does just that.
2015-05-19 17:47:22 -07:00
Donald Sharp
6e26278cba zebra: zebra-static-route-nht.patch
Use NHT to support static routes with NH derived from protocols.
2015-05-19 17:47:22 -07:00
Donald Sharp
9f0ea7d4f2 zebra: zebra-nht-routemap.patch
Zebra: Add route-map support for Next Hop Tracking

It is sometimes useful to restrict the resolution of recursive routes
to only specific via's. For example, in some configurations resolving
a route through a default route is not acceptable.

This patch adds a new route-map attach point, to zebra's next-hop-tracking
server. Whenever NHT is considering sending notification of a route
resolution, it applies a specified route-map and only if it passes, is the
NHT reachable message sent to the appropriate client protocol (BGP, OSPF etc.).
If the route-map filters the resolution, then a withdraw is sent to the
client protocol.

The route-map is sent the ip address of the route via which the resolution is
happening as well as the valid NHs associated with that route.

We also add support for matching on IP addr prefix len and source protocol
to ensure that resolution happens only via a very specific route.
2015-05-19 17:47:20 -07:00
Donald Sharp
0d9551dc3c Add support for route tags
Credit
------
A huge amount of credit for this patch goes to Piotr Chytla for
their 'route tags support' patch that was submitted to quagga-dev
in June 2007.

Documentation
-------------
All ipv4 and ipv6 static route commands now have a "tag" option
which allows the user to set a tag between 1 and 65535.

quagga(config)# ip route 1.1.1.1/32 10.1.1.1 tag ?
  <1-65535>  Tag value
quagga(config)# ip route 1.1.1.1/32 10.1.1.1 tag 40
quagga(config)#

quagga# show ip route 1.1.1.1/32
Routing entry for 1.1.1.1/32
  Known via "static", distance 1, metric 0, tag 40, best
  * 10.1.1.1, via swp1

quagga#

The route-map parser supports matching on tags and setting tags
!
route-map MATCH_TAG_18 permit 10
 match tag 18
!

!
route-map SET_TAG_22 permit 10
 set tag 22
!

BGP and OSPF support:
- matching on tags when redistribing routes from the RIB into BGP/OSPF.
- setting tags when redistribing routes from the RIB into BGP/OSPF.

BGP also supports setting a tag via a table-map, when installing BGP
routes into the RIB.

Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2015-05-19 17:46:33 -07:00
Donald Sharp
518f0eb188 bgpd: bgpd-event-driven-route-map-updates.patch
BGP: Reprocess the trigger points when an attached route map changes

Currently, modifications to route maps do not affect already processed
routes; they only affect new route updates. This patch addresses this
limitation.

Signed-off-by: Dinesh G Dutt <ddutt@cumulusnetworks.com>
2015-05-19 17:40:45 -07:00
Donald Sharp
2037f143d8 Do not allow a program outside Quagga to delete a Quagga route from the kernel.
To delete a Quagga route, do it inside Quagga.
2015-05-19 17:40:43 -07:00
Donald Sharp
fb018d251e nexthop-tracking.patch
quagga: nexthop-tracking.patch

Add next hop tracking support to Quagga. Complete documentation in doc/next-hop-tracking.txt.

Signed-off-by: Pradosh Mohapatra <pmohapat@cumulusnetworks.com>
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
Signed-off-by: Dinesh Dutt <ddutt@cumulusnetworks.com>
2015-05-19 17:40:34 -07:00
Donald Sharp
41fc27146a This patch enables support for multipath for IPV6. The nexthop information
from the protocols have ifindices and nexthop addresses in two different
structures. This patch combines them to ensure that the correct APIs can
be called. Also, given that IPV6 Linux implementation does not support the
rta_XXX APIs for multipath, the communication with the kernel is in terms
of a single nh/ifindex pair.
2015-05-19 17:24:43 -07:00
Donald Sharp
4595531e1d zebra-non-default-table-for-static-routes.patch
Make static IPv6 routes respect non-default routing tables.

Signed-off-by: Nolan Leake <nolan@cumulusnetworks.com>
Reviewed-by: Shrijeet Mukherjee <shm@cumulusnetworks.com>
2015-05-19 16:37:41 -07:00
David Lamparter
6b0655a251 *: nuke ^L (page feed)
Quagga sources have inherited a slew of Page Feed (^L, \xC) characters
from ancient history.  Among other things, these break patchwork's
XML-RPC API because \xC is not a valid character in XML documents.

Nuke them from high orbit.

Patches can be adapted simply by:
	sed -e 's%^L%%' -i filename.patch
(you can type page feeds in some environments with Ctrl-V Ctrl-L)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2014-06-04 06:58:02 +02:00
David Lamparter
f7bf41534e zebra: apply syntactic sugar to rib_dump()
strip the explicit __func__ present on all calls and make the prefix
argument a transparent union.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2014-04-01 17:27:58 +02:00
Christian Franke
b52aef18a9 zebra: log routes w/o gateway in rib_delete_ipv4
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
Acked-by: Feng Lu <lu.feng@6wind.com>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2014-02-11 04:53:14 +01:00
Vincent Bernat
fed643f409 zebra: make rib_dump() compatible with IPv6 RIB
[DL: resolved conflicts in zebra_rib.c]
[DL: fix usage with --disable-ipv6]
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2013-10-22 10:38:35 -07:00
Christian Franke
f3a1732eb3 zebra: apply route-maps for interface routes
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2013-09-19 18:04:40 +02:00
Christian Franke
c3e6b59516 zebra: fix recursive-routes via ifindex routes
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2013-09-19 18:04:40 +02:00
Christian Franke
48a53dc71c zebra: handle blackholes encountered in recursive resolution
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2013-09-19 18:04:40 +02:00
Christian Franke
fa713d9ee5 zebra: rework recursive route resolution
Change the datastructure for recursive routes. This brings the following
benefits:

By using struct nexthop also to store nexthops obtained by recursive
resolution, we can get rid of quite a bit of code duplication in the fib
management. (rt_netlink, rt_socket, ...)

With the new datastructure we can make use of all available paths when
recursive routes are resolved with multipath routes.

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2013-09-19 18:04:40 +02:00
Leonid Rosenboim
9499bf2bc6 zebra: don't overrun afi/safi array boundaries
zebra was not checking afi/safi values.  This was leading to crashes where
these values were coming directly from some protocol's on-wire fields.
Safeguarding them in zebra is a good start.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2013-01-14 16:07:25 +01:00
Avneesh Sachdev
5adc2528d3 zebra: add module to communicate routes to FPM
Enhance zebra to send routes to the (optional) Forwarding Path Manager
component using the interface defined by fpm/fpm.h.

  * configure.ac

    - Add --enable-fpm flag.

      The FPM-related code in zebra is activated only if the build is
      configured with '--enable-fpm'.

    - Add HAVE_NETLINK automake conditional.

      This allows us to conditionally build netlink-dependent C code.

  * zebra/{rib.h,zebra_rib.c}

    - Add the 'fpm_q_entries' field to the rib_dest_t structure. This
      allows dests to be placed on the fpm queue.

    - Define a couple new rib_dest_t flags that hold FPM-related
      state.

    - Invoke the zfpm_trigger_update() function for a route_node
      whenever the information to be sent to the FPM changes.

    - rib_can_delete_dest(): Return FALSE if we have to update the FPM
      about the given dest. This ensures that the dest is not deleted
      even if there are no ribs hanging off of it.

  * zebra/zebra_fpm.c

    This file holds most of the code for interacting with the FPM.

    - If quagga was configured with '--enable-fpm', periodically try
      to connect to the FPM.

    - When the connection comes up, enqueue all relevent dests to the
      FPM queue.

    - When the FPM socket is readable, dequeue the next rib_dest_t
      from the FPM queue, encode it in to a message and send the
      message to the FPM.

    - When the connection to the FPM goes down, remove all dests from
      the FPM queue, and then start trying to connect to the FPM
      again.

    - Expose the following new operational commands:

      show zebra fpm stats
      clear zebra fpm stats

  * zebra/zebra_fpm_netlink.c

    - zfpm_netlink_encode_route(): Function to encode information
      about a rib_dest_t in netlink format.

  * zebra/zebra_fpm_private.h

    Private header file for the zebra FPM module.

  * zebra/zebra_fpm.h

    Header file exported by zebra FPM module to the rest of zebra.

  * zebra/debug.c

    Add the 'debug zebra fpm' command.

  * zebra/main.c

    Initialize the zebra-FPM code on startup.

  * zebra/misc_null.c

    Add stub for zfpm_trigger_update().

  * zebra/Makefile.am

    - Include new file zebra_fpm.c in build.

    - Include zebra_fpm_netlink.c in build if HAVE_NETLINK is defined.

  * vtysh/Makefile.am

    Include zebra_fpm.c in list of files that define cli commands.

Signed-off-by: Avneesh Sachdev <avneesh@opensourcerouting.org>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2012-11-30 21:41:17 +01:00
Avneesh Sachdev
78deec450c zebra: extern/extract some functions from rt_netlink.c
* zebra/{rib.h,zebra_rib.c}

    Add nexthop_type_to_str(), which returns a human-readable string
    corresponding to a nexthop type.

  * zebra/rt_netlink.[hc]

    - Add new header file that exposes some existing and new
      netlink-related functions from rt_netlink.c to the rest of
      zebra.

        addattr32
        addattr_l
        rta_addattr_l
        nl_msg_type_to_str (new)
        nl_rtproto_to_str (new)

    - Use nexthop_type_to_str() instead of the static array
      'nexthop_types_desc'.

Signed-off-by: Avneesh Sachdev <avneesh@opensourcerouting.org>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2012-11-30 21:41:17 +01:00
Avneesh Sachdev
0915bb0ce2 zebra: add iterator for walking all tables in RIB
* lib/zebra.h

    Add macro ZEBRA_NUM_OF, which returns the number of elements in a
    static array.

  * zebra/rib.h

    Add the rib_tables_iter_t structure and associated functions,
    which allow one to walk all tables in the rib.

  * zebra/zebra_rib.c

    - Add vrf_id_get_next() to retrieve the first VRF id (if any) that
      is greater than a given VRF id.

    - Add rib_tables_iter_next().

Signed-off-by: Avneesh Sachdev <avneesh@opensourcerouting.org>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2012-11-30 21:41:16 +01:00
Avneesh Sachdev
1b5ed1b054 zebra: add way to determine VRF/AFI/SAFI of table
Add some code that allows us to determine which VRF and AFI/SAFI a
given RIB table corresponds to.

  * zebra/rib.h

    Add rib_table_info_t structure, which contains information about
    the VRF, AFI and SAFI that a table is for.

  * zebra/zebra_rib.c

    - Add the vrf_table_create() function, which creates a table and
      sets its 'info' pointer to a newly created rib_table_info_t.
      The 'info' pointer allows us to go from a route_node or a table
      to the associated vrf.

    - vrf_alloc(): Use vrf_create_table() to create tables.

  * lib/memtypes.c

    Add memory type for rib_table_info_t.

Signed-off-by: Avneesh Sachdev <avneesh@opensourcerouting.org>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2012-11-30 21:41:16 +01:00
Avneesh Sachdev
9fd92e3c4b zebra: add structure to hold per-prefix state in RIB
Add the rib_dest_t structure to hold per-prefix state in the routing
information base. This gives us an appropriate place to maintain the
queueing state of a route_node. Queuing state was previously being
stored on the first rib in the list of ribs hanging off the
route_node.

  * zebra/rib.h

    - Add new structure rib_dest_t.

    - Remove the rn_status field from 'struct rib', it is no longer
      required.

    - Add macros (RNODE_FOREACH_RIB, RNODE_FOREACH_RIB_SAFE) for
      walking all 'struct ribs' corresponding to a route_node. These
      hide the fact that there is an intermediate rib_dest_t
      structure.

    - Add a few utility inlines to go between a rib_dest_t and
      associated structures.

  * zebra/zebra_rib.c

    - rib_link()/rib_unlink()

      Tweak for new behavior, where the 'info' pointer of a route_node
      points to a rib_dest_t. The list of ribs for a prefix now hangs
      off of the dest.

      Change the way we ref count route_nodes. We now hold a single
      ref count on a route_node if there is a corresponding
      rib_dest_t.

    - Maintain the queuing state of a route_node on the flags field of
      the rib_dest_t.

    - Add the rib_gc_dest() function, which deletes a rib_dest_t if it
      is no longer required. A rib_dest_t can be deleted iff there are
      no struct ribs hanging off of it.

    - Call rib_gc_dest() any time we unlink a rib from the
      rib_dest_t. Currently we only need to call it once, just before
      we return from rib_process().

  * zebra/{redistribute,zebra_rib,zebra_snmp,zebra_vty}.c

    Use new macros to walk over route_node ribs.

  * lib/memtypes.c

    Add memory type for rib_dest_t.

Signed-off-by: Avneesh Sachdev <avneesh@opensourcerouting.org>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2012-11-30 21:41:16 +01:00
Balaji.G
837d16ccbe *: use array_size() helper macro
Use the array_size() helper macro.  Replaces several instances of local
macros with the same definition.

Reviewed-by: Scott Feldman <sfeldma@cumulusnetworks.com>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2012-10-25 10:15:59 -07:00
Nolan Leake
b0145ddb4b zebra: make static routes respect table setting
Make static routes respect non-default routing tables.

BEFORE PATCH
------------

! in zebra.conf
table 1

! add static route
vtysh> ip route 10.0.0.0/30 eth0

cumulus@net-top0:~$ ip route
default via 192.168.0.2 dev eth0
10.0.0.0/30 dev eth0  proto zebra
192.168.0.0/24 dev eth0  proto kernel  scope link  src 192.168.0.15

! nothing in table 1
cumulus@net-top0:~$ ip route show table 1

AFTER PATCH
-----------

! in zebra.conf
table 1

! add static route
vtysh> ip route 10.0.0.0/30 eth0

cumulus@net-top0:~$ ip route
default via 192.168.0.2 dev eth0
192.168.0.0/24 dev eth0  proto kernel  scope link  src 192.168.0.15

! static route in table 1
cumulus@net-top0:~$ ip route show table 1
10.0.0.0/30 dev eth0  proto zebra

Signed-off-by: Nolan Leake <nolan@cumulusnetworks.com>
Reviewed-by: Scott Feldman <sfeldma@cumulusnetworks.com>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2012-10-25 10:15:58 -07:00
Jorge Boncompte [DTI2]
128293286a lib, zebra: extend use of sockunion2ip macro
* lib/sockunion.c,
  * zebra/zebra_rib.c: replace ->sin.sin_addr.s_addr with sockunion2ip

Signed-off-by: Jorge Boncompte [DTI2] <jorge@dti2.net>
[reworded commit message]
Signed-off-by: David Lamparter <equinox@diac24.net>
2012-05-02 17:03:28 +02:00
David Lamparter
9665856e37 Revert "zebra: clean up client routes when client goes away"
This reverts commit af56d404cd,
which was accidentally duplicating functionality from commit
2ea1ab1 "zebra: ZEBRA_HELLO and mopping up routes (BZ#448)"

Conflicts:

	zebra/zebra_rib.c

Signed-off-by: David Lamparter <equinox@diac24.net>
2012-04-20 17:29:31 +02:00
Avneesh Sachdev
14d2bbaa3f Merge quagga mainline into the google ISIS code.
The steps were:

  $ git checkout google-is-is
  $ git merge quagga
  $ git checkout google-is-is -- isisd

  # Resolve conflicts in the following:
  lib/md5.h
  zebra/rt_netlink.c
  zebra/zebra_rib.c
  zebra/zserv.c

Note that the content in the isisd directory is left unchanged in the
merge. As a result, changes made to isisd as part of the following
commits on the quagga mainline are dropped.

  # 8ced4e82 is the merge base, e96b3121 is the current quagga master
  $ git log --oneline --reverse 8ced4e82..e96b3121 -- isisd
  5574999 isisd: fix crash on "no router isis" (BZ#536)
  8998075 isisd: raise hello rate for DIS (BZ#539)
  306ca83 isisd: include hash.h, not hash.c
  b82cdeb delete CVS keywords
  2f65867 isisd: indent longopts array
  b511468 quagga: option "-z" ("--socket <path>") added
  05e54ee build: delete .cvsignore files
  b4e45f6 fix zebra protocol after MP-BGP changes
  7fd6cd8 isisd: fix circuit state machine
  907fd95 isisd: send proper LSP after DIS election
  d034aa0 isisd: fix wrong next-hops from SPF
  c25eaff isisd: unexpected kernel routing table (BZ#544)
  e6b03b7 isisd: implement MD5 circuit authentication
2012-04-11 23:51:08 -07:00
Josh Bailey
af56d404cd zebra: clean up client routes when client goes away
* zebra/zebra_rib.c: Add code to clean up routes added by a client
    (as identfied by 'rib type').

  * zebra/zserv.[ch]: Maintain the type of the routes added by a
    client on the 'zserv' structure -- assume that a given client uses
    a single route type for now.

    Clean up routes from a client when the client goes away (in
    zebra_client_close()).

From: Josh Bailey <joshb@google.com>
Signed-off-by: Avneesh Sachdev <avneesh@opensourcerouting.org>
Signed-off-by: David Lamparter <equinox@diac24.net>
2012-04-08 00:28:50 -07:00
Subbaiah Venkata
fc328ac9d3 zebra: add more logs/asserts to rib work queue code
* zebra/zebra_rib.c: (rib_queue_add, rib_queue_init) Add some more
    logs and asserts.

From: Subbaiah Venkata <svenkata@google.com>
Signed-off-by: Avneesh Sachdev <avneesh@opensourcerouting.org>
Signed-off-by: David Lamparter <equinox@diac24.net>
2012-04-07 23:52:40 -07:00
Josh Bailey
26e2ae362b zebra: read multipath routes and hw addr from netlink
* zebra/rt_netlink.c:

    - Pick up the hardware address of an interface when we receive a
      netlink link change message. Extract code for parsing the
      link-layer hardware address into a new function so we can reuse
      it.

    - netlink_routing_table(): Update to handle multipath routes.

    - netlink_route_change(): Update to handle multipath routes. Fix
      problem where the metric was not being read out.

  * zebra/zebra_rib.[ch]: Extern nexthop_ipv4_ifindex_add() -- it is
    now called from the netlink code.

From: Josh Bailey <joshb@google.com>
Signed-off-by: Avneesh Sachdev <avneesh@opensourcerouting.org>
Signed-off-by: David Lamparter <equinox@diac24.net>
2012-04-07 13:54:02 -07:00
Paul Jakma
5734509c05 babeld: Initial import, for Babel routing protocol.
* Initial import of the Babel routing protocol, ported to Quagga.
* LICENCE: Update the original LICENCE file to include all known potentially
  applicable copyright claims.  Ask that any future contributors to babeld/
  grant MIT/X11 licence to their work.
* *.{c,h}: Add GPL headers, in according with the SFLC guidance on
  dealing with potentially mixed GPL/other licensed work, at:

  https://www.softwarefreedom.org/resources/2007/gpl-non-gpl-collaboration.html
2012-03-25 17:06:51 +01:00
G.Balaji
f768f367bc zebra: IPv6 MP-BGP Routes addition and deletion
This patch contains the following:
1. Addition of IPv6 SAFI_MULTICAST BGP routes into the RTM's RIB.
2. Deletion of IPv6 SAFI_MULTICAST BGP routes from the RTM's RIB.
2012-01-23 14:30:57 +04:00
G.Balaji
cddf391bf6 zebra: IPv4 MP-BGP Routes addition and deletion
This patch contains the following:
1. Addition of IPv4 SAFI_MULTICAST BGP routes into the RTM's RIB.
2. Deletion of IPv4 SAFI_MULTICAST BGP routes from the RTM's RIB.
2012-01-23 14:30:42 +04:00
Matthias Ferdinand
4f1735fd6a zebra: fix ifindex test condition (BZ#487)
When the same ip address is used on several interfaces,
and one of them gets deleted (or equivalent: set to down and
then address removed), rib_delete_ipv[46] will also remove
the connected route from other interfaces.

rib_delete_ipv[46] is called twice when an interface is
deleted:
    - for the "ifdown" event
    - for the address removal
(note: this may be specific to the netlink interface of linux)
The second call does not find the connected route to that same
ifindex anymore, but deletes similar connected routes to any
other ifindex instead.

Reason: the ifindex check is on the same level as the check
for ZEBRA_ROUTE_CONNECT/NEXTHOP_TYPE_IFINDEX. If everything
matches except for the ifindex, the "else" part (intended for
different route types) is executed, thus removing the route
from the wrong interface.

fix: move ifindex check inside the "then" part of the check
for ZEBRA_ROUTE_CONNECT/NEXTHOP_TYPE_IFINDEX. Now connected
routes to other ifindexes will not spill over to the "else"
part for different route types anymore.
2012-01-02 19:13:58 +04:00
Vyacheslav Trushkin
2ea1ab1c30 zebra: ZEBRA_HELLO and mopping up routes (BZ#448)
ZEBRA_HELLO message is used by routing daemons to inform zebra
what type of routes daemon will be announcing to zebra. Also
zebra uses route_type_oaths array to track which daemon announces
which protocol. Zebra mops up routes if daemon didn't for some
reason.
2012-01-02 18:37:24 +04:00
David Lamparter
7052f22880 rib: default distance value for new protocols (v2)
adding protocols and forgetting to update zebra_rib.c currently causes
a beyond end of array access for the default distance value. fix by
making 150 the default distance for unknown routing protocols.

150 is higher than all other IGPs but lower than iBGP (200)
2011-12-13 19:12:49 +04:00
Stephen Hemminger
cc2dd9280c zebra: cleanup RIB meta queue code
* zebra/zebra_rib.c
  * rib_queue_add(): indent comments and simplify debug code
  * rib_queue_init(): remove unneeded assert() calls and
    extra return statements
2009-12-09 17:54:49 +03:00
Stephen Hemminger
d02c56cdf0 zebra: fix more compiler warnings
* zebra/zebra_rib.c
  * nexthop_active_update(): make local int vars unsigned
  * nexthop_active_check(): return unsigned for consistency
  * rib_dump(): cast time in printf format
  * vrf_free(): remove unused function
  * vrf_lookup_by_name(): idem
  * rib_if_up(): idem
  * rib_if_down(): idem
2009-12-08 13:14:27 +03:00
David Ward
a50c107e3f zebra: fix RIB debug message for IPv6
Apply changes from commit f304cb48f0
to rib_queue_add.

Also includes spelling fixes.
2009-12-03 15:34:39 +03:00
Chris Caputo
67b9467f6c [zebra] Silence noisy process_subq
zebra_rib.c: process_subq(): #ifdef out debug code.
2009-07-21 10:13:11 +01:00
Joakim Tjernlund
c3a5606302 zebra: Static route does not reach kernel.
A static route like below: ip route 172.16.1.0/30 192.168.101.162 11
does not move properly to a new interface when the
interface used goes down. Zebra reports that it have
moved but kernel isn't informed so the route is lost.

* zebra_rib.c: (nexthop_active_update) if ifindex has changed, then the
  route should be considered to have changed.

Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
2009-06-24 22:43:58 +01:00
Stephen Hemminger
81cce0185e [cleanup] Use correct buffer size for inet_ntop()
Don't need big buffer 1024 to hold IPV4 (INET_ADDRSTRLEN)
or IPv6 (INET6_ADDRSTRLEN) message.
2009-06-18 20:18:27 +01:00
Stephen Hemminger
6c684653f0 [zebra] remove incorrect debug message 2009-06-18 20:18:25 +01:00
Stephen Hemminger
5110a0c622 [zebra] Cleanup meta-queue code
Do some cleanup work on recently added meta-queue code:
  * use table rather than switch
  * indent with quagga standard indentation
  * since meta_queue_new is only used at initialization
    allocation failure should be fatal.
2009-06-18 20:18:25 +01:00
Stephen Hemminger
393deb9bd6 [cleanup] Convert XMALLOC/memset to XCALLOC
Simple conversion of XMALLOC/memset to XCALLOC
2009-06-12 17:07:49 +01:00
Stephen Hemminger
ef9b113e2d [zebra] trivia: static qualifiers for metaq
2008-08-17 Stephen Hemminger <stephen.hemminger@vyatta.com>

	* zebra_rib.c: (process_subq) mark static
	  (rib_meta_queue_add) ditto
	  (meta_queue_new) ditt

Signed-off-by: Paul Jakma <paul@quagga.net>
2008-08-22 19:56:26 +01:00
Stephen Hemminger
d145bc008a [zebra] make some data local
2008-06-17 Stephen Hemminger <stephen.hemminger@vyatta.com>

	* zebra_rib.c: static qualifier on local data

Signed-off-by: Paul Jakma <paul@quagga.net>
2008-08-22 19:56:25 +01:00
Stephen Hemminger
16814f9698 [zebra] ignore dead routes in RIB update
2008-08-17 Stephen Hemminger <stephen.hemminger@vyatta.com>

	* zebra_rib.c: When doing a RIB update, routes in process of removal
	  should be ignored. This fixes bugs where a route is removed but a
	  recursive route is not changed.

Signed-off-by: Paul Jakma <paul@quagga.net>
2008-08-22 19:56:25 +01:00
Denis Ovsienko
e96f92034d + initial edition of meta-queue for RIB updates processing (bug #431) 2008-06-02 12:03:22 +00:00
Denis Ovsienko
20e5ff0a88 + fix bug#326 by rib_lookup_and_pushup() 2008-02-26 14:02:24 +00:00
Andrew J. Schorr
3f087670ef [link-detect] Static interface routes should behave properly with link-detect.
2008-01-08 Michael Larson <mike@vyatta.com>

	* zebra_rib.c: (nexthop_active_check) Replace if_is_up with
	  if_is_operative to solve problems with static interface
	  routes not behaving properly with link-detect.
2008-01-08 20:12:46 +00:00
Denis Ovsienko
a3aaf5b0ce + rib_process() speedup for multi-nexthop route nodes 2007-10-04 10:49:21 +00:00
Denis Ovsienko
f304cb48f0 + Minor bugfix: IPv6 prefixes were logged incorrectly in RIB debugging calls. Fixed. 2007-10-03 12:27:16 +00:00
Denis Ovsienko
03e232a458 Merged own patch for bug #390 (rewrite zebra/zebra_rib.c:nexthop_active_update()) 2007-08-14 09:46:48 +00:00
Denis Ovsienko
dc95824ae1 Merged own patch for the bug #391 (debugging and comments mostly). 2007-08-13 16:03:06 +00:00
Paul Jakma
93bdadae74 [zebra] Add extra debug logging for RIB and RIB queueing
2007-08-06  Denis Ovsienko

	* zebra_rib.c: (general) Add extra debug logging for RIB and
	  RIB queue.
2007-08-06 19:25:11 +00:00
Paul Jakma
0b8c4f1d81 [zebra] rib loop check for RIB_ENTRY_REMOVED checks wrong var
2007-06-25 Denis Ovsienko

	* zebra_rib.c: (rib_add_ipv4_multipath) Loop through RIB
	  is using 'same' variable, but RIB_ENTRY_REMOVED check
	  is testing the constant 'rib' variable, fix. Impact
	  unknown at this point.
2007-06-27 11:12:38 +00:00
Paul Jakma
7514fb7739 [zebra] Routemap support on received routes, with 'set src' command (linux)
2007-05-01 David L Stevens <dlstevens@us.ibm.com>

	* (general) These changes collectively add route-map and
	  prefix-list support to zebra and fix a bug in "show
	  route-map" (with no argument).
	* doc/main.texi: added route-map, prefix-list, ip protocol
	  and set src documentation
	* lib/command.h: added PROTOCOL_NODE type
	* lib/log.c: (proto_name2num) new function, protocol name to
	  number translation.
	* lib/routemap.c: (vty_show_route_map) fixed "show route-map"
	  without route-map name
	* lib/routemap.h: added RMAP_ZEBRA type
	* lib/zebra.h: added proto_name2num() prototype
	* vtysh/extract.pl.in: added VTYSH_ZEBRA flag for route-map and
	  plist
	* vtysh/Makefile.am: added zebra_routemap.c
	* vtysh/vtysh.h: added VTYSH_ZEBRA flag to VTYSH_RMAP
	* zebra/connected.c: (connected_up_ipv4) added src preference argument
	  to rib_add_ipv4()
	* zebra/kernel_socket.c: (rtm_read) ditto
	* zebra/main.c: added prefix list initialization
	* zebra/Makefile.am: added zebra_routemap.c source file
	* zebra/rib.h: added generic address union "g_addr" and use in
	  existing places that had an explicit union.
	  Added "src" to struct nexthop.
	  Added preferred src arg to nexthop_ipv4_add and rib_add_ipv4.
	* zebra/rt_netlink.c: (netlink_routing_table) set preferred source on
	  netlink messages.
	  (netlink_route_change) ditto
	  (netlink_route_multipath) ditto.
	* zebra/rtread_getmsg.c: (handle_route_entry) added (NULL) src to
	  rib_add_ipv4() call.
	* zebra/rtread_proc.c: (proc_route_read) ditto
	* zebra/zebra_rib.c: (nexthop_ipv4_add) add src argument.
	  (nexthop_ipv4_ifindex_add) ditto
	  (rib_add_ipv4) ditto
	  (nexthop_active_check) Add route-map processing.
	* zebra/zebra_routemap.c: new file for zebra route-map commands.
	* zebra/zebra_vty.c: (ip_protocol_cmd) Apply route-map to protocol
	  (vty_show_ip_route_detail) added "src" printing
	  (vty_show_ip_route) ditto
	  (show_ip_protocol_cmd) new command, list routemaps.
	  (config_write_protocol) write out routemap protocl config.
	  (zebra_vty_init) Install the new routemap protocol commands.
	* zebra/zserv.c: (zread_ipv4_add) added (NULL) src arg
	  (zebra_init) init zebra route-maps.
	* zebra/zserv.h: add zebra_route_map_init
2007-05-02 16:05:35 +00:00
Paul Jakma
3c0755dc97 [zebra] Changes of nexthops of static routes didnt take effect
2006-12-08 Piotr Chytla <pch@packetconsulting.pl>

	* zebra_rib.c: (static_install_ipv{4,6}) Case where existing
	  RIB is updated must explicitely rib_addqueue the route_node,
	  to ensure the update actually takes effect.
2006-12-08 00:53:14 +00:00
Paul Jakma
6d69112959 [zebra] Bug #268, Fix race between add/delete of routes, sanitise rib queueing
2006-07-27 Paul Jakma <paul.jakma@sun.com>

	* rib.h: (struct rib) Add a route_node rn_status flag field,
	  this has to be copied every time head RIB of a route_node
	  changes.
	  Remove the rib lock field, not needed - see below.
	  Add a status field for RIB-private flags.
	* zebra_rib.c: Add a global for the workqueue hold time, useful
	  for testing.
	  (general) Fix for bug #268. Problem originally
	  detailed by Simon Bryden in [quagga-dev 4001].
	  Essentially, add/delete of a RIB must happen /before/ the
	  queue. Best-path selection (ie rib_process) and reaping of
	  freed RIBs can then be done after queueing. Only the route_node
	  is queued - no important RIB state (i.e. whether a RIB is to be
	  deleted) is queued.
	  (struct zebra_queue_node_t) Disappears, no longer need to
	  track multiple things on the queue, only the route_node.
	  (rib_{lock,unlock}) removed, RIBs no longer need to be
	  refcounted, no longer queued.
	  (rib_queue_qnode_del) Removed, deleted RIBs no longer deleted
	  via the queue.
	  (rib_queue_add_qnode) deleted
	  (rib_queue_add) Only the route_node is queued for best-path
	  selection, we can check whether it is already queued or
	  not and avoid queueing same node twice - struct rib * argument
	  is not needed.
	  (rib_link/unlink) (un)link RIB from route_node.
	  (rib_{add,del}node) Front-end to updates of a RIB.
	  (rib_process) Reap any deleted RIBs via rib_unlink.
	  Unset the route_node 'QUEUED' flag.
	  (General) Remove calls to rib_queue_add where add/del node was
	  called - not needed, update calls where not.
	  Ignore RIB_ENTRY_REMOVEd ribs in loops through route_nodes
2006-07-27 21:49:00 +00:00
Paul Jakma
457eb9af72 [zebra] Add test rig code, for testing the zebra RIB
2006-07-27 Paul Jakma <paul.jakma@sun.com>

	* {ioctl,kernel}_null.c: Dummy/Null kernel method implementations,
	  useful for testing zebra code that calls such methods.
	* {redistribute,misc}_null.c: Dummy/Null methods, as above. But
	  for zclient, and for various misc functions.
	* test_main.c: Test harness for zebra, currently just to test the
	  RIB.
	* Makefile.am: Build testzebra using above.
	* zebra_rib.c: Add a global for the workqueue hold time, useful
	  for testing.
2006-07-27 19:59:58 +00:00
Paul Jakma
171eee31ed [zebra] Connected routes must always be added to main table
2006-07-27 Rumen Svobodnikov <rumen@telecoms.bg>

	* connected.c: (connected_up_ipv4) interface connected routes always
	  go to table main (or otherwise they cannot be used by linux as
          nexthops)
	* zserv.c: (zread_ipv4_add) send route to the correct routing table
	* zebra_rib.c (static_install_ipv4) set routing table
2006-07-27 16:11:02 +00:00
Paul Jakma
27b472533b [zebra] Fix CID #104, check addr for null, and #18, check nexthop type args
2006-07-02 Paul Jakma <paul.jakma@sun.com>

	* rt_netlink.c: (netlink_interface_addr) Fix CID #104, can not
	  proceed if addr is NULL.
	* zebra_rib.c: (static_add_ipv6) Fix CID #18, double check
	  required arguments are supplied for the given nexthop type.
2006-07-02 16:38:54 +00:00
paul
a1038a1565 [zebra] Fix pauls zebra_rib/rib_process commit mistakes, again.
2006-01-30 Paul Jakma <paul.jakma@sun.com>

	* zebra_rib.c: (rib_process) Fourth time lucky on this jinxed
	  commit, last commit had a hole that could allow connected
	  route selection to escape beyond the connected route logic.
	  This time I cross-checked with Gunnar first. ;)
2006-01-30 14:08:51 +00:00
paul
a8d9c1f9ca [zebra] Fix incorrect changes made in RIB metric selection patch
2006-01-25 Gunnar Stigen <gunnar.stigen@axxessit.no>

	* zebra_rib.c: (rib_process) Application of Gunnar's earlier
	  metric selection RIB change included incorrect tidy-ups made
	  by commiter. Fix. (NB: any errors here are again due to paul).
2006-01-25 06:31:04 +00:00
paul
e8e1946edf [compiler] miscellaneous trivial compiler warning fixes
2006-01-19 Paul Jakma <paul.jakma@sun.com>

        * (general) various miscellaneous compiler warning fixes.
          Remove redundant break statements from switch clauses
          which return.
          return from main, not exit, cause it annoys SOS.
          Remove stray semi-colons which cause empty-statement
          warnings.
	* zebra/main.c: (sighup) remove private declaration of external
	  function.
2006-01-19 20:16:55 +00:00
paul
af887b5111 2006-01-18 Gunnar Stigen <gunnar.stigen@axxessit.no>
* zebra_rib.c: Take interface metric into account.
2006-01-18 14:52:52 +00:00
paul
0fb58d5d79 2005-11-14 Paul Jakma <paul.jakma@sun.com>
* zebra_rib.c: (rib_process) convert to new workqueue specs and
	  shut up gcc, which complains about cast from void via
	  function parameters, for some dumb reason. Do the cast
	  inside the function instead.
	  (rib_queue_qnode_del) ditto.
	  (rib_queue_init) no need for the casts anymore.
2005-11-14 14:31:49 +00:00
hasso
ebf1ead032 * zebra_rib.c: Reduce the height of some staircases. Fix
rib_delete_ipv6() to match routes in the RIB by their gateway as
	  well as by destination.
2005-09-21 14:58:20 +00:00
paul
319572cc52 2005-09-21 Paul Jakma <paul.jakma@sun.com>
* zebra_rib.c: (static_uninstall_ipv{4,6}) Fix regression wrt
	  removal of static routes with multiple-hops introduced with
	  the workqueue conversion. We should free the relevant
	  nexthop and then get rib_process to run, otherwise we just
	  get same static route back again (with no way to unconfigure
          it, because its already deleted from configuration).
2005-09-21 12:30:08 +00:00
hasso
be61c4eb59 * zebra_rib.c, rib.h: Add distance and metric arguments to the
rib_add_ipv6() function so that IPv6 routes in RIB can have correct
	  metric. No IPv6 routing daemon uses distance yet though.
	* zserv.c, connected.c, kernel_socket.c, rt_netlink.c,
	  rtread_proc.c,zserv.c: Pass metric and distance info to the
	  rib_add_ipv6().

	Forwardport from stable branch.
2005-08-27 06:05:47 +00:00
paul
a1ac18c4d5 2005-06-28 Paul Jakma <paul.jakma@sun.com>
* (global) Extern and static'ification, with related fixups
	  of declarations, ensuring files include their own headers, etc.
	  if_ioctl.c: (interface_info_ioctl) fix obvious arg mis-order in
	  list loop
2005-06-28 17:17:12 +00:00
paul
4d38fdb421 2005-04-28 Paul Jakma <paul.jakma@sun.com>
* rib.h: (struct rib) Add lock field for refcounting.
	* zserv.h: (struct zebra_t) Add a ribq workqueue to the zebra
	  'master' struct.
	* zserv.c: (zread_ipv4_add) XMALLOC then memset should be XCALLOC.
	* zebra_rib.c: Clean up refcounting of route_node, make struct rib
	  refcounted and convert rib_process to work-queue. In general,
	  rib's should be rib_addnode'd and delnode'd to route_nodes, and
	  these symmetrical functions will manage the locking of referenced
	  route_node and freeing of struct rib - rather than having users
	  manage each seperately - with much scope for bugs..
	  (newrib_free) removed and replaced with rib_lock
	  (rib_lock) new function, check state of lock and increment.
	  (rib_unlock) new function, check lock state and decrement. Free
	  struct rib if refcount hits 0, freeing struct nexthop's, as
	  newrib_free did.
	  (rib_addnode) Add RIB to route_node, locking both.
	  (rib_delnode) Delete RIB from route_node, unlocking each.
	  (rib_process) Converted to a work-queue work function.
	  Functional changes are minimal, just arguments, comments and
	  whitespace.
	  (rib_queue_add_qnode) Helper function to setup a ribq item.
	  (rib_queue_add) Helper function, same arguments as old
	  rib_process, to replace in callers of rib_process.
	  (rib_queue_qnode_del) ribq deconstructor.
	  (rib_queue_init) Create the ribq.
	  (rib_init) call rib_queue_init.
	  (remainder) Sanitise refcounting of route_node's. Convert to
	  rib_queue_add, rib_addnode and rib_delnode. Change XMALLOC/memset
	  to XCALLOC. Remove calls to nexthop_delete and nexthop_free.
2005-04-28 17:35:14 +00:00
paul
55468c8604 2005-03-14 Paul Jakma <paul.jakma@sun.com>
* (global) update all c files to match the lib/vector.h rename of
	  (struct vector).active to max, and vector_max macro to
	  vector_active.
	* lib/vector.h: Rename to (struct vector).max to slightly less
	  confusing active, for the number of active slots, distinct from
	  allocated or active-and-not-empty. Rename vector_max to
	  vector_active for same reason.
2005-03-14 20:19:01 +00:00
ajs
b617800227 2004-12-07 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* *.c: Change level of debug messages to LOG_DEBUG.
2004-12-07 21:12:56 +00:00
hasso
39db97e4e0 Some compiler warnings fixes and fix for bugzilla #119. 2004-10-12 20:50:58 +00:00
hasso
fce954f8de Fix warnings. Didn't even look at files not compiled in Linux though. 2004-10-07 20:29:24 +00:00
jardin
9e867fe663 Merge isisd into the Quagga's framework:
- add privs support
  - use misc quagga's definitions
  - make it compile"able"
  - fix segfault cases related to hostname()
  - add debug isis xxx command

This patch has been approved by Paul Jakma.
2003-12-23 08:56:18 +00:00
paul
b5f4502146 2003-11-02 Krzysztof Oledzki <oleq@ans.pl>
* zebra/zebra_rib.c: Revert patch (dating from zebra.org) which
          caused zebra to read all routes in all tables, rather than just
          the main table. See [quagga-dev 280].
2003-11-02 07:28:05 +00:00
paul
6baeb98892 2003-10-27 Gilad Arnold <gilad.arnold@terayon.com>
* zebra/zebra_rib.c: (nexthop_active_update) Check for multipath
          limit when setting changed flag to avoid spurious changes.
          (static_install_ipv{4,6}) dont uninstall by default, might not be
          required - avoid spurious uninstalls.
          (static_uninstall_ipv{4,6}) only uninstall the route if its
	  actually FIB route.
2003-10-28 03:47:15 +00:00
paul
143a385f0c 2003-09-29 Gilad Arnold <gilad.arnold@terayon.com>
* zebra/zebra_rib.c: Fix possible dangling reference to rib
 	route_nodes - unlock it the appropriate number of times. (twice,
	because of the implicit lock). see [quagga-dev 251].
2003-09-29 20:06:13 +00:00
paul
7021c425a9 2003-07-15 Paul Jakma <paul@dishone.st>
* lib/version.h: add ZEBRA_URL (unused for now)
        * lib/vty.c: CMD_ERR_NOTHING_TODO when reading conf file should not
          be fatal. slight reformating.
        * ospfd/ospf_zebra.c: ignore reject/blackhole routes if zebra sends
          these type of routes. probably should be a new type of route to
          allow daemons to more easily choose whether to redistribute them
          - rathen than just a flag (eg for reject/blackhole).
          reorder the is_prefix_default test for ZEBRA_IPV4_ROUTE_DELETE to
          avoid the inverted test - slightly more readable.
        * redhat/zebra.spec.in: Add ospfapi port to services file, if
          with_ospfapi.
        * zebra/rib.h: Change nexthop types to an enum.
        * zebra/rt_netlink.c: run it through indent -nut.
          Add nexthop_types_desc[] descriptive array for nexthop types.
          (netlink_route_multipath) debug statements indicate which branch
          they are in and print out nexthop type.
        * zebra/zebra_rib.c: slight reformatting.
        * zebra/zebra_vty.c: Pass ZEBRA_FLAG_BLACKHOLE flag to
          static_add_ipv4() if Null0 route is configured. print out Null0 if
          STATIC_IPV4_BLACKHOLE route, and ignore flags (shouldnt be
          possible to set flags from vty) for config and show route.
2003-07-15 12:52:22 +00:00
paul
5ec90d28c9 2003-06-19 Vladimir Ivaschenko <hazard@francoudi.com>
* zebra/rt_netlink.c: Debug statements added to
          netlink_route_multipath()
	* zebra/zebra_rib.c: If route has a gateway, delete only existing
          route with that specified gateway.
2003-06-19 01:41:37 +00:00
paul
b21b19c578 2003-06-15 Paul Jakma <paul@dishone.st>
* lib/vty.{c,h}: Remove vty layer depending on a 'master' global,
	  pass the thread master in explicitly to vty_init. Sort out some
	  header dependency problems with lib/command.h
	* zebra/: Move globals to struct zebrad. Update vty_init().
	* (.*)/\1_main.c: update call to vty_init().
2003-06-15 01:28:29 +00:00
paul
368aa3f0f5 Fix missing else in static_add_ipv4() which was causing case of (!ifname)
to always be considered to be a blackhole route. (if gate is passed in, it
cant be).
2003-05-25 23:24:50 +00:00
paul
595db7f165 Add back support for null0 interface blackhole routes. 2003-05-25 21:35:06 +00:00
hasso
726f9b2bbd Last fixes from 6Wind patch. 2003-05-25 21:04:54 +00:00
hasso
81dfcaa2e2 Route (reject|blackhole) support from 6Wind patch. 2003-05-25 19:21:25 +00:00
paul
a4b70768b4 From: Gilad Arnold <gilad.arnold@terayon.com>
Subject: [zebra 19084] Re: suspected memory leakage upon static route

I believe this is a more complete patch, it also addresses
allocating/freeing of nexthop->ifname string buffer (1) using
XSTRDUP/XFREE macros (thus correctly updating memory statistics), and
(2) for all nexthop->type cases that carry an ifname string.
2003-05-16 17:19:48 +00:00
paul
a0f6acd8a4 From: Gilad Arnold <gilad arnold at terayon com>
Subject: [zebra 19080] suspected memory leakage upon static route deletion

upon deletion of a static route entry, at the end of
zebra/zebra_rib.c/static_delete_ipv4(), there's a call to XFREE to
deallocate the 'struct static_ipv4'. However, in the case of a static with
ifname as nexthop (type==STATIC_IPV4_IFNAME), this struct holds a pointer to
a dynamically allocated ifname string buffer (si->gate.ifname, see its
allocation within static_add_ipv4() using XSTRDUP). IMO, the attached patch
is required.

Notes: the same applies to IPv6 statics as well (fix included in patch);
and, I admit I haven't yet tested that, but it seems simple enough to be
working... ;->
2003-05-14 18:29:13 +00:00
paul
d753e9eec9 Matthew Grant <grantma@anathoth.gen.nz>
Subject: [zebra 17290] [PATCHES] - Fixes for problems in 0.93b

Added ifupstaticfix
2003-01-22 19:45:50 +00:00
paul
718e374419 Initial revision 2002-12-13 20:15:29 +00:00