Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp469814yba; Wed, 15 May 2019 04:41:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqybiJdDiN4u45SLQ5ulqDRKeU134OV7CLxHBbCmX0VUuIDbjwTKYin2aYavakDEdbHPvQ0l X-Received: by 2002:a17:902:765:: with SMTP id 92mr42458929pli.196.1557920483019; Wed, 15 May 2019 04:41:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557920483; cv=none; d=google.com; s=arc-20160816; b=07RczYjV0uT7rV6fpIipb4bz6d9w6UZUPwB2NZyPYjCWeNHv/aqHFYqfg0kZ9sq8xt J7jV9Z2DDBZfFHM05t79xq6u1E4J7kgEybrXORGq6rUXDsqsvd0LoAMamvV52aaZPe39 RdsedkOEdPSLP/xHDp6NTXBLeQlMHmggc4/+rSUB80iR3aZVX8hkqAfuCjDwXu5nyO5w Ew4RX21n3sZ06c/yH+wNB1Gg+1eE4ai5Wljlon/dTrcJ/mHFMl2eneT1aLn5x0oS2A8L GFYQdznci4DQW6dbJgw/acq1az+g6VWGD1BuH9znfrEBrjLaqB/kGAYfdChPUEHD2iDi o23w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=TVoyc1XQ1h+RXK849dxZKxovevUdDCmLg2230FGe9AU=; b=GNbl97Hgg42b9KCMtbfE662+BVtTg21UoByKBW7x6drGkKlBIaHPZwo9diF95DW24T OsHVwwAmuC5wj4Aa/F6/k0KKVG+llsUi3nNIoQ5xGJG3dVEj2nXWFpXm1T3tceaMFwPx zrBUCvG4/7c/E26Y+1sYLiCRnrwiHiMtlffb8gZfxUizSBLXm5YhisTZ6nzLPHzoLi5t BzgODfPS09J5S8F4u3GJRoboJ/J4lwWGqwVQJrXpzqIjjZ+euYXCrx7JqmPH7zOwp2My kPnuR3So5guV5PyOMFQ0f8V7HytYuE4xRnhVv75OL3rL0VzKtDXOJShVmgYrOCZAY9Dk 1U2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=j7seZHID; 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 l7si1653170plg.222.2019.05.15.04.41.07; Wed, 15 May 2019 04:41:23 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=j7seZHID; 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 S1732253AbfEOLad (ORCPT + 99 others); Wed, 15 May 2019 07:30:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:42072 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726599AbfEOLab (ORCPT ); Wed, 15 May 2019 07:30:31 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B2FED20843; Wed, 15 May 2019 11:30:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557919831; bh=D2wjTzLY+6BhBi4u1J9Nm0dZ/GGBbMLUC2F6GZL8Gug=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j7seZHIDf8G8ihl+zVW6wwWmJl2IWK7Fru4e6XsHJNba1aEuYz98jCq892h2VIA42 imFBtEjnRPcBjTOeHe4VTSfd0kLkiIVqoHRnK1T1+vOIr26G+o6xZztcBAGksvp1w3 OYhNYieGuWM4r9Oiv0x/myoVpjcp4YYGilzMfDKg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Ahern , "David S. Miller" Subject: [PATCH 5.0 109/137] ipv4: Fix raw socket lookup for local traffic Date: Wed, 15 May 2019 12:56:30 +0200 Message-Id: <20190515090701.497230082@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190515090651.633556783@linuxfoundation.org> References: <20190515090651.633556783@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: David Ahern [ Upstream commit 19e4e768064a87b073a4b4c138b55db70e0cfb9f ] inet_iif should be used for the raw socket lookup. inet_iif considers rt_iif which handles the case of local traffic. As it stands, ping to a local address with the '-I ' option fails ever since ping was changed to use SO_BINDTODEVICE instead of cmsg + IP_PKTINFO. IPv6 works fine. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: David Ahern Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv4/raw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/net/ipv4/raw.c +++ b/net/ipv4/raw.c @@ -173,6 +173,7 @@ static int icmp_filter(const struct sock static int raw_v4_input(struct sk_buff *skb, const struct iphdr *iph, int hash) { int sdif = inet_sdif(skb); + int dif = inet_iif(skb); struct sock *sk; struct hlist_head *head; int delivered = 0; @@ -185,8 +186,7 @@ static int raw_v4_input(struct sk_buff * net = dev_net(skb->dev); sk = __raw_v4_lookup(net, __sk_head(head), iph->protocol, - iph->saddr, iph->daddr, - skb->dev->ifindex, sdif); + iph->saddr, iph->daddr, dif, sdif); while (sk) { delivered = 1;