Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp2772554rdh; Mon, 30 Oct 2023 07:20:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGCec+nKdDE3WBIl8QihKN4gO1WONiFMt9laN07xBnm3wesgcnHpjSL6C+3Z3qh21O04CC8 X-Received: by 2002:a05:6a20:9146:b0:153:73ec:fe70 with SMTP id x6-20020a056a20914600b0015373ecfe70mr7747132pzc.13.1698675610169; Mon, 30 Oct 2023 07:20:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698675610; cv=none; d=google.com; s=arc-20160816; b=aGnAh6sbmiGG5t8ftlPQgwruslsEQCZq1CkDSrDjK9uxrLrHKttwD3IQ4tCHl0Lb4F avTVILNi3RH1Hf7HpptDMl/1g9tylJuoAxr7pwrTT/dJ60XLBPsILfcWAVt8tA+CECIi N6cLD3LfeerfmEREQ1kP+aomMr+m/KurwOKJa/45Yy//a3XhGj3v5Tl65DitULWQHC4u bmhpQhq4Oev5IHtuKGn+GT4eyq2WUhlcceSFUvBATAXl7DLJ7MewfwfdXfMOvh5Mog75 KMhwLIPgUfZ4zPr8wJe4uGK8QfyByx7gFQs0wUVsKmAo4ZX0p9w4+6+VyV6fqtLYN5SL djxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=pUI5nGy0LFYKow2okhoQ6OKyczy/kEldDjABNORebOc=; fh=sRu/WlfocMSjtGhhbfRsD8gxBzxSvhNhM+3eG58fgMk=; b=bg3xCT2xLSQoBxaxh82TwOS7xNwNtdBX/Zh7N5PTNwMizQVb/qGbJINT2mo72vfmkh 171vXnoAhft5kYNxuvaku3LCm8Zw6Y37+ErJsxqPhs5G1mgkmMwvATv6dVC5FGs2WreF whUVpKnJP2kLsayrjJhPyx87WpI00xF65gg/MBiywrQOXoBenuwRgSOFGL6Mx+1/oyDE rl2YIDElyKy5VAtXp116/KopuDOi3idWP1496jLgmfLpcAl0mfL+SjeImCc47Sfdn3si M5yKEV6HCNst7TLjksb0QCLbCqpehsh06mJ+GK3e9Ubnj3VfFRmObkJEaZ8y2ejhndfd D6fQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@iogearbox.net header.s=default2302 header.b=Ic4ZQEsz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=iogearbox.net Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id l192-20020a6391c9000000b005b18ac47c1csi5031762pge.310.2023.10.30.07.20.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 07:20:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@iogearbox.net header.s=default2302 header.b=Ic4ZQEsz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=iogearbox.net Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 036C8809500A; Mon, 30 Oct 2023 07:20:00 -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 S231598AbjJ3OTt (ORCPT + 99 others); Mon, 30 Oct 2023 10:19:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229568AbjJ3OTs (ORCPT ); Mon, 30 Oct 2023 10:19:48 -0400 Received: from www62.your-server.de (www62.your-server.de [213.133.104.62]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDED7B7; Mon, 30 Oct 2023 07:19:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=iogearbox.net; s=default2302; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=pUI5nGy0LFYKow2okhoQ6OKyczy/kEldDjABNORebOc=; b=Ic4ZQEszf7DdPBZRY4YiXz7+XW MXv68gsOVMuwSkXRYL3DrKHyZyOzPhzVGgAzEr2A8oyeWtTuVUNGncN2F6Z6J4fvq0Qi+kxFw3Nv+ Wf2XDjFO0BG4tlbg6rVzLmM4d2PQc1hwMNJAKKWQFYImP5WKESkANmYPNN6Qxph0TbYQdY3QbEPQ6 Di2fOOca1/h91PJlU7/bCFlPRgI4jm3zJn92v3HYBljyZR/8uiXQ6JDr1dIDq0nhvxRVrE7nsJXX6 TlIZkm3efA9OG3prnCXoxKJq8psh4siiA9ollSw1vn53aWlwdBFGj6ZROeQb92e8a3iV6UND6mRPD /f/ivMyw==; Received: from sslproxy05.your-server.de ([78.46.172.2]) by www62.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qxT72-0001SS-KC; Mon, 30 Oct 2023 15:19:28 +0100 Received: from [85.1.206.226] (helo=linux.home) by sslproxy05.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qxT71-000Y1o-O6; Mon, 30 Oct 2023 15:19:27 +0100 Subject: Re: [PATCH net] veth: Fix RX stats for bpf_redirect_peer() traffic To: Peilin Ye 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 References: <20231027184657.83978-1-yepeilin.cs@gmail.com> <20231027190254.GA88444@n191-129-154.byted.org> <59be18ff-dabc-2a07-3d78-039461b0f3f7@iogearbox.net> <20231028231135.GA2236124@n191-129-154.byted.org> From: Daniel Borkmann Message-ID: <94c88020-5282-c82b-8f88-a2d012444699@iogearbox.net> Date: Mon, 30 Oct 2023 15:19:26 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <20231028231135.GA2236124@n191-129-154.byted.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.103.10/27077/Mon Oct 30 08:39:55 2023) X-Spam-Status: No, score=-6.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,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]); Mon, 30 Oct 2023 07:20:00 -0700 (PDT) On 10/29/23 1:11 AM, Peilin Ye wrote: > 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? Yes. So the idea is to transition to tstats replace the location where we used to bump lstats with tstat's tx counter, and only the peer redirect would bump the rx counter.. then upon stats traversal we fold the latter into the rx stats which was populated by the opposite's tx counters. Makes sense. OT: does cadvisor run inside the Pod to collect the device stats? Just curious how it gathers them. >>> 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. sgtm. Thanks, Daniel