From patchwork Thu Apr 25 03:23:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13642849 X-Patchwork-Delegate: bpf@iogearbox.net Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8BBEA22F0D; Thu, 25 Apr 2024 03:24:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714015473; cv=none; b=qzmDgV80HJBn2/oS3sSHKbfCYANwNdmWHr2H798goNPYruGmJx7m37b9veQZp3UHcrapO/MMZpnIuAv0HrHAkyN4ghaoEmvh/mV5f/m8Y5/ZARtyYw9wB2lIZo7afqR/GPkmHtnZM5mc+M9r+GrKDaGRiALJI+pwr5Fi3A1y3NU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714015473; c=relaxed/simple; bh=MslP5v/DhbDl30mweKw1fyNAy1kzzY7JRHIHzaxV3ZA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JfbpHVMoOR0VPnh46Gtig1JNT1dzdmFqQdqis2fSTaHf+X3c8SXxSc/IFIR32eDGPbU/ycPA9Edh1mz8+b60wlfLOpbI3xt/CllD+KNaT6V4bQBYPm03VoZ4l18D+roZr6nKqDNZoqf1qUDtQZMoBwhk/O/Voi9oOKsZ8TdRTRg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=W1JZ1yN2; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="W1JZ1yN2" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E577CC113CE; Thu, 25 Apr 2024 03:24:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714015471; bh=MslP5v/DhbDl30mweKw1fyNAy1kzzY7JRHIHzaxV3ZA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W1JZ1yN2sEzTY60+AWYk0dfLBmwEoulH7dLg8G8iLscHFVUVqjLgGKFI4zj2PYJaR N1VKmzcBAY5kiGD4K1jn/ZYhoxcRvM7YpnSr9Q19mkmYpp6dSAk2xdw17+0EfSVgHM smia4msG/d1cVf7izliMJrKupdI2PGwRd0Bmcxao4ddOuX5AukelUtHZ/wmIN1YOrP sGK/vGHopFQIYQjbr5hWFmemXg/qqb4VlMKfKFIa9YRsUQVTP1+3QdUYbrrOF/ucJP Z/GSJlAPP3ljJzzCHujF6C006fxpsYwM8U5WwV1eyH5jt8Z5sTHMEck8STRrYMxIqG f0XdHnUNfmQjg== From: Geliang Tang To: Andrii Nakryiko , Eduard Zingerman , Mykola Lysenko , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan Cc: Geliang Tang , bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, Geliang Tang Subject: [PATCH bpf-next 1/6] selftests/bpf: Add opts argument for __start_server Date: Thu, 25 Apr 2024 11:23:41 +0800 Message-Id: <127d2f0929980b41f757dcfebe1b667e6bfb43f1.1714014697.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: bpf@iogearbox.net From: Geliang Tang This patch adds network_helper_opts parameter for __start_server() instead of "int protocol" and "int timeout_ms". This not only reduces the number of parameters, but also makes it more flexible. Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf/network_helpers.c | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/tools/testing/selftests/bpf/network_helpers.c b/tools/testing/selftests/bpf/network_helpers.c index c134cd740638..b9d204a1a480 100644 --- a/tools/testing/selftests/bpf/network_helpers.c +++ b/tools/testing/selftests/bpf/network_helpers.c @@ -80,19 +80,19 @@ int settimeo(int fd, int timeout_ms) #define save_errno_close(fd) ({ int __save = errno; close(fd); errno = __save; }) -static int __start_server(int type, int protocol, const struct sockaddr *addr, - socklen_t addrlen, int timeout_ms, bool reuseport) +static int __start_server(int type, const struct sockaddr *addr, socklen_t addrlen, + bool reuseport, const struct network_helper_opts *opts) { int on = 1; int fd; - fd = socket(addr->sa_family, type, protocol); + fd = socket(addr->sa_family, type, opts->proto); if (fd < 0) { log_err("Failed to create server socket"); return -1; } - if (settimeo(fd, timeout_ms)) + if (settimeo(fd, opts->timeout_ms)) goto error_close; if (reuseport && @@ -123,14 +123,17 @@ static int __start_server(int type, int protocol, const struct sockaddr *addr, static int start_server_proto(int family, int type, int protocol, const char *addr_str, __u16 port, int timeout_ms) { + struct network_helper_opts opts = { + .timeout_ms = timeout_ms, + .proto = protocol, + }; struct sockaddr_storage addr; socklen_t addrlen; if (make_sockaddr(family, addr_str, port, &addr, &addrlen)) return -1; - return __start_server(type, protocol, (struct sockaddr *)&addr, - addrlen, timeout_ms, false); + return __start_server(type, (struct sockaddr *)&addr, addrlen, false, &opts); } int start_server(int family, int type, const char *addr_str, __u16 port, @@ -149,6 +152,9 @@ int start_mptcp_server(int family, const char *addr_str, __u16 port, int *start_reuseport_server(int family, int type, const char *addr_str, __u16 port, int timeout_ms, unsigned int nr_listens) { + struct network_helper_opts opts = { + .timeout_ms = timeout_ms, + }; struct sockaddr_storage addr; unsigned int nr_fds = 0; socklen_t addrlen; @@ -164,8 +170,7 @@ int *start_reuseport_server(int family, int type, const char *addr_str, if (!fds) return NULL; - fds[0] = __start_server(type, 0, (struct sockaddr *)&addr, addrlen, - timeout_ms, true); + fds[0] = __start_server(type, (struct sockaddr *)&addr, addrlen, true, &opts); if (fds[0] == -1) goto close_fds; nr_fds = 1; @@ -174,8 +179,7 @@ int *start_reuseport_server(int family, int type, const char *addr_str, goto close_fds; for (; nr_fds < nr_listens; nr_fds++) { - fds[nr_fds] = __start_server(type, 0, (struct sockaddr *)&addr, - addrlen, timeout_ms, true); + fds[nr_fds] = __start_server(type, (struct sockaddr *)&addr, addrlen, true, &opts); if (fds[nr_fds] == -1) goto close_fds; } @@ -193,8 +197,7 @@ int start_server_addr(int type, const struct sockaddr_storage *addr, socklen_t l if (!opts) opts = &default_opts; - return __start_server(type, 0, (struct sockaddr *)addr, len, - opts->timeout_ms, 0); + return __start_server(type, (struct sockaddr *)addr, len, 0, opts); } void free_fds(int *fds, unsigned int nr_close_fds) From patchwork Thu Apr 25 03:23:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13642850 X-Patchwork-Delegate: bpf@iogearbox.net Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CE6421CA89; Thu, 25 Apr 2024 03:24:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714015480; cv=none; b=PjFf3KwKRkztjAGWiU5OPGRZX4Pwzqd9oGfBCvEjAT7iQHC6bq5PCUxtQEiXfDxxDqXBMkCYOEmYozA+Gm/MLlSFRXz1EYkLeEAOEOQNi5qdMedENsgrkc8fgB35cSXQw3dZw7sqdgjK4VqYyBtse1WvG8rrQZViDP8vaDYkP1I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714015480; c=relaxed/simple; bh=ftlF6ggg6QPRW/a7JZR+Yl+pkGyisHVYkvLGCWEDrs4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PFGz4fRc9mZG8iWQXGSt8WjbWSwq8mKLR1Z8ozNDevyHt4Aihql5p8O8mJlqCa/q8KVjOw+DfpnMlJX4H6Ef0k1WO34kZ2ewDLET7JhVbolnA7WXcWh48+7P6c/G1N4Pve6Roy3uNaEhJQSU4WoMo5p7VZ1e8PW9dMtSYc7WOHg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MJ4d0rNG; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="MJ4d0rNG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 09956C113CC; Thu, 25 Apr 2024 03:24:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714015480; bh=ftlF6ggg6QPRW/a7JZR+Yl+pkGyisHVYkvLGCWEDrs4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MJ4d0rNGHLzzEjZMGxbt+cG+2S19D5eDwXh/JdrTDRwJ+r/QOpqEos38YlWno0iZv KH9oguB9utfSuE4xH8JWL5jWmlqM2OfIDKAOSra+D+AJOCzX3cLeqla/bd6HnVekeT 69Rmj9LHF5uajqfBLfmLk/pqJSjdT8b2rALlfLjerpc7NIZMvQHZMaLRBl2hOBd5zo Imdf+G5f+1wkJDso5z2LfHJDwt1mHT4ilzD+Obg7Eq9Ry3jaK+yNzUuBedxLqWBUn+ gwevGQxcvN0VBBsq2PvyDofotZVS8qwXTXr9Gs2nxcl36nO/4J0qGQeeRYMcf7Vkbl KeLqjVoQHK26A== From: Geliang Tang To: Andrii Nakryiko , Eduard Zingerman , Mykola Lysenko , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan Cc: Geliang Tang , bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, Geliang Tang Subject: [PATCH bpf-next 2/6] selftests/bpf: Make start_mptcp_server static Date: Thu, 25 Apr 2024 11:23:42 +0800 Message-Id: <50ec7049e280c60a2924937940851f8fee2b73b8.1714014697.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: bpf@iogearbox.net From: Geliang Tang start_mptcp_server() shouldn't be a public helper, it only be used in MPTCP tests. This patch moves it into prog_tests/mptcp.c, and implenments it using make_sockaddr() and start_server_addr() instead of using start_server_proto(). Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf/network_helpers.c | 7 ------- tools/testing/selftests/bpf/network_helpers.h | 2 -- tools/testing/selftests/bpf/prog_tests/mptcp.c | 16 ++++++++++++++++ 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/tools/testing/selftests/bpf/network_helpers.c b/tools/testing/selftests/bpf/network_helpers.c index b9d204a1a480..4f16f7d6ce3f 100644 --- a/tools/testing/selftests/bpf/network_helpers.c +++ b/tools/testing/selftests/bpf/network_helpers.c @@ -142,13 +142,6 @@ int start_server(int family, int type, const char *addr_str, __u16 port, return start_server_proto(family, type, 0, addr_str, port, timeout_ms); } -int start_mptcp_server(int family, const char *addr_str, __u16 port, - int timeout_ms) -{ - return start_server_proto(family, SOCK_STREAM, IPPROTO_MPTCP, addr_str, - port, timeout_ms); -} - int *start_reuseport_server(int family, int type, const char *addr_str, __u16 port, int timeout_ms, unsigned int nr_listens) { diff --git a/tools/testing/selftests/bpf/network_helpers.h b/tools/testing/selftests/bpf/network_helpers.h index 5a8c5cf4ec1a..c62b54daa914 100644 --- a/tools/testing/selftests/bpf/network_helpers.h +++ b/tools/testing/selftests/bpf/network_helpers.h @@ -49,8 +49,6 @@ extern struct ipv6_packet pkt_v6; int settimeo(int fd, int timeout_ms); int start_server(int family, int type, const char *addr, __u16 port, int timeout_ms); -int start_mptcp_server(int family, const char *addr, __u16 port, - int timeout_ms); int *start_reuseport_server(int family, int type, const char *addr_str, __u16 port, int timeout_ms, unsigned int nr_listens); diff --git a/tools/testing/selftests/bpf/prog_tests/mptcp.c b/tools/testing/selftests/bpf/prog_tests/mptcp.c index f84c74b87d23..3629d17b08ee 100644 --- a/tools/testing/selftests/bpf/prog_tests/mptcp.c +++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c @@ -104,6 +104,22 @@ static void cleanup_netns(struct nstoken *nstoken) SYS_NOFAIL("ip netns del %s", NS_TEST); } +static int start_mptcp_server(int family, const char *addr_str, __u16 port, + int timeout_ms) +{ + struct network_helper_opts opts = { + .timeout_ms = timeout_ms, + .proto = IPPROTO_MPTCP, + }; + struct sockaddr_storage addr; + socklen_t addrlen; + + if (make_sockaddr(family, addr_str, port, &addr, &addrlen)) + return -1; + + return start_server_addr(SOCK_STREAM, &addr, addrlen, &opts); +} + static int verify_tsk(int map_fd, int client_fd) { int err, cfd = client_fd; From patchwork Thu Apr 25 03:23:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13642851 X-Patchwork-Delegate: bpf@iogearbox.net Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 20CEC1CD2B; Thu, 25 Apr 2024 03:24:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714015489; cv=none; b=Z65Ogc9mQcVL4Wx/1Hj3LPLoRwY7WUU/VD6Ci+YUGRja7ADLSUaXOI6Sq8gn88esXMrx9FEFirW3c7YVtPBOgraFW7wnAvHhmaCXFM0UYrNaqZKZTt9c3v+afUTErabyTJeI/6WsbGEdT3ZZpMQou3evP2opuH2puhhPp5Ym7bk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714015489; c=relaxed/simple; bh=9+yIzx3EP2XgITiiTjTwmTvJqp8Yxc/T0zf9HG3dBbc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tTVvQBYaD2Xq3a2CrGfCbcF9Qz5kE5S1qfq7DK1pVMq2Js/e4SqIyenOCbd7wVozHgqnXZJYzU3ol9CinJSWuF8aLEnM0DVjhBMCUZZtCnB9aF2ZnoQY8OYNRJuw4yKRmbknPQ+4wDgaCH0VxXe6K9uBEJmyvf7Gv+64N0k61XI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=g/NnXh/S; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="g/NnXh/S" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3E139C2BD10; Thu, 25 Apr 2024 03:24:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714015488; bh=9+yIzx3EP2XgITiiTjTwmTvJqp8Yxc/T0zf9HG3dBbc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g/NnXh/Sko2uwi+bC2HZ43oJHXmJn88CqiQtAhtmoFnnqD/QKFRpKUwIGoLpG1NDx p6uRpzspA+w484Aw5XyDVmBo3dFvIDT0weLT2d1PSHRX8qjQsKupHQn5babPnX9VXf 4kkoJyXvvzv1uJTo7sEmDPYGGxoSpAQv/eo2fE4OAzXTycocNS3cpNwfjh8CUNG9m9 mkA8zccYk8tWjtfOAxIsWCv205+eAHuzHqVFFeurrQziZLruo/SQU8v4AEUUex8Wu8 KhgoEN8fuygtGKSaaN4l+gQDGwf2GOEhjGnJC/B5+ZItpkjDfUOXSIcn6bORfWMSge pNJX+ks9tKbjw== From: Geliang Tang To: Andrii Nakryiko , Eduard Zingerman , Mykola Lysenko , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan Cc: Geliang Tang , bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, Geliang Tang Subject: [PATCH bpf-next 3/6] selftests/bpf: Drop start_server_proto helper Date: Thu, 25 Apr 2024 11:23:43 +0800 Message-Id: <55d8a04e0bb8240a5fda2da3e9bdffe6fc8547b2.1714014697.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: bpf@iogearbox.net From: Geliang Tang Protocol can be set by __start_server() helper directly now, this makes the heler start_server_proto() useless. This patch drops it, and implenments start_server() using make_sockaddr() and __start_server(). Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf/network_helpers.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/tools/testing/selftests/bpf/network_helpers.c b/tools/testing/selftests/bpf/network_helpers.c index 4f16f7d6ce3f..1519f02f8090 100644 --- a/tools/testing/selftests/bpf/network_helpers.c +++ b/tools/testing/selftests/bpf/network_helpers.c @@ -120,12 +120,11 @@ static int __start_server(int type, const struct sockaddr *addr, socklen_t addrl return -1; } -static int start_server_proto(int family, int type, int protocol, - const char *addr_str, __u16 port, int timeout_ms) +int start_server(int family, int type, const char *addr_str, __u16 port, + int timeout_ms) { struct network_helper_opts opts = { .timeout_ms = timeout_ms, - .proto = protocol, }; struct sockaddr_storage addr; socklen_t addrlen; @@ -136,12 +135,6 @@ static int start_server_proto(int family, int type, int protocol, return __start_server(type, (struct sockaddr *)&addr, addrlen, false, &opts); } -int start_server(int family, int type, const char *addr_str, __u16 port, - int timeout_ms) -{ - return start_server_proto(family, type, 0, addr_str, port, timeout_ms); -} - int *start_reuseport_server(int family, int type, const char *addr_str, __u16 port, int timeout_ms, unsigned int nr_listens) { From patchwork Thu Apr 25 03:23:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13642852 X-Patchwork-Delegate: bpf@iogearbox.net Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C5D0B1CAA6; Thu, 25 Apr 2024 03:24:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714015498; cv=none; b=ptC4ijDTuCNay2SQDMjlmxbTHoN4DM14QGCmqdQAFeiPUuZeTtdCTfAypWYapFXr1Jrxy7AxPuwxD2KstbIre/oAlDuNL2ANw6ce5BzHCQbtnwjJB2/I1+z2m8OJQ/0BaNYsHM697z81KPQLhG8ppcVP/joQo3bw6tUGZR+gTjQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714015498; c=relaxed/simple; bh=vYkUUYP6hJn1TqZiTEfrLDiwxzbySFa0BQVMKzr7Kek=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=IChEoskiHQ+QX3NwL+9QPit0gUPogBqt7wEghJC8LD7zwgOhA/7bzY/Uv0EnoQRR77kGirjzJKhPLRYVI9r+7NWIjPvqpYIKhiL6hm+V3u9vDYj2vW3oQmdvu0JezydtkiK0xdVV8JYSSFsxBFZD3RDqu3at9AWQaaoMy1Q5Dls= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=d+NKzUGT; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="d+NKzUGT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 72DD9C32786; Thu, 25 Apr 2024 03:24:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714015498; bh=vYkUUYP6hJn1TqZiTEfrLDiwxzbySFa0BQVMKzr7Kek=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d+NKzUGTPx/caAUqEFYsXOtBlIckDxw9XzSF5yCNCf+f2ItkaHM6RwC+/Ktss1/IW ByrmwAaUramzUsjS9Nft6cTyYy1wXXp5TNupTwy5ZAbXYAtN/BDtTct6RHXICX6i48 Amxdid9v5i6r46SfiRNiBmxUOWExo+QuhA05RPY5CazlsLk6cq4kV7pmO89dYuF0D/ WHHm6pkU/VQQG/f1+XUCeshLFwkB+SpfsT6+nAbJ5xQyPXx4FRkZ5fmb4WC5n3dVEX BmZEuW6xLj/xb2jmcDMZcLzi6BnroUQxuJmetQZfjEHQkgCD30QhnHligqSvQQXzYq 6P5tvg0nFDE6A== From: Geliang Tang To: Andrii Nakryiko , Eduard Zingerman , Mykola Lysenko , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan Cc: Geliang Tang , bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, Geliang Tang Subject: [PATCH bpf-next 4/6] selftests/bpf: Add setsockopt for network_helper_opts Date: Thu, 25 Apr 2024 11:23:44 +0800 Message-Id: <0f676d51126bf7c260a71cfb60df0d1acb23e552.1714014697.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: bpf@iogearbox.net From: Geliang Tang __start_server() sets SO_REUSPORT through setsockopt() when the parameter 'reuseport' is set. This patch makes it more flexible by adding setsockopt function pointer, together with optval and optlen fields into struct network_helper_opts. Then 'reuseport' parameter can be dropped. Now the original start_reuseport_server() can be implemented by setting a newly defined setsockopt_reuseport() function pointer to setsockopt filed of struct network_helper_opts. Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf/network_helpers.c | 26 ++++++++++++------- tools/testing/selftests/bpf/network_helpers.h | 3 +++ 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/tools/testing/selftests/bpf/network_helpers.c b/tools/testing/selftests/bpf/network_helpers.c index 1519f02f8090..baeb4acf5fae 100644 --- a/tools/testing/selftests/bpf/network_helpers.c +++ b/tools/testing/selftests/bpf/network_helpers.c @@ -81,9 +81,8 @@ int settimeo(int fd, int timeout_ms) #define save_errno_close(fd) ({ int __save = errno; close(fd); errno = __save; }) static int __start_server(int type, const struct sockaddr *addr, socklen_t addrlen, - bool reuseport, const struct network_helper_opts *opts) + const struct network_helper_opts *opts) { - int on = 1; int fd; fd = socket(addr->sa_family, type, opts->proto); @@ -95,9 +94,9 @@ static int __start_server(int type, const struct sockaddr *addr, socklen_t addrl if (settimeo(fd, opts->timeout_ms)) goto error_close; - if (reuseport && - setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &on, sizeof(on))) { - log_err("Failed to set SO_REUSEPORT"); + if (opts->setsockopt && + opts->setsockopt(fd, opts->optval, opts->optlen)) { + log_err("Failed to set sockopt"); goto error_close; } @@ -132,14 +131,23 @@ int start_server(int family, int type, const char *addr_str, __u16 port, if (make_sockaddr(family, addr_str, port, &addr, &addrlen)) return -1; - return __start_server(type, (struct sockaddr *)&addr, addrlen, false, &opts); + return __start_server(type, (struct sockaddr *)&addr, addrlen, &opts); +} + +static int setsockopt_reuseport(int fd, const void *optval, socklen_t optlen) +{ + return setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, optval, optlen); } int *start_reuseport_server(int family, int type, const char *addr_str, __u16 port, int timeout_ms, unsigned int nr_listens) { + int on = 1; struct network_helper_opts opts = { .timeout_ms = timeout_ms, + .setsockopt = setsockopt_reuseport, + .optval = &on, + .optlen = sizeof(on), }; struct sockaddr_storage addr; unsigned int nr_fds = 0; @@ -156,7 +164,7 @@ int *start_reuseport_server(int family, int type, const char *addr_str, if (!fds) return NULL; - fds[0] = __start_server(type, (struct sockaddr *)&addr, addrlen, true, &opts); + fds[0] = __start_server(type, (struct sockaddr *)&addr, addrlen, &opts); if (fds[0] == -1) goto close_fds; nr_fds = 1; @@ -165,7 +173,7 @@ int *start_reuseport_server(int family, int type, const char *addr_str, goto close_fds; for (; nr_fds < nr_listens; nr_fds++) { - fds[nr_fds] = __start_server(type, (struct sockaddr *)&addr, addrlen, true, &opts); + fds[nr_fds] = __start_server(type, (struct sockaddr *)&addr, addrlen, &opts); if (fds[nr_fds] == -1) goto close_fds; } @@ -183,7 +191,7 @@ int start_server_addr(int type, const struct sockaddr_storage *addr, socklen_t l if (!opts) opts = &default_opts; - return __start_server(type, (struct sockaddr *)addr, len, 0, opts); + return __start_server(type, (struct sockaddr *)addr, len, opts); } void free_fds(int *fds, unsigned int nr_close_fds) diff --git a/tools/testing/selftests/bpf/network_helpers.h b/tools/testing/selftests/bpf/network_helpers.h index c62b54daa914..540ecfc52bd7 100644 --- a/tools/testing/selftests/bpf/network_helpers.h +++ b/tools/testing/selftests/bpf/network_helpers.h @@ -28,6 +28,9 @@ struct network_helper_opts { bool noconnect; int type; int proto; + int (*setsockopt)(int fd, const void *optval, socklen_t optlen); + const void *optval; + socklen_t optlen; }; /* ipv4 test vector */ From patchwork Thu Apr 25 03:23:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13642853 X-Patchwork-Delegate: bpf@iogearbox.net Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CAD961CAA6; Thu, 25 Apr 2024 03:25:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714015506; cv=none; b=sfpt8azDFHG0O1TuUEFblhorlM3CmAdlEdUi02hCK3OLyw03HlEWy2TwNe3tplDzrCRMqUgddCzzxPFTJqkEbpPr41QivSFCXF3pg3smeCA/hwDNeuhi3tWVPGln3gM3S98UDI9+kn1sKsYpcksxgZovTwFwE0Ayk5+0f4jzEAI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714015506; c=relaxed/simple; bh=GEmknfXbM8BqwBQteO+nfWsRu6fmsr9HCBaPQe0RqrQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YdvONeispqu0i+YT5FiFwFO5HQJW716houpbifCRB2bMoi3gsMVlVL5CGXcJ2nNapjrUrB91tE30dIWZzORkbnneOgbyxvfKwYoGm7CQC7hbafbasrfwnVoVOtcbJJXsfmTod5uWMFEWzvRPQkWFIOg4zSRAXlh5fC4GGRg8J6A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GlKz4JeO; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GlKz4JeO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ED83FC2BBFC; Thu, 25 Apr 2024 03:24:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714015506; bh=GEmknfXbM8BqwBQteO+nfWsRu6fmsr9HCBaPQe0RqrQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GlKz4JeOWbgobZzoCgKyFHH6cEPO0dsoJEvL4+g+Jyt3XnlkQIvWedxMsjreYqGtu zyyyTECvTj6zSDUM4NEpr/3TxeKfJbjlAjDXeT5pZb2XDXHC1hwKwyhKrjeJRLLwAH jjTu+sFuaJKpsz0XqBFGx0XUTmX0r2uSqXdkad+8ljXUv5WfQHM8iqBq66mR18eg5R WivLRVa/RJCpP5mNMNN054gY0T7734jNMpjHUqWeNaK7rFK+lFHkFOGlKL2BcF4UX3 aE9iHA09Tgtghy+jBSIjMnjGQ0uqQE+9cRr4s8s5vwnk1N2fxpWKuvnOMr9KsqfTMD vyFJQOJI1s5+g== From: Geliang Tang To: Andrii Nakryiko , Eduard Zingerman , Mykola Lysenko , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan Cc: Geliang Tang , bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, Geliang Tang Subject: [PATCH bpf-next 5/6] selftests/bpf: Use start_server_addr in sockopt_inherit Date: Thu, 25 Apr 2024 11:23:45 +0800 Message-Id: <53b6b85cbcdc9e3a7277d8e06c4b53c42dadbd5b.1714014697.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: bpf@iogearbox.net From: Geliang Tang Include network_helpers.h in prog_tests/sockopt_inherit.c, use public helper start_server_addr() instead of the local defined function start_server(). This can avoid duplicate code. Add a helper setsockopt_custom() to set SOL_CUSTOM sockopt looply, set it to setsockopt pointer of struct network_helper_opts, and pass it to start_server_addr(). Signed-off-by: Geliang Tang --- .../bpf/prog_tests/sockopt_inherit.c | 34 +++++++------------ 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/sockopt_inherit.c b/tools/testing/selftests/bpf/prog_tests/sockopt_inherit.c index 917f486db826..31cf7e9075da 100644 --- a/tools/testing/selftests/bpf/prog_tests/sockopt_inherit.c +++ b/tools/testing/selftests/bpf/prog_tests/sockopt_inherit.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 #include #include "cgroup_helpers.h" +#include "network_helpers.h" #include "sockopt_inherit.skel.h" @@ -98,23 +99,12 @@ static void *server_thread(void *arg) return (void *)(long)err; } -static int start_server(void) +static int setsockopt_custom(int fd, const void *optval, socklen_t optlen) { - struct sockaddr_in addr = { - .sin_family = AF_INET, - .sin_addr.s_addr = htonl(INADDR_LOOPBACK), - }; char buf; int err; - int fd; int i; - fd = socket(AF_INET, SOCK_STREAM, 0); - if (fd < 0) { - log_err("Failed to create server socket"); - return -1; - } - for (i = CUSTOM_INHERIT1; i <= CUSTOM_LISTENER; i++) { buf = 0x01; err = setsockopt(fd, SOL_CUSTOM, i, &buf, 1); @@ -125,20 +115,21 @@ static int start_server(void) } } - if (bind(fd, (const struct sockaddr *)&addr, sizeof(addr)) < 0) { - log_err("Failed to bind socket"); - close(fd); - return -1; - } - - return fd; + return 0; } static void run_test(int cgroup_fd) { struct bpf_link *link_getsockopt = NULL; struct bpf_link *link_setsockopt = NULL; + struct network_helper_opts opts = { + .setsockopt = setsockopt_custom, + }; int server_fd = -1, client_fd; + struct sockaddr_in addr = { + .sin_family = AF_INET, + .sin_addr.s_addr = htonl(INADDR_LOOPBACK), + }; struct sockopt_inherit *obj; void *server_err; pthread_t tid; @@ -160,8 +151,9 @@ static void run_test(int cgroup_fd) if (!ASSERT_OK_PTR(link_setsockopt, "cg-attach-setsockopt")) goto close_bpf_object; - server_fd = start_server(); - if (!ASSERT_GE(server_fd, 0, "start_server")) + server_fd = start_server_addr(SOCK_STREAM, (struct sockaddr_storage *)&addr, + sizeof(addr), &opts); + if (!ASSERT_GE(server_fd, 0, "start_server_addr")) goto close_bpf_object; pthread_mutex_lock(&server_started_mtx); From patchwork Thu Apr 25 03:23:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13642854 X-Patchwork-Delegate: bpf@iogearbox.net Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9FADB1CF8A; Thu, 25 Apr 2024 03:25:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714015517; cv=none; b=GBM2QYc8qsPTnSfKfgiA+KVxIdsve5GAVAWa0tNCwfErVEalycb+GVWEFu2JZ8/TvMeg1Pg6QNr8ggCuSa9y9loBTt4LSNmTew1gVgopCzeuLPsQ8spa8Hh5dP3wdpFMTI3tsL7JhpvjJHGAyGoy6+4cBxDMPl6nRSfdpRfMpqM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714015517; c=relaxed/simple; bh=KKa40t/UH/iVI8vNB195Mgml0vbWpiZwIBJwGi8S2/g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JDS9dX+qjgRLGDfqTmd8a0SyIV8RSUuwkN5eP3WlVd5F7oetMJDD9sA0WJKjJrB324Viiuy53hBv82WVC6kdQkOjgy0xLBWa5RLM9aHVOfVHk7BMWAk8UobfynWpmrDfw95RehoFQWSbdU11FJxk8BSLPq0u0LVo2Q5XOzGYkns= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nlzr+pFB; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="nlzr+pFB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 27EE6C4AF08; Thu, 25 Apr 2024 03:25:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714015517; bh=KKa40t/UH/iVI8vNB195Mgml0vbWpiZwIBJwGi8S2/g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nlzr+pFBrfyBl8kK3/4cpyuKJUdsfr6A/XVcKVXb2LDr08dEmLdsvsSZ6BaiCwxae tZqPzwcI6D/q2kLAJx8U/jeY5swwKXJ37YQk7eO51XqE1TW/QfgAnL/KE/eeZ3fVjW b5vR0+v7MlqsVDxqTcIqtvpF5MPUjzela2iuKwcJhVhUVXtu7pSYYnHfm1Ac2mrTf7 1P3fPNr63pcW/bL0R8lxob0zRlMO1qMCJ30C0Ys64N28PF8VdFBiTbJoXg8tzktaQq B0qTxU01i0tdc3KXbuE8ThXrMznDzZofuKSOwgBKkFtXeQavg/ESDvZriWpFsJiKxL xBQSdQ+DLDjbw== From: Geliang Tang To: Andrii Nakryiko , Eduard Zingerman , Mykola Lysenko , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan Cc: Geliang Tang , bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, Geliang Tang Subject: [PATCH bpf-next 6/6] selftests/bpf: Use start_server_addr in test_tcp_check_syncookie Date: Thu, 25 Apr 2024 11:23:46 +0800 Message-Id: <4be40922b4f10fe6b5da1e5898b46f322713b72e.1714014697.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: bpf@iogearbox.net From: Geliang Tang Include network_helpers.h in test_tcp_check_syncookie_user.c, use public helper start_server_addr() in it instead of the local defined function start_server(). This can avoid duplicate code. Add a helper setsockopt_v6only() to set IPV6_V6ONLY sockopt, set it to setsockopt pointer of struct network_helper_opts, and pass it to start_server_setsockopt(). In order to use functions defined in network_helpers.c, Makefile needs to be updated too. Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf/Makefile | 1 + .../bpf/test_tcp_check_syncookie_user.c | 64 ++++++------------- 2 files changed, 21 insertions(+), 44 deletions(-) diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile index 2182a5af68c4..b5496ebec594 100644 --- a/tools/testing/selftests/bpf/Makefile +++ b/tools/testing/selftests/bpf/Makefile @@ -297,6 +297,7 @@ $(OUTPUT)/flow_dissector_load: $(TESTING_HELPERS) $(OUTPUT)/test_maps: $(TESTING_HELPERS) $(OUTPUT)/test_verifier: $(TESTING_HELPERS) $(CAP_HELPERS) $(UNPRIV_HELPERS) $(OUTPUT)/xsk.o: $(BPFOBJ) +$(OUTPUT)/test_tcp_check_syncookie_user: $(NETWORK_HELPERS) BPFTOOL ?= $(DEFAULT_BPFTOOL) $(DEFAULT_BPFTOOL): $(wildcard $(BPFTOOLDIR)/*.[ch] $(BPFTOOLDIR)/Makefile) \ diff --git a/tools/testing/selftests/bpf/test_tcp_check_syncookie_user.c b/tools/testing/selftests/bpf/test_tcp_check_syncookie_user.c index 32df93747095..bf60d529d0e8 100644 --- a/tools/testing/selftests/bpf/test_tcp_check_syncookie_user.c +++ b/tools/testing/selftests/bpf/test_tcp_check_syncookie_user.c @@ -16,44 +16,7 @@ #include #include "cgroup_helpers.h" - -static int start_server(const struct sockaddr *addr, socklen_t len, bool dual) -{ - int mode = !dual; - int fd; - - fd = socket(addr->sa_family, SOCK_STREAM, 0); - if (fd == -1) { - log_err("Failed to create server socket"); - goto out; - } - - if (addr->sa_family == AF_INET6) { - if (setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, (char *)&mode, - sizeof(mode)) == -1) { - log_err("Failed to set the dual-stack mode"); - goto close_out; - } - } - - if (bind(fd, addr, len) == -1) { - log_err("Failed to bind server socket"); - goto close_out; - } - - if (listen(fd, 128) == -1) { - log_err("Failed to listen on server socket"); - goto close_out; - } - - goto out; - -close_out: - close(fd); - fd = -1; -out: - return fd; -} +#include "network_helpers.h" static int connect_to_server(const struct sockaddr *addr, socklen_t len) { @@ -216,8 +179,19 @@ static bool get_port(int server_fd, in_port_t *port) return true; } +static int setsockopt_v6only(int fd, const void *optval, socklen_t optlen) +{ + return setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, optval, optlen); +} + int main(int argc, char **argv) { + int mode = false; + struct network_helper_opts opts = { + .setsockopt = setsockopt_v6only, + .optval = &mode, + .optlen = sizeof(mode), + }; struct sockaddr_in addr4; struct sockaddr_in6 addr6; struct sockaddr_in addr4dual; @@ -259,18 +233,20 @@ int main(int argc, char **argv) addr6dual.sin6_addr = in6addr_any; addr6dual.sin6_port = 0; - server = start_server((const struct sockaddr *)&addr4, sizeof(addr4), - false); + server = start_server_addr(SOCK_STREAM, (struct sockaddr_storage *)&addr4, + sizeof(addr4), NULL); if (server == -1 || !get_port(server, &addr4.sin_port)) goto err; - server_v6 = start_server((const struct sockaddr *)&addr6, - sizeof(addr6), false); + mode = true; + server_v6 = start_server_addr(SOCK_STREAM, (struct sockaddr_storage *)&addr6, + sizeof(addr6), &opts); if (server_v6 == -1 || !get_port(server_v6, &addr6.sin6_port)) goto err; - server_dual = start_server((const struct sockaddr *)&addr6dual, - sizeof(addr6dual), true); + mode = false; + server_dual = start_server_addr(SOCK_STREAM, (struct sockaddr_storage *)&addr6dual, + sizeof(addr6dual), &opts); if (server_dual == -1 || !get_port(server_dual, &addr4dual.sin_port)) goto err;