Commit graph

69 commits

Author SHA1 Message Date
Donald Sharp f77095430d zebra: Cleanup linked list on shutdown in label manager
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-12-11 15:26:20 -05:00
Philippe Guibert d3f686d163 zebra: do not accept static label requests conflicting with dynamic-block
A static label allocation should not be accepted if the desired range
conflicts with the configured dynamic-block configuration.

Do not accept such label requests, only when dynamic blocks are
configured.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-10-18 17:46:28 +02:00
Philippe Guibert c6498ace44 zebra: dump the dynamic-block bounds on vty command
The 'show debugging label-table' needs to dump
dynamic block information.
Display the lower and upper values for the dynamic
block.

> # show debugging label-table json
> {
>     "dynamicBlock":{
>     "lowerBound":16,
>     "upperBound":1048575
>   },
> [..]
> # show debugging label-table
> Dynamic block: lower-bound 16, upper-bound 1048575
> [..]

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-10-18 17:46:25 +02:00
Philippe Guibert 0bd8a16082 zebra: add json support to 'show debugging label-table'
Add the json keyword to dump the label chunks of
the zebra label manager in json format.

>dut# show debugging label-table json
> {
>   "chunks":[
>     {
>       "protocol":"bgp",
>       "instance":0,
>       "sessionId":1,
>       "start":16,
>       "end":16,
>       "dynamic":true
>     },
>     {
>       "protocol":"ldp",
>       "instance":0,
>       "sessionId":1,
>       "start":17,
>       "end":80,
>       "dynamic":true
>     }
>   ]
> }

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-10-18 17:45:29 +02:00
Philippe Guibert fccda55eac zebra: add label chunk allocation in the dynamic block range
This commit adds support for the label chunk allocation in
the configured dynamic block range.

An additional check ensures the upper bound does not go
over the upper bound of the dynamic-block.
Otherwise, a chunk is created with the lower bound set
to the first label element available in the defined
range.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-10-18 09:41:02 +02:00
Philippe Guibert 7a7c4bc80a zebra: rework dynamic label request algorithm
The label chunk algorithm needs to be revisited to support a
configured dynamic-block or the default one.

Reuse the 'lbl_mgr.dynamic_block_[start/end]' variables,
whereever needed, and simplify the algorithm.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-10-18 09:41:02 +02:00
Philippe Guibert 0832a2be53 zebra: add 'mpls label dynamic-block' command
Hardset label values (eg. ISIS Segment-routing label blocks,
hardset BGP L3VPN service label) may conflict with label chunks
dynamically allocated by zebra.

Add an optional 'mpls label dynamic-block' command to let the user
define a range that is not in conflict with the hardset values.
Restarting control planes is recommended when dynamic label
chunks are already allocated. Command is aborted when any hardset
label chunks conflict with the dynamic block.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-10-18 09:41:02 +02:00
Philippe Guibert b71370e83f zebra: fix label allocation when room space before first chunk
After ISIS first allocates a label chunk at [1000;2000],
the '16' label value is not used when BGP tries to
allocate a label chunk in auto mode. This does not happen
when BGP is the only one to do the label allocation.

When a label chunk has been accepted, the next label
request checks if there is room space before the existing
label chunk, and uses the lower label value to 17, and not
16.

Fix this by changing the previous range end 'prev_end' label
value to 15 which is the end of the reserved MPLS label
range.

Fixes: 3c84497943 ("zebra: label manager should never return a reserved block")
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-10-18 09:41:02 +02:00
Philippe Guibert 9d32589b58 zebra, test: mark mpls label chunks as dynamic or static
The zebra label manager stores the mpls label chunks,
but does not record if the label request was for a
dynamic or a static chunk.

For all label requests accepted, mark the label chunk
if the 'base' parameter is set to MPLS_LABEL_BASE_ANY,
unmark it otherwise.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-10-18 09:41:02 +02:00
Philippe Guibert 1cedcf7b15 zebra: add label chunk range in log when label manager request fails
When the label manager is unable to provide a label chunk to
a routing service, an error message is displayed:

> Oct 11 11:47:27 vsr zebra[163745]: [YMY6E-K9JYD][EC 4043309085] Unable to assign Label Chunk to bgp instance 0

There is missing information on the range that was requested.
Add this information in the log message.

> Oct 11 11:47:27 vsr zebra[163745]: [YMY6E-K9JYD][EC 4043309085] Unable to assign Label Chunk 60 - 60 to bgp instance 0

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-10-13 14:01:56 +02:00
Philippe Guibert 6988622832 zebra: merge lm_get_chunk_response() function
This function lm_get_chunk_response() is only called
by label_manager_get_chunk(). Let us move the code of
the function in the caller.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-10-13 14:01:29 +02:00
fmihoub6WIND a4b3f03108 zebra: delete label chunk upon release
In zebra/label_manager.c the releasing of the label chunk is done by
disowning the chunk to the system. The presence of this system label
chunk will cause label assignment to fail for this use case example:

label chunk ospf: 300-320
label chunk system: 510-520
label chunk isis: 1200-1300

Then we try to allocate the chunk 500-530, we get this error:
  "Allocation of mpls label chunk [500/530] failed"

The error is raised when the below condition is true:
    /* if chunk is used, cannot honor request */
      if (lmc->proto != NO_PROTO)
	      return NULL;

Delete the label chunk instead of disowning it when the label releasing
is done.

Signed-off-by: Farid MIHOUB <farid.mihoub@6wind.com>
2023-09-29 08:24:18 +02:00
fmihoub6WIND 2b8e22f264 zebra: dump label table information
Add the new command "show debugging labeltable" to show allocated label
chunks in the label table managed with label_manager.c

Signed-off-by: Farid Mihoub <farid.mihoub@6wind.com>
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-09-29 08:24:18 +02:00
David Lamparter acddc0ed3c *: auto-convert to SPDX License IDs
Done with a combination of regex'ing and banging my head against a wall.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-02-09 14:09:11 +01:00
Donald Sharp 7df0e6bb3b
Merge pull request #7756 from pjdruddy/bgplu-fixes
Bgplu fixes
2021-01-09 15:48:22 -05:00
Pat Ruddy 507d2737d6 zebra: expose label-manager util-funcs
Revert "zebra: unexpose label-manager util-funcs as static"
This reverts commit d3d9639d9a.

Signed-off-by: Pat Ruddy <pat@voltanet.io>
2021-01-05 18:19:44 +00:00
Pat Ruddy 189982283a zebra: labelmanager could return reserved labels
when checking if there is a "hole" behind the current reservation
marker the calculation of whether the hole is big enough to satisfy
the requested chunk is out by 1. This could result in returning a label
which has already been allocated.

Signed-off-by: Pat Ruddy <pat@voltanet.io>
2021-01-04 14:29:44 +00:00
Pat Ruddy 3c84497943 zebra: label manager should never return a reserved block
if the requested chunk size was less than 16 then a chunk
within the reserved block would be returned. Make sure that
we never return labels that are below MPLS_LABEL_UNRESERVED_MIN

Signed-off-by: Pat Ruddy <pat@voltanet.io>
2021-01-04 14:29:44 +00:00
Hiroki Shirokura d3d9639d9a zebra: unexpose label-manager util-funcs as static
Following functions which is a piece of label-maanager implementation
isn't called from out side of its file. And all lines of label-manager
are coded on zebra/label_manager.c at this time. So these functions
should be unexposed.

Functions:
- create_label_chunk
- assign_label_chunk
- delete_label_chunk
- release_label_chunk

Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2020-12-10 09:56:55 +09:00
GalaxyGorilla 7658c2e560 zebra: Fix selection of label chunks in label manager
For allocating a new label range the label manager will loop
the existing label chunks and compare the start and end labels
with the label range in question. In case a label range should
be re-allocated to the existing label chunk, the end label
of the chunk is not honored correctly, e.g. the new label
range has to be a true subset of the existing label chunk.

This is very easy reproducable by re-allocating a single label.
e.g. a label range of size 1.

This problem is fixed by allowing the mentioned 'end' labels to
be equal.

Signed-off-by: GalaxyGorilla <sascha@netdef.org>
2020-08-07 11:08:49 +02:00
Mark Stapp 4cebdb9bb8 zebra,ldpd: use zapi client session id in LM apis
Use the zapi client session id in the label manager apis;
use the client struct directly in some code. Assign a session
id to ldpd's sync LM zapi session.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-04-16 12:07:54 -04:00
Emanuele Di Pascale 1935832264 zebra: minor fix to label manager log
zebra should only check whether a get_chunk operation succeeded
when processing the response, rather than insde the get_chunk
call itself. Spllitting the request and response hooks was done
precisely to allow for asynchronous calls to an external label
manager; in this case, the requested chunk is not necessarily
going to be available at request time.

Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
2020-04-07 11:33:16 +02:00
Lou Berger 8678d6387c *: use the current project name (FRRouting)
Signed-off-by: Lou Berger <lberger@labn.net>
2020-03-25 17:38:56 -04:00
Donald Sharp 7feb884d15 zebra: Fix label manager memory leak
==25402==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 16 byte(s) in 1 object(s) allocated from:
    #0 0x533302 in calloc (/usr/lib/frr/zebra+0x533302)
    #1 0x7fee84cdc80b in qcalloc /home/qlyoung/frr/lib/memory.c:110:27
    #2 0x5a3032 in create_label_chunk /home/qlyoung/frr/zebra/label_manager.c:188:3
    #3 0x5a3c2b in assign_label_chunk /home/qlyoung/frr/zebra/label_manager.c:354:8
    #4 0x5a2a38 in label_manager_get_chunk /home/qlyoung/frr/zebra/label_manager.c:424:9
    #5 0x5a1412 in hook_call_lm_get_chunk /home/qlyoung/frr/zebra/label_manager.c:60:1
    #6 0x5a1412 in lm_get_chunk_call /home/qlyoung/frr/zebra/label_manager.c:81:2
    #7 0x72a234 in zread_get_label_chunk /home/qlyoung/frr/zebra/zapi_msg.c:2026:2
    #8 0x72a234 in zread_label_manager_request /home/qlyoung/frr/zebra/zapi_msg.c:2073:4
    #9 0x73150c in zserv_handle_commands /home/qlyoung/frr/zebra/zapi_msg.c:2688:2

When creating label chunk that has a specified base, we eventually are
calling assign_specific_label_chunk. This function finds the appropriate
list node and deletes it from the lbl_mgr.lc_list but since
the function uses list_delete_node() the deletion function that is
specified for lbl_mgr.lc_list is not called thus dropping the memory.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-01-15 08:18:50 -05:00
Donald Sharp 8f86bb067e zebra: Guard debug messages
A bunch of debug code has snuck in that is unguarded.
Fix this.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-07-16 20:30:55 -04:00
Emanuele Di Pascale e11d7c96d7 zebra: label manager refactor
in order to both streamline the code and allow users to
define their own specialized versions of the LM api handlers,
define hooks for the 4 main primitives offered by the label
manager (i.e. connect, disconnect, get_chunk and release_chunk),
and have the existing code be run in response to a hook_call.
Additionally, have the responses to the requesting daemon be
callable from an external API.

Note that the proxy version of the label manager was a source of
issues and hardly used in practice. With the new hooks, users with
more complex requirements can simply plug in their own code to
handle label distribution remotely, so there is no longer a reason
to maintain this code.

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
Emanuele Di Pascale 614a0f8613 zebra: fix label manager EAGAIN error
when receiving an EAGAIN while trying to read the header
of a ZAPI message, we were erroneously continuing as if
everything was fine, which could crash zebra. Fix this
by returning and letting the re-armed read task deal with
this

Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
2019-06-24 11:35:44 +02:00
F. Aragon 98e9ab8b31
zebra: label manager race condition fix
This fix covers the case where two or more events are processed but only one
becoming effective. E.g. when mixing a synchronous label request from a LDP
deamon and an asynchronous request from a BGP daemon it could happen to the
BGP having the label chunk, but the LDP stuck waiting for the response.

Given e.g.

  ldpd     <-------->
  (sync label request)
                       Zebra (label proxy)  <-->  Zebra (shared label manager)
  bgpd     <-------->
  (async label request)

Sequence:

   LDP label request ----->
                               Zebra (label proxy FW) ----> Zebra (LM)
   BGP label request ----->
                               Zebra (label proxy FW) ----> Zebra (LM)
                                                      <---- Zebra (LM) RP LDP
                                                      <---- Zebra (LM) RP BGP

Signed-off-by: F. Aragon <paco@voltanet.io>
2019-04-05 15:39:03 +02:00
Donald Sharp 3801e7646c zebra: Move the master thread handler to the zrouter structure
The master thread handler is really part of the zrouter structure.
So let's move it over to that.  Eventually zserv.h will only be
used for zapi messages.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-01-31 09:20:46 -05:00
Ruben Kerkhof 4d762f2607 Treewide: use ANSI function definitions
Signed-off-by: Ruben Kerkhof <ruben@rubenkerkhof.com>
2019-01-24 11:21:59 +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
David Lamparter 6a154c8812 *: list_delete_and_null() -> list_delete()
Signed-off-by: David Lamparter <equinox@diac24.net>
2018-10-02 11:40:52 +02:00
F. Aragon 61eefcadc7
zebra: filter zebra messages (label manager)
This change makes the zebra acting as label manager proxy not to relay non-LM
messages to clients that a zebra acting in non-proxy mode may send to it. Also,
the existing code does not schedule a rcv in case of relay_response_back
returns -1. This patch re-schedules reads on the socket even in case such a
function returns -1 by calling thread_add_read().

Signed-off-by: F. Aragon <paco@voltanet.io>
2018-09-18 17:39:20 +02:00
paco f533be73f6
bgpd, doc, ldpd, lib, tests, zebra: LM fixes
Corrections so that the BGP daemon can work with the label manager properly
through a label-manager proxy. Details:

- Correction so the BGP daemon behind a proxy label manager gets the range
  correctly (-I added to the BGP daemon, to set the daemon instance id)
- For the BGP case, added an asynchronous label manager connect command so
  the labels get recycled in case of a BGP daemon reconnection. With this,
  BGPd and LDPd would behave similarly.

Signed-off-by: F. Aragon <paco@voltanet.io>
2018-09-18 17:39:16 +02:00
Quentin Young 1c50c1c0d6 *: style for EC replacements
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-13 19:38:57 +00:00
Quentin Young e914ccbe9c zebra: ZEBRA_[ERR|WARN] -> EC_ZEBRA
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-13 19:23:29 +00:00
Quentin Young 9df414feeb zebra: flog_warn conversion
Convert Zebra to user error subsystem.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-06 20:56:38 +00:00
Quentin Young af4c27286d *: rename zlog_fer -> flog_err
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-08-14 20:02:05 +00:00
Quentin Young 43e52561b4 zebra, lib: error references for zebra
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-08-14 20:02:05 +00:00
Donald Sharp 0ce1ca805d *: ALLOC calls cannot fail
There is no need to check for failure of a ALLOC call
as that any failure to do so will result in a assert
happening.  So we can safely remove all of this code.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-08-11 17:14:58 +02:00
Quentin Young c0ea1ae701 zebra: rebase zserv-mt
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-05-29 19:06:43 +00:00
Quentin Young 21ccc0cf24 zebra: refactor zserv names, consolidate events
* Add centralized thread scheduling dispatchers for client threads and
  the main thread

* Rename everything in zserv.c to stop using a combination of:
  - zebra_server_*
  - zebra_*
  - zserv_*

  Everything in zserv.c now begins with zserv_*.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-05-29 19:06:16 +00:00
Fredi Raspall 0313523d77 lib, zebra: fix formatting and style
Signed-off-by: Fredi Raspall <fredi@voltanet.io>
2018-05-08 18:37:05 +02:00
Fredi Raspall 35cbe02a20 zebra, lib: Fix SA warning and formatting.
Signed-off-by: Fredi Raspall <fredi@voltanet.io>
2018-05-01 21:43:18 +02:00
Fredi Raspall 1cbba8cece zebra: Fix label manager proxy mode.
The current implementation did not consider multiple clients to
a label-manager acting as proxy, i.e. relaying messages to another
label manager. Specifically, upon a client's request, it checked
the socket & buffer from the actual label manager for pending
responses and directly copìed them to the client --currently--
being served. As a result, if two clients (e.g. ldpd and bgpd)
sent requests, it could happen that responses being 'on the wire'
from the real label manager towards the proxy, where relayed to
the wrong client. This patch, which requires all msgs to include
a a proto & instance pair, lookups up the zserv client that a
message (response) is to be relayed to.

Signed-off-by: Fredi Raspall <fredi@voltanet.io>
2018-05-01 21:43:18 +02:00
Fredi Raspall 881999e64f zebra: fix broken label manager proxy mode.
In a prior refactor, label manager proxy functionality
was broken in two places:

1) in function relay_response_back(), "dst" stream was
accidentally  replaced by "src".

2) in zread_relay_label_manager_request(), src was set to point
to a global struct stream *ibuf that was not used/initialized
anywhere.

Signed-off-by: Fredi Raspall <fredi@voltanet.io>
2018-04-27 20:10:39 +02:00
Quentin Young d864709552 zebra: cleanup for zapi_msg.c split
* Rename client_connect and client_close hooks to zapi_client_connect
  and zapi_client_close
* Remove some more unnecessary headers
* Fix a copy-paste error in zapi_msg.[ch] header comments
* Fix an inclusion comment in zserv.c

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-04-22 22:50:25 -04:00
Quentin Young 453844abd7 zebra: use hooks for client lifecycle callbacks
zserv.c was using hardcoded callbacks to clean up various components
when a client disconnected. Ergo zserv.c had to know about all these
unrelated components that it should not care about. We have hooks now,
let's use the proper thing instead.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-04-22 22:50:24 -04:00
Philippe Guibert 8288a24fc1 zebra: add the handling of table ids from remote daemons
This commit is connecting the table manager with remote daemons by
handling the queries.
As the function is similar in many points with label allocator, a
function has been renamed.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-03-29 09:19:58 +02:00