Commit Graph

165 Commits

Author SHA1 Message Date
Philippe Guibert
8e71b98f72
Merge pull request #1654 from mkanjari/evpn-symm-routing-enhancements
Evpn symmetric routing enhancements
2018-02-08 11:46:29 +01:00
Renato Westphal
2415f045c6
Merge pull request #1712 from donaldsharp/nht_updates
Nht updates
2018-02-06 23:34:12 -02:00
Donald Sharp
f3f32e0a70 lib: Fix encoding of vrf
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-02-05 05:49:27 -05:00
Donald Sharp
4a749e2cb2 bgpd, lib, pimd: Make nexthop_update decoding common
Create a zapi_nexthop_update_decode function that both
pim and bgp use to decode the message from zebra.

There probably could be further optimizations but I opted
to keep the code as similiar as is possible between the
originals because they both make some assumptions about
code flow that I do not fully understand yet.

The real goal here is that I want to create a new
user of the nexthop tracking code from a higher level
daemon and I see no need to re-implement this damn
code again for a 3rd time.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-02-05 03:44:29 -05:00
Russ White
dd19d6a6e7
Merge pull request #1665 from donaldsharp/nexthop_labels
Cleanup some zclient code
2018-01-23 19:09:08 -05:00
Mitesh Kanjariya
31310b25f2 bgpd: advertise VNI subnet
In EVPN symmetric routing, not all subnets are presents everywhere.
We have multiple scenarios where a host might not get learned locally.
1. GARP miss
2. SVI down/up
3. Silent host

We need a mechanism to resolve such hosts. In order to achieve this,
we will be advertising a subnet route from a box and that box will help
in resolving the ARP to such hosts.

Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2018-01-23 15:58:53 -08:00
Philippe Guibert
d6fed38109
Merge pull request #1618 from donaldsharp/zebra_startup_ordering
zebra route-leaking for static routes
2018-01-23 08:25:01 +01:00
Donald Sharp
3c19254068 bgpd, lib, pimd: Abstract commands for nexthop tracking
Abstract the code that sends the zapi message into zebra
for the turn on/off of nexthop tracking for a prefix.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-01-22 19:45:31 -05:00
Donald Sharp
09eef679fb lib: Unset bitmap when not using it
The zclient->redist bitmap for vrf's was being set again
for the zclient_send_dereg_requests function.  This should
be a unset on tear down.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-01-22 19:44:52 -05:00
Donald Sharp
0d9e7f455e lib: Cleanup some zclient clutter.
The zclient code can be cleaned up a tiny bit and hopefully
improve it's indentation some.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-01-22 19:44:52 -05:00
Philippe Guibert
a9ff90c41b lib: increase vrf_id from 16 bit to 32 bit identifier
This is a preparatory work for configuring vrf/frr over netns
vrf structure is being changed to 32 bit, and the VRF will have the
possibility to have a backend made up of NETNS.

Let's put some history.
Initially the 32 bit was because one wanted to map on vrf_id both the
VRFLITE and the NSID.
Initially, one would have liked to make zebra configure at the same time
both vrf lite and vrf from netns in a flat way. From the show
running perspective, one would have had both kind of vrfs, thatone
would configure on the same way.
however, it leads to inconsistencies in concepts, because it mixes vrf
vrf with vrf, and vrf is not always mapped with netns.
For instance, logical-router could also be used with netns. In that
case, it would not be possible to map vrf with netns.
There was an other reason why 32 bit is proposed. this is because
some systems handle NSID to 32 bits. As vrf lite exists only on
Linux, there are other systems that would like to use an other vrf
backend than vrf lite. The netns backend for vrf will be used for that
too. for instance, for windows or freebsd, some similar
netns concept exists; so it will be easier to reuse netns
backend for vrf, than reusing vrflite backend for vrf.

This commit is here to extend vrf_id to 32 bits. Following commits in a
second step will help in enable a VRF backend.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-01-22 13:52:17 +01:00
Donald Sharp
d5b2119cb4 *: Send/receive the nexthop vrf_id
Modify the code to send and receive to/from zebra
the nexthops vrf_id.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-01-12 09:22:07 -05: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
2dbad57fc6 bgpd: program nh/rmac entries
Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2017-12-14 10:57:05 -08:00
Mitesh Kanjariya
b7cfce934f zebra, lib: zebra changes for symmetric routing support
Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2017-12-14 10:56:44 -08:00
Donald Sharp
e1a1880de3 *: Make zapi route install Notifications optional
Allow the higher level protocol to specify if it would
like to receive notifications about it's routes that
it has installed.

