mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-08-14 06:22:34 +02:00
Add userns_devmem.py, which mirrors nk_devmem.py but places the netkit guest in a netns whose owning user_ns is non-init. ncdevmem is ran there via nsenter so the bind-rx call is issued with creds that hold CAP_NET_ADMIN only in the child user_ns. Without the preceding GENL_UNS_ADMIN_PERM patch the test fails at bind-rx with EPERM, but with the patch the transfer completes and tests pass. Signed-off-by: Bobby Eshleman <bobbyeshleman@meta.com> Acked-by: Stanislav Fomichev <sdf@fomichev.me> Link: https://patch.msgid.link/20260602-nl-prov-v2-2-ad721142c641@meta.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
50 lines
1.3 KiB
Python
Executable File
50 lines
1.3 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
"""
|
|
Devmem tests for non-init userns.
|
|
"""
|
|
|
|
import os
|
|
|
|
from devmem_lib import run_rx, run_rx_hds, run_tx, run_tx_chunks, setup_test
|
|
from lib.py import NetDrvContEnv, ksft_disruptive, ksft_exit, ksft_run
|
|
|
|
|
|
@ksft_disruptive
|
|
def check_userns_rx(cfg) -> None:
|
|
"""Run the devmem RX test through non-init userns netkit."""
|
|
run_rx(cfg)
|
|
|
|
|
|
@ksft_disruptive
|
|
def check_userns_tx(cfg) -> None:
|
|
"""Run the devmem TX test through non-init userns netkit."""
|
|
run_tx(cfg)
|
|
|
|
|
|
@ksft_disruptive
|
|
def check_userns_tx_chunks(cfg) -> None:
|
|
"""Run the devmem TX chunking test through non-init userns netkit."""
|
|
run_tx_chunks(cfg)
|
|
|
|
|
|
def check_userns_rx_hds(cfg) -> None:
|
|
"""Run the HDS test through non-init userns netkit."""
|
|
run_rx_hds(cfg)
|
|
|
|
|
|
def main() -> None:
|
|
"""Run userns devmem RX selftests against the test environment."""
|
|
with NetDrvContEnv(__file__, userns=True, rxqueues=2,
|
|
primary_rx_redirect=True) as cfg:
|
|
setup_test(cfg,
|
|
os.path.join(os.path.dirname(os.path.abspath(__file__)),
|
|
"ncdevmem"))
|
|
ksft_run([check_userns_rx, check_userns_tx, check_userns_tx_chunks,
|
|
check_userns_rx_hds], args=(cfg,))
|
|
ksft_exit()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|