summaryrefslogtreecommitdiffstats
path: root/zebra/label_manager.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #7756 from pjdruddy/bgplu-fixesDonald Sharp2021-01-091-3/+2
|\ | | | | Bgplu fixes
| * zebra: labelmanager could return reserved labelsPat Ruddy2021-01-041-2/+1
| | | | | | | | | | | | | | | | | | 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>
| * zebra: label manager should never return a reserved blockPat Ruddy2021-01-041-1/+1
| | | | | | | | | | | | | | | | 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>
* | zebra: expose label-manager util-funcsPat Ruddy2021-01-051-15/+8
|/ | | | | | | Revert "zebra: unexpose label-manager util-funcs as static" This reverts commit d3d9639d9a2251aa519b5399706ce816982001a1. Signed-off-by: Pat Ruddy <pat@voltanet.io>
* zebra: unexpose label-manager util-funcs as staticHiroki Shirokura2020-12-101-12/+16
| | | | | | | | | | | | | | | 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>
* zebra: Fix selection of label chunks in label managerGalaxyGorilla2020-08-071-1/+1
| | | | | | | | | | | | | | | | | 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>
* zebra,ldpd: use zapi client session id in LM apisMark Stapp2020-04-161-75/+97
| | | | | | | | 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>
* zebra: minor fix to label manager logEmanuele Di Pascale2020-04-071-0/+9
| | | | | | | | | | | 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>
* *: use the current project name (FRRouting)Lou Berger2020-03-251-1/+1
| | | | Signed-off-by: Lou Berger <lberger@labn.net>
* zebra: Fix label manager memory leakDonald Sharp2020-01-151-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | ==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>
* zebra: Guard debug messagesDonald Sharp2019-07-171-4/+8
| | | | | | | A bunch of debug code has snuck in that is unguarded. Fix this. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* zebra: label manager refactorEmanuele Di Pascale2019-07-101-293/+132
| | | | | | | | | | | | | | | | | | 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>
* lib, zebra: support label chunk requests for SRGBEmanuele Di Pascale2019-07-101-16/+140
| | | | | | | | | | | | | | | | 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>
* zebra: fix label manager EAGAIN errorEmanuele Di Pascale2019-06-241-4/+9
| | | | | | | | | | 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>
* zebra: label manager race condition fixF. Aragon2019-04-051-5/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* zebra: Move the master thread handler to the zrouter structureDonald Sharp2019-01-311-3/+4
| | | | | | | | 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>
* Treewide: use ANSI function definitionsRuben Kerkhof2019-01-241-1/+1
| | | | Signed-off-by: Ruben Kerkhof <ruben@rubenkerkhof.com>
* *: Replace zclient_new with zclient_new_notifyDonald Sharp2018-11-121-1/+1
| | | | | | | 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>
* *: list_delete_and_null() -> list_delete()David Lamparter2018-10-021-1/+1
| | | | Signed-off-by: David Lamparter <equinox@diac24.net>
* zebra: filter zebra messages (label manager)F. Aragon2018-09-181-1/+22
| | | | | | | | | | 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>
* bgpd, doc, ldpd, lib, tests, zebra: LM fixespaco2018-09-181-2/+3
| | | | | | | | | | | | | 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>
* *: style for EC replacementsQuentin Young2018-09-131-14/+14
| | | | Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* zebra: ZEBRA_[ERR|WARN] -> EC_ZEBRAQuentin Young2018-09-131-11/+11
| | | | Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* zebra: flog_warn conversionQuentin Young2018-09-061-4/+3
| | | | | | Convert Zebra to user error subsystem. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* *: rename zlog_fer -> flog_errQuentin Young2018-08-141-10/+10
| | | | Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* zebra, lib: error references for zebraQuentin Young2018-08-141-18/+29
| | | | Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* *: ALLOC calls cannot failDonald Sharp2018-08-111-2/+0
| | | | | | | | 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>
* zebra: rebase zserv-mtQuentin Young2018-05-291-1/+1
| | | | Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* zebra: refactor zserv names, consolidate eventsQuentin Young2018-05-291-1/+1
| | | | | | | | | | | | | | * 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>
* lib, zebra: fix formatting and styleFredi Raspall2018-05-081-15/+16
| | | | Signed-off-by: Fredi Raspall <fredi@voltanet.io>
* zebra, lib: Fix SA warning and formatting.Fredi Raspall2018-05-011-9/+8
| | | | Signed-off-by: Fredi Raspall <fredi@voltanet.io>
* zebra: Fix label manager proxy mode.Fredi Raspall2018-05-011-25/+87
| | | | | | | | | | | | | | | | 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>
* zebra: fix broken label manager proxy mode.Fredi Raspall2018-04-271-6/+3
| | | | | | | | | | | | | | 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>
* zebra: cleanup for zapi_msg.c splitQuentin Young2018-04-231-1/+1
| | | | | | | | | | * 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>
* zebra: use hooks for client lifecycle callbacksQuentin Young2018-04-231-31/+36
| | | | | | | | | 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>
* zebra: add the handling of table ids from remote daemonsPhilippe Guibert2018-03-291-1/+1
| | | | | | | | | 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>
* *: use C99 standard fixed-width integer typesQuentin Young2018-03-271-8/+9
| | | | | | | | | | | | | | | | | | | | | | The following types are nonstandard: - u_char - u_short - u_int - u_long - u_int8_t - u_int16_t - u_int32_t Replace them with the C99 standard types: - uint8_t - unsigned short - unsigned int - unsigned long - uint8_t - uint16_t - uint32_t Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* zebra: reorganize zserv, batch i/oQuentin Young2018-03-121-6/+16
| | | | | | | | Group send and receive functions together, change handlers to take a message instead of looking at ->ibuf and ->obuf, allow zebra to read multiple packets off the wire at a time. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* *: Make code use a consisten definition of labelsDonald Sharp2018-02-091-2/+2
| | | | | | | | | | Turns out we had 3 different ways to define labels all of them overlapping with the same meanings. Consolidate to 1. This one choosen is consistent naming wise with what the *bsd and linux kernels use. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* zebra: use zclient_create_headerDonald Sharp2018-01-221-1/+1
| | | | | | | | The function zserv_create_header was exactly the same as zclient_create_header. Let's just have one in the system. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* ldpd: Add privs to label managerßingen2018-01-051-0/+3
| | | | Signed-off-by: ßingen <bingen@voltanet.io>
* *: Make zapi route install Notifications optionalDonald Sharp2017-11-271-1/+1
| | | | | | | | | | | Allow the higher level protocol to specify if it would like to receive notifications about it's routes that it has installed. I've purposely made it part of zclient_new_notify because we need to track the routes on a per daemon basis only. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* *: Convert list_delete(struct list *) to ** to allow nullingDonald Sharp2017-10-051-1/+1
| | | | | | | | | | | | | | | | | | | Convert the list_delete(struct list *) function to use struct list **. This is to allow the list pointer to be nulled. I keep running into uses of this list_delete function where we forget to set the returned pointer to NULL and attempt to use it and then experience a crash, usually after the developer has long since left the building. Let's make the api explicit in it setting the list pointer to null. Cynical Prediction: This code will expose a attempt to use the NULL'ed list pointer in some obscure bit of code. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* *: remove --enable-tcp-zebra, rework ZAPI pathDavid Lamparter2017-08-081-1/+3
| | | | | | | | | | | | | | | | | | This adds "@tcp" as new choice on the -z option present in zebra and the protocol daemons. The --enable-tcp-zebra option on configure is no longer needed, both UNIX and TCP socket support is always available. Note that @tcp should not be used by default (e.g. in an init script), and --enable-tcp-zebra should never have been in any distro package builds, because **** TCP-ZEBRA IS A SECURITY PROBLEM **** It allows arbitrary local users to mess with the routing table and inject bogus data -- and also ZAPI is not designed to be robust against attacks. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* *: reindentreindent-master-afterwhitespace / reindent2017-07-171-31/+34
| | | | | | indent.py `git ls-files | pcregrep '\.[ch]$' | pcregrep -v '^(ldpd|babeld|nhrpd)/'` Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* zebra: fix label manager merge snafuDavid Lamparter2017-05-181-2/+2
| | | | Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* Merge branch 'stable/3.0'David Lamparter2017-05-181-38/+95
|\ | | | | | | | | | | | | | | Conflicts: ldpd/lde.c zebra/label_manager.c Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
| * lm: Make relay label manager asyncßingen2017-05-111-38/+95
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To avoid blocking zebra when it's acting as a proxy for an external label manager. Besides: Fix get chunk reconnection. Socket was still being destroyed on failure, so next attempt would never work. Filter out unwanted messages in lm sync sock. Until LDE client sends ZEBRA_LABEL_MANAGER_CONNECT message, zserv doesn't know which kind of client it is, so it might enqueue unwanted messages like interface add, interface up, etc. Changes in this commit discard those messages in the client side in case they arrive before the expected response. Change function name for zclient_connect in label manager to avoid confusion with zclient one. Signed-off-by: ßingen <bingen@voltanet.io>
| * Address the error "Dead assignment" of static analysifHung-Weic Chiu2017-05-101-1/+0
| | | | | | | | | | | | | | - Refer to https://ci1.netdef.org/browse/FRR-FRR4-44/artifact/shared/static_analysis/index.html - Remove unused variable Signed-off-by: Hung-Weic Chiu <sppsorrg@gmail.com>
* | *: make consistent & update GPLv2 file headersDavid Lamparter2017-05-151-4/+3
| | | | | | | | | | | | | | | | | | | | | | The FSF's address changed, and we had a mixture of comment styles for the GPL file header. (The style with * at the beginning won out with 580 to 141 in existing files.) Note: I've intentionally left intact other "variations" of the copyright header, e.g. whether it says "Zebra", "Quagga", "FRR", or nothing. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>