I've purposely made it part of zclient_new_notify because
we need to track the routes on a per daemon basis only.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-11-27 09:09:35 -05:00
Donald Sharp
7ea7b86e2b lib, zebra: Add ability to notify to Routing Protocols Success/Failure
Provide ZAPI code that can pass to an upper level protocol
what happened to it's route on install.

There are these notifications:
1) ZAPI_ROUTE_FAIL_INSTALL - The route attempted to be
   installed did not work.
2) ZAPI_ROUTE_BETTER_ADMIN_WON - A route that was installed
   has become un-installed due to another routing protocol
   installing a better admin distance
3) ZAPI_ROUTE_INSTALLED - The route specified has been installed

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-11-27 09:09:32 -05:00
Donald Sharp
832d0f566f lib: Pass the safi as a uint8_t
The safi encode/decode is using 2 bytes, which
may cause problems on some platforms.  Let's assume
that a safi is a uint8_t and work accordingly.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-11-13 14:18:43 -05:00
Donald Sharp
ec93aa120e lib, zebra: Modify zebra to use STREAM_GET for zapi
This code modifies zebra to use the STREAM_GET functionality.
This will allow zebra to continue functioning in the case of
bad input data from higher level protocols instead of crashing.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-11-13 14:16:13 -05:00
Donald Sharp
2a82635882 lib: Remove strange line
Remove a line that only has a semi-colon on it.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-25 22:34:45 -04:00
Donald Sharp
342213eac0 *: Modify zclient_init to require privs data
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-23 18:12:29 -04:00
Renato Westphal
ff880b78ef *: introduce new rb-tree to optimize interface lookup by ifindex
Performance tests showed that, when running on a system with a large
number of interfaces, some daemons would spend a considerable amount
of time in the if_lookup_by_index() function. Introduce a new rb-tree
to solve this problem.

With this change, we need to use the if_set_index() function whenever
we want to change the ifindex of an interface. This is necessary to
ensure that the 'ifaces_by_index' rb-tree is updated accordingly. The
return value of all insert/remove operations in the interface rb-trees
is checked to ensure that an error is logged if a corruption is
detected.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-10-10 09:05:02 -03:00
Renato Westphal
bcc245799b lib: nuke the if_*_by_name_len() functions
Make use of strnlen() and strlcpy() so we can get rid of these
convoluted if_*_by_name_len() functions.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-10-10 09:01:24 -03:00
Donald Sharp
acdf5e2510 *: Convert list_free usage to list_delete
list_free is occassionally being used to delete the
list and accidently not deleting all the nodes.
We keep running across this usage pattern.  Let's
remove the temptation and only allow list_delete
to handle list deletion.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-05 10:53:17 -04:00
Vincent JARDIN
c31a793b48 scan-build: cleanup some warnings
Current cleanup is for unset values or variables that are not used anymore.

Regarding ospfd/ospf_vty.c: argv_find()
  we'll never get it NULL, so get coststr = argv[idx]->arg;
2017-10-02 09:14:03 +02:00
Renato Westphal
a74e593b35 *: fix segfault when sending more than MULTIPATH_NUM nexthops
This is a fallout from PR #1022 (zapi consolidation). In the early days,
the client daemons would allocate enough memory to send all nexthops
to zebra.  Then zebra would add all nexthops to the RIB and respect
MULTIPATH_NUM only when installing the routes in the kernel. Now things
are different and the client daemons can send at most MULTIPATH_NUM
nexthops to zebra, and failure to respect that will result in a buffer
overflow. The MULTIPATH_NUM limit in the new zebra API is a small price
we pay to avoid allocating memory for each route sent to zebra.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-09-21 11:21:09 -03:00
David Lamparter
94758e6681 lib, zebra: carry blackhole type over ZAPI
Allow daemons to add blackholes of specific types (reject/drop.)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-28 06:03:36 +02:00
David Lamparter
09a484dd1d *: remove ZEBRA_FLAG_{BLACKHOLE,REJECT} from API
FLAG_BLACKHOLE is used for different things in different places. remove
it from the zclient API, instead indicate blackholes as proper nexthops
inside the message.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-28 01:21:43 +02:00
Donald Sharp
b5f7965155 lib: Fix nexthop num
If we assign MULTIPATH_NUM to be 256, this causes issues
for us since 256 is bigger than a u_char.  So let's make
the api's multipath_num to be a u_int16_t and pass it
around as a word.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-08-24 08:30:08 -04:00
Renato Westphal
744899219f *: use zapi_route to send/receive redistributed routes as well
Some differences compared to the old API:
* Now the redistributed routes are sent using address-family
  independent messages (ZEBRA_REDISTRIBUTE_ROUTE_ADD and
  ZEBRA_REDISTRIBUTE_ROUTE_DEL). This allows us to unify the ipv4/ipv6
  zclient callbacks in the client daemons and thus remove a lot of
  duplicate code;

