Received: by 10.223.176.5 with SMTP id f5csp3405208wra; Mon, 29 Jan 2018 12:42:26 -0800 (PST) X-Google-Smtp-Source: AH8x227BhqFeS4QLEC6iSxIuGMzHqZbvRAs6IPLLk9xmDvBtPt36NL04DX14t9ZaNFLnbh7dtkyI X-Received: by 2002:a17:902:3f83:: with SMTP id a3-v6mr22392080pld.263.1517258546276; Mon, 29 Jan 2018 12:42:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517258546; cv=none; d=google.com; s=arc-20160816; b=slDJJclZVidZ6j51whLxIX7sHwdU48bJgbZdfHnwdosR1zVp0Lv0elCB+ECauefoZX h3t1eQec6VdxCRd43IuXp24jRqPtXjoRCAFubzOeC9kdo/SBdnY7OfVITZuX2o113F9C ypbZs1SNYrxzCGLgkpVJ72zkBu6h+h1BVtXTubX1tV0a98wsekVEGTBxCE2vHgxE+T9/ BAkUjEUF1ZIyBVJoWBkhV8ZfPPGB7QBSA7h6sTKm1vomftgxUSnk0IeILbhPxI6fiaVg qfi605rSJJbO6wzjwwFE10Qv2hVFyBkzY0EC5BOeQEq5r/VVJDrA5kOoY0Xqe40xzMBq mWRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=Wn16EsA38KrkyyfEAo7vud5+VozSZB04tP9zpBTiF74=; b=cI6aQhaSWOIMd/AVW65PhAl23mXYTvZesbSvGx/X4uCOxrld3jzMFCsBQqS/I8YOdS e1utWzaCof5Ae0OjrMkLyCwtJC6ZYDXNwWn+IXkDOf18K3mVNKbP6SlVlDPL2GOHutKC p+p5mXe/Esf3T8b1ji53wNK636J56+MZ11/gLRbH2YR1/cQ42dJPeNrIScO2UIlX7pTt O25J3SmCYt334js4k1eNOk2s4TtYe1fOxX7gpzGNxcRV1u5LV0e4Lcntf9EwCeq3Njf9 4/rwGhiGJrvQ+yX5ihkNjn15A5PnhukS5X8S0K9sWXfjlAeQVpizTNqd1V7CEqm4sayY MWEA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z2si10957967pfe.350.2018.01.29.12.42.11; Mon, 29 Jan 2018 12:42:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754122AbeA2Ult (ORCPT + 99 others); Mon, 29 Jan 2018 15:41:49 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:36272 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754013AbeA2UM5 (ORCPT ); Mon, 29 Jan 2018 15:12:57 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 17ED93027; Mon, 29 Jan 2018 13:10:15 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lorenzo Colitti , David Ahern , "David S. Miller" Subject: [PATCH 4.14 58/71] net: ipv4: Make "ip route get" match iif lo rules again. Date: Mon, 29 Jan 2018 13:57:26 +0100 Message-Id: <20180129123831.481269376@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180129123827.271171825@linuxfoundation.org> References: <20180129123827.271171825@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Lorenzo Colitti [ Upstream commit 6503a30440962f1e1ccb8868816b4e18201218d4 ] Commit 3765d35ed8b9 ("net: ipv4: Convert inet_rtm_getroute to rcu versions of route lookup") broke "ip route get" in the presence of rules that specify iif lo. Host-originated traffic always has iif lo, because ip_route_output_key_hash and ip6_route_output_flags set the flow iif to LOOPBACK_IFINDEX. Thus, putting "iif lo" in an ip rule is a convenient way to select only originated traffic and not forwarded traffic. inet_rtm_getroute used to match these rules correctly because even though it sets the flow iif to 0, it called ip_route_output_key which overwrites iif with LOOPBACK_IFINDEX. But now that it calls ip_route_output_key_hash_rcu, the ifindex will remain 0 and not match the iif lo in the rule. As a result, "ip route get" will return ENETUNREACH. Fixes: 3765d35ed8b9 ("net: ipv4: Convert inet_rtm_getroute to rcu versions of route lookup") Tested: https://android.googlesource.com/kernel/tests/+/master/net/test/multinetwork_test.py passes again Signed-off-by: Lorenzo Colitti Acked-by: David Ahern Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv4/route.c | 1 + 1 file changed, 1 insertion(+) --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -2762,6 +2762,7 @@ static int inet_rtm_getroute(struct sk_b if (err == 0 && rt->dst.error) err = -rt->dst.error; } else { + fl4.flowi4_iif = LOOPBACK_IFINDEX; rt = ip_route_output_key_hash_rcu(net, &fl4, &res, skb); err = 0; if (IS_ERR(rt))