From c4c7118c2a1e32e17e202da1fa4547f15931e1d1 Mon Sep 17 00:00:00 2001 From: Rafael Zalamena Date: Wed, 5 Feb 2025 09:57:45 -0300 Subject: [PATCH] topotests: multicast source group join Allow topotests to generate source group join to test SSM. Signed-off-by: Rafael Zalamena --- tests/topotests/lib/mcast-tester.py | 61 ++++++++++++++++++++++++++--- 1 file changed, 55 insertions(+), 6 deletions(-) diff --git a/tests/topotests/lib/mcast-tester.py b/tests/topotests/lib/mcast-tester.py index 5efbecd5e5..3645eef25e 100755 --- a/tests/topotests/lib/mcast-tester.py +++ b/tests/topotests/lib/mcast-tester.py @@ -34,16 +34,64 @@ def interface_name_to_index(name): return None -def multicast_join(sock, ifindex, group, port): +def interface_index_to_address(index, iptype="inet"): + "Gets the interface main address using its name. Returns None on failure." + interfaces = json.loads(subprocess.check_output("ip -j addr show", shell=True)) + + for interface in interfaces: + if interface["ifindex"] == index: + break + + for address in interface["addr_info"]: + if address["family"] == iptype: + break + + local_address = ipaddress.ip_address(address["local"]) + + return local_address.packed + + +def group_source_req(ifindex, group, source): + "Packs the information into 'struct group_source_req' format." + mreq = struct.pack(" 0: # Block to ensure packet send. msock.setblocking(True) else: - multicast_join(msock, ifindex, args.group, args.port) + multicast_join(msock, ifindex, args.group, args.port, args.source) def should_exit():