Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp488572yba; Wed, 15 May 2019 05:03:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqzO8q1/jtDTe573mSecESwAdNLnPeWAqa5qwZg9aHdIgjReXfF6o+1ruIEMsKy/ihMEQ6tg X-Received: by 2002:a62:5103:: with SMTP id f3mr48517005pfb.146.1557921800533; Wed, 15 May 2019 05:03:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557921800; cv=none; d=google.com; s=arc-20160816; b=uDvkJyYjdwE9adwPAwsizoWPtmZ+cArfQwd4XX72k0EbOtBEcJ86SmacfN4Rj+tumI K8u6Vex9caPUkYldIeJR4pZ6l7AODGBCUxhSUR51eP+8bovHNBk1M8Q738IALmX9/ep3 CcBMRmOfG+RiVYul1IBTant3xQnNvFEtLpls0zGuCIne7GyjBhs1CAPfWm0j5m5KkXkq iun+Cj+GVAG/zO5XvCYp5rnVyZ6m3aW3a9RRqi+k7YLZSfxAJhXAhf6HE0sKU8jG8sOZ AoM2sYoZolMZ441bZIp2fYMfdRsJj+GYulA6M8l8xmnvEpT9nVSQW2RoQAWyAu0pzqew ZtSg== 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=U/d/8aUWFp370ydP8SVidGsX64kk/vDjzIPvpZiqLUU=; b=zPp2aRN5+y7fp7xNruqJPDJC2EWEcmacso2WYi/99/XvvHvNvSpj8mlPbbfOsJ23Pi Ld2o+5+HkqxY2YPE9YmZoPQOjLvPnMAg3W126N6uI2J0Htz9jG9H7n69RwmeBU10cSJ8 iR8i9Gsz8z2whPSS1GihJ0UAO41r2JO8QcI1/KKxJEkRkIvKlZC8GJ2kr6T6Q2w99kMY XIOza1ZcRB1BnKrejlgZXGboZGMDN3eUooEkYPT5qDeFFZt/cvNPl0MMevY/qCsezcno KaIMVlrgvN6VGuc6nZiHpdnwwz+zelijtiTBpoIiZfy7EIcqfSX+AARsUYm9i2ZYUW4z baNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=b8f4eRUo; 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 r84si2064980pfa.10.2019.05.15.05.03.02; Wed, 15 May 2019 05:03:20 -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=b8f4eRUo; 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 S1730192AbfEOL74 (ORCPT + 99 others); Wed, 15 May 2019 07:59:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:51578 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730013AbfEOLPK (ORCPT ); Wed, 15 May 2019 07:15:10 -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 BB7EB20644; Wed, 15 May 2019 11:15:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557918910; bh=BrGBuaBYFEbSew5mma2LdrWM9G9Zzz1MNTXJovmdlt8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b8f4eRUoEBhKb98CWNCUs5R55rAJ92i77noHnGz7OkdG+yuRKlhmWyLKnLPPayXmW 50yzbk7vTgZwPG6T3A+/FEHO517vRCR+cR7MY/Hpuy++Gdj+4DNMxSibr5UFJKo7uf J6dGszvzkz5ovgEr0WjXb5HqwftoIS1Dzn2dKdSs= 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 4.9 46/51] ipv4: Fix raw socket lookup for local traffic Date: Wed, 15 May 2019 12:56:21 +0200 Message-Id: <20190515090629.253646048@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190515090616.669619870@linuxfoundation.org> References: <20190515090616.669619870@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 @@ -169,6 +169,7 @@ static int icmp_filter(const struct sock */ static int raw_v4_input(struct sk_buff *skb, const struct iphdr *iph, int hash) { + int dif = inet_iif(skb); struct sock *sk; struct hlist_head *head; int delivered = 0; @@ -181,8 +182,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); + iph->saddr, iph->daddr, dif); while (sk) { delivered = 1;