Skip to content
Open
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
6 changes: 4 additions & 2 deletions bgpd/bgp_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -2015,7 +2015,9 @@ static int bgp_open_receive(struct peer_connection *connection,
}
(void)peer_sort(peer);
} else if (peer->as_type == AS_INTERNAL) {
if (remote_as != peer->bgp->as) {
as_t local_as = peer->change_local_as ? peer->change_local_as : peer->bgp->as;

if (remote_as != local_as) {
if (bgp_debug_neighbor_events(peer))
zlog_debug(
"%s bad OPEN, remote AS is %u, internal specified",
Expand All @@ -2026,7 +2028,7 @@ static int bgp_open_receive(struct peer_connection *connection,
notify_data_remote_as, 2);
return BGP_Stop;
}
peer->as = peer->local_as;
peer->as = peer->change_local_as ? peer->change_local_as : peer->local_as;
} else if (peer->as_type == AS_EXTERNAL) {
if (remote_as == peer->bgp->as) {
if (bgp_debug_neighbor_events(peer))
Expand Down
5 changes: 3 additions & 2 deletions bgpd/bgp_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -15839,7 +15839,8 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, uint16_t sh_flags, bo
: "");
}
/* peer type internal or confed-internal */
if ((p->as == p->local_as) || (CHECK_FLAG(p->as_type, AS_INTERNAL))) {
if (p->as == p->local_as || (p->change_local_as && p->as == p->change_local_as) ||
CHECK_FLAG(p->as_type, AS_INTERNAL)) {
if (use_json) {
if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION))
json_object_boolean_true_add(
Expand All @@ -15854,7 +15855,7 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, uint16_t sh_flags, bo
vty_out(vty, "internal link\n");
}
/* peer type external or confed-external */
} else if (p->as || (p->as_type == AS_EXTERNAL)) {
} else if (p->as || CHECK_FLAG(p->as_type, AS_EXTERNAL)) {
if (use_json) {
if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION))
json_object_boolean_true_add(
Expand Down
7 changes: 4 additions & 3 deletions tests/topotests/bgp_remote_as_auto/r1/frr.conf
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ router bgp 65001
neighbor 192.168.1.3 remote-as auto
neighbor 192.168.1.3 timers 1 3
neighbor 192.168.1.3 timers connect 1
neighbor 192.168.1.5 remote-as auto
neighbor 192.168.1.5 timers 1 3
neighbor 192.168.1.5 timers connect 1
neighbor 192.168.1.5 local-as 65005 no-prepend replace-as
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: 2 additions & 1 deletion tests/topotests/bgp_remote_as_auto/r5/frr.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ 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 remote-as internal
neighbor 192.168.1.1 timers 1 3
neighbor 192.168.1.1 timers connect 1
neighbor 192.168.1.1 local-as 65005 no-prepend replace-as
neighbor 192.168.1.2 peer-group PG
neighbor 192.168.1.2 remote-as internal
neighbor 192.168.1.2 timers 1 3
Expand Down
34 changes: 32 additions & 2 deletions tests/topotests/bgp_remote_as_auto/test_bgp_remote_as_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ def _bgp_converge():
"localAs": 65001,
"state": "Established",
},
"192.168.1.5": {
"hostname": "r5",
"remoteAs": 65005,
"localAs": 65005,
"state": "Established",
},
}
}
return topotest.json_cmp(output, expected)
Expand All @@ -84,6 +90,30 @@ def _bgp_converge():
_, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
assert result is None, "Can't see automatic iBGP/eBGP peerings"

def _bgp_neighbors():
output = json.loads(r1.vtysh_cmd("show bgp neighbors json"))
expected = {
"r1-eth1": {
"nbrExternalLink": True,
},
"192.168.1.2": {
"nbrExternalLink": None,
},
"192.168.1.3": {
"nbrExternalLink": True,
},
"192.168.1.5": {
"nbrExternalLink": None,
},
}
return topotest.json_cmp(output, expected)

test_func = functools.partial(
_bgp_neighbors,
)
_, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
assert result is None, "Neighbors link types are not matching"

def _bgp_converge_internal():
output = json.loads(r2.vtysh_cmd("show bgp ipv4 unicast 10.0.0.1/32 json"))
expected = {
Expand Down Expand Up @@ -162,8 +192,8 @@ def _bgp_converge_peer_group():
"peers": {
"192.168.1.1": {
"hostname": "r1",
"remoteAs": 65001,
"localAs": 65001,
"remoteAs": 65005,
"localAs": 65005,
"state": "Established",
},
"192.168.1.2": {
Expand Down
Loading