Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bgpd: fix peer up message for loc-rib not sent #17545

Merged
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
14 changes: 9 additions & 5 deletions bgpd/bgp_bmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -467,13 +467,19 @@ static struct stream *bmp_peerstate(struct peer *peer, bool down)
struct stream *s;
size_t len;
struct timeval uptime, uptime_real;
uint8_t peer_type;
bool is_locrib = false;

uptime.tv_sec = peer->uptime;
uptime.tv_usec = 0;
monotime_to_realtime(&uptime, &uptime_real);

uint8_t peer_type = bmp_get_peer_type(peer);
bool is_locrib = peer_type == BMP_PEER_TYPE_LOC_RIB_INSTANCE;
peer_type = bmp_get_peer_type(peer);
if (peer_type == BMP_PEER_TYPE_LOC_RIB_INSTANCE)
is_locrib = true;
else
/* TODO: remove this when other RD and local instances supported */
peer_type = BMP_PEER_TYPE_GLOBAL_INSTANCE;

#define BGP_BMP_MAX_PACKET_SIZE 1024
#define BMP_PEERUP_INFO_TYPE_STRING 0
Expand All @@ -484,9 +490,7 @@ static struct stream *bmp_peerstate(struct peer *peer, bool down)

bmp_common_hdr(s, BMP_VERSION_3,
BMP_TYPE_PEER_UP_NOTIFICATION);
bmp_per_peer_hdr(s, peer->bgp, peer, 0,
BMP_PEER_TYPE_GLOBAL_INSTANCE, 0,
&uptime_real);
bmp_per_peer_hdr(s, peer->bgp, peer, 0, peer_type, 0, &uptime_real);

/* Local Address (16 bytes) */
if (is_locrib)
Expand Down
15 changes: 10 additions & 5 deletions tests/topotests/bgp_bmp/bgpbmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,16 @@ def bmp_check_for_peer_message(
]

# get the list of pairs (prefix, policy, seq) for the given message type
peers = [
m["peer_ip"]
for m in messages
if "peer_ip" in m.keys() and m["bmp_log_type"] == bmp_log_type
]
peers = []
for m in messages:
if (
"peer_ip" in m.keys()
and m["peer_ip"] != "0.0.0.0"
and m["bmp_log_type"] == bmp_log_type
):
peers.append(m["peer_ip"])
elif m["policy"] == "loc-rib" and m["bmp_log_type"] == bmp_log_type:
peers.append("0.0.0.0")

# check for prefixes
for ep in expected_peers:
Expand Down
2 changes: 1 addition & 1 deletion tests/topotests/bgp_bmp/test_bgp_bmp_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def test_peer_up():
"""

tgen = get_topogen()
peers = ["192.168.0.2", "192:168::2"]
peers = ["192.168.0.2", "192:168::2", "0.0.0.0"]

logger.info("checking for BMP peers up messages")

Expand Down
2 changes: 1 addition & 1 deletion tests/topotests/bgp_bmp/test_bgp_bmp_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def test_peer_up():
"""

tgen = get_topogen()
peers = ["192.168.0.2", "192:168::2"]
peers = ["192.168.0.2", "192:168::2", "0.0.0.0"]

logger.info("checking for BMP peers up messages")

Expand Down
Loading