From patchwork Mon Aug 9 19:47:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Wang X-Patchwork-Id: 494224 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4B91C43214 for ; Mon, 9 Aug 2021 19:48:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 85B3560EB5 for ; Mon, 9 Aug 2021 19:48:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236191AbhHITsz (ORCPT ); Mon, 9 Aug 2021 15:48:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236185AbhHITsu (ORCPT ); Mon, 9 Aug 2021 15:48:50 -0400 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AD7DC06179F for ; Mon, 9 Aug 2021 12:48:16 -0700 (PDT) Received: by mail-pl1-x62b.google.com with SMTP id l11so6090108plk.6 for ; Mon, 09 Aug 2021 12:48:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OmM6Jh2wG8NHNQR7MWK2cVhqAuC5kqvoMNBPLIkIjok=; b=AOwR4z0XTEbEBQqzKL0s0VWoAS2otiHIQRmj7xZhJsKQGRCVbaHwi1Sc6OXqve2xBn jYd8l/YsCD30Vy314LDEog+QsSpUVntFinFf9IS2uzA9652nV+5dPCy1qr5L6VHC9WoX kJ7mzyRLz9l1E0XWvrOj/t9b5O8xTIVWvad28ufrjPrRvDjkHGdh3XbXzcEXeH8E4IsE a5XmQz1oSz2K/egJcVoDCCx1WCwo46xR5bcAbYy2N4RrGGfwhPiGmWbntw0iwN3sHyG6 FGDL6rdIzhkcqexExyugNvD3MT0hQFzOfMx4kA53w1abnUgANs6TgN4exMkfDPgOK3eH 1abQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OmM6Jh2wG8NHNQR7MWK2cVhqAuC5kqvoMNBPLIkIjok=; b=jnUb5Jmw5mwsL4gCq/YtWBeBD/e2l8tYCDDQYM4/6JpWLcgstqrGB/uXthy64d9aTG BZvlz/OXH1K+ZpOuWmdmZf0gs8wHhtRaDQm6WkddVEqTKHg03fGs0G8MOmWtrn8ygYp6 G1viJc8pyv+8oYcoilJqpLG7lrFkBM5XGDjU9bBI6V5BF91XfQ4tZuZjbl8MrwMoT52O zuUoCGv5vUi9XRG8WhhD4C48kMfN6LS97jX6hNUFXCW/wFdRx4W6p8l/PNUbvPo+Y3AX 1XjEy0JmnCKQMrrZAIGZA1kHkdlcPqknIsy6XRdVuRJX/1zGzEj1Q6JCal7JXX9+ZsGe 8Otg== X-Gm-Message-State: AOAM530fwNxscveh/JgCUDavgMe33LUL3U1oWPWXG5HLSC0e5NUa5Z3X Ic8nphFUEInugjaYUbg+KZPFx3LTMNp2TA== X-Google-Smtp-Source: ABdhPJwlGyWdQ3zFdvLNPAcH1eZbQinuozSjuWh/LsvNq9Fo/aJ7EAy2SuNOnieqGCiSGeeEDah2cQ== X-Received: by 2002:a17:902:6bc5:b029:12c:c275:ae10 with SMTP id m5-20020a1709026bc5b029012cc275ae10mr19298195plt.81.1628538495500; Mon, 09 Aug 2021 12:48:15 -0700 (PDT) Received: from ip-10-124-121-13.byted.org (ec2-54-241-92-238.us-west-1.compute.amazonaws.com. [54.241.92.238]) by smtp.gmail.com with ESMTPSA id x19sm21372291pfa.104.2021.08.09.12.48.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Aug 2021 12:48:15 -0700 (PDT) From: Jiang Wang To: netdev@vger.kernel.org Cc: cong.wang@bytedance.com, duanxiongchun@bytedance.com, xieyongji@bytedance.com, chaiwen.cc@bytedance.com, John Fastabend , "David S. Miller" , Jakub Kicinski , Daniel Borkmann , Jakub Sitnicki , Lorenz Bauer , Alexei Starovoitov , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , KP Singh , Shuah Khan , Al Viro , Christian Brauner , Johan Almbladh , linux-kernel@vger.kernel.org, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH bpf-next v6 4/5] selftest/bpf: change udp to inet in some function names Date: Mon, 9 Aug 2021 19:47:37 +0000 Message-Id: <20210809194742.1489985-5-jiang.wang@bytedance.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210809194742.1489985-1-jiang.wang@bytedance.com> References: <20210809194742.1489985-1-jiang.wang@bytedance.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This is to prepare for adding new unix stream tests. Mostly renames, also pass the socket types as an argument. Signed-off-by: Jiang Wang Reviewed-by: Cong Wang Acked-by: John Fastabend --- .../selftests/bpf/prog_tests/sockmap_listen.c | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/sockmap_listen.c b/tools/testing/selftests/bpf/prog_tests/sockmap_listen.c index 7a976d43281a..07ed8081f9ae 100644 --- a/tools/testing/selftests/bpf/prog_tests/sockmap_listen.c +++ b/tools/testing/selftests/bpf/prog_tests/sockmap_listen.c @@ -1692,14 +1692,14 @@ static void test_reuseport(struct test_sockmap_listen *skel, } } -static int udp_socketpair(int family, int *s, int *c) +static int inet_socketpair(int family, int type, int *s, int *c) { struct sockaddr_storage addr; socklen_t len; int p0, c0; int err; - p0 = socket_loopback(family, SOCK_DGRAM | SOCK_NONBLOCK); + p0 = socket_loopback(family, type | SOCK_NONBLOCK); if (p0 < 0) return p0; @@ -1708,7 +1708,7 @@ static int udp_socketpair(int family, int *s, int *c) if (err) goto close_peer0; - c0 = xsocket(family, SOCK_DGRAM | SOCK_NONBLOCK, 0); + c0 = xsocket(family, type | SOCK_NONBLOCK, 0); if (c0 < 0) { err = c0; goto close_peer0; @@ -1747,10 +1747,10 @@ static void udp_redir_to_connected(int family, int sock_mapfd, int verd_mapfd, zero_verdict_count(verd_mapfd); - err = udp_socketpair(family, &p0, &c0); + err = inet_socketpair(family, SOCK_DGRAM, &p0, &c0); if (err) return; - err = udp_socketpair(family, &p1, &c1); + err = inet_socketpair(family, SOCK_DGRAM, &p1, &c1); if (err) goto close_cli0; @@ -1825,7 +1825,7 @@ static void test_udp_redir(struct test_sockmap_listen *skel, struct bpf_map *map udp_skb_redir_to_connected(skel, map, family); } -static void udp_unix_redir_to_connected(int family, int sock_mapfd, +static void inet_unix_redir_to_connected(int family, int type, int sock_mapfd, int verd_mapfd, enum redir_mode mode) { const char *log_prefix = redir_mode_str(mode); @@ -1843,7 +1843,7 @@ static void udp_unix_redir_to_connected(int family, int sock_mapfd, return; c0 = sfd[0], p0 = sfd[1]; - err = udp_socketpair(family, &p1, &c1); + err = inet_socketpair(family, SOCK_DGRAM, &p1, &c1); if (err) goto close; @@ -1897,14 +1897,16 @@ static void udp_unix_skb_redir_to_connected(struct test_sockmap_listen *skel, return; skel->bss->test_ingress = false; - udp_unix_redir_to_connected(family, sock_map, verdict_map, REDIR_EGRESS); + inet_unix_redir_to_connected(family, SOCK_DGRAM, sock_map, verdict_map, + REDIR_EGRESS); skel->bss->test_ingress = true; - udp_unix_redir_to_connected(family, sock_map, verdict_map, REDIR_INGRESS); + inet_unix_redir_to_connected(family, SOCK_DGRAM, sock_map, verdict_map, + REDIR_INGRESS); xbpf_prog_detach2(verdict, sock_map, BPF_SK_SKB_VERDICT); } -static void unix_udp_redir_to_connected(int family, int sock_mapfd, +static void unix_inet_redir_to_connected(int family, int type, int sock_mapfd, int verd_mapfd, enum redir_mode mode) { const char *log_prefix = redir_mode_str(mode); @@ -1917,7 +1919,7 @@ static void unix_udp_redir_to_connected(int family, int sock_mapfd, zero_verdict_count(verd_mapfd); - err = udp_socketpair(family, &p0, &c0); + err = inet_socketpair(family, SOCK_DGRAM, &p0, &c0); if (err) return; @@ -1972,9 +1974,11 @@ static void unix_udp_skb_redir_to_connected(struct test_sockmap_listen *skel, return; skel->bss->test_ingress = false; - unix_udp_redir_to_connected(family, sock_map, verdict_map, REDIR_EGRESS); + unix_inet_redir_to_connected(family, SOCK_DGRAM, sock_map, verdict_map, + REDIR_EGRESS); skel->bss->test_ingress = true; - unix_udp_redir_to_connected(family, sock_map, verdict_map, REDIR_INGRESS); + unix_inet_redir_to_connected(family, SOCK_DGRAM, sock_map, verdict_map, + REDIR_INGRESS); xbpf_prog_detach2(verdict, sock_map, BPF_SK_SKB_VERDICT); }