diff options
author | Michal Luczaj <mhal@rbox.co> | 2025-05-22 02:18:24 +0300 |
---|---|---|
committer | Paolo Abeni <pabeni@redhat.com> | 2025-05-27 12:05:21 +0300 |
commit | 8b07b7e5c253981ccbab2f2506e07f5ef1082181 (patch) | |
tree | c61f6d39bec5e76d25b1e8bb7fcfaebac942c91c /tools/testing/vsock/util.c | |
parent | e78e0596c762609ee5a92bd9d38351694b52f249 (diff) | |
download | linux-8b07b7e5c253981ccbab2f2506e07f5ef1082181.tar.xz |
vsock/test: Introduce enable_so_linger() helper
Add a helper function that sets SO_LINGER. Adapt the caller.
Signed-off-by: Michal Luczaj <mhal@rbox.co>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Link: https://patch.msgid.link/20250522-vsock-linger-v6-4-2ad00b0e447e@rbox.co
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Diffstat (limited to 'tools/testing/vsock/util.c')
-rw-r--r-- | tools/testing/vsock/util.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tools/testing/vsock/util.c b/tools/testing/vsock/util.c index 4427d459e199..0c7e9cbcbc85 100644 --- a/tools/testing/vsock/util.c +++ b/tools/testing/vsock/util.c @@ -823,3 +823,16 @@ void enable_so_zerocopy_check(int fd) setsockopt_int_check(fd, SOL_SOCKET, SO_ZEROCOPY, 1, "setsockopt SO_ZEROCOPY"); } + +void enable_so_linger(int fd, int timeout) +{ + struct linger optval = { + .l_onoff = 1, + .l_linger = timeout + }; + + if (setsockopt(fd, SOL_SOCKET, SO_LINGER, &optval, sizeof(optval))) { + perror("setsockopt(SO_LINGER)"); + exit(EXIT_FAILURE); + } +} |