]> git.puffer.fish Git - matthieu/frr.git/commitdiff
topotests: test MSDP SA filtering
authorRafael Zalamena <rzalamena@opensourcerouting.org>
Fri, 9 Dec 2022 17:34:13 +0000 (14:34 -0300)
committerRafael Zalamena <rzalamena@opensourcerouting.org>
Sat, 27 Jul 2024 14:32:51 +0000 (11:32 -0300)
Modify existing MSDP topology to use test SA filtering:
- Add new multicast host (so we get two sources for same group)
- Test group only filtering
- Test source / group filtering

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
tests/topotests/msdp_topo1/r4/pimd.conf
tests/topotests/msdp_topo1/test_msdp_topo1.py

index 28085913fb9cdd9186b58a8d0d3ba1c39b7c4384..46de4fbe384a5fcc47150c8140bcc8a07a8cc749 100644 (file)
@@ -20,3 +20,16 @@ ip msdp peer 192.168.2.1 source 192.168.2.2
 ip msdp peer 192.168.3.1 source 192.168.3.2
 ip pim rp 10.254.254.4
 ip pim join-prune-interval 5
+!
+access-list forbidden-multicast seq 5 deny 229.2.1.0 0.0.0.255
+access-list forbidden-multicast seq 1000 permit any
+access-list local-only-multicast seq 5 deny 229.3.1.0 0.0.0.255
+access-list local-only-multicast seq 6 deny ip 192.168.4.100 0.0.0.0 229.10.1.0 0.0.0.255
+access-list local-only-multicast seq 1000 permit any
+!
+router pim
+ msdp peer 192.168.2.1 sa-filter forbidden-multicast in
+ msdp peer 192.168.2.1 sa-filter local-only-multicast out
+ msdp peer 192.168.3.1 sa-filter forbidden-multicast in
+ msdp peer 192.168.3.1 sa-filter local-only-multicast out
+!
index 4b54ef29ffc45f9fc555efdad41d961a16a3c859..ff80052d266599f46463ac358392e1d111dbc0be 100755 (executable)
@@ -66,7 +66,9 @@ def build_topo(tgen):
 
     # Create a host connected and direct at r4:
     tgen.add_host("h1", "192.168.4.100/24", "via 192.168.4.1")
+    tgen.add_host("h3", "192.168.4.120/24", "via 192.168.4.1")
     switch.add_link(tgen.gears["h1"])
+    switch.add_link(tgen.gears["h3"])
 
     # Create a host connected and direct at r1:
     switch = tgen.add_switch("s6")
@@ -82,7 +84,6 @@ def setup_module(mod):
 
     router_list = tgen.routers()
     for rname, router in router_list.items():
-
         daemon_file = "{}/{}/zebra.conf".format(CWD, rname)
         if os.path.isfile(daemon_file):
             router.load_config(TopoRouter.RD_ZEBRA, daemon_file)
@@ -428,6 +429,87 @@ def test_msdp():
         assert val is None, "multicast route convergence failure"
 
 
+def test_msdp_sa_filter():
+    "Start a number of multicast streams and check if filtering works"
+
+    tgen = get_topogen()
+
+    # Flow from r1 -> r4
+    for multicast_address in ["229.2.1.1", "229.2.1.2", "229.2.2.1"]:
+        app_helper.run("h1", [multicast_address, "h1-eth0"])
+        app_helper.run("h2", ["--send=0.7", multicast_address, "h2-eth0"])
+
+    # Flow from r4 -> r1
+    for multicast_address in ["229.3.1.1", "229.3.1.2", "229.3.2.1"]:
+        app_helper.run("h1", ["--send=0.7", multicast_address, "h1-eth0"])
+        app_helper.run("h2", [multicast_address, "h2-eth0"])
+
+    # Flow from r4 -> r1 but with more sources
+    for multicast_address in ["229.10.1.1", "229.11.1.1"]:
+        app_helper.run("h1", ["--send=0.7", multicast_address, "h1-eth0"])
+        app_helper.run("h2", [multicast_address, "h2-eth0"])
+        app_helper.run("h3", ["--send=0.7", multicast_address, "h3-eth0"])
+
+    # Test that we don't learn any filtered multicast streams.
+    r4_sa_expected = {
+        "229.2.1.1": None,
+        "229.2.1.2": None,
+        "229.2.2.1": {
+            "192.168.10.100": {
+                "local": "no",
+                "sptSetup": "yes",
+            }
+        },
+    }
+    test_func = partial(
+        topotest.router_json_cmp,
+        tgen.gears["r4"],
+        "show ip msdp sa json",
+        r4_sa_expected,
+    )
+    logger.info("Waiting for r4 MDSP SA data")
+    _, val = topotest.run_and_expect(test_func, None, count=30, wait=1)
+    assert val is None, "multicast route convergence failure"
+
+    # Test that we don't send any filtered multicast streams.
+    r1_sa_expected = {
+        "229.3.1.1": None,
+        "229.3.1.2": None,
+        "229.3.2.1": {
+            "192.168.4.100": {
+                "local": "no",
+                "sptSetup": "yes",
+            }
+        },
+        "229.10.1.1": {
+            "192.168.4.100": None,
+            "192.168.4.120": {
+                "local": "no",
+                "sptSetup": "yes",
+            },
+        },
+        "229.11.1.1": {
+            "192.168.4.100": {
+                "local": "no",
+                "sptSetup": "yes",
+            },
+            "192.168.4.120": {
+                "local": "no",
+                "sptSetup": "yes",
+            },
+        },
+    }
+    test_func = partial(
+        topotest.router_json_cmp,
+        tgen.gears["r1"],
+        "show ip msdp sa json",
+        r1_sa_expected,
+    )
+    logger.info("Waiting for r1 MDSP SA data")
+    _, val = topotest.run_and_expect(test_func, None, count=30, wait=1)
+    assert val is None, "multicast route convergence failure"
+
+
 def test_memory_leak():
     "Run the memory leak test and report results."
     tgen = get_topogen()