summaryrefslogtreecommitdiff
path: root/zebra/zebra_mpls.c
AgeCommit message (Collapse)Author
2020-04-20*: sprintf -> snprintfQuentin Young
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>
2020-03-27zebra,lib: use const in more apisMark Stapp
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-02zebra: add a free api for LSPsMark Stapp
consolidate some LSP cleanup code into a common free function. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-02-27zebra: Embed lib nexthop-group in zebra hash entryMark Stapp
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>
2020-02-13*: Remove break after returnDonatas Abraitis
Just a deadcode. Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2019-12-04Merge pull request #5416 from mjstapp/re_nhe_pointerDonald Sharp
lib,zebra: use shared nexthop-group in route_entry
2019-12-04lib,zebra: use nhg_hash_entry pointer in route_entryMark Stapp
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>
2019-11-29zebra: support LSPs with multiple outgoing labelsRenato Westphal
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>
2019-11-21zebra: clean up rib and nhg headersMark Stapp
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>
2019-11-12zebra: mpls_ftn_uninstall handle nhg hash label changeStephen Worley
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>
2019-10-25zebra: Use ng pointer in mpls_ftn_uninstallStephen Worley
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>
2019-10-25zebra: Zebra nexthop group re-work checkpatch fixesStephen Worley
Checkpatch fixes for the zebra nexthop group re-work. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25zebra: Use nexthop/interface vrf, not the routesStephen Worley
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>
2019-10-25zebra: Create a new NHE if the mpls labels changeStephen Worley
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>
2019-10-25zebra: Replace nexthop_group with pointer in route entryDonald Sharp
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>
2019-09-18zebra: fix mpls ftn uninstallEmanuele Di Pascale
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>
2019-09-13Merge pull request #4949 from opensourcerouting/mpls-zapi-improvementsOlivier Dugeon
MPLS zapi improvements
2019-09-10lib, zebra: add new MPLS zapi message with route replace semanticsRenato Westphal
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-06zebra: improve cleanup of MPLS labels when zclient disconnectsRenato Westphal
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>
2019-09-06zebra: identify MPLS FTNs by route type and instanceRenato Westphal
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-06zebra: add missing case statement in nhlfe2str()Renato Westphal
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-09-06zebra: improve the output of "show mpls table"Renato Westphal
Use the table generator to adjust the columns width according to the table's content. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-05-29zebra: strcat -> strlcatQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-28zebra: generate updates from notificationsMark Stapp
If an async notification changes a route that's current, generate an update to keep the kernel in sync. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-05-28zebra: mpls lsp async notificationsMark Stapp
Add LSP notification event type; add a handler for LSP notifs; dispatch to that handler. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-05-14lib: hashing functions should take const argumentsQuentin Young
It doesn't make much sense for a hash function to modify its argument, so const the hash input. BGP does it in a couple places, those cast away the const. Not great but not any worse than it was. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-07zebra: remove vrf LSPs when vrf is deletedMark Stapp
Try to remove any LSPs associated with a vrf when the vrf is deleted. The vrf code was calling a helpful zebra_mpls api, but that api was basically a no-op for vrfs other than the default. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-02-25*: remove null check before XFREEQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-02-25*: Rename backet to bucketTim Bray
Presume typo from original author Signed-off-by: Tim Bray <tim@kooky.org>
2019-02-13zebra: Deletion of a lsp is not a failure eventDonald Sharp
FRR is reporting that a lsp deletion event as a failure in the log messsages. This will lead to confusion and lots of fun debugging. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-01-31zebra: Remove `struct zebra_t`Donald Sharp
This structure is unused anymore and does not belong in zserv.h Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-01-31zebra: Move lsp_process_q to zrouterDonald Sharp
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
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-22zebra: Fix compile issues introduced by recent commit on newer compilersDonald Sharp
We were using dplane_ctx_get_status(ctx) and assigning that value to zebra_dplane_status, not zebra_dplane_result( yeah what? ) Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-01-22zebra: openbsd LSP update codeMark Stapp
Finish the LSP update code for the async dataplane for the openbsd platform. Remove synch apis now that we've converted to the async code path. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-01-22zebra: remove use of sync LSP update apisMark Stapp
Remove the last use of the pre-dataplane LSP update apis; remove the stubs from the 'null' implementation file. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-01-22zebra: move LSP updates into dataplane subsystemMark Stapp
Start performing LSP updates through the async dataplane subsystem. This is plumbed through for linux/netlink. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-01-22zebra: add apis to add and delete NHLFEsMark Stapp
Add public versions of zebra apis that add NHLFEs to an LSP, and that free NHLFEs. The dataplane code needs to capture/copy NHLFEs in order to do async LSP programming. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2018-12-20bgpd, zebra: auto assign labels from label pool to regular prefixes in BGP ↵Anton Degtyarev
labeled unicast This commit is the last missing piece to complete BGP LU support in bgpd. To this moment, bgpd (and zebra) supported auto label assignment only for prefixes leaked from VRFs to vpn and for MPLS SR prefixes. This adds auto label assignment to other routes types in bgpd. The following enhancements have been made: * bgp_route.c:bgp_process_main_one() now sets implicit-null local_label to all local, aggregate and redistributed routes. * bgp_route.c:bgp_process_main_one() now will request a label from the label pool for any prefix that loses the label for some reason (for example, when the static label assignment config is removed) * bgp_label.c:bgp_reg_dereg_for_label() now requests labels from label pool for routes which have no associated label index * zebra_mpls.c:zebra_mpls_fec_register() now expects both label and label_index from the calling function, one of which must be set to MPLS_INVALID_LABEL or MPLS_INVALID_LABEL_INDEX, based on this it will decide how to register the provided FEC. Signed-off-by: Anton Degtyarev <anton@cumulusnetworks.com>
2018-10-19*: Replace hash_cmp function return value to a boolDonald Sharp
The ->hash_cmp and linked list ->cmp functions were sometimes being used interchangeably and this really is not a good thing. So let's modify the hash_cmp function pointer to return a boolean and convert everything to use the new syntax. 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-19zebra: Create zebra_dplane.c and .hMark Stapp
Add first sketchy 'dplane' files. Signed-off-by: Mark Stapp <mjs@voltanet.io> Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
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-30bgpd/ospfd: make bgp and ospf json response a bit more consistentDon Slice
Problem reported that some bgp and ospf json commands did not return any json output at all if the bgp/ospf instance did not exist. Additionally, some bgp and ospf json commands did not return any json output if the instance existed but no neighbors were defined. This fix makes these commands more consistent in returning empty braces for json output and issue a message if not using json output. Additionally, made the flag "use_json" a bool to make it consistent since previously, it had been defined as an int, char, u_char, and bool at various places. Ticket: CM-21040 Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2018-08-16Merge pull request #2846 from donaldsharp/backet_dataRuss White
Backet data
2018-08-15zebra: Trust backet->dataDonald Sharp
The backet->data cannot be NULL, no need to check for it. Signed-off-by: Donald Sharp <sharpd@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>