diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2005-10-03 17:35:55 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2005-10-03 17:35:55 -0400 |
commit | e5ed639913eea3e4783a550291775ab78dd84966 (patch) | |
tree | e6e915aa686d2a7125181fc83a847e1955a8ba46 /drivers/net/wan | |
parent | a5e7c210fefd2454c757a3542e41063407ca7108 (diff) |
[IPV4]: Replace __in_dev_get with __in_dev_get_rcu/rtnl
The following patch renames __in_dev_get() to __in_dev_get_rtnl() and
introduces __in_dev_get_rcu() to cover the second case.
1) RCU with refcnt should use in_dev_get().
2) RCU without refcnt should use __in_dev_get_rcu().
3) All others must hold RTNL and use __in_dev_get_rtnl().
There is one exception in net/ipv4/route.c which is in fact a pre-existing
race condition. I've marked it as such so that we remember to fix it.
This patch is based on suggestions and prior work by Suzanne Wood and
Paul McKenney.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/wan')
-rw-r--r-- | drivers/net/wan/sdlamain.c | 23 | ||||
-rw-r--r-- | drivers/net/wan/syncppp.c | 2 |
2 files changed, 15 insertions, 10 deletions
diff --git a/drivers/net/wan/sdlamain.c b/drivers/net/wan/sdlamain.c index 74e151acef3e..7a8b22a7ea31 100644 --- a/drivers/net/wan/sdlamain.c +++ b/drivers/net/wan/sdlamain.c | |||
@@ -57,6 +57,7 @@ | |||
57 | #include <linux/ioport.h> /* request_region(), release_region() */ | 57 | #include <linux/ioport.h> /* request_region(), release_region() */ |
58 | #include <linux/wanrouter.h> /* WAN router definitions */ | 58 | #include <linux/wanrouter.h> /* WAN router definitions */ |
59 | #include <linux/wanpipe.h> /* WANPIPE common user API definitions */ | 59 | #include <linux/wanpipe.h> /* WANPIPE common user API definitions */ |
60 | #include <linux/rcupdate.h> | ||
60 | 61 | ||
61 | #include <linux/in.h> | 62 | #include <linux/in.h> |
62 | #include <asm/io.h> /* phys_to_virt() */ | 63 | #include <asm/io.h> /* phys_to_virt() */ |
@@ -1268,37 +1269,41 @@ unsigned long get_ip_address(struct net_device *dev, int option) | |||
1268 | 1269 | ||
1269 | struct in_ifaddr *ifaddr; | 1270 | struct in_ifaddr *ifaddr; |
1270 | struct in_device *in_dev; | 1271 | struct in_device *in_dev; |
1272 | unsigned long addr = 0; | ||
1271 | 1273 | ||
1272 | if ((in_dev = __in_dev_get(dev)) == NULL){ | 1274 | rcu_read_lock(); |
1273 | return 0; | 1275 | if ((in_dev = __in_dev_get_rcu(dev)) == NULL){ |
1276 | goto out; | ||
1274 | } | 1277 | } |
1275 | 1278 | ||
1276 | if ((ifaddr = in_dev->ifa_list)== NULL ){ | 1279 | if ((ifaddr = in_dev->ifa_list)== NULL ){ |
1277 | return 0; | 1280 | goto out; |
1278 | } | 1281 | } |
1279 | 1282 | ||
1280 | switch (option){ | 1283 | switch (option){ |
1281 | 1284 | ||
1282 | case WAN_LOCAL_IP: | 1285 | case WAN_LOCAL_IP: |
1283 | return ifaddr->ifa_local; | 1286 | addr = ifaddr->ifa_local; |
1284 | break; | 1287 | break; |
1285 | 1288 | ||
1286 | case WAN_POINTOPOINT_IP: | 1289 | case WAN_POINTOPOINT_IP: |
1287 | return ifaddr->ifa_address; | 1290 | addr = ifaddr->ifa_address; |
1288 | break; | 1291 | break; |
1289 | 1292 | ||
1290 | case WAN_NETMASK_IP: | 1293 | case WAN_NETMASK_IP: |
1291 | return ifaddr->ifa_mask; | 1294 | addr = ifaddr->ifa_mask; |
1292 | break; | 1295 | break; |
1293 | 1296 | ||
1294 | case WAN_BROADCAST_IP: | 1297 | case WAN_BROADCAST_IP: |
1295 | return ifaddr->ifa_broadcast; | 1298 | addr = ifaddr->ifa_broadcast; |
1296 | break; | 1299 | break; |
1297 | default: | 1300 | default: |
1298 | return 0; | 1301 | break; |
1299 | } | 1302 | } |
1300 | 1303 | ||
1301 | return 0; | 1304 | out: |
1305 | rcu_read_unlock(); | ||
1306 | return addr; | ||
1302 | } | 1307 | } |
1303 | 1308 | ||
1304 | void add_gateway(sdla_t *card, struct net_device *dev) | 1309 | void add_gateway(sdla_t *card, struct net_device *dev) |
diff --git a/drivers/net/wan/syncppp.c b/drivers/net/wan/syncppp.c index b56a7b516d24..a6d3b55013a5 100644 --- a/drivers/net/wan/syncppp.c +++ b/drivers/net/wan/syncppp.c | |||
@@ -769,7 +769,7 @@ static void sppp_cisco_input (struct sppp *sp, struct sk_buff *skb) | |||
769 | u32 addr = 0, mask = ~0; /* FIXME: is the mask correct? */ | 769 | u32 addr = 0, mask = ~0; /* FIXME: is the mask correct? */ |
770 | #ifdef CONFIG_INET | 770 | #ifdef CONFIG_INET |
771 | rcu_read_lock(); | 771 | rcu_read_lock(); |
772 | if ((in_dev = __in_dev_get(dev)) != NULL) | 772 | if ((in_dev = __in_dev_get_rcu(dev)) != NULL) |
773 | { | 773 | { |
774 | for (ifa=in_dev->ifa_list; ifa != NULL; | 774 | for (ifa=in_dev->ifa_list; ifa != NULL; |
775 | ifa=ifa->ifa_next) { | 775 | ifa=ifa->ifa_next) { |