Skip to content

Commit 372e6c8

Browse files
stephen hemmingerdavem330
authored andcommitted
ipv6: convert temporary address list to list macros
Use list macros instead of open coded linked list. Signed-off-by: Stephen Hemminger <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent e77c8e8 commit 372e6c8

File tree

2 files changed

+14
-20
lines changed

2 files changed

+14
-20
lines changed

include/net/if_inet6.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ struct inet6_ifaddr {
5858
struct inet6_ifaddr *if_next; /* next addr in inet6_dev */
5959

6060
#ifdef CONFIG_IPV6_PRIVACY
61-
struct inet6_ifaddr *tmp_next; /* next addr in tempaddr_lst */
61+
struct list_head tmp_list;
6262
struct inet6_ifaddr *ifpub;
6363
int regen_count;
6464
#endif
@@ -175,7 +175,7 @@ struct inet6_dev {
175175
#ifdef CONFIG_IPV6_PRIVACY
176176
u8 rndid[8];
177177
struct timer_list regen_timer;
178-
struct inet6_ifaddr *tempaddr_list;
178+
struct list_head tempaddr_list;
179179
#endif
180180

181181
struct neigh_parms *nd_parms;

net/ipv6/addrconf.c

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ static struct inet6_dev * ipv6_add_dev(struct net_device *dev)
401401
#endif
402402

403403
#ifdef CONFIG_IPV6_PRIVACY
404+
INIT_LIST_HEAD(&ndev->tempaddr_list);
404405
setup_timer(&ndev->regen_timer, ipv6_regen_rndid, (unsigned long)ndev);
405406
if ((dev->flags&IFF_LOOPBACK) ||
406407
dev->type == ARPHRD_TUNNEL ||
@@ -679,8 +680,7 @@ ipv6_add_addr(struct inet6_dev *idev, const struct in6_addr *addr, int pfxlen,
679680

680681
#ifdef CONFIG_IPV6_PRIVACY
681682
if (ifa->flags&IFA_F_TEMPORARY) {
682-
ifa->tmp_next = idev->tempaddr_list;
683-
idev->tempaddr_list = ifa;
683+
list_add(&ifa->tmp_list, &idev->tempaddr_list);
684684
in6_ifa_hold(ifa);
685685
}
686686
#endif
@@ -732,19 +732,12 @@ static void ipv6_del_addr(struct inet6_ifaddr *ifp)
732732
write_lock_bh(&idev->lock);
733733
#ifdef CONFIG_IPV6_PRIVACY
734734
if (ifp->flags&IFA_F_TEMPORARY) {
735-
for (ifap = &idev->tempaddr_list; (ifa=*ifap) != NULL;
736-
ifap = &ifa->tmp_next) {
737-
if (ifa == ifp) {
738-
*ifap = ifa->tmp_next;
739-
if (ifp->ifpub) {
740-
in6_ifa_put(ifp->ifpub);
741-
ifp->ifpub = NULL;
742-
}
743-
__in6_ifa_put(ifp);
744-
ifa->tmp_next = NULL;
745-
break;
746-
}
735+
list_del(&ifp->tmp_list);
736+
if (ifp->ifpub) {
737+
in6_ifa_put(ifp->ifpub);
738+
ifp->ifpub = NULL;
747739
}
740+
__in6_ifa_put(ifp);
748741
}
749742
#endif
750743

@@ -1970,7 +1963,7 @@ void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len)
19701963
#ifdef CONFIG_IPV6_PRIVACY
19711964
read_lock_bh(&in6_dev->lock);
19721965
/* update all temporary addresses in the list */
1973-
for (ift=in6_dev->tempaddr_list; ift; ift=ift->tmp_next) {
1966+
list_for_each_entry(ift, &in6_dev->tempaddr_list, tmp_list) {
19741967
/*
19751968
* When adjusting the lifetimes of an existing
19761969
* temporary address, only lower the lifetimes.
@@ -2675,9 +2668,10 @@ static int addrconf_ifdown(struct net_device *dev, int how)
26752668
in6_dev_put(idev);
26762669

26772670
/* clear tempaddr list */
2678-
while ((ifa = idev->tempaddr_list) != NULL) {
2679-
idev->tempaddr_list = ifa->tmp_next;
2680-
ifa->tmp_next = NULL;
2671+
while (!list_empty(&idev->tempaddr_list)) {
2672+
ifa = list_first_entry(&idev->tempaddr_list,
2673+
struct inet6_ifaddr, tmp_list);
2674+
list_del(&ifa->tmp_list);
26812675
ifa->dead = 1;
26822676
write_unlock_bh(&idev->lock);
26832677
spin_lock_bh(&ifa->lock);

0 commit comments

Comments
 (0)