Commit Graph

623 Commits

Author SHA1 Message Date
Jakub Urbańczyk
86d5622362 zebra: remove "PENDING" dplane request state
This request state is redundant with new message batching interface.

Signed-off-by: Jakub Urbańczyk <xthaid@gmail.com>
2020-08-10 21:33:00 +02:00
Sebastien Merle
31f937fb43 lib, zebra: Add SR-TE policy infrastructure to zebra
For the sake of Segment Routing (SR) and Traffic Engineering (TE)
Policies there's a need for additional infrastructure within zebra.
The infrastructure in this PR is supposed to manage such policies
in terms of installing binding SIDs and LSPs. Also it is capable of
managing MPLS labels using the label manager, keeping track of
nexthops (for resolving labels) and notifying interested parties about
changes of a policy/LSP state. Further it enables a route map mechanism
for BGP and SR-TE colors such that learned BGP routes can be mapped
onto SR-TE Policies.

This PR does not introduce any usable features by now, it is just
infrastructure for other upcoming PRs which will introduce 'pathd',
a new SR-TE daemon.

Co-authored-by: Renato Westphal <renato@opensourcerouting.org>
Co-authored-by: GalaxyGorilla <sascha@netdef.org>
Signed-off-by: Sebastien Merle <sebastien@netdef.org>
2020-08-07 11:08:49 +02:00
Renato Westphal
790953a387
Merge pull request #6765 from mjstapp/backup_nhg_netlink
lib,zebra: support multiple backup nexthops
2020-07-27 12:49:36 -03:00
Stephen Worley
55528234ea
Merge pull request #6753 from mjstapp/fix_zebra_backup_sa
zebra: fix SA warnings in backup nexthop code
2020-07-17 17:29:49 -04:00
Mark Stapp
7483dcbe29 zebra: add a route_entry flag for FIB-specific nexthops
Add a route_entry flag to indicate the presence of a fib
(installed) list of nexthops - more explicit and clearer.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-07-17 13:12:33 -04:00
Mark Stapp
474aebd939 lib,sharpd,zebra: initial support for multiple backup nexthops
Initial changes to support a nexthop with multiple backups. Lib
changes to hold a small array in each primary, zapi message
changes to support sending multiple backups, and daemon
changes to show commands to support multiple backups. The config
input for multiple backup indices is not present here.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-07-17 13:12:33 -04:00
Mark Stapp
43a9f66cd1 zebra: fix SA warnings in backup nexthop code
Fix a couple of recent SA warnings that came from backup
nexthop/nhlfe changes.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-07-16 11:00:17 -04:00
David Lamparter
3efd0893d0 *: un-split strings across lines
Remove mid-string line breaks, cf. workflow doc:

  .. [#tool_style_conflicts] For example, lines over 80 characters are allowed
     for text strings to make it possible to search the code for them: please
     see `Linux kernel style (breaking long lines and strings)
     <https://www.kernel.org/doc/html/v4.10/process/coding-style.html#breaking-long-lines-and-strings>`_
     and `Issue #1794 <https://github.com/FRRouting/frr/issues/1794>`_.

Scripted commit, idempotent to running:
```
python3 tools/stringmangle.py --unwrap `git ls-files | egrep '\.[ch]$'`
```

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-07-14 10:37:25 +02:00
Mark Stapp
9959f1daba zebra: improve logic handling backup nexthop installation
When handling a fib notification event that involves a route
with backup nexthops, be clearer about representing the
installed state of the backups: any installed backup will be
on a dedicated route_entry list.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-07-07 13:14:01 -04:00
Mark Stapp
4db01e7914 zebra: add fib nhg for backups, revise api
Add an nhg for the fib-installed backup nexthops; rename an
api to access the fib-installed nexthop nhg.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-07-07 13:14:01 -04:00
Jakub Urbańczyk
2f74a82a11 zebra: prepare data plane for batching
* Add new zebra_dplane_result to allow kernel updates not to return
   a result immediately.

Signed-off-by: Jakub Urbańczyk <xthaid@gmail.com>
2020-06-26 22:03:44 +02:00
Mark Stapp
9db35a5e6f zebra: improve route_entry comparison logic
Improve and centralize some logic used to a) compare two
route_entries, and b) to locate a route_entry that matches
a dplane context object that contains the results of a
fib update. We were not rigorous enough in checking routes'
properties, especially when examining connected routes where
we allow multiple route_entries.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-06-25 08:21:27 -04:00
Jakub Urbańczyk
f62e5480ec zebra: convert ip rule installation to use dplane thread
* Implement new dataplane operations
 * Convert existing code to use dataplane context object
 * Modify function preparing netlink message to use dataplane
   context object

