From patchwork Tue Jun 18 04:06:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 805479 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 BECC82595; Tue, 18 Jun 2024 04:07:43 +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=1718683663; cv=none; b=mEYF0ssrNZI17aoayCCCE4eDmMnGFD1cET64nX3Gn33wMZ6zKXFMs5zYBKbh/DA6VSmRT2S2YLUN53OEtKS7/FlEP9D3EtOoL4dMijlvvYdDEYv/m8QbsXOf4g10GtxyAeRt4StaOcoIuDPDv8wplcvum8/q9T7bxoEGAA1NiM4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718683663; c=relaxed/simple; bh=AsdAeRE0aIxwv2Q2OeCYD5fNH5nAbKhA8vWFDG9rv9s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mjBJJlzgt4r3/tbDLSNzc+HK6huicaOTajD0//S9SvdWHelkXKR/s8w3Thbqs44sWw/BpUENCcBHA5d1bp0BafUynZ1+W+srLE8cpnTj4zZJ2xsd+owW9qEY3kea2TWZlNxoSdEL1Zf+4y1Fj4uD/o5WS8YG2HteCufkL/wy1gA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mQtmsjyR; 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="mQtmsjyR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C2CAAC4AF1D; Tue, 18 Jun 2024 04:07:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718683663; bh=AsdAeRE0aIxwv2Q2OeCYD5fNH5nAbKhA8vWFDG9rv9s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mQtmsjyR4OIZK5ulmerThy/C/bLXVeJ4u19nClDAhpX1aX6+M18dgCYYO9gifyIil LbZ7I1LjzhITjU7pgXRTvSYV9PH/iYxLwaha5NjYy53nJJ1VDiZ5OAPzXwaZR3CrIu qPEToz77X+V0a/uc3GkSaIS64XaKLan395DOEG/vHnNH9TGWMpS298Mhk63aIuOkTP C1Hx8oYYg0VCNw1UesSQoPeBhh25Tfjk0lYQFIB4x9KAQeqXVu2cZQWHpGnCnQ+8gL 6cwHmfgFWmgT+t2pUYBh/ySCSlra3EGtpynuCUd9AWKQOdBNigYaWbDrrTNV9p0jHK p05GVUlHHyQ/w== 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 Subject: [PATCH bpf-next v4 1/6] selftests/bpf: Drop type from network_helper_opts Date: Tue, 18 Jun 2024 12:06:51 +0800 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang The opts.{type, noconnect} is at least a bit non intuitive or unnecessary. The only use case now is in test_bpf_ip_check_defrag_ok which ends up bypassing most (or at least some) of the connect_to_fd_opts() logic. It's much better that test should have its own connect_to_fd_opts() instead. This patch adds a new "type" parameter for connect_to_fd_opts(), then opts->type and getsockopt(SO_TYPE) can be replaced by "type" parameter in it. In connect_to_fd(), use getsockopt(SO_TYPE) to get "type" value and pass it to connect_to_fd_opts(). In bpf_tcp_ca.c and cgroup_v1v2.c, "SOCK_STREAM" types are passed to connect_to_fd_opts(), and in ip_check_defrag.c, different types "SOCK_RAW" and "SOCK_DGRAM" are passed to it. With these changes, the strcut member "type" of network_helper_opts can be dropped now. Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf/network_helpers.c | 26 +++++++++---------- tools/testing/selftests/bpf/network_helpers.h | 3 +-- .../selftests/bpf/prog_tests/bpf_tcp_ca.c | 2 +- .../selftests/bpf/prog_tests/cgroup_v1v2.c | 4 +-- .../bpf/prog_tests/ip_check_defrag.c | 5 ++-- 5 files changed, 18 insertions(+), 22 deletions(-) diff --git a/tools/testing/selftests/bpf/network_helpers.c b/tools/testing/selftests/bpf/network_helpers.c index e20caef06aae..c0efccaae488 100644 --- a/tools/testing/selftests/bpf/network_helpers.c +++ b/tools/testing/selftests/bpf/network_helpers.c @@ -303,27 +303,16 @@ int connect_to_addr(int type, const struct sockaddr_storage *addr, socklen_t add return -1; } -int connect_to_fd_opts(int server_fd, const struct network_helper_opts *opts) +int connect_to_fd_opts(int server_fd, int type, const struct network_helper_opts *opts) { struct sockaddr_storage addr; struct sockaddr_in *addr_in; socklen_t addrlen, optlen; - int fd, type, protocol; + int fd, protocol; if (!opts) opts = &default_opts; - optlen = sizeof(type); - - if (opts->type) { - type = opts->type; - } else { - if (getsockopt(server_fd, SOL_SOCKET, SO_TYPE, &type, &optlen)) { - log_err("getsockopt(SOL_TYPE)"); - return -1; - } - } - if (opts->proto) { protocol = opts->proto; } else { @@ -369,8 +358,17 @@ int connect_to_fd(int server_fd, int timeout_ms) struct network_helper_opts opts = { .timeout_ms = timeout_ms, }; + socklen_t optlen; + int type; + + optlen = sizeof(type); + + if (getsockopt(server_fd, SOL_SOCKET, SO_TYPE, &type, &optlen)) { + log_err("getsockopt(SOL_TYPE)"); + return -1; + } - return connect_to_fd_opts(server_fd, &opts); + return connect_to_fd_opts(server_fd, type, &opts); } int connect_fd_to_fd(int client_fd, int server_fd, int timeout_ms) diff --git a/tools/testing/selftests/bpf/network_helpers.h b/tools/testing/selftests/bpf/network_helpers.h index 11eea8e2e4f1..c92bed35dfe2 100644 --- a/tools/testing/selftests/bpf/network_helpers.h +++ b/tools/testing/selftests/bpf/network_helpers.h @@ -25,7 +25,6 @@ struct network_helper_opts { int timeout_ms; bool must_fail; bool noconnect; - int type; int proto; int (*post_socket_cb)(int fd, void *opts); void *cb_opts; @@ -61,7 +60,7 @@ void free_fds(int *fds, unsigned int nr_close_fds); int connect_to_addr(int type, const struct sockaddr_storage *addr, socklen_t len, const struct network_helper_opts *opts); int connect_to_fd(int server_fd, int timeout_ms); -int connect_to_fd_opts(int server_fd, const struct network_helper_opts *opts); +int connect_to_fd_opts(int server_fd, int type, const struct network_helper_opts *opts); int connect_fd_to_fd(int client_fd, int server_fd, int timeout_ms); int fastopen_connect(int server_fd, const char *data, unsigned int data_len, int timeout_ms); diff --git a/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c b/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c index 67358adf5db3..164f237b24dd 100644 --- a/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c +++ b/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c @@ -49,7 +49,7 @@ static bool start_test(char *addr_str, goto err; /* connect to server */ - *cli_fd = connect_to_fd_opts(*srv_fd, cli_opts); + *cli_fd = connect_to_fd_opts(*srv_fd, SOCK_STREAM, cli_opts); if (!ASSERT_NEQ(*cli_fd, -1, "connect_to_fd_opts")) goto err; diff --git a/tools/testing/selftests/bpf/prog_tests/cgroup_v1v2.c b/tools/testing/selftests/bpf/prog_tests/cgroup_v1v2.c index addf720428f7..9709c8db7275 100644 --- a/tools/testing/selftests/bpf/prog_tests/cgroup_v1v2.c +++ b/tools/testing/selftests/bpf/prog_tests/cgroup_v1v2.c @@ -32,7 +32,7 @@ static int run_test(int cgroup_fd, int server_fd, bool classid) goto out; } - fd = connect_to_fd_opts(server_fd, &opts); + fd = connect_to_fd_opts(server_fd, SOCK_STREAM, &opts); if (fd < 0) err = -1; else @@ -52,7 +52,7 @@ void test_cgroup_v1v2(void) server_fd = start_server(AF_INET, SOCK_STREAM, NULL, port, 0); if (!ASSERT_GE(server_fd, 0, "server_fd")) return; - client_fd = connect_to_fd_opts(server_fd, &opts); + client_fd = connect_to_fd_opts(server_fd, SOCK_STREAM, &opts); if (!ASSERT_GE(client_fd, 0, "client_fd")) { close(server_fd); return; diff --git a/tools/testing/selftests/bpf/prog_tests/ip_check_defrag.c b/tools/testing/selftests/bpf/prog_tests/ip_check_defrag.c index 284764e7179f..1607a05bf2c2 100644 --- a/tools/testing/selftests/bpf/prog_tests/ip_check_defrag.c +++ b/tools/testing/selftests/bpf/prog_tests/ip_check_defrag.c @@ -164,7 +164,6 @@ void test_bpf_ip_check_defrag_ok(bool ipv6) }; struct network_helper_opts tx_ops = { .timeout_ms = 1000, - .type = SOCK_RAW, .proto = IPPROTO_RAW, .noconnect = true, }; @@ -201,7 +200,7 @@ void test_bpf_ip_check_defrag_ok(bool ipv6) nstoken = open_netns(NS0); if (!ASSERT_OK_PTR(nstoken, "setns ns0")) goto out; - client_tx_fd = connect_to_fd_opts(srv_fd, &tx_ops); + client_tx_fd = connect_to_fd_opts(srv_fd, SOCK_RAW, &tx_ops); close_netns(nstoken); if (!ASSERT_GE(client_tx_fd, 0, "connect_to_fd_opts")) goto out; @@ -210,7 +209,7 @@ void test_bpf_ip_check_defrag_ok(bool ipv6) nstoken = open_netns(NS0); if (!ASSERT_OK_PTR(nstoken, "setns ns0")) goto out; - client_rx_fd = connect_to_fd_opts(srv_fd, &rx_opts); + client_rx_fd = connect_to_fd_opts(srv_fd, SOCK_DGRAM, &rx_opts); close_netns(nstoken); if (!ASSERT_GE(client_rx_fd, 0, "connect_to_fd_opts")) goto out; From patchwork Tue Jun 18 04:06:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 805802 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 CA7E02595; Tue, 18 Jun 2024 04:07:50 +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=1718683670; cv=none; b=oxpV2TDuIP2sgPrRMtLpgtsI9kE2HtOUT2XTCI6ImGykqel3kfM0zrLZOzYjXk2HTjfUSGLtoafXxRiZ0zQui1JAr4qF6mmYle/e6p0CJVujCi4p7XCecQeNoPdi3KZF49H3VhxiqOtD03DiPhZzydDTZzsGNPsusplsRV0j+X0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718683670; c=relaxed/simple; bh=0rjNeAgSfA9rNmcaBi7nAyQg190Rhp086VAjo0t8FUc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Cv7WQvN9sJH4db6lgO1BUADtJAleWQ/hF9yqfIoKporP1zDOv/y2OWaV0aEYaHzmHcHxq80taDuT8iKh1IYxZVmMrJDlNVjGbX+/Aoo1kDMh6I3usIAm8SE0TQna2q+J8XVFj7Sr/So5HTFh+cQasHsRp7xHCjJnaPMsRryqEzo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NAKm/Wc+; 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="NAKm/Wc+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 74305C4AF61; Tue, 18 Jun 2024 04:07:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718683670; bh=0rjNeAgSfA9rNmcaBi7nAyQg190Rhp086VAjo0t8FUc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NAKm/Wc+kgIy/A3ynTSuaNeyeEf4/W7uKewfwGlRnCTPGqRybSR4Nk2Rbx47okpgr /q7B+BnOak33HdsO4hQgxk+Ra+iK2C0ThXEWdWkRIKRaTGpc+DxxLbDqTR8czSslag kJpJMPlQqVUToL4buHugl7R3sKAQt8OYfecGgApdYyz6foJmSyPgHFmAPnFip54Do2 rg71X8ZYjkk5NzxBlMl/RBIrkB2yS4LRy43yneXICbJNTAFCsagJwuBKAZd7faOpZh 0VHBIBtVcdEq+JwbHwP+ctRNhEeJsiwq7wqsvmq2ZzARIpbeKhOzSIWMJeeQF8qKJ5 XfDi27K7W0loA== 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 Subject: [PATCH bpf-next v4 2/6] selftests/bpf: Use connect_to_addr in connect_to_fd_opt Date: Tue, 18 Jun 2024 12:06:52 +0800 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang This patch moves "post_socket_cb" and "noconnect" into connect_to_addr(), then connect_to_fd_opts() can be implemented by getsockname() and connect_to_addr(). This change makes connect_to_* interfaces more unified. Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf/network_helpers.c | 44 ++++--------------- 1 file changed, 8 insertions(+), 36 deletions(-) diff --git a/tools/testing/selftests/bpf/network_helpers.c b/tools/testing/selftests/bpf/network_helpers.c index c0efccaae488..16c2586c33ad 100644 --- a/tools/testing/selftests/bpf/network_helpers.c +++ b/tools/testing/selftests/bpf/network_helpers.c @@ -293,9 +293,14 @@ int connect_to_addr(int type, const struct sockaddr_storage *addr, socklen_t add if (settimeo(fd, opts->timeout_ms)) goto error_close; - if (connect_fd_to_addr(fd, addr, addrlen, opts->must_fail)) + if (opts->post_socket_cb && + opts->post_socket_cb(fd, opts->cb_opts)) goto error_close; + if (!opts->noconnect) + if (connect_fd_to_addr(fd, addr, addrlen, opts->must_fail)) + goto error_close; + return fd; error_close: @@ -306,51 +311,18 @@ int connect_to_addr(int type, const struct sockaddr_storage *addr, socklen_t add int connect_to_fd_opts(int server_fd, int type, const struct network_helper_opts *opts) { struct sockaddr_storage addr; - struct sockaddr_in *addr_in; - socklen_t addrlen, optlen; - int fd, protocol; + socklen_t addrlen; if (!opts) opts = &default_opts; - if (opts->proto) { - protocol = opts->proto; - } else { - if (getsockopt(server_fd, SOL_SOCKET, SO_PROTOCOL, &protocol, &optlen)) { - log_err("getsockopt(SOL_PROTOCOL)"); - return -1; - } - } - addrlen = sizeof(addr); if (getsockname(server_fd, (struct sockaddr *)&addr, &addrlen)) { log_err("Failed to get server addr"); return -1; } - addr_in = (struct sockaddr_in *)&addr; - fd = socket(addr_in->sin_family, type, protocol); - if (fd < 0) { - log_err("Failed to create client socket"); - return -1; - } - - if (settimeo(fd, opts->timeout_ms)) - goto error_close; - - if (opts->post_socket_cb && - opts->post_socket_cb(fd, opts->cb_opts)) - goto error_close; - - if (!opts->noconnect) - if (connect_fd_to_addr(fd, &addr, addrlen, opts->must_fail)) - goto error_close; - - return fd; - -error_close: - save_errno_close(fd); - return -1; + return connect_to_addr(type, &addr, addrlen, opts); } int connect_to_fd(int server_fd, int timeout_ms) From patchwork Tue Jun 18 04:06:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 805478 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 BFC782595; Tue, 18 Jun 2024 04:07:56 +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=1718683676; cv=none; b=WOlUlc0IfxuQSRJ2rZZyyGJLuRYUjUDf1J2kibQRuFqTv48jbltOETDztYVknmDxpYgDQJr4Q5Ps3+ELE4MGJyfQtR/lXBVUq8+tN2MIbFTev40xGUreFJCXu18qnCdNTM3FixuAP9GWtVDoOc+lhi5/QMRg2LL+joPslO9hLe4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718683676; c=relaxed/simple; bh=LgLu2BDQEqIlcROtCzfjnqir6VeDbEN4B9SGDbwbc4k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HHMzSYr3G8J+/K+UuME0DU28hhxGDvNmXHJhLAWZNaCWOuuTJ9MhIjuRc2vqgmWrS8kPFFyuMQfNBzdISWF2yBjnAe9ypoliityUGqnskUcu731pG3nxaajFZmyaJ18J8kzKoTTCctGVeZVg46UT+iqB1oOUk407SdOXsy95p2w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=K39SREdO; 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="K39SREdO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DEBF0C3277B; Tue, 18 Jun 2024 04:07:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718683676; bh=LgLu2BDQEqIlcROtCzfjnqir6VeDbEN4B9SGDbwbc4k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K39SREdOYyiSVf7CPcY+PD8radE6AEP23yN1jQVoZQwvVuMigkmF5HOPR8r/PDC8D Y1HIUbQ1+i5fC1T81hSsFTjUw/gW1RdZSsn0MvkmRU8UNuhUovAbOxwQrvpjSQcnIH pmoyHH8DT6XGPAhb080RT3UDo6hBUDKFDJkfuks/KmQ4fXxLQOe7+3lDC1M8NLfqpi CShM4wnrex7aepoYXZLu0oLl9ZhVgwMMmu8SKF+11ZfN2NlEVe5+XDTZyFLclkAJZe P3fxNVamcZuUsYl+Jmn/zdI0wXEbF0R4X5Loay42eoAkDIoOXrwBPSheXL/RNaDce9 +le9jJqh5cLKg== 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 Subject: [PATCH bpf-next v4 3/6] selftests/bpf: Add client_socket helper Date: Tue, 18 Jun 2024 12:06:53 +0800 Message-ID: <7413bca7c2c345ce8eaf3e63e51506faad41926c.1718683292.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang This patch extracts a new helper client_socket() from connect_to_fd_opts() to create the client socket, but don't connect to the server. Then connect_to_fd_opts() can be implemented using client_socket() and connect_fd_to_addr(). This helper can be used in connect_to_addr() too, and make "noconnect" opts useless. Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf/network_helpers.c | 37 +++++++++++++++---- tools/testing/selftests/bpf/network_helpers.h | 2 + 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/tools/testing/selftests/bpf/network_helpers.c b/tools/testing/selftests/bpf/network_helpers.c index 16c2586c33ad..47c86987de12 100644 --- a/tools/testing/selftests/bpf/network_helpers.c +++ b/tools/testing/selftests/bpf/network_helpers.c @@ -249,6 +249,34 @@ int fastopen_connect(int server_fd, const char *data, unsigned int data_len, return -1; } +int client_socket(int family, int type, + const struct network_helper_opts *opts) +{ + int fd; + + if (!opts) + opts = &default_opts; + + fd = socket(family, type, opts->proto); + if (fd < 0) { + log_err("Failed to create client socket"); + return -1; + } + + if (settimeo(fd, opts->timeout_ms)) + goto error_close; + + if (opts->post_socket_cb && + opts->post_socket_cb(fd, opts->cb_opts)) + goto error_close; + + return fd; + +error_close: + save_errno_close(fd); + return -1; +} + static int connect_fd_to_addr(int fd, const struct sockaddr_storage *addr, socklen_t addrlen, const bool must_fail) @@ -284,19 +312,12 @@ int connect_to_addr(int type, const struct sockaddr_storage *addr, socklen_t add if (!opts) opts = &default_opts; - fd = socket(addr->ss_family, type, opts->proto); + fd = client_socket(addr->ss_family, type, opts); if (fd < 0) { log_err("Failed to create client socket"); return -1; } - if (settimeo(fd, opts->timeout_ms)) - goto error_close; - - if (opts->post_socket_cb && - opts->post_socket_cb(fd, opts->cb_opts)) - goto error_close; - if (!opts->noconnect) if (connect_fd_to_addr(fd, addr, addrlen, opts->must_fail)) goto error_close; diff --git a/tools/testing/selftests/bpf/network_helpers.h b/tools/testing/selftests/bpf/network_helpers.h index c92bed35dfe2..e89eadfb02d6 100644 --- a/tools/testing/selftests/bpf/network_helpers.h +++ b/tools/testing/selftests/bpf/network_helpers.h @@ -57,6 +57,8 @@ int *start_reuseport_server(int family, int type, const char *addr_str, int start_server_addr(int type, const struct sockaddr_storage *addr, socklen_t len, const struct network_helper_opts *opts); void free_fds(int *fds, unsigned int nr_close_fds); +int client_socket(int family, int type, + const struct network_helper_opts *opts); int connect_to_addr(int type, const struct sockaddr_storage *addr, socklen_t len, const struct network_helper_opts *opts); int connect_to_fd(int server_fd, int timeout_ms); From patchwork Tue Jun 18 04:06:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 805801 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 82A9213A24B; Tue, 18 Jun 2024 04:08:03 +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=1718683683; cv=none; b=WoHLSaKd/xjIrc+m+HCQ7abs8B5SYMF07jAWNKgU6/ORfu4t2Al1EUw9xlIEATzJWZ8eZiK9xHcOhSsRfWZ5l5O3JQxIW8+KIejZ3/w7NUaTRzAUXAad5MwIUiWmB0a6/x8p6IokKfMDk719ZVAj6VDLBXvczAQy9yLDzPoWilM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718683683; c=relaxed/simple; bh=e/JLTeEFEAOhfmwQgh2DXqK3uTH/XxAWmI2jXxJrmAg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=diX5xHC3QupfTiHd4FMe/+2WJfrlLnkHWeag9TGn+DEka4o2T9pu2ZGkwS8zpL+1nfghofu4w3x56yv2cjkW+1kHpLfSMx78PPHGddOjRTPCXRAqKaZGlV4c6tSa3FsrhgNvbg1gJUIspYLnEMzXMKZFlCuiSBrXFBb2XIjvfhw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cAqAcrhN; 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="cAqAcrhN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5AEE6C4AF1D; Tue, 18 Jun 2024 04:07:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718683683; bh=e/JLTeEFEAOhfmwQgh2DXqK3uTH/XxAWmI2jXxJrmAg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cAqAcrhNcX4WjPzvxX4g8fP4VDQ2r75jel5Ectuw9rsdsqMVvKrvrY94KVbwQ+6u6 gRGUXmhH3ocdRvQS5C2mENtRcYH5Dqp6w+D9uRbnvtsPXwb0DbEUAjxi+oXGci4O0y gsHfVdn6PzuzkbpobJDTljtC/IsWboEzoZjI9QWx74lO8bYFPmfc4cWkfZ69NgaPek 3QrJFlRM5aoPpTB0AuRmdiYu/OI3TjNjIcPOMfcgA7I1F6hbwQntoCE3t1RWBZXyIU 8UBRwG0k4pjUfwZ2DpY+m8TOOgNRmmxeZYdVPyWGsz12JjEVFrD+GuwPIfU20BXP4k gUIBRadbMSOoQ== 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 Subject: [PATCH bpf-next v4 4/6] selftests/bpf: Drop noconnect from network_helper_opts Date: Tue, 18 Jun 2024 12:06:54 +0800 Message-ID: <9fdafce163de5e89a1d45527154dff88cbb6722f.1718683292.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang In test_bpf_ip_check_defrag_ok(), the new helper client_socket() can be used to replace connect_to_fd_opts() with "noconnect" opts, and the strcut member "noconnect" of network_helper_opts can be dropped now, always connect to server in connect_to_fd_opts(). Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf/network_helpers.c | 5 ++--- tools/testing/selftests/bpf/network_helpers.h | 1 - tools/testing/selftests/bpf/prog_tests/ip_check_defrag.c | 9 ++++----- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/tools/testing/selftests/bpf/network_helpers.c b/tools/testing/selftests/bpf/network_helpers.c index 47c86987de12..a8d65f5845ce 100644 --- a/tools/testing/selftests/bpf/network_helpers.c +++ b/tools/testing/selftests/bpf/network_helpers.c @@ -318,9 +318,8 @@ int connect_to_addr(int type, const struct sockaddr_storage *addr, socklen_t add return -1; } - if (!opts->noconnect) - if (connect_fd_to_addr(fd, addr, addrlen, opts->must_fail)) - goto error_close; + if (connect_fd_to_addr(fd, addr, addrlen, opts->must_fail)) + goto error_close; return fd; diff --git a/tools/testing/selftests/bpf/network_helpers.h b/tools/testing/selftests/bpf/network_helpers.h index e89eadfb02d6..9ea36524b9db 100644 --- a/tools/testing/selftests/bpf/network_helpers.h +++ b/tools/testing/selftests/bpf/network_helpers.h @@ -24,7 +24,6 @@ typedef __u16 __sum16; struct network_helper_opts { int timeout_ms; bool must_fail; - bool noconnect; int proto; int (*post_socket_cb)(int fd, void *opts); void *cb_opts; diff --git a/tools/testing/selftests/bpf/prog_tests/ip_check_defrag.c b/tools/testing/selftests/bpf/prog_tests/ip_check_defrag.c index 1607a05bf2c2..e73da3de5bf6 100644 --- a/tools/testing/selftests/bpf/prog_tests/ip_check_defrag.c +++ b/tools/testing/selftests/bpf/prog_tests/ip_check_defrag.c @@ -158,14 +158,13 @@ static int send_frags6(int client) void test_bpf_ip_check_defrag_ok(bool ipv6) { + int family = ipv6 ? AF_INET6 : AF_INET; struct network_helper_opts rx_opts = { .timeout_ms = 1000, - .noconnect = true, }; struct network_helper_opts tx_ops = { .timeout_ms = 1000, .proto = IPPROTO_RAW, - .noconnect = true, }; struct sockaddr_storage caddr; struct ip_check_defrag *skel; @@ -191,7 +190,7 @@ void test_bpf_ip_check_defrag_ok(bool ipv6) nstoken = open_netns(NS1); if (!ASSERT_OK_PTR(nstoken, "setns ns1")) goto out; - srv_fd = start_server(ipv6 ? AF_INET6 : AF_INET, SOCK_DGRAM, NULL, SERVER_PORT, 0); + srv_fd = start_server(family, SOCK_DGRAM, NULL, SERVER_PORT, 0); close_netns(nstoken); if (!ASSERT_GE(srv_fd, 0, "start_server")) goto out; @@ -200,7 +199,7 @@ void test_bpf_ip_check_defrag_ok(bool ipv6) nstoken = open_netns(NS0); if (!ASSERT_OK_PTR(nstoken, "setns ns0")) goto out; - client_tx_fd = connect_to_fd_opts(srv_fd, SOCK_RAW, &tx_ops); + client_tx_fd = client_socket(family, SOCK_RAW, &tx_ops); close_netns(nstoken); if (!ASSERT_GE(client_tx_fd, 0, "connect_to_fd_opts")) goto out; @@ -209,7 +208,7 @@ void test_bpf_ip_check_defrag_ok(bool ipv6) nstoken = open_netns(NS0); if (!ASSERT_OK_PTR(nstoken, "setns ns0")) goto out; - client_rx_fd = connect_to_fd_opts(srv_fd, SOCK_DGRAM, &rx_opts); + client_rx_fd = client_socket(family, SOCK_DGRAM, &rx_opts); close_netns(nstoken); if (!ASSERT_GE(client_rx_fd, 0, "connect_to_fd_opts")) goto out; From patchwork Tue Jun 18 04:06:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 805477 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 3BE071386A7; Tue, 18 Jun 2024 04:08:10 +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=1718683690; cv=none; b=gAWk9L8/CaDGtn/g3KgOLxJA/J4qcm6uMMgf9F/O+bLpkuq8n2OC8f6ggspR0HmrdlBF8TIWdnxyteHQoj4nrTb8HFMI2Ho0FcFInQrGqf/0A6PMnBaoVD4qxYgXFopU+gLbRaMG6e1eG1SXOC7P0xKJCg/rZVOFpiFJTT89V5Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718683690; c=relaxed/simple; bh=QDeYipd1o0V9wiiSdEf3dBRvIuDzcvSCSFdjltKsxtY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HfL6MboZ8azZBvPy7L/GgiNL7nOPFY68KZGw3iWYLH/X2vwL2qBv5m/v6BLAmsn3eNk/E8wNZrgSZEUAty+E9UvqmP/pVyluuphfguLBdu4/zDcLfWAjf+Rfzz4Cg/TLgquQ/ql1Rbu8vsXCyifvPSLEqGjmPZzoEfYdUqRxdxY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RiY5zGr1; 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="RiY5zGr1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ADCE6C4AF48; Tue, 18 Jun 2024 04:08:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718683690; bh=QDeYipd1o0V9wiiSdEf3dBRvIuDzcvSCSFdjltKsxtY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RiY5zGr1X/TnIOkszWyDmNWOqvc4spKG03xPir5P9cqjFF81PXMOmD6Z3gqYrUss8 gYdCMnJrfEEOBCOquX4mqhfDS75XbLN6vm1tniPMZj/79ZGosoiDsE4MA75/Yhw6Go wvzgbXn34VAlsmewuMtlr1ZpRmoMVePm/Wb896YTsekMdWUoK5GJGoM+MPzfI6K2mU SUtPGrYgPgZOIu+1JVq33GeaTkDJlj67EZnNCJn45kPWGU0jtqkiTg5UVWtphclDmE JpzTX4tX02XISK3x4bbWVMcn+ngjqgpe9c0eo+uJ0PhGkiDP4XTkKfcz7kivevYGe9 kgpgbuWVxx90g== 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 Subject: [PATCH bpf-next v4 5/6] selftests/bpf: Use start_server_str in mptcp Date: Tue, 18 Jun 2024 12:06:55 +0800 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang Since start_server_str() is added now, it can be used in mptcp.c in start_mptcp_server() instead of using helpers make_sockaddr() and start_server_addr() to simplify the code. Signed-off-by: Geliang Tang Acked-by: Eduard Zingerman --- tools/testing/selftests/bpf/prog_tests/mptcp.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/mptcp.c b/tools/testing/selftests/bpf/prog_tests/mptcp.c index 274d2e033e39..d2ca32fa3b21 100644 --- a/tools/testing/selftests/bpf/prog_tests/mptcp.c +++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c @@ -89,13 +89,8 @@ static int start_mptcp_server(int family, const char *addr_str, __u16 port, .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); + return start_server_str(family, SOCK_STREAM, addr_str, port, &opts); } static int verify_tsk(int map_fd, int client_fd) From patchwork Tue Jun 18 04:06:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 805800 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 E2AF115532B; Tue, 18 Jun 2024 04:08:16 +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=1718683697; cv=none; b=HXzuy0x64RGnb2+SmdsEComJxru+mqZB3/11pm2P8QxK561IyjnNCQ6sqvs3Cknb0d+h1qSy8E5eWAC9SFXm+Iuudny9w5tNSOBvmhgCGHyFmX6TLMp36n3EyYWt3VWq+VGbkdAazrAaL2fwxfZGMfM/faoyYZSzMMAinAzc9KM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718683697; c=relaxed/simple; bh=ek0iCBSuhwxmBUkXZ25YiD2CARKWMEhFftoQUiEh56g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NNk8I8Jpm2wpS0AlOan8n/qR2J4EBdVLB74n0M3uaThuTUSfmNoZwEcNFhF9e2YfkiHR2tl30jPPmmYTiwlB8Z5JTlUcgmMMHQowJ0nY/0y1HVFiBvholcqJjtaqOIKAimWHc6uj3vbJAOWQ7L5eH2FvkFF+uIe2bPBDhnzY7Es= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=N4Z/UG/T; 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="N4Z/UG/T" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A859CC4AF51; Tue, 18 Jun 2024 04:08:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718683696; bh=ek0iCBSuhwxmBUkXZ25YiD2CARKWMEhFftoQUiEh56g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N4Z/UG/T7SUK8hVg9+Z5E4EY/NLjAMgD5PbeatzY0Kk48bEjsEviq40KyMPSyi0jU NrP9BCnMDIQ4AagiGefw8+sa0DTssBuEn6yo7Ag5H6ZYrJlQFqRLK4fCzKg/1sO4su JnAS2ZNCFy1e/cMmu0ZQ5xQR0RLaL63yHNZ7/Rxu+3vHQWYbvkQJZGv/EDCZUaPEb2 0PIAVM7kU32EfE65rsBVIOxKkbjHxzWwJ621knVJ06UyhdO9MFsq2dwy4cn+5d5O8x Cx3HchCng0+p0cpyWRnb+5AgDvHVwYMtW/sP4/0cxfDfZVtLiaXAmWYKUd6IzM/sMo Zrn5g/XoCvb8A== 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 Subject: [PATCH bpf-next v4 6/6] selftests/bpf: Use start_server_str in test_tcp_check_syncookie_user Date: Tue, 18 Jun 2024 12:06:56 +0800 Message-ID: <8cb3e3d02ff076666492e30a5e75098c8124519e.1718683292.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang Since start_server_str() is added now, it can be used in script test_tcp_check_syncookie_user.c instead of start_server_addr() to simplify the code. Signed-off-by: Geliang Tang Acked-by: Eduard Zingerman --- .../bpf/test_tcp_check_syncookie_user.c | 29 ++----------------- 1 file changed, 3 insertions(+), 26 deletions(-) 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 aebc58c24dc5..3844f9b8232a 100644 --- a/tools/testing/selftests/bpf/test_tcp_check_syncookie_user.c +++ b/tools/testing/selftests/bpf/test_tcp_check_syncookie_user.c @@ -156,10 +156,6 @@ static int v6only_false(int fd, void *opts) int main(int argc, char **argv) { struct network_helper_opts opts = { 0 }; - struct sockaddr_in addr4; - struct sockaddr_in6 addr6; - struct sockaddr_in addr4dual; - struct sockaddr_in6 addr6dual; int server = -1; int server_v6 = -1; int server_dual = -1; @@ -181,36 +177,17 @@ int main(int argc, char **argv) goto err; } - memset(&addr4, 0, sizeof(addr4)); - addr4.sin_family = AF_INET; - addr4.sin_addr.s_addr = htonl(INADDR_LOOPBACK); - addr4.sin_port = 0; - memcpy(&addr4dual, &addr4, sizeof(addr4dual)); - - memset(&addr6, 0, sizeof(addr6)); - addr6.sin6_family = AF_INET6; - addr6.sin6_addr = in6addr_loopback; - addr6.sin6_port = 0; - - memset(&addr6dual, 0, sizeof(addr6dual)); - addr6dual.sin6_family = AF_INET6; - addr6dual.sin6_addr = in6addr_any; - addr6dual.sin6_port = 0; - - server = start_server_addr(SOCK_STREAM, (struct sockaddr_storage *)&addr4, - sizeof(addr4), NULL); + server = start_server_str(AF_INET, SOCK_STREAM, "127.0.0.1", 0, NULL); if (server == -1) goto err; opts.post_socket_cb = v6only_true; - server_v6 = start_server_addr(SOCK_STREAM, (struct sockaddr_storage *)&addr6, - sizeof(addr6), &opts); + server_v6 = start_server_str(AF_INET6, SOCK_STREAM, "::1", 0, &opts); if (server_v6 == -1) goto err; opts.post_socket_cb = v6only_false; - server_dual = start_server_addr(SOCK_STREAM, (struct sockaddr_storage *)&addr6dual, - sizeof(addr6dual), &opts); + server_dual = start_server_str(AF_INET6, SOCK_STREAM, "::0", 0, &opts); if (server_dual == -1) goto err;