Commit 6bcc10c70e for frr

commit 6bcc10c70eb1288be98a1299eb2e6205a04da1ce
Author: Donald Sharp <sharpd@nvidia.com>
Date:   Sat Nov 21 21:37:50 2026 -0500

    nhrpd: Fix uninitialized nbma_addr when deleting NHRP map bindings

    When removing an NHRP map entry in if_no_nhrp_map() or suppressing
    it in interface_config_update_nhrp_map(), an uninitialized
    union sockunion nbma_addr was passed to nhrp_peer_get(), causing
    valgrind conditional jump errors in sockunion_hash() and
    sockunion_same() as a bogus VC and peer were created and immediately
    destroyed.

    This workaround existed because nhrp_cache_update_binding() did not
    check holding_time >= 0 before taking the in-place update branch
    when c->cur.type == type && c->cur.peer == p && c->cur.mtu == mtu.
    For local map entries (where c->cur.peer == NULL), passing
    holding_time = -1 with p = NULL matched that condition and left the
    cache entry untouched.

    Check holding_time >= 0 in nhrp_cache_update_binding() so negative
    holding times always invalidate the binding, and pass NULL directly
    from if_no_nhrp_map() and interface_config_update_nhrp_map() instead
    of calling nhrp_peer_get() with an uninitialized sockunion.

    Signed-off-by: Donald Sharp <sharpd@nvidia.com>

diff --git a/nhrpd/nhrp_cache.c b/nhrpd/nhrp_cache.c
index d71ae0bab6..de8dcef33c 100644
--- a/nhrpd/nhrp_cache.c
+++ b/nhrpd/nhrp_cache.c
@@ -451,7 +451,7 @@ int nhrp_cache_update_binding(struct nhrp_cache *c, enum nhrp_cache_type type,
 		sockunion2str(nbma_oa, buf[1], sizeof(buf[1]));

 	nhrp_cache_reset_new(c);
-	if (c->cur.type == type && c->cur.peer == p && c->cur.mtu == mtu) {
+	if (holding_time >= 0 && c->cur.type == type && c->cur.peer == p && c->cur.mtu == mtu) {
 		c->cur.unique = unique;
 		debugf(NHRP_DEBUG_COMMON,
 		       "cache: same type %u, updating expiry and changing nbma addr from %s to %s",
diff --git a/nhrpd/nhrp_interface.c b/nhrpd/nhrp_interface.c
index 28ebc59f06..06995d5527 100644
--- a/nhrpd/nhrp_interface.c
+++ b/nhrpd/nhrp_interface.c
@@ -409,7 +409,6 @@ static void interface_config_update_nhrp_map(struct nhrp_cache_config *cc,
 	struct map_ctx *ctx = data;
 	struct interface *ifp = cc->ifp;
 	struct nhrp_cache *c;
-	union sockunion nbma_addr;

 	if (sockunion_family(&cc->remote_addr) != ctx->family)
 		return;
@@ -424,11 +423,8 @@ static void interface_config_update_nhrp_map(struct nhrp_cache_config *cc,

 	/* suppress */
 	if (!ctx->enabled) {
-		if (c && c->map) {
-			nhrp_cache_update_binding(
-				c, c->cur.type, -1, 0,
-				nhrp_peer_get(ifp, &nbma_addr), 0, NULL, NULL);
-		}
+		if (c && c->map)
+			nhrp_cache_update_binding(c, c->cur.type, -1, 0, NULL, 0, NULL, NULL);
 		return;
 	}

diff --git a/nhrpd/nhrp_vty.c b/nhrpd/nhrp_vty.c
index 0b407d52d4..2b58d253d3 100644
--- a/nhrpd/nhrp_vty.c
+++ b/nhrpd/nhrp_vty.c
@@ -624,7 +624,7 @@ DEFUN(if_no_nhrp_map, if_no_nhrp_map_cmd,
 {
 	VTY_DECLVAR_CONTEXT(interface, ifp);
 	afi_t afi = cmd_to_afi(argv[1]);
-	union sockunion proto_addr, nbma_addr;
+	union sockunion proto_addr;
 	struct nhrp_cache_config *cc;
 	struct nhrp_cache *c;

@@ -642,9 +642,7 @@ DEFUN(if_no_nhrp_map, if_no_nhrp_map_cmd,
 	if (!c || !c->map)
 		return CMD_SUCCESS;

-	nhrp_cache_update_binding(c, c->cur.type, -1, 0,
-				  nhrp_peer_get(ifp, &nbma_addr), 0, NULL,
-				  NULL);
+	nhrp_cache_update_binding(c, c->cur.type, -1, 0, NULL, 0, NULL, NULL);
 	return CMD_SUCCESS;
 }