* [PATCH net-next-2.6] ipv4: avoid two atomic ops in ip_rt_redirect()
@ 2010-06-07 13:23 Eric Dumazet
2010-06-08 4:26 ` David Miller
0 siblings, 1 reply; 4+ messages in thread
From: Eric Dumazet @ 2010-06-07 13:23 UTC (permalink / raw)
To: David Miller; +Cc: netdev
in_dev_get() -> __in_dev_get_rcu() in a rcu protected function.
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
---
net/ipv4/route.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 7b8eacd..0c30534 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1343,11 +1343,12 @@ static void rt_del(unsigned hash, struct rtable *rt)
spin_unlock_bh(rt_hash_lock_addr(hash));
}
+/* called in rcu_read_lock() section */
void ip_rt_redirect(__be32 old_gw, __be32 daddr, __be32 new_gw,
__be32 saddr, struct net_device *dev)
{
int i, k;
- struct in_device *in_dev = in_dev_get(dev);
+ struct in_device *in_dev = __in_dev_get_rcu(dev);
struct rtable *rth, **rthp;
__be32 skeys[2] = { saddr, 0 };
int ikeys[2] = { dev->ifindex, 0 };
@@ -1383,7 +1384,6 @@ void ip_rt_redirect(__be32 old_gw, __be32 daddr, __be32 new_gw,
rthp=&rt_hash_table[hash].chain;
- rcu_read_lock();
while ((rth = rcu_dereference(*rthp)) != NULL) {
struct rtable *rt;
@@ -1405,12 +1405,10 @@ void ip_rt_redirect(__be32 old_gw, __be32 daddr, __be32 new_gw,
break;
dst_hold(&rth->u.dst);
- rcu_read_unlock();
rt = dst_alloc(&ipv4_dst_ops);
if (rt == NULL) {
ip_rt_put(rth);
- in_dev_put(in_dev);
return;
}
@@ -1463,12 +1461,10 @@ void ip_rt_redirect(__be32 old_gw, __be32 daddr, __be32 new_gw,
ip_rt_put(rt);
goto do_next;
}
- rcu_read_unlock();
do_next:
;
}
}
- in_dev_put(in_dev);
return;
reject_redirect:
@@ -1479,7 +1475,6 @@ reject_redirect:
&old_gw, dev->name, &new_gw,
&saddr, &daddr);
#endif
- in_dev_put(in_dev);
}
static struct dst_entry *ipv4_negative_advice(struct dst_entry *dst)
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net-next-2.6] ipv4: avoid two atomic ops in ip_rt_redirect()
2010-06-07 13:23 [PATCH net-next-2.6] ipv4: avoid two atomic ops in ip_rt_redirect() Eric Dumazet
@ 2010-06-08 4:26 ` David Miller
2010-06-08 4:51 ` David Miller
0 siblings, 1 reply; 4+ messages in thread
From: David Miller @ 2010-06-08 4:26 UTC (permalink / raw)
To: eric.dumazet; +Cc: netdev
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Mon, 07 Jun 2010 15:23:03 +0200
> in_dev_get() -> __in_dev_get_rcu() in a rcu protected function.
>
> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Applied.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next-2.6] ipv4: avoid two atomic ops in ip_rt_redirect()
2010-06-08 4:26 ` David Miller
@ 2010-06-08 4:51 ` David Miller
2010-06-08 4:56 ` Eric Dumazet
0 siblings, 1 reply; 4+ messages in thread
From: David Miller @ 2010-06-08 4:51 UTC (permalink / raw)
To: eric.dumazet; +Cc: netdev
From: David Miller <davem@davemloft.net>
Date: Mon, 07 Jun 2010 21:26:22 -0700 (PDT)
> From: Eric Dumazet <eric.dumazet@gmail.com>
> Date: Mon, 07 Jun 2010 15:23:03 +0200
>
>> in_dev_get() -> __in_dev_get_rcu() in a rcu protected function.
>>
>> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
>
> Applied.
I needed to modify this patch to get it to build.
You left a code label with no code afterwards at the end of
ip_rt_redirect() when CONFIG_IP_ROUTE_VERBOSE is disabled,
which breaks the build.
I fixed it by adding a semicolon.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next-2.6] ipv4: avoid two atomic ops in ip_rt_redirect()
2010-06-08 4:51 ` David Miller
@ 2010-06-08 4:56 ` Eric Dumazet
0 siblings, 0 replies; 4+ messages in thread
From: Eric Dumazet @ 2010-06-08 4:56 UTC (permalink / raw)
To: David Miller; +Cc: netdev
Le lundi 07 juin 2010 à 21:51 -0700, David Miller a écrit :
> From: David Miller <davem@davemloft.net>
> Date: Mon, 07 Jun 2010 21:26:22 -0700 (PDT)
>
> > From: Eric Dumazet <eric.dumazet@gmail.com>
> > Date: Mon, 07 Jun 2010 15:23:03 +0200
> >
> >> in_dev_get() -> __in_dev_get_rcu() in a rcu protected function.
> >>
> >> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
> >
> > Applied.
>
> I needed to modify this patch to get it to build.
>
> You left a code label with no code afterwards at the end of
> ip_rt_redirect() when CONFIG_IP_ROUTE_VERBOSE is disabled,
> which breaks the build.
>
> I fixed it by adding a semicolon.
OK, thanks David, I missed this.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-06-08 4:56 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-07 13:23 [PATCH net-next-2.6] ipv4: avoid two atomic ops in ip_rt_redirect() Eric Dumazet
2010-06-08 4:26 ` David Miller
2010-06-08 4:51 ` David Miller
2010-06-08 4:56 ` Eric Dumazet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox