Skip to content

Commit 19e4e76

Browse files
dsaherndavem330
authored andcommitted
ipv4: Fix raw socket lookup for local traffic
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 <dev>' option fails ever since ping was changed to use SO_BINDTODEVICE instead of cmsg + IP_PKTINFO. IPv6 works fine. Fixes: 1da177e ("Linux-2.6.12-rc2") Signed-off-by: David Ahern <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent e9919a2 commit 19e4e76

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

net/ipv4/raw.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ static int icmp_filter(const struct sock *sk, const struct sk_buff *skb)
173173
static int raw_v4_input(struct sk_buff *skb, const struct iphdr *iph, int hash)
174174
{
175175
int sdif = inet_sdif(skb);
176+
int dif = inet_iif(skb);
176177
struct sock *sk;
177178
struct hlist_head *head;
178179
int delivered = 0;
@@ -185,8 +186,7 @@ static int raw_v4_input(struct sk_buff *skb, const struct iphdr *iph, int hash)
185186

186187
net = dev_net(skb->dev);
187188
sk = __raw_v4_lookup(net, __sk_head(head), iph->protocol,
188-
iph->saddr, iph->daddr,
189-
skb->dev->ifindex, sdif);
189+
iph->saddr, iph->daddr, dif, sdif);
190190

191191
while (sk) {
192192
delivered = 1;

0 commit comments

Comments
 (0)