]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd, topotests: bmp, fix wrong peer type for peer up/down events
authorPhilippe Guibert <philippe.guibert@6wind.com>
Thu, 31 Oct 2024 08:31:04 +0000 (09:31 +0100)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Wed, 11 Dec 2024 10:47:56 +0000 (11:47 +0100)
When running the bgp_bmp_2 vrf test, peer up/down events from the pre
and post policy are received with a wrong peer type value

> {"peer_type": "global instance", "policy": "pre-policy", "ipv6": false,
> "peer_ip": "192.168.0.2", "peer_distinguisher": "0:0", "peer_asn": 65502,
> "peer_bgp_id": "192.168.0.2", "timestamp": "2024-10-16 21:59:53.111962",
> "bmp_log_type": "peer up", "local_ip": "192.168.0.1", "local_port": 179,
> "remote_port": 50710, "seq": 4}

RFC7854 defines RD instance peer type, and later in 4.2 requests that
the peer distinguisher value be set to non zero value when the peer type
is not global. This is the case for peer vrf instances.

Fix this by modifying the BMP client, update the peer type
value by updating the peer type value when sending peer up/down messages.

Add a check in the bgp_bmp_2 test to ensure that peer type is correctly
set.

> {"peer_type": "route distinguisher instance", "policy": "pre-policy",
> "ipv6": true, "peer_ip": "192:168::2", "peer_distinguisher": "0:0",
> "peer_asn": 65502, "peer_bgp_id": "192.168.0.2", "timestamp":
> "2024-10-16 21:59:53.111962", "bmp_log_type": "peer up", "local_ip":
> "192:168::1", "local_port": 179, "remote_port": 50836, "seq": 5}

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
bgpd/bgp_bmp.c
tests/topotests/bgp_bmp/bgpbmp.py
tests/topotests/bgp_bmp/test_bgp_bmp_2.py

index 65a99d75e7f41f492fdc79c3d059c602cbff11b9..08cfcdb37c0337b64594a128ef3309fbf9fbef71 100644 (file)
@@ -474,12 +474,6 @@ static struct stream *bmp_peerstate(struct peer *peer, bool down)
        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;
-
-       if (is_locrib == false)
-               peer_type = BMP_PEER_TYPE_GLOBAL_INSTANCE;
 
        if (bmp_get_peer_distinguisher(peer->bgp, AFI_UNSPEC, peer_type, &peer_distinguisher)) {
                zlog_warn("skipping bmp message for peer %s: can't get peer distinguisher",
index 0a0a845b3ab3be7b607b0f22bdd9e05be1543a82..4f770ebcd1d4c0cd8937066494db0760fe24b426 100644 (file)
@@ -187,7 +187,7 @@ def bmp_check_for_prefixes(
 
 
 def bmp_check_for_peer_message(
-    expected_peers, bmp_log_type, bmp_collector, bmp_log_file
+    expected_peers, bmp_log_type, bmp_collector, bmp_log_file, is_rd_instance=False
 ):
     """
     Check for the presence of a peer up message for the peer
@@ -211,6 +211,8 @@ def bmp_check_for_peer_message(
             and m["peer_ip"] != "0.0.0.0"
             and m["bmp_log_type"] == bmp_log_type
         ):
+            if is_rd_instance and m["peer_type"] != "route distinguisher instance":
+                continue
             peers.append(m["peer_ip"])
         elif m["policy"] == "loc-rib" and m["bmp_log_type"] == bmp_log_type:
             peers.append("0.0.0.0")
index e8f67515bd5d9d16349f76c8e1d98c6eb4bdf780..f16ff2b4458b5da55d6f3f0b1b1b0225f47bd620 100644 (file)
@@ -210,6 +210,7 @@ def test_peer_up():
         "peer up",
         tgen.gears["bmp1vrf"],
         os.path.join(tgen.logdir, "bmp1vrf", "bmp.log"),
+        is_rd_instance=True,
     )
     success, _ = topotest.run_and_expect(test_func, True, count=30, wait=1)
     assert success, "Checking the updated prefixes has been failed !."
@@ -245,6 +246,7 @@ def test_peer_down():
         "peer down",
         tgen.gears["bmp1vrf"],
         os.path.join(tgen.logdir, "bmp1vrf", "bmp.log"),
+        is_rd_instance=True,
     )
     success, _ = topotest.run_and_expect(test_func, True, count=30, wait=1)
     assert success, "Checking the updated prefixes has been failed !."