mirror of
https://github.com/torvalds/linux.git
synced 2026-09-24 06:24:02 +02:00
selftests: drv-net: psp: test PSP and TCP ULP mutual exclusion
Test both setting PSP after TLS ULP, and TLS ULP after PSP. Add CONFIG_TLS=y to the drivers/net/config. Signed-off-by: Daniel Zahka <daniel.zahka@gmail.com> Reviewed-by: Willem de Bruijn <willemb@google.com> Link: https://patch.msgid.link/20260915-psp-ktls-fix-v2-2-0eedc3b148ec@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
a41f24c612
commit
b4288c59bd
|
|
@ -21,5 +21,6 @@ CONFIG_NET_SCH_INGRESS=y
|
|||
CONFIG_NET_SCH_PRIO=m
|
||||
CONFIG_PPP=y
|
||||
CONFIG_PPPOE=y
|
||||
CONFIG_TLS=y
|
||||
CONFIG_VLAN_8021Q=m
|
||||
CONFIG_XDP_SOCKETS=y
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ from lib.py import NetNSEnter
|
|||
from lib.py import bkg, rand_port, wait_port_listen
|
||||
from lib.py import ip
|
||||
|
||||
TCP_ULP = 31
|
||||
|
||||
|
||||
def _get_outq(s):
|
||||
one = b'\0' * 4
|
||||
|
|
@ -333,6 +335,50 @@ def assoc_version_mismatch(cfg):
|
|||
ksft_eq(the_exception.nl_msg.error, -errno.EINVAL)
|
||||
|
||||
|
||||
def _require_tls_ulp():
|
||||
with socket.create_server(("localhost", 0)) as srv, \
|
||||
socket.create_connection(srv.getsockname()) as s:
|
||||
try:
|
||||
s.setsockopt(socket.SOL_TCP, TCP_ULP, b"tls")
|
||||
except OSError as exc:
|
||||
raise KsftSkipEx("kTLS not available") from exc
|
||||
|
||||
|
||||
def assoc_psp_ulp_exclusive(cfg):
|
||||
""" Test that a TCP ULP cannot be attached to a PSP socket """
|
||||
_init_psp_dev(cfg)
|
||||
_require_tls_ulp()
|
||||
|
||||
with _make_clr_conn(cfg) as s:
|
||||
try:
|
||||
cfg.pspnl.rx_assoc({"version": 0,
|
||||
"dev-id": cfg.psp_dev_id,
|
||||
"sock-fd": s.fileno()})
|
||||
with ksft_raises(OSError) as cm:
|
||||
s.setsockopt(socket.SOL_TCP, TCP_ULP, b"tls")
|
||||
ksft_eq(cm.exception.errno, errno.EINVAL)
|
||||
finally:
|
||||
_close_conn(cfg, s)
|
||||
|
||||
|
||||
def assoc_ulp_psp_exclusive(cfg):
|
||||
""" Test that a PSP assoc cannot be added to a socket with a TCP ULP """
|
||||
_init_psp_dev(cfg)
|
||||
_require_tls_ulp()
|
||||
|
||||
with _make_clr_conn(cfg) as s:
|
||||
try:
|
||||
s.setsockopt(socket.SOL_TCP, TCP_ULP, b"tls")
|
||||
with ksft_raises(NlError) as cm:
|
||||
cfg.pspnl.rx_assoc({"version": 0,
|
||||
"dev-id": cfg.psp_dev_id,
|
||||
"sock-fd": s.fileno()})
|
||||
ksft_eq(cm.exception.nl_msg.error, -errno.EINVAL)
|
||||
ksft_eq(cm.exception.nl_msg.extack['bad-attr'], ".sock-fd")
|
||||
finally:
|
||||
_close_conn(cfg, s)
|
||||
|
||||
|
||||
def assoc_twice(cfg):
|
||||
""" Test reusing Tx assoc for two sockets """
|
||||
_init_psp_dev(cfg)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user