summaryrefslogtreecommitdiffstats
path: root/nhrpd (follow)
Commit message (Collapse)AuthorAgeFilesLines
* nhrp: replace hard coded retry time with value derived from holdtimeLou Berger2024-04-231-3/+9
| | | | Signed-off-by: Lou Berger <lberger@labn.net>
* *: Add missing SPDX-License-Identifier for some .c/.h filesDonatas Abraitis2024-03-214-0/+6
| | | | | | Adding them as others: GPL-2.0-or-later Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
* nhrp: fix race conditionLou Berger2024-02-081-0/+5
| | | | | | | where null lladdr recieved from zebra before nhrp next hop is installed. Signed-off-by: Lou Berger <lberger@labn.net>
* *: create a single registry of daemons' default port valuesMark Stapp2024-02-011-1/+0
| | | | | | | | Create a single registry of default port values that daemons are using. Most of these are vty ports, but there are some others for features like ospfapi and zebra FPM. Signed-off-by: Mark Stapp <mjs@labn.net>
* *: fix `frr_daemon_info` indentationDavid Lamparter2024-01-271-5/+10
| | | | | | | | | | clang-format doesn't understand FRR_DAEMON_INFO is a long macro where laying out items semantically makes sense. (Also use only one `FRR_DAEMON_INFO(` in isisd so editors don't get confused with the mismatching `( ( )`. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* nhrpd: remove netlink_configure_arp declarationLouis Scalbert2024-01-241-1/+0
| | | | | | Remove the unused netlink_configure_arp() declaration. Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
* nhrpd: unset noarp flag using a zapi messageLouis Scalbert2024-01-244-21/+8
| | | | | | | Unset the IFF_NOARP interface flag using a ZAPI message. It removes the dependency to if.h headers. Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
* lib, nhrpd: Move neighbor reg/unreg to lib/zclient.cDonald Sharp2024-01-222-27/+13
| | | | | | This is needed to be generic. Let's make it so. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* *: Rename ZEBRA_NHRP_NEIGH_XXX to ZEBRA_NEIGH_XXXDonald Sharp2024-01-222-12/+12
| | | | | | This does not need to be nhrp specific. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* *: zebra.h should not have fcntl.hDonald Sharp2024-01-092-0/+2
| | | | Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* *: Remove sys/ioctl.h from zebra.hDonald Sharp2024-01-041-0/+1
| | | | | | | Practically no-one uses this and ioctls are pretty much wrappered. Further wrappering could make this even better. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* nhrpd: Cleanup a hash on nhrp shutdownDonald Sharp2023-12-161-0/+1
| | | | Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* lib, bgpd, nhrpd: Cleanup memory in lib/resolver on shutdownDonald Sharp2023-12-161-0/+2
| | | | | | This memory was not being cleaned up on shutdown. Fix this. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* *: convert `struct interface->connected` to DLISTDavid Lamparter2023-11-221-2/+1
| | | | | | | | | | | | | | | | | Replace `struct list *` with `DLIST(if_connected, ...)`. NB: while converting this, I found multiple places using connected prefixes assuming they were IPv4 without checking: - vrrpd/vrrp.c: vrrp_socket() - zebra/irdp_interface.c: irdp_get_prefix(), irdp_if_start(), irdp_advert_off() (these fixes are really hard to split off into separate commits as that would require going back and reapplying the change but with the old list handling) Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* *: Remove netlink headers from lib/zebra.hDonald Sharp2023-11-072-0/+8
| | | | | | | | | | | | The headers associated with netlink code really only belong in those that need it. Move these headers out of lib/zebra.h and into more appropriate places. bgp's usage of the RT_TABLE_XXX defines are probably not appropriate and will be cleaned up in future commits. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* lib: convert if_zapi_callbacks into actual hooksDavid Lamparter2023-11-031-2/+4
| | | | | | | | | ...so that multiple functions can be subscribed. The create/destroy hooks are renamed to real/unreal because that's what they *actually* signal. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* Merge pull request #14561 from idryzhov/implicit-fallthroughDonald Sharp2023-10-132-4/+4
|\ | | | | build: add -Wimplicit-fallthrough
| * build: add -Wimplicit-fallthroughIgor Ryzhov2023-10-122-4/+4
| | | | | | | | | | | | | | | | | | | | 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>
* | nhrpd: Fix nhrp_peer leakKeelan102023-10-123-2/+5
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Addressed memory leak by removing `&c->peer_notifier` from the notifier list on termination. Retaining it caused the notifier list to stay active, preventing the deletion of `c->cur.peer` thereby causing a memory leak. - Reordered termination steps to call `vrf_terminate` before `nhrp_vc_terminate`, preventing a heap-use-after-free issue when `nhrp_vc_notify_del` is invoked in `nhrp_peer_check_delete`. - Added an if statement to avoid passing NULL as hash to `hash_release`, which leads to a SIGSEGV. The ASan leak log for reference: ``` *********************************************************************************** Address Sanitizer Error detected in nhrp_topo.test_nhrp_topo/r1.asan.nhrpd.20265 ================================================================= ==20265==ERROR: LeakSanitizer: detected memory leaks Direct leak of 112 byte(s) in 1 object(s) allocated from: #0 0x7f80270c9b40 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdeb40) #1 0x7f8026ac1eb8 in qmalloc lib/memory.c:100 #2 0x560fd648f0a6 in nhrp_peer_create nhrpd/nhrp_peer.c:175 #3 0x7f8026a88d3f in hash_get lib/hash.c:147 #4 0x560fd6490a5d in nhrp_peer_get nhrpd/nhrp_peer.c:228 #5 0x560fd648a51a in nhrp_nhs_resolve_cb nhrpd/nhrp_nhs.c:297 #6 0x7f80266b000f in resolver_cb_literal lib/resolver.c:234 #7 0x7f8026b62e0e in event_call lib/event.c:1969 #8 0x7f8026aa5437 in frr_run lib/libfrr.c:1213 #9 0x560fd6488b4f in main nhrpd/nhrp_main.c:166 #10 0x7f8025eb2c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) SUMMARY: AddressSanitizer: 112 byte(s) leaked in 1 allocation(s). *********************************************************************************** *********************************************************************************** Address Sanitizer Error detected in nhrp_topo.test_nhrp_topo/r2.asan.nhrpd.20400 ================================================================= ==20400==ERROR: LeakSanitizer: detected memory leaks Direct leak of 112 byte(s) in 1 object(s) allocated from: #0 0x7fb6e3ca5b40 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdeb40) #1 0x7fb6e369deb8 in qmalloc lib/memory.c:100 #2 0x562652de40a6 in nhrp_peer_create nhrpd/nhrp_peer.c:175 #3 0x7fb6e3664d3f in hash_get lib/hash.c:147 #4 0x562652de5a5d in nhrp_peer_get nhrpd/nhrp_peer.c:228 #5 0x562652de1e8e in nhrp_packet_recvraw nhrpd/nhrp_packet.c:325 #6 0x7fb6e373ee0e in event_call lib/event.c:1969 #7 0x7fb6e3681437 in frr_run lib/libfrr.c:1213 #8 0x562652dddb4f in main nhrpd/nhrp_main.c:166 #9 0x7fb6e2a8ec86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) SUMMARY: AddressSanitizer: 112 byte(s) leaked in 1 allocation(s). *********************************************************************************** ``` Signed-off-by: Keelan Cannoo <keelan.cannoo@icloud.com>
* nhrpd: clean up locals in route zapi apiMark Stapp2023-07-101-3/+3
| | | | | | Clean up use of a nexthop pointer - seemed inconsistent. Signed-off-by: Mark Stapp <mjs@labn.net>
* nhrpd: Fix nhrpd memory leakKeelan102023-04-241-0/+1
| | | | | | Free NHRP peers associated with an interface when NHS is deleted on shutdown Signed-off-by: Keelan Cannoo <keelan.cannoo@icloud.com>
* Merge pull request #12837 from donaldsharp/unlikely_routemapRuss White2023-04-041-8/+0
|\ | | | | Unlikely routemap
| * babeld, lib, nhrpd: Add likely and unlikely macrosDonald Sharp2023-03-231-8/+0
| | | | | | | | | | | | | | | | We have 2 competing versions of likely and unlikely in babeld and nhrpd. Standardize onto lower case versions and consolidate in the code. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* | *: Convert event.h to frrevent.hDonald Sharp2023-03-2412-12/+12
| | | | | | | | | | | | | | We should probably prevent any type of namespace collision with something else. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* | *: Convert `struct event_master` to `struct event_loop`Donald Sharp2023-03-242-2/+2
| | | | | | | | | | | | Let's find a better name for it. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* | *: Convert THREAD_XXX macros to EVENT_XXX macrosDonald Sharp2023-03-249-42/+42
| | | | | | | | Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* | *: Convert struct thread_master to struct event_master and it's ilkDonald Sharp2023-03-242-2/+2
| | | | | | | | | | | | | | Convert the `struct thread_master` to `struct event_master` across the code base. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* | *: Convert thread_cancelXXX to event_cancelXXXDonald Sharp2023-03-241-1/+1
| | | | | | | | | | | | Modify the code base so that thread_cancel becomes event_cancel Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* | *: Convert thread_add_XXX functions to event_add_XXXDonald Sharp2023-03-249-84/+83
| | | | | | | | Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* | *: Rename `struct thread` to `struct event`Donald Sharp2023-03-2410-36/+36
| | | | | | | | | | | | | | | | | | Effectively a massive search and replace of `struct thread` to `struct event`. Using the term `thread` gives people the thought that this event system is a pthread when it is not Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* | *: Rename thread.[ch] to event.[ch]Donald Sharp2023-03-2412-12/+12
| | | | | | | | | | | | | | | | | | | | | | 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>
* | *: Add a hash_clean_and_free() functionDonald Sharp2023-03-211-6/+1
|/ | | | | | | | | | 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>
* nhrpd: drop peer references on freeing cache entryDavid Lamparter2023-03-191-0/+2
| | | | | | | | | When dropping an interface (e.g. at shutdown) while there are still valid cache entries, the reference held on the cache entries' peer pointers was leaking. Fixes: #12505 Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* *: auto-convert to SPDX License IDsDavid Lamparter2023-02-0923-133/+23
| | | | | | Done with a combination of regex'ing and banging my head against a wall. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* *: manual SPDX License ID conversionsDavid Lamparter2023-02-091-3/+1
| | | | | | | | | | The files converted in this commit either had some random misspelling or formatting weirdness that made them escape automated replacement, or have a particularly "weird" licensing setup (e.g. dual-licensed.) This also marks a bunch of "public domain" files as SPDX License "NONE". Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* nhrpd: Add missing enum's to switch statementDonald Sharp2023-01-314-16/+37
| | | | Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* build, vtysh: extract vtysh commands from .xrefDavid Lamparter2022-10-261-1/+0
| | | | | | | | | | | | | | | | | | | Rather than running selected source files through the preprocessor and a bunch of perl regex'ing to get the list of all DEFUNs, use the data collected in frr.xref. This not only eliminates issues we've been having with preprocessor failures due to nonexistent header files, but is also much faster. Where extract.pl would take 5s, this now finishes in 0.2s. And since this is a non-parallelizable build step towards the end of the build (dependent on a lot of other things being done already), the speedup is actually noticeable. Also files containing CLI no longer need to be listed in `vtysh_scan` since the .xref data covers everything. `#ifndef VTYSH_EXTRACT_PL` checks are equally obsolete. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* *: Create and use infrastructure to show debugs in libDonald Sharp2022-10-071-0/+2
| | | | | | | | | There are lib debugs being set but never show up in `show debug` commands because there was no way to show that they were being used. Add a bit of infrastructure to allow this and then use it for `debug route-map` Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* nhrpd: Use nhrp_interface_update_nbma when source vrf was changedDmitrii Turlupov2022-08-221-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. Run frr: interface enp0s8 ip address 193.168.1.2/24 exit ! interface gre1 ip address 10.8.1.2/32 ip nhrp network-id 1 ip nhrp nhs dynamic nbma 193.168.1.1 tunnel source enp0s8 exit Log: NHS: Register 10.8.1.2 -> 10.8.1.2 (timeout 2) Send Registration-Request(3) 10.8.1.2 -> 10.8.1.2 Recv Registration-Reply(4) 10.8.1.1 -> 10.8.1.2 2. Create VRF and move enp0s8 to VRF ip link set enp0s8 master vrf1 Before patch: NHS: Waiting link for 193.168.1.1 After patch: NHS: Register 10.8.1.2 -> 10.8.1.2 (timeout 2) Signed-off-by: Dmitrii Turlupov <dturlupov@factor-ts.ru>
* nhrpd: Use frr_weak_random()Donald Sharp2022-08-151-1/+2
| | | | | | Convert usage of rand() to frr_weak_random() Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* *: Replace sockunion2str => %pSUDonatas Abraitis2022-06-214-28/+14
| | | | Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
* nhrpd: r is always < 0 at some points of if else statementsDonald Sharp2022-06-161-3/+3
| | | | | | | Since r is always < 0 at the last if/else there is no point in testing for it. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* *: Properly use memset() when zeroingDonatas Abraitis2022-05-111-1/+1
| | | | | | | Wrong: memset(&a, 0, sizeof(struct ...)); Good: memset(&a, 0, sizeof(a)); Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
* *: remove the checking returned value for hash_get()anlan_cs2022-05-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* build: first header *must* be zebra.h or config.hDavid Lamparter2022-04-041-1/+2
| | | | | | | | This has already been a requirement for Solaris, it is still a requirement for some of the autoconf feature checks to work correctly, and it will be a requirement for `-fms-extensions`. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* *: Change thread->func to return void instead of intDonald Sharp2022-02-249-68/+36
| | | | | | | The int return value is never used. Modify the code base to just return a void instead. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* bgpd,pimd,isisd,nhrpd: Convert to vty_json()Donatas Abraitis2022-01-311-10/+3
| | | | Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
* *: do not print vrf name for interface config when using vrf-liteIgor Ryzhov2022-01-241-2/+2
| | | | | | | VRF name should not be printed in the config since 574445ec. The update was done for NB config output but I missed it for regular vty output. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* *: rework renaming the default VRFIgor Ryzhov2021-12-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, it is possible to rename the default VRF either by passing `-o` option to zebra or by creating a file in `/var/run/netns` and binding it to `/proc/self/ns/net`. In both cases, only zebra knows about the rename and other daemons learn about it only after they connect to zebra. This is a problem, because daemons may read their config before they connect to zebra. To handle this rename after the config is read, we have some special code in every single daemon, which is not very bad but not desirable in my opinion. But things are getting worse when we need to handle this in northbound layer as we have to manually rewrite the config nodes. This approach is already hacky, but still works as every daemon handles its own NB structures. But it is completely incompatible with the central management daemon architecture we are aiming for, as mgmtd doesn't even have a connection with zebra to learn from it. And it shouldn't have it, because operational state changes should never affect configuration. To solve the problem and simplify the code, I propose to expand the `-o` option to all daemons. By using the startup option, we let daemons know about the rename before they read their configs so we don't need any special code to deal with it. There's an easy way to pass the option to all daemons by using `frr_global_options` variable. Unfortunately, the second way of renaming by creating a file in `/var/run/netns` is incompatible with the new mgmtd architecture. Theoretically, we could force daemons to read their configs only after they connect to zebra, but it means adding even more code to handle a very specific use-case. And anyway this won't work for mgmtd as it doesn't have a connection with zebra. So I had to remove this option. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* Merge pull request #9878 from pguibert6WIND/resolver_vrfDonatas Abraitis2021-12-011-2/+2
|\ | | | | lib: resolver per vrf support