Commit Graph

411 Commits

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

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

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

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-08-11 17:14:58 +02:00
Donald Sharp
40ecd8e46d lib, zebra: Allow protocols to use Distance as part of RR semantics
Allow protocols to specify to zebra that they would like zebra
to use the distance passed down as part of determine sameness for
Route Replace semantics.

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

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-07-29 12:43:23 -04:00
Donald Sharp
7e24fdf333 staticd: Start the addition of a staticd
This is the start of separating out the static
handling code from zebra -> staticd.  This will
help simplify the zebra code and isolate static
route handling to it's own code base.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-07-29 12:37:24 -04:00
Christian Franke
1f610a1fb3 zebra: do not ignore ipv6 srcdest routes
Commit a2ca67d1d2 consolidated IPv4 and IPv6 handling. It also applied
our ignorance for IPv4 srcdest routes onto IPv6.

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2018-07-24 14:09:17 +02:00
Mark Stapp
86391e5659 zebra, libs: use const prefix ptrs in apis
Add 'const' to prefix args to several zebra route update,
redistribution, and route owner notification apis.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2018-07-11 09:22:49 -04:00
paco
0cfbff749e
zebra: flow control (Coverity 1462467 1465497)
Signed-off-by: F. Aragon <paco@voltanet.io>
2018-06-21 17:09:04 +02:00
paco
36228974c2
isisd, zebra: FIXME fixes
Signed-off-by: F. Aragon <paco@voltanet.io>
2018-06-19 19:22:13 +02:00
Donald Sharp
1e88567226 zebra: Add a result from dataplane request
Add a bit of code to allow return of data plane
request messages.

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

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

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-05-30 08:00:55 -04:00
Donald Sharp
633a66a586 zebra: Add 'match source-instance' to allow finer grained control
Add to zebra route-maps the ability to match on a source-instance

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

ip protocol any route-map FOO

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

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-05-17 10:57:59 -04:00
vivek
a317a9b9a4 bgpd, zebra: Handle EVPN router MAC per next hop
Ensure that when EVPN routes are installed into zebra, the router MAC
is passed per next hop and appropriately handled. This is required for
proper multipath operation.

Ticket: CM-18999
Reviewed By:
Testing Done: Verified failed scenario, other manual tests
Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2018-04-26 07:50:34 -04:00
Quentin Young
bf094f6975 zebra: clean up zapi organization
zserv.c has become something of a dumping ground for everything vaguely
related to ZAPI and really needs some love. This change splits out the
code fo building and consuming ZAPI messages into a separate source
file, leaving the actual session and client lifecycle code in zserv.c.

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

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

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

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-27 15:51:53 -04:00
Quentin Young
d7c0a89a3a
*: use C99 standard fixed-width integer types
The following types are nonstandard:
- u_char
- u_short
- u_int
- u_long
- u_int8_t
- u_int16_t
- u_int32_t

Replace them with the C99 standard types:
- uint8_t
- unsigned short
- unsigned int
- unsigned long
- uint8_t
- uint16_t
- uint32_t

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

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

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

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

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

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

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

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

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

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

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

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-14 20:14:36 -04:00
paulzlabn
3f1224cd1a
Merge branch 'master' into working/master/bgp-vpn-vrf-leaking 2018-03-14 13:31:58 -07:00
vivek
4e262455a2 Merge branch 'master' of https://github.com/frrouting/frr into evpn-ipv6-tenant-routing
Conflicts:
	bgpd/bgp_evpn.c
2018-03-10 04:03:41 +00:00
G. Paul Ziemba
ff954ba48b zebra: add BGP VPN route type to meta_queue_map
Signed-off-by: G. Paul Ziemba <paulz@labn.net>
2018-03-09 16:42:40 -05:00
Donald Sharp
7ee30f288e lib: Isolate nexthop_group functions to nexthop_group.c
Also modify `struct route_entry` to use nexthop_groups.
Move ALL_NEXTHOPS loop to nexthop_group.h

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-09 11:07:41 -05:00
Donald Sharp
5e54c60269 *: Add code to notify on route removal status
If a interested party removes one of it's routes let
it know that it has happened as asked for.

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

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

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-08 19:50:06 -05:00
vivek
bfd498f0da Merge branch 'master' of https://github.com/frrouting/frr into evpn-ipv6-tenant-routing
Conflicts:
	zebra/zserv.c
2018-03-06 22:19:24 +00:00
Lou Berger
996c93142d *: conform with COMMUNITY.md formatting rules, via 'make indent'
Signed-off-by: Lou Berger <lberger@labn.net>
2018-03-06 14:04:32 -05:00
vivek
1ec31309bb *: EVPN symmetric routing for IPv6 tenant routes
Implement support for EVPN symmetric routing for IPv6 routes. The next hop
for EVPN routes is the IP address of the remote VTEP which is only an IPv4
address. This means that for IPv6 symmetric routing, there will be IPv6
destinations with IPv4 next hops. To make this work, the IPv4 next hops are
converted into IPv4-mapped IPv6 addresses.

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

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

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

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

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

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

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

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

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

This was happening for redistributed table 10 routes
into BGP.

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

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

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-01-24 08:22:57 -05:00
Philippe Guibert
d6fed38109
Merge pull request #1618 from donaldsharp/zebra_startup_ordering
zebra route-leaking for static routes
2018-01-23 08:25:01 +01:00
Renato Westphal
f674dfe234 zebra: implement recursive MPLS labels
When a nexthop is resolved via a label based nexthop, copy
the labels into the newly created recursive nexthop.

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

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

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

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

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

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

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

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

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

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

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-01-12 09:20:30 -05:00
Mitesh Kanjariya
9bb77a5b3d
Merge branch 'master' into evpn-symmetric-routing 2018-01-11 09:00:23 -08:00
Donald Sharp
607425e554 zebra: Fix dest dereference
The rn can not have an rn->info pointer and as
such the dest may be NULL.  Don't assign
the old_fib pointer if so.  This is ok
because we know RNODE_FOREACH... will not
iterate if dest is NULL.

