Commit 779e925ede for frr

commit 779e925ede4fa5751ff22ef48da7f28c60161388
Author: Manpreet Kaur <manpreetk@nvidia.com>
Date:   Wed Oct 7 13:16:27 2026 +0530

    bgpd: remove stale peer when deleting interface neighbor

    An accepted BGP connection uses a doppelganger while its handshake is
    in progress. If the interface neighbor is deleted while that connection
    is in OpenConfirm, peer_delete() detaches the doppelganger but leaves its
    socket and FSM running.

    A later KEEPALIVE can move the detached peer to Established even though
    the configured peer no longer exists. Re-adding the neighbor can then
    collide with the surviving connection.

    Delete the doppelganger with the configured peer in both interface-neighbor
    delete paths, matching the existing numbered-neighbor cleanup.

    Signed-off-by: Manpreet Kaur <manpreetk@nvidia.com>

diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index 1f3d5e7c30..4ae929a591 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -5833,8 +5833,13 @@ DEFUN (no_neighbor,
 			 * interface. */
 			if (peer->ifp)
 				bgp_zebra_terminate_radv(peer->bgp, peer);
+			other = peer->doppelganger;
 			peer_notify_unconfig(peer->connection);
 			peer_delete(peer);
+			if (other && other->connection->status != Deleted) {
+				peer_notify_unconfig(other->connection);
+				peer_delete(other);
+			}
 			return CMD_SUCCESS;
 		}

@@ -5903,7 +5908,7 @@ DEFUN (no_neighbor_interface_config,
 {
 	VTY_DECLVAR_CONTEXT(bgp, bgp);
 	int idx_word = 2;
-	struct peer *peer;
+	struct peer *peer, *other;

 	/* look up for neighbor by interface name config. */
 	peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg);
@@ -5911,8 +5916,13 @@ DEFUN (no_neighbor_interface_config,
 		/* Request zebra to terminate IPv6 RAs on this interface. */
 		if (peer->ifp)
 			bgp_zebra_terminate_radv(peer->bgp, peer);
+		other = peer->doppelganger;
 		peer_notify_unconfig(peer->connection);
 		peer_delete(peer);
+		if (other && other->connection->status != Deleted) {
+			peer_notify_unconfig(other->connection);
+			peer_delete(other);
+		}
 	} else {
 		vty_out(vty, "%% Create the bgp interface first\n");
 		return CMD_WARNING_CONFIG_FAILED;