Signed-off-by: Jakub Urbańczyk <xthaid@gmail.com>
2020-06-10 16:18:45 +02:00
Renato Westphal
30712725a0
Merge pull request #6480 from volta-networks/feat_pwstatus
ldpd: Relay data plane pseudowire status in LDP notification
2020-06-01 21:00:51 -03:00
Mark Stapp
daaeaa2150 zebra: init dest's list of routes
Use the dlist init api on the zebra dest object's list
of routes.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-06-01 14:46:32 -04:00
Karen Schoener
fd563cc7f3 ldpd: Relay data plane pseudowire status in LDP notification
Provide a way for the data plane to indicate pseudowire
status (such as: not forwarding, AC failure).

On a data plane pseudowire install failure, data plane
sets the pseudowire status.
Zebra relays the pseudowire status to LDP.
LDP includes the pseudowire status in the LDP notification
to the LDP peer.

Signed-off-by: Karen Schoener <karen@voltanet.io>
2020-06-01 13:21:37 -04:00
Emanuele Di Pascale
cd7108ba92 zebra: avoid using c++ keywords in headers
to make sure that c++ code can include them, avoid using reserved
keywords like 'delete' or 'new'.

Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
2020-05-14 16:42:47 +02:00
Donald Sharp
91e6f25bc0 zebra: remove typedef rib_update_event_t from system
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-05-08 08:10:49 -04:00
Donald Sharp
630d596249 zebra: Remove typedef rib_table_info_t from system
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-05-08 08:10:49 -04:00
Stephen Worley
090152ec9c
Merge pull request #5786 from mjstapp/fix_notif_empty_nhg
zebra: fix handling of failed route install via notification
2020-04-29 12:28:56 -04:00
Mark Stapp
a126f12003 zebra: fix handling of failed route install via notification
An async route notification can indicate that installation
has failed, but the handling code wasn't dealing with that
possibility correctly.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-04-27 10:24:55 -04:00
Quentin Young
772270f3b6 *: sprintf -> snprintf
Replace sprintf with snprintf where straightforward to do so.

- sprintf's into local scope buffers of known size are replaced with the
  equivalent snprintf call
- snprintf's into local scope buffers of known size that use the buffer
  size expression now use sizeof(buffer)
- sprintf(buf + strlen(buf), ...) replaced with snprintf() into temp
  buffer followed by strlcat

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-20 19:14:33 -04:00
Jakub Urbańczyk
bd47f3a3b4 zebra: Add vrf name and id to debugs
In some places we log the interface but not the vfr the
interface is in. In others we only output the vrf id, which
can be difficult for human to read. This commit makes zebra
debugs more vrf aware.

Signed-off-by: Jakub Urbańczyk <xthaid@gmail.com>
2020-04-12 21:03:29 +02:00
Donatas Abraitis
c4efd0f423 *: Do not cast to the same type
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-04-08 17:15:06 +03:00
Stephen Worley
ff82bbbb91
Merge pull request #5901 from mjstapp/backup_nh_prep
zebra, lib: Backup nexthop (path) prep work
2020-03-30 10:26:17 -04:00
David Lamparter
07ef3e34ae lib: prepare for plugin-based frr_format check
Signed-off-by: David Lamparter <equinox@diac24.net>
2020-03-29 10:45:46 +02:00
Mark Stapp
377e29f7e7 zebra: handle backup nexthops in nhe/nhgs
Include backup nexthops in nhe processing; connect incoming
zapi route data with updated rib/nhg apis; add more debugs in
nhg processing.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-03-27 11:50:03 -04:00
Mark Stapp
6d81b590a9 zebra: improve route debugging and add support for backups
Refactor the detailed route debugging so that the dump of nexthops
can be used for both normal/active nexthops and backups (if they
are present).

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-03-27 11:50:03 -04:00
Mark Stapp
1d48702ede zebra: add per-nexthop backup index
Use a backup index in a nexthop directly (if it has a backup
nexthop); revise the zebra nhe/nhg code; revise zapi route
decoding to match; revise the dataplane route datastructs.

