Commit Graph

364 Commits

Author SHA1 Message Date
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
Quentin Young
b98edbccf8 lib: ensure iface name is null terminated
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-13 13:25:25 -04:00
Quentin Young
7239d3d9e6 lib: handle bogus VRF backend type
And use an enum...

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-13 13:25:25 -04:00
Quentin Young
efc7191bbe lib: make all zclient.[ch] stream funcs safe
Use STREAM_GET* variants of stream getters, which all have non-assert
error paths.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-13 13:25:25 -04: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
Mark Stapp
1df3b1dc65 sharpd: support backup nexthops
Add cli and zapi support for backup nexthops for sharpd routes.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-03-27 09:39:14 -04:00
Mark Stapp
0a8881b4b5 lib: support backup nexthops in nexthop-groups and zapi
Add vty support for backup nexthops in nexthop groups. Capture
backup nexthop info in zapi route messages.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-03-27 09:39:14 -04:00
Mark Stapp
018c648864 lib: add backup nexthops to zapi routes
Add backup nexthop info to zapi route messages.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-03-27 09:37:02 -04:00
Mark Stapp
e4a1ec7454 zebra,lib: use const in more apis
Use const with some args to ipaddr, zebra vxlan, mpls
lsp, and nexthop apis; add some extra checks to some
nexthop-related apis.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-03-27 09:37:02 -04:00
Renato Westphal
4e9d40b8a1
Merge pull request #5925 from volta-networks/synchronous_client
zebra: synchronous client queues accumulate messages from zebra
2020-03-26 17:32:37 -03:00
Karen Schoener
17da84a49d zebra: Synchronous client queues accumulate messages from zebra.
Zebra is currently sending messages on interface add/delete/update,
VRF add/delete, and interface address change - regardless of whether
its clients had requested them.  This is problematic for lde and isis,
which only listens to label chunk messages, and only when it is
waiting for one (synchronous client). The effect is the that messages
accumulate on the lde synchronous message queue.

With this change:
  - Zebra does not send unsolicited messages to synchronous clients.
  - Synchronous clients send a ZEBRA_HELLO to zebra.
    The ZEBRA_HELLO contains a new boolean field: sychronous.
  - LDP and PIM have been updated to send a ZEBRA_HELLO for their
    synchronous clients.

Signed-off-by: Karen Schoener <karen@voltanet.io>
2020-03-23 09:17:17 -04:00
Donald Sharp
46f56dadd4 lib: Modify zclient_send_rnh to use const struct prefix
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-22 18:38:56 -04:00
Donatas Abraitis
0d6f7fd6fd *: Replace sizeof something to sizeof(something)
Satisfy checkpatch.pl requirements (check for sizeof without parenthesis)

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-03-08 21:44:53 +02: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
Donald Sharp
0d60f61f18
Merge pull request #5813 from mjstapp/zapi_labels_use_nh
*: encode zapi labels message using nexthops
2020-02-18 09:57:22 -05:00
Mark Stapp
4945002d71 *: encode zapi labels message using nexthops
Use the zapi_nexthop struct with the mpls_labels
zapi messages instead of the special-purpose (and
more limited) nexthop struct that was being used.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-02-14 16:16:21 -05:00
Donatas Abraitis
752022670a *: Remove break after return
Just a deadcode.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-02-13 15:39:54 +02:00
Santosh P K
be7bbe529d lib: Adding GR capabilites encode and decode.
For Graceful restart clients have to send GR capabilities
library functions are added to encode capabilities and
also for zebra to decode client capabilities.

Co-authored-by: Santosh P K <sapk@vmware.com>
Co-authored-by: Soman K S <somanks@vmware.com>
Signed-off-by: Santosh P K <sapk@vmware.com>
2020-01-30 10:25:52 -08:00
bisdhdh
2ba1fe6951 bgpd: BGP Garaceful Restart debug logs.
Reorganizing bgp gr debug logs and code review comments.

Signed-off-by: Biswajit Sadhu <sadhub@vmware.com>
2020-01-23 09:36:33 +05:30
bisdhdh
eb451ee589 bgpd: Zebra lib for Graceful Restart.
These changes are for Zebra lib in order to supportGraceful Restart
feature. These changes are addedtemporarily, until Zebra Graceful
Restart lib Pr is merged.

