-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
selftests/net: Add selftest for IPv4 RTM_GETMULTICAST support
This change introduces a new selftest case to verify the functionality of dumping IPv4 multicast addresses using the RTM_GETMULTICAST netlink message. The test utilizes the ynl library to interact with the netlink interface and validate that the kernel correctly reports the joined IPv4 multicast addresses. To run the test, execute the following command: $ vng -v --user root --cpus 16 -- \ make -C tools/testing/selftests TARGETS=net \ TEST_PROGS=rtnetlink.py TEST_GEN_PROGS="" run_tests Cc: Maciej Żenczykowski <maze@google.com> Cc: Lorenzo Colitti <lorenzo@google.com> Signed-off-by: Yuyang Huang <yuyanghuang@google.com> Link: https://patch.msgid.link/20250207110836.2407224-2-yuyanghuang@google.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
- Loading branch information
Yuyang Huang
authored and
Paolo Abeni
committed
Feb 11, 2025
1 parent
eb4e17a
commit 4f28037
Showing
5 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/usr/bin/env python3 | ||
# SPDX-License-Identifier: GPL-2.0 | ||
|
||
from lib.py import ksft_exit, ksft_run, ksft_ge, RtnlAddrFamily | ||
import socket | ||
|
||
IPV4_ALL_HOSTS_MULTICAST = b'\xe0\x00\x00\x01' | ||
|
||
def dump_mcaddr_check(rtnl: RtnlAddrFamily) -> None: | ||
""" | ||
Verify that at least one interface has the IPv4 all-hosts multicast address. | ||
At least the loopback interface should have this address. | ||
""" | ||
|
||
addresses = rtnl.getmaddrs({"ifa-family": socket.AF_INET}, dump=True) | ||
|
||
all_host_multicasts = [ | ||
addr for addr in addresses if addr['ifa-multicast'] == IPV4_ALL_HOSTS_MULTICAST | ||
] | ||
|
||
ksft_ge(len(all_host_multicasts), 1, | ||
"No interface found with the IPv4 all-hosts multicast address") | ||
|
||
def main() -> None: | ||
rtnl = RtnlAddrFamily() | ||
ksft_run([dump_mcaddr_check], args=(rtnl, )) | ||
ksft_exit() | ||
|
||
if __name__ == "__main__": | ||
main() |