* [PATCH] ipv4: fix the problem of ping failure in some cases
@ 2020-08-22 7:46 guodeqing
2020-08-24 2:27 ` David Ahern
0 siblings, 1 reply; 4+ messages in thread
From: guodeqing @ 2020-08-22 7:46 UTC (permalink / raw)
To: davem; +Cc: kuba, dsahern, netdev, geffrey.guo
ie.,
$ ifconfig eth0 9.9.9.9 netmask 255.255.255.0
$ ping -I lo 9.9.9.9
ping: Warning: source address might be selected on device other than lo.
PING 9.9.9.9 (9.9.9.9) from 9.9.9.9 lo: 56(84) bytes of data.
4 packets transmitted, 0 received, 100% packet loss, time 3068ms
This is because the return value of __raw_v4_lookup in raw_v4_input
is null, the packets cannot be sent to the ping application.
The reason of the __raw_v4_lookup failure is that sk_bound_dev_if and
dif/sdif are not equal in raw_sk_bound_dev_eq.
Here I add a check of whether the sk_bound_dev_if is LOOPBACK_IFINDEX
to solve this problem.
Fixes: 19e4e768064a8 ("ipv4: Fix raw socket lookup for local traffic")
Signed-off-by: guodeqing <geffrey.guo@huawei.com>
---
include/net/inet_sock.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h
index a3702d1..7707b1d 100644
--- a/include/net/inet_sock.h
+++ b/include/net/inet_sock.h
@@ -144,7 +144,7 @@ static inline bool inet_bound_dev_eq(bool l3mdev_accept, int bound_dev_if,
{
if (!bound_dev_if)
return !sdif || l3mdev_accept;
- return bound_dev_if == dif || bound_dev_if == sdif;
+ return bound_dev_if == dif || bound_dev_if == sdif || bound_dev_if == LOOPBACK_IFINDEX;
}
struct inet_cork {
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] ipv4: fix the problem of ping failure in some cases
2020-08-22 7:46 [PATCH] ipv4: fix the problem of ping failure in some cases guodeqing
@ 2020-08-24 2:27 ` David Ahern
2020-08-24 2:33 ` David Ahern
0 siblings, 1 reply; 4+ messages in thread
From: David Ahern @ 2020-08-24 2:27 UTC (permalink / raw)
To: guodeqing, davem; +Cc: kuba, dsahern, netdev
On 8/22/20 1:46 AM, guodeqing wrote:
> ie.,
> $ ifconfig eth0 9.9.9.9 netmask 255.255.255.0
>
> $ ping -I lo 9.9.9.9
> ping: Warning: source address might be selected on device other than lo.
> PING 9.9.9.9 (9.9.9.9) from 9.9.9.9 lo: 56(84) bytes of data.
>
> 4 packets transmitted, 0 received, 100% packet loss, time 3068ms
>
> This is because the return value of __raw_v4_lookup in raw_v4_input
> is null, the packets cannot be sent to the ping application.
> The reason of the __raw_v4_lookup failure is that sk_bound_dev_if and
> dif/sdif are not equal in raw_sk_bound_dev_eq.
>
> Here I add a check of whether the sk_bound_dev_if is LOOPBACK_IFINDEX
> to solve this problem.
>
> Fixes: 19e4e768064a8 ("ipv4: Fix raw socket lookup for local traffic")
> Signed-off-by: guodeqing <geffrey.guo@huawei.com>
> ---
> include/net/inet_sock.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h
> index a3702d1..7707b1d 100644
> --- a/include/net/inet_sock.h
> +++ b/include/net/inet_sock.h
> @@ -144,7 +144,7 @@ static inline bool inet_bound_dev_eq(bool l3mdev_accept, int bound_dev_if,
> {
> if (!bound_dev_if)
> return !sdif || l3mdev_accept;
> - return bound_dev_if == dif || bound_dev_if == sdif;
> + return bound_dev_if == dif || bound_dev_if == sdif || bound_dev_if == LOOPBACK_IFINDEX;
> }
>
> struct inet_cork {
>
this is used by more than just raw socket lookups.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ipv4: fix the problem of ping failure in some cases
2020-08-24 2:27 ` David Ahern
@ 2020-08-24 2:33 ` David Ahern
2020-08-24 3:09 ` 答复: " Guodeqing (A)
0 siblings, 1 reply; 4+ messages in thread
From: David Ahern @ 2020-08-24 2:33 UTC (permalink / raw)
To: guodeqing, davem; +Cc: kuba, netdev
On 8/23/20 8:27 PM, David Ahern wrote:
> On 8/22/20 1:46 AM, guodeqing wrote:
>> ie.,
>> $ ifconfig eth0 9.9.9.9 netmask 255.255.255.0
>>
>> $ ping -I lo 9.9.9.9
If that ever worked it was wrong; the address is scoped to eth0, not lo.
>> ping: Warning: source address might be selected on device other than lo.
>> PING 9.9.9.9 (9.9.9.9) from 9.9.9.9 lo: 56(84) bytes of data.
>>
>> 4 packets transmitted, 0 received, 100% packet loss, time 3068ms
>>
>> This is because the return value of __raw_v4_lookup in raw_v4_input
>> is null, the packets cannot be sent to the ping application.
>> The reason of the __raw_v4_lookup failure is that sk_bound_dev_if and
>> dif/sdif are not equal in raw_sk_bound_dev_eq.
>>
>> Here I add a check of whether the sk_bound_dev_if is LOOPBACK_IFINDEX
>> to solve this problem.
>>
>> Fixes: 19e4e768064a8 ("ipv4: Fix raw socket lookup for local traffic")
>> Signed-off-by: guodeqing <geffrey.guo@huawei.com>
>> ---
>> include/net/inet_sock.h | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h
>> index a3702d1..7707b1d 100644
>> --- a/include/net/inet_sock.h
>> +++ b/include/net/inet_sock.h
>> @@ -144,7 +144,7 @@ static inline bool inet_bound_dev_eq(bool l3mdev_accept, int bound_dev_if,
>> {
>> if (!bound_dev_if)
>> return !sdif || l3mdev_accept;
>> - return bound_dev_if == dif || bound_dev_if == sdif;
>> + return bound_dev_if == dif || bound_dev_if == sdif || bound_dev_if == LOOPBACK_IFINDEX;
>> }
>>
>> struct inet_cork {
>>
>
> this is used by more than just raw socket lookups.
>
And assuming it should work, this is definitely the wrong fix.
^ permalink raw reply [flat|nested] 4+ messages in thread
* 答复: [PATCH] ipv4: fix the problem of ping failure in some cases
2020-08-24 2:33 ` David Ahern
@ 2020-08-24 3:09 ` Guodeqing (A)
0 siblings, 0 replies; 4+ messages in thread
From: Guodeqing (A) @ 2020-08-24 3:09 UTC (permalink / raw)
To: David Ahern, davem; +Cc: kuba, netdev
> -----邮件原件-----
> 发件人: David Ahern [mailto:dsahern@gmail.com]
> 发送时间: Monday, August 24, 2020 10:34
> 收件人: Guodeqing (A) <geffrey.guo@huawei.com>; davem@davemloft.net
> 抄送: kuba@kernel.org; netdev@vger.kernel.org
> 主题: Re: [PATCH] ipv4: fix the problem of ping failure in some cases
>
> On 8/23/20 8:27 PM, David Ahern wrote:
> > On 8/22/20 1:46 AM, guodeqing wrote:
> >> ie.,
> >> $ ifconfig eth0 9.9.9.9 netmask 255.255.255.0
> >>
> >> $ ping -I lo 9.9.9.9
>
> If that ever worked it was wrong; the address is scoped to eth0, not lo.
>
> >> ping: Warning: source address might be selected on device other than lo.
> >> PING 9.9.9.9 (9.9.9.9) from 9.9.9.9 lo: 56(84) bytes of data.
> >>
> >> 4 packets transmitted, 0 received, 100% packet loss, time 3068ms
> >>
> >> This is because the return value of __raw_v4_lookup in raw_v4_input
> >> is null, the packets cannot be sent to the ping application.
> >> The reason of the __raw_v4_lookup failure is that sk_bound_dev_if and
> >> dif/sdif are not equal in raw_sk_bound_dev_eq.
> >>
> >> Here I add a check of whether the sk_bound_dev_if is LOOPBACK_IFINDEX
> >> to solve this problem.
> >>
> >> Fixes: 19e4e768064a8 ("ipv4: Fix raw socket lookup for local
> >> traffic")
> >> Signed-off-by: guodeqing <geffrey.guo@huawei.com>
> >> ---
> >> include/net/inet_sock.h | 2 +-
> >> 1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h index
> >> a3702d1..7707b1d 100644
> >> --- a/include/net/inet_sock.h
> >> +++ b/include/net/inet_sock.h
> >> @@ -144,7 +144,7 @@ static inline bool inet_bound_dev_eq(bool
> >> l3mdev_accept, int bound_dev_if, {
> >> if (!bound_dev_if)
> >> return !sdif || l3mdev_accept;
> >> - return bound_dev_if == dif || bound_dev_if == sdif;
> >> + return bound_dev_if == dif || bound_dev_if == sdif || bound_dev_if
> >> +== LOOPBACK_IFINDEX;
> >> }
> >>
> >> struct inet_cork {
> >>
> >
> > this is used by more than just raw socket lookups.
> >
>
> And assuming it should work, this is definitely the wrong fix.
ok, I see now. I misunderstood the function of the loopback interface, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-08-24 3:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-22 7:46 [PATCH] ipv4: fix the problem of ping failure in some cases guodeqing
2020-08-24 2:27 ` David Ahern
2020-08-24 2:33 ` David Ahern
2020-08-24 3:09 ` 答复: " Guodeqing (A)
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.