Commit Graph

341 Commits

Author SHA1 Message Date
Donald Sharp
a0ee6f3224 lib: Convert to builtin printf functionality
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-03-14 22:56:07 +01:00
Philippe Guibert
ef524230a6 zebra: move ipset and ipset_entry to zebra dplane contexts
like it has been done for iptable contexts, a zebra dplane context is
created for each ipset/ipset entry event. The zebra_dplane_ctx job is
then enqueued and processed by separate thread. Like it has been done
for zebra_pbr_iptable context, the ipset and ipset entry contexts are
encapsulated into an union of structures in zebra_dplane_ctx.

There is a specificity in that when storing ipset_entry structure, there
was a backpointer pointer to the ipset structure that is necessary
to get some complementary information before calling the hook. The
proposal is to use an ipset_entry_info structure next to the ipset_entry,
in the zebra_dplane context. That information is used for ipset_entry
processing. The ipset name and the ipset type are the only fields
 necessary.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-03-10 14:57:32 +01:00
David Lamparter
1d5453d607 *: remove tabs & newlines from log messages
Neither tabs nor newlines are acceptable in syslog messages.  They also
break line-based parsing of file logs.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-02-14 15:36:51 +01:00
Mark Stapp
5898ce6f35 libs,zebra: remove zapi nhg encode and decode public apis
The raw zapi apis to encode and decode NHGs don't need to be
public; also add a little more validity-checking.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2021-01-19 08:48:54 -05:00
Donald Sharp
bf902d4c52 zebra: Create function to dump MACIP flags
Create a function to dump MACIP flags and to use it.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-01-13 13:22:27 -05:00
Donald Sharp
61e6de9d57 zebra: Add ability to display in human readable format re->flags and status
The re->flags and re->status in debugs were being dumped as hex values.
I can never quickly decode this.  Here is an idea.  Let's let FRR do
it for me.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-01-13 10:16:06 -05:00
Russ White
101ad544fa
Merge pull request #7678 from donaldsharp/aspath_to_zebra
Aspath to zebra
2020-12-10 10:38:14 -05:00
Donald Sharp
71c4870b2c lib: Add encode/decode of opaque data
Add a bit of code that allows for opaque data to be
sent from an upper level protocol to zebra.  This is just
pass through data that will be used as part of displaying
useful data about a route in a `show ip route` command
in future commits.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-12-08 09:06:08 -05:00
Karen Schoener
581e797e02 zebra: Adding zapi client close notification
When zebra detects a client close, send a zapi client close
notification.

Signed-off-by: Karen Schoener <karen@voltanet.io>
2020-12-07 18:22:36 -05:00
Donald Sharp
7cfdb48554 *: Convert all usage of zclient_send_message to new enum
The `enum zclient_send_status` enum needs to be extended
throughout the code base to use the new states and
to fix up places where we tested against the return
value being non zero.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-11-15 15:04:52 -05:00
Donald Sharp
8a3f8f2e4a bgpd, lib, sharpd: Add enum for zclient_send_message return
Add a `enum zclient_send_status` for appropriate handling
of return codes from zclient_send_message.  Touch all the places
where we handle this.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-11-15 14:50:17 -05:00
Donald Sharp
db71415b41 bgpd, lib: Indicate when we are buffering instead of immediately sending down ZAPI
When FRR sends data over the ZAPI protocol from the upper levels to zebra, indicate
to the calling functions that we have started buffering data to be sent if the
socket is full underneath it.

Also add a call back function `zebra_buffer_write_ready` that we can call
when an upper level protocol's socket buffer has been drained.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-11-15 14:50:17 -05:00
Mark Stapp
32f7e999f2 lib: clean up out-of-date zapi comment
Clean up and edit a comment about zapi route encoding; was
outdated (or just ... wrong).

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-11-15 14:50:17 -05:00
Soman K S
77b38a4a7d bgpd: Advertise FIB installed routes to bgp peers (Part 1)
Issue:
The bgp routes learnt from peers which are not installed in kernel are
advertised to peers. This can cause routers to send traffic to these
destinations only to get dropped. The fix is to provide a configurable
option "bgp suppress-fib-pending". When the option is enabled, bgp will
advertise routes only if it these are successfully installed in kernel.