Signed-off-by: Biswajit Sadhu <sadhub@vmware.com>
Signed-off-by: Soman K S <somanks@vmware.com>
2020-01-23 09:36:33 +05:30
Donald Sharp
9d080116b9 lib: Fix nexthop encoding
Commit
68a02e06e5 broke nexthop encoding
for nexthop tracking.

This code combined the different types of nexthop encoding
being done in the zapi protocol.  What was missed that
resolved nexthops of type NEXTHOP_TYPE_IPV4|6 have an ifindex
value that was not being reported.  This commit ensures
that we always send this data( even if it is 0).

The following test commit will ensure that this stays working
as is expected by an upper level protocol.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-01-18 09:29:30 -05:00
Quentin Young
24c370dd46 zebra: fix redist memleak on client disconnect
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-01-15 14:18:40 -05:00
Stephen Worley
9ab0b2a37a lib,zebra: add zapi msg top level error handling
Add error handling for top level failures (not able to
execute command, unable to find vrf for command, etc.)

With this error handling we add a new zapi message type
of ZEBRA_ERROR used when we are unable to properly handle
a zapi command and pass it down into the lower level code.

In the event of this, we reply with a message of type
enum zebra_error_types containing the error type.

The sent packet will look like so:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Length            |     Marker    |    Version    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                             VRF ID                            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|            Command            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|            ERROR TYPE         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Also add appropriate hooks for clients to subscribe to for
handling these types of errors.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-01-08 12:22:29 -05:00
Quentin Young
b900b3c6a4 lib: dont decode more nexthops than we can handle
If someone provides us more nexthops than our configured multipath
setting, drop the rest of them

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-01-06 12:43:29 -05:00
Donald Sharp
bd054c1aa2 lib, zebra: Allow for encode/decode of nexthop weight in pass down
Add code to encode/decode the nexthop weight when we pass it down
into zebra.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-12-09 13:37:37 -05:00
Mark Stapp
68a02e06e5 *: revise zapi nexthop encoding
Use a per-nexthop flag to indicate the presence of labels; add
some utility zapi encode/decode apis for nexthops; use the zapi
apis more consistently.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-12-06 10:17:20 -05:00
Satheesh Kumar K
46c2687c72 pimd, lib: adding support for MLAG Message processing at PIM
This includes:
1. Defining message formats
2. Stream Decoding after receiving the message at PIM
3. Handling MLAG UP & Down Notifications

Signed-off-by: Satheesh Kumar K <sathk@cumulusnetworks.com>
2019-11-13 20:43:15 -08:00
Satheesh Kumar K
36b5b98fef pimd : Add support for MLAG Register & Un-register
when ever a FRR Client wants to send any data to another node
using MLAG Channel, uses below mechanisam.

1. sends  a MLAG Registration to zebra with interested messages that
   it is intended to receive from peer.
2. In response to this request, Zebra opens communication channel with
   MLAG. and also in Rx. diretion zebra forwards only those messages which
   client shown interest during registration
3. when client is no-longer interested in communicating with MLAG, client
   posts De-register to Zebra
4. if this is the last client which is interested for MLAG Communication,
   zebra closes the channel.

why PIM Needs MLAG Communication
================================
1. In general on LAN Networks elecetd DR will send the Join towards
   Multicast RP in case of a LHR and Register in case of FHR.
2. But in case DR Goes down, traffic will be re-converged only after
   the New DR is elected, but this can take time based on Hold Timer to
   detect the DR down.
3. this can be optimised by using MLAG Mecganisam.
4. and also Traffic can be forwarded more efficiently by knowing the cost
   towards RP using MLAG

Signed-off-by: Satheesh Kumar K <sathk@cumulusnetworks.com>
2019-11-13 19:46:52 -08:00
Donald Sharp
6e8e092521 lib, zebra: Fix last write command written
With commit: a9ff90c41b
the vrf_id_t was changed from a uint16_t to a uint32_t

Zebra tracked the last command sent to it's peer via peeking
into the data it was sending to each client ( since we had
lost the idea of what the command was when it was time to track
the data ).

