diff mbox

[-next] Adapt s390 qeth & lcs driver code to use RCU

Message ID 1290073388.2781.12.camel@edumazet-laptop
State RFC, archived
Delegated to: David Miller
Headers show

Commit Message

Eric Dumazet Nov. 18, 2010, 9:43 a.m. UTC
Le jeudi 18 novembre 2010 à 10:33 +0100, Eric Dumazet a écrit :
> Le jeudi 18 novembre 2010 à 14:48 +0530, Sachin Sant a écrit :
> > Commit 1d7138de878d1d4210727c1200193e69596f93b3
> > igmp: RCU conversion of in_dev->mc_list
> > 
> > converted rwlock to RCU.
> > 
> > Update the s390 network drivers(qeth & lcs) code to adapt to this change.
> > 
> > Signed-off-by : Sachin Sant <sachinp@in.ibm.com>
> > ---
> > 
> > Only compile tested.
> > 
> 
> Hmm, sorry but this wont work.
> 
> > diff -Narup linux-2.6-next/drivers/s390/net/lcs.c linux-2.6-next-new/drivers/s390/net/lcs.c
> > --- linux-2.6-next/drivers/s390/net/lcs.c	2010-11-17 11:38:25.000000000 +0530
> > +++ linux-2.6-next-new/drivers/s390/net/lcs.c	2010-11-18 11:59:46.000000000 +0530
> > @@ -1269,10 +1269,10 @@ lcs_register_mc_addresses(void *data)
> >  	in4_dev = in_dev_get(card->dev);
> >  	if (in4_dev == NULL)
> >  		goto out;
> > -	read_lock(&in4_dev->mc_list_lock);
> > +	rcu_read_lock();
> 
> If you use rcu_read_lock(), then you also need to 
> use the rcu list iterators in lcs_remove_mc_addresses() and
> lcs_set_mc_addresses()
> 
> Then, its strange this driver is not protected by RTNL at this stage.
> 
> Ah yes, it uses a kthread from its ndo_set_multicast_list() handler.
> 
> This seems not safe at all.

Please check following patch to give you the idea of what is needed :




--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/s390/net/lcs.c b/drivers/s390/net/lcs.c
index 0f19d54..05755b7 100644
--- a/drivers/s390/net/lcs.c
+++ b/drivers/s390/net/lcs.c
@@ -1188,7 +1188,9 @@  lcs_remove_mc_addresses(struct lcs_card *card, struct in_device *in4_dev)
 	spin_lock_irqsave(&card->ipm_lock, flags);
 	list_for_each(l, &card->ipm_list) {
 		ipm = list_entry(l, struct lcs_ipm_list, list);
-		for (im4 = in4_dev->mc_list; im4 != NULL; im4 = im4->next) {
+		for (im4 = rcu_dereference(in4_dev->mc_list);
+		     im4 != NULL;
+		     im4 = rcu_dereference(im4->next_rcu)) {
 			lcs_get_mac_for_ipm(im4->multiaddr, buf, card->dev);
 			if ( (ipm->ipm.ip_addr == im4->multiaddr) &&
 			     (memcmp(buf, &ipm->ipm.mac_addr,
@@ -1233,7 +1235,9 @@  lcs_set_mc_addresses(struct lcs_card *card, struct in_device *in4_dev)
 	unsigned long flags;
 
 	LCS_DBF_TEXT(4, trace, "setmclst");
-	for (im4 = in4_dev->mc_list; im4; im4 = im4->next) {
+	for (im4 = rcu_dereference(in4_dev->mc_list);
+	     im4 != NULL;
+	     im4 = rcu_dereference(im4->next_rcu)) {
 		lcs_get_mac_for_ipm(im4->multiaddr, buf, card->dev);
 		ipm = lcs_check_addr_entry(card, im4, buf);
 		if (ipm != NULL)
@@ -1269,10 +1273,10 @@  lcs_register_mc_addresses(void *data)
 	in4_dev = in_dev_get(card->dev);
 	if (in4_dev == NULL)
 		goto out;
-	read_lock(&in4_dev->mc_list_lock);
+	rcu_read_lock();
 	lcs_remove_mc_addresses(card,in4_dev);
 	lcs_set_mc_addresses(card, in4_dev);
-	read_unlock(&in4_dev->mc_list_lock);
+	rcu_read_unlock();
 	in_dev_put(in4_dev);
 
 	netif_carrier_off(card->dev);