Fix (Part1) :
* Added message ZEBRA_ROUTE_NOTIFY_REQUEST used by client to request
  FIB install status for routes
* Added AFI/SAFI to ZAPI messages
* Modified the functions zapi_route_notify_decode(), zsend_route_notify_owner()
  and route_notify_internal() to include AFI, SAFI as parameters

Signed-off-by: kssoman <somanks@gmail.com>
2020-11-06 08:39:28 +05:30
Donatas Abraitis
2dbe669bdf :* Convert prefix2str to %pFX
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-10-22 09:07:41 +03:00
Quentin Young
2fec17cd04 lib: fix zapi_nexthop_update_decode error rc
This function returns true on success and false otherwise. Returning -1
on error is equivalent to returning true.

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-09-30 18:22:33 -04:00
Stephen Worley
2173535298 lib,zebra,sharpd: add code for backup proto-NHs but disabled
Add the zapi code for encoding/decoding of backup nexthops for when
we are ready for it, but disable it for now so that we revert
to the old way with them.

When zebra gets a proto-NHG with a backup in it, we early fail and
tell the upper level proto. In this case sharpd. Sharpd then reverts
to the old way of installation with the route.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-09-28 12:41:00 -04:00
Stephen Worley
c6ce9334b5 lib,sharpd: align zapi NHG apis a bit
Align the zapi NHG apis to be more consistent with the zapi_route
apis. Add a struct zapi_nhg to use for encodings as well.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-09-28 12:41:00 -04:00
Stephen Worley
ff9aca4f8d lib,zebra,sharpd: clang format
Clang format for NHG API and sharpd patches.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-09-28 12:41:00 -04:00
Stephen Worley
2c7819b9d4 lib,zebra: fixup NHG notify zapi messaging
Make the message parameters align better with other zapi
notifications and change the ID to correctly be a uint32.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-09-28 12:41:00 -04:00
Stephen Worley
e90284d77f lib: add onlink flag to zapi_nh conversion helper
Add setting the onlink flag to the zapi_nh conversion
helper function so that we can set the onlink flag with
it when passing down NHGs from upper level protos.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-09-28 12:40:59 -04:00
Stephen Worley
54c89c9377 zebra: NHG ID bounds macros
Determine the NHG ID spacing and lower bound with ZEBRA_ROUTE_MAX
in macros.

Directly set the upperbound to be the lower 28bits of the uint32_t ID
space (the top 4 are reserved for l2-NHGs). Round that number down
a bit to make it more even.

Convert all former lower_bound calls to just use the macro.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-09-28 12:40:59 -04:00
Stephen Worley
6c67f41f9e zebra,lib: command to only install proto-based nexthops
Add a command/functionality to only install proto-based nexthops.
That is nexthops owned/created by upper level protocols, not ones
implicitly created by zebra.

