aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorEric Dumazet <eric.dumazet@gmail.com>2010-09-15 00:04:31 -0400
committerDavid S. Miller <davem@davemloft.net>2010-09-16 01:06:05 -0400
commit95ae6b228f814fc0528d0506ee9f18ac333d6851 (patch)
treed5287f3dee478e1bd5fa79e63192447c5bc91e92 /drivers/net
parent9e0064a5456fd75fd7c70f6f3692c7f732f91a65 (diff)
ipv4: ip_ptr cleanups
dev->ip_ptr is protected by rtnl and rcu. Yet some places dont use appropriate primitives and/or locking rules. Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/plip.c8
-rw-r--r--drivers/net/via-velocity.h11
-rw-r--r--drivers/net/wan/hdlc_cisco.c4
3 files changed, 16 insertions, 7 deletions
diff --git a/drivers/net/plip.c b/drivers/net/plip.c
index 7e82a82422c..ca4df7f4cf2 100644
--- a/drivers/net/plip.c
+++ b/drivers/net/plip.c
@@ -995,8 +995,10 @@ plip_tx_packet(struct sk_buff *skb, struct net_device *dev)
995static void 995static void
996plip_rewrite_address(const struct net_device *dev, struct ethhdr *eth) 996plip_rewrite_address(const struct net_device *dev, struct ethhdr *eth)
997{ 997{
998 const struct in_device *in_dev = dev->ip_ptr; 998 const struct in_device *in_dev;
999 999
1000 rcu_read_lock();
1001 in_dev = __in_dev_get_rcu(dev);
1000 if (in_dev) { 1002 if (in_dev) {
1001 /* Any address will do - we take the first */ 1003 /* Any address will do - we take the first */
1002 const struct in_ifaddr *ifa = in_dev->ifa_list; 1004 const struct in_ifaddr *ifa = in_dev->ifa_list;
@@ -1006,6 +1008,7 @@ plip_rewrite_address(const struct net_device *dev, struct ethhdr *eth)
1006 memcpy(eth->h_dest+2, &ifa->ifa_address, 4); 1008 memcpy(eth->h_dest+2, &ifa->ifa_address, 4);
1007 } 1009 }
1008 } 1010 }
1011 rcu_read_unlock();
1009} 1012}
1010 1013
1011static int 1014static int
@@ -1088,7 +1091,8 @@ plip_open(struct net_device *dev)
1088 when the device address isn't identical to the address of a 1091 when the device address isn't identical to the address of a
1089 received frame, the kernel incorrectly drops it). */ 1092 received frame, the kernel incorrectly drops it). */
1090 1093
1091 if ((in_dev=dev->ip_ptr) != NULL) { 1094 in_dev=__in_dev_get_rtnl(dev);
1095 if (in_dev) {
1092 /* Any address will do - we take the first. We already 1096 /* Any address will do - we take the first. We already
1093 have the first two bytes filled with 0xfc, from 1097 have the first two bytes filled with 0xfc, from
1094 plip_init_dev(). */ 1098 plip_init_dev(). */
diff --git a/drivers/net/via-velocity.h b/drivers/net/via-velocity.h
index f7b33ae7a70..b5e120b0074 100644
--- a/drivers/net/via-velocity.h
+++ b/drivers/net/via-velocity.h
@@ -1504,22 +1504,25 @@ struct velocity_info {
1504 * addresses on this chain then we use the first - multi-IP WOL is not 1504 * addresses on this chain then we use the first - multi-IP WOL is not
1505 * supported. 1505 * supported.
1506 * 1506 *
1507 * CHECK ME: locking
1508 */ 1507 */
1509 1508
1510static inline int velocity_get_ip(struct velocity_info *vptr) 1509static inline int velocity_get_ip(struct velocity_info *vptr)
1511{ 1510{
1512 struct in_device *in_dev = (struct in_device *) vptr->dev->ip_ptr; 1511 struct in_device *in_dev;
1513 struct in_ifaddr *ifa; 1512 struct in_ifaddr *ifa;
1513 int res = -ENOENT;
1514 1514
1515 rcu_read_lock();
1516 in_dev = __in_dev_get_rcu(vptr->dev);
1515 if (in_dev != NULL) { 1517 if (in_dev != NULL) {
1516 ifa = (struct in_ifaddr *) in_dev->ifa_list; 1518 ifa = (struct in_ifaddr *) in_dev->ifa_list;
1517 if (ifa != NULL) { 1519 if (ifa != NULL) {
1518 memcpy(vptr->ip_addr, &ifa->ifa_address, 4); 1520 memcpy(vptr->ip_addr, &ifa->ifa_address, 4);
1519 return 0; 1521 res = 0;
1520 } 1522 }
1521 } 1523 }
1522 return -ENOENT; 1524 rcu_read_unlock();
1525 return res;
1523} 1526}
1524 1527
1525/** 1528/**
diff --git a/drivers/net/wan/hdlc_cisco.c b/drivers/net/wan/hdlc_cisco.c
index b38ffa149ab..b1e5e5b69c2 100644
--- a/drivers/net/wan/hdlc_cisco.c
+++ b/drivers/net/wan/hdlc_cisco.c
@@ -191,7 +191,8 @@ static int cisco_rx(struct sk_buff *skb)
191 191
192 switch (ntohl (cisco_data->type)) { 192 switch (ntohl (cisco_data->type)) {
193 case CISCO_ADDR_REQ: /* Stolen from syncppp.c :-) */ 193 case CISCO_ADDR_REQ: /* Stolen from syncppp.c :-) */
194 in_dev = dev->ip_ptr; 194 rcu_read_lock();
195 in_dev = __in_dev_get_rcu(dev);
195 addr = 0; 196 addr = 0;
196 mask = ~cpu_to_be32(0); /* is the mask correct? */ 197 mask = ~cpu_to_be32(0); /* is the mask correct? */
197 198
@@ -211,6 +212,7 @@ static int cisco_rx(struct sk_buff *skb)
211 cisco_keepalive_send(dev, CISCO_ADDR_REPLY, 212 cisco_keepalive_send(dev, CISCO_ADDR_REPLY,
212 addr, mask); 213 addr, mask);
213 } 214 }
215 rcu_read_unlock();
214 dev_kfree_skb_any(skb); 216 dev_kfree_skb_any(skb);
215 return NET_RX_SUCCESS; 217 return NET_RX_SUCCESS;
216 218