Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/netinet6 fix anycast address determination.
details: https://anonhg.NetBSD.org/src/rev/da3b3aabb6db
branches: trunk
changeset: 487399:da3b3aabb6db
user: itojun <itojun%NetBSD.org@localhost>
date: Wed Jun 07 06:27:43 2000 +0000
description:
fix anycast address determination.
correct interface address addition when link-local is added (check if ifp
matches).
make diff to kame repository easier (breaks some KNF)
sync with kame.
diffstat:
sys/netinet6/in6_prefix.c | 67 ++++++++++++++++++++++++++++++++--------------
1 files changed, 47 insertions(+), 20 deletions(-)
diffs (222 lines):
diff -r 4afbdf96e69a -r da3b3aabb6db sys/netinet6/in6_prefix.c
--- a/sys/netinet6/in6_prefix.c Wed Jun 07 05:28:17 2000 +0000
+++ b/sys/netinet6/in6_prefix.c Wed Jun 07 06:27:43 2000 +0000
@@ -1,9 +1,10 @@
-/* $NetBSD: in6_prefix.c,v 1.11 2000/03/23 07:03:29 thorpej Exp $ */
+/* $NetBSD: in6_prefix.c,v 1.12 2000/06/07 06:27:43 itojun Exp $ */
+/* $KAME: in6_prefix.c,v 1.29 2000/06/07 05:59:38 itojun Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -15,7 +16,7 @@
* 3. Neither the name of the project nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -153,7 +154,8 @@
struct ifprefix *ifpr;
/* search matched prefix */
- for (ifpr = ifp->if_prefixlist; ifpr; ifpr = ifpr->ifpr_next) {
+ for (ifpr = ifp->if_prefixlist; ifpr; ifpr = ifpr->ifpr_next)
+ {
if (ifpr->ifpr_prefix->sa_family != AF_INET6 ||
ifpr->ifpr_type != IN6_PREFIX_RR)
continue;
@@ -200,7 +202,8 @@
if (rpp != 0)
return rpp;
- for (ifpr = ifp->if_prefixlist; ifpr; ifpr = ifpr->ifpr_next) {
+ for (ifpr = ifp->if_prefixlist; ifpr; ifpr = ifpr->ifpr_next)
+ {
if (ifpr->ifpr_prefix->sa_family != AF_INET6 ||
ifpr->ifpr_type != IN6_PREFIX_RR)
continue;
@@ -228,7 +231,8 @@
int matchlen, matched = 0;
/* search matched prefixes */
- for (ifpr = ifp->if_prefixlist; ifpr; ifpr = ifpr->ifpr_next) {
+ for (ifpr = ifp->if_prefixlist; ifpr; ifpr = ifpr->ifpr_next)
+ {
if (ifpr->ifpr_prefix->sa_family != AF_INET6 ||
ifpr->ifpr_type != IN6_PREFIX_RR)
continue;
@@ -283,7 +287,8 @@
struct ifprefix *ifpr;
/* search matched prefixes */
- for (ifpr = ifp->if_prefixlist; ifpr; ifpr = ifpr->ifpr_next) {
+ for (ifpr = ifp->if_prefixlist; ifpr; ifpr = ifpr->ifpr_next)
+ {
if (ifpr->ifpr_prefix->sa_family != AF_INET6 ||
ifpr->ifpr_type != IN6_PREFIX_RR)
continue;
@@ -301,7 +306,8 @@
struct ifprefix *ifpr;
/* unmark all prefix */
- for (ifpr = ifp->if_prefixlist; ifpr; ifpr = ifpr->ifpr_next) {
+ for (ifpr = ifp->if_prefixlist; ifpr; ifpr = ifpr->ifpr_next)
+ {
if (ifpr->ifpr_prefix->sa_family != AF_INET6 ||
ifpr->ifpr_type != IN6_PREFIX_RR)
continue;
@@ -365,10 +371,12 @@
for (rap = rpp->rp_addrhead.lh_first; rap != NULL;
rap = rap->ra_entry.le_next)
+ {
if (rr_are_ifid_equal(ifid, &rap->ra_ifid,
(sizeof(struct in6_addr) << 3) -
rpp->rp_plen))
break;
+ }
return rap;
}
@@ -399,6 +407,10 @@
return 0;
}
+/*
+ * add a link-local address to an interface. we will add new interface address
+ * (prefix database + new interface id).
+ */
static int
in6_prefix_add_llifid(int iilen, struct in6_ifaddr *ia)
{
@@ -418,6 +430,12 @@
/* insert into list */
for (rpp = LIST_FIRST(&rr_prefix); rpp; rpp = LIST_NEXT(rpp, rp_entry))
{
+ /*
+ * do not attempt to add an address, if ifp does not match
+ */
+ if (rpp->rp_ifp != ia->ia_ifp)
+ continue;
+
s = splnet();
LIST_INSERT_HEAD(&rpp->rp_addrhead, rap, ra_entry);
splx(s);
@@ -426,7 +444,10 @@
return 0;
}
-
+/*
+ * add an address to an interface. if the interface id portion is new,
+ * we will add new interface address (prefix database + new interface id).
+ */
int
in6_prefix_add_ifid(int iilen, struct in6_ifaddr *ia)
{
@@ -536,7 +557,8 @@
struct ifprefix *ifpr, *nextifpr;
/* delete prefixes before ifnet goes away */
- for (ifpr = ifp->if_prefixlist; ifpr; ifpr = nextifpr) {
+ for (ifpr = ifp->if_prefixlist; ifpr; ifpr = nextifpr)
+ {
nextifpr = ifpr->ifpr_next;
if (ifpr->ifpr_prefix->sa_family != AF_INET6 ||
ifpr->ifpr_type != IN6_PREFIX_RR)
@@ -632,7 +654,8 @@
int s;
/* search existing prefix */
- for (ifpr = new->rp_ifp->if_prefixlist; ifpr; ifpr = ifpr->ifpr_next) {
+ for (ifpr = new->rp_ifp->if_prefixlist; ifpr; ifpr = ifpr->ifpr_next)
+ {
if (ifpr->ifpr_prefix->sa_family != AF_INET6 ||
ifpr->ifpr_type != IN6_PREFIX_RR)
continue;
@@ -698,7 +721,8 @@
*rpp = *new;
LIST_INIT(&rpp->rp_addrhead);
/* move rp_addr entries of new to rpp */
- while (new->rp_addrhead.lh_first != NULL) {
+ while (new->rp_addrhead.lh_first != NULL)
+ {
rap = LIST_FIRST(&new->rp_addrhead);
LIST_REMOVE(rap, ra_entry);
LIST_INSERT_HEAD(&rpp->rp_addrhead, rap, ra_entry);
@@ -716,8 +740,7 @@
ifpr = ifpr->ifpr_next)
continue;
ifpr->ifpr_next = rp2ifpr(rpp);
- }
- else
+ } else
ifp->if_prefixlist = rp2ifpr(rpp);
rp2ifpr(rpp)->ifpr_type = IN6_PREFIX_RR;
}
@@ -736,7 +759,8 @@
* init the prefix pointer.
*/
for (rap = rpp->rp_addrhead.lh_first; rap != NULL;
- rap = rap->ra_entry.le_next) {
+ rap = rap->ra_entry.le_next)
+ {
if (rap->ra_addr != NULL) {
if (rap->ra_addr->ia6_ifpr == NULL)
rap->ra_addr->ia6_ifpr = rp2ifpr(rpp);
@@ -823,7 +847,8 @@
min(ifpr->ifpr_plen - irr->irr_u_uselen,
irr->irr_u_keeplen));
for (orap = (ifpr2rp(ifpr)->rp_addrhead).lh_first; orap != NULL;
- orap = orap->ra_entry.le_next) {
+ orap = orap->ra_entry.le_next)
+ {
struct rp_addr *rap;
int error = 0;
@@ -831,7 +856,7 @@
return error;
rap->ra_ifid = orap->ra_ifid;
rap->ra_flags.anycast = (orap->ra_addr != NULL &&
- (orap->ra_addr->ia_flags &
+ (orap->ra_addr->ia6_flags &
IN6_IFF_ANYCAST) != 0) ? 1 : 0;
LIST_INSERT_HEAD(&rpp->rp_addrhead, rap, ra_entry);
}
@@ -845,7 +870,7 @@
rpp->rp_rrf = irr->irr_rrf;
rpp->rp_origin = irr->irr_origin;
- return 0;
+ return 0;
}
static void
@@ -876,7 +901,8 @@
int error = 0;
/* add prefixes to each of marked prefix */
- for (ifpr = ifp->if_prefixlist; ifpr; ifpr = nextifpr) {
+ for (ifpr = ifp->if_prefixlist; ifpr; ifpr = nextifpr)
+ {
nextifpr = ifpr->ifpr_next;
if (ifpr->ifpr_prefix->sa_family != AF_INET6 ||
ifpr->ifpr_type != IN6_PREFIX_RR)
@@ -947,7 +973,8 @@
struct ifprefix *ifpr, *nextifpr;
/* delete prefixes marked as tobe deleted */
- for (ifpr = ifp->if_prefixlist; ifpr; ifpr = nextifpr) {
+ for (ifpr = ifp->if_prefixlist; ifpr; ifpr = nextifpr)
+ {
nextifpr = ifpr->ifpr_next;
if (ifpr->ifpr_prefix->sa_family != AF_INET6 ||
ifpr->ifpr_type != IN6_PREFIX_RR)
Home |
Main Index |
Thread Index |
Old Index