From 23fcf3135875f12ea4cf52a56f74e85f4641fa14 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Sun, 13 Apr 2025 12:47:44 -0400 Subject: [PATCH 1/5] pimd: Allow ssmpingd command to work for pim Commit: 1c56018f66723a5ea478f0d6607a8f81f4d6ada5 broke the ssmpingd implementation in pim. This is because it just completely botched the bind to the correct port and address. Signed-off-by: Donald Sharp --- pimd/pim_ssmpingd.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/pimd/pim_ssmpingd.c b/pimd/pim_ssmpingd.c index 27dbb0d6b4..5c04284a35 100644 --- a/pimd/pim_ssmpingd.c +++ b/pimd/pim_ssmpingd.c @@ -155,10 +155,13 @@ static inline int ssmpingd_setsockopt(int fd, pim_addr addr, int mttl) static int ssmpingd_socket(pim_addr addr, int port, int mttl) { - struct sockaddr_storage sockaddr; +#if PIM_IPV == 4 + struct sockaddr_in sockaddr; +#else + struct sockaddr_in6 sockaddr; +#endif int fd; int ret; - socklen_t len = sizeof(sockaddr); fd = socket(PIM_AF, SOCK_DGRAM, IPPROTO_UDP); if (fd < 0) { @@ -167,8 +170,15 @@ static int ssmpingd_socket(pim_addr addr, int port, int mttl) __func__, errno, safe_strerror(errno)); return -1; } - - pim_socket_getsockname(fd, (struct sockaddr *)&sockaddr, &len); +#if PIM_IPV == 4 + sockaddr.sin_addr = addr; + sockaddr.sin_port = htons(port); + sockaddr.sin_family = PIM_AF; +#else + sockaddr.sin6_addr = addr; + sockaddr.sin6_port = htons(port); + sockaddr.sin6_family = PIM_AF; +#endif if (bind(fd, (struct sockaddr *)&sockaddr, sizeof(sockaddr))) { zlog_warn( From f5de14db8e85a5c01328039ad44f61824234b7c2 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Sun, 13 Apr 2025 13:01:39 -0400 Subject: [PATCH 2/5] tests: Convert pim_basic to use integrated configuration Since I am in this test, modifying it let's just convert it to a integrated configuration. Signed-off-by: Donald Sharp --- tests/topotests/pim_basic/r1/bgpd.conf | 5 --- tests/topotests/pim_basic/r1/frr.conf | 32 +++++++++++++++++++ tests/topotests/pim_basic/r1/pimd.conf | 18 ----------- tests/topotests/pim_basic/r1/zebra.conf | 14 -------- .../pim_basic/r2/{zebra.conf => frr.conf} | 7 ++++ tests/topotests/pim_basic/r2/pimd.conf | 1 - .../pim_basic/r3/{zebra.conf => frr.conf} | 3 ++ tests/topotests/pim_basic/r3/pimd.conf | 1 - tests/topotests/pim_basic/rp/bgpd.conf | 5 --- tests/topotests/pim_basic/rp/frr.conf | 26 +++++++++++++++ tests/topotests/pim_basic/rp/pimd.conf | 13 -------- tests/topotests/pim_basic/rp/zebra.conf | 8 ----- tests/topotests/pim_basic/test_pim.py | 17 +++++----- 13 files changed, 76 insertions(+), 74 deletions(-) delete mode 100644 tests/topotests/pim_basic/r1/bgpd.conf create mode 100644 tests/topotests/pim_basic/r1/frr.conf delete mode 100644 tests/topotests/pim_basic/r1/pimd.conf delete mode 100644 tests/topotests/pim_basic/r1/zebra.conf rename tests/topotests/pim_basic/r2/{zebra.conf => frr.conf} (53%) delete mode 100644 tests/topotests/pim_basic/r2/pimd.conf rename tests/topotests/pim_basic/r3/{zebra.conf => frr.conf} (73%) delete mode 100644 tests/topotests/pim_basic/r3/pimd.conf delete mode 100644 tests/topotests/pim_basic/rp/bgpd.conf create mode 100644 tests/topotests/pim_basic/rp/frr.conf delete mode 100644 tests/topotests/pim_basic/rp/pimd.conf delete mode 100644 tests/topotests/pim_basic/rp/zebra.conf diff --git a/tests/topotests/pim_basic/r1/bgpd.conf b/tests/topotests/pim_basic/r1/bgpd.conf deleted file mode 100644 index 84d9598bc6..0000000000 --- a/tests/topotests/pim_basic/r1/bgpd.conf +++ /dev/null @@ -1,5 +0,0 @@ -router bgp 65001 - no bgp ebgp-requires-policy - neighbor 10.0.30.3 remote-as external - neighbor 10.0.30.3 timers 3 10 - redistribute connected diff --git a/tests/topotests/pim_basic/r1/frr.conf b/tests/topotests/pim_basic/r1/frr.conf new file mode 100644 index 0000000000..503e6f16e9 --- /dev/null +++ b/tests/topotests/pim_basic/r1/frr.conf @@ -0,0 +1,32 @@ +hostname r1 +! +service integrated-vtysh-config +! +interface r1-eth0 + ip address 10.0.20.1/24 + ip igmp + ip pim +! +interface r1-eth1 + ip address 10.0.30.1/24 + ip pim +! +interface r1-eth2 + ip address 10.0.40.1/24 + ip igmp + ip pim +! +interface lo + ip address 10.254.0.1/32 + ip pim +! +router bgp 65001 + no bgp ebgp-requires-policy + neighbor 10.0.30.3 remote-as external + neighbor 10.0.30.3 timers 3 10 + redistribute connected +! +router pim + rp 10.254.0.3 + join-prune-interval 5 +! diff --git a/tests/topotests/pim_basic/r1/pimd.conf b/tests/topotests/pim_basic/r1/pimd.conf deleted file mode 100644 index 737019fa51..0000000000 --- a/tests/topotests/pim_basic/r1/pimd.conf +++ /dev/null @@ -1,18 +0,0 @@ -hostname r1 -! -interface r1-eth0 - ip igmp - ip pim -! -interface r1-eth1 - ip pim -! -interface r1-eth2 - ip igmp - ip pim -! -interface lo - ip pim -! -ip pim rp 10.254.0.3 -ip pim join-prune-interval 5 diff --git a/tests/topotests/pim_basic/r1/zebra.conf b/tests/topotests/pim_basic/r1/zebra.conf deleted file mode 100644 index e43041758b..0000000000 --- a/tests/topotests/pim_basic/r1/zebra.conf +++ /dev/null @@ -1,14 +0,0 @@ -hostname r1 -! -interface r1-eth0 - ip address 10.0.20.1/24 -! -interface r1-eth1 - ip address 10.0.30.1/24 -! -interface r1-eth2 - ip address 10.0.40.1/24 -! -interface lo - ip address 10.254.0.1/32 -! diff --git a/tests/topotests/pim_basic/r2/zebra.conf b/tests/topotests/pim_basic/r2/frr.conf similarity index 53% rename from tests/topotests/pim_basic/r2/zebra.conf rename to tests/topotests/pim_basic/r2/frr.conf index cb30858f58..abcb81539c 100644 --- a/tests/topotests/pim_basic/r2/zebra.conf +++ b/tests/topotests/pim_basic/r2/frr.conf @@ -1,8 +1,15 @@ hostname r2 ! +frr version 8.4 +frr defaults traditional +! +service integrated-vtysh-config +! interface r2-eth0 ip address 10.0.20.2/24 ! interface lo ip address 10.254.0.2/32 ! +line vty +! \ No newline at end of file diff --git a/tests/topotests/pim_basic/r2/pimd.conf b/tests/topotests/pim_basic/r2/pimd.conf deleted file mode 100644 index 932cff6f3b..0000000000 --- a/tests/topotests/pim_basic/r2/pimd.conf +++ /dev/null @@ -1 +0,0 @@ -hostname r2 diff --git a/tests/topotests/pim_basic/r3/zebra.conf b/tests/topotests/pim_basic/r3/frr.conf similarity index 73% rename from tests/topotests/pim_basic/r3/zebra.conf rename to tests/topotests/pim_basic/r3/frr.conf index 8e58e8c66a..2d60a4d685 100644 --- a/tests/topotests/pim_basic/r3/zebra.conf +++ b/tests/topotests/pim_basic/r3/frr.conf @@ -1,5 +1,8 @@ hostname r3 ! +! +service integrated-vtysh-config +! interface r3-eth0 ip address 10.0.40.4/24 ! diff --git a/tests/topotests/pim_basic/r3/pimd.conf b/tests/topotests/pim_basic/r3/pimd.conf deleted file mode 100644 index f94ee99930..0000000000 --- a/tests/topotests/pim_basic/r3/pimd.conf +++ /dev/null @@ -1 +0,0 @@ -hostname r3 diff --git a/tests/topotests/pim_basic/rp/bgpd.conf b/tests/topotests/pim_basic/rp/bgpd.conf deleted file mode 100644 index 1bfae6059b..0000000000 --- a/tests/topotests/pim_basic/rp/bgpd.conf +++ /dev/null @@ -1,5 +0,0 @@ -router bgp 65003 - no bgp ebgp-requires-policy - neighbor 10.0.30.1 remote-as external - neighbor 10.0.30.1 timers 3 10 - redistribute connected diff --git a/tests/topotests/pim_basic/rp/frr.conf b/tests/topotests/pim_basic/rp/frr.conf new file mode 100644 index 0000000000..8b40f2fd1a --- /dev/null +++ b/tests/topotests/pim_basic/rp/frr.conf @@ -0,0 +1,26 @@ +hostname rp +! +! +service integrated-vtysh-config +! +interface rp-eth0 + ip address 10.0.30.3/24 + ip pim +! +interface lo + ip address 10.254.0.3/32 + ip pim +! +router bgp 65003 + no bgp ebgp-requires-policy + neighbor 10.0.30.1 remote-as external + neighbor 10.0.30.1 timers 3 10 + redistribute connected +! +router pim + join-prune-interval 5 + rp 10.254.0.3 + register-accept-list ACCEPT +! +ip prefix-list ACCEPT seq 5 permit 10.0.20.0/24 le 32 +! diff --git a/tests/topotests/pim_basic/rp/pimd.conf b/tests/topotests/pim_basic/rp/pimd.conf deleted file mode 100644 index fd26bc4d71..0000000000 --- a/tests/topotests/pim_basic/rp/pimd.conf +++ /dev/null @@ -1,13 +0,0 @@ -hostname rp -! -interface rp-eth0 - ip pim -! -interface lo - ip pim -! -ip pim join-prune-interval 5 -ip pim rp 10.254.0.3 -ip pim register-accept-list ACCEPT - -ip prefix-list ACCEPT seq 5 permit 10.0.20.0/24 le 32 diff --git a/tests/topotests/pim_basic/rp/zebra.conf b/tests/topotests/pim_basic/rp/zebra.conf deleted file mode 100644 index 0a1359ecd0..0000000000 --- a/tests/topotests/pim_basic/rp/zebra.conf +++ /dev/null @@ -1,8 +0,0 @@ -hostname rp -! -interface rp-eth0 - ip address 10.0.30.3/24 -! -interface lo - ip address 10.254.0.3/32 -! diff --git a/tests/topotests/pim_basic/test_pim.py b/tests/topotests/pim_basic/test_pim.py index 74d5406970..3ccc4251a5 100644 --- a/tests/topotests/pim_basic/test_pim.py +++ b/tests/topotests/pim_basic/test_pim.py @@ -71,16 +71,15 @@ def setup_module(mod): tgen = Topogen(build_topo, mod.__name__) tgen.start_topology() - # For all registered routers, load the zebra configuration file + # For all registered routers, load the integrated configuration file for rname, router in tgen.routers().items(): - router.load_config( - TopoRouter.RD_ZEBRA, os.path.join(CWD, "{}/zebra.conf".format(rname)) - ) - router.load_config( - TopoRouter.RD_PIM, os.path.join(CWD, "{}/pimd.conf".format(rname)) - ) - router.load_config( - TopoRouter.RD_BGP, os.path.join(CWD, "{}/bgpd.conf".format(rname)) + router.load_frr_config( + os.path.join(CWD, "{}/frr.conf".format(rname)), + [ + (TopoRouter.RD_ZEBRA, None), + (TopoRouter.RD_PIM, None), + (TopoRouter.RD_BGP, None), + ], ) # After loading the configurations, this function loads configured daemons. From 3b780b023a41425531c5c286f114484b13ff4fe1 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Sun, 13 Apr 2025 13:47:00 -0400 Subject: [PATCH 3/5] tests: Add a simple ssmping test to the system There are no tests that attempt to cover the ssmpingd functionality in pimd. Add a very very simple test case. This test requires the ssmping package to be installed. Signed-off-by: Donald Sharp --- tests/topotests/pim_basic/test_pim.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/topotests/pim_basic/test_pim.py b/tests/topotests/pim_basic/test_pim.py index 3ccc4251a5..d0787b27be 100644 --- a/tests/topotests/pim_basic/test_pim.py +++ b/tests/topotests/pim_basic/test_pim.py @@ -217,6 +217,27 @@ def test_pim_igmp_report(): p.wait() +def test_pim_ssm_ping(): + "Test SSM ping functionality between r1 and r2" + logger.info("Testing SSM ping from r1 to r2") + + tgen = get_topogen() + + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + r1 = tgen.gears["r1"] + r2 = tgen.gears["r2"] + + r2.vtysh_cmd("conf\nip ssmpingd 10.0.20.2") + + # Run ssmping from r1 to r2 + output = r1.run("ssmping -I r1-eth0 10.0.20.2 -c 5") + + # Check if we got successful responses + assert "5 packets received" in output, "SSM ping failed" + + def test_memory_leak(): "Run the memory leak test and report results." tgen = get_topogen() From ebe345828885f8039506749d32adeffe617140e6 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Mon, 14 Apr 2025 09:07:54 -0400 Subject: [PATCH 4/5] doc: Document new test dependancy ssmping is needed to test the ssmpingd in the pimd daemon. Signed-off-by: Donald Sharp --- doc/developer/topotests.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/developer/topotests.rst b/doc/developer/topotests.rst index 9e05a99474..c52b0b4ba5 100644 --- a/doc/developer/topotests.rst +++ b/doc/developer/topotests.rst @@ -35,7 +35,8 @@ Installing Topotest Requirements iputils-ping \ iptables \ tshark \ - valgrind + valgrind \ + ssmping python3 -m pip install wheel python3 -m pip install 'pytest>=8.3.2' 'pytest-asyncio>=0.24.0' 'pytest-xdist>=3.6.1' python3 -m pip install 'scapy>=2.4.5' From 143f1dfc9cadc60ddf975cbe54ca707f1078a88e Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 23 Apr 2025 13:57:21 -0400 Subject: [PATCH 5/5] docker: add ssmping to the the ubuntu docker images ssmping is missing from our docker builds. Let's add it so that topotests can run correctly. Signed-off-by: Donald Sharp Signed-off-by: Christian Hopps --- docker/ubuntu-ci/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/docker/ubuntu-ci/Dockerfile b/docker/ubuntu-ci/Dockerfile index 0bfcb51878..98d025e554 100644 --- a/docker/ubuntu-ci/Dockerfile +++ b/docker/ubuntu-ci/Dockerfile @@ -66,6 +66,7 @@ RUN apt update && apt upgrade -y && \ snmp \ snmp-mibs-downloader \ snmpd \ + ssmping \ sudo \ time \ tshark \