All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@vyatta.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org
Subject: [PATCH 1/9] ipv6: convert temporary address list to list macros
Date: Wed, 17 Mar 2010 23:31:09 -0700	[thread overview]
Message-ID: <20100318063122.866367333@vyatta.com> (raw)
In-Reply-To: 20100318063108.109693694@vyatta.com

[-- Attachment #1: ipv6-tmp-addrlist.patch --]
[-- Type: text/plain, Size: 3069 bytes --]

Use list macros instead of open coded linked list.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>

---
 include/net/if_inet6.h |    4 ++--
 net/ipv6/addrconf.c    |   30 ++++++++++++------------------
 2 files changed, 14 insertions(+), 20 deletions(-)

--- a/include/net/if_inet6.h	2010-03-15 16:03:26.618586975 -0700
+++ b/include/net/if_inet6.h	2010-03-15 16:10:15.159524680 -0700
@@ -58,7 +58,7 @@ struct inet6_ifaddr {
 	struct inet6_ifaddr	*if_next;       /* next addr in inet6_dev */
 
 #ifdef CONFIG_IPV6_PRIVACY
-	struct inet6_ifaddr	*tmp_next;	/* next addr in tempaddr_lst */
+	struct list_head	tmp_list;
 	struct inet6_ifaddr	*ifpub;
 	int			regen_count;
 #endif
@@ -175,7 +175,7 @@ struct inet6_dev {
 #ifdef CONFIG_IPV6_PRIVACY
 	u8			rndid[8];
 	struct timer_list	regen_timer;
-	struct inet6_ifaddr	*tempaddr_list;
+	struct list_head	tempaddr_list;
 #endif
 
 	struct neigh_parms	*nd_parms;
--- a/net/ipv6/addrconf.c	2010-03-15 16:03:46.418964602 -0700
+++ b/net/ipv6/addrconf.c	2010-03-15 16:10:15.169524547 -0700
@@ -401,6 +401,7 @@ static struct inet6_dev * ipv6_add_dev(s
 #endif
 
 #ifdef CONFIG_IPV6_PRIVACY
+	INIT_LIST_HEAD(&ndev->tempaddr_list);
 	setup_timer(&ndev->regen_timer, ipv6_regen_rndid, (unsigned long)ndev);
 	if ((dev->flags&IFF_LOOPBACK) ||
 	    dev->type == ARPHRD_TUNNEL ||
@@ -679,8 +680,7 @@ ipv6_add_addr(struct inet6_dev *idev, co
 
 #ifdef CONFIG_IPV6_PRIVACY
 	if (ifa->flags&IFA_F_TEMPORARY) {
-		ifa->tmp_next = idev->tempaddr_list;
-		idev->tempaddr_list = ifa;
+		list_add(&ifa->tmp_list, &idev->tempaddr_list);
 		in6_ifa_hold(ifa);
 	}
 #endif
@@ -732,19 +732,12 @@ static void ipv6_del_addr(struct inet6_i
 	write_lock_bh(&idev->lock);
 #ifdef CONFIG_IPV6_PRIVACY
 	if (ifp->flags&IFA_F_TEMPORARY) {
-		for (ifap = &idev->tempaddr_list; (ifa=*ifap) != NULL;
-		     ifap = &ifa->tmp_next) {
-			if (ifa == ifp) {
-				*ifap = ifa->tmp_next;
-				if (ifp->ifpub) {
-					in6_ifa_put(ifp->ifpub);
-					ifp->ifpub = NULL;
-				}
-				__in6_ifa_put(ifp);
-				ifa->tmp_next = NULL;
-				break;
-			}
+		list_del(&ifp->tmp_list);
+		if (ifp->ifpub) {
+			in6_ifa_put(ifp->ifpub);
+			ifp->ifpub = NULL;
 		}
+		__in6_ifa_put(ifp);
 	}
 #endif
 
@@ -1970,7 +1963,7 @@ ok:
 #ifdef CONFIG_IPV6_PRIVACY
 			read_lock_bh(&in6_dev->lock);
 			/* update all temporary addresses in the list */
-			for (ift=in6_dev->tempaddr_list; ift; ift=ift->tmp_next) {
+			list_for_each_entry(ift, &in6_dev->tempaddr_list, tmp_list) {
 				/*
 				 * When adjusting the lifetimes of an existing
 				 * temporary address, only lower the lifetimes.
@@ -2675,9 +2668,10 @@ static int addrconf_ifdown(struct net_de
 		in6_dev_put(idev);
 
 	/* clear tempaddr list */
-	while ((ifa = idev->tempaddr_list) != NULL) {
-		idev->tempaddr_list = ifa->tmp_next;
-		ifa->tmp_next = NULL;
+	while (!list_empty(&idev->tempaddr_list)) {
+		ifa = list_first_entry(&idev->tempaddr_list,
+				       struct inet6_ifaddr, tmp_list);
+		list_del(&ifa->tmp_list);
 		ifa->dead = 1;
 		write_unlock_bh(&idev->lock);
 		spin_lock_bh(&ifa->lock);

-- 


  reply	other threads:[~2010-03-18  6:36 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-18  6:31 [PATCH 0/9] IPv6 addrconf non-bug patches Stephen Hemminger
2010-03-18  6:31 ` Stephen Hemminger [this message]
2010-03-20 23:05   ` [PATCH 1/9] ipv6: convert temporary address list to list macros David Miller
2010-03-18  6:31 ` [PATCH 2/9] ipv6: convert addrconf list to hlist Stephen Hemminger
2010-03-20 23:05   ` David Miller
2010-03-18  6:31 ` [PATCH 3/9] IPv6: convert addrconf hash list to RCU Stephen Hemminger
2010-03-20 23:05   ` David Miller
2010-03-18  6:31 ` [PATCH 4/9] ipv6: user better hash for addrconf Stephen Hemminger
2010-03-20 23:05   ` David Miller
2010-03-18  6:31 ` [PATCH 5/9] ipv6: convert idev_list to list macros Stephen Hemminger
2010-03-20 23:05   ` David Miller
2010-03-18  6:31 ` [PATCH 6/9] ipv6: addrconf timer changes Stephen Hemminger
2010-03-18  7:37   ` YOSHIFUJI Hideaki
2010-03-18  6:31 ` [PATCH 7/9] IPv6: addrconf cleanups Stephen Hemminger
2010-03-20 23:12   ` David Miller
2010-03-18  6:31 ` [PATCH 8/9] addrconf: checkpatch fixes Stephen Hemminger
2010-03-20 23:13   ` David Miller
2010-03-18  6:31 ` [PATCH 9/9] IPv6: addrconf cleanup addrconf_verify Stephen Hemminger
2010-03-20 23:13   ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100318063122.866367333@vyatta.com \
    --to=shemminger@vyatta.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.