bgpd, topotests: fix wrong peer type for loc-rib peer events

When running the bgp_bmp test, peer_up message from the loc-rib
are received with a wrong peer type.
> {"peer_type": "global instance", "policy": "pre-policy", "ipv6": false, "peer_ip": "0.0.0.0",
> "peer_distinguisher": "0:0", "peer_asn": 0, "peer_bgp_id": "0.0.0.0",
> "timestamp": "2024-10-16 21:59:53.111963", "bmp_log_type": "peer up", "local_ip": "0.0.0.0",
> "local_port": 0, "remote_port": 0, "seq": 1}

RFC9069 mentions in 5.1 that peer address must be set to 0.0.0.0,
and the peer_type value must be set to 3. Today, the value set
is 0 (global instance). This is wrong.

Fix this by modifying the BMP client, update the peer type value to
loc-rib on peer up messages.

Modify the current BMP test, by checking the peer up messages for the
0.0.0.0 IP address (which is the value used for loc-rib).

> {"peer_type": "loc-rib instance", "is_filtered": false, "policy": "loc-rib",
> "peer_distinguisher": "0:0", "peer_asn": 65501, "peer_bgp_id": "192.168.0.1",
> "timestamp": "2024-10-16 21:59:53.111963", "bmp_log_type": "peer up", "local_ip": "0.0.0.0",
> "local_port": 0, "remote_port": 0, "seq": 1}

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
This commit is contained in:
Philippe Guibert 2024-10-30 21:24:44 +01:00
parent 0190fd5985
commit 8198dec807

View File

@ -481,6 +481,9 @@ static struct stream *bmp_peerstate(struct peer *peer, bool down)
/* TODO: remove this when other RD and local instances supported */ /* TODO: remove this when other RD and local instances supported */
peer_type = BMP_PEER_TYPE_GLOBAL_INSTANCE; peer_type = BMP_PEER_TYPE_GLOBAL_INSTANCE;
if (is_locrib == false)
peer_type = BMP_PEER_TYPE_GLOBAL_INSTANCE;
#define BGP_BMP_MAX_PACKET_SIZE 1024 #define BGP_BMP_MAX_PACKET_SIZE 1024
#define BMP_PEERUP_INFO_TYPE_STRING 0 #define BMP_PEERUP_INFO_TYPE_STRING 0
s = stream_new(BGP_MAX_PACKET_SIZE); s = stream_new(BGP_MAX_PACKET_SIZE);
@ -552,9 +555,7 @@ static struct stream *bmp_peerstate(struct peer *peer, bool down)
bmp_common_hdr(s, BMP_VERSION_3, bmp_common_hdr(s, BMP_VERSION_3,
BMP_TYPE_PEER_DOWN_NOTIFICATION); BMP_TYPE_PEER_DOWN_NOTIFICATION);
bmp_per_peer_hdr(s, peer->bgp, peer, 0, bmp_per_peer_hdr(s, peer->bgp, peer, 0, peer_type, 0, &uptime_real);
BMP_PEER_TYPE_GLOBAL_INSTANCE, 0,
&uptime_real);
type_pos = stream_get_endp(s); type_pos = stream_get_endp(s);
stream_putc(s, 0); /* placeholder for down reason */ stream_putc(s, 0); /* placeholder for down reason */