Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2360559pxk; Mon, 14 Sep 2020 11:11:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwj+6JJEkWVP1Jl1M95IjiWeNvb7dm6ESfmMUXTp6Yb0m4B0Iq/VIALGL0XkBa+85G0Jg9G X-Received: by 2002:a17:906:a415:: with SMTP id l21mr15143976ejz.431.1600107080607; Mon, 14 Sep 2020 11:11:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600107080; cv=none; d=google.com; s=arc-20160816; b=ko98EigxfrAWG0PfxkEptTLJbFXFXJRWotQS91VP1sDMVd6SO/qOLIFH3KwX/QdSxA 6Iq7XsJX3GBbeMuU6+wVQDdCezR3mQBa0cpXb1RiPt+0bMXluzRxXXOpqMP/xdlqVa9U t0a2uo3Ht5lMrAk2J4hu8jA/Dwb8itKFMFQsmFPZUQsvGLPbR4SffU17McxCEgUwdggu 7Ap0zw8UUiWHraZnnthDwpyEBm0QleD2fzVkqAhVfbcS6LgPI8Phnmd38LULi06lPB84 +X4Dlg+PBn9KQUWgFrRA8y2djR2dw5HQHcffEOeezmMZX5ndIks+3GxQzChIaRGUOirk uWJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=8DNnTh738slHGq9EY4ikUHcYZZOVSwyZglM9SUsqV/Q=; b=q4CimPWGQxn/CBcfFJ/fHYnRtHF6ydHakv0bjsiqkFyMCWn2zT1Qwl0wXxAtsowiCS JoT5230AeRcIQ3PpxxzOI3MLgijZU3i7p+1p4n6j+2XDVm1fRUKm58jiX6YKk8A6B2L5 knV+N/HZjQnPqSacHoxCshYkdFQfI++g1gnWL5KOmuWbIJ+ObfSMLbHKIZRD8erKU2mM 8KDJcuRmydEW7KU3wGkge6RrJZpBk9PlvUCObGwRzIXQk9qguZ6WtIrjtv6nrtFOJ7Qm JVrYokStd/1UC5NrmlI7m3GFonUEZFCbhUPjwjtWZu0Kwc53FLZ4i6bnsCUnF8NO/xHL rcUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=NFTeoWN5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a8si7120304ejs.101.2020.09.14.11.10.58; Mon, 14 Sep 2020 11:11:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=NFTeoWN5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726150AbgINSID (ORCPT + 99 others); Mon, 14 Sep 2020 14:08:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:38334 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726142AbgINSHp (ORCPT ); Mon, 14 Sep 2020 14:07:45 -0400 Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E328421BE5; Mon, 14 Sep 2020 18:07:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600106864; bh=urbtEzAStq9D8KVHTpwpJn7jcktQ6xC9fDu3gqRUPFY=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=NFTeoWN5BtSyuRAkk3F3SSt0TKQNWr5/wwsVvf2VWeFhvOic4nJw99gnG4AI5nCk2 fVtUprdLbmrmRpszi0/2pIvVrivYCeEIcFu0qw2qKEygXwV4EA0RwiQ3dZcDLjLg8U G3PXt85ubBilRmGyyCaN3nv244fWnikl+9wGDjd8= Received: by mail-lf1-f49.google.com with SMTP id m5so251456lfp.7; Mon, 14 Sep 2020 11:07:43 -0700 (PDT) X-Gm-Message-State: AOAM531tdWmu5PJcAvQbHvJv6mL/64onvHLXXB0nPJjh6ibB2y3g5lN6 FolqOERlnf3gXu9t6qglIgnshGToxpcLuoKCRHQ= X-Received: by 2002:a19:8907:: with SMTP id l7mr4802438lfd.105.1600106862141; Mon, 14 Sep 2020 11:07:42 -0700 (PDT) MIME-Version: 1.0 References: <20200911143022.414783-1-nicolas.rybowski@tessares.net> <20200911143022.414783-4-nicolas.rybowski@tessares.net> In-Reply-To: <20200911143022.414783-4-nicolas.rybowski@tessares.net> From: Song Liu Date: Mon, 14 Sep 2020 11:07:30 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH bpf-next v2 4/5] bpf: selftests: add MPTCP test base To: Nicolas Rybowski Cc: Shuah Khan , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , Andrii Nakryiko , John Fastabend , KP Singh , Matthieu Baerts , open list , linux-kselftest@vger.kernel.org, Networking , bpf Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 11, 2020 at 8:02 AM Nicolas Rybowski wrote: > > This patch adds a base for MPTCP specific tests. > > It is currently limited to the is_mptcp field in case of plain TCP > connection because for the moment there is no easy way to get the subflow > sk from a msk in userspace. This implies that we cannot lookup the > sk_storage attached to the subflow sk in the sockops program. > > Acked-by: Matthieu Baerts > Signed-off-by: Nicolas Rybowski Acked-by: Song Liu With some nitpicks below. > --- > > Notes: > v1 -> v2: > - new patch: mandatory selftests (Alexei) > [...] > int timeout_ms); > diff --git a/tools/testing/selftests/bpf/prog_tests/mptcp.c b/tools/testing/selftests/bpf/prog_tests/mptcp.c > new file mode 100644 > index 000000000000..0e65d64868e9 > --- /dev/null > +++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c > @@ -0,0 +1,119 @@ > +// SPDX-License-Identifier: GPL-2.0 > +#include > +#include "cgroup_helpers.h" > +#include "network_helpers.h" > + > +struct mptcp_storage { > + __u32 invoked; > + __u32 is_mptcp; > +}; > + > +static int verify_sk(int map_fd, int client_fd, const char *msg, __u32 is_mptcp) > +{ > + int err = 0, cfd = client_fd; > + struct mptcp_storage val; > + > + /* Currently there is no easy way to get back the subflow sk from the MPTCP > + * sk, thus we cannot access here the sk_storage associated to the subflow > + * sk. Also, there is no sk_storage associated with the MPTCP sk since it > + * does not trigger sockops events. > + * We silently pass this situation at the moment. > + */ > + if (is_mptcp == 1) > + return 0; > + > + if (CHECK_FAIL(bpf_map_lookup_elem(map_fd, &cfd, &val) < 0)) { > + perror("Failed to read socket storage"); Maybe simplify this with CHECK(), which contains a customized error message? Same for some other calls. > + return -1; > + } > + > + if (val.invoked != 1) { > + log_err("%s: unexpected invoked count %d != %d", > + msg, val.invoked, 1); > + err++; > + } > + > + if (val.is_mptcp != is_mptcp) { > + log_err("%s: unexpected bpf_tcp_sock.is_mptcp %d != %d", > + msg, val.is_mptcp, is_mptcp); > + err++; > + } > + > + return err; > +} > + > +static int run_test(int cgroup_fd, int server_fd, bool is_mptcp) [...] > + > + client_fd = is_mptcp ? connect_to_mptcp_fd(server_fd, 0) : > + connect_to_fd(server_fd, 0); > + if (client_fd < 0) { > + err = -1; > + goto close_client_fd; This should be "goto close_bpf_object;", and we don't really need the label close_client_fd. > + } > + > + err += is_mptcp ? verify_sk(map_fd, client_fd, "MPTCP subflow socket", 1) : It doesn't really change the logic, but I guess we only need "err = xxx"? > + verify_sk(map_fd, client_fd, "plain TCP socket", 0); > + > +close_client_fd: > + close(client_fd); > + > +close_bpf_object: > + bpf_object__close(obj); > + return err; > +} > +