Skip to contentSkip to conversation

ipv6_chk_acast_addr remove unused loop

PATCH NAK Daniel Lezcano 2 participants 3 messages Feb 8, 2008

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

Subject: ipv6_chk_acast_addr remove unused loop
From: Daniel Lezcano <[email protected]>

The ipv6_chk_acast_addr is called with a netdev pointer parameter which can be NULL. This value is used as a wildcard to browse the netdev list and search if a device is owning the address. But when looking closely to the code, this function is only called one time in ndisc.c and the netdev parameter is never NULL. The code browsing the netdev list is pointless in this case.

This patch removes netdev list browsing code.

---
 net/ipv6/anycast.c |   22 +---------------------
 1 file changed, 1 insertion(+), 21 deletions(-)
net/ipv6/anycast.c +1 -21
Index: net-2.6-fixes/net/ipv6/anycast.c
===================================================================
@@ -401,7 +401,7 @@ static int ipv6_dev_ac_dec(struct net_de
 /*
  *	check if the interface has this anycast address
  */
-static int ipv6_chk_acast_dev(struct net_device *dev, struct in6_addr *addr)
+int ipv6_chk_acast_addr(struct net_device *dev, struct in6_addr *addr)
 {
 	struct inet6_dev *idev;
 	struct ifacaddr6 *aca;
@@ -419,26 +419,6 @@ static int ipv6_chk_acast_dev(struct net
 	return 0;
 }
 
-/*
- *	check if given interface (or any, if dev==0) has this anycast address
- */
-int ipv6_chk_acast_addr(struct net_device *dev, struct in6_addr *addr)
-{
-	int found = 0;
-
-	if (dev)
-		return ipv6_chk_acast_dev(dev, addr);
-	read_lock(&dev_base_lock);
-	for_each_netdev(&init_net, dev)
-		if (ipv6_chk_acast_dev(dev, addr)) {
-			found = 1;
-			break;
-		}
-	read_unlock(&dev_base_lock);
-	return found;
-}
-
-
 #ifdef CONFIG_PROC_FS
 struct ac6_iter_state {
 	struct net_device *dev;
#1 lore raw

NACK.

Daniel,
This code is part of the in-kernel API for anycast, which is
intended
to be the same as for multicast. By removing support for NULL there, you're
making a special case for the anycast code that isn't there in the multicast
code (can't support a NULL dev), and you really aren't buying all that much for it.

                                                        +-DLS
#2 lore raw
Quoted 8 lines · David Stevens

NACK.

Daniel,
This code is part of the in-kernel API for anycast, which is
intended
to be the same as for multicast. By removing support for NULL there, you're making a special case for the anycast code that isn't there in the multicast code (can't support a NULL dev), and you really aren't buying all that much for it.

I was hesitating to send this patch exactly for the reason you are explaining. Apparently I did the bad choice :)

Thanks.
-- Daniel