mirror of
https://github.com/torvalds/linux.git
synced 2026-05-27 08:33:17 +02:00
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>
30 lines
680 B
Python
Executable File
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()
|