Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp1330161rwb; Wed, 26 Jul 2023 10:47:18 -0700 (PDT) X-Google-Smtp-Source: APBJJlGEWnWc9naZP8GwOI4t/X1ZXUEThZLOFN1s2CNDjh5+wqlYBCsGxea5uHD+AR4XYdWXqFiJ X-Received: by 2002:a05:6402:278a:b0:51f:ef58:da87 with SMTP id b10-20020a056402278a00b0051fef58da87mr285390ede.2.1690393638213; Wed, 26 Jul 2023 10:47:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690393638; cv=none; d=google.com; s=arc-20160816; b=DXOqxrspgvpTyLONhj3evCdS3uL+fbi66WjlH44YGqPZRkwrd0yblJ4j2E7EUbA+3N fNNDT2x2juEw/bCqYOpGBI3xA3KBmTIrY06VBe/pnzFZMFrkoX5NoV+kDXdypXZGbvtk TBF0bXv10Ww25bS+Y8AVuc3YtmNrF9uh7myMMtOp20o6wClV68FR86S0ZrjUlTByxIQ0 dahiq0PFsZRW1860+DkvqhxSIWgDW75EgAATZyYyYGGUB/3QBHkvwN83S0lxL04RYcdJ gXFiRfPWUrj/AGrxDREMzhQgmkIaMqF/7lRsqiYBkyne4zVfFvDOuS1W+W8oSHyqomjx 2DHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=2UPiX7fReDR3fI6kmxK7fKJRGBv6XCkE0IO8pClG7+g=; fh=H6UQKSAqGHjb54pZqph1tH1MP6c6rOoC25f6obiXGjY=; b=YZJRPqa6ZOuxY7YNSErrt++5B1ZPcI4e06yCRp+xNcpC29WcB2TMH9DgMUnc5OlSgR 1QXh20B6muZIZ+FPHJ7Rex9BgmjS58gfnebAepPLU43V2LMe4n1YUB5ddoXAai3GcTF7 s6I6IE5vzM+Jy0vM65xTBaRH0e5sHwQgTjFbBKFFyXG6nrDwGNjSvzV8sCpuMXtilUxf IBVD0KYAceLIXmhA/WjaM++aiuIa24Jd8Gmbj8Y3YyWxqOOBEpsl/gjIoMTb95Vxl+bn ZjiRaixFaAMz04LtImOKcSg1+1EF0yST4+LC6PDVYmueVx+zFfaiubMpDTQgzu3J8UQ3 op0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IBozOJkH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d28-20020a056402517c00b0052228551730si5766524ede.279.2023.07.26.10.46.48; Wed, 26 Jul 2023 10:47:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IBozOJkH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231238AbjGZQxl (ORCPT + 99 others); Wed, 26 Jul 2023 12:53:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230296AbjGZQxk (ORCPT ); Wed, 26 Jul 2023 12:53:40 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD2AC26AC for ; Wed, 26 Jul 2023 09:53:38 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-3fb4146e8fcso9097455e9.0 for ; Wed, 26 Jul 2023 09:53:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1690390417; x=1690995217; h=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=2UPiX7fReDR3fI6kmxK7fKJRGBv6XCkE0IO8pClG7+g=; b=IBozOJkHMEJObNgwvMorzSH0KtIJG9/P8EQ1ZZJVm28cONWXXjTayecK4rWdnAyUxW xxbMsywVvJPOah5xbdygmmgf+ExN/CF0K0egEoibj6PKc5IY6dINi6UaHUBLrrmte37n qic+uwFKpgt43UklcnIv686n/cFqm13uOiM9iMZFtjQLJqOuOHW106bp0ljruQlr69w3 AnNrCBMX1dkprJy1ItKB7yxlKQvEbFdlYpsQuo/sAJ6RNxGA+WFBXtGTDXp5+veI3VGk L49LlZG33rdpSc3BboCAuzFoSAI0Zlf0aIGHtfzhMFBjbcfnxs+ej+jjt00pALR/gJ/r GpIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690390417; x=1690995217; h=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=2UPiX7fReDR3fI6kmxK7fKJRGBv6XCkE0IO8pClG7+g=; b=A6syDrYLUUuPSAceMW9z+7UkN+2Usy72cJzu+dwHQqvSSe1xHeymY9PsUuzm1UczeY m6zDeywq5bKyld+hI8DB5nh0nb/urFfxeZiKg/9vrjvMJwNbpBbfpgRAeKEnKwtUz2e/ olxVhT9ZMlOHj9GHp2BFq6kuuRR7Pn3A6jcXjmM+8rNeaeycaqkO8jqk8W5Gdlfnaoej ToEy8pvPVjw2J5Rg1KJTuqb06XAuRL8G5zKJfKP7/a1NsmatbhTVGOp/QoX05436xhf9 xy+VUNQKnzUQN0Cy1SC/TkMbcFMJhdH9Hz3aZ+k78BIs0GGjpD2a5cHys5dUP8DqSmZf GCEQ== X-Gm-Message-State: ABy/qLa416iGIrNc2XGAQ2rhvjJuZycG6Nkb6CdUbevbZ85fc9xfqapa YMiRAA3drSG1sbDkfqfhbntumw== X-Received: by 2002:a05:600c:4e14:b0:3fa:ef97:1fa5 with SMTP id b20-20020a05600c4e1400b003faef971fa5mr77269wmq.6.1690390417249; Wed, 26 Jul 2023 09:53:37 -0700 (PDT) Received: from localhost ([102.36.222.112]) by smtp.gmail.com with ESMTPSA id f2-20020a7bc8c2000000b003fc04eb92cbsm2483960wml.44.2023.07.26.09.53.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jul 2023 09:53:36 -0700 (PDT) Date: Wed, 26 Jul 2023 19:53:33 +0300 From: Dan Carpenter To: Yan Zhai Cc: bpf@vger.kernel.org, Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Mykola Lysenko , Shuah Khan , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, kernel-team@cloudflare.com, Jordan Griege , Markus Elfring , Jakub Sitnicki Subject: Re: [PATCH v4 bpf 1/2] bpf: fix skb_do_redirect return values Message-ID: <8b681fe1-4cc6-4310-9f50-1cff868f8f7f@kadam.mountain> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable 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 On Wed, Jul 26, 2023 at 09:10:20AM -0700, Yan Zhai wrote: > On Wed, Jul 26, 2023 at 06:01:00PM +0300, Dan Carpenter wrote: > > On Wed, Jul 26, 2023 at 07:14:56AM -0700, Yan Zhai wrote: > > > On Wed, Jul 26, 2023 at 04:39:08PM +0300, Dan Carpenter wrote: > > > > I'm not positive I understand the code in ip_finish_output2(). I think > > > > instead of looking for LWTUNNEL_XMIT_DONE it should instead look for > > > > != LWTUNNEL_XMIT_CONTINUE. It's unfortunate that NET_XMIT_DROP and > > > > LWTUNNEL_XMIT_CONTINUE are the both 0x1. Why don't we just change that > > > > instead? > > > > > > > I considered about changing lwt side logic. But it would bring larger > > > impact since there are multiple types of encaps on this hook, not just > > > bpf redirect. Changing bpf return values is a minimum change on the > > > other hand. In addition, returning value of NET_RX_DROP and > > > NET_XMIT_CN are the same, so if we don't do something in bpf redirect, > > > there is no way to distinguish them later: the former is considered as > > > an error, while "CN" is considered as non-error. > > > > Uh, NET_RX/XMIT_DROP values are 1. NET_XMIT_CN is 2. > > > > I'm not an expert but I think what happens is that we treat NET_XMIT_CN > > as success so that it takes a while for the resend to happen. > > Eventually the TCP layer will detect it as a dropped packet. > > > My eyes slipped lines. CN is 2. But the fact RX return value can be > returned on a TX path still makes me feel unclean. Odds are low that > we will have new statuses in future, it is a risk. I'd hope to contain > these values only inside BPF redirect code as they are the reason why > such rx values can show up there. Meanwhile, your argument do make > good sense to me that the same problem may occur for other stuff. It > is true. In fact, I just re-examined BPF-REROUTE path, it has the > exact same issue by directly sending dst_output value back. > > So I would propose to do two things: > 1. still convert BPF redirect ingress code to contain the propagation > of mixed return. Return only TX side value instead, which is also what > majority of those local senders are expecting. (I was wrong about > positive values returned to sendmsg below btw, they are not). > > 2. change LWTUNNEL_XMIT_CONTINUE and check for this at xmit hook. > Sounds good! regards, dan carpenter