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 | |
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')
-rw-r--r-- | drivers/net/bonding/bond_main.c | 2 | ||||
-rw-r--r-- | drivers/net/wan/sdlamain.c | 23 | ||||
-rw-r--r-- | drivers/net/wan/syncppp.c | 2 | ||||
-rw-r--r-- | drivers/net/wireless/strip.c | 4 | ||||
-rw-r--r-- | drivers/parisc/led.c | 5 | ||||
-rw-r--r-- | drivers/s390/net/qeth_main.c | 4 |
6 files changed, 24 insertions, 16 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 6d00c3de1a83..bf81cd45e4d4 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c | |||
@@ -2776,7 +2776,7 @@ static u32 bond_glean_dev_ip(struct net_device *dev) | |||
2776 | return 0; | 2776 | return 0; |
2777 | 2777 | ||
2778 | rcu_read_lock(); | 2778 | rcu_read_lock(); |
2779 | idev = __in_dev_get(dev); | 2779 | idev = __in_dev_get_rcu(dev); |
2780 | if (!idev) | 2780 | if (!idev) |
2781 | goto out; | 2781 | goto out; |
2782 | 2782 | ||
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) { |
diff --git a/drivers/net/wireless/strip.c b/drivers/net/wireless/strip.c index 4b0acae22b0d..7bc7fc823128 100644 --- a/drivers/net/wireless/strip.c +++ b/drivers/net/wireless/strip.c | |||
@@ -1352,7 +1352,7 @@ static unsigned char *strip_make_packet(unsigned char *buffer, | |||
1352 | struct in_device *in_dev; | 1352 | struct in_device *in_dev; |
1353 | 1353 | ||
1354 | rcu_read_lock(); | 1354 | rcu_read_lock(); |
1355 | in_dev = __in_dev_get(strip_info->dev); | 1355 | in_dev = __in_dev_get_rcu(strip_info->dev); |
1356 | if (in_dev == NULL) { | 1356 | if (in_dev == NULL) { |
1357 | rcu_read_unlock(); | 1357 | rcu_read_unlock(); |
1358 | return NULL; | 1358 | return NULL; |
@@ -1508,7 +1508,7 @@ static void strip_send(struct strip *strip_info, struct sk_buff *skb) | |||
1508 | 1508 | ||
1509 | brd = addr = 0; | 1509 | brd = addr = 0; |
1510 | rcu_read_lock(); | 1510 | rcu_read_lock(); |
1511 | in_dev = __in_dev_get(strip_info->dev); | 1511 | in_dev = __in_dev_get_rcu(strip_info->dev); |
1512 | if (in_dev) { | 1512 | if (in_dev) { |
1513 | if (in_dev->ifa_list) { | 1513 | if (in_dev->ifa_list) { |
1514 | brd = in_dev->ifa_list->ifa_broadcast; | 1514 | brd = in_dev->ifa_list->ifa_broadcast; |
diff --git a/drivers/parisc/led.c b/drivers/parisc/led.c index e90fb72a6962..286902298e33 100644 --- a/drivers/parisc/led.c +++ b/drivers/parisc/led.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #include <linux/proc_fs.h> | 37 | #include <linux/proc_fs.h> |
38 | #include <linux/ctype.h> | 38 | #include <linux/ctype.h> |
39 | #include <linux/blkdev.h> | 39 | #include <linux/blkdev.h> |
40 | #include <linux/rcupdate.h> | ||
40 | #include <asm/io.h> | 41 | #include <asm/io.h> |
41 | #include <asm/processor.h> | 42 | #include <asm/processor.h> |
42 | #include <asm/hardware.h> | 43 | #include <asm/hardware.h> |
@@ -358,9 +359,10 @@ static __inline__ int led_get_net_activity(void) | |||
358 | /* we are running as tasklet, so locking dev_base | 359 | /* we are running as tasklet, so locking dev_base |
359 | * for reading should be OK */ | 360 | * for reading should be OK */ |
360 | read_lock(&dev_base_lock); | 361 | read_lock(&dev_base_lock); |
362 | rcu_read_lock(); | ||
361 | for (dev = dev_base; dev; dev = dev->next) { | 363 | for (dev = dev_base; dev; dev = dev->next) { |
362 | struct net_device_stats *stats; | 364 | struct net_device_stats *stats; |
363 | struct in_device *in_dev = __in_dev_get(dev); | 365 | struct in_device *in_dev = __in_dev_get_rcu(dev); |
364 | if (!in_dev || !in_dev->ifa_list) | 366 | if (!in_dev || !in_dev->ifa_list) |
365 | continue; | 367 | continue; |
366 | if (LOOPBACK(in_dev->ifa_list->ifa_local)) | 368 | if (LOOPBACK(in_dev->ifa_list->ifa_local)) |
@@ -371,6 +373,7 @@ static __inline__ int led_get_net_activity(void) | |||
371 | rx_total += stats->rx_packets; | 373 | rx_total += stats->rx_packets; |
372 | tx_total += stats->tx_packets; | 374 | tx_total += stats->tx_packets; |
373 | } | 375 | } |
376 | rcu_read_unlock(); | ||
374 | read_unlock(&dev_base_lock); | 377 | read_unlock(&dev_base_lock); |
375 | 378 | ||
376 | retval = 0; | 379 | retval = 0; |
diff --git a/drivers/s390/net/qeth_main.c b/drivers/s390/net/qeth_main.c index 86582cf1e19e..71de834ece1a 100644 --- a/drivers/s390/net/qeth_main.c +++ b/drivers/s390/net/qeth_main.c | |||
@@ -5200,7 +5200,7 @@ qeth_free_vlan_addresses4(struct qeth_card *card, unsigned short vid) | |||
5200 | if (!card->vlangrp) | 5200 | if (!card->vlangrp) |
5201 | return; | 5201 | return; |
5202 | rcu_read_lock(); | 5202 | rcu_read_lock(); |
5203 | in_dev = __in_dev_get(card->vlangrp->vlan_devices[vid]); | 5203 | in_dev = __in_dev_get_rcu(card->vlangrp->vlan_devices[vid]); |
5204 | if (!in_dev) | 5204 | if (!in_dev) |
5205 | goto out; | 5205 | goto out; |
5206 | for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) { | 5206 | for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) { |
@@ -7725,7 +7725,7 @@ qeth_arp_constructor(struct neighbour *neigh) | |||
7725 | goto out; | 7725 | goto out; |
7726 | 7726 | ||
7727 | rcu_read_lock(); | 7727 | rcu_read_lock(); |
7728 | in_dev = rcu_dereference(__in_dev_get(dev)); | 7728 | in_dev = __in_dev_get_rcu(dev); |
7729 | if (in_dev == NULL) { | 7729 | if (in_dev == NULL) { |
7730 | rcu_read_unlock(); | 7730 | rcu_read_unlock(); |
7731 | return -EINVAL; | 7731 | return -EINVAL; |