Skip to content

Commit

Permalink
decnet: RCU conversion and get rid of dev_base_lock
Browse files Browse the repository at this point in the history
While tracking dev_base_lock users, I found decnet used it in
dnet_select_source(), but for a wrong purpose:

Writers only hold RTNL, not dev_base_lock, so readers must use RCU if
they cannot use RTNL.

Adds an rcu_head in struct dn_ifaddr and handle proper RCU management.

Adds __rcu annotation in dn_route as well.

Signed-off-by: Eric Dumazet <[email protected]>
Acked-by: Steven Whitehouse <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Eric Dumazet authored and davem330 committed Nov 8, 2010
1 parent e4a7b93 commit fc766e4
Show file tree
Hide file tree
Showing 8 changed files with 127 additions and 88 deletions.
2 changes: 1 addition & 1 deletion include/linux/netdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,7 @@ struct net_device {
#endif
void *atalk_ptr; /* AppleTalk link */
struct in_device __rcu *ip_ptr; /* IPv4 specific data */
void *dn_ptr; /* DECnet specific data */
struct dn_dev __rcu *dn_ptr; /* DECnet specific data */
struct inet6_dev __rcu *ip6_ptr; /* IPv6 specific data */
void *ec_ptr; /* Econet specific data */
void *ax25_ptr; /* AX.25 specific data */
Expand Down
27 changes: 18 additions & 9 deletions include/net/dn_dev.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
struct dn_dev;

struct dn_ifaddr {
struct dn_ifaddr *ifa_next;
struct dn_ifaddr __rcu *ifa_next;
struct dn_dev *ifa_dev;
__le16 ifa_local;
__le16 ifa_address;
__u8 ifa_flags;
__u8 ifa_scope;
char ifa_label[IFNAMSIZ];
struct rcu_head rcu;
};

#define DN_DEV_S_RU 0 /* Run - working normally */
Expand Down Expand Up @@ -83,7 +84,7 @@ struct dn_dev_parms {


struct dn_dev {
struct dn_ifaddr *ifa_list;
struct dn_ifaddr __rcu *ifa_list;
struct net_device *dev;
struct dn_dev_parms parms;
char use_long;
Expand Down Expand Up @@ -171,19 +172,27 @@ extern int unregister_dnaddr_notifier(struct notifier_block *nb);

static inline int dn_dev_islocal(struct net_device *dev, __le16 addr)
{
struct dn_dev *dn_db = dev->dn_ptr;
struct dn_dev *dn_db;
struct dn_ifaddr *ifa;
int res = 0;

rcu_read_lock();
dn_db = rcu_dereference(dev->dn_ptr);
if (dn_db == NULL) {
printk(KERN_DEBUG "dn_dev_islocal: Called for non DECnet device\n");
return 0;
goto out;
}

for(ifa = dn_db->ifa_list; ifa; ifa = ifa->ifa_next)
if ((addr ^ ifa->ifa_local) == 0)
return 1;

return 0;
for (ifa = rcu_dereference(dn_db->ifa_list);
ifa != NULL;
ifa = rcu_dereference(ifa->ifa_next))
if ((addr ^ ifa->ifa_local) == 0) {
res = 1;
break;
}
out:
rcu_read_unlock();
return res;
}

#endif /* _NET_DN_DEV_H */
8 changes: 4 additions & 4 deletions include/net/dst.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ struct dst_entry {
int __use;
unsigned long lastuse;
union {
struct dst_entry *next;
struct rtable __rcu *rt_next;
struct rt6_info *rt6_next;
struct dn_route *dn_next;
struct dst_entry *next;
struct rtable __rcu *rt_next;
struct rt6_info *rt6_next;
struct dn_route __rcu *dn_next;
};
};

Expand Down
2 changes: 1 addition & 1 deletion net/decnet/af_decnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -1848,7 +1848,7 @@ unsigned dn_mss_from_pmtu(struct net_device *dev, int mtu)
{
unsigned mss = 230 - DN_MAX_NSP_DATA_HEADER;
if (dev) {
struct dn_dev *dn_db = dev->dn_ptr;
struct dn_dev *dn_db = rcu_dereference_raw(dev->dn_ptr);
mtu -= LL_RESERVED_SPACE(dev);
if (dn_db->use_long)
mtu -= 21;
Expand Down
Loading

0 comments on commit fc766e4

Please sign in to comment.