Refactor some of the rib_add_multipath code to be prepared to
be called with an nhe, carrying nexthop and (possibly) backup
info together.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-03-27 11:50:03 -04:00
Donatas Abraitis
15569c58f8 *: Replace __PRETTY_FUNCTION__/__FUNCTION__ to __func__
Just keep the code cool.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-03-05 20:23:23 +02:00
Ruben Kerkhof
05267678eb zebra: fix typo in debug log message
Signed-off-by: Ruben Kerkhof <ruben@rubenkerkhof.com>
2020-03-04 16:08:18 +01:00
Mark Stapp
c415d89528 zebra: Embed lib nexthop-group in zebra hash entry
Embed nexthop-group, which is just a pointer, in the zebra
nexthop-hash-entry object, rather than mallocing one.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-02-27 15:49:31 -05:00
Donald Sharp
c479e75665 zebra: Add vrf name to debug output
The vrf id is insufficient of a discriminator in people's head
Give them what they need.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-02-14 08:41:42 -05:00
Quentin Young
efa618369a
Merge pull request #5794 from mjstapp/remove_nexthop_matched_flag
lib,zebra: remove unused MATCHED nexthop flag
2020-02-12 11:29:22 -05:00
Mark Stapp
0641a955d7 lib,zebra: remove unused MATCHED nexthop flag
Remove an unused flag value from the nexthop struct.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-02-11 15:56:35 -05:00
Russ White
5bf7fe566d
Merge pull request #5722 from donaldsharp/kernel_routes
Kernel routes
2020-02-06 08:04:42 -05:00
Quentin Young
b3ba5dc7fe *: don't null after XFREE; XFREE does this itself
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-02-03 11:22:13 -05:00
Donald Sharp
3332f4f0fb zebra: Kernel routes w/ AD were not being marked as installed
When we are receiving a kernel route, with an admin distance
of 255 we are not marking it as installed.  This route
should be marked as installed.

New behavior:
K>* 4.5.7.0/24 [255/8192] via 192.168.209.1, enp0s8, 00:10:14

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-01-23 17:17:01 -05:00
Mark Stapp
9287b4c50f zebra: route changes via notify path trigger nht and mpls
Changes to a route via the dataplane notify path should
trigger nht and mpls lsp processing.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-01-06 10:09:47 -05:00
Stephen Worley
84a89a8d2e zebra: null check re->nhe not re->nhe->nhg on attach
We should be NULL checking the entire re->nhe struct, not
the group inside of it. When we get routes from the kernel
using a nexthop group (and future protocols) they will only
pass us an ID to use. Hence, this struct can (and will be)
NULL on first attach when only passed an ID.

There shouldn't be a situation where we have an re->nhe
and don't have an re->nhe->nhg anyway.

Before this patch you can easily make zebra crash by creating a
route in the kernel using a nexthop group and starting zebra.

`ip next add dev lo id 111`
`ip route add 1.1.1.1/32 nhid 111`

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-12-16 16:37:14 -05:00
Mark Stapp
1f6a5aca26 zebra: handle route notification with no nexthops
Handle the special case where a route update contains
no installed nexthops - that means the route is not
installed.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-12-12 12:55:51 -05:00
Mark Stapp
4c0b5436f9 zebra: accept async notification for un-install
Handle an async notification when a route-update operation
uninstalls one route in favor of another.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-12-11 11:22:53 -05:00
Mark Stapp
1c30d64bb6 zebra: align dplane notify processing with nhg work
The processing of dataplane route notifications was a little
off-target after the nexthop-group re-work. This should allow
notifications to work better.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-12-09 16:19:14 -05:00
Donald Sharp
e302caaa81
Merge pull request #5416 from mjstapp/re_nhe_pointer
lib,zebra: use shared nexthop-group in route_entry
2019-12-04 14:11:04 -05:00
Mark Stapp
0eb97b860d lib,zebra: use nhg_hash_entry pointer in route_entry
Replace the existing list of nexthops (via a nexthop_group
struct) in the route_entry with a direct pointer to zebra's
new shared group (from zebra_nhg.h). This allows more
direct access to that shared group and the info it carries.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-12-04 08:13:52 -05:00
David Lamparter
2b64873d24 *: generously apply const
const const const your boat, merrily down the stream...

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-12-02 15:01:29 +01:00
Mark Stapp
5463ce26c3 zebra: clean up rib and nhg headers
Clean up the relationships between zebra's rib and nexthop-group
headers as prep for adding a nexthop-group pointer to the
route_entry.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-11-21 15:05:52 -05:00
Stephen Worley
ace3bbba4b zebra: Don't clear nexthop fib flag on rib_install
We cannot clear the NEXTHOP_FLAG_FIB nexthop flag
when sending routes to the dataplane anymore since
nexthops are now shared.

