Received: by 2002:a05:6a10:8395:0:0:0:0 with SMTP id n21csp482725pxh; Tue, 9 Nov 2021 13:59:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJzlM81Un2+VMbL3FtvLkM4A6fRuInruIx9dVqUZMiF37KBIHCxxSohnpqNaJxnPGZUHeMpL X-Received: by 2002:a05:6e02:1848:: with SMTP id b8mr7539406ilv.299.1636495150018; Tue, 09 Nov 2021 13:59:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636495150; cv=none; d=google.com; s=arc-20160816; b=06PF+JZZhxW3onzJwO+r+yPfTyiOvQO4fhW7xNyyTIf9ap6yto82zmnxroWM2XEamU 6QR5YLuDC2g4LJ01oaf5ontvgyV+KKBNrMezWwBV3QCy4AmEP5Yu1CxtkFFVakIjzwtU +Fta32TQq7VUXiPZMdltIhlJAc8GgE+78b55j2vYtEE2NbFQFLN69X4Hyj9KgpgPaIV4 1plZKjtqrwkilYL8K+Ew38XgWwkycrDvoyhBt1CxaaT66vDWqjNhewy9zBIvByPO87/q VkKzLkPLvtTO0xN6MlWlB6ro+foC4EFXDNPUYORHT6h67dGbBjXLOdCQL8SdG7yyBGJ4 u+MA== 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; bh=eu1KUJhU7x6XyW3UDPx7mYoYsBJ/4TARy5mQCxOiHxg=; b=NaucmQJ8uIP5VeSC528ife+wfXXnBvr8HwQM5kN42Cm3sncRDJ50dEav5Eh22MfLeS JwZf872VGf0RiQIRXz7WviUVkUuh8q1bhF1MNHkg94DyuvVI5s5E5uLfMhURBf4Ftv6e ZEqIgZoidGFNWnDRGLa7xGvd9hsL7DN/NUqI6AGJFamm+GA3yjdXp/B3++ixo/BVCg9E iu+aTDpLuyWQjt7xlF/y1CSp8bUt0VD69KaD1HhafFvpCWiyHyJlyez9FdeEvxDY09lv bXzxpewyd/w5dtt4Ccm6Wos5Kk3aHHik/QGEi7POSuoFKrlctoQvfCTblOHx8Ieh3bxc DtmA== ARC-Authentication-Results: i=1; mx.google.com; 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 f14si29713093iol.77.2021.11.09.13.58.57; Tue, 09 Nov 2021 13:59:10 -0800 (PST) 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; 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 S1343569AbhKILtN (ORCPT + 99 others); Tue, 9 Nov 2021 06:49:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229879AbhKILtL (ORCPT ); Tue, 9 Nov 2021 06:49:11 -0500 Received: from Chamillionaire.breakpoint.cc (Chamillionaire.breakpoint.cc [IPv6:2a0a:51c0:0:12e:520::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6198FC061764; Tue, 9 Nov 2021 03:46:25 -0800 (PST) Received: from fw by Chamillionaire.breakpoint.cc with local (Exim 4.92) (envelope-from ) id 1mkPZs-0004YE-OB; Tue, 09 Nov 2021 12:46:12 +0100 Date: Tue, 9 Nov 2021 12:46:12 +0100 From: Florian Westphal To: Changliang Wu Cc: davem@davemloft.net, kuba@kernel.org, yoshfuji@linux-ipv6.org, dsahern@kernel.org, edumazet@google.com, idosch@OSS.NVIDIA.COM, amcohen@nvidia.com, fw@strlen.de, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] ipv4: add sysctl knob to control the discarding of skb from local in ip_forward Message-ID: <20211109114612.GC16363@breakpoint.cc> References: <1636457577-43305-1-git-send-email-changliang.wu@smartx.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1636457577-43305-1-git-send-email-changliang.wu@smartx.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Changliang Wu wrote: > This change is meant to add a control for forwarding skb from local. > By default, ip forward will not receive the pakcet to/from the local. > But in some special cases, for example: > - > | ovs-bridge gw-port | <----> kube-proxy(iptables) | > - > Ovs sends the packet to the gateway, which requires iptables for nat, > such as kube-proxy (iptables), and then sends it back to the gateway > through routing for further processing in ovs. This a very terse description. How does packet end up in forward after skb->sk assignment? > diff --git a/net/ipv4/ip_forward.c b/net/ipv4/ip_forward.c > index 00ec819..06b7e00 100644 > --- a/net/ipv4/ip_forward.c > +++ b/net/ipv4/ip_forward.c > @@ -95,9 +95,6 @@ int ip_forward(struct sk_buff *skb) > if (skb->pkt_type != PACKET_HOST) > goto drop; > > - if (unlikely(skb->sk)) > - goto drop; > - Please have a look at 2ab957492d13bb819400ac29ae55911d50a82a13 you need to explain why this is now ok. Without explanation i have to assume stack will now crash again when net->ipv4.sysctl_ip_fwd_accept_local=1 and TW socket is assigned.