tools/testing/selftests/net/nl_netdev.py
Source file repositories/reference/linux-study-clean/tools/testing/selftests/net/nl_netdev.py
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/net/nl_netdev.py- Extension
.py- Size
- 12829 bytes
- Lines
- 390
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: tools
- Status
- atlas-only
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
- No top-level syscall, struct, function, initcall, or export declaration detected by the generator.
Annotated Snippet
#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-2.0
"""
Tests for the netdev netlink family.
"""
import errno
from os import system
from lib.py import ksft_run, ksft_exit
from lib.py import ksft_eq, ksft_ge, ksft_ne, ksft_raises, ksft_busy_wait
from lib.py import NetdevFamily, NetdevSimDev, NlError, defer, ip
def empty_check(nf) -> None:
devs = nf.dev_get({}, dump=True)
ksft_ge(len(devs), 1)
def lo_check(nf) -> None:
lo_info = nf.dev_get({"ifindex": 1})
ksft_eq(len(lo_info['xdp-features']), 0)
ksft_eq(len(lo_info['xdp-rx-metadata-features']), 0)
def dev_dump_reject_attr(nf) -> None:
"""Test that dev-get dump rejects attributes (no dump request policy)."""
with ksft_raises(NlError) as cm:
nf.dev_get({'ifindex': 1}, dump=True)
ksft_eq(cm.exception.nl_msg.error, -errno.EINVAL)
ksft_eq(cm.exception.nl_msg.extack['msg'], 'Unknown attribute type')
ksft_eq(cm.exception.nl_msg.extack['bad-attr'], '.ifindex')
def napi_list_check(nf) -> None:
with NetdevSimDev(queue_count=100) as nsimdev:
nsim = nsimdev.nsims[0]
ip(f"link set dev {nsim.ifname} up")
napis = nf.napi_get({'ifindex': nsim.ifindex}, dump=True)
ksft_eq(len(napis), 100)
for q in [50, 0, 99]:
for i in range(4):
nsim.dfs_write("queue_reset", f"{q} {i}")
napis = nf.napi_get({'ifindex': nsim.ifindex}, dump=True)
ksft_eq(len(napis), 100,
comment=f"queue count after reset queue {q} mode {i}")
def napi_set_threaded(nf) -> None:
"""
Test that verifies various cases of napi threaded
set and unset at napi and device level.
"""
with NetdevSimDev(queue_count=2) as nsimdev:
nsim = nsimdev.nsims[0]
ip(f"link set dev {nsim.ifname} up")
napis = nf.napi_get({'ifindex': nsim.ifindex}, dump=True)
ksft_eq(len(napis), 2)
napi0_id = napis[0]['id']
napi1_id = napis[1]['id']
# set napi threaded and verify
nf.napi_set({'id': napi0_id, 'threaded': "enabled"})
napi0 = nf.napi_get({'id': napi0_id})
ksft_eq(napi0['threaded'], "enabled")
Annotation
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: atlas-only.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.