Skip to content

Commit

Permalink
nd_defrouter now stored sockaddr_in6, not in6_addr.
Browse files Browse the repository at this point in the history
  • Loading branch information
jinmei committed Feb 3, 2002
1 parent 4312a0a commit 99cf510
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 84 deletions.
6 changes: 3 additions & 3 deletions kame/sys/netinet6/mip6_ha.c
@@ -1,4 +1,4 @@
/* $KAME: mip6_ha.c,v 1.32 2002/01/17 05:24:03 keiichi Exp $ */
/* $KAME: mip6_ha.c,v 1.33 2002/02/03 11:27:06 jinmei Exp $ */

/*
* Copyright (C) 2001 WIDE Project. All rights reserved.
Expand Down Expand Up @@ -198,7 +198,7 @@ mip6_ha_list_update_hainfo(mha_list, dr, hai)

if ((mha_list == NULL) ||
(dr == NULL) ||
!IN6_IS_ADDR_LINKLOCAL(&dr->rtaddr)) {
!IN6_IS_ADDR_LINKLOCAL(&dr->rtaddr.sin6_addr)) {
return (EINVAL);
}

Expand All @@ -209,7 +209,7 @@ mip6_ha_list_update_hainfo(mha_list, dr, hai)
}

/* find an exising entry. */
lladdr = dr->rtaddr;
lladdr = dr->rtaddr.sin6_addr; /* XXX: scope */
/* XXX: KAME link-local hack; remove ifindex */
lladdr.s6_addr16[1] = 0;
mha = mip6_ha_list_find_withaddr(mha_list, &lladdr);
Expand Down
64 changes: 23 additions & 41 deletions kame/sys/netinet6/nd6.c
@@ -1,4 +1,4 @@
/* $KAME: nd6.c,v 1.222 2002/01/31 14:14:53 jinmei Exp $ */
/* $KAME: nd6.c,v 1.223 2002/02/03 11:27:07 jinmei Exp $ */

/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
Expand Down Expand Up @@ -1085,7 +1085,6 @@ nd6_free(rt, gc)
int gc;
{
struct llinfo_nd6 *ln = (struct llinfo_nd6 *)rt->rt_llinfo, *next;
struct in6_addr in6 = ((struct sockaddr_in6 *)rt_key(rt))->sin6_addr;
struct nd_defrouter *dr;

/*
Expand All @@ -1100,7 +1099,7 @@ nd6_free(rt, gc)
#else
s = splnet();
#endif
dr = defrouter_lookup(&((struct sockaddr_in6 *)rt_key(rt))->sin6_addr,
dr = defrouter_lookup((struct sockaddr_in6 *)rt_key(rt),
rt->rt_ifp);

if (dr != NULL && dr->expire &&
Expand All @@ -1123,12 +1122,24 @@ nd6_free(rt, gc)
}

if (ln->ln_router || dr) {
struct sockaddr_in6 sin6;
int e = 0; /* XXX */

sin6 = *((struct sockaddr_in6 *)rt_key(rt));
/*
* rt6_flush must be called whether or not the neighbor
* is in the Default Router List.
* See a corresponding comment in nd6_na_input().
*/
rt6_flush(&in6, rt->rt_ifp);
#ifndef SCOPEDROUTING
/* sin6 may not have a valid sin6_scope_id */
e = in6_recoverscope(&sin6, &sin6.sin6_addr, NULL);
if (e == 0) { /* XXX */
sin6.sin6_addr = ((struct sockaddr_in6 *)rt_key(rt))->sin6_addr;
}
#endif
if (e == 0)
rt6_flush(&sin6, rt->rt_ifp);
}

if (dr) {
Expand Down Expand Up @@ -1543,16 +1554,8 @@ nd6_ioctl(cmd, data, ifp)
#endif
dr = TAILQ_FIRST(&nd_defrouter);
while (dr && i < DRLSTSIZ) {
drl->defrouter[i].rtaddr = dr->rtaddr;
if (IN6_IS_ADDR_LINKLOCAL(&drl->defrouter[i].rtaddr)) {
/* XXX: need to this hack for KAME stack */
drl->defrouter[i].rtaddr.s6_addr16[1] = 0;
} else
log(LOG_ERR,
"default router list contains a "
"non-linklocal address(%s)\n",
ip6_sprintf(&drl->defrouter[i].rtaddr));

drl->defrouter[i].rtaddr = dr->rtaddr.sin6_addr;
in6_clearscope(&drl->defrouter[i].rtaddr);
drl->defrouter[i].flags = dr->flags;
drl->defrouter[i].rtlifetime = dr->rtlifetime;
drl->defrouter[i].expire = dr->expire;
Expand Down Expand Up @@ -1614,16 +1617,8 @@ nd6_ioctl(cmd, data, ifp)
while (pfr) {
if (j < DRLSTSIZ) {
#define RTRADDR oprl->prefix[i].advrtr[j]
RTRADDR = pfr->router->rtaddr;
if (IN6_IS_ADDR_LINKLOCAL(&RTRADDR)) {
/* XXX: hack for KAME */
RTRADDR.s6_addr16[1] = 0;
} else
log(LOG_ERR,
"a router(%s) advertises "
"a prefix with "
"non-link local address\n",
ip6_sprintf(&RTRADDR));
RTRADDR = pfr->router->rtaddr.sin6_addr;
in6_clearscope(&RTRADDR);
#undef RTRADDR
}
j++;
Expand Down Expand Up @@ -2505,14 +2500,8 @@ fill_drlist(req)
#endif
d + 1 <= de) {
bzero(d, sizeof(*d));
d->rtaddr.sin6_family = AF_INET6;
d->rtaddr.sin6_len = sizeof(d->rtaddr);
if (in6_recoverscope(&d->rtaddr, &dr->rtaddr,
dr->ifp) != 0)
log(LOG_ERR,
"scope error in "
"default router list (%s)\n",
ip6_sprintf(&dr->rtaddr));
d->rtaddr = dr->rtaddr;
in6_clearscope(&d->rtaddr);
d->flags = dr->flags;
d->rtlifetime = dr->rtlifetime;
d->expire = dr->expire;
Expand Down Expand Up @@ -2650,15 +2639,8 @@ fill_prlist(req)
#else
s6 = &advrtr;
#endif
bzero(s6, sizeof(*s6));
s6->sin6_family = AF_INET6;
s6->sin6_len = sizeof(*s6);
if (in6_recoverscope(s6, &pfr->router->rtaddr,
pfr->router->ifp) != 0) {
log(LOG_ERR, "scope error in "
"prefix list (%s)\n",
ip6_sprintf(&pfr->router->rtaddr));
}
*s6 = pfr->router->rtaddr;
in6_clearscope(&s6->sin6_addr);
#ifdef __FreeBSD__
SYSCTL_OUT(req, s6, sizeof(*s6));
#endif
Expand Down
8 changes: 4 additions & 4 deletions kame/sys/netinet6/nd6.h
@@ -1,4 +1,4 @@
/* $KAME: nd6.h,v 1.77 2002/01/31 14:14:53 jinmei Exp $ */
/* $KAME: nd6.h,v 1.78 2002/02/03 11:27:07 jinmei Exp $ */

/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
Expand Down Expand Up @@ -235,7 +235,7 @@ struct in6_ndifreq {
TAILQ_HEAD(nd_drhead, nd_defrouter);
struct nd_defrouter {
TAILQ_ENTRY(nd_defrouter) dr_entry;
struct in6_addr rtaddr;
struct sockaddr_in6 rtaddr;
u_char flags; /* flags on RA message */
u_short rtlifetime;
u_long expire;
Expand Down Expand Up @@ -436,11 +436,11 @@ int nd6_prelist_add __P((struct nd_prefix *, struct nd_defrouter *,
int nd6_prefix_onlink __P((struct nd_prefix *));
int nd6_prefix_offlink __P((struct nd_prefix *));
void pfxlist_onlink_check __P((void));
struct nd_defrouter *defrouter_lookup __P((struct in6_addr *,
struct nd_defrouter *defrouter_lookup __P((struct sockaddr_in6 *,
struct ifnet *));
struct nd_prefix *nd6_prefix_lookup __P((struct nd_prefix *));
int in6_init_prefix_ltimes __P((struct nd_prefix *ndpr));
void rt6_flush __P((struct in6_addr *, struct ifnet *));
void rt6_flush __P((struct sockaddr_in6 *, struct ifnet *));
int nd6_setdefaultiface __P((int));
int in6_tmpifadd __P((const struct in6_ifaddr *, int));

Expand Down
19 changes: 10 additions & 9 deletions kame/sys/netinet6/nd6_nbr.c
@@ -1,4 +1,4 @@
/* $KAME: nd6_nbr.c,v 1.88 2002/02/02 07:06:13 jinmei Exp $ */
/* $KAME: nd6_nbr.c,v 1.89 2002/02/03 11:27:07 jinmei Exp $ */

/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
Expand Down Expand Up @@ -677,9 +677,7 @@ nd6_na_input(m, off, icmp6len)
struct ifnet *ifp = m->m_pkthdr.rcvif;
struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *);
struct nd_neighbor_advert *nd_na;
#if 0
struct in6_addr saddr6 = ip6->ip6_src;
#endif
struct sockaddr_in6 *saddr6;
struct sockaddr_in6 taddr6;
int flags;
int is_router;
Expand Down Expand Up @@ -714,6 +712,11 @@ nd6_na_input(m, off, icmp6len)
return;
}
#endif

if (ip6_getpktaddrs(m, &saddr6, NULL))
goto bad; /* should be impossible */


flags = nd_na->nd_na_flags_reserved;
is_router = ((flags & ND_NA_FLAG_ROUTER) != 0);
is_solicited = ((flags & ND_NA_FLAG_SOLICITED) != 0);
Expand Down Expand Up @@ -917,11 +920,8 @@ nd6_na_input(m, off, icmp6len)
* update the Destination Cache entries.
*/
struct nd_defrouter *dr;
struct in6_addr *in6;
int s;

in6 = &((struct sockaddr_in6 *)rt_key(rt))->sin6_addr;

/*
* Lock to protect the default router list.
* XXX: this might be unnecessary, since this function
Expand All @@ -933,7 +933,8 @@ nd6_na_input(m, off, icmp6len)
#else
s = splnet();
#endif
dr = defrouter_lookup(in6, rt->rt_ifp);
dr = defrouter_lookup((struct sockaddr_in6 *)rt_key(rt),
rt->rt_ifp);
if (dr)
defrtrlist_del(dr);
else if (!ip6_forwarding && ip6_accept_rtadv) {
Expand All @@ -944,7 +945,7 @@ nd6_na_input(m, off, icmp6len)
* (e.g. redirect case). So we must
* call rt6_flush explicitly.
*/
rt6_flush(&ip6->ip6_src, rt->rt_ifp);
rt6_flush(saddr6, rt->rt_ifp);
}
splx(s);
}
Expand Down

0 comments on commit 99cf510

Please sign in to comment.