Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp1982863rdh; Sat, 28 Oct 2023 16:13:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF8OfUxn9V/TexWn7inYrEcuKRV+gkfS2h8hehusuKfm5dlqMR3BjnVTkbeCoYZZUh8fud1 X-Received: by 2002:a17:90a:fa10:b0:27d:20ca:1156 with SMTP id cm16-20020a17090afa1000b0027d20ca1156mr4635290pjb.34.1698534838640; Sat, 28 Oct 2023 16:13:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698534838; cv=none; d=google.com; s=arc-20160816; b=zgZIoPwZiVtc2WF5hoQ0hYnV/jJjS2k9OZvBnLw2NhTZU1Pai01IvuKX4Wto4P6JUK DogDNK7jarfM6+FY1LrNPeBRZiPPfgqSywNvZPZ3nHB0Vtg9BUeg5cAXiHZ2G4zJGBvx zNFFo6UkrBttsaBbkZ4W+yhco/RmGW/hTubWsGGWwyvP2c23wvh2yGfewPehmX2NNZAR GPovxFlwU7mDPQczyfGQvuS3GpL/3qEkU2sBE8VWcRGCJffo7U4GlyF9o2DlMcLxBOof wQKOPlpLkBJmMc/F+57lAUWlaO4HX9X+NwEbu7WCly1kvLlSOhEt3Oz14LrH9HU0Z5n1 nXdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=jYVnGp3cT6/jvVqSx9OkSVZgoRvtxkzuv24koCwWOG8=; fh=UseyeKzOtTZlTl7C2uD2BZIaUlrAqP4fFCE6K8IHY7Y=; b=j1jI8x2ajtunMPphLRjES4rHiMssvoN2JwPCEB0oQBLC3du6hWp+VgoUkasXZcjH2D zlCh/X8Mzu0iBx15RHK2VCsSlSJP42MsroSnNzWxcf/EoN5jK7kIKJVfI6dwExcY7+eL 3+pKommL5W7VHT4xn97T30nlVc2q6bHdHvGVuNoIZlxEpXwbx/zeCYA8kDOH4LhEolKR fMXdQmHgHX/QF7rR80+DfbZ36sf1sVl7+GUE1JcIHcMgkBK9dd4USnEWJJOrUoBvCvEu W+oxdiy0X1ubz/pEKgisqrJSKuT/1rDj6uoqbM9WODlywyGC4iSZdBLupboMrdok4U34 560w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=D2T6KYUM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id w9-20020a17090aea0900b002681fea6d14si1697519pjy.79.2023.10.28.16.13.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 16:13:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=D2T6KYUM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 6D673804E716; Sat, 28 Oct 2023 16:13:57 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229750AbjJ1XLn (ORCPT + 99 others); Sat, 28 Oct 2023 19:11:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229605AbjJ1XLm (ORCPT ); Sat, 28 Oct 2023 19:11:42 -0400 Received: from mail-qk1-x72a.google.com (mail-qk1-x72a.google.com [IPv6:2607:f8b0:4864:20::72a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9415ED6; Sat, 28 Oct 2023 16:11:40 -0700 (PDT) Received: by mail-qk1-x72a.google.com with SMTP id af79cd13be357-77891c236fcso262019385a.3; Sat, 28 Oct 2023 16:11:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698534699; x=1699139499; darn=vger.kernel.org; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=jYVnGp3cT6/jvVqSx9OkSVZgoRvtxkzuv24koCwWOG8=; b=D2T6KYUM+NLwFRHO0Cclg+cwjQO+kbeFA34kSNssPvsFCVsOkNYVEId+XkhonvgPCe GHiS0nIo9nio5i7bUfLEVe8BZfLMjZ8LxsCkESzI8PKHJiDwLsEv4FUc8T2zhTml9JG4 9L1hnJUwUM7DRwYNJvwBK4a2W4hhL1DPCchDPGne/l1Ai9R761vq6zjNGRQi07vh3Z0E dMRAMBsksK5osIHPZZpIRki28Xubl5GeAyOhkvyq12DQJQCOquIvnB0Kyjn0bnPqu8Uh 4yjBRKiXL/C1V7rFAZGbkoBF2yuP3r/Nrj5+efktHyQpmB2bb2b4m79kRC2t/X6h1Lf4 0BHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698534699; x=1699139499; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jYVnGp3cT6/jvVqSx9OkSVZgoRvtxkzuv24koCwWOG8=; b=mqHEQSAWoq69H0dDXtOG02+RYbjIy7d+CUSUevSvG4nCKw2hJwgGXF0FmA1bSw7V/b EG3Bv0NYUNGUyOFHuXqByivQVq1wK5sOTGvLTS1DEPUGMsgOR4zpiCzt4EC8YUpNr7sc FcRkcN/trpn17k1O9UizKzG91fB6qR+eIk+Fjvmpu36GwyF/nrKth4o+r+73KgTSpcYE ZSjmuKrF2J8u0jCoplLUr9aAo/m4E1gVJTpVxz+W6mwxRwB9CXLcD54itstt9MVzHHQ4 j7NlJSLJqE8Z6DE5itasS7cR5cBDHxI/RRa/PjNAFwZ/gwXcTDdgzrrKEwkKl1U3Ie0H 2DAQ== X-Gm-Message-State: AOJu0YzINiI5maSNlhA5ksFir6lIgheN5kXMRJusASzleQYrYnwEtu1n zmJT3GgwgUJZblB6aGnQ1Q== X-Received: by 2002:a05:622a:130c:b0:418:a14:9c30 with SMTP id v12-20020a05622a130c00b004180a149c30mr8750949qtk.9.1698534699640; Sat, 28 Oct 2023 16:11:39 -0700 (PDT) Received: from n191-129-154.byted.org ([147.160.184.150]) by smtp.gmail.com with ESMTPSA id z18-20020a05622a061200b00417dd1dd0adsm1968894qta.87.2023.10.28.16.11.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 16:11:39 -0700 (PDT) Date: Sat, 28 Oct 2023 23:11:37 +0000 From: Peilin Ye To: Daniel Borkmann Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Alexei Starovoitov , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Jesper Dangaard Brouer , Peilin Ye , netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, Cong Wang , Jiang Wang , Youlun Zhang Subject: Re: [PATCH net] veth: Fix RX stats for bpf_redirect_peer() traffic Message-ID: <20231028231135.GA2236124@n191-129-154.byted.org> References: <20231027184657.83978-1-yepeilin.cs@gmail.com> <20231027190254.GA88444@n191-129-154.byted.org> <59be18ff-dabc-2a07-3d78-039461b0f3f7@iogearbox.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <59be18ff-dabc-2a07-3d78-039461b0f3f7@iogearbox.net> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Sat, 28 Oct 2023 16:13:57 -0700 (PDT) Hi Daniel, Thanks for taking a look! On Sat, Oct 28, 2023 at 09:06:44AM +0200, Daniel Borkmann wrote: > > > diff --git a/net/core/filter.c b/net/core/filter.c > > > index 21d75108c2e9..7aca28b7d0fd 100644 > > > --- a/net/core/filter.c > > > +++ b/net/core/filter.c > > > @@ -2492,6 +2492,7 @@ int skb_do_redirect(struct sk_buff *skb) > > > net_eq(net, dev_net(dev)))) > > > goto out_drop; > > > skb->dev = dev; > > > + dev_sw_netstats_rx_add(dev, skb->len); > > > > This assumes that all devices that support BPF_F_PEER (currently only > > veth) use tstats (instead of lstats, or dstats) - is that okay? > > Dumb question, but why all this change and not simply just call ... > > dev_lstats_add(dev, skb->len) > > ... on the host dev ? Since I didn't want to update host-veth's TX counters. If we bpf_redirect_peer()ed a packet from NIC TC ingress to Pod-veth TC ingress, I think it means we've bypassed host-veth TX? > > If not, should I add another NDO e.g. ->ndo_stats_rx_add()? > > Definitely no new stats ndo resp indirect call in fast path. Yeah, I think I'll put a comment saying that all devices that support BPF_F_PEER must use tstats (or must use lstats), then. Thanks, Peilin Ye