Fixes: #1575
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-01-02 09:12:07 -05:00
Renato Westphal
fb6f7c2c25
Merge pull request #1515 from donaldsharp/selected_to_front1
Store selected_fib as a pointer off of rib_dest_t
2017-12-19 14:09:03 -02:00
Mitesh Kanjariya
90264d64ef bgpd: process evpn type-5 routes received from peers
Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2017-12-14 10:57:08 -08:00
mitesh
6134fd82a0 zebra: proper refcounting for rmac/nh entries
Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.comy>
2017-12-14 10:57:06 -08:00
Mitesh Kanjariya
19a847a9cd bgpd: set evpn rvtep nexthops as active by default
Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2017-12-14 10:57:05 -08:00
mitesh
d3135ba31d bgpd: program mac-ip routes in matching vrfs
Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2017-12-14 10:57:05 -08:00
Kaloyan Kovachev
4e40b6d615 zebra: Add ability to support tags -> realms in linux
Linux has the ability to support a concept of 'realms'.
This concept allows you to mark routes with a realm id
value of 1-255.  If you have marked the realm
of a route then you can use the tc program to
apply policy to the routes.

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

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

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

Signed-off-by: Kaloyan Kovachev <kkovachev@varna.net>
2017-12-14 09:44:44 -05:00
Donald Sharp
5f7a4718e2 zebra: Replace SELECTED_FIB flag with a rib_dest_t pointer
The SELECTED_FIB flag was placed upon the entry that we
have inserted into the kernel.  Remove this flag and replace
with a `rib_dest_t` *selected_fib.  Just keep track of the
selected_fib as we modify it.  This removes allot of
FOREACH_RE loops as that we do not need to find the
entry anymore.

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

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

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

This separation is to allow us to do these things:

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

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

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-11-29 12:56:34 -05:00
Donald Sharp
019a82cbbc zebra: Allow zebra_find_client to match on instance as well
zebra_find_client needs to match on instance as well so
protocols like ospfd will work correctly for notification.

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

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

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

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

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

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

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-10-09 20:15:14 -03:00
Renato Westphal
09d0f308ce Merge pull request #1237 from donaldsharp/distance_special
zebra: Modify metric read to be admin distance and metric
2017-10-09 20:11:39 -03:00
Donald Sharp
affe9e9983 *: Convert list_delete(struct list *) to ** to allow nulling
Convert the list_delete(struct list *) function to use
struct list **.  This is to allow the list pointer to be nulled.

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

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

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

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-05 10:53:13 -04:00
Renato Westphal
c00ad29fc4 Merge pull request #1236 from donaldsharp/interface_startup
zebra: Do not allow same rib_dest_t be queued multiple times to meta …
2017-09-28 22:04:02 -03:00
Renato Westphal
310f64be93 Merge pull request #1240 from donaldsharp/allow_self_delete
zebra: Do not allow delete of route from kernel in non-startup case
2017-09-27 09:11:11 -03:00
Renato Westphal
8a38c34b5a Merge pull request #1235 from chiragshah6/ospf_vrf_dev
zebra: Nexthop APIs to use correct vrf_id
2017-09-26 00:34:04 -03:00
Donald Sharp
5dfeba1904 zebra: Do not allow delete of route from kernel in non-startup case
This is a continuation of 915902cb82.  Basically the netlink
read of messages up from the kernel is now noticing the proper
owner of the route.  As such when rib_delete was being called
as part of the upcall from the kernel we were not noticing that
we were the originator and not diss-allowing the rib_delete
from happening.  This restores this behavior that we were getting
pre-915902cb82cfd

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-09-25 12:28:39 -04:00
Donald Sharp
fd289fc83e zebra: Make admin distance a uint8_t
While u_char is technically a uint8_t in size I would
like to treat and think about the admin distance
as an actual integer value from 0-255, instead
of a char.

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

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

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

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

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

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

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

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

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

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-09-21 13:27:50 -03:00
Renato Westphal
7865c65d23 zebra: plug memory leak in rib_add_multipath()
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-09-21 13:27:50 -03:00
Renato Westphal
7990990e54 zebra: use the afi parameter in rib_add_multipath()
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-09-21 13:27:50 -03:00
Jafar Al-Gharaibeh
b1cebe20cd Merge pull request #1157 from donaldsharp/recursive_blackhole
Recursive blackhole resolution
2017-09-21 11:16:35 -05:00
Donald Sharp
60c2286880 Merge pull request #1160 from opensourcerouting/admin_distance
Admin distance
2017-09-21 07:55:08 -04:00
Renato Westphal
a2addae8fe *: use clang's 'ForEachMacros' format style option
This fixes the broken indentation of several foreach loops throughout
the code.

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

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

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-09-15 14:53:46 -03:00
Russ White
dcc4574ae6 Merge pull request #1163 from donaldsharp/deduplicate_nexthops
zebra: deduplicate nexthops
2017-09-13 16:18:41 -04:00
David Lamparter
25b9cb0cc8 zebra: deduplicate nexthops
There exists situations where it is possible to have duplicate
nexthops passed from a higher level protocol into zebra.

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

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

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-09-12 10:05:07 -04:00
Renato Westphal
0492eea08e zebra: fix administrative distance issues
* Reuse route_distance() on rib_add_multipath() and on rib_add();
* Set the admin distance of LDP and BGP MPLS LSPs.

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

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

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

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

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

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

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

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

Fixes #1112.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-09-07 15:00:42 -03:00