Introduce macros for the prefix list

No functional change.
This commit is contained in:
ozaki-r 2016-12-12 03:14:01 +00:00
parent f5a82c952d
commit f2613b7f35
3 changed files with 32 additions and 23 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: nd6.c,v 1.214 2016/12/12 03:13:14 ozaki-r Exp $ */
/* $NetBSD: nd6.c,v 1.215 2016/12/12 03:14:01 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.214 2016/12/12 03:13:14 ozaki-r Exp $");
__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.215 2016/12/12 03:14:01 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_net_mpsafe.h"
@ -692,7 +692,7 @@ nd6_timer_work(struct work *wk, void *arg)
curlwp_bindx(bound);
/* expire prefix list */
LIST_FOREACH_SAFE(pr, &nd_prefix, ndpr_entry, next_pr) {
ND_PREFIX_LIST_FOREACH_SAFE(pr, next_pr) {
/*
* check prefix lifetime.
* since pltime is just for autoconf, pltime processing for
@ -859,7 +859,7 @@ nd6_purge(struct ifnet *ifp, struct in6_ifextra *ext)
}
/* Nuke prefix list entries toward ifp */
LIST_FOREACH_SAFE(pr, &nd_prefix, ndpr_entry, npr) {
ND_PREFIX_LIST_FOREACH_SAFE(pr, npr) {
if (pr->ndpr_ifp == ifp) {
/*
* Because if_detach() does *not* release prefixes
@ -981,7 +981,7 @@ nd6_is_new_addr_neighbor(const struct sockaddr_in6 *addr, struct ifnet *ifp)
* If the address matches one of our on-link prefixes, it should be a
* neighbor.
*/
LIST_FOREACH(pr, &nd_prefix, ndpr_entry) {
ND_PREFIX_LIST_FOREACH(pr) {
if (pr->ndpr_ifp != ifp)
continue;
@ -1079,7 +1079,7 @@ nd6_is_addr_neighbor(const struct sockaddr_in6 *addr, struct ifnet *ifp)
* If the address matches one of our on-link prefixes, it should be a
* neighbor.
*/
LIST_FOREACH(pr, &nd_prefix, ndpr_entry) {
ND_PREFIX_LIST_FOREACH(pr) {
if (pr->ndpr_ifp != ifp)
continue;
@ -1647,7 +1647,7 @@ nd6_ioctl(u_long cmd, void *data, struct ifnet *ifp)
*/
memset(oprl, 0, sizeof(*oprl));
s = splsoftnet();
LIST_FOREACH(pr, &nd_prefix, ndpr_entry) {
ND_PREFIX_LIST_FOREACH(pr) {
struct nd_pfxrouter *pfr;
int j;
@ -1854,7 +1854,7 @@ nd6_ioctl(u_long cmd, void *data, struct ifnet *ifp)
struct nd_prefix *pfx, *next;
s = splsoftnet();
LIST_FOREACH_SAFE(pfx, &nd_prefix, ndpr_entry, next) {
ND_PREFIX_LIST_FOREACH_SAFE(pfx, next) {
struct in6_ifaddr *ia, *ia_next;
int _s;
@ -2696,7 +2696,7 @@ fill_prlist(void *oldp, size_t *oldlenp, size_t ol)
}
l = 0;
LIST_FOREACH(pr, &nd_prefix, ndpr_entry) {
ND_PREFIX_LIST_FOREACH(pr) {
u_short advrtrs;
struct sockaddr_in6 sin6;
struct nd_pfxrouter *pfr;

View File

@ -1,4 +1,4 @@
/* $NetBSD: nd6.h,v 1.77 2016/12/12 03:13:14 ozaki-r Exp $ */
/* $NetBSD: nd6.h,v 1.78 2016/12/12 03:14:01 ozaki-r Exp $ */
/* $KAME: nd6.h,v 1.95 2002/06/08 11:31:06 itojun Exp $ */
/*
@ -321,6 +321,15 @@ struct nd_prefix {
#define ndpr_raf_auto ndpr_flags.autonomous
#define ndpr_raf_router ndpr_flags.router
#define ND_PREFIX_LIST_FOREACH(pr) \
LIST_FOREACH((pr), &nd_prefix, ndpr_entry)
#define ND_PREFIX_LIST_FOREACH_SAFE(pr, pr_next) \
LIST_FOREACH_SAFE((pr), &nd_prefix, ndpr_entry, (pr_next))
#define ND_PREFIX_LIST_REMOVE(pr) \
LIST_REMOVE((pr), ndpr_entry)
#define ND_PREFIX_LIST_INSERT_HEAD(pr) \
LIST_INSERT_HEAD(&nd_prefix, (pr), ndpr_entry)
/*
* Message format for use in obtaining information about prefixes
* from inet6 sysctl function

View File

@ -1,4 +1,4 @@
/* $NetBSD: nd6_rtr.c,v 1.124 2016/12/12 03:13:14 ozaki-r Exp $ */
/* $NetBSD: nd6_rtr.c,v 1.125 2016/12/12 03:14:01 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.124 2016/12/12 03:13:14 ozaki-r Exp $");
__KERNEL_RCSID(0, "$NetBSD: nd6_rtr.c,v 1.125 2016/12/12 03:14:01 ozaki-r Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -528,7 +528,7 @@ nd6_defrtrlist_del(struct nd_defrouter *dr, struct in6_ifextra *ext)
/*
* Also delete all the pointers to the router in each prefix lists.
*/
LIST_FOREACH(pr, &nd_prefix, ndpr_entry) {
ND_PREFIX_LIST_FOREACH(pr) {
struct nd_pfxrouter *pfxrtr;
if ((pfxrtr = pfxrtr_lookup(pr, dr)) != NULL)
pfxrtr_del(pfxrtr);
@ -881,7 +881,7 @@ nd6_prefix_lookup(struct nd_prefixctl *key)
{
struct nd_prefix *search;
LIST_FOREACH(search, &nd_prefix, ndpr_entry) {
ND_PREFIX_LIST_FOREACH(search) {
if (key->ndprc_ifp == search->ndpr_ifp &&
key->ndprc_plen == search->ndpr_plen &&
in6_are_prefix_equal(&key->ndprc_prefix.sin6_addr,
@ -983,7 +983,7 @@ nd6_prelist_add(struct nd_prefixctl *prc, struct nd_defrouter *dr,
s = splsoftnet();
/* link ndpr_entry to nd_prefix list */
LIST_INSERT_HEAD(&nd_prefix, newpr, ndpr_entry);
ND_PREFIX_LIST_INSERT_HEAD(newpr);
splx(s);
/* ND_OPT_PI_FLAG_ONLINK processing */
@ -1039,7 +1039,7 @@ nd6_prelist_remove(struct nd_prefix *pr)
s = splsoftnet();
/* unlink ndpr_entry from nd_prefix list */
LIST_REMOVE(pr, ndpr_entry);
ND_PREFIX_LIST_REMOVE(pr);
/* free list of routers that adversed the prefix */
for (pfr = LIST_FIRST(&pr->ndpr_advrtrs); pfr != NULL; pfr = next) {
@ -1454,7 +1454,7 @@ nd6_pfxlist_onlink_check(void)
* Check if there is a prefix that has a reachable advertising
* router.
*/
LIST_FOREACH(pr, &nd_prefix, ndpr_entry) {
ND_PREFIX_LIST_FOREACH(pr) {
if (pr->ndpr_raf_onlink && find_pfxlist_reachable_router(pr))
break;
}
@ -1466,7 +1466,7 @@ nd6_pfxlist_onlink_check(void)
ND_DEFROUTER_LIST_FOREACH(dr) {
struct nd_prefix *pr0;
LIST_FOREACH(pr0, &nd_prefix, ndpr_entry) {
ND_PREFIX_LIST_FOREACH(pr0) {
if ((pfxrtr = pfxrtr_lookup(pr0, dr)) != NULL)
break;
}
@ -1484,7 +1484,7 @@ nd6_pfxlist_onlink_check(void)
* Detach prefixes which have no reachable advertising
* router, and attach other prefixes.
*/
LIST_FOREACH(pr, &nd_prefix, ndpr_entry) {
ND_PREFIX_LIST_FOREACH(pr) {
/* XXX: a link-local prefix should never be detached */
if (IN6_IS_ADDR_LINKLOCAL(&pr->ndpr_prefix.sin6_addr))
continue;
@ -1505,7 +1505,7 @@ nd6_pfxlist_onlink_check(void)
}
} else {
/* there is no prefix that has a reachable router */
LIST_FOREACH(pr, &nd_prefix, ndpr_entry) {
ND_PREFIX_LIST_FOREACH(pr) {
if (IN6_IS_ADDR_LINKLOCAL(&pr->ndpr_prefix.sin6_addr))
continue;
@ -1525,7 +1525,7 @@ nd6_pfxlist_onlink_check(void)
* interfaces. Such cases will be handled in nd6_prefix_onlink,
* so we don't have to care about them.
*/
LIST_FOREACH(pr, &nd_prefix, ndpr_entry) {
ND_PREFIX_LIST_FOREACH(pr) {
int e;
if (IN6_IS_ADDR_LINKLOCAL(&pr->ndpr_prefix.sin6_addr))
@ -1679,7 +1679,7 @@ nd6_prefix_onlink(struct nd_prefix *pr)
* Although such a configuration is expected to be rare, we explicitly
* allow it.
*/
LIST_FOREACH(opr, &nd_prefix, ndpr_entry) {
ND_PREFIX_LIST_FOREACH(opr) {
if (opr == pr)
continue;
@ -1794,7 +1794,7 @@ nd6_prefix_offlink(struct nd_prefix *pr)
* If there's one, try to make the prefix on-link on the
* interface.
*/
LIST_FOREACH(opr, &nd_prefix, ndpr_entry) {
ND_PREFIX_LIST_FOREACH(opr) {
if (opr == pr)
continue;