* [PATCH] net: Fix sk_dst_check() to reset the obsolete dst_entry of a socket.
@ 2010-10-06 7:27 Chung-Yih Wang (王崇懿)
2010-10-06 7:35 ` David Miller
0 siblings, 1 reply; 6+ messages in thread
From: Chung-Yih Wang (王崇懿) @ 2010-10-06 7:27 UTC (permalink / raw)
To: netdev; +Cc: linux-kernel
The issue is caused by the CL d11a4dc18bf41719c9f0d7ed494d295dd2973b92
which will never reset the dst_entry of a socket if its current entry
is freed(obsolete) for ipv4. This will block the socket's traffic
instead of looking up a new dst_entry.
Signed-off-by: Chung-yih Wang <cywang@google.com>
---
diff --git a/net/core/sock.c b/net/core/sock.c
index ef30e9d..b508819 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -382,7 +382,8 @@ struct dst_entry *__sk_dst_check(struct sock *sk,
u32 cookie)
{
struct dst_entry *dst = __sk_dst_get(sk);
- if (dst && dst->obsolete && dst->ops->check(dst, cookie) == NULL) {
+ if (dst && dst->obsolete && ((dst->obsolete > 0) ||
+ (dst->ops->check(dst, cookie) == NULL))) {
sk_tx_queue_clear(sk);
rcu_assign_pointer(sk->sk_dst_cache, NULL);
dst_release(dst);
@@ -397,7 +398,8 @@ struct dst_entry *sk_dst_check(struct sock *sk, u32 cookie)
{
struct dst_entry *dst = sk_dst_get(sk);
- if (dst && dst->obsolete && dst->ops->check(dst, cookie) == NULL) {
+ if (dst && dst->obsolete && ((dst->obsolete > 0) ||
+ (dst->ops->check(dst, cookie) == NULL))) {
sk_dst_reset(sk);
dst_release(dst);
return NULL;
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH] net: Fix sk_dst_check() to reset the obsolete dst_entry of a socket. 2010-10-06 7:27 [PATCH] net: Fix sk_dst_check() to reset the obsolete dst_entry of a socket Chung-Yih Wang (王崇懿) @ 2010-10-06 7:35 ` David Miller 2010-10-06 7:47 ` Chung-Yih Wang (王崇懿) 0 siblings, 1 reply; 6+ messages in thread From: David Miller @ 2010-10-06 7:35 UTC (permalink / raw) To: cywang; +Cc: netdev, linux-kernel, timo.teras This should have been fixed by: -------------------- commit ae2688d59b5f861dc70a091d003773975d2ae7fb Author: Jianzhao Wang <jianzhao.wang@6wind.com> Date: Wed Sep 8 14:35:43 2010 -0700 net: blackhole route should always be recalculated Blackhole routes are used when xfrm_lookup() returns -EREMOTE (error triggered by IKE for example), hence this kind of route is always temporary and so we should check if a better route exists for next packets. Bug has been introduced by commit d11a4dc18bf41719c9f0d7ed494d295dd2973b92. Signed-off-by: Jianzhao Wang <jianzhao.wang@6wind.com> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com> Signed-off-by: David S. Miller <davem@davemloft.net> diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 3f56b6e..6298f75 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -2738,6 +2738,11 @@ slow_output: } EXPORT_SYMBOL_GPL(__ip_route_output_key); +static struct dst_entry *ipv4_blackhole_dst_check(struct dst_entry *dst, u32 cookie) +{ + return NULL; +} + static void ipv4_rt_blackhole_update_pmtu(struct dst_entry *dst, u32 mtu) { } @@ -2746,7 +2751,7 @@ static struct dst_ops ipv4_dst_blackhole_ops = { .family = AF_INET, .protocol = cpu_to_be16(ETH_P_IP), .destroy = ipv4_dst_destroy, - .check = ipv4_dst_check, + .check = ipv4_blackhole_dst_check, .update_pmtu = ipv4_rt_blackhole_update_pmtu, .entries = ATOMIC_INIT(0), }; ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] net: Fix sk_dst_check() to reset the obsolete dst_entry of a socket. 2010-10-06 7:35 ` David Miller @ 2010-10-06 7:47 ` Chung-Yih Wang (王崇懿) 2010-10-06 9:47 ` Chung-Yih Wang (王崇懿) 0 siblings, 1 reply; 6+ messages in thread From: Chung-Yih Wang (王崇懿) @ 2010-10-06 7:47 UTC (permalink / raw) To: David Miller; +Cc: netdev, linux-kernel, timo.teras In fact, that is what I intent to change originally. However, consider Timo's issue, I intent to submit this patch instead. On Wed, Oct 6, 2010 at 12:35 AM, David Miller <davem@davemloft.net> wrote: > > This should have been fixed by: > > -------------------- > commit ae2688d59b5f861dc70a091d003773975d2ae7fb > Author: Jianzhao Wang <jianzhao.wang@6wind.com> > Date: Wed Sep 8 14:35:43 2010 -0700 > > net: blackhole route should always be recalculated > > Blackhole routes are used when xfrm_lookup() returns -EREMOTE (error > triggered by IKE for example), hence this kind of route is always > temporary and so we should check if a better route exists for next > packets. > Bug has been introduced by commit d11a4dc18bf41719c9f0d7ed494d295dd2973b92. > > Signed-off-by: Jianzhao Wang <jianzhao.wang@6wind.com> > Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com> > Signed-off-by: David S. Miller <davem@davemloft.net> > > diff --git a/net/ipv4/route.c b/net/ipv4/route.c > index 3f56b6e..6298f75 100644 > --- a/net/ipv4/route.c > +++ b/net/ipv4/route.c > @@ -2738,6 +2738,11 @@ slow_output: > } > EXPORT_SYMBOL_GPL(__ip_route_output_key); > > +static struct dst_entry *ipv4_blackhole_dst_check(struct dst_entry *dst, u32 cookie) > +{ > + return NULL; > +} > + > static void ipv4_rt_blackhole_update_pmtu(struct dst_entry *dst, u32 mtu) > { > } > @@ -2746,7 +2751,7 @@ static struct dst_ops ipv4_dst_blackhole_ops = { > .family = AF_INET, > .protocol = cpu_to_be16(ETH_P_IP), > .destroy = ipv4_dst_destroy, > - .check = ipv4_dst_check, > + .check = ipv4_blackhole_dst_check, > .update_pmtu = ipv4_rt_blackhole_update_pmtu, > .entries = ATOMIC_INIT(0), > }; > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] net: Fix sk_dst_check() to reset the obsolete dst_entry of a socket. 2010-10-06 7:47 ` Chung-Yih Wang (王崇懿) @ 2010-10-06 9:47 ` Chung-Yih Wang (王崇懿) 2010-10-07 19:37 ` Chung-Yih Wang (王崇懿) 0 siblings, 1 reply; 6+ messages in thread From: Chung-Yih Wang (王崇懿) @ 2010-10-06 9:47 UTC (permalink / raw) To: David Miller; +Cc: netdev, linux-kernel, timo.teras I did not pay attention to the CL, actually that did not fix the issue I encountered. I have a connected UDP socket which will not escape from the "blackhole" since it will never enter the ipv4_blackhole function. In udp_sendmsg(), if the socket is connected one and the dst entry is obsolete, you will never have a chance to reset the socket's dst entry since rt will not be NULL. udp_sendmsg() { .... if (connected) rt = (struct rtable *)sk_dst_check(sk, 0); if (rt == NULL) { ... blackhole_function_will_be_executed_here? } ... } On Wed, Oct 6, 2010 at 12:47 AM, Chung-Yih Wang (王崇懿) <cywang@google.com> wrote: > In fact, that is what I intent to change originally. However, consider > Timo's issue, I intent to submit this patch instead. > > On Wed, Oct 6, 2010 at 12:35 AM, David Miller <davem@davemloft.net> wrote: >> >> This should have been fixed by: >> >> -------------------- >> commit ae2688d59b5f861dc70a091d003773975d2ae7fb >> Author: Jianzhao Wang <jianzhao.wang@6wind.com> >> Date: Wed Sep 8 14:35:43 2010 -0700 >> >> net: blackhole route should always be recalculated >> >> Blackhole routes are used when xfrm_lookup() returns -EREMOTE (error >> triggered by IKE for example), hence this kind of route is always >> temporary and so we should check if a better route exists for next >> packets. >> Bug has been introduced by commit d11a4dc18bf41719c9f0d7ed494d295dd2973b92. >> >> Signed-off-by: Jianzhao Wang <jianzhao.wang@6wind.com> >> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com> >> Signed-off-by: David S. Miller <davem@davemloft.net> >> >> diff --git a/net/ipv4/route.c b/net/ipv4/route.c >> index 3f56b6e..6298f75 100644 >> --- a/net/ipv4/route.c >> +++ b/net/ipv4/route.c >> @@ -2738,6 +2738,11 @@ slow_output: >> } >> EXPORT_SYMBOL_GPL(__ip_route_output_key); >> >> +static struct dst_entry *ipv4_blackhole_dst_check(struct dst_entry *dst, u32 cookie) >> +{ >> + return NULL; >> +} >> + >> static void ipv4_rt_blackhole_update_pmtu(struct dst_entry *dst, u32 mtu) >> { >> } >> @@ -2746,7 +2751,7 @@ static struct dst_ops ipv4_dst_blackhole_ops = { >> .family = AF_INET, >> .protocol = cpu_to_be16(ETH_P_IP), >> .destroy = ipv4_dst_destroy, >> - .check = ipv4_dst_check, >> + .check = ipv4_blackhole_dst_check, >> .update_pmtu = ipv4_rt_blackhole_update_pmtu, >> .entries = ATOMIC_INIT(0), >> }; >> > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] net: Fix sk_dst_check() to reset the obsolete dst_entry of a socket. 2010-10-06 9:47 ` Chung-Yih Wang (王崇懿) @ 2010-10-07 19:37 ` Chung-Yih Wang (王崇懿) 2010-10-10 1:10 ` Chung-Yih Wang (王崇懿) 0 siblings, 1 reply; 6+ messages in thread From: Chung-Yih Wang (王崇懿) @ 2010-10-07 19:37 UTC (permalink / raw) To: David Miller; +Cc: netdev, linux-kernel, timo.teras As I am testing the l2tp/ipsec client(it is working fine on 2.6.32 but failed on 2.6.35 with the same client). Please see the following log dump for sk_dst_check(). <2>[ 201.390289] ==== sk_dst_check sk=C7485800 dst=C717AC60 obsolete=FFFFFFFF cookie=0 check=C0296510 <2>[ 211.247467] ==== sk_dst_check sk=C7485000 dst=C717AC60 obsolete=FFFFFFFF cookie=0 check=C0296510 [Basically, the ipsec tunnel is built and then free the dst_entry for this l2tp socket. Therefore, the obsolete entry should be reset in sk_dst_check(). However, the kernel 2.6.35 will do nothing here since the ipv4_dst_check still return the obsolete entry even if it is obsolete(dst->obsolete=2)] <2>[ 216.571350] ==== sk_dst_check sk=C7485400 dst=C6F670E0 obsolete=00000002 cookie=0 check=C0296510 <6>[ 218.069396] alg: No test for authenc(hmac(sha1),cbc(des3_ede)) (authenc(hmac(sha1-generic),cbc(des3_ede-generic))) <6>[ 218.164764] batt: 96%, 4114 mV, 0 mA (-6 avg), 27.2 C, 1305 mAh <2>[ 218.575561] ==== sk_dst_check sk=C7485400 dst=C6F670E0 obsolete=00000002 cookie=0 check=C0296510 <2>[ 220.580535] ==== sk_dst_check sk=C7485400 dst=C6F670E0 obsolete=00000002 cookie=0 check=C0296510 <2>[ 222.585754] ==== sk_dst_check sk=C7485400 dst=C6F670E0 obsolete=00000002 cookie=0 check=C0296510 <2>[ 224.591522] ==== sk_dst_check sk=C7485400 dst=C6F670E0 obsolete=00000002 cookie=0 check=C0296510 <2>[ 226.599212] ==== sk_dst_check sk=C7485400 dst=C6F670E0 obsolete=00000002 cookie=0 check=C0296510 <2>[ 228.602600] ==== sk_dst_check sk=C7485400 dst=C6F670E0 obsolete=00000002 cookie=0 check=C0296510 <2>[ 230.608062] ==== sk_dst_check sk=C7485400 dst=C6F670E0 obsolete=00000002 cookie=0 check=C0296510 <2>[ 232.613464] ==== sk_dst_check sk=C7485400 dst=C6F670E0 obsolete=00000002 cookie=0 check=C0296510 <2>[ 234.618896] ==== sk_dst_check sk=C7485400 dst=C6F670E0 obsolete=00000002 cookie=0 check=C0296510 <2>[ 236.623504] ==== sk_dst_check sk=C7485400 dst=C6F670E0 obsolete=00000002 cookie=0 check=C0296510 <2>[ 238.628936] ==== sk_dst_check sk=C7485400 dst=C6F670E0 obsolete=00000002 cookie=0 check=C0296510 <2>[ 240.634338] ==== sk_dst_check sk=C7485400 dst=C6F670E0 obsolete=00000002 cookie=0 check=C0296510 <2>[ 242.639709] ==== sk_dst_check sk=C7485400 dst=C6F670E0 obsolete=00000002 cookie=0 check=C0296510 <2>[ 244.645111] ==== sk_dst_check sk=C7485400 dst=C6F670E0 obsolete=00000002 cookie=0 check=C0296510 <2>[ 246.648864] ==== sk_dst_check sk=C7485400 dst=C6F670E0 obsolete=00000002 cookie=0 check=C0296510 <2>[ 248.654693] ==== sk_dst_check sk=C7485400 dst=C6F670E0 obsolete=00000002 cookie=0 check=C0296510 <2>[ 250.660125] ==== sk_dst_check sk=C7485400 dst=C6F670E0 obsolete=00000002 cookie=0 check=C0296510 <2>[ 252.665527] ==== sk_dst_check sk=C7485400 dst=C6F670E0 obsolete=00000002 cookie=0 check=C0296510 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] net: Fix sk_dst_check() to reset the obsolete dst_entry of a socket. 2010-10-07 19:37 ` Chung-Yih Wang (王崇懿) @ 2010-10-10 1:10 ` Chung-Yih Wang (王崇懿) 0 siblings, 0 replies; 6+ messages in thread From: Chung-Yih Wang (王崇懿) @ 2010-10-10 1:10 UTC (permalink / raw) To: David Miller; +Cc: netdev, linux-kernel, timo.teras After I gave it a try, that patch worked. Please ignore my patch then. Thanks! On Thu, Oct 7, 2010 at 12:37 PM, Chung-Yih Wang (王崇懿) <cywang@google.com> wrote: > As I am testing the l2tp/ipsec client(it is working fine on 2.6.32 but > failed on 2.6.35 with the same client). Please see the following log > dump for sk_dst_check(). > > <2>[ 201.390289] ==== sk_dst_check sk=C7485800 dst=C717AC60 > obsolete=FFFFFFFF cookie=0 check=C0296510 > <2>[ 211.247467] ==== sk_dst_check sk=C7485000 dst=C717AC60 > obsolete=FFFFFFFF cookie=0 check=C0296510 > > [Basically, the ipsec tunnel is built and then free the dst_entry for > this l2tp socket. Therefore, the obsolete entry should be reset in > sk_dst_check(). However, the kernel 2.6.35 will do nothing here since > the ipv4_dst_check still return the obsolete entry even if it is > obsolete(dst->obsolete=2)] > > <2>[ 216.571350] ==== sk_dst_check sk=C7485400 dst=C6F670E0 > obsolete=00000002 cookie=0 check=C0296510 > <6>[ 218.069396] alg: No test for authenc(hmac(sha1),cbc(des3_ede)) > (authenc(hmac(sha1-generic),cbc(des3_ede-generic))) > <6>[ 218.164764] batt: 96%, 4114 mV, 0 mA (-6 avg), 27.2 C, 1305 mAh > <2>[ 218.575561] ==== sk_dst_check sk=C7485400 dst=C6F670E0 > obsolete=00000002 cookie=0 check=C0296510 > <2>[ 220.580535] ==== sk_dst_check sk=C7485400 dst=C6F670E0 > obsolete=00000002 cookie=0 check=C0296510 > <2>[ 222.585754] ==== sk_dst_check sk=C7485400 dst=C6F670E0 > obsolete=00000002 cookie=0 check=C0296510 > <2>[ 224.591522] ==== sk_dst_check sk=C7485400 dst=C6F670E0 > obsolete=00000002 cookie=0 check=C0296510 > <2>[ 226.599212] ==== sk_dst_check sk=C7485400 dst=C6F670E0 > obsolete=00000002 cookie=0 check=C0296510 > <2>[ 228.602600] ==== sk_dst_check sk=C7485400 dst=C6F670E0 > obsolete=00000002 cookie=0 check=C0296510 > <2>[ 230.608062] ==== sk_dst_check sk=C7485400 dst=C6F670E0 > obsolete=00000002 cookie=0 check=C0296510 > <2>[ 232.613464] ==== sk_dst_check sk=C7485400 dst=C6F670E0 > obsolete=00000002 cookie=0 check=C0296510 > <2>[ 234.618896] ==== sk_dst_check sk=C7485400 dst=C6F670E0 > obsolete=00000002 cookie=0 check=C0296510 > <2>[ 236.623504] ==== sk_dst_check sk=C7485400 dst=C6F670E0 > obsolete=00000002 cookie=0 check=C0296510 > <2>[ 238.628936] ==== sk_dst_check sk=C7485400 dst=C6F670E0 > obsolete=00000002 cookie=0 check=C0296510 > <2>[ 240.634338] ==== sk_dst_check sk=C7485400 dst=C6F670E0 > obsolete=00000002 cookie=0 check=C0296510 > <2>[ 242.639709] ==== sk_dst_check sk=C7485400 dst=C6F670E0 > obsolete=00000002 cookie=0 check=C0296510 > <2>[ 244.645111] ==== sk_dst_check sk=C7485400 dst=C6F670E0 > obsolete=00000002 cookie=0 check=C0296510 > <2>[ 246.648864] ==== sk_dst_check sk=C7485400 dst=C6F670E0 > obsolete=00000002 cookie=0 check=C0296510 > <2>[ 248.654693] ==== sk_dst_check sk=C7485400 dst=C6F670E0 > obsolete=00000002 cookie=0 check=C0296510 > <2>[ 250.660125] ==== sk_dst_check sk=C7485400 dst=C6F670E0 > obsolete=00000002 cookie=0 check=C0296510 > <2>[ 252.665527] ==== sk_dst_check sk=C7485400 dst=C6F670E0 > obsolete=00000002 cookie=0 check=C0296510 > ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-10-10 1:10 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2010-10-06 7:27 [PATCH] net: Fix sk_dst_check() to reset the obsolete dst_entry of a socket Chung-Yih Wang (王崇懿) 2010-10-06 7:35 ` David Miller 2010-10-06 7:47 ` Chung-Yih Wang (王崇懿) 2010-10-06 9:47 ` Chung-Yih Wang (王崇懿) 2010-10-07 19:37 ` Chung-Yih Wang (王崇懿) 2010-10-10 1:10 ` Chung-Yih Wang (王崇懿)
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).