Skip to content

Commit

Permalink
- use coa when doing NUD.
Browse files Browse the repository at this point in the history
  • Loading branch information
keiichi committed Feb 8, 2002
1 parent 0adf2c9 commit d326dfe
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 51 deletions.
99 changes: 54 additions & 45 deletions kame/sys/netinet6/in6_src.c
@@ -1,4 +1,4 @@
/* $KAME: in6_src.c,v 1.105 2002/02/02 07:06:12 jinmei Exp $ */
/* $KAME: in6_src.c,v 1.106 2002/02/08 04:51:14 keiichi Exp $ */

/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
Expand Down Expand Up @@ -382,14 +382,22 @@ in6_selectsrc(dstsock, opts, mopts, ro, laddr, ifpp, errorp)
*/
#ifdef MIP6
/*
* If SA is simultaneously a home address and care-of address
* and SB is not, then prefer SA. Similarly, if SB is
* simultaneously a home address and care-of address and SA is
* not, then prefer SB.
* a caller can specify IP6PO_USECOA to not to use a
* home address. for example, the case that the
* neighbour unreachability detection to the global
* address.
*/
{
if (!((opts != NULL) &&
((opts->ip6po_flags & IP6PO_USECOA) != 0))) {
struct mip6_bu *mbu_ia_best = NULL, *mbu_ia = NULL;

/*
* If SA is simultaneously a home address and
* care-of address and SB is not, then prefer
* SA. Similarly, if SB is simultaneously a
* home address and care-of address and SA is
* not, then prefer SB.
*/
if (ia_best->ia6_flags & IN6_IFF_HOME) {
/*
* find a binding update entry for ia_best.
Expand Down Expand Up @@ -442,47 +450,48 @@ in6_selectsrc(dstsock, opts, mopts, ro, laddr, ifpp, errorp)
== MIP6_BU_REG_STATE_NOTREG))) {
REPLACE(4);
}
}
#ifdef MIP6_ALLOW_COA_FALLBACK
if (coafallback) {
/*
* if the peer doesn't recognize a home
* address destination option, we will use a
* CoA as a source address instead of a home
* address we have registered before. Though
* this behavior may arouse a mip6 beleiver's
* anger, is very useful in the current
* transition period that many hosts don't
* recognize a home address destination
* option...
*/
if ((ia_best->ia6_flags & IN6_IFF_HOME) == 0 &&
(ia->ia6_flags & IN6_IFF_HOME) != 0) {
/* XXX will break stat! */
NEXT(0);
}
if ((ia_best->ia6_flags & IN6_IFF_HOME) != 0 &&
(ia->ia6_flags & IN6_IFF_HOME) == 0) {
/* XXX will break stat! */
REPLACE(0);
}
} else
if (coafallback) {
/*
* if the peer doesn't recognize a
* home address destination option, we
* will use a CoA as a source address
* instead of a home address we have
* registered before. Though this
* behavior breaks the mobility, this
* is very useful in the current
* transition period that many hosts
* don't recognize a home address
* destination option...
*/
if ((ia_best->ia6_flags & IN6_IFF_HOME) == 0 &&
(ia->ia6_flags & IN6_IFF_HOME) != 0) {
/* XXX will break stat! */
NEXT(0);
}
if ((ia_best->ia6_flags & IN6_IFF_HOME) != 0 &&
(ia->ia6_flags & IN6_IFF_HOME) == 0) {
/* XXX will break stat! */
REPLACE(0);
}
} else
#endif
{
/*
* If SA is just a home address and SB is just
* a care-of address, then prefer
* SA. Similarly, if SB is just a home address
* and SA is just a care-of address, then
* prefer SB.
*/
if ((ia_best->ia6_flags & IN6_IFF_HOME) != 0 &&
(ia->ia6_flags & IN6_IFF_HOME) == 0) {
NEXT(4);
}
if ((ia_best->ia6_flags & IN6_IFF_HOME) == 0 &&
(ia->ia6_flags & IN6_IFF_HOME) != 0) {
REPLACE(4);
{
/*
* If SA is just a home address and SB
* is just a care-of address, then
* prefer SA. Similarly, if SB is just
* a home address and SA is just a
* care-of address, then prefer SB.
*/
if ((ia_best->ia6_flags & IN6_IFF_HOME) != 0 &&
(ia->ia6_flags & IN6_IFF_HOME) == 0) {
NEXT(4);
}
if ((ia_best->ia6_flags & IN6_IFF_HOME) == 0 &&
(ia->ia6_flags & IN6_IFF_HOME) != 0) {
REPLACE(4);
}
}
}
#endif /* MIP6 */
Expand Down
3 changes: 2 additions & 1 deletion kame/sys/netinet6/ip6_var.h
@@ -1,4 +1,4 @@
/* $KAME: ip6_var.h,v 1.86 2002/02/07 05:31:00 keiichi Exp $ */
/* $KAME: ip6_var.h,v 1.87 2002/02/08 04:51:14 keiichi Exp $ */

/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
Expand Down Expand Up @@ -169,6 +169,7 @@ struct ip6_pktopts {
#define IP6PO_REACHCONF 0x01 /* upper-layer reachability confirmation */
#define IP6PO_MINMTU 0x02 /* use minimum MTU (IPV6_USE_MIN_MTU) */
#define IP6PO_DONTFRAG 0x04 /* disable fragmentation (IPV6_DONTFRAG) */
#define IP6PO_USECOA 0x08 /* use care of address */

int needfree; /* members dynamically allocated */
};
Expand Down
11 changes: 10 additions & 1 deletion kame/sys/netinet6/mip6.c
@@ -1,4 +1,4 @@
/* $KAME: mip6.c,v 1.113 2002/02/02 07:06:12 jinmei Exp $ */
/* $KAME: mip6.c,v 1.114 2002/02/08 04:51:13 keiichi Exp $ */

/*
* Copyright (C) 2001 WIDE Project. All rights reserved.
Expand Down Expand Up @@ -2683,6 +2683,7 @@ mip6_addr_exchange(m, dstm)
struct in6_addr ip6_src;
u_int8_t *opt;
int ii, dstoptlen;
struct mbuf *n;

/* sanity check */
if (!MIP6_IS_MN) {
Expand Down Expand Up @@ -2735,6 +2736,14 @@ mip6_addr_exchange(m, dstm)
/* Swap the IPv6 homeaddress and the care-of address. */
ip6 = mtod(m, struct ip6_hdr *);
bcopy(&ip6->ip6_src, &ip6_src, sizeof(ip6->ip6_src));
n = ip6_findaux(m);
if (n) {
struct ip6aux *ip6a;
ip6a = mtod(n, struct ip6aux *);
/* XXX scope */
bcopy(haopt->ip6oh_addr, &ip6a->ip6a_src.sin6_addr,
sizeof(haopt->ip6oh_addr));
}
bcopy(haopt->ip6oh_addr, &ip6->ip6_src, sizeof(haopt->ip6oh_addr));
bcopy(&ip6_src, haopt->ip6oh_addr, sizeof(ip6_src));

Expand Down
33 changes: 29 additions & 4 deletions kame/sys/netinet6/nd6_nbr.c
@@ -1,4 +1,4 @@
/* $KAME: nd6_nbr.c,v 1.92 2002/02/04 08:37:37 jinmei Exp $ */
/* $KAME: nd6_nbr.c,v 1.93 2002/02/08 04:51:13 keiichi Exp $ */

/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
Expand Down Expand Up @@ -563,10 +563,22 @@ nd6_ns_output(ifp, daddr0, taddr0, ln, dad)
else {
struct sockaddr_in6 *src0;
int error;
#ifdef MIP6
struct ip6_pktopts opts;
#endif /* MIP6 */

#ifdef MIP6
init_ip6pktopts(&opts);
opts.ip6po_flags |= IP6PO_USECOA;
#endif /* MIP6 */
bcopy(&dst_sa, &ro.ro_dst, sizeof(dst_sa));
src0 = in6_selectsrc(&dst_sa, NULL, NULL, &ro,
NULL, NULL, &error);
src0 = in6_selectsrc(&dst_sa,
#ifdef MIP6
&opts,
#else
NULL,
#endif /* MIP6 */
NULL, &ro, NULL, NULL, &error);
if (src0 == NULL) {
nd6log((LOG_DEBUG,
"nd6_ns_output: source can't be "
Expand Down Expand Up @@ -1001,6 +1013,9 @@ nd6_na_output(ifp, daddr6, taddr6, flags, tlladdr, sdl0)
#else
struct route_in6 ro;
#endif
#ifdef MIP6
struct ip6_pktopts opts;
#endif /* MIP6 */

bzero(&ro, sizeof(ro));

Expand Down Expand Up @@ -1067,8 +1082,18 @@ nd6_na_output(ifp, daddr6, taddr6, flags, tlladdr, sdl0)
/*
* Select a source whose scope is the same as that of the dest.
*/
#ifdef MIP6
init_ip6pktopts(&opts);
opts.ip6po_flags |= IP6PO_USECOA;
#endif /* MIP6 */
bcopy(&dst_sa, &ro.ro_dst, sizeof(dst_sa));
src0 = in6_selectsrc(&dst_sa, NULL, NULL, &ro, NULL, NULL, &error);
src0 = in6_selectsrc(&dst_sa,
#ifdef MIP6
&opts,
#else
NULL,
#endif /* MIP6 */
NULL, &ro, NULL, NULL, &error);
if (src0 == NULL) {
nd6log((LOG_DEBUG, "nd6_na_output: source can't be "
"determined: dst=%s, error=%d\n",
Expand Down

0 comments on commit d326dfe

Please sign in to comment.