diff mbox series

[v3,net,2/2] selftest: af_unix: Make SCM_RIGHTS into OOB data.

Message ID 20240517093138.1436323-3-mhal@rbox.co (mailing list archive)
State Accepted
Commit e060e433e51246d970c5a8aa1c5ccd9ecc7ba4bf
Delegated to: Netdev Maintainers
Headers show
Series af_unix: Fix GC and improve selftest | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/build_tools success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 1 maintainers not CCed: linux-kselftest@vger.kernel.org
netdev/build_clang success Errors and warnings before: 8 this patch: 8
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 8 this patch: 8
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 10 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-05-19--03-00 (tests: 1039)

Commit Message

Michal Luczaj May 17, 2024, 9:27 a.m. UTC
From: Kuniyuki Iwashima <kuniyu@amazon.com>

scm_rights.c covers various test cases for inflight file descriptors
and garbage collector for AF_UNIX sockets.

Currently, SCM_RIGHTS messages are sent with 3-bytes string, and it's
not good for MSG_OOB cases, as SCM_RIGTS cmsg goes with the first 2-bytes,
which is non-OOB data.

Let's send SCM_RIGHTS messages with 1-byte character to pack SCM_RIGHTS
into OOB data.

Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
---
 tools/testing/selftests/net/af_unix/scm_rights.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Michal Luczaj May 19, 2024, 8:44 a.m. UTC | #1
On 5/17/24 11:27, Michal Luczaj wrote:
> From: Kuniyuki Iwashima <kuniyu@amazon.com>
> 
> scm_rights.c covers various test cases for inflight file descriptors
> and garbage collector for AF_UNIX sockets.
> 
> Currently, SCM_RIGHTS messages are sent with 3-bytes string, and it's
> not good for MSG_OOB cases, as SCM_RIGTS cmsg goes with the first 2-bytes,
> which is non-OOB data.
> 
> Let's send SCM_RIGHTS messages with 1-byte character to pack SCM_RIGHTS
> into OOB data.
> 
> Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
> ---
>  tools/testing/selftests/net/af_unix/scm_rights.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/testing/selftests/net/af_unix/scm_rights.c b/tools/testing/selftests/net/af_unix/scm_rights.c
> index bab606c9f1eb..2bfed46e0b19 100644
> --- a/tools/testing/selftests/net/af_unix/scm_rights.c
> +++ b/tools/testing/selftests/net/af_unix/scm_rights.c
> @@ -197,8 +197,8 @@ void __send_fd(struct __test_metadata *_metadata,
>  	       const FIXTURE_VARIANT(scm_rights) *variant,
>  	       int inflight, int receiver)
>  {
> -#define MSG "nop"
> -#define MSGLEN 3
> +#define MSG "x"
> +#define MSGLEN 1
>  	struct {
>  		struct cmsghdr cmsghdr;
>  		int fd[2];

As discussed in
https://lore.kernel.org/netdev/20240517122419.0c9a0539@kernel.org/ :

Signed-off-by: Michal Luczaj <mhal@rbox.co>
diff mbox series

Patch

diff --git a/tools/testing/selftests/net/af_unix/scm_rights.c b/tools/testing/selftests/net/af_unix/scm_rights.c
index bab606c9f1eb..2bfed46e0b19 100644
--- a/tools/testing/selftests/net/af_unix/scm_rights.c
+++ b/tools/testing/selftests/net/af_unix/scm_rights.c
@@ -197,8 +197,8 @@  void __send_fd(struct __test_metadata *_metadata,
 	       const FIXTURE_VARIANT(scm_rights) *variant,
 	       int inflight, int receiver)
 {
-#define MSG "nop"
-#define MSGLEN 3
+#define MSG "x"
+#define MSGLEN 1
 	struct {
 		struct cmsghdr cmsghdr;
 		int fd[2];