summaryrefslogtreecommitdiff
path: root/zebra/label_manager.c
AgeCommit message (Collapse)Author
2023-12-11zebra: Cleanup linked list on shutdown in label managerDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-10-18zebra: do not accept static label requests conflicting with dynamic-blockPhilippe Guibert
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-18zebra: dump the dynamic-block bounds on vty commandPhilippe Guibert
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-18zebra: add json support to 'show debugging label-table'Philippe Guibert
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-18zebra: add label chunk allocation in the dynamic block rangePhilippe Guibert
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-18zebra: rework dynamic label request algorithmPhilippe Guibert
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-18zebra: add 'mpls label dynamic-block' commandPhilippe Guibert
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-18zebra: fix label allocation when room space before first chunkPhilippe Guibert
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: 3c8449794318 ("zebra: label manager should never return a reserved block") Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-10-18zebra, test: mark mpls label chunks as dynamic or staticPhilippe Guibert
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-13zebra: add label chunk range in log when label manager request failsPhilippe Guibert
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-13zebra: merge lm_get_chunk_response() functionPhilippe Guibert
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-09-29zebra: delete label chunk upon releasefmihoub6WIND
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-29zebra: dump label table informationfmihoub6WIND
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-02-09*: auto-convert to SPDX License IDsDavid Lamparter
Done with a combination of regex'ing and banging my head against a wall. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-01-09Merge pull request #7756 from pjdruddy/bgplu-fixesDonald Sharp
Bgplu fixes
2021-01-05zebra: expose label-manager util-funcsPat Ruddy
Revert "zebra: unexpose label-manager util-funcs as static" This reverts commit d3d9639d9a2251aa519b5399706ce816982001a1. Signed-off-by: Pat Ruddy <pat@voltanet.io>
2021-01-04zebra: labelmanager could return reserved labelsPat Ruddy
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-04zebra: label manager should never return a reserved blockPat Ruddy
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>
2020-12-10zebra: unexpose label-manager util-funcs as staticHiroki Shirokura
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-08-07zebra: Fix selection of label chunks in label managerGalaxyGorilla
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-04-16zebra,ldpd: use zapi client session id in LM apisMark Stapp
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-07zebra: minor fix to label manager logEmanuele Di Pascale
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-03-25*: use the current project name (FRRouting)Lou Berger
Signed-off-by: Lou Berger <lberger@labn.net>
2020-01-15zebra: Fix label manager memory leakDonald Sharp
==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>
2019-07-16zebra: Guard debug messagesDonald Sharp
A bunch of debug code has snuck in that is unguarded. Fix this. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-07-10zebra: label manager refactorEmanuele Di Pascale
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-10lib, zebra: support label chunk requests for SRGBEmanuele Di Pascale
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-06-24zebra: fix label manager EAGAIN errorEmanuele Di Pascale
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-04-05zebra: label manager race condition fixF. Aragon
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-01-31zebra: Move the master thread handler to the zrouter structureDonald Sharp
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-24Treewide: use ANSI function definitionsRuben Kerkhof
Signed-off-by: Ruben Kerkhof <ruben@rubenkerkhof.com>
2018-11-12*: Replace zclient_new with zclient_new_notifyDonald Sharp
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-10-02*: list_delete_and_null() -> list_delete()David Lamparter
Signed-off-by: David Lamparter <equinox@diac24.net>
2018-09-18zebra: filter zebra messages (label manager)F. Aragon
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-18bgpd, doc, ldpd, lib, tests, zebra: LM fixespaco
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-13*: style for EC replacementsQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-13zebra: ZEBRA_[ERR|WARN] -> EC_ZEBRAQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-06zebra: flog_warn conversionQuentin Young
Convert Zebra to user error subsystem. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-08-14*: rename zlog_fer -> flog_errQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-08-14zebra, lib: error references for zebraQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-08-11*: ALLOC calls cannot failDonald Sharp
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-05-29zebra: rebase zserv-mtQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-05-29zebra: refactor zserv names, consolidate eventsQuentin Young
* 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-08lib, zebra: fix formatting and styleFredi Raspall
Signed-off-by: Fredi Raspall <fredi@voltanet.io>
2018-05-01zebra, lib: Fix SA warning and formatting.Fredi Raspall
Signed-off-by: Fredi Raspall <fredi@voltanet.io>
2018-05-01zebra: Fix label manager proxy mode.Fredi Raspall
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-04-27zebra: fix broken label manager proxy mode.Fredi Raspall
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-22zebra: cleanup for zapi_msg.c splitQuentin Young
* 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-22zebra: use hooks for client lifecycle callbacksQuentin Young
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-03-29zebra: add the handling of table ids from remote daemonsPhilippe Guibert
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>