Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D47DAECAAA1 for ; Mon, 24 Oct 2022 17:14:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232417AbiJXROa (ORCPT ); Mon, 24 Oct 2022 13:14:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235400AbiJXRN7 (ORCPT ); Mon, 24 Oct 2022 13:13:59 -0400 Received: from out199-3.us.a.mail.aliyun.com (out199-3.us.a.mail.aliyun.com [47.90.199.3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9CDE30557 for ; Mon, 24 Oct 2022 08:49:50 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R171e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046059;MF=hengqi@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0VT-xL5q_1666618751; Received: from 30.13.191.196(mailfrom:hengqi@linux.alibaba.com fp:SMTPD_---0VT-xL5q_1666618751) by smtp.aliyun-inc.com; Mon, 24 Oct 2022 21:39:12 +0800 Message-ID: <2b09c4ab-da18-3b85-d16b-46f9b0e8c278@linux.alibaba.com> Date: Mon, 24 Oct 2022 21:39:08 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:106.0) Gecko/20100101 Thunderbird/106.0 Subject: Re: [PATCH net] veth: Avoid drop packets when xdp_redirect performs To: =?UTF-8?Q?Toke_H=C3=B8iland-J=C3=B8rgensen?= Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Xuan Zhuo , netdev@vger.kernel.org, Paolo Abeni References: <1664267413-75518-1-git-send-email-hengqi@linux.alibaba.com> <87wn9proty.fsf@toke.dk> <87v8p7r1f2.fsf@toke.dk> <189b8159-c05f-1730-93f3-365999755f72@linux.alibaba.com> <567d3635f6e7969c4e1a0e4bc759556c472d1dff.camel@redhat.com> <87o7uymlh5.fsf@toke.dk> <87bkq6v4hn.fsf@toke.dk> <3a9b641a-f84d-92e0-a416-43bbde26f866@linux.alibaba.com> <089cff2e-b113-0603-d751-9ca0ad998553@linux.alibaba.com> <87r0yxgxba.fsf@toke.dk> From: Heng Qi In-Reply-To: <87r0yxgxba.fsf@toke.dk> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 在 2022/10/24 下午9:34, Toke Høiland-Jørgensen 写道: > Heng Qi writes: > >> 在 2022/10/21 下午2:31, Heng Qi 写道: >>> >>> 在 2022/10/21 上午12:34, Toke Høiland-Jørgensen 写道: >>>> Heng Qi writes: >>>> >>>>> maybe we should consider a simpler method: when loading xdp in veth, >>>>> we can automatically enable the napi ring of peer veth, which seems to >>>>> have no performance impact and functional impact on the veth pair, and >>>>> no longer requires users to do more things for peer veth (after all, >>>>> they may be unaware of more requirements for peer veth). Do you think >>>>> this is feasible? >>>> It could be, perhaps? One issue is what to do once the XDP program is >>>> then unloaded? We should probably disable NAPI on the peer in this case, >>>> but then we'd need to track whether it was enabled by loading an XDP >>>> program; we don't want to disable GRO/NAPI if the user requested it >>>> explicitly. This kind of state tracking gets icky fast, so I guess it'll >>>> depend on the patch... >>> Regarding tracking whether we disable the napi of peer veth when >>> unloading >>> the veth's xdp program, this can actually be handled cleanly. >>> >>> We need to note that when peer veth enable GRO, the peer veth device will >>> update the `dev->wanted_features` with NETIF_F_GRO of peer veth (refer to >>> __netdev_update_features() and veth_set_features() ). >>> >>> When veth loads the xdp program and the napi of peer veth is not ready >>> (that is, peer veth does not load the xdp program or has no enable gro), >>> at this time, we can choose `ethtool -K veth0 gro on` to enable the >>> napi of >>> peer veth, this command also makes the peer veth device update their >>> wanted_features, or choose we automatically enable napi for peer veth. >>> >>> If we want to unload the xdp program for veth, peer veth cannot directly >>> disable its napi, because we need to judge whether peer veth is >>> gro_requested >>> ( ref to veth_gro_requested() ) or has its priv->_xdp_prog, if so, just >>> clean veth's xdp environment and disable the napi of veth instead of >>> directly disable the napi of peer veth, because of the existence of the >>> gro_requested and the xdp program loading on peer veth. >>> >>> But, if peer veth does not have gro_requested or xdp_program loading >>> on itself, >>> then we can directly disable the napi of peer veth. >> Hi, Toke. Do you think the above solution is effective for the problem >> of veth >> xdp_rediect dropping packets? Or is there more to add? If the above solution >> seems to be no problem for the time being, I'm ready to start with this idea >> and try to make the corresponding patch. > I think it might? Please write a patch and we can have a look :) Okay, I will do it right away. Thanks. > > -Toke