Add a define to track this and add a bit of verbiage
to the code to allow us to notice when we screw with
the header again so that this is just fixed correctly
when it happens again.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-10-15 14:54:35 -04:00
Quentin Young
6a597223d3 Revert "Merge pull request #4885 from satheeshkarra/pim_mlag"
This reverts commit d563896dad, reversing
changes made to 09ea1a4038.
2019-10-14 17:15:09 +00:00
Jafar Al-Gharaibeh
d563896dad
Merge pull request #4885 from satheeshkarra/pim_mlag
pimd, lib, Zebra: PIM MLAG Support
2019-10-14 01:07:24 -05:00
Stephen Worley
66cd1bb309 lib: Decode vrf_id update appropriately from zapi
The vrf_id in `zsend_interface_vrf_update()` is encoded as
a long via `stream_putl()`, we should decode it as such
as well.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-01 19:07:37 -04:00
Satheesh Kumar K
5fdca4ded5 pimd, lib: adding support for MLAG Message processing at PIM
This includes:
1. Defining message formats
2. Stream Decoding after receiving the message at PIM
3. Handling MLAG UP & Down Notifications

Signed-off-by: Satheesh Kumar K <sathk@cumulusnetworks.com>
2019-09-24 01:35:09 -07:00
Donald Sharp
26f8f6fe7f lib: delete interface if you can in upper level protocol
In an upper level protocol, delete the interface on notification
about deletion.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-09-19 13:34:06 -04:00
Donald Sharp
3c3c325203 *: Convert zapi->interface_delete to ifp callback
Convert the callback of the interface_delete to the new
ifp callback.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-09-19 13:34:06 -04:00
Donald Sharp
b0b69e59f4 *: Convert interface_down to interface down callback
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-09-19 13:34:06 -04:00
Donald Sharp
ddbf3e6060 *: Convert from ->interface_up to the interface callback
For all the places we have a zclient->interface_up convert
them to use the interface ifp_up callback instead.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-09-19 13:34:06 -04:00
Donald Sharp
ef7bd2a3d5 *: Switch all zclient->interface_add to interface create callback
Switch the zclient->interface_add functionality to have everyone
use the interface create callback in lib/if.c

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-09-19 13:34:06 -04:00
Satheesh Kumar K
4bf3dda597 pimd : Add support for MLAG Register & Un-register
when ever a FRR Client wants to send any data to another node
using MLAG Channel, uses below mechanisam.

1. sends  a MLAG Registration to zebra with interested messages that
   it is intended to receive from peer.
2. In response to this request, Zebra opens communication channel with
   MLAG. and also in Rx. diretion zebra forwards only those messages which
   client shown interest during registration
3. when client is no-longer interested in communicating with MLAG, client
   posts De-register to Zebra
4. if this is the last client which is interested for MLAG Communication,
   zebra closes the channel.

why PIM Needs MLAG Communication
================================
1. In general on LAN Networks elecetd DR will send the Join towards
   Multicast RP in case of a LHR and Register in case of FHR.
2. But in case DR Goes down, traffic will be re-converged only after
   the New DR is elected, but this can take time based on Hold Timer to
   detect the DR down.
3. this can be optimised by using MLAG Mecganisam.
4. and also Traffic can be forwarded more efficiently by knowing the cost
   towards RP using MLAG

Signed-off-by: Satheesh Kumar K <sathk@cumulusnetworks.com>
2019-09-16 20:11:01 -07:00
Renato Westphal
ea6b290bf6 lib, zebra: add new MPLS zapi message with route replace semantics
This new message makes it possible to install/reinstall LSPs with
multiple nexthops using a single ZAPI message.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-09-10 00:01:10 -03:00
Renato Westphal
b3c49d0e77 lib, zebra: enhance the MPLS zapi messages
* Add ability to specify the nexthop type;
* Add ability to install or not a FTN (in addition to an LSP).

These two additions will be useful to install local SR Prefix-SIDs
configured with the no-PHP option.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-09-06 21:06:11 -03:00
Renato Westphal
e132dea064 zebra: identify MPLS FTNs by route type and instance
Use the route type and instance instead of the route distance
to identify MPLS FTNs. This is a more robust approach since the
routing daemons can modify the distance of their announced routes
via configuration, which can cause inconsistencies.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-09-06 21:06:11 -03:00
Renato Westphal
bad6b0e72e lib: introduce encode/decode functions for the MPLS zapi messages
Do this for the following reasons:
* Improve modularity of the code by separating the decoding of the
  ZAPI messages from their processing;
