Skip to content

Commit a6928a8

Browse files
committed
BACKPORT: selftests: ncdevmem: Implement devmem TCP TX
Add support for devmem TX in ncdevmem. This is a combination of the ncdevmem from the devmem TCP series RFCv1 which included the TX path, and work by Stan to include the netlink API and refactored on top of his generic memory_provider support. Signed-off-by: Mina Almasry <almasrymina@google.com> Signed-off-by: Stanislav Fomichev <sdf@fomichev.me> Acked-by: Stanislav Fomichev <sdf@fomichev.me> Signed-off-by: Pranjal Shrivastava <praan@google.com>
1 parent 38685e8 commit a6928a8

File tree

2 files changed

+308
-15
lines changed

2 files changed

+308
-15
lines changed

tools/testing/selftests/drivers/net/hw/devmem.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python3
22
# SPDX-License-Identifier: GPL-2.0
33

4+
from os import path
45
from lib.py import ksft_run, ksft_exit
56
from lib.py import ksft_eq, KsftSkipEx
67
from lib.py import NetDrvEpEnv
@@ -10,8 +11,7 @@
1011

1112
def require_devmem(cfg):
1213
if not hasattr(cfg, "_devmem_probed"):
13-
port = rand_port()
14-
probe_command = f"./ncdevmem -f {cfg.ifname}"
14+
probe_command = f"{cfg.bin_local} -f {cfg.ifname}"
1515
cfg._devmem_supported = cmd(probe_command, fail=False, shell=True).ret == 0
1616
cfg._devmem_probed = True
1717

@@ -25,18 +25,34 @@ def check_rx(cfg) -> None:
2525
require_devmem(cfg)
2626

2727
port = rand_port()
28-
listen_cmd = f"./ncdevmem -l -f {cfg.ifname} -s {cfg.v6} -p {port}"
28+
listen_cmd = f"{cfg.bin_local} -l -f {cfg.ifname} -s {cfg.addr_v['6']} -p {port}"
2929

3030
with bkg(listen_cmd) as socat:
3131
wait_port_listen(port)
3232
cmd(f"echo -e \"hello\\nworld\"| socat -u - TCP6:[{cfg.v6}]:{port}", host=cfg.remote, shell=True)
3333

3434
ksft_eq(socat.stdout.strip(), "hello\nworld")
3535

36+
@ksft_disruptive
37+
def check_tx(cfg) -> None:
38+
cfg.require_ipver("6")
39+
require_devmem(cfg)
40+
41+
port = rand_port()
42+
listen_cmd = f"socat -U - TCP6-LISTEN:{port}"
43+
44+
with bkg(listen_cmd, exit_wait=True) as socat:
45+
wait_port_listen(port)
46+
cmd(f"echo -e \"hello\\nworld\"| {cfg.bin_remote} -f {cfg.ifname} -s {cfg.addr_v['6']} -p {port}", host=cfg.remote, shell=True)
47+
48+
ksft_eq(socat.stdout.strip(), "hello\nworld")
3649

3750
def main() -> None:
3851
with NetDrvEpEnv(__file__) as cfg:
39-
ksft_run([check_rx],
52+
cfg.bin_local = path.abspath(path.dirname(__file__) + "/ncdevmem")
53+
cfg.bin_remote = cfg.remote.deploy(cfg.bin_local)
54+
55+
ksft_run([check_rx, check_tx],
4056
args=(cfg, ))
4157
ksft_exit()
4258

0 commit comments

Comments
 (0)