linux/tools/testing/selftests/drivers/net/hw/nk_netns.py
David Wei 37d24994a7 selftests/net: Add netkit container ping test
Add a basic ping test using NetDrvContEnv that sets up a netkit pair,
with one end in a netns. Use LOCAL_PREFIX_V6 and nk_forward BPF program
to ping from a remote host to the netkit in netns.

Signed-off-by: David Wei <dw@davidwei.uk>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://patch.msgid.link/20260305181803.2912736-5-dw@davidwei.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-03-06 13:16:40 -08:00

30 lines
680 B
Python
Executable File

#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-2.0
"""
Test exercising NetDrvContEnv() itself, a NetDrvContEnv() selftest.
"""
from lib.py import ksft_run, ksft_exit
from lib.py import NetDrvContEnv
from lib.py import cmd
def test_ping(cfg) -> None:
""" Run ping between the container and the remote system. """
cfg.require_ipver("6")
cmd(f"ping -c 1 -W5 {cfg.nk_guest_ipv6}", host=cfg.remote)
cmd(f"ping -c 1 -W5 {cfg.remote_addr_v['6']}", ns=cfg.netns)
def main() -> None:
""" Ksft boiler plate main """
with NetDrvContEnv(__file__) as cfg:
ksft_run([test_ping], args=(cfg,))
ksft_exit()
if __name__ == "__main__":
main()