* Create an API that is easier to use by the client daemons.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-09-06 21:06:11 -03:00
Mark Stapp
8ce4c74607
Merge pull request #4789 from sworleys/Nexthop-Sort-Optimization
lib: Nexthop Sorting Optimizations
2019-09-04 13:35:50 -04:00
Renato Westphal
6a2b0d9a7a lib: don't ignore stream errors in some zapi decode functions
Some other ZAPI decode functions still use void return values and
can't propagate stream errors to their callers. They need to be fixed
as well in the future.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-08-21 00:53:00 -03:00
Stephen Worley
3c6e0bd472 lib: Sort zapi_nexthops on the encode
Sort nexthops before we push them to zebra. This offloads
the nexthop sorting zebra is doing onto the upper level protocols
so that when it gets to zebra and we construct a group, it just has
to append them to the tail for every nexthop.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-08-19 15:56:45 -04:00
Emanuele Di Pascale
f004f7c3ce lib, zebra: handle failure in get chunk
when requesting a specific label chunk (e.g. for the SRGB),
it might happen that we cannot get what we want. In this
event, we must be prepared to receive a response with no
label chunk. Without this fix, if the remote label manager
was not able to alloate the chunk we requested, we would
hang indefinitely trying to read data from the stream which
was not there.

Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
2019-07-10 15:20:27 +02:00
Emanuele Di Pascale
0e3b6a926a lib, zebra: support label chunk requests for SRGB
For SRGB, we need to support chunk requests starting at a
specific point in the label space, rather than just asking
for any sufficiently large chunk. To this purpose, we extend
the label manager api to request a chunk with a base value;
if the base is set to 0, the label manager will behave as it
currently does, i.e. fetching the first free chunk big enough
to satisfy the request.

update all the existing calls to get chunks from the label
manager so that they use MPLS_LABEL_BASE_ANY as the base
for the requested chunk

Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
2019-07-10 15:20:27 +02:00
Donald Sharp
a36898e755
Revert "Ospf missing interface handling 2" 2019-06-23 19:46:39 -04:00
Philippe Guibert
a41c4e1b1f *: change interface structure, from vrf_id to vrf
Field vrf_id is replaced by the pointer of the struct vrf *.
For that all other code referencing to (interface)->vrf_id is replaced.
This work should not change the behaviour.
It is just a continuation work toward having an interface API handling
vrf pointer only.

some new generic functions are created in vrf:
vrf_to_id, vrf_to_name,

a zebra function is also created:
zvrf_info_lookup

an ospf function is also created:
ospf_lookup_by_vrf

it is to be noted that now that interface has a vrf pointer, some more
optimisations could be thought through all the rest of the code. as
example, many structure store the vrf_id. those structures could get
the exact vrf structure if inherited from an interface vrf context.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-06-12 14:10:28 +02:00
Philippe Guibert
f11e98eca3 *: change if_lookup_by_name() api with vrf
the vrf_id parameter is replaced by struct vrf * parameter.
this impacts most of the daemons that look for an interface based on the
name and the vrf identifier.
Also, it fixes 2 lookup calls in zebra and sharpd, where the vrf_id was
ignored until now.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-06-12 08:37:54 +02:00
Philippe Guibert
4c634658a6 ospf, ospf6d, zebra, lib: change if_get_by_name prototype with vrf
vrf pointer is used as reference when calling if_get_by_name() function.
this will permit to create interfaces with an unknown vrf_id, since it
is only necessary to get the vrf structure to store the interfaces.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-06-11 17:10:47 +02:00
Donald Sharp
f3f4562612 lib, zebra: Ensure route encoding has enough space
When you have compiled FRR with a large multipath number
then encoding large ecmp routes between zebra and the
routing daemons.  There exists a theoritical size
of multipath that will cause the encoding to be larger
than the ZEBRA_MAX_PACKET_SIZ.  In the cases where
we have allocated streams that will encode routes
then let's ensure that whatever size we have will
auto-fit what we say we can send.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-05-31 10:25:18 -04:00
Quentin Young
53e60e5c58 vrrpd: autoconfig support
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-17 00:27:08 +00:00
Quentin Young
c3bd894e4d vrrpd: protodown macvlan in backup state
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-17 00:27:08 +00:00
Quentin Young
121f9dee7c *: use ZAPI_CALLBACK_ARGS macro for zapi handlers
This macro:
- Marks ZAPI callbacks for readability
- Standardizes argument names
- Makes it simple to add ZAPI arguments in the future
- Ensures proper types
- Looks better
- Shortens function declarations

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-03 20:57:35 +00:00
Anuradha Karuppiah
4ab3321f29 lib, zebra: changes to propagate vxlan mcast SG entries to pimd
These updates act as triggers to pimd to -
1. join the MDT for rxing VxLAN encapsulated BUM traffic
2. register the local-vtep-ip as a source for the MDT

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2019-04-20 08:33:20 -07:00
Renato Westphal
338b8e914a *: setting the socket send/recv buffer sizes doesn't need elevated privs
The less code running under elevated privileges the better.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-04-08 13:11:28 -03:00
Quentin Young
c17faa4b10 lib: reduce exported var symbols
Don't need these in our DSO tables

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-04-03 20:34:18 +00:00
Renato Westphal
add682b39b
Merge pull request #4014 from dslicenc/zclient-interface-add
lib: zclient provide interface info during reg_requests
2019-03-29 10:04:30 -03:00
Don Slice
eeb2dfa3af lib: zclient provide interface info during reg_requests
Problem found in bgpd where it wasn't learning interface address
information at startup due to the interface information becoming
available before the bgp instance was created. This issue was
caused by an earlier change that tried to make the interface
information discovery process more efficient but left this hole
for bgpd. For now, putting back in the previous method of
gathering interface info via the zclient_send_reg_requests call
and will revisit a more efficient way to get the info in the future.

