Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Define IFADDR_FOREACH_SAFE for on-the-fly element remova...
details: https://anonhg.NetBSD.org/src/rev/3fb3b5a1334d
branches: trunk
changeset: 331096:3fb3b5a1334d
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Thu Jul 31 06:35:47 2014 +0000
description:
Define IFADDR_FOREACH_SAFE for on-the-fly element removal in a loop
We have to use it when we purge an address element in an ifaddr loop.
This change restores the original behavior that was accidentally degraded.
diffstat:
sys/net/if.c | 8 ++++----
sys/net/if.h | 5 ++++-
sys/netinet6/nd6_rtr.c | 8 ++++----
3 files changed, 12 insertions(+), 9 deletions(-)
diffs (85 lines):
diff -r cb45ecb23c82 -r 3fb3b5a1334d sys/net/if.c
--- a/sys/net/if.c Thu Jul 31 06:26:06 2014 +0000
+++ b/sys/net/if.c Thu Jul 31 06:35:47 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if.c,v 1.288 2014/07/30 13:32:09 ozaki-r Exp $ */
+/* $NetBSD: if.c,v 1.289 2014/07/31 06:35:47 ozaki-r Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.288 2014/07/30 13:32:09 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.289 2014/07/31 06:35:47 ozaki-r Exp $");
#include "opt_inet.h"
@@ -697,9 +697,9 @@
void
if_purgeaddrs(struct ifnet *ifp, int family, void (*purgeaddr)(struct ifaddr *))
{
- struct ifaddr *ifa;
+ struct ifaddr *ifa, *nifa;
- IFADDR_FOREACH(ifa, ifp) {
+ IFADDR_FOREACH_SAFE(ifa, ifp, nifa) {
if (ifa->ifa_addr->sa_family != family)
continue;
(*purgeaddr)(ifa);
diff -r cb45ecb23c82 -r 3fb3b5a1334d sys/net/if.h
--- a/sys/net/if.h Thu Jul 31 06:26:06 2014 +0000
+++ b/sys/net/if.h Thu Jul 31 06:35:47 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if.h,v 1.173 2014/07/31 02:21:51 ozaki-r Exp $ */
+/* $NetBSD: if.h,v 1.174 2014/07/31 06:35:47 ozaki-r Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -988,6 +988,9 @@
#define IFADDR_NEXT(__ifa) TAILQ_NEXT((__ifa), ifa_list)
#define IFADDR_FOREACH(__ifa, __ifp) TAILQ_FOREACH(__ifa, \
&(__ifp)->if_addrlist, ifa_list)
+#define IFADDR_FOREACH_SAFE(__ifa, __ifp, __nifa) \
+ TAILQ_FOREACH_SAFE(__ifa, \
+ &(__ifp)->if_addrlist, ifa_list, __nifa)
#define IFADDR_EMPTY(__ifp) TAILQ_EMPTY(&(__ifp)->if_addrlist)
extern struct ifnet_head ifnet_list;
diff -r cb45ecb23c82 -r 3fb3b5a1334d sys/netinet6/nd6_rtr.c
--- a/sys/netinet6/nd6_rtr.c Thu Jul 31 06:26:06 2014 +0000
+++ b/sys/netinet6/nd6_rtr.c Thu Jul 31 06:35:47 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nd6_rtr.c,v 1.92 2014/07/25 07:12:55 ozaki-r Exp $ */
+/* $NetBSD: nd6_rtr.c,v 1.93 2014/07/31 06:35:47 ozaki-r Exp $ */
/* $KAME: nd6_rtr.c,v 1.95 2001/02/07 08:09:47 itojun Exp $ */
/*
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nd6_rtr.c,v 1.92 2014/07/25 07:12:55 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nd6_rtr.c,v 1.93 2014/07/31 06:35:47 ozaki-r Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -897,7 +897,7 @@
{
struct nd_prefix *pr, *pr_next;
struct in6_ifaddr *ia;
- struct ifaddr *ifa;
+ struct ifaddr *ifa, *ifa_next;
for (pr = nd_prefix.lh_first; pr; pr = pr_next) {
pr_next = pr->ndpr_next;
@@ -915,7 +915,7 @@
!LIST_EMPTY(&pr->ndpr_advrtrs)))
continue;
- IFADDR_FOREACH(ifa, ifp) {
+ IFADDR_FOREACH_SAFE(ifa, ifp, ifa_next) {
if (ifa->ifa_addr->sa_family != AF_INET6)
continue;
ia = (struct in6_ifaddr *)ifa;
Home |
Main Index |
Thread Index |
Old Index