Skip to content

Commit

Permalink
Merge pull request #17542 from opensourcerouting/fix/peer-group_remot…
Browse files Browse the repository at this point in the history
…e_as_regression

bgpd: Fix remote-as with peer-group
  • Loading branch information
riw777 authored Dec 3, 2024
2 parents ed4a758 + 6f1ad10 commit e9c9db0
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 1 deletion.
1 change: 1 addition & 0 deletions bgpd/bgpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions tests/topotests/bgp_peer_group/r1/frr.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
!
7 changes: 7 additions & 0 deletions tests/topotests/bgp_peer_group/r4/frr.conf
Original file line number Diff line number Diff line change
@@ -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
!
29 changes: 28 additions & 1 deletion tests/topotests/bgp_peer_group/test_bgp_peer-group.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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__)
Expand Down Expand Up @@ -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)

Expand All @@ -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()

Expand Down

0 comments on commit e9c9db0

Please sign in to comment.