Ticket: CM-23932
Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2019-03-25 16:18:07 +00:00
Donald Sharp
cdc6ed9016 lib: Improve debugs in zclient.c
Fixup a couple of places to improve debugging of what is
going on in zclient.c.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-03-25 09:09:35 -04:00
Quentin Young
9165c5f5ff *: remove trailing newlines from zlog messages
Zlog puts its own newlines on, and doing this makes logs look nasty.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-03-14 18:41:15 +00:00
Donald Sharp
22761baa25 lib: Send interface request after initial hello
Ask for all interface information after we have connected
to zebra and sent the initial hello.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-02-05 09:13:30 -05:00
Donald Sharp
fe85601c96 *: The onlink attribute should be owned by the nexthop not the route.
The onlink attribute was being passed from upper level protocols
as an attribute of the route *not* the individual nexthop.  When
we pass this data to the kernel, we treat the onlink as a attribute
of the nexthop.  This commit modifies the code base to allow
us to pass the ONLINK attribute as an attribute of the nexthop.

This commit also fixes static routes that have multiple nexthops
some onlink and some not.

ip route 4.5.6.7/32 192.168.41.1 eveth1 onlink
ip route 4.5.6.7/32 192.168.42.2

S>* 4.5.6.7/32 [1/0] via 192.168.41.1, eveth1 onlink, 00:03:04
  *                  via 192.168.42.2, eveth2, 00:03:04

sharpd@robot ~/frr2> sudo ip netns exec EVA ip route show
4.5.6.7 proto 196 metric 20
	nexthop via 192.168.41.1 dev eveth1 weight 1 onlink
	nexthop via 192.168.42.2 dev eveth2 weight 1

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-01-26 21:02:26 -05:00
Quentin Young
b9c25a2a90
Merge pull request #3559 from opensourcerouting/zapi-sanity-checks
add a few moar sanity checks when encoding/decoding zapi routes
2019-01-22 13:53:08 -05:00
Donald Sharp
b3cfe1e2da
Merge pull request #3633 from opensourcerouting/send-vrf-backend
Send VRF backend to the client daemons
2019-01-22 09:11:58 -05:00
Renato Westphal
bb6b7f79be zebra, lib: send VRF backend to the client daemons
Add a new field in the ZEBRA_CAPABILITIES zapi message specifying
the VRF backend in use.

For simplicity, make the zclient code call vrf_configure_backend()
to apply the received value automatically instead of requiring
the daemons to do that themselves in their zebra_capabilities()
callbacks.

Additionally, call zebra_vrf_update_all() only after sending the
capabilities message to the client, so that it will know which VRF
backend is in use when processing the VRF messages.

