summaryrefslogtreecommitdiffstats
path: root/zebra/zebra_mpls.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* zebra: be more selective about processing LSPsMark Stapp2021-04-051-0/+16
| | | | | | | | | When certain events occur (connected route changes e.g.) zebra examines LSPs to see if they might have been affected. For LSPs with backup nhlfes, skip this immediate processing and wait for the owning protocol daemon to react. Signed-off-by: Mark Stapp <mjs@voltanet.io>
* zebra: kill zebra_memory.h, use MTYPE_STATICDavid Lamparter2021-03-221-1/+0
| | | | | | | This one also needed a bit of shuffling around, but MTYPE_RE is the only one left used across file boundaries now. Signed-off-by: David Lamparter <equinox@diac24.net>
* *: require semicolon after DEFINE_MTYPE & coDavid Lamparter2021-03-171-3/+3
| | | | | | | | | | | | | | | | | Back when I put this together in 2015, ISO C11 was still reasonably new and we couldn't require it just yet. Without ISO C11, there is no "good" way (only bad hacks) to require a semicolon after a macro that ends with a function definition. And if you added one anyway, you'd get "spurious semicolon" warnings on some compilers... With C11, `_Static_assert()` at the end of a macro will make it so that the semicolon is properly required, consumed, and not warned about. Consistently requiring semicolons after "file-level" macros matches Linux kernel coding style and helps some editors against mis-syntax'ing these macros. Signed-off-by: David Lamparter <equinox@diac24.net>
* zebra: Fix prefix2str buf and some invalid data output in zebra_mpls.cDonald Sharp2020-10-261-31/+12
| | | | | | | | | | | | There are several places where prefix2str was used to convert a prefix but they were debug guarded and the buffer was used for flog_err/warn. This would lead to corrupt data being output in the failure cases if debugs were not turned on. Modify the code in zebra_mpls.c to not use prefix2str Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* zebra: replace inet_ntoaMark Stapp2020-10-221-2/+3
| | | | | | Stop using inet_ntoa - use %pI4 or inet_ntop instead Signed-off-by: Mark Stapp <mjs@voltanet.io>
* :* Convert prefix2str to %pFXDonatas Abraitis2020-10-221-23/+16
| | | | Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
* zebra: remove 'static' lsp objectsMark Stapp2020-10-081-253/+120
| | | | | | | | Use the same lsp and nexthop/nhlfe objects for 'static' and dynamic LSPs; remove the 'static' objects and their supporting code. Signed-off-by: Mark Stapp <mjs@voltanet.io>
* zebra: remove "PENDING" dplane request stateJakub Urbańczyk2020-08-101-11/+0
| | | | | | This request state is redundant with new message batching interface. Signed-off-by: Jakub Urbańczyk <xthaid@gmail.com>
* lib, zebra: Add SR-TE policy infrastructure to zebraSebastien Merle2020-08-071-4/+39
| | | | | | | | | | | | | | | | | | | | 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>
* zebra: reset LSP backup nh info on updateMark Stapp2020-08-041-1/+5
| | | | | | | If an existing LSP nh is updated, ensure any backup nh info is also reset. Signed-off-by: Mark Stapp <mjs@voltanet.io>
* Merge pull request #6765 from mjstapp/backup_nhg_netlinkRenato Westphal2020-07-271-11/+58
|\ | | | | lib,zebra: support multiple backup nexthops
| * zebra: improve vty, simplify some primary/backup codeMark Stapp2020-07-201-5/+39
| | | | | | | | | | | | | | | | Improve vty output for routes and lsps with backups, including json. Simplify or correct some code that uses both primary and backup nexthops in dplane, nht. Signed-off-by: Mark Stapp <mjs@voltanet.io>
| * lib,sharpd,zebra: initial support for multiple backup nexthopsMark Stapp2020-07-171-6/+16
| | | | | | | | | | | | | | | | | | | | 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>
| * zebra: include installed backup nexthops in kernel updateMark Stapp2020-07-161-0/+3
| | | | | | | | | | | | | | | | | | | | | | Include any installed backups when updating the local kernel after processing an async notification. This includes routes' nexthops and LSPs' nhlfes. Add the 'b' character to the route show display and header to indicate backup nexthops. Signed-off-by: Mark Stapp <mjs@voltanet.io>
* | Merge pull request #6753 from mjstapp/fix_zebra_backup_saStephen Worley2020-07-171-5/+6
|\ \ | | | | | | zebra: fix SA warnings in backup nexthop code
| * | zebra: fix SA warnings in backup nexthop codeMark Stapp2020-07-161-5/+6
| |/ | | | | | | | | | | | | Fix a couple of recent SA warnings that came from backup nexthop/nhlfe changes. Signed-off-by: Mark Stapp <mjs@voltanet.io>
* / *: un-split strings across linesDavid Lamparter2020-07-141-8/+4
|/ | | | | | | | | | | | | | | | | 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>
* zebra: clean up the code flow in lsp results processingMark Stapp2020-07-071-14/+27
| | | | | | | | Clean up some awkward code in a couple of places where we're processing lsp results from the dataplane. Also add some more debugs in those paths. Signed-off-by: Mark Stapp <mjs@voltanet.io>
* zebra: include backup lsp nhlfes in 'active' checkMark Stapp2020-07-071-4/+15
| | | | | | | | Check backup nhlfes/nexthops for 'active' status when checking an LSP. Also tweak the show command output for backup nhlfes slightly. Signed-off-by: Mark Stapp <mjs@voltanet.io>
* zebra: collapse some duplicate LSP nhlfe apisMark Stapp2020-07-071-194/+61
| | | | | | | | | Collapse some apis where primary and backup nhlfe code was very similar, generally using a single common api and using a bool to distinguish between primary and backup. Signed-off-by: Mark Stapp <mjs@voltanet.io>
* zebra: support backup nhlfes in lsp async notificationsMark Stapp2020-07-071-56/+131
| | | | | | | Include backup nhlfes and nexthops in LSP async notification processing from the dataplane. Signed-off-by: Mark Stapp <mjs@voltanet.io>
* zebra: add const to mpls and dplane nhlfe apisMark Stapp2020-07-071-2/+2
| | | | | | | Add const to an arg to a couple of the dplane and mpls module apis that add nhlfes to LSPs. Signed-off-by: Mark Stapp <mjs@voltanet.io>
* zebra: check LSP flags when deleting an LSPMark Stapp2020-07-051-3/+18
| | | | | | | | | Check the LSP INSTALLED flag in delete apis, to ensure we enqueue a delete operation for the lfib. Some apis were only checking the nexthop/nhlfe INSTALLED flags, and those could be unset if there's an in-flight dataplane update. Signed-off-by: Mark Stapp <mjs@voltanet.io>
* zebra: prepare data plane for batchingJakub Urbańczyk2020-06-261-0/+11
| | | | | | | * Add new zebra_dplane_result to allow kernel updates not to return a result immediately. Signed-off-by: Jakub Urbańczyk <xthaid@gmail.com>
* zebra: fix coverity SA warningsMark Stapp2020-06-101-1/+2
| | | | | | Fix a few coverity warnings. Signed-off-by: Mark Stapp <mjs@voltanet.io>
* zebra: nhlfe_alloc should not failDonald Sharp2020-06-051-10/+3
| | | | | | | | | | | | | | | Let's prevent nhlfe_alloc from actually returning anything that can fail: 1) nexthop_new -> never returns NULL so checking for NULL here makes no sense, remove it. 2) lsp not being NULL is a assert condition here as that it's a precondition for the function to work properly. 3) since nhlfe_alloc cannot return NULL now remove tests for it in callng functions Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* zebra: backup LSP zapi processingMark Stapp2020-06-011-129/+372
| | | | | | | | Move some processing of zapi label messages so they can be handled more efficiently. Handle zapi delete and replace messages. Signed-off-by: Mark Stapp <mjs@voltanet.io>
* zebra: add check_free apiMark Stapp2020-06-011-11/+37
| | | | | | | | Add a 'check' api to hold the code that determines whether an LSP can be freed or not. Replace calls to the free api with check calls. Signed-off-by: Mark Stapp <mjs@voltanet.io>
* zebra: show backup nhlfes with dynamic LSPsMark Stapp2020-06-011-10/+29
| | | | | | | Include backup nhlfe info with the show output of dynamic LSPs (no json yet). Signed-off-by: Mark Stapp <mjs@voltanet.io>
* zebra: support backup nhlfes in LSPsMark Stapp2020-06-011-63/+349
| | | | | | | Handle backup nhlfes in LSP zapi messages. Capture backup info with LSPs, capture backup info in the dataplane LSP processing. Signed-off-by: Mark Stapp <mjs@voltanet.io>
* zebra: convert LSP nhlfe lists to use typesafe listsMark Stapp2020-06-011-92/+99
| | | | | | | Convert the embedded lists of nhlfes and snhlfes in zebra LSPs and SLSPs to use typesafe dlists. Signed-off-by: Mark Stapp <mjs@voltanet.io>
* *: sprintf -> snprintfQuentin Young2020-04-211-1/+2
| | | | | | | | | | | | | Replace sprintf with snprintf where straightforward to do so. - sprintf's into local scope buffers of known size are replaced with the equivalent snprintf call - snprintf's into local scope buffers of known size that use the buffer size expression now use sizeof(buffer) - sprintf(buf + strlen(buf), ...) replaced with snprintf() into temp buffer followed by strlcat Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* zebra,lib: use const in more apisMark Stapp2020-03-271-27/+29
| | | | | | | | 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>
* zebra: add a free api for LSPsMark Stapp2020-03-021-39/+43
| | | | | | consolidate some LSP cleanup code into a common free function. Signed-off-by: Mark Stapp <mjs@voltanet.io>
* zebra: Embed lib nexthop-group in zebra hash entryMark Stapp2020-02-271-7/+7
| | | | | | | Embed nexthop-group, which is just a pointer, in the zebra nexthop-hash-entry object, rather than mallocing one. Signed-off-by: Mark Stapp <mjs@voltanet.io>
* *: Remove break after returnDonatas Abraitis2020-02-131-1/+0
| | | | | | Just a deadcode. Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
* Merge pull request #5416 from mjstapp/re_nhe_pointerDonald Sharp2019-12-041-8/+9
|\ | | | | lib,zebra: use shared nexthop-group in route_entry
| * lib,zebra: use nhg_hash_entry pointer in route_entryMark Stapp2019-12-041-7/+8
| | | | | | | | | | | | | | | | | | Replace the existing list of nexthops (via a nexthop_group struct) in the route_entry with a direct pointer to zebra's new shared group (from zebra_nhg.h). This allows more direct access to that shared group and the info it carries. Signed-off-by: Mark Stapp <mjs@voltanet.io>
| * zebra: clean up rib and nhg headersMark Stapp2019-11-211-1/+1
| | | | | | | | | | | | | | | | Clean up the relationships between zebra's rib and nexthop-group headers as prep for adding a nexthop-group pointer to the route_entry. Signed-off-by: Mark Stapp <mjs@voltanet.io>
* | zebra: support LSPs with multiple outgoing labelsRenato Westphal2019-11-291-20/+48
|/ | | | | | | | | For SR-TE we'll need to create Binding-SIDs which are essentially LSPs that can push multiple outgoing labels. This commit sets the groundwork for that. Luckily the netlink code didn't need to be changed since it already supports pushing label stacks. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* zebra: mpls_ftn_uninstall handle nhg hash label changeStephen Worley2019-11-121-14/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We were crashing due to a missed label change code path in mpls_ftn_uninstall() with the zebra_nhg hashing code. Add a static handler function for label changing everywhere in that code and use it in mpls_ftn_uninstall(). The crash was found in the ISIS-SR tests: ==23== Thread 1: ==23== Invalid read of size 4 ==23== at 0x15B20E: zebra_nhg_hash_equal (zebra_nhg.c:365) ==23== by 0x489A2FD: hash_get (hash.c:143) ==23== by 0x489A4BC: hash_lookup (hash.c:183) ==23== by 0x15B5A3: zebra_nhg_find (zebra_nhg.c:494) ==23== by 0x15C536: zebra_nhg_rib_find (zebra_nhg.c:1070) ==23== by 0x1573E8: mpls_ftn_update (zebra_mpls.c:2661) ==23== by 0x1A2554: zread_mpls_labels_replace (zapi_msg.c:1890) ==23== by 0x1A41CD: zserv_handle_commands (zapi_msg.c:2613) ==23== by 0x199B17: zserv_process_messages (zserv.c:517) ==23== by 0x48EE6B7: thread_call (thread.c:1549) ==23== by 0x48A8AD5: frr_run (libfrr.c:1064) ==23== by 0x1391B7: main (main.c:468) ==23== Address 0x5839330 is 0 bytes inside a block of size 80 free'd ==23== at 0x48369AB: free (vg_replace_malloc.c:530) ==23== by 0x48AEE6C: qfree (memory.c:129) ==23== by 0x15C5F8: zebra_nhg_free (zebra_nhg.c:1095) ==23== by 0x15BC8C: zebra_nhg_handle_uninstall (zebra_nhg.c:734) ==23== by 0x15DCFA: zebra_nhg_uninstall_kernel (zebra_nhg.c:1826) ==23== by 0x15C666: zebra_nhg_decrement_ref (zebra_nhg.c:1106) ==23== by 0x15D9D7: zebra_nhg_re_update_ref (zebra_nhg.c:1711) ==23== by 0x15D8B1: nexthop_active_update (zebra_nhg.c:1660) ==23== by 0x167072: rib_process (zebra_rib.c:1154) ==23== by 0x168D72: process_subq_route (zebra_rib.c:2039) ==23== by 0x168E92: process_subq (zebra_rib.c:2078) ==23== by 0x168F5B: meta_queue_process (zebra_rib.c:2112) ==23== Block was alloc'd at ==23== at 0x4837B65: calloc (vg_replace_malloc.c:752) ==23== by 0x48AED56: qcalloc (memory.c:110) ==23== by 0x15B07B: zebra_nhg_copy (zebra_nhg.c:307) ==23== by 0x15B13E: zebra_nhg_hash_alloc (zebra_nhg.c:329) ==23== by 0x489A339: hash_get (hash.c:148) ==23== by 0x15B6CA: zebra_nhg_find (zebra_nhg.c:532) ==23== by 0x15C536: zebra_nhg_rib_find (zebra_nhg.c:1070) ==23== by 0x15D89A: nexthop_active_update (zebra_nhg.c:1658) ==23== by 0x167072: rib_process (zebra_rib.c:1154) ==23== by 0x168D72: process_subq_route (zebra_rib.c:2039) ==23== by 0x168E92: process_subq (zebra_rib.c:2078) ==23== by 0x168F5B: meta_queue_process (zebra_rib.c:2112) Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
* zebra: Use ng pointer in mpls_ftn_uninstallStephen Worley2019-10-251-1/+1
| | | | | | | | With the new nexthop group shared memory framework, pointers are being used in route_entry for the nexthop_group. Update the use of this in `mpls_ftn_uninstall()` to reflect the change. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
* zebra: Zebra nexthop group re-work checkpatch fixesStephen Worley2019-10-251-1/+1
| | | | | | Checkpatch fixes for the zebra nexthop group re-work. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
* zebra: Use nexthop/interface vrf, not the routesStephen Worley2019-10-251-3/+2
| | | | | | | | When hashing/creating the NHE, use the nexthops vrf as its source of data. This is gotten directly from an interface and should not come from a route. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
* zebra: Create a new NHE if the mpls labels changeStephen Worley2019-10-251-12/+40
| | | | | | | | We should create a new NHE if the mpls labels change since we hash on them. This adds the functonality to do that and decrement the refcnt on the old one. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
* zebra: Replace nexthop_group with pointer in route entryDonald Sharp2019-10-251-6/+6
| | | | | | | | In the route_entry we are keeping a non pointer based nexthop group, switch the code to use a pointer for all operations here and ensure we create and delete the memory. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* zebra: fix mpls ftn uninstallEmanuele Di Pascale2019-09-181-2/+4
| | | | | | | | | | | | when a client disconnects, we iterate over the routing table to remove any label that originated from that client. However we were erroneously passing the route type to the function, while it was expecting the lsp type. As a result, for example, killing ldpd would not remove the ldp labels from the routes. Kudos to @rwestphal for pointing me to the source of the issue. Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
* Merge pull request #4949 from opensourcerouting/mpls-zapi-improvementsOlivier Dugeon2019-09-131-10/+108
|\ | | | | MPLS zapi improvements
| * lib, zebra: add new MPLS zapi message with route replace semanticsRenato Westphal2019-09-101-0/+57
| | | | | | | | | | | | | | 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>
| * zebra: improve cleanup of MPLS labels when zclient disconnectsRenato Westphal2019-09-071-7/+48
| | | | | | | | | | | | | | | | | | Use the zserv_client_close hook to cleanup all MPLS labels advertised by a zclient when it disconnects. We were doing this cleanup for ldpd only, but now we have other daemons that are MPLS aware, like ospfd (due to the new Segment Routing feature). Signed-off-by: Renato Westphal <renato@opensourcerouting.org>