We were seeing a situation where if we delete a route
using a nexthop group that is still active with another
route, the fib flag was being unset by this code
path despite them still being valid fib nexthops with the
other route.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-11-12 01:24:39 -05:00
Stephen Worley
c7c0b007a4 zebra: separate zebra_vrf_lookup_table_with_id()
We were creating `other` tables in rib_del(), vty commands, and
dataplane return callback via the zebra_vrf_table_with_table_id()
API.

Seperate the API into only a lookup, never create
and added another with `get` in the name (following the standard
we use in other table APIs).

Then changed the rib_del(), rib_find_rn_from_ctx(), and show route
summary vty command to use the lookup API instead.

This was found via a crash where two different vrfs though they owned
the table. On delete, one free'd all the nodes, and then the other tried
to use them. It required specific timing of a VRF existing, going away,
and coming back again to cause the crash.

=23464== Invalid read of size 8
==23464==    at 0x179EA4: rib_dest_from_rnode (rib.h:433)
==23464==    by 0x17ACB1: zebra_vrf_delete (zebra_vrf.c:253)
==23464==    by 0x48F3D45: vrf_delete (vrf.c:243)
==23464==    by 0x48F4468: vrf_terminate (vrf.c:532)
==23464==    by 0x13D8C5: sigint (main.c:172)
==23464==    by 0x48DD25C: quagga_sigevent_process (sigevent.c:105)
==23464==    by 0x48F0502: thread_fetch (thread.c:1417)
==23464==    by 0x48AC82B: frr_run (libfrr.c:1023)
==23464==    by 0x13DD02: main (main.c:483)
==23464==  Address 0x5152788 is 104 bytes inside a block of size 112 free'd
==23464==    at 0x48369AB: free (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==23464==    by 0x48B25B8: qfree (memory.c:129)
==23464==    by 0x48EA335: route_node_destroy (table.c:500)
==23464==    by 0x48E967F: route_node_free (table.c:90)
==23464==    by 0x48E9742: route_table_free (table.c:124)
==23464==    by 0x48E9599: route_table_finish (table.c:60)
==23464==    by 0x170CEA: zebra_router_free_table (zebra_router.c:165)
==23464==    by 0x170DB4: zebra_router_release_table (zebra_router.c:188)
==23464==    by 0x17AAD2: zebra_vrf_disable (zebra_vrf.c:222)
==23464==    by 0x48F3F0C: vrf_disable (vrf.c:313)
==23464==    by 0x48F3CCF: vrf_delete (vrf.c:223)
==23464==    by 0x48F4468: vrf_terminate (vrf.c:532)
==23464==  Block was alloc'd at
==23464==    at 0x4837B65: calloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==23464==    by 0x48B24A2: qcalloc (memory.c:110)
==23464==    by 0x48EA2FE: route_node_create (table.c:488)
==23464==    by 0x48E95C7: route_node_new (table.c:66)
==23464==    by 0x48E95E5: route_node_set (table.c:75)
==23464==    by 0x48E9EA9: route_node_get (table.c:326)
==23464==    by 0x48E1EDB: srcdest_rnode_get (srcdest_table.c:244)
==23464==    by 0x16EA4B: rib_add_multipath (zebra_rib.c:2730)
==23464==    by 0x1A5310: zread_route_add (zapi_msg.c:1592)
==23464==    by 0x1A7B8E: zserv_handle_commands (zapi_msg.c:2579)
==23464==    by 0x19D689: zserv_process_messages (zserv.c:523)
==23464==    by 0x48F09F8: thread_call (thread.c:1599)

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-11-01 16:06:19 -04:00
Stephen Worley
d3a3513811 lib,pbrd,zebra: Use one api to delete nexthops/group
Reduce the api for deleting nexthops and the containing
group to just one call rather than having a special case
and handling it separately.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:43 -04:00