* Now zebra sends all nexthops of the redistributed routes to the client
  daemons, not only the first one. This shouldn't have any noticeable
  performance implications and will allow us to remove an ugly exception
  we had for ldpd (which needs to know all nexthops of the redistributed
  routes). The other client daemons can simply ignore the nexthops if
  they want or consult just the first one (e.g. ospfd/ospf6d/ripd/ripngd).

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-08-23 20:25:45 -03:00
Renato Westphal
52dd3aa483 zapi: add support for routes with multiple labels
This will be necessary for the Segment Routing feature.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-08-23 18:58:35 -03:00
Renato Westphal
0e51b4a368 lib/zserv: introduce address-family independent ZAPI message types
As noticed in 657cde1, the zapi_ipv[4|6]_route functions are broken in
many ways and that's the reason that many client daemons (e.g. ospfd,
isisd) need to send handcrafted messages to zebra.

The zapi_route() function introduced by Donald solves the problem
by providing a consistent way to send ipv4/ipv6 routes to zebra with
nexthops of any type, in all possible combinations including IPv4 routes
with IPv6 nexthops (for BGP unnumbered routes).

This patch goes a bit further and creates two new address-family
independent ZAPI message types that the client daemons can
use to advertise route information to zebra: ZEBRA_ROUTE_ADD and
ZEBRA_ROUTE_DELETE. The big advantage of having address-family independent
messages is that it allows us to remove a lot of duplicate code in zebra
and in the client daemons.

This patch also introduces the zapi_route_decode() function. It will be
used by zebra to decode route messages sent by the client daemons using
zclient_route_send(), which calls zapi_route_encode().

Later on we'll use this same pair of encode/decode functions to
send/receive redistributed routes from zebra to the client daemons,
taking the idea of removing code duplication to the next level.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-08-23 17:45:17 -03:00
Renato Westphal
bb1b9c47ca lib: updates to zapi_route
This patch introduces the following changes to the zapi_route structure
and associated code:
* Use a fixed-size array to store the nexthops instead of a pointer. This
  makes the zapi_route() function much easier to use when we have multiple
  nexthops to send. It's also much more efficient to put everything on
  the stack rather than allocating an array in the heap every time we
  need to send a route to zebra;

* Use the new 'zapi_nexthop' structure. This will allow the client daemons
  to send labeled routes without having to allocate memory for the labels
  (the 'nexthop' structure was designed to be memory efficient and doesn't
  have room for MPLS labels, only a pointer). Also, 'zapi_nexthop' is more
  compact and more clean from an API perspective;

* Embed the route prefix inside the zapi_route structure. Since the
  route's prefix is sent along with its nexthops and attributes, it makes
  sense to pack everything inside the same structure.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-08-23 17:45:17 -03:00
Renato Westphal
34b054ba6d *: remove leftovers from "router zebra"
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-08-23 17:45:17 -03:00
David Lamparter
4e1fd26a5e Merge remote-tracking branch 'frr/master' into tcp-zebra 2017-08-09 20:42:27 +02:00
ßingen
6833ae01bc zebra: add pseudowire manager
Base framework for supporting MPLS pseudowires in FRR.

A consistent zserv interface is provided so that any client daemon
(e.g. ldpd, bgpd) can install/uninstall pseudowires in a standard
way. Static pseudowires can also be implemented by using the same
interface.

When zebra receives a request to install a pseudowire and the installation
in the kernel or hardware fails, a notification is sent back to the
client daemon and a new install attempt is made every 60 seconds (until
it succeeds).

