Skip to content

Commit 30b9817

Browse files
committed
selftests: drv-net: test empty queue and NAPI responses in netlink
Make sure kernel doesn't respond to GETs for queues and NAPIs when link is down. Not with valid data, or with empty message, we want a ENOENT. Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 4a25201 commit 30b9817

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

tools/testing/selftests/drivers/net/queues.py

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

4-
from lib.py import ksft_run, ksft_exit, ksft_eq, KsftSkipEx
5-
from lib.py import EthtoolFamily, NetdevFamily
4+
from lib.py import ksft_disruptive, ksft_exit, ksft_run
5+
from lib.py import ksft_eq, ksft_raises, KsftSkipEx
6+
from lib.py import EthtoolFamily, NetdevFamily, NlError
67
from lib.py import NetDrvEnv
7-
from lib.py import cmd
8+
from lib.py import cmd, defer, ip
9+
import errno
810
import glob
911

1012

@@ -59,9 +61,27 @@ def addremove_queues(cfg, nl) -> None:
5961
ksft_eq(queues, expected)
6062

6163

64+
@ksft_disruptive
65+
def check_down(cfg, nl) -> None:
66+
# Check the NAPI IDs before interface goes down and hides them
67+
napis = nl.napi_get({'ifindex': cfg.ifindex}, dump=True)
68+
69+
ip(f"link set dev {cfg.dev['ifname']} down")
70+
defer(ip, f"link set dev {cfg.dev['ifname']} up")
71+
72+
with ksft_raises(NlError) as cm:
73+
nl.queue_get({'ifindex': cfg.ifindex, 'id': 0, 'type': 'rx'})
74+
ksft_eq(cm.exception.nl_msg.error, -errno.ENOENT)
75+
76+
if napis:
77+
with ksft_raises(NlError) as cm:
78+
nl.napi_get({'id': napis[0]['id']})
79+
ksft_eq(cm.exception.nl_msg.error, -errno.ENOENT)
80+
81+
6282
def main() -> None:
6383
with NetDrvEnv(__file__, queue_count=100) as cfg:
64-
ksft_run([get_queues, addremove_queues], args=(cfg, NetdevFamily()))
84+
ksft_run([get_queues, addremove_queues, check_down], args=(cfg, NetdevFamily()))
6585
ksft_exit()
6686

6787

0 commit comments

Comments
 (0)