summaryrefslogtreecommitdiff
path: root/zebra/zebra_mpls.c
AgeCommit message (Collapse)Author
2024-12-09zebra: Reduce memory usage of streams for encoding packetsDonald Sharp
For those packets that we are not sending 16k of data, but something far less than 256 bytes. Reduce those stream sizes we allocate to something much more reasonable. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-11-22lib, zebra: Do not have duplicate memory type problemsDonald Sharp
In zebra_mpls.c it has a usage of MTYPE_NH_LABEL which is defined in both lib/nexthop.c and zebra/zebra_mpls.c. The usage in zebra_mpls.c is a realloc. This leads to a crash: (gdb) bt 0 __pthread_kill_implementation (no_tid=0, signo=6, threadid=126487246404032) at ./nptl/pthread_kill.c:44 1 __pthread_kill_internal (signo=6, threadid=126487246404032) at ./nptl/pthread_kill.c:78 2 __GI___pthread_kill (threadid=126487246404032, signo=signo@entry=6) at ./nptl/pthread_kill.c:89 3 0x0000730a1b442476 in __GI_raise (sig=6) at ../sysdeps/posix/raise.c:26 4 0x0000730a1b94fb18 in core_handler (signo=6, siginfo=0x7ffeed1e07b0, context=0x7ffeed1e0680) at lib/sigevent.c:268 5 <signal handler called> 6 __pthread_kill_implementation (no_tid=0, signo=6, threadid=126487246404032) at ./nptl/pthread_kill.c:44 7 __pthread_kill_internal (signo=6, threadid=126487246404032) at ./nptl/pthread_kill.c:78 8 __GI___pthread_kill (threadid=126487246404032, signo=signo@entry=6) at ./nptl/pthread_kill.c:89 9 0x0000730a1b442476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26 10 0x0000730a1b4287f3 in __GI_abort () at ./stdlib/abort.c:79 11 0x0000730a1b9984f5 in _zlog_assert_failed (xref=0x730a1ba59480 <_xref.16>, extra=0x0) at lib/zlog.c:789 12 0x0000730a1b8f8908 in mt_count_free (mt=0x576e0edda520 <MTYPE_NH_LABEL>, ptr=0x576e36617b80) at lib/memory.c:74 13 0x0000730a1b8f8a59 in qrealloc (mt=0x576e0edda520 <MTYPE_NH_LABEL>, ptr=0x576e36617b80, size=16) at lib/memory.c:112 14 0x0000576e0ec85e2e in nhlfe_out_label_update (nhlfe=0x576e368895f0, nh_label=0x576e3660e9b0) at zebra/zebra_mpls.c:1462 15 0x0000576e0ec833ff in lsp_install (zvrf=0x576e3655fb50, label=17, rn=0x576e366197c0, re=0x576e3660a590) at zebra/zebra_mpls.c:224 16 0x0000576e0ec87c34 in zebra_mpls_lsp_install (zvrf=0x576e3655fb50, rn=0x576e366197c0, re=0x576e3660a590) at zebra/zebra_mpls.c:2215 17 0x0000576e0ecbb427 in rib_process_update_fib (zvrf=0x576e3655fb50, rn=0x576e366197c0, old=0x576e36619660, new=0x576e3660a590) at zebra/zebra_rib.c:1084 18 0x0000576e0ecbc230 in rib_process (rn=0x576e366197c0) at zebra/zebra_rib.c:1480 19 0x0000576e0ecbee04 in process_subq_route (lnode=0x576e368e0270, qindex=8 '\b') at zebra/zebra_rib.c:2661 20 0x0000576e0ecc0711 in process_subq (subq=0x576e3653fc80, qindex=META_QUEUE_BGP) at zebra/zebra_rib.c:3226 21 0x0000576e0ecc07f9 in meta_queue_process (dummy=0x576e3653fae0, data=0x576e3653fb80) at zebra/zebra_rib.c:3265 22 0x0000730a1b97d2a9 in work_queue_run (thread=0x7ffeed1e3f30) at lib/workqueue.c:282 23 0x0000730a1b96b039 in event_call (thread=0x7ffeed1e3f30) at lib/event.c:1996 24 0x0000730a1b8e4d2d in frr_run (master=0x576e36277e10) at lib/libfrr.c:1232 25 0x0000576e0ec35ca9 in main (argc=7, argv=0x7ffeed1e4208) at zebra/main.c:536 Clearly replacing a label stack is an operation that should be owned by lib/nexthop.c. So lets move this function into there and have zebra_mpls.c just call the function to replace the label stack. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-09-10Merge pull request #15259 from dmytroshytyi-6WIND/nexthop_resolutionRuss White
zebra: add LSP entry to nexthop via recursive (part 2)
2024-09-01*: Create termtable specific temp memoryDonald Sharp
When trying to track down a MTYPE_TMP memory leak it's harder to search for it when you happen to have some usage of ttable_dump. Let's just give it it's own memory type so that we can avoid confusion in the future. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-06-07zebra: return void zebra_mpls_lsp_installDmytro Shytyi
zebra_mpls_lsp_install() returned integer is never checked. Return void instead. Signed-off-by: Dmytro Shytyi <dmytro.shytyi@6wind.com>
2024-06-07zebra: update nhlfe when the outgoing labels differPhilippe Guibert
Because the nhlfe label stack may contain more than one label, ensure to copy all labels. Co-developed-by: Dmytro Shytyi <dmytro.shytyi@6wind.com> Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com> Signed-off-by: Dmytro Shytyi <dmytro.shytyi@6wind.com>
2024-06-07zebra: when adding an LSP, update the log message with multiple labelDmytro Shytyi
When an LSP entry is created from a FEC entry, multiple labels may now be appended to the LSP entry, instead of one single. Upon lsp creation, the LSP trace will display all the labels appended. Signed-off-by: Dmytro Shytyi <dmytro.shytyi@6wind.com>
2024-06-07zebra, lib: upon lsp install, iterate nexthop accordinglyPhilippe Guibert
There are two ways of iterating over nexthops of a given route entry. - Either only the main nexthop are taken into account (which is the case today when attempting to install an LSP entry on a BGP connected labeled route. - Or by taking into account nexthops that are resolved and linked in nexthop->resolved of the previous nexthop which has RECURSIVE flag set. This second case has to be taken into account in the case where recursive routes may be used to install an LSP entry. Introduce a new API in nexthop that will parse over the appropriate nexthop, if the nexthop-resolution flag is turned on or not on the given VRF. Use that API in the lsp_install() function so as to walk over the appropriate nexthops. Co-developed-by: Dmytro Shytyi <dmytro.shytyi@6wind.com> Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com> Signed-off-by: Dmytro Shytyi <dmytro.shytyi@6wind.com>
2024-06-07zebra: handle nexthop-resolution updatesPhilippe Guibert
Upon reconfiguring nexthop-resolution updates, update the lsp entries accordingly. If fec nexthop-resolution becomes true, then call again fec_change_update_lsp() for each fec entry available. If fec nexthop-resolution becomes false, then call again fec_change_update_lsp() for each fec entry available, and if the update fails, uninstall any lsp related with the fec entry. In the case lsp_install() and no lsp entry could be created or updated, then consider this call as a failure, and return -1. Co-developed-by: Dmytro Shytyi <dmytro.shytyi@6wind.com> Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com> Signed-off-by: Dmytro Shytyi <dmytro.shytyi@6wind.com>
2024-06-07zebra: add 'mpls fec nexthop-resolution' command to vtyshDmytro Shytyi
Commands added: r3# configure r3(config)# mpls fec MPLS FEC table label Label configuration ldp Label Distribution Protocol lsp Establish label switched path r3(config)# mpls fec mpls fec nexthop-resolution Authorise nexthop resolution over all labeled routes. r3(config)# mpls fec mpls fec nexthop-resolution r3# configure r3(config)# vrf default r3(config-vrf)# mpls fec MPLS FEC table r3(config-vrf)# mpls fec mpls fec nexthop-resolution Authorise nexthop resolution over all labeled routes. r3(config-vrf)# mpls fec nexthop-resolution east-vm# show running-config Building configuration... ... ! mpls fec nexthop-resolution ! ... Signed-off-by: Dmytro Shytyi <dmytro.shytyi@6wind.com>
2024-05-16zebra: fix mpls commandanlan_cs
Configured with "mpls label bind 1.1.1.1/32 explicit-null", the running configuration is: ``` ! mpls label bind 1.1.1.1/32 IPv4 Explicit Null ! ``` After this commit, the running configuration is: ``` ! mpls label bind 1.1.1.1/32 explicit-null ! ``` And add the support for the "no" form: ``` anlan(config)# mpls label bind 1.1.1.1/32 explicit-null anlan(config)# no mpls label bind 1.1.1.1/32 explicit-null ``` Signed-off-by: anlan_cs <anlan_cs@tom.com>
2024-04-06zebra: fix wrong check for mpls labelanlan_cs
Add a parameter for `zebra_mpls_fec_for_label()`, as before if it is `NULL`, otherwise exclude what this parameter represents. Before: ``` anlan(config)# mpls label bind 1.1.1.2/32 88 anlan(config)# mpls label bind 1.1.1.2/32 88 % Label already bound to a FEC anlan(config)# mpls label bind 1.1.1.3/32 88 % Label already bound to a FEC ``` After: ``` anlan(config)# mpls label bind 1.1.1.2/32 88 anlan(config)# mpls label bind 1.1.1.2/32 88 anlan(config)# mpls label bind 1.1.1.3/32 88 % Label already bound to a FEC ``` Signed-off-by: anlan_cs <anlan_cs@tom.com>
2024-04-05zebra: cosmetic change for one flaganlan_cs
Use `CHECK_FLAG()` for readability. Signed-off-by: anlan_cs <anlan_cs@tom.com>
2024-03-15zebra: changes for code maintainabilitysri-mohan1
these changes are for improving the code maintainability and readability Signed-off-by: sri-mohan1 <sri.mohan@samsung.com>
2023-12-05Merge pull request #12600 from donaldsharp/local_routesRuss White
*: Introduce Local Host Routes to FRR
2023-11-21zebra: Unregister mpls hooks on zebra shutdownDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-11-17zebra: reduce number of switch statements with dplane opcodesMark Stapp
Replace several switch blocks that contain every dplane opcode with simpler sets of if()s. In these cases the code only uses a couple of opcodes. Signed-off-by: Mark Stapp <mjs@labn.net>
2023-11-01*: Introduce Local Host Routes to FRRDonald Sharp
Create Local routes in FRR: S 0.0.0.0/0 [1/0] via 192.168.119.1, enp39s0, weight 1, 00:03:46 K>* 0.0.0.0/0 [0/100] via 192.168.119.1, enp39s0, 00:03:51 O 192.168.119.0/24 [110/100] is directly connected, enp39s0, weight 1, 00:03:46 C>* 192.168.119.0/24 is directly connected, enp39s0, 00:03:51 L>* 192.168.119.224/32 is directly connected, enp39s0, 00:03:51 O 192.168.119.229/32 [110/100] via 0.0.0.0, enp39s0 inactive, weight 1, 00:03:46 C>* 192.168.119.229/32 is directly connected, enp39s0, 00:03:46 Create ability to redistribute local routes. Modify tests to support this change. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-10-12build: add -Wimplicit-fallthroughIgor Ryzhov
Also: - replace all /* fallthrough */ comments with portable fallthrough; pseudo keyword to accomodate both gcc and clang - add missing break; statements as required by older versions of gcc - cleanup some code to remove unnecessary fallthrough Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-07-12zebra: remove unnecessary check for default vrfanlan_cs
The default vrf is generally non-NULL, except when shutdown. So, most of the time it is not necessary to check if it is NULL, we should remove the useless checks for it. Searched them with exact match: ``` grep -rI "zebra_vrf_lookup_by_id(VRF_DEFAULT)" | wc -l 31 ``` Signed-off-by: anlan_cs <vic.lan@pica8.com>
2023-07-05zebra: Add code to get/set interface to pass up from dplaneDonald Sharp
1) Add a bunch of get/set functions and associated data structure in zebra_dplane to allow the setting and retrieval of interface netlink data up into the master pthread. 2) Add a bit of code to breakup startup into stages. This is because FRR currently has a mix of dplane and non dplane interactions and the code needs to be paused before continuing on. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-05-09zebra: mpls nexthop entry displays also interface when availablePhilippe Guibert
The 'show mpls table json' command displays the outgoing interface name only when the nexthop type is either NEXTHOP_TYPE_IFINDEX or NEXTHOP_TYPE_IPV6_IFINDEX. add the interface name for the nexthop type NEXTHOP_TYPE_IPV4_IFINDEX. Fixes: ("b78b820d46d6") MPLS: Display enhancements and JSON support Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-05-09zebra: handle nexthop vrf_id in ZEBRA_MPLS_LABELS messagesPhilippe Guibert
This commit addresses the case where a service wants to install an LSP entry to a next-hop located in a VRF instance. The incoming MPLS packet is on the namespace and has to be directed to a nexthop located behind an interface that sits in a specific VRF instance. The below iproute command can illustrate: > ip link add vrf1 type vrf table 10 > ip link set dev vrf1 up > ip link set dev eth0 master vrf1 > ip a a 192.0.2.1/24 dev eth0 > ip -f mpls route add 105 via inet 192.0.2.45 dev eth0 If a service uses the ZEBRA_MPLS_LABELS messages, then the LSP message is ignored: from zebra perspective, the MPLS entries are visible via the 'show mpls table' command, but no LSP entry is installed in the kernel. The issue is in the nhlfe_nexthop_active_ipv[4/6] function: the outgoing interface mentioned in the nexthop is searched in the main VRF, whereas the interface is in a separate VRF. The interface is not found, and the nhlfe to install is considered not active. To address this issue, reuse the incoming vrf_id parameter transmitted in the nexthop structure from the ZEBRA_MPLS_LABELS message. When creating an NHLFE entry, the vrf_id is used instead of the DEFAULT_VRF. And the nhlfe entry can be considered as active. One alternate solution to reuse the vrf_id parameter in the mpls network context would be to modify the search function in nhlfe_nexthop_active..() function: looking for an existing ifindex in the zns. However, this solution may not fit later when netns backend would be used. Note that some changes have not been done yet and are considered sufficient for now: - The 'nhlfe_find' API: the assumption is done that only the linux vrf backend is used for now. - The 'mpls_lsp_install()' API: It is currently used by the CLI command which does not handle the interface parameter, and the SRTE service, whih always sends LSPs towards a nexthop located in the VRF_DEFAULT. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-05-09zebra: accept LSP entries with an mpls-less outgoing interfacePhilippe Guibert
The ZEBRA_MPLS_LABELS_[ADD/DELETE/REPLACE] messages may change an LSP entry based on an incoming MPLS entry, followed by a given next-hop. Having a next hop with no label information inside is rejected by the zebra layer. As illustration, the following ZAPI message would be rejected, because the next hop does not contain any label information. > ip -f mpls route add 105 via inet 192.0.2.45 At the same time, such configuration is desirable to be supported: An attempt has been done to configure the next-hop with an implicit- null label. But the message is rejected by the kernel: > ip -f mpls route add 104 as 3 via inet 192.0.2.45 > Error: Implicit NULL Label (3) can not be used in encapsulation. The commit proposes to accept ZEBRA_MPLS_LABELS_[XX] messages with a nexthop that does not contain any label information. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-05-03Revert "MPLS allocation mode per next hop"Donatas Abraitis
Broken tests, let's revert now. Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-05-02Merge pull request #12646 from pguibert6WIND/mpls_alloc_per_nhDonatas Abraitis
MPLS allocation mode per next hop
2023-03-28zebra: Use zebra_vrf_lookup_by_id when we canDonald Sharp
Let's make this as consistent as is possible. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Convert event.h to frrevent.hDonald Sharp
We should probably prevent any type of namespace collision with something else. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Rename thread.[ch] to event.[ch]Donald Sharp
This is a first in a series of commits, whose goal is to rename the thread system in FRR to an event system. There is a continual problem where people are confusing `struct thread` with a true pthread. In reality, our entire thread.c is an event system. In this commit rename the thread.[ch] files to event.[ch]. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-22zebra: mpls nexthop entry displays also interface when availablePhilippe Guibert
The 'show mpls table json' command displays the outgoing interface name only when the nexthop type is either NEXTHOP_TYPE_IFINDEX or NEXTHOP_TYPE_IPV6_IFINDEX. add the interface name for the nexthop type NEXTHOP_TYPE_IPV4_IFINDEX. Fixes: ("b78b820d46d6") MPLS: Display enhancements and JSON support Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-03-22zebra: handle nexthop vrf_id in ZEBRA_MPLS_LABELS messagesPhilippe Guibert
This commit addresses the case where a service wants to install an LSP entry to a next-hop located in a VRF instance. The incoming MPLS packet is on the namespace and has to be directed to a nexthop located behind an interface that sits in a specific VRF instance. The below iproute command can illustrate: > ip link add vrf1 type vrf table 10 > ip link set dev vrf1 up > ip link set dev eth0 master vrf1 > ip a a 192.0.2.1/24 dev eth0 > ip -f mpls route add 105 via inet 192.0.2.45 dev eth0 If a service uses the ZEBRA_MPLS_LABELS messages, then the LSP message is ignored: from zebra perspective, the MPLS entries are visible via the 'show mpls table' command, but no LSP entry is installed in the kernel. The issue is in the nhlfe_nexthop_active_ipv[4/6] function: the outgoing interface mentioned in the nexthop is searched in the main VRF, whereas the interface is in a separate VRF. The interface is not found, and the nhlfe to install is considered not active. To address this issue, reuse the incoming vrf_id parameter transmitted in the nexthop structure from the ZEBRA_MPLS_LABELS message. When creating an NHLFE entry, the vrf_id is used instead of the DEFAULT_VRF. And the nhlfe entry can be considered as active. One alternate solution to reuse the vrf_id parameter in the mpls network context would be to modify the search function in nhlfe_nexthop_active..() function: looking for an existing ifindex in the zns. However, this solution may not fit later when netns backend would be used. Note that some changes have not been done yet and are considered sufficient for now: - The 'nhlfe_find' API: the assumption is done that only the linux vrf backend is used for now. - The 'mpls_lsp_install()' API: It is currently used by the CLI command which does not handle the interface parameter, and the SRTE service, whih always sends LSPs towards a nexthop located in the VRF_DEFAULT. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-03-22zebra: accept LSP entries with an mpls-less outgoing interfacePhilippe Guibert
The ZEBRA_MPLS_LABELS_[ADD/DELETE/REPLACE] messages may change an LSP entry based on an incoming MPLS entry, followed by a given next-hop. Having a next hop with no label information inside is rejected by the zebra layer. As illustration, the following ZAPI message would be rejected, because the next hop does not contain any label information. > ip -f mpls route add 105 via inet 192.0.2.45 At the same time, such configuration is desirable to be supported: An attempt has been done to configure the next-hop with an implicit- null label. But the message is rejected by the kernel: > ip -f mpls route add 104 as 3 via inet 192.0.2.45 > Error: Implicit NULL Label (3) can not be used in encapsulation. The commit proposes to accept ZEBRA_MPLS_LABELS_[XX] messages with a nexthop that does not contain any label information. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-03-21*: Add a hash_clean_and_free() functionDonald Sharp
Add a hash_clean_and_free() function as well as convert the code to use it. This function also takes a double pointer to the hash to set it NULL. Also it cleanly does nothing if the pointer is NULL( as a bunch of code tested for ). Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-09zebra: add json support when "show zebra mpls" returns nothingPhilippe Guibert
The "show zebra mpls .. json" vty command may return empty information in case the MPLS database is empty or a given label entry is not available. When those errors occur, add the braces to return a valid json format. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-02-17Merge pull request #12780 from opensourcerouting/spdx-license-idDonald Sharp
*: convert to SPDX License identifiers
2023-02-13lib,zebra,bgpd,staticd: use label code to store VNI infoStephen Worley
Use the already existing mpls label code to store VNI info for vxlan. VNI's are defined as labels just like mpls, we should be using the same code for both. This patch is the first part of that. Next we will need to abstract the label code to not be so mpls specific. Currently in this, we are just treating VXLAN as a label type and storing it that way. Signed-off-by: Stephen Worley <sworley@nvidia.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>
2023-01-31zebra: Add missing enums to switch statementsDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-12-15lib, tests, zebra: Remove unused workqueue error functionDonald Sharp
The wq->spec.errorfunc is never used in the code. It's been in the code base since 2005 and I also do not remember ever seeing it being called. No workqueue process function ever returns error. Since it's not used let's just remove it from the code base. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-08-17zebra: Convert label processing to Meta-QDonald Sharp
Convert label processing that comes from zapi messages into being handled by the meta-Q. This is because early route processing is going to be moved to the meta-Q as well and we will have a chicken and egg problem without moving this code to be processed by the meta-Q. Ordering of messages from ospf as an example: 2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_ROUTE_ADD:0:48] comes from socket [36] 2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_ROUTE_ADD:0:48] comes from socket [36] 2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_ROUTE_ADD:0:48] comes from socket [36] 2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_ROUTE_ADD:0:48] comes from socket [36] 2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_ROUTE_ADD:0:62] comes from socket [36] 2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_ROUTE_ADD:0:43] comes from socket [36] 2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_ROUTE_ADD:0:47] comes from socket [36] 2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_ROUTE_ADD:0:47] comes from socket [36] 2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_ROUTE_ADD:0:47] comes from socket [36] 2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_ROUTE_ADD:0:47] comes from socket [36] 2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_ROUTE_ADD:0:61] comes from socket [36] 2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_ROUTE_ADD:0:47] comes from socket [36] 2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_ROUTE_ADD:0:47] comes from socket [36] 2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_MPLS_LABELS_REPLACE:0:47] comes from socket [36] 2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_MPLS_LABELS_REPLACE:0:66] comes from socket [36] 2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_MPLS_LABELS_REPLACE:0:47] comes from socket [36] 2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_MPLS_LABELS_REPLACE:0:47] comes from socket [36] 2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_MPLS_LABELS_REPLACE:0:47] comes from socket [36] The ZEBRA_MPLS_LABELS_REPLACE immediately turn around and attempt to replace nexthop labels on routes that were added. If the route add is placed on the metaQ, it will not exist yet and as such the label replace will fail. Modify the zebra code to take the label operations and place them on the metaQ as well. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-08-10zebra: Remove unused return codes in zebra_mpls.cDonald Sharp
There are some return codes for functions that are not really used. Clean them up. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-08-08zebra: Notice when an interface is turned on w/ mpls and enable mpls subsystemDonald Sharp
Currently when FRR starts up it queries the kernel to see if mpls is turned on. If not FRR does not enable zebra's mpls subsection. If at a later time mpls is turned on, let's notice that an interface now is enabled for mpls( thus implying that all the bits and bobs in the kernel are now setup properly ). a) convert mpls_enabled to a bool b) abstract a new function zebra_mpls_turned_on and call it when FRR notices that an interface now has mpls enabled. c) mpls_processq_init cannot fail, so actually notice that and don't have special code to detect a failure. New results: sharpd@eva ~> vtysh -c "show zebra" OS Linux(5.10.0-12-amd64) ECMP Maximum 128 v4 Forwarding On v6 Forwarding On MPLS Off EVPN Off Kernel socket buffer size 90000000 VRF l3mdev Available ASIC offload Unavailable RA Compiled in RFC 5549 BGP is not using Kernel NHG Available v4 All LinkDown Routes Off v4 Default LinkDown Routes Off v6 All LinkDown Routes Off v6 Default LinkDown Routes Off v4 All MC Forwarding On v4 Default MC Forwarding Off v6 All MC Forwarding On v6 Default MC Forwarding Off Route Route Neighbor LSP LSP VRF Installs Removals Updates Installs Removals default 26 7 0 0 0 <turn on mpls_iptunnel and mpls_router modules in the kernel and then do this>: sharpd@eva ~> sudo sysctl -w net.mpls.conf.enp39s0.input=1 [sudo] password for sharpd: net.mpls.conf.enp39s0.input = 1 sharpd@eva ~> vtysh -c "show zebra" OS Linux(5.10.0-12-amd64) ECMP Maximum 128 v4 Forwarding On v6 Forwarding On MPLS On EVPN Off Kernel socket buffer size 90000000 VRF l3mdev Available ASIC offload Unavailable RA Compiled in RFC 5549 BGP is not using Kernel NHG Available v4 All LinkDown Routes Off v4 Default LinkDown Routes Off v6 All LinkDown Routes Off v6 Default LinkDown Routes Off v4 All MC Forwarding On v4 Default MC Forwarding Off v6 All MC Forwarding On v6 Default MC Forwarding Off Route Route Neighbor LSP LSP VRF Installs Removals Updates Installs Removals default 26 7 0 0 0 sharpd@eva ~> I am doing this work because FRR keeps having operators not know about how to properly use mpls. Let's make FRR behave a bit better in this weird edge case. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-08-05zebra: zrouter.in_shutdown is an atomic variableDonald Sharp
So let's treat the variable like it is atomic and properly load it when we need to look at it. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-07-26zebra: Fix lost memory on lsp freeDonald Sharp
When cleaning up memory associated with a lsp the nhlfe is lost in some cases. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-07-18zebra: Cleanup the memory from the hash for MPLS stuffDonatas Abraitis
==1595641== 280 (80 direct, 200 indirect) bytes in 1 blocks are definitely lost in loss record 30 of 38 ==1595641== at 0x483AB65: calloc (vg_replace_malloc.c:760) ==1595641== by 0x493C89C: qcalloc (memory.c:116) ==1595641== by 0x1E8426: lsp_alloc (zebra_mpls.c:1116) ==1595641== by 0x49147F1: hash_get (hash.c:162) ==1595641== by 0x1EC880: mpls_lsp_install (zebra_mpls.c:3192) ==1595641== by 0x1C51BB: zread_vrf_label (zapi_msg.c:3197) ==1595641== by 0x1C6F11: zserv_handle_commands (zapi_msg.c:3863) ==1595641== by 0x24D0F4: zserv_process_messages (zserv.c:523) ==1595641== by 0x498F4CC: thread_call (thread.c:2002) ==1595641== by 0x49253A2: frr_run (libfrr.c:1198) ==1595641== by 0x1A28BA: main (main.c:475) ==1595641== ==1595641== 1,400 (400 direct, 1,000 indirect) bytes in 5 blocks are definitely lost in loss record 35 of 38 ==1595641== at 0x483AB65: calloc (vg_replace_malloc.c:760) ==1595641== by 0x493C89C: qcalloc (memory.c:116) ==1595641== by 0x1E8426: lsp_alloc (zebra_mpls.c:1116) ==1595641== by 0x49147F1: hash_get (hash.c:162) ==1595641== by 0x1EBD7C: mpls_zapi_labels_process (zebra_mpls.c:2915) ==1595641== by 0x1C35D9: zread_mpls_labels_add (zapi_msg.c:2513) ==1595641== by 0x1C6F11: zserv_handle_commands (zapi_msg.c:3863) ==1595641== by 0x24D0F4: zserv_process_messages (zserv.c:523) ==1595641== by 0x498F4CC: thread_call (thread.c:2002) ==1595641== by 0x49253A2: frr_run (libfrr.c:1198) ==1595641== by 0x1A28BA: main (main.c:475) Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-06-29zebra: make rib_process_dplane_results own ctx freeingDonald Sharp
The rib_process_dplane_results function was having each sub function handler process the results and then free the ctx. Lot's of functionality that needs to remember to free the context. Let's just free it in the main loop. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-05-11*: Properly use memset() when zeroingDonatas Abraitis
Wrong: memset(&a, 0, sizeof(struct ...)); Good: memset(&a, 0, sizeof(a)); Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-03*: remove the checking returned value for hash_get()anlan_cs
Firstly, *keep no change* for `hash_get()` with NULL `alloc_func`. Only focus on cases with non-NULL `alloc_func` of `hash_get()`. Since `hash_get()` with non-NULL `alloc_func` parameter shall not fail, just ignore the returned value of it. The returned value must not be NULL. So in this case, remove the unnecessary checking NULL or not for the returned value and add `void` in front of it. Importantly, also *keep no change* for the two cases with non-NULL `alloc_func` - 1) Use `assert(<returned_data> == <searching_data>)` to ensure it is a created node, not a found node. Refer to `isis_vertex_queue_insert()` of isisd, there are many examples of this case in isid. 2) Use `<returned_data> != <searching_data>` to judge it is a found node, then free <searching_data>. Refer to `aspath_intern()` of bgpd, there are many examples of this case in bgpd. Here, <returned_data> is the returned value from `hash_get()`, and <searching_data> is the data, which is to be put into hash table. Signed-off-by: anlan_cs <vic.lan@pica8.com>
2021-11-25zebra: Convert vty_out to vty_json for JSONDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-11-18Merge pull request #10092 from ↵Igor Ryzhov
ton31337/feature/replace_json_object_string_add_to_json_object_string_addf_for_inet_ntop *: inet_ntop for JSON output