Introduce a new helper function, `sk_set_prio_allowed`,
to centralize the logic for validating priority settings.
Add support for the `SO_PRIORITY` control message,
enabling user-space applications to set socket priority
via control messages (cmsg).
Patch Overview:
Patch 1/4: Introduce 'sk_set_prio_allowed' helper function.
Patch 2/4: Add support for setting SO_PRIORITY via control messages
Patch 3/4: Add test for SO_PRIORITY setting via control messages
Patch 4/4: Add new socket option, SO_RCVPRIORITY
v7:
- Carry Eric's and Willem's "Reviewed-by" tags from v3 to
patch 1/4 since that is resubmitted without changes.
- Carry Willem's "Reviewed-by" tag from v4 in patch 2/4,
as it is resubmitted without changes.
- Carry Willem's "Reviewed-by" tag from v5 in patch 4/4,
as it is resubmitted without changes.
- Carry Willem's "Reviewed-by" tag from v6
since it is resubmitted with minor cosmetic changes in
patch 3/4.
- Carry Willem's "Acked-by" tag from v5 on FILTER_COUNTER
(patch 3/4).
- Carry Ido's "Reviewed-by" and "Tested-by" tags from v6
since it is resubmitted with minor cosmetic changes in
patch 3/4.
- Align the code to the open parenthesis in cmsg_sender.c
(patch 3/4).
- Remove unnecessary blank line in cmsg_so_priority.sh
(patch 3/4).
- Remove unused delay variable from cmsg_so_priority.sh
(patch 3/4).
- Rebased on net-next.
v6:
https://lore.kernel.org/netdev/20241210191309.8681-1-annaemesenyiri@gmail.c…
- Carry Eric's and Willem's "Reviewed-by" tags from v3 to
patch 1/4 since that is resubmitted without changes.
- Carry Willem's "Reviewed-by" tag from v4 in patch 2/4,
as it is resubmitted without changes.
- Carry Willem's "Reviewed-by" tag from v5 in patch 4/4,
as it is resubmitted without changes.
- Use KSFT_SKIP in jq installation test and
add 'nodad' flag for IPv6 address in cmsg_so_priority.sh (patch 3/4).
- Rebased on net-next.
v5:
https://lore.kernel.org/netdev/20241205133112.17903-1-annaemesenyiri@gmail.…
- Carry Eric's and Willem's "Reviewed-by" tags from v3 to
patch 1/4 since that is resubmitted without changes.
- Carry Willem's "Reviewed-by" tag from v4 in patch 2/4,
as it is resubmitted without changes.
- Eliminate variable duplication, fix indentation, simplify cleanup,
verify dependencies, separate setsockopt and control message
priority testing, and modify namespace setup
in patch 3/4 cmsg_so_priority.sh.
- Add cmsg_so_priority.sh to tools/testing/selftests/net/Makefile.
- Remove the unused variable, rename priority_cmsg to priority,
and document the -P option in cmsg_sender.c in patch 3/4.
- New in v5: add new socket option, SO_RCVPRIORITY in patch 4/4.
- Rebased on net-next.
v4:
https://lore.kernel.org/netdev/20241118145147.56236-1-annaemesenyiri@gmail.…
- Carry Eric's and Willem's "Reviewed-by" tags from v3 to
patch 1/3 since that is resubmitted without changes.
- Updated description in patch 2/3.
- Missing ipc6.sockc.priority field added in ping_v6_sendmsg()
in patch 2/3.
- Update cmsg_so_priority.sh to test SO_PRIORITY sockopt and cmsg
setting with VLAN priority tagging in patch 3/3. (Ido Schimmel)
- Rebased on net-next.
v3:
https://lore.kernel.org/netdev/20241107132231.9271-1-annaemesenyiri@gmail.c…
- Updated cover letter text.
- Removed priority field from ipcm_cookie.
- Removed cork->tos value check from ip_setup_cork, so
cork->priority will now take its value from ipc->sockc.priority.
- Replaced ipc->priority with ipc->sockc.priority
in ip_cmsg_send().
- Modified the error handling for the SO_PRIORITY
case in __sock_cmsg_send().
- Added missing initialization for ipc6.sockc.priority.
- Introduced cmsg_so_priority.sh test script.
- Modified cmsg_sender.c to set priority via control message (cmsg).
- Rebased on net-next.
v2:
https://lore.kernel.org/netdev/20241102125136.5030-1-annaemesenyiri@gmail.c…
- Introduced sk_set_prio_allowed helper to check capability
for setting priority.
- Removed new fields and changed sockcm_cookie::priority
from char to u32 to align with sk_buff::priority.
- Moved the cork->tos value check for priority setting
from __ip_make_skb() to ip_setup_cork().
- Rebased on net-next.
v1:
https://lore.kernel.org/all/20241029144142.31382-1-annaemesenyiri@gmail.com/
Anna Emese Nyiri (4):
Introduce sk_set_prio_allowed helper function
support SO_PRIORITY cmsg
test SO_PRIORITY ancillary data with cmsg_sender
introduce SO_RCVPRIORITY socket option
arch/alpha/include/uapi/asm/socket.h | 2 +
arch/mips/include/uapi/asm/socket.h | 2 +
arch/parisc/include/uapi/asm/socket.h | 2 +
arch/sparc/include/uapi/asm/socket.h | 2 +
include/net/inet_sock.h | 2 +-
include/net/ip.h | 2 +-
include/net/sock.h | 8 +-
include/uapi/asm-generic/socket.h | 2 +
net/can/raw.c | 2 +-
net/core/sock.c | 26 ++-
net/ipv4/ip_output.c | 4 +-
net/ipv4/ip_sockglue.c | 2 +-
net/ipv4/raw.c | 2 +-
net/ipv6/ip6_output.c | 3 +-
net/ipv6/ping.c | 1 +
net/ipv6/raw.c | 3 +-
net/ipv6/udp.c | 1 +
net/packet/af_packet.c | 2 +-
net/socket.c | 11 ++
tools/include/uapi/asm-generic/socket.h | 2 +
tools/testing/selftests/net/Makefile | 1 +
tools/testing/selftests/net/cmsg_sender.c | 11 +-
.../testing/selftests/net/cmsg_so_priority.sh | 151 ++++++++++++++++++
23 files changed, 228 insertions(+), 16 deletions(-)
create mode 100755 tools/testing/selftests/net/cmsg_so_priority.sh
--
2.43.0
Currently, when we run the BPF selftests with the following command:
'make -C tools/testing/selftests TARGETS=bpf SKIP_TARGETS=""'
The command generates untracked files and directories:
'''
Untracked files:
(use "git add <file>..." to include in what will be committed)
tools/testing/selftests/bpfFEATURE-DUMP.selftests
tools/testing/selftests/bpffeature/
'''
The core reason is our Makefile(tools/testing/selftests/bpf/Makefile)
was written like this:
'''
OUTPUT := $(OUTPUT)/
$(eval include ../../../build/Makefile.feature)
OUTPUT := $(patsubst %/,%,$(OUTPUT))
'''
This way of assigning values to OUTPUT will never be effective for the
variable OUTPUT provided via the command argument and sub makefile called
like this(tools/testing/selftests/Makefile):
'''
all:
...
$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET
'''
As stated in the GNU make documentation:
'''
An argument that contains '=' specifies the value of a variable: 'v=x'
sets the value of the variable v to x. If you specify a value in this way,
all ordinary assignments of the same variable in the makefile are ignored;
we say they have been overridden by the command line argument.
'''
According to GNU make, we use override Directive to fix this issue:
'''
If you want to set the variable in the makefile even though it was set
with a command argument, you can use an override directive, which is a
line that looks like this:
override variable := value
Link: https://www.gnu.org/software/make/manual/make.html#Override-Directive
Fixes: dc3a8804d790 ("selftests/bpf: Adapt OUTPUT appending logic to lower versions of Make")
Signed-off-by: Jiayuan Chen <mrpre(a)163.com>
---
tools/testing/selftests/bpf/Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index 9e870e519c30..eb4d21651aa7 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -202,9 +202,9 @@ ifeq ($(shell expr $(MAKE_VERSION) \>= 4.4), 1)
$(let OUTPUT,$(OUTPUT)/,\
$(eval include ../../../build/Makefile.feature))
else
-OUTPUT := $(OUTPUT)/
+override OUTPUT := $(OUTPUT)/
$(eval include ../../../build/Makefile.feature)
-OUTPUT := $(patsubst %/,%,$(OUTPUT))
+override OUTPUT := $(patsubst %/,%,$(OUTPUT))
endif
endif
base-commit: a7c205120d339b6ad2557fe3f33fdf20394f1a0f
--
2.43.5
In commit 03c7527e97f7 ("KVM: arm64: Do not allow ID_AA64MMFR0_EL1.ASIDbits
to be overridden") we made that bitfield in the ID registers unwritable
however the change neglected to make the corresponding update to set_id_regs
resulting in it failing:
# ok 56 ID_AA64MMFR0_EL1_BIGEND
# ==== Test Assertion Failure ====
# aarch64/set_id_regs.c:434: masks[idx] & ftr_bits[j].mask == ftr_bits[j].mask
# pid=5566 tid=5566 errno=22 - Invalid argument
# 1 0x00000000004034a7: test_vm_ftr_id_regs at set_id_regs.c:434
# 2 0x0000000000401b53: main at set_id_regs.c:684
# 3 0x0000ffff8e6b7543: ?? ??:0
# 4 0x0000ffff8e6b7617: ?? ??:0
# 5 0x0000000000401e6f: _start at ??:?
# 0 != 0xf0 (masks[idx] & ftr_bits[j].mask != ftr_bits[j].mask)
not ok 8 selftests: kvm: set_id_regs # exit=254
Remove ID_AA64MMFR1_EL1.ASIDBITS from the set of bitfields we test for
writeability.
Fixes: 03c7527e97f7 ("KVM: arm64: Do not allow ID_AA64MMFR0_EL1.ASIDbits to be overridden")
Signed-off-by: Mark Brown <broonie(a)kernel.org>
---
tools/testing/selftests/kvm/aarch64/set_id_regs.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/tools/testing/selftests/kvm/aarch64/set_id_regs.c b/tools/testing/selftests/kvm/aarch64/set_id_regs.c
index a79b7f18452d2ec336ae623b8aa5c9cf329b6b4e..3a97c160b5fec990aaf8dfaf100a907b913f057c 100644
--- a/tools/testing/selftests/kvm/aarch64/set_id_regs.c
+++ b/tools/testing/selftests/kvm/aarch64/set_id_regs.c
@@ -152,7 +152,6 @@ static const struct reg_ftr_bits ftr_id_aa64mmfr0_el1[] = {
REG_FTR_BITS(FTR_LOWER_SAFE, ID_AA64MMFR0_EL1, BIGENDEL0, 0),
REG_FTR_BITS(FTR_LOWER_SAFE, ID_AA64MMFR0_EL1, SNSMEM, 0),
REG_FTR_BITS(FTR_LOWER_SAFE, ID_AA64MMFR0_EL1, BIGEND, 0),
- REG_FTR_BITS(FTR_LOWER_SAFE, ID_AA64MMFR0_EL1, ASIDBITS, 0),
REG_FTR_BITS(FTR_LOWER_SAFE, ID_AA64MMFR0_EL1, PARANGE, 0),
REG_FTR_END,
};
---
base-commit: 78d4f34e2115b517bcbfe7ec0d018bbbb6f9b0b8
change-id: 20241216-kvm-arm64-fix-set-id-asidbits-9bede25b7ad3
Best regards,
--
Mark Brown <broonie(a)kernel.org>
Hi All,
This patch-set aims to improve precision of BPF_MUL and add testcases
to illustrate precision gains using signed and unsigned bounds.
Thanks for taking the time to review and specifically for Eduard's feedback!
Best,
Matan
Changes from v1:
- Fixed typo made in patch
Changes from v2:
- Added signed multiplication to BPF_MUL
- Added test cases to exercise BPF_MUL
- Reordered patches in the series.
Matan Shachnai (2):
bpf, verifier: Improve precision of BPF_MUL
selftests/bpf: Add testcases for BPF_MUL
kernel/bpf/verifier.c | 72 +++++-----
.../selftests/bpf/progs/verifier_bounds.c | 134 ++++++++++++++++++
2 files changed, 166 insertions(+), 40 deletions(-)
--
2.25.1
If the selftest is not running as root, it should skip not
fail and give an appropriate warning to the user. This patch adds
ksft_exit_skip() if the test is not running as root.
Logs:
Before change:
TAP version 13
1..1
ok 1 # SKIP This test needs root to run!
After change:
TAP version 13
1..1
ok 2 # SKIP This test needs root to run!
Totals: pass:0 fail:0 xfail:0 xpass:0 skip:1 error:0
Signed-off-by: Shivam Chaudhary <cvam0000(a)gmail.com>
---
v1->v2 : Replace ksft_exit_fail_msg -> ksft_exit_skip
v1 : https://lore.kernel.org/all/20241115191721.621381-1-cvam0000@gmail.com/
tools/testing/selftests/acct/acct_syscall.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/acct/acct_syscall.c b/tools/testing/selftests/acct/acct_syscall.c
index e44e8fe1f4a3..87c044fb9293 100644
--- a/tools/testing/selftests/acct/acct_syscall.c
+++ b/tools/testing/selftests/acct/acct_syscall.c
@@ -24,7 +24,7 @@ int main(void)
// Check if test is run a root
if (geteuid()) {
- ksft_test_result_skip("This test needs root to run!\n");
+ ksft_exit_skip("This test needs root to run!\n");
return 1;
}
--
2.34.1
When adapting the test to the kselftest framework, a few printf() calls
indicating test progress were not updated.
Fix this by replacing these printf() calls by ksft_print_msg() calls.
Fixes: ce7d101750ff8450 ("selftests: timers: clocksource-switch: adapt to kselftest framework")
Signed-off-by: Geert Uytterhoeven <geert+renesas(a)glider.be>
Reviewed-by: Thomas Gleixner <tglx(a)linutronix.de>
---
v2:
- Add Reviewed-by.
When just running the test, the output looks like:
# Validating clocksource arch_sys_counter
TAP version 13
1..12
ok 1 CLOCK_REALTIME
...
# Validating clocksource ffca0000.timer
TAP version 13
1..12
ok 1 CLOCK_REALTIME
...
When redirecting the test output to a file, the progress prints are not
interspersed with the test output, but collated at the end:
TAP version 13
1..12
ok 1 CLOCK_REALTIME
...
TAP version 13
1..12
ok 1 CLOCK_REALTIME
...
# Totals: pass:6 fail:0 xfail:0 xpass:0 skip:6 error:0
# Validating clocksource arch_sys_counter
# Validating clocksource ffca0000.timer
...
This makes it hard to match the test results with the timer under test.
Is there a way to fix this? The test does use fork().
Thanks!
---
tools/testing/selftests/timers/clocksource-switch.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/timers/clocksource-switch.c b/tools/testing/selftests/timers/clocksource-switch.c
index c5264594064c8516..83faa4e354e389c2 100644
--- a/tools/testing/selftests/timers/clocksource-switch.c
+++ b/tools/testing/selftests/timers/clocksource-switch.c
@@ -156,8 +156,8 @@ int main(int argc, char **argv)
/* Check everything is sane before we start switching asynchronously */
if (do_sanity_check) {
for (i = 0; i < count; i++) {
- printf("Validating clocksource %s\n",
- clocksource_list[i]);
+ ksft_print_msg("Validating clocksource %s\n",
+ clocksource_list[i]);
if (change_clocksource(clocksource_list[i])) {
status = -1;
goto out;
@@ -169,7 +169,7 @@ int main(int argc, char **argv)
}
}
- printf("Running Asynchronous Switching Tests...\n");
+ ksft_print_msg("Running Asynchronous Switching Tests...\n");
pid = fork();
if (!pid)
return run_tests(runtime);
--
2.34.1
Hi all,
This patch series continues the work to migrate the script tests into
prog_tests.
test_xdp_meta.sh uses the BPF programs defined in progs/test_xdp_meta.c
to do a simple XDP/TC functional test that checks the metadata
allocation performed by the bpf_xdp_adjust_meta() helper.
This is already partly covered by two tests under prog_tests/:
- xdp_context_test_run.c uses bpf_prog_test_run_opts() to verify the
validity of the xdp_md context after a call to bpf_xdp_adjust_meta()
- xdp_metadata.c ensures that these meta-data can be exchanged through
an AF_XDP socket.
However test_xdp_meta.sh also verifies that the meta-data initialized
in the struct xdp_md is forwarded to the struct __sk_buff used by BPF
programs at 'TC level'. To cover this, I add a test case in
xdp_context_test_run.c that uses the same BPF programs from
progs/test_xdp_meta.c.
---
Changes in v2:
- Add missing close_netns()
- Use a unique 'close' label
- Link to v1: https://lore.kernel.org/r/20241206-xdp_meta-v1-0-5c150618f6e9@bootlin.com
---
Bastien Curutchet (2):
selftests/bpf: test_xdp_meta: Rename BPF sections
selftests/bpf: Migrate test_xdp_meta.sh into xdp_context_test_run.c
tools/testing/selftests/bpf/Makefile | 1 -
.../bpf/prog_tests/xdp_context_test_run.c | 87 ++++++++++++++++++++++
tools/testing/selftests/bpf/progs/test_xdp_meta.c | 4 +-
tools/testing/selftests/bpf/test_xdp_meta.sh | 58 ---------------
4 files changed, 89 insertions(+), 61 deletions(-)
---
base-commit: 0c30734c4f35c4784d3d3ca1bb89d9779045878c
change-id: 20241203-xdp_meta-868307cd0e03
Best regards,
--
Bastien Curutchet (eBPF Foundation) <bastien.curutchet(a)bootlin.com>