]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.4.180/ipv4-fix-raw-socket-lookup-for-local-traffic.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.4.180 / ipv4-fix-raw-socket-lookup-for-local-traffic.patch
1 From foo@baz Wed 15 May 2019 09:45:15 AM CEST
2 From: David Ahern <dsahern@gmail.com>
3 Date: Tue, 7 May 2019 20:44:59 -0700
4 Subject: ipv4: Fix raw socket lookup for local traffic
5
6 From: David Ahern <dsahern@gmail.com>
7
8 [ Upstream commit 19e4e768064a87b073a4b4c138b55db70e0cfb9f ]
9
10 inet_iif should be used for the raw socket lookup. inet_iif considers
11 rt_iif which handles the case of local traffic.
12
13 As it stands, ping to a local address with the '-I <dev>' option fails
14 ever since ping was changed to use SO_BINDTODEVICE instead of
15 cmsg + IP_PKTINFO.
16
17 IPv6 works fine.
18
19 Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
20 Signed-off-by: David Ahern <dsahern@gmail.com>
21 Signed-off-by: David S. Miller <davem@davemloft.net>
22 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
23 ---
24 net/ipv4/raw.c | 4 ++--
25 1 file changed, 2 insertions(+), 2 deletions(-)
26
27 --- a/net/ipv4/raw.c
28 +++ b/net/ipv4/raw.c
29 @@ -167,6 +167,7 @@ static int icmp_filter(const struct sock
30 */
31 static int raw_v4_input(struct sk_buff *skb, const struct iphdr *iph, int hash)
32 {
33 + int dif = inet_iif(skb);
34 struct sock *sk;
35 struct hlist_head *head;
36 int delivered = 0;
37 @@ -179,8 +180,7 @@ static int raw_v4_input(struct sk_buff *
38
39 net = dev_net(skb->dev);
40 sk = __raw_v4_lookup(net, __sk_head(head), iph->protocol,
41 - iph->saddr, iph->daddr,
42 - skb->dev->ifindex);
43 + iph->saddr, iph->daddr, dif);
44
45 while (sk) {
46 delivered = 1;