From e57fb3282a6dce0835bb6d0f2a2f83fa54a35df4 Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Sun, 1 Dec 2024 14:32:08 +0200 Subject: [PATCH 1/2] bgpd: Initialize as_type for peer-group as AS_UNSPECIFIED Previously AS_UNSPECIFIED was treated as 0, but with now it's 1 after renumbering peer_asn_type enum. Fixes: 0dfe25697f5299326046fcfb66f2c6beca7c423c ("bgpd: Implement neighbor X remote-as auto") Signed-off-by: Donatas Abraitis --- bgpd/bgpd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index f92ae969f8c4..9daf8bb11ace 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -2859,6 +2859,7 @@ struct peer_group *peer_group_get(struct bgp *bgp, const char *name) group->conf->host = XSTRDUP(MTYPE_BGP_PEER_HOST, name); group->conf->group = group; group->conf->as = 0; + group->conf->as_type = AS_UNSPECIFIED; group->conf->ttl = BGP_DEFAULT_TTL; group->conf->gtsm_hops = BGP_GTSM_HOPS_DISABLED; group->conf->v_routeadv = BGP_DEFAULT_EBGP_ROUTEADV; From 6f1ad10d904973a8b0aa93fa38b71772c78e203a Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Sun, 1 Dec 2024 14:49:40 +0200 Subject: [PATCH 2/2] tests: Check if remote-as is not flushed once peer-group applied Signed-off-by: Donatas Abraitis --- tests/topotests/bgp_peer_group/r1/frr.conf | 7 +++++ tests/topotests/bgp_peer_group/r4/frr.conf | 7 +++++ .../bgp_peer_group/test_bgp_peer-group.py | 29 ++++++++++++++++++- 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 tests/topotests/bgp_peer_group/r4/frr.conf diff --git a/tests/topotests/bgp_peer_group/r1/frr.conf b/tests/topotests/bgp_peer_group/r1/frr.conf index 035c8e4cf16e..cf9d16c91849 100644 --- a/tests/topotests/bgp_peer_group/r1/frr.conf +++ b/tests/topotests/bgp_peer_group/r1/frr.conf @@ -5,6 +5,9 @@ interface r1-eth0 interface r1-eth1 ip address 192.168.251.1/30 ! +interface r1-eth2 + ip address 192.168.252.1/30 +! ip forwarding ! router bgp 65001 @@ -17,5 +20,9 @@ router bgp 65001 neighbor PG1 remote-as external neighbor PG1 timers 3 20 neighbor PG1 graceful-restart-disable + neighbor PG2 peer-group + neighbor PG2 local-as 65554 no-prepend replace-as neighbor 192.168.251.2 peer-group PG1 + neighbor 192.168.252.2 remote-as 65004 + neighbor 192.168.252.2 peer-group PG2 ! diff --git a/tests/topotests/bgp_peer_group/r4/frr.conf b/tests/topotests/bgp_peer_group/r4/frr.conf new file mode 100644 index 000000000000..b1da90f0644e --- /dev/null +++ b/tests/topotests/bgp_peer_group/r4/frr.conf @@ -0,0 +1,7 @@ +! +interface r4-eth0 + ip address 192.168.252.2/30 +! +router bgp 65004 + neighbor 192.168.252.1 remote-as external +! diff --git a/tests/topotests/bgp_peer_group/test_bgp_peer-group.py b/tests/topotests/bgp_peer_group/test_bgp_peer-group.py index 45f713b8a240..e98d5f8b3b07 100644 --- a/tests/topotests/bgp_peer_group/test_bgp_peer-group.py +++ b/tests/topotests/bgp_peer_group/test_bgp_peer-group.py @@ -30,7 +30,7 @@ def build_topo(tgen): - for routern in range(1, 4): + for routern in range(1, 5): tgen.add_router("r{}".format(routern)) switch = tgen.add_switch("s1") @@ -42,6 +42,10 @@ def build_topo(tgen): switch.add_link(tgen.gears["r1"]) switch.add_link(tgen.gears["r2"]) + switch = tgen.add_switch("s3") + switch.add_link(tgen.gears["r1"]) + switch.add_link(tgen.gears["r4"]) + def setup_module(mod): tgen = Topogen(build_topo, mod.__name__) @@ -84,6 +88,11 @@ def _bgp_peer_group_configured(): "bgpState": "Established", "neighborCapabilities": {"gracefulRestart": "received"}, }, + "192.168.252.2": { + "peerGroup": "PG2", + "bgpState": "Established", + "neighborCapabilities": {"gracefulRestart": "advertisedAndReceived"}, + }, } return topotest.json_cmp(output, expected) @@ -110,6 +119,24 @@ def _bgp_peer_group_check_advertised_routes(): assert result is None, "Failed checking advertised routes from r3" +def test_show_running_remote_as_peer_group(): + tgen = get_topogen() + + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + output = ( + tgen.gears["r1"] + .cmd( + 'vtysh -c "show running bgpd" | grep "^ neighbor 192.168.252.2 remote-as 65004"' + ) + .rstrip() + ) + assert ( + output == " neighbor 192.168.252.2 remote-as 65004" + ), "192.168.252.2 remote-as is flushed" + + def test_bgp_peer_group_remote_as_del_readd(): tgen = get_topogen()