Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bgpd/bgp_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -1989,6 +1989,7 @@ static int bgp_open_receive(struct peer_connection *connection,
SET_FLAG(peer->as_type, AS_EXTERNAL);
UNSET_FLAG(peer->as_type, AS_INTERNAL);
}
(void)peer_sort(peer);
} else if (peer->as_type == AS_INTERNAL) {
if (remote_as != peer->bgp->as) {
if (bgp_debug_neighbor_events(peer))
Expand Down
10 changes: 9 additions & 1 deletion bgpd/bgpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1108,8 +1108,16 @@ static inline enum bgp_peer_sort peer_calc_sort(struct peer *peer)
assert(peer->group);
peer1 = listnode_head(peer->group->peer);

if (peer1)
if (peer1) {
/* AS_AUTO without INTERNAL/EXTERNAL bits means
* the type is not yet resolved (no session up).
* Treat as unestablished so it doesn't block
* other members from being configured.
*/
if (peer1->as_type == AS_AUTO)
return BGP_PEER_INTERNAL;
return peer1->sort;
}
}
return BGP_PEER_INTERNAL;
}
Expand Down
3 changes: 3 additions & 0 deletions tests/topotests/bgp_remote_as_auto/r1/frr.conf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ router bgp 65001
neighbor r1-eth1 interface remote-as auto
neighbor r1-eth1 timers 1 3
neighbor r1-eth1 timers connect 1
neighbor 192.168.1.5 remote-as internal
neighbor 192.168.1.5 timers 1 3
neighbor 192.168.1.5 timers connect 1
address-family ipv4 unicast
network 10.0.0.1/32
exit-address-family
Expand Down
3 changes: 3 additions & 0 deletions tests/topotests/bgp_remote_as_auto/r2/frr.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ router bgp 65001
neighbor 192.168.1.1 remote-as auto
neighbor 192.168.1.1 timers 1 3
neighbor 192.168.1.1 timers connect 1
neighbor 192.168.1.5 remote-as internal
neighbor 192.168.1.5 timers 1 3
neighbor 192.168.1.5 timers connect 1
!
3 changes: 3 additions & 0 deletions tests/topotests/bgp_remote_as_auto/r3/frr.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ router bgp 65003
neighbor 192.168.1.1 remote-as auto
neighbor 192.168.1.1 timers 1 3
neighbor 192.168.1.1 timers connect 1
neighbor 192.168.1.5 remote-as external
neighbor 192.168.1.5 timers 1 3
neighbor 192.168.1.5 timers connect 1
!
20 changes: 20 additions & 0 deletions tests/topotests/bgp_remote_as_auto/r5/frr.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
!
int r5-eth0
ip address 192.168.1.5/24
!
router bgp 65001
no bgp ebgp-requires-policy
neighbor PG peer-group
neighbor 192.168.1.1 peer-group PG
neighbor 192.168.1.1 remote-as auto
neighbor 192.168.1.1 timers 1 3
neighbor 192.168.1.1 timers connect 1
neighbor 192.168.1.2 peer-group PG
neighbor 192.168.1.2 remote-as internal
neighbor 192.168.1.2 timers 1 3
neighbor 192.168.1.2 timers connect 1
neighbor 192.168.1.3 peer-group PG
neighbor 192.168.1.3 remote-as external
neighbor 192.168.1.3 timers 1 3
neighbor 192.168.1.3 timers connect 1
!
37 changes: 36 additions & 1 deletion tests/topotests/bgp_remote_as_auto/test_bgp_remote_as_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@


def setup_module(mod):
topodef = {"s1": ("r1", "r2", "r3"), "s2": ("r1", "r4")}
topodef = {"s1": ("r1", "r2", "r3", "r5"), "s2": ("r1", "r4")}
tgen = Topogen(topodef, mod.__name__)
tgen.start_topology()

Expand All @@ -50,6 +50,7 @@ def test_bgp_remote_as_auto():
r2 = tgen.gears["r2"]
r3 = tgen.gears["r3"]
r4 = tgen.gears["r4"]
r5 = tgen.gears["r5"]

def _bgp_converge():
output = json.loads(r1.vtysh_cmd("show bgp ipv4 unicast summary json"))
Expand Down Expand Up @@ -155,6 +156,40 @@ def _bgp_converge_external_unnumbered():
_, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
assert result is None, "Can't see automatic unnumbered eBGP peering"

def _bgp_converge_peer_group():
output = json.loads(r5.vtysh_cmd("show bgp ipv4 unicast summary json"))
expected = {
"peers": {
"192.168.1.1": {
"hostname": "r1",
"remoteAs": 65001,
"localAs": 65001,
"state": "Established",
},
"192.168.1.2": {
"hostname": "r2",
"remoteAs": 65001,
"localAs": 65001,
"state": "Established",
},
"192.168.1.3": {
"hostname": "r3",
"remoteAs": 65003,
"localAs": 65001,
"state": "Established",
},
}
}
return topotest.json_cmp(output, expected)

test_func = functools.partial(
_bgp_converge_peer_group,
)
_, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
assert (
result is None
), "Peer-group with mixed remote-as auto/internal members failed to establish"


if __name__ == "__main__":
args = ["-s"] + sys.argv[1:]
Expand Down
Loading