Commit eda124ff6f for frr
commit eda124ff6f4b1bec38a0d3e350b56f56c42de3fe
Author: keskydi <antoine.orhant@gmail.com>
Date: Thu Oct 22 12:11:41 2026 +0200
bgpd: open socket on neighbor bind to peer-group with remote-as
When using VRFs, removing the last neighbor of a bgp router closes the
listening socket. Adding it again and associating it to a group does not
reopen the socket breaking connection with the newly inserted peer.
Fix by calling bgp_need_listening() in neighbor_set_peer_group when
peer-group has remote-as configured
Fixes: https://github.com/FRRouting/frr/issues/23691
Signed-off-by: keskydi <antoine.orhant@gmail.com>
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index f42134670a..0103b411a6 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -6295,6 +6295,9 @@ DEFUN (neighbor_set_peer_group,
ret = peer_group_bind(bgp, &su, peer, group, &as);
+ if (ret == 0 && group->conf->as_type != AS_UNSPECIFIED)
+ bgp_need_listening(bgp, vty);
+
return bgp_vty_return(vty, ret);
}
diff --git a/tests/topotests/bgp_listen_l3vrf/test_bgp_listen_l3vrf.py b/tests/topotests/bgp_listen_l3vrf/test_bgp_listen_l3vrf.py
index 7788035d3a..e922641024 100644
--- a/tests/topotests/bgp_listen_l3vrf/test_bgp_listen_l3vrf.py
+++ b/tests/topotests/bgp_listen_l3vrf/test_bgp_listen_l3vrf.py
@@ -303,6 +303,66 @@ def test_add_vrf():
assertmsg = "BGP port related to r1-cust listening when listen range is removed"
assert res is None, assertmsg
+ step("configure neighbor with peer-group in vrf r1-cust")
+
+ r1.vtysh_cmd(
+ """
+ configure terminal
+ router bgp 64600 vrf r1-cust
+ neighbor 192.0.2.3 peer-group rlisten
+ """
+ )
+
+ test_func = functools.partial(check_port_179_open, "r1-cust")
+ _, res = topotest.run_and_expect(test_func, "r1-cust", count=30, wait=1)
+ assertmsg = "BGP port related to r1-cust not listening when a neighbor is set with peer-group"
+ assert res == "r1-cust", assertmsg
+
+ step("remove neighbor with peer-group in vrf r1-cust")
+
+ r1.vtysh_cmd(
+ """
+ configure terminal
+ router bgp 64600 vrf r1-cust
+ no neighbor 192.0.2.3
+ """
+ )
+
+ test_func = functools.partial(check_port_179_open, "r1-cust")
+ _, res = topotest.run_and_expect(test_func, None, count=30, wait=1)
+ assertmsg = "BGP port related to r1-cust listening when neighbor is removed"
+ assert res is None, assertmsg
+
+ step("configure neighbor with peer-group without remote-as in vrf r1-cust")
+
+ r1.vtysh_cmd(
+ """
+ configure terminal
+ router bgp 64600 vrf r1-cust
+ neighbor nopgas peer-group
+ neighbor 192.0.2.3 peer-group nopgas
+ """
+ )
+
+ test_func = functools.partial(check_port_179_open, "r1-cust")
+ _, res = topotest.run_and_expect(test_func, None, count=30, wait=1)
+ assertmsg = (
+ "BGP port related to r1-cust listening when neighbor is bound "
+ "to peer-group without remote-as"
+ )
+ assert res is None, assertmsg
+
+ step("cleanup neighbor and peer-group without remote-as")
+
+ r1.vtysh_cmd(
+ """
+ configure terminal
+ router bgp 64600 vrf r1-cust
+ no neighbor 192.0.2.3
+ no neighbor nopgas peer-group
+ """
+ )
+
step("remove bgp on vrf default")
test_func = functools.partial(check_port_179_open, "default")