Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/netinet6 Introduce macros for the default router list
details: https://anonhg.NetBSD.org/src/rev/4e1f0ea877cc
branches: trunk
changeset: 349485:4e1f0ea877cc
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Mon Dec 12 03:13:14 2016 +0000
description:
Introduce macros for the default router list
No functional change.
diffstat:
sys/netinet6/nd6.c | 22 +++++++++++-----------
sys/netinet6/nd6.h | 21 ++++++++++++++++++++-
sys/netinet6/nd6_rtr.c | 36 +++++++++++++++++-------------------
3 files changed, 48 insertions(+), 31 deletions(-)
diffs (260 lines):
diff -r 7fa512fc89df -r 4e1f0ea877cc sys/netinet6/nd6.c
--- a/sys/netinet6/nd6.c Mon Dec 12 02:51:24 2016 +0000
+++ b/sys/netinet6/nd6.c Mon Dec 12 03:13:14 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nd6.c,v 1.213 2016/12/11 07:38:50 ozaki-r Exp $ */
+/* $NetBSD: nd6.c,v 1.214 2016/12/12 03:13:14 ozaki-r Exp $ */
/* $KAME: nd6.c,v 1.279 2002/06/08 11:16:51 itojun Exp $ */
/*
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.213 2016/12/11 07:38:50 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.214 2016/12/12 03:13:14 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_net_mpsafe.h"
@@ -138,7 +138,7 @@
int error;
/* initialization of the default router list */
- TAILQ_INIT(&nd_defrouter);
+ ND_DEFROUTER_LIST_INIT();
callout_init(&nd6_slowtimo_ch, CALLOUT_MPSAFE);
callout_init(&nd6_timer_ch, CALLOUT_MPSAFE);
@@ -593,7 +593,7 @@
/* expire default router list */
- TAILQ_FOREACH_SAFE(dr, &nd_defrouter, dr_entry, next_dr) {
+ ND_DEFROUTER_LIST_FOREACH_SAFE(dr, next_dr) {
if (dr->expire && dr->expire < time_uptime) {
nd6_defrtrlist_del(dr, NULL);
}
@@ -838,7 +838,7 @@
* in the routing table, in order to keep additional side effects as
* small as possible.
*/
- TAILQ_FOREACH_SAFE(dr, &nd_defrouter, dr_entry, ndr) {
+ ND_DEFROUTER_LIST_FOREACH_SAFE(dr, ndr) {
if (dr->installed)
continue;
@@ -848,7 +848,7 @@
}
}
- TAILQ_FOREACH_SAFE(dr, &nd_defrouter, dr_entry, ndr) {
+ ND_DEFROUTER_LIST_FOREACH_SAFE(dr, ndr) {
if (!dr->installed)
continue;
@@ -1033,7 +1033,7 @@
* as on-link, and thus, as a neighbor.
*/
if (ND_IFINFO(ifp)->flags & ND6_IFF_ACCEPT_RTADV &&
- TAILQ_EMPTY(&nd_defrouter) &&
+ ND_DEFROUTER_LIST_EMPTY() &&
nd6_defifindex == ifp->if_index) {
return 1;
}
@@ -1097,7 +1097,7 @@
* XXX: we restrict the condition to hosts, because routers usually do
* not have the "default router list".
*/
- if (!ip6_forwarding && TAILQ_FIRST(&nd_defrouter) == NULL &&
+ if (!ip6_forwarding && ND_DEFROUTER_LIST_EMPTY() &&
nd6_defifindex == ifp->if_index) {
return 1;
}
@@ -1617,7 +1617,7 @@
*/
memset(drl, 0, sizeof(*drl));
s = splsoftnet();
- TAILQ_FOREACH(dr, &nd_defrouter, dr_entry) {
+ ND_DEFROUTER_LIST_FOREACH(dr) {
if (i >= DRLSTSIZ)
break;
drl->defrouter[i].rtaddr = dr->rtaddr;
@@ -1892,7 +1892,7 @@
s = splsoftnet();
nd6_defrouter_reset();
- TAILQ_FOREACH_SAFE(drtr, &nd_defrouter, dr_entry, next) {
+ ND_DEFROUTER_LIST_FOREACH_SAFE(drtr, next) {
nd6_defrtrlist_del(drtr, NULL);
}
nd6_defrouter_select();
@@ -2644,7 +2644,7 @@
}
l = 0;
- TAILQ_FOREACH(dr, &nd_defrouter, dr_entry) {
+ ND_DEFROUTER_LIST_FOREACH(dr) {
if (oldp && d + 1 <= de) {
memset(d, 0, sizeof(*d));
diff -r 7fa512fc89df -r 4e1f0ea877cc sys/netinet6/nd6.h
--- a/sys/netinet6/nd6.h Mon Dec 12 02:51:24 2016 +0000
+++ b/sys/netinet6/nd6.h Mon Dec 12 03:13:14 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nd6.h,v 1.76 2016/12/11 07:38:50 ozaki-r Exp $ */
+/* $NetBSD: nd6.h,v 1.77 2016/12/12 03:13:14 ozaki-r Exp $ */
/* $KAME: nd6.h,v 1.95 2002/06/08 11:31:06 itojun Exp $ */
/*
@@ -256,6 +256,25 @@
int installed; /* is installed into kernel routing table */
};
+#define ND_DEFROUTER_LIST_INIT() \
+ TAILQ_INIT(&nd_defrouter)
+#define ND_DEFROUTER_LIST_FOREACH(dr) \
+ TAILQ_FOREACH((dr), &nd_defrouter, dr_entry)
+#define ND_DEFROUTER_LIST_FOREACH_SAFE(dr, dr_next) \
+ TAILQ_FOREACH_SAFE((dr), &nd_defrouter, dr_entry, (dr_next))
+#define ND_DEFROUTER_LIST_EMPTY() \
+ TAILQ_EMPTY(&nd_defrouter)
+#define ND_DEFROUTER_LIST_REMOVE(dr) \
+ TAILQ_REMOVE(&nd_defrouter, (dr), dr_entry)
+#define ND_DEFROUTER_LIST_INSERT_BEFORE(dr, dr_new) \
+ TAILQ_INSERT_BEFORE((dr), (dr_new), dr_entry)
+#define ND_DEFROUTER_LIST_INSERT_TAIL(dr) \
+ TAILQ_INSERT_TAIL(&nd_defrouter, (dr), dr_entry)
+#define ND_DEFROUTER_LIST_FIRST() \
+ TAILQ_FIRST(&nd_defrouter)
+#define ND_DEFROUTER_LIST_NEXT(dr) \
+ TAILQ_NEXT((dr), dr_entry)
+
struct nd_prefixctl {
struct ifnet *ndprc_ifp;
diff -r 7fa512fc89df -r 4e1f0ea877cc sys/netinet6/nd6_rtr.c
--- a/sys/netinet6/nd6_rtr.c Mon Dec 12 02:51:24 2016 +0000
+++ b/sys/netinet6/nd6_rtr.c Mon Dec 12 03:13:14 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nd6_rtr.c,v 1.123 2016/12/11 07:38:50 ozaki-r Exp $ */
+/* $NetBSD: nd6_rtr.c,v 1.124 2016/12/12 03:13:14 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.123 2016/12/11 07:38:50 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nd6_rtr.c,v 1.124 2016/12/12 03:13:14 ozaki-r Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -487,7 +487,7 @@
{
struct nd_defrouter *dr;
- TAILQ_FOREACH(dr, &nd_defrouter, dr_entry) {
+ ND_DEFROUTER_LIST_FOREACH(dr) {
if (dr->ifp == ifp && IN6_ARE_ADDR_EQUAL(addr, &dr->rtaddr))
break;
}
@@ -523,7 +523,7 @@
deldr = dr;
defrouter_delreq(dr);
}
- TAILQ_REMOVE(&nd_defrouter, dr, dr_entry);
+ ND_DEFROUTER_LIST_REMOVE(dr);
/*
* Also delete all the pointers to the router in each prefix lists.
@@ -599,8 +599,7 @@
{
struct nd_defrouter *dr;
- for (dr = TAILQ_FIRST(&nd_defrouter); dr;
- dr = TAILQ_NEXT(dr, dr_entry))
+ ND_DEFROUTER_LIST_FOREACH(dr)
defrouter_delreq(dr);
/*
@@ -654,7 +653,7 @@
* Let's handle easy case (3) first:
* If default router list is empty, there's nothing to be done.
*/
- if (!TAILQ_FIRST(&nd_defrouter)) {
+ if (ND_DEFROUTER_LIST_EMPTY()) {
splx(s);
return;
}
@@ -664,8 +663,7 @@
* We just pick up the first reachable one (if any), assuming that
* the ordering rule of the list described in defrtrlist_update().
*/
- for (dr = TAILQ_FIRST(&nd_defrouter); dr;
- dr = TAILQ_NEXT(dr, dr_entry)) {
+ ND_DEFROUTER_LIST_FOREACH(dr) {
ndi = ND_IFINFO(dr->ifp);
if (nd6_accepts_rtadv(ndi))
continue;
@@ -691,10 +689,11 @@
* or when the new one has a really higher preference value.
*/
if (selected_dr == NULL) {
- if (installed_dr == NULL || !TAILQ_NEXT(installed_dr, dr_entry))
- selected_dr = TAILQ_FIRST(&nd_defrouter);
+ if (installed_dr == NULL ||
+ ND_DEFROUTER_LIST_NEXT(installed_dr) == NULL)
+ selected_dr = ND_DEFROUTER_LIST_FIRST();
else
- selected_dr = TAILQ_NEXT(installed_dr, dr_entry);
+ selected_dr = ND_DEFROUTER_LIST_NEXT(installed_dr);
} else if (installed_dr &&
nd6_is_llinfo_probreach(installed_dr) &&
rtpref(selected_dr) <= rtpref(installed_dr)) {
@@ -781,7 +780,7 @@
* nd6_defrouter_select() below will handle routing
* changes later.
*/
- TAILQ_REMOVE(&nd_defrouter, dr, dr_entry);
+ ND_DEFROUTER_LIST_REMOVE(dr);
n = dr;
goto insert;
}
@@ -824,15 +823,14 @@
*/
/* insert at the end of the group */
- for (dr = TAILQ_FIRST(&nd_defrouter); dr;
- dr = TAILQ_NEXT(dr, dr_entry)) {
+ ND_DEFROUTER_LIST_FOREACH(dr) {
if (rtpref(n) > rtpref(dr))
break;
}
if (dr)
- TAILQ_INSERT_BEFORE(dr, n, dr_entry);
+ ND_DEFROUTER_LIST_INSERT_BEFORE(dr, n);
else
- TAILQ_INSERT_TAIL(&nd_defrouter, n, dr_entry);
+ ND_DEFROUTER_LIST_INSERT_TAIL(n);
nd6_defrouter_select();
@@ -1465,7 +1463,7 @@
* that does not advertise any prefixes.
*/
if (pr == NULL) {
- TAILQ_FOREACH(dr, &nd_defrouter, dr_entry) {
+ ND_DEFROUTER_LIST_FOREACH(dr) {
struct nd_prefix *pr0;
LIST_FOREACH(pr0, &nd_prefix, ndpr_entry) {
@@ -1476,7 +1474,7 @@
break;
}
}
- if (pr != NULL || (TAILQ_FIRST(&nd_defrouter) && !pfxrtr)) {
+ if (pr != NULL || (!ND_DEFROUTER_LIST_EMPTY() && !pfxrtr)) {
/*
* There is at least one prefix that has a reachable router,
* or at least a router which probably does not advertise
Home |
Main Index |
Thread Index |
Old Index