summaryrefslogtreecommitdiff
path: root/nhrpd
AgeCommit message (Collapse)Author
2025-04-09Merge pull request #17915 from mjstapp/compile_wshadowDavid Lamparter
2025-04-08nhrpd: clean up -Wshadow compiler warningsMark Stapp
Clean up compiler warnings. Signed-off-by: Mark Stapp <mjs@cisco.com>
2025-04-07nhrpd: Add Hop Count Validation Before Forwarding in nhrp_peer_recv()zmw12306
According to [RFC 2332, Section 5.1], if an NHS receives a packet that it would normally forward and the hop count is zero, it must send an error indication back to the source and drop the packet. Signed-off-by: zmw12306 <zmw12306@gmail.com>
2025-02-11nhrpd: fix dont consider incomplete L2 entryPhilippe Guibert
Sometimes, NHRP receives L2 information on a cache entry with the 0.0.0.0 IP address. NHRP considers it as valid and updates the binding with the new IP address. > Feb 09 20:09:54 aws-sin-vpn01 nhrpd[2695]: [QQ0NK-1H449] Netlink: new-neigh 10.2.114.238 dev dmvpn1 lladdr 162.251.180.10 nud 0x2 cache used 0 type 4 > Feb 09 20:10:35 aws-sin-vpn01 nhrpd[2695]: [QQ0NK-1H449] Netlink: new-neigh 10.2.114.238 dev dmvpn1 lladdr 162.251.180.10 nud 0x4 cache used 1 type 4 > Feb 09 20:10:48 aws-sin-vpn01 nhrpd[2695]: [QQ0NK-1H449] Netlink: del-neigh 10.2.114.238 dev dmvpn1 lladdr 162.251.180.10 nud 0x4 cache used 1 type 4 > Feb 09 20:10:49 aws-sin-vpn01 nhrpd[2695]: [QQ0NK-1H449] Netlink: who-has 10.2.114.238 dev dmvpn1 lladdr (unspec) nud 0x1 cache used 1 type 4 > Feb 09 20:10:49 aws-sin-vpn01 nhrpd[2695]: [QVXNM-NVHEQ] Netlink: update binding for 10.2.114.238 dev dmvpn1 from c 162.251.180.10 peer.vc.nbma 162.251.180.10 to lladdr (unspec) > Feb 09 20:10:49 aws-sin-vpn01 nhrpd[2695]: [QQ0NK-1H449] Netlink: new-neigh 10.2.114.238 dev dmvpn1 lladdr 0.0.0.0 nud 0x2 cache used 1 type 4 > Feb 09 20:11:30 aws-sin-vpn01 nhrpd[2695]: [QQ0NK-1H449] Netlink: new-neigh 10.2.114.238 dev dmvpn1 lladdr 0.0.0.0 nud 0x4 cache used 1 type 4 Actually, the 0.0.0.0 IP addressed mentiones in the 'who-has' message is wrong because the nud state value means that value is incomplete and should not be handled as a valid entry. Instead of considering it, fix this by by invalidating the current binding. This step is necessary in order to permit NHRP to trigger resolution requests again. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2024-11-28Merge pull request #16700 from louis-6wind/fix-nhrp-outputDonatas Abraitis
nhrpd: fix show ip nhrp output
2024-10-29nhrpd: Modify NHRP authentication feature loggingJoshua Muthii
Modified nhrp_connection_authorized(). Initially, when writing debug information about incoming NHRP packets with authentication enabled, the nhrp_connection_authorized() function would print the passphrase of the incoming packet as if it were a null terminated string. This meant that if the passphrase on the incoming packet had non ASCII-complient bytes in it, it would attempt to print those bytes anyway. There was also no check that the size of the passphrase in the incoming packet matched the size of the passphrase on the interface. The changes in this commit log the passphrase on the incoming packet as well as the passphrase on interface in HEX to avoid issues with ASCII. It also performs a check that accounts for the sizes of the two different passphrases Moved CISCO_PASS_LENGTH_LEN from nhrp_vty.c to nhrp_protocol.h for easier access to the macro in other files Signed-off-by: Joshua Muthii <jmuthii@labn.net>
2024-10-17nhrpd: normalize sh ip nhrp opennhrp outputLouis Scalbert
The command outputs too much "\n". Normalize it. Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-10-17nhrpd: fix sh ip nhrp opennhrp json counterLouis Scalbert
"show ip nhrp opennhrp json" counter is incorrect. > root@nhs1:/# vtysh -c 'sh ip nhrp opennhrp json' | jq . > { > "attr": { > "status": "ok", > "entriesCount": 1 <=== NOK > }, > "table": [ > { > "type": "dynamic", > "up": true, > "used": false, > "protocolAddress": "172.16.1.4", > "protocolAddressSize": 32, > "nbmaAddress": "192.168.2.4" > }, > { > "type": "dynamic", > "up": true, > "used": false, > "protocolAddress": "172.16.1.5", > "protocolAddressSize": 32, > "nbmaAddress": "192.168.2.5" > } > ] > } > Fixes: 87b9e98203 ("nhrpd: add json support to show nhrp vty commands") Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-09-24Merge pull request #16788 from LabNConsulting/jmuthii/nhrpd-retry-resolutionJafar Al-Gharaibeh
nhrpd: Implement retrying resolution request
2024-09-17nhrpd: Implement retrying resolution requestJoshua Muthii
In the event that a resolution request is sent and and resolution reply is never received, resolution requests will continue to be sent until either the newly created shortcut has been purged or a resolution reply is finally received. NHRPD_DEFAULT_PURGE_TIME and NHRPD_PURGE_EXPIRE are values that were previously hardcoded and moved into macros for the sake of readability. Signed-off-by: Joshua Muthii <jmuthii@labn.net>
2024-09-12nhrpd: fixes duplicate auth extensionDenys Haryachyy
When an NHRP peer was forwarding a message, it was copying all extensions from the originally received packet. The authentication extension must be regenerated hop by hop per RFC2332. This fix checks for the auth extension when copying extensions and omits the original packet auth and instead regenerates a new auth extension. Fix bug #16507 Signed-off-by: Denys Haryachyy <garyachy@gmail.com>
2024-09-10nhrpd: Added a command "no tunnel protection vici profile PROFILE"aapostoliuk
For compatibility with frr-reload, a command "no tunnel protection [vici profile PROFILE [fallback-profile FALLBACK]]" was added. Signed-off-by: aapostoliuk <a.apostoliuk@vyos.io>
2024-08-30nhrpd: fix show nhrp shortcut jsonLouis Scalbert
Fix show nhrp shortcut json Fixes: 87b9e98203 ("nhrpd: add json support to show nhrp vty commands") Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-08-23nhrpd: fix sending /32 shortcutLouis Scalbert
The remote spoke always sends a 32 prefix length to a shortcut request. In the example, the remote spoke as the IP address 192.168.2.1/24. spoke1# sh ip nhrp shortcut Type Prefix Via Identity dynamic 192.168.2.1/32 10.255.255.2 Do not deal with local routes in nhrpd. Now: spoke1# sh ip nhrp shortcut Type Prefix Via Identity dynamic 192.168.2.0/24 10.255.255.2 Fixes: d4aa24ba7d ("*: Introduce Local Host Routes to FRR") Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-07-26nhrpd: fixes duplicate auth extensionDave LeRoy
When an NHRP server was forwarding a message, it was copying all extensions from the originally received packet. The authentication extension must be regenerated hop by hop per RFC2332. The copied auth extension had an incorrect length. This fix checks for the auth extension when copying extensions and omits the original packet auth and instead regenerates a new auth extension. Fix bug #16466 Signed-off-by: Dave LeRoy <dleroy@labn.net>
2024-07-18nhrpd: Fixes auth no redirect bugDave LeRoy
The nhrp_peer_forward() routine was not explicitly handling the Authentication Extension in the switch statement and instead fell through to the default case which checked whether this was an unhandled Compulsory extension and errored out, never forwarding the Resolution Request. Fix bug #16371 Signed-off-by: Dave LeRoy <dleroy@labn.net>
2024-07-17nhrpd: Fixes auth config change bugDave LeRoy
Freeing auth-token does not set nifp->auth_token to NULL. Explicitly set auth_token to NULL when deleting auth config in order for write config logic to succeed. Fix bug #16359 Signed-off-by: Dave LeRoy <dleroy@labn.net>
2024-06-10nhrpd: add cisco-authentication password supportDave LeRoy
Taking over this development from https://github.com/FRRouting/frr/pull/14788 This commit addresses 4 issues found in the previous PR 1) FRR would accept messages from a spoke without authentication when FRR NHRP had auth configured. 2) The error indication was not being sent in network byte order 3) The debug print in nhrp_connection_authorized was not correctly printing the received password 4) The addresses portion of the mandatory part of the error indication was invalid on the wire (confirmed in wireshark) Signed-off-by: Dave LeRoy <dleroy@labn.net> Co-authored-by: Volodymyr Huti <volodymyr.huti@gmail.com>
2024-06-10nhrp: add `cisco-authentication` password supportVolodymyr Huti
Implemented: - handling 8 char long password, aka Cisco style. - minimal error inidication routine - test case, password change affects conection Signed-off-by: Volodymyr Huti <v.huti@vyos.io>
2024-06-05nhrpd: cleans up shortcut cache entries on terminationDave LeRoy
nhrp_shortcut_terminate() previously was just freeing the associated AFI shortcut RIBs and not addressing existing shortcut cache entries. This cause a use after free issue in vrf_terminate() later in the terminate sequence NHRP: Received signal 7 at 1717516286 (si_addr 0x1955d, PC 0x7098786912c0); aborting... NHRP: zlog_signal+0xf5 709878ad1255 7fff3d992eb0 /usr/lib/frr/libfrr.so.0 (mapped at 0x709878a00000) NHRP: core_handler+0xb5 709878b0db85 7fff3d992ff0 /usr/lib/frr/libfrr.so.0 (mapped at 0x709878a00000) NHRP: __sigaction+0x50 709878642520 7fff3d993140 /lib/x86_64-linux-gnu/libc.so.6 (mapped at 0x709878600000) NHRP: ---- signal ---- NHRP: __lll_lock_wait_private+0x90 7098786912c0 7fff3d9936d8 /lib/x86_64-linux-gnu/libc.so.6 (mapped at 0x709878600000) NHRP: pthread_mutex_lock+0x112 709878698002 7fff3d9936e0 /lib/x86_64-linux-gnu/libc.so.6 (mapped at 0x709878600000) NHRP: _event_add_read_write+0x63 709878b1f423 7fff3d993700 /usr/lib/frr/libfrr.so.0 (mapped at 0x709878a00000) NHRP: zclient_send_message+0xd4 709878b37614 7fff3d993770 /usr/lib/frr/libfrr.so.0 (mapped at 0x709878a00000) NHRP: nhrp_route_announce+0x1ad 5ab34d63d39d 7fff3d993790 /usr/lib/frr/nhrpd (mapped at 0x5ab34d621000) NHRP: nhrp_shortcut_cache_notify+0xd8 5ab34d63e758 7fff3d99d4e0 /usr/lib/frr/nhrpd (mapped at 0x5ab34d621000) NHRP: nhrp_cache_free+0x165 5ab34d632f25 7fff3d99d510 /usr/lib/frr/nhrpd (mapped at 0x5ab34d621000) NHRP: hash_iterate+0x4d 709878ab949d 7fff3d99d540 /usr/lib/frr/libfrr.so.0 (mapped at 0x709878a00000) NHRP: nhrp_cache_interface_del+0x37 5ab34d633eb7 7fff3d99d580 /usr/lib/frr/nhrpd (mapped at 0x5ab34d621000) NHRP: nhrp_if_delete_hook+0x26 5ab34d6350d6 7fff3d99d5a0 /usr/lib/frr/nhrpd (mapped at 0x5ab34d621000) NHRP: if_delete_retain+0x3d 709878abcd1d 7fff3d99d5c0 /usr/lib/frr/libfrr.so.0 (mapped at 0x709878a00000) NHRP: if_delete+0x4c 709878abd87c 7fff3d99d600 /usr/lib/frr/libfrr.so.0 (mapped at 0x709878a00000) NHRP: if_terminate+0x53 709878abda83 7fff3d99d630 /usr/lib/frr/libfrr.so.0 (mapped at 0x709878a00000) NHRP: vrf_terminate_single+0x24 709878b23c74 7fff3d99d670 /usr/lib/frr/libfrr.so.0 (mapped at 0x709878a00000) NHRP: nhrp_request_stop+0x34 5ab34d636844 7fff3d99d690 /usr/lib/frr/nhrpd (mapped at 0x5ab34d621000) NHRP: frr_sigevent_process+0x53 709878b0df53 7fff3d99d6a0 /usr/lib/frr/libfrr.so.0 (mapped at 0x709878a00000) NHRP: event_fetch+0x6c5 709878b20405 7fff3d99d6c0 /usr/lib/frr/libfrr.so.0 (mapped at 0x709878a00000) NHRP: frr_run+0xd3 709878ac8163 7fff3d99d840 /usr/lib/frr/libfrr.so.0 (mapped at 0x709878a00000) NHRP: main+0x195 5ab34d631915 7fff3d99d960 /usr/lib/frr/nhrpd (mapped at 0x5ab34d621000) NHRP: __libc_init_first+0x90 709878629d90 7fff3d99d980 /lib/x86_64-linux-gnu/libc.so.6 (mapped at 0x709878600000) NHRP: __libc_start_main+0x80 709878629e40 7fff3d99da20 /lib/x86_64-linux-gnu/libc.so.6 (mapped at 0x709878600000) NHRP: _start+0x25 5ab34d631b65 7fff3d99da70 /usr/lib/frr/nhrpd (mapped at 0x5ab34d621000) Signed-off-by: Dave LeRoy <dleroy@labn.net>
2024-05-30nhrpd: fixes core dump on shutdowndleroy
When nhrpd is shutdown via nhrp_request_stop() the shutdown sequence was not handling the case where there are active shortcut routes installed. The zebra client and shortcut rib were being cleaned up before vrf_terminate() had an opportunity to delete the active routes. Signed-off-by: dleroy <dleroy@labn.net>
2024-04-23nhrp: replace hard coded retry time with value derived from holdtimeLou Berger
Signed-off-by: Lou Berger <lberger@labn.net>
2024-03-21*: Add missing SPDX-License-Identifier for some .c/.h filesDonatas Abraitis
Adding them as others: GPL-2.0-or-later Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-02-07nhrp: fix race conditionLou Berger
where null lladdr recieved from zebra before nhrp next hop is installed. Signed-off-by: Lou Berger <lberger@labn.net>
2024-02-01*: create a single registry of daemons' default port valuesMark Stapp
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>
2024-01-27*: fix `frr_daemon_info` indentationDavid Lamparter
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>
2024-01-24nhrpd: remove netlink_configure_arp declarationLouis Scalbert
Remove the unused netlink_configure_arp() declaration. Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-01-24nhrpd: unset noarp flag using a zapi messageLouis Scalbert
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>
2024-01-22lib, nhrpd: Move neighbor reg/unreg to lib/zclient.cDonald Sharp
This is needed to be generic. Let's make it so. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-01-22*: Rename ZEBRA_NHRP_NEIGH_XXX to ZEBRA_NEIGH_XXXDonald Sharp
This does not need to be nhrp specific. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-01-09*: zebra.h should not have fcntl.hDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-01-04*: Remove sys/ioctl.h from zebra.hDonald Sharp
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>
2023-12-16nhrpd: Cleanup a hash on nhrp shutdownDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-12-16lib, bgpd, nhrpd: Cleanup memory in lib/resolver on shutdownDonald Sharp
This memory was not being cleaned up on shutdown. Fix this. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-11-22*: convert `struct interface->connected` to DLISTDavid Lamparter
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>
2023-11-07*: Remove netlink headers from lib/zebra.hDonald Sharp
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>
2023-11-02lib: convert if_zapi_callbacks into actual hooksDavid Lamparter
...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>
2023-10-13Merge pull request #14561 from idryzhov/implicit-fallthroughDonald Sharp
build: add -Wimplicit-fallthrough
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-10-12nhrpd: Fix nhrp_peer leakKeelan10
- 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>
2023-07-10nhrpd: clean up locals in route zapi apiMark Stapp
Clean up use of a nexthop pointer - seemed inconsistent. Signed-off-by: Mark Stapp <mjs@labn.net>
2023-04-24nhrpd: Fix nhrpd memory leakKeelan10
Free NHRP peers associated with an interface when NHS is deleted on shutdown Signed-off-by: Keelan Cannoo <keelan.cannoo@icloud.com>
2023-04-04Merge pull request #12837 from donaldsharp/unlikely_routemapRuss White
Unlikely routemap
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*: Convert `struct event_master` to `struct event_loop`Donald Sharp
Let's find a better name for it. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Convert THREAD_XXX macros to EVENT_XXX macrosDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Convert struct thread_master to struct event_master and it's ilkDonald Sharp
Convert the `struct thread_master` to `struct event_master` across the code base. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Convert thread_cancelXXX to event_cancelXXXDonald Sharp
Modify the code base so that thread_cancel becomes event_cancel Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Convert thread_add_XXX functions to event_add_XXXDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Rename `struct thread` to `struct event`Donald Sharp
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>