This commit fixes a couple of bugs in the "interface" CLI command and
associated northbound callbacks, which behave differently depending
on the VRF backend in use. Before this commit, the vrf_backend
variable would always be set to VRF_BACKEND_NETNS in the client
daemons, even when zebra was started without the --vrfwnetns option.
This could lead to inconsistent behavior and subtle bugs under
specific circumstances.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-01-19 22:46:37 -02:00
Renato Westphal
edc127627d lib: use the correct VRF ID when parsing INTERFACE_LINK_PARAMS messages
Bug found during code inspection.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-01-18 16:06:00 -02:00
Renato Westphal
d763789879 lib: fix checking of clients subscribed to receive default routes
In these two functions, we were using VRF_DEFAULT instead of the
VRF ID passed as a parameter when checking if the given client
subscribed to receive default routes or not. This prevented the
"default-originate" command from ospfd/isisd from working correctly
under specific circumstances.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-01-18 16:06:00 -02:00
Renato Westphal
e4081c0e0b lib: add a few more sanity checks when encoding/decoding routes
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-01-14 15:58:26 -02:00
Renato Westphal
49db7a7b05 lib, zebra: add AFI parameter to the ZEBRA_REDISTRIBUTE_DEFAULT_* messages
Some daemons like ospfd and isisd have the ability to advertise a
default route to their peers only if one exists in the RIB. This
is what the "default-information originate" commands do when used
without the "always" parameter.

For that to work, these daemons use the ZEBRA_REDISTRIBUTE_DEFAULT_ADD
message to request default route information to zebra. The problem
is that this message didn't have an AFI parameter, so a default route
from any address-family would satisfy the requests from both daemons
(e.g. ::/0 would trigger ospfd to advertise a default route to its
peers, and 0.0.0.0/0 would trigger isisd to advertise a default route
to its IPv6 peers).

Fix this by adding an AFI parameter to the
ZEBRA_REDISTRIBUTE_DEFAULT_{ADD,DELETE} messages and making the
corresponding code changes.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-01-14 11:41:33 -02:00
Donald Sharp
02c0866dbe lib, zebra: On startup send mlag role as part of the capabilities
On startup send the mlag role as part of the capabilities to
the end protocol.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-01-04 12:21:00 -05:00
Renato Westphal
91d227b7e3 zebra, lib: fix the ZEBRA_INTERFACE_VRF_UPDATE zapi message
Unlike the other interface zapi messages, ZEBRA_INTERFACE_VRF_UPDATE
identifies interfaces using ifindexes and not interface names. This
is a problem because zebra always sends ZEBRA_INTERFACE_DOWN
and ZEBRA_INTERFACE_DELETE messages before sending
ZEBRA_INTERFACE_VRF_UPDATE, and the ZEBRA_INTERFACE_DELETE callback
from all daemons set the interface index to IFINDEX_INTERNAL. Hence,
when decoding a ZEBRA_INTERFACE_VRF_UPDATE message, the interface
lookup would always fail since the corresponding interface lost
its ifindex. Example (ospfd):

OSPF: Zebra: Interface[rt1-eth2] state change to down.
OSPF: Zebra: interface delete rt1-eth2 vrf default[0] index 8 flags 11143 metric 0 mtu 1500
OSPF: [EC 100663301] INTERFACE_VRF_UPDATE: Cannot find IF 8 in VRF 0

To fix this problem, use interface names instead of ifindexes to
indentify interfaces like the other interface zapi messages do.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-01-02 13:32:31 -02:00
Philippe Guibert
4fe52e7622 lib, zebra: default vrf configured will not be overwritten by discovery
the netns discovery process executed when vrf backend is netns, allows
the zebra daemon to dynamically change the default vrf name value. This
option is disabled, when the zebra is forced to a default vrf value with
option -o.

PR=61513
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Acked-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
2018-11-21 17:21:19 +01:00
Donald Sharp
26f63a1ec6 *: Replace zclient_new with zclient_new_notify
It's been a year since we added the new optional parameters
to instantiation.  Let's switch over to the new name.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-11-12 09:16:23 -05:00
Donald Sharp
b6c9de3bd3 lib, zebra: Encode nexthop vrf in nht updates
The nexthop vrf was not being encoded in nht updates.
Add it in.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-11-01 18:34:40 -04:00
Renato Westphal
8f90d89ba9 lib: retrofit interface commands to the new northbound model
The frr-interface YANG module models interfaces using a YANG list keyed
by the interface name and the interface VRF. Interfaces can't be keyed
only by their name since interface names might not be globally unique
when the netns VRF backend is in use. When using the VRF-Lite backend,
however, interface names *must* be globally unique. In this case, we need
to validate the uniqueness of interface names inside the appropriate
northbound callback since this constraint can't be expressed in the
YANG language. We must also ensure that only inactive interfaces can be
removed, among other things we need to validate in the northbound layer.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-10-27 16:16:12 -02:00