Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3283969pxk; Tue, 15 Sep 2020 15:18:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwSbgYk3ZidCZPvh090DPW7CbVNFycWVhfjhmLBFqn2xgitbiHdTN0vXdEiAYBgIEBal/ul X-Received: by 2002:a17:906:aecb:: with SMTP id me11mr23297065ejb.217.1600208323451; Tue, 15 Sep 2020 15:18:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600208323; cv=none; d=google.com; s=arc-20160816; b=ExXdaqMtic42eS1fnUYasacEMXvHoQ3oIE7+ocIG9pSXeHqM594jdKNMV9UNv6NUoM lrtmrO2rB08a5qqI1cTq41MCJpqGaNcxouEZGOy7iJBtgm3eJyqc/mkrz9pTrThgUSCg PUM6v1/JDvHWnlbK30cNwboDGnYHlG9mqtePuU1fCF4/nJDQTqyoGB/H8AKJD3o4ZFEZ NOweqxZ5b9b26CB8Bx1SOPMWNZM7ZN9FbRajGfMfZLBPO9cc2hxpALL9Ntdr86WnEK8D 6L9S70NgI5WeK1SIbCqHC64OUXPuPMIPPENFXaG6ZOmJIuxL3/GRG7vVTJ1WveGSWxyK PAhA== 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=hTYtDNRWZ3IQd17IVwiFvjdPJC2m5bl5cpimFc01bsE=; b=UoNiU0hIxYyeq6RNzCrFPZyjh8EMFvbh0rTaySlqexsTwJgYJfIYW7sdpRZe64cJ92 /rYhhrrqsoGowGaGZkMRXV4/FX8GdJwm/8ZiBRhXkJ0kOusJZ5VBkNUZKY8AhSXZSf4U sznR0q3sDj+EgN88z5yY+dgYmMX7Nk10WqhaAy2a7qH+z7e5f6gRXl57pMI+flAAXKL+ Glv1m0dCW22XielkYG5vi6fvUnOXOOsIMoYibWRzAFYqAsNvn1shEqe2vJDkDzj+km5q PyYm+C00uwt8evdPPzPepme9YrvDXOYjRcxpjaBhzr1DjynQaZMuEMyCMyKYyTpvvoW8 wxWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares-net.20150623.gappssmtp.com header.s=20150623 header.b=dd8bL7eb; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d3si9891701ejw.357.2020.09.15.15.18.21; Tue, 15 Sep 2020 15:18:43 -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=@tessares-net.20150623.gappssmtp.com header.s=20150623 header.b=dd8bL7eb; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727513AbgIOWPn (ORCPT + 99 others); Tue, 15 Sep 2020 18:15:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727281AbgIOQgM (ORCPT ); Tue, 15 Sep 2020 12:36:12 -0400 Received: from mail-io1-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0E1AC061351 for ; Tue, 15 Sep 2020 09:36:11 -0700 (PDT) Received: by mail-io1-xd42.google.com with SMTP id z13so4771648iom.8 for ; Tue, 15 Sep 2020 09:36:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares-net.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=hTYtDNRWZ3IQd17IVwiFvjdPJC2m5bl5cpimFc01bsE=; b=dd8bL7ebVaZyzMDfsYKo20tvtiuZtcDmrHxwpMH6xunQdc01MjGuk18V+0XPn8WHrl Fis6Uo8ZkZSeYMw/H78zlSzVvrGy4lwsCvjqkxiT5CkoD8OYqyA+IbeH5o+YrirpA6r0 K8iLbnom0h1MLtbmdJo3GIQKZLGp8PT7JlepSGsUyzIZ6zgUM0WQ7PA3XVS8h2Jhq2pJ kzHaBtpJJTkGGvgCKfbE1evnoBXp1Dad1Boq4Vl9c9ekuQvXK4qX4JS1c1w7QWEIZ0q7 lhbLIxyyUMt0OvM1lYg8LZlT0B+Pe0m3kwJXdmKVS7TF7Hciljn7WW/NJvTrGqu6jynF Td1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=hTYtDNRWZ3IQd17IVwiFvjdPJC2m5bl5cpimFc01bsE=; b=ricqnZ29KjZMFq2t61paR+6UxsMcMQOMn7n50meGV1A2YPJz1TELqK2RPHugRRVTZn sX3kQg75rdVmIOY66y86/XRHTfm3im9pttjXhAKSeCdmbmhXO/aYuQC1Jnklt618WPdE 6NbrMjU29Nem4YmswSke5B5nLS58YqSbg/r0TgAKmcQSoOdVKw9lIbFpDYPKdBVlnfCy dS69X3Vo2w3ZDh/EBhA53vrhs987Zh1smJV92Tte+TlM9prlOAqGBilb7n4ttDCY4QIc HNhEMHS+xK2nXYvBpWGS6UulRsSrBn8/2AHh5Bxqyq1rbYpsxYNNF6HCsBcT4XzpEWB3 TQTw== X-Gm-Message-State: AOAM530Dec/BNJr1ey41/xYSFXzeOeZXQ28sYH3vNLLMrQ2xIMhxW0Jk v6SDywc+lQuYagGs3/d+SbUGbMcz5VFC2NOykdiEWA== X-Received: by 2002:a05:6638:1643:: with SMTP id a3mr18483174jat.4.1600187770959; Tue, 15 Sep 2020 09:36:10 -0700 (PDT) MIME-Version: 1.0 References: <20200911143022.414783-1-nicolas.rybowski@tessares.net> <20200911143022.414783-4-nicolas.rybowski@tessares.net> In-Reply-To: From: Nicolas Rybowski Date: Tue, 15 Sep 2020 18:35:59 +0200 Message-ID: Subject: Re: [PATCH bpf-next v2 4/5] bpf: selftests: add MPTCP test base To: Song Liu 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 Hi Song, Thanks for the feedback ! On Mon, Sep 14, 2020 at 8:07 PM Song Liu wrote: > > 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. > The whole logic here is strongly inspired from prog_tests/tcp_rtt.c where CHECK_FAIL is used. Also the CHECK macro will print a PASS message on successful map lookup, which is not expected at this point of the tests. I think it would be more interesting to leave it as it is to keep a cohesion between TCP and MPTCP selftests. What do you think? If there are no objections, I will send a v3 with the other requested changes and a rebase on the latest bpf-next. > > + 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; > > +} > > +