Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

nd_defrouter now stored sockaddr_in6, not in6_addr.

  • Loading branch information...
commit 99cf510e161a74dd66f93fcf68d37e88c394017d 1 parent 4312a0a
jinmei authored
View
6 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.
@@ -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);
}
@@ -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);
View
64 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.
@@ -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;
/*
@@ -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 &&
@@ -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) {
@@ -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;
@@ -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++;
@@ -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;
@@ -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
View
8 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.
@@ -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;
@@ -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));
View
19 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.
@@ -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;
@@ -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);
@@ -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
@@ -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) {
@@ -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);
}
View
71 kame/sys/netinet6/nd6_rtr.c
@@ -1,4 +1,4 @@
-/* $KAME: nd6_rtr.c,v 1.190 2002/01/31 14:14:54 jinmei Exp $ */
+/* $KAME: nd6_rtr.c,v 1.191 2002/02/03 11:27:07 jinmei Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -295,7 +295,7 @@ nd6_ra_input(m, off, icmp6len)
#endif
Bzero(&dr0, sizeof(dr0));
- dr0.rtaddr = src_sa6->sin6_addr;
+ dr0.rtaddr = *src_sa6;
dr0.flags = nd_ra->nd_ra_flags_reserved;
dr0.rtlifetime = ntohs(nd_ra->nd_ra_router_lifetime);
dr0.expire = time_second + dr0.rtlifetime;
@@ -567,12 +567,14 @@ defrouter_addreq(new)
Bzero(&def, sizeof(def));
Bzero(&mask, sizeof(mask));
- Bzero(&gate, sizeof(gate));
+ Bzero(&gate, sizeof(gate)); /* for safety */
- def.sin6_len = mask.sin6_len = gate.sin6_len
- = sizeof(struct sockaddr_in6);
- def.sin6_family = mask.sin6_family = gate.sin6_family = AF_INET6;
- gate.sin6_addr = new->rtaddr;
+ def.sin6_len = mask.sin6_len = sizeof(struct sockaddr_in6);
+ def.sin6_family = mask.sin6_family = AF_INET6;
+ gate = new->rtaddr;
+#ifndef SCOPEDROUTING
+ gate.sin6_scope_id = 0; /* XXX */
+#endif
#ifdef __NetBSD__
s = splsoftnet();
@@ -696,15 +698,26 @@ defrouter_delifreq()
struct nd_defrouter *
defrouter_lookup(addr, ifp)
- struct in6_addr *addr;
+ struct sockaddr_in6 *addr;
struct ifnet *ifp;
{
struct nd_defrouter *dr;
for (dr = TAILQ_FIRST(&nd_defrouter); dr;
dr = TAILQ_NEXT(dr, dr_entry)) {
- if (dr->ifp == ifp && IN6_ARE_ADDR_EQUAL(addr, &dr->rtaddr))
+ if (dr->ifp == ifp &&
+#ifdef SCOPEDROUTING
+ SA6_ARE_ADDR_EQUAL(addr, &dr->rtaddr)
+#else
+ /*
+ * XXX: when addr comes from the routing table, it does
+ * not have a valid scope zone ID.
+ */
+ IN6_ARE_ADDR_EQUAL(&addr->sin6_addr, &dr->rtaddr.sin6_addr)
+#endif
+ ) {
return(dr);
+ }
}
return(NULL); /* search failed */
@@ -721,10 +734,8 @@ defrtrlist_del(dr)
* Flush all the routing table entries that use the router
* as a next hop.
*/
- if (!ip6_forwarding && ip6_accept_rtadv) {
- /* above is a good condition? */
+ if (!ip6_forwarding && ip6_accept_rtadv) /* XXX: better condition? */
rt6_flush(&dr->rtaddr, dr->ifp);
- }
if (dr->installed) {
deldr = dr;
@@ -767,13 +778,14 @@ defrouter_delreq(dr)
Bzero(&def, sizeof(def));
Bzero(&mask, sizeof(mask));
- Bzero(&gw, sizeof(gw));
+ Bzero(&gw, sizeof(gw)); /* for safety */
- def.sin6_len = mask.sin6_len = gw.sin6_len =
- sizeof(struct sockaddr_in6);
- def.sin6_family = mask.sin6_family = gw.sin6_family = AF_INET6;
- if (dr)
- gw.sin6_addr = dr->rtaddr;
+ def.sin6_len = mask.sin6_len = sizeof(struct sockaddr_in6);
+ def.sin6_family = mask.sin6_family = AF_INET6;
+ gw = dr->rtaddr;
+#ifndef SCOPEDROUTING
+ gw.sin6_scope_id = 0; /* XXX */
+#endif
rtrequest(RTM_DELETE, (struct sockaddr *)&def,
dr ? (struct sockaddr *)&gw : NULL,
@@ -911,7 +923,7 @@ defrouter_select()
for (dr = TAILQ_FIRST(&nd_defrouter); dr;
dr = TAILQ_NEXT(dr, dr_entry)) {
if (!selected_dr &&
- (rt = nd6_lookup(&dr->rtaddr, 0, dr->ifp)) &&
+ (rt = nd6_lookup(&dr->rtaddr.sin6_addr, 0, dr->ifp)) &&
(ln = (struct llinfo_nd6 *)rt->rt_llinfo) &&
ND6_IS_LLINFO_PROBREACH(ln)) {
selected_dr = dr;
@@ -939,7 +951,7 @@ defrouter_select()
else
selected_dr = TAILQ_NEXT(installed_dr, dr_entry);
} else if (installed_dr &&
- (rt = nd6_lookup(&installed_dr->rtaddr, 0,
+ (rt = nd6_lookup(&installed_dr->rtaddr.sin6_addr, 0,
installed_dr->ifp)) &&
(ln = (struct llinfo_nd6 *)rt->rt_llinfo) &&
ND6_IS_LLINFO_PROBREACH(ln) &&
@@ -1592,7 +1604,7 @@ find_pfxlist_reachable_router(pr)
for (pfxrtr = LIST_FIRST(&pr->ndpr_advrtrs); pfxrtr;
pfxrtr = LIST_NEXT(pfxrtr, pfr_entry)) {
- if ((rt = nd6_lookup(&pfxrtr->router->rtaddr, 0,
+ if ((rt = nd6_lookup(&pfxrtr->router->rtaddr.sin6_addr, 0,
pfxrtr->router->ifp)) &&
(ln = (struct llinfo_nd6 *)rt->rt_llinfo) &&
ND6_IS_LLINFO_PROBREACH(ln))
@@ -2297,7 +2309,7 @@ in6_init_address_ltimes(struct nd_prefix *new, struct in6_addrlifetime *lt6)
*/
void
rt6_flush(gateway, ifp)
- struct in6_addr *gateway;
+ struct sockaddr_in6 *gateway;
struct ifnet *ifp;
{
struct radix_node_head *rnh = rt_tables[AF_INET6];
@@ -2308,12 +2320,10 @@ rt6_flush(gateway, ifp)
#endif
/* We'll care only link-local addresses */
- if (!IN6_IS_ADDR_LINKLOCAL(gateway)) {
+ if (!IN6_IS_ADDR_LINKLOCAL(&gateway->sin6_addr)) {
splx(s);
return;
}
- /* XXX: hack for KAME's link-local address kludge */
- gateway->s6_addr16[1] = htons(ifp->if_index);
rnh->rnh_walktree(rnh, rt6_deleteroute, (void *)gateway);
splx(s);
@@ -2326,13 +2336,20 @@ rt6_deleteroute(rn, arg)
{
#define SIN6(s) ((struct sockaddr_in6 *)s)
struct rtentry *rt = (struct rtentry *)rn;
- struct in6_addr *gate = (struct in6_addr *)arg;
+ struct sockaddr_in6 *gate = (struct sockaddr_in6 *)arg;
if (rt->rt_gateway == NULL || rt->rt_gateway->sa_family != AF_INET6)
return(0);
- if (!IN6_ARE_ADDR_EQUAL(gate, &SIN6(rt->rt_gateway)->sin6_addr))
+#ifdef SCOPEDROUTING
+ if (!SA6_ARE_ADDR_EQUAL(gate, SIN6(rt->rt_gateway)))
return(0);
+#else
+ if (!IN6_ARE_ADDR_EQUAL(&gate->sin6_addr,
+ &SIN6(rt->rt_gateway)->sin6_addr)) {
+ return(0);
+ }
+#endif
/*
* Do not delete a static route.
Please sign in to comment.
Something went wrong with that request. Please try again.