There are some scenarios where you would not want zebra to be
arbitrarily installing nexthop groups and but you still want
to use ones you have control over via lib/nexthop_group config
and an upper level protocol.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-09-28 12:40:59 -04:00
Donald Sharp
27141ea94e lib, zebra: Add ability to send down a nhgid over route install
Modify the send down of a route to use the nexthop group id
if we have one associated with the route.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-09-28 12:40:59 -04:00
Donald Sharp
2f35a820bf lib, zebra: Add ZAPI_NHG_ADD|DELETE
Add the ability to send a NHG from an upper level protocol down to
zebra.  ZAPI_NHG_ADD encompasses both the addition and replace
semantics ( If the id passed down does not exist yet, it's Add,
else it's a replace ).

Effectively zebra will take this nhg passed down save the nhg
in the id hash for nhg's and then create the appropriate nhg's
and finally install them into the linux kernel.  Notification
will be the ZAPI_NHG_NOTIFY_OWNER zapi message for normal
success/failure messaging to the installing protocol.

This work is being done to allow us to work with EVPN MH
which needs the ability to modify NHG's that BGP will own
and operate on.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-09-28 12:40:59 -04:00
Donald Sharp
224b3c8a79 lib: Add the ability to grab a nhg starting id
Add new function zclient_get_nhg_start that will allow an
upper level protocol to get a starting point for it's own
nhg space.  Give each protocol a space of 50 million.
zebra will own the space from 0 - 199999999 because
of SYSTEM, KERNEL and CONNECT route types.

This is the start of some work that will allow upper
level protocols to install and maintain their own NHG's.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-09-28 12:40:59 -04:00
Donald Sharp
58a1d24924 bgpd, lib, pbrd, zebra: Pass by ifname
When installing rules pass by the interface name across
zapi.

This is being changed because we have a situation where
if you quickly create/destroy ephermeal interfaces under
linux the upper level protocol may be trying to add
a rule for a interface that does not quite exist
at the moment.  Since ip rules actually want the
interface name ( to handle just this sort of situation )
convert over to passing the interface name and storing
it and using it in zebra.

Ticket: CM-31042
Signed-off-by: Stephen Worley <sworley@nvidia.com>
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-09-11 20:04:45 -04:00
Donald Sharp
e7ff02539c lib: Note old ifindex on shutdown
If we have an interface configured in a daemon on shutdown
store the old ifindex value for retrieval on when it is
possibly recreated.

This is especially important for nexthop groups as that we
had at one point in time the ability to restore the
configuration but it was lost when we started deleting
all deleted interfaces.  We need the nexthop group subsystem
to also mark that it has configured an interface.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-08-28 07:51:06 -04:00
Mark Stapp
38fd3eda40 lib: zapi nexthop sort fixes
The sorting for zapi nexthops in zapi routes needs to match
the sorting of nexthops done in zebra. Ensure all zapi_nexthop
attributes are included in the sort.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-08-20 14:50:38 -04:00
Jakub Urbańczyk
d68e74b41c lib, zebra: add support for sending ARP requests
We can make the Linux kernel send an ARP/NDP request by adding
a neighbour with the 'NUD_INCOMPLETE' state and the 'NTF_USE' flag.

This commit adds new dataplane operation as well as new zapi message
to allow other daemons send ARP/NDP requests.

Signed-off-by: Jakub Urbańczyk <xthaid@gmail.com>
2020-08-12 23:19:58 +02:00
Russ White
271ac28499
Merge pull request #6783 from opensourcerouting/feature/sr-te
lib, zebra: Add SR-TE policy infrastructure to zebra
2020-08-10 15:31:35 -04:00
Donald Sharp
8e3ac40d2c
Merge pull request #6483 from sylane/router-id-v6
zebra: add IPv6 router-id
2020-08-10 08:39:51 -04: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
Anuradha Karuppiah
ce5160c081 zebra: Ethernet segment management and support for MAC-ECMP
1. Local ethernet segments are configured in zebra by attaching a
local-es-id and sys-mac to a access interface -
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
!
interface hostbond1
 evpn mh es-id 1
 evpn mh es-sys-mac 00:00:00:00:01:11
!
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
This info is then sent to BGP and used for the generation of EAD-per-ES
routes.

2. Access VLANs associated with an (ES) access port are translated into
ES-EVI objects and sent to BGP. This is used by BGP for the
generation of EAD-EVI routes.

3. Remote ESs are imported by BGP and sent to zebra. A list of VTEPs
is maintained per-remote ES in zebra. This list is used for the creation
of the L2-NHG that is used for forwarding traffic.

4. MAC entries with a non-zero ESI destination use the L2-NHG associated
with the ESI for forwarding traffic over the VxLAN overlay.

Please see zebra_evpn_mh.h for the datastruct organization details.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-08-05 06:46:12 -07: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
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
Sebastien Merle
98a3fb0ab9 zebra: add IPv6 router-id
* add a vrf sub-command `[no] ipv6 router-id X:X::X:X`.
 * add command `[no] ipv6 router-id X:X::X:X [vrf NAME]` for backward
   compatibility.
 * add a vrf sub-command `[no] ip router-id A.B.C.D` and make the old
   one without `ip` an alias for it.
 * add a  command `[no] ip router-id A.B.C.D [vrf NAME]` for backward
   comptibility and make the old one without `ip` an alias for it.
 * add command `show ip router-id [vrf NAME]` and make
   the old one without `ip` an alias for it.
 * add command `show ipv6 router-id [vrf NAME]`.
 * add ZAPI commands `ZEBRA_ROUTER_ID_V6_ADD`,
   `ZEBRA_ROUTER_ID_V6_DELETE` and `ZEBRA_ROUTER_ID_V6_UPDATE`
   for deamons to get notified of the IPv6 router-id.
 * update zebra documentation.

Signed-off-by: Sebastien Merle <sebastien@netdef.org>
2020-07-17 17:39:05 +02: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
2be4d61a86 sharpd: add zclient session create and delete
Add a couple of clis and some simple support that allows sharpd to
create extra zapi client sessions.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-06-16 12:24:24 -04:00
Mark Stapp
387831ffc3 lib,zebra,sharpd: modify opaque zapi message to support unicast
Start modifying the OPAQUE zapi message to include optional
unicast destination zapi client info. Add a 'decode' api and
opaque msg struct to encapsulate that optional info.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-06-10 08:26:27 -04:00
Mark Stapp
d2ddc1416b lib,zebra: rename opaque decode api
Change name of an opaque zapi api to 'decode' to align with the
other zapi message parsing apis. Missed that in the original
opaque commits.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-06-10 08:16:10 -04:00
Mark Stapp
ff49114095 lib: add OPAQUE zapi message
Add a zapi message type designed to carry opaque data. Add
'send' api, and prototype for client handler function. Also
add registration/unreg messages, so that clients can 'subscribe'
to receive these messages as they're passing through zebra.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-06-02 08:20:54 -04:00
Mark Stapp
ae076fc276 lib: add zapi_nexthop2str()
Add a handy 2str api for zapi nexthop debugging.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-06-01 14:46:32 -04:00
Mark Stapp
34f86754a2 lib: add backup nexthop/nhlfe to zapi label messages
Add backup nexthops/nhlfes to the zapi messages used
to convey LSPs to zebra.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-06-01 14:46:12 -04:00
Mark Stapp
4e0b5b31b7 lib,zebra: add a session id for zapi sessions
Distinguish zapi sessions, for daemons who use more than one,
by adding a session id. The tuple of proto + instance is not
adequate to support clients who use multiple zapi sessions.
Include the id in the client show output if it's present. Add
a bit of info about this to the developer doc.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-04-16 12:07:54 -04:00
Quentin Young
cff0de128d lib: fix SA warning in vrf creation zapi handler
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-13 17:03:48 -04:00
Quentin Young
41ce53847b lib: fix if_set_value
Something in there is wrong and causing test failures. Moving it back to
how it was; we'll stil assert if the message was wrong, just in a
different place now.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-13 17:03:48 -04:00
Quentin Young
e4f5680d6e lib: re-add accidentally deleted pfx family set
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-13 13:25:25 -04:00
Quentin Young
f17a9d0a07 lib: more zclient fixes; str termination, vrfs...
* Don't crash if we get a request to create an existing VRF
* Ensure interface & vrf names are null terminated...again

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-13 13:25:25 -04:00
Quentin Young
229d0d4edc lib: don't crash on iface add for unknown vrf
If Zebra sends us an interface add notification with a garbage VRF we
crash on an assert(vrf_get(vrf_id, NULL)); let's not

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-13 13:25:25 -04:00