Support for external dataplanes is provided by the use of hooks to
install/uninstall pseudowires.

Signed-off-by: ßingen <bingen@voltanet.io>
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-08-09 12:35:15 +02:00
David Lamparter
689f5a8c84 *: remove --enable-tcp-zebra, rework ZAPI path
This adds "@tcp" as new choice on the -z option present in zebra and the
protocol daemons.  The --enable-tcp-zebra option on configure is no
longer needed, both UNIX and TCP socket support is always available.

Note that @tcp should not be used by default (e.g. in an init script),
and --enable-tcp-zebra should never have been in any distro package
builds, because

**** TCP-ZEBRA IS A SECURITY PROBLEM ****

It allows arbitrary local users to mess with the routing table and
inject bogus data -- and also ZAPI is not designed to be robust against
attacks.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-08 11:14:05 +02:00
Donald Sharp
e0ae31b886 lib, pimd, zebra: Allow pim to set pimregX into appropriate vrf
The pimregX devices when created by the kernel are put into
the default vrf.  When pim gets the callback that the device
exists, check to see if it is a pimregX device and if so
move it into the appropriate vrf.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-24 13:51:39 -04:00
David Lamparter
9d303b37d7 Revert "*: reindent pt. 2"
This reverts commit c14777c6bf.

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

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

* reflow comments
* struct members go 1 per line
* binpack algo was adjusted
2017-07-17 15:26:02 -04:00
whitespace / reindent
d62a17aede *: reindent
indent.py `git ls-files | pcregrep '\.[ch]$' | pcregrep -v '^(ldpd|babeld|nhrpd)/'`

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-17 14:04:07 +02:00
vivek
5b4168879d lib: Define handlers for VNI and MACIP
Define client handlers for processing add or delete of local VNIs
and local MACIPs.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2017-07-12 12:39:12 -04:00
David Lamparter
97bd5c48de Merge remote-tracking branch 'frr/master' into pull-624 2017-06-13 09:18:14 +02:00
Donald Sharp
657cde1267 lib: Add zapi_route function.
Allow routing protocols to call one function to add/delete
routes into zebra.  Future commits will start adding
this code to individual routing protocols.

Why are we doing this?  Well the zapi_ipv[4|6]_route functions
are fundamentally broken in their ability to pass down anything
but NEXTHOP_TYPE_IFINDEX or NEXTHOP_TYPE_IPV[4|6] and we need
the ability to pass down a bit more information.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-06-04 19:14:44 -04:00
Donald Sharp
1da2945621 lib, zebra: Pass up kernel table_id for vrf's
pim controls the vrf table creation for due to the way that
pim must interact with the kernel.  In order to match the
table_id for unicast <-> multicast( not necessary but a
real nice to have ) we need to pass up from zebra the
table_id associated with the vrf.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-06-02 13:43:15 -04:00
David Lamparter
fa84d1932b Merge branch 'stable/3.0'
Conflicts:
	ldpd/lde.c
	zebra/label_manager.c

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-05-18 14:14:00 +02:00
David Lamparter
bac7b7b935 Merge pull request #537 from donaldsharp/vrf_stuff
Vrf stuff
2017-05-17 22:06:39 +02:00
Donald Sharp
7922fc65ae lib, zebra: Cleanup vrf api some
Segregate the vrf enable/disable functionality from other vrf
code.  This is to ensure that people are not actually using
the functions when they should not be.  Also document the
why of it properly in the new vrf_int.h header.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-05-15 19:02:34 -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
ßingen
5c7ef8dc4f lm: Make relay label manager async
To avoid blocking zebra when it's acting as a proxy for an external
label manager.

Besides:

Fix get chunk reconnection. Socket was still being destroyed on failure,
so next attempt would never work.

Filter out unwanted messages in lm sync sock.
Until LDE client sends ZEBRA_LABEL_MANAGER_CONNECT message, zserv
doesn't know which kind of client it is, so it might enqueue unwanted
messages like interface add, interface up, etc. Changes in this commit
discard those messages in the client side in case they arrive before the
expected response.

Change function name for zclient_connect in label manager to avoid
confusion with zclient one.

Signed-off-by: ßingen <bingen@voltanet.io>
2017-05-11 19:20:08 +02:00