Eliminate address family-specific route caches (struct route, struct

route_in6, struct route_iso), replacing all caches with a struct
route.

The principle benefit of this change is that all of the protocol
families can benefit from route cache-invalidation, which is
necessary for correct routing.  Route-cache invalidation fixes an
ancient PR, kern/3508, at long last; it fixes various other PRs,
also.

Discussions with and ideas from Joerg Sonnenberger influenced this
work tremendously.  Of course, all design oversights and bugs are
mine.

DETAILS

1 I added to each address family a pool of sockaddrs.  I have
  introduced routines for allocating, copying, and duplicating,
  and freeing sockaddrs:

        struct sockaddr *sockaddr_alloc(sa_family_t af, int flags);
        struct sockaddr *sockaddr_copy(struct sockaddr *dst,
                                       const struct sockaddr *src);
        struct sockaddr *sockaddr_dup(const struct sockaddr *src, int flags);
        void sockaddr_free(struct sockaddr *sa);

  sockaddr_alloc() returns either a sockaddr from the pool belonging
  to the specified family, or NULL if the pool is exhausted.  The
  returned sockaddr has the right size for that family; sa_family
  and sa_len fields are initialized to the family and sockaddr
  length---e.g., sa_family = AF_INET and sa_len = sizeof(struct
  sockaddr_in).  sockaddr_free() puts the given sockaddr back into
  its family's pool.

  sockaddr_dup() and sockaddr_copy() work analogously to strdup()
  and strcpy(), respectively.  sockaddr_copy() KASSERTs that the
  family of the destination and source sockaddrs are alike.

  The 'flags' argumet for sockaddr_alloc() and sockaddr_dup() is
  passed directly to pool_get(9).

2 I added routines for initializing sockaddrs in each address
  family, sockaddr_in_init(), sockaddr_in6_init(), sockaddr_iso_init(),
  etc.  They are fairly self-explanatory.

3 structs route_in6 and route_iso are no more.  All protocol families
  use struct route.  I have changed the route cache, 'struct route',
  so that it does not contain storage space for a sockaddr.  Instead,
  struct route points to a sockaddr coming from the pool the sockaddr
  belongs to.  I added a new method to struct route, rtcache_setdst(),
  for setting the cache destination:

        int rtcache_setdst(struct route *, const struct sockaddr *);

  rtcache_setdst() returns 0 on success, or ENOMEM if no memory is
  available to create the sockaddr storage.

  It is now possible for rtcache_getdst() to return NULL if, say,
  rtcache_setdst() failed.  I check the return value for NULL
  everywhere in the kernel.

4 Each routing domain (struct domain) has a list of live route
  caches, dom_rtcache.  rtflushall(sa_family_t af) looks up the
  domain indicated by 'af', walks the domain's list of route caches
  and invalidates each one.
This commit is contained in:
dyoung 2007-05-02 20:40:22 +00:00
parent 9c16b5e434
commit 72f0a6dfb0
71 changed files with 1351 additions and 1129 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: files,v 1.839 2007/05/01 17:18:55 bouyer Exp $
# $NetBSD: files,v 1.840 2007/05/02 20:40:22 dyoung Exp $
# @(#)files.newconf 7.5 (Berkeley) 5/10/93
@ -39,6 +39,7 @@ defflag NEW_BUFQ_STRATEGY # same as BUFQ_READPRIO
defparam SOMAXKVA
defflag opt_sock_counters.h SOSEND_COUNTERS
defflag opt_sosend_loan.h SOSEND_NO_LOAN
defflag opt_route.h RTCACHE_DEBUG RTFLUSH_DEBUG
defflag MULTIPROCESSOR

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip_fil_netbsd.c,v 1.34 2007/05/01 19:08:04 martti Exp $ */
/* $NetBSD: ip_fil_netbsd.c,v 1.35 2007/05/02 20:40:22 dyoung Exp $ */
/*
* Copyright (C) 1993-2003 by Darren Reed.
@ -1067,7 +1067,15 @@ frdest_t *fdp;
struct route *ro;
int off, len, hlen, code;
struct ifnet *ifp, *sifp;
#if __NetBSD_Version__ < 499001100
struct sockaddr_in *dst;
#else /* __NetBSD_Version__ < 499001100 */
const struct sockaddr *dst;
union {
struct sockaddr dst;
struct sockaddr_in dst4;
} u;
#endif /* __NetBSD_Version__ < 499001100 */
struct route iproute;
u_short ip_off;
frentry_t *fr;
@ -1099,15 +1107,6 @@ frdest_t *fdp;
m0->m_pkthdr.csuminfo = 0;
# endif /* __NetBSD__ && M_CSUM_IPv4 */
/*
* Route packet.
*/
ro = &iproute;
bzero((void *)ro, sizeof (*ro));
dst = (struct sockaddr_in *)&ro->ro_dst;
dst->sin_family = AF_INET;
dst->sin_addr = ip->ip_dst;
fr = fin->fin_fr;
if (fdp != NULL)
ifp = fdp->fd_ifp;
@ -1119,15 +1118,29 @@ frdest_t *fdp;
goto bad;
}
/*
* Route packet.
*/
ro = &iproute;
memset(ro, 0, sizeof(*ro));
#if __NetBSD_Version__ < 499001100
dst = (struct sockaddr_in *)&ro->ro_dst;
dst->sin_family = AF_INET;
dst->sin_addr = ip->ip_dst;
if ((fdp != NULL) && (fdp->fd_ip.s_addr != 0))
dst->sin_addr = fdp->fd_ip;
dst->sin_len = sizeof(*dst);
#if __NetBSD_Version__ >= 499001100
rtcache_init(ro);
#else
rtalloc(ro);
#endif
#else /* __NetBSD_Version__ < 499001100 */
if ((fdp != NULL) && (fdp->fd_ip.s_addr != 0))
sockaddr_in_init(&u.dst4, &fdp->fd_ip, 0);
else
sockaddr_in_init(&u.dst4, &ip->ip_dst, 0);
dst = &u.dst;
rtcache_setdst(ro, dst);
rtcache_init(ro);
#endif /* __NetBSD_Version__ < 499001100 */
if ((ifp == NULL) && (ro->ro_rt != NULL))
ifp = ro->ro_rt->rt_ifp;
@ -1141,8 +1154,13 @@ frdest_t *fdp;
error = ENETUNREACH;
goto bad;
}
#if __NetBSD_Version__ < 499001100
if (ro->ro_rt->rt_flags & RTF_GATEWAY)
dst = (struct sockaddr_in *)ro->ro_rt->rt_gateway;
#else /* __NetBSD_Version__ < 499001100 */
if (ro->ro_rt->rt_flags & RTF_GATEWAY)
dst = ro->ro_rt->rt_gateway;
#endif /* __NetBSD_Version__ < 499001100 */
if (ro->ro_rt)
ro->ro_rt->rt_use++;
@ -1208,8 +1226,12 @@ frdest_t *fdp;
if (!ip->ip_sum)
ip->ip_sum = in_cksum(m, hlen);
# endif /* M_CSUM_IPv4 */
#if __NetBSD_Version__ < 499001100
error = (*ifp->if_output)(ifp, m, (struct sockaddr *)dst,
ro->ro_rt);
#else /* __NetBSD_Version__ < 499001100 */
error = (*ifp->if_output)(ifp, m, dst, ro->ro_rt);
#endif /* __NetBSD_Version__ < 499001100 */
if (i) {
ip->ip_len = ntohs(ip->ip_len);
ip->ip_off = ntohs(ip->ip_off);
@ -1299,11 +1321,18 @@ sendorfree:
for (m = m0; m; m = m0) {
m0 = m->m_act;
m->m_act = 0;
#if __NetBSD_Version__ < 499001100
if (error == 0)
error = (*ifp->if_output)(ifp, m,
(struct sockaddr *)dst, ro->ro_rt);
else
FREE_MB_T(m);
#else /* __NetBSD_Version__ < 499001100 */
if (error == 0)
error = (*ifp->if_output)(ifp, m, dst, ro->ro_rt);
else
FREE_MB_T(m);
#endif /* __NetBSD_Version__ < 499001100 */
}
}
done:
@ -1348,9 +1377,19 @@ struct mbuf *m0, **mpp;
fr_info_t *fin;
frdest_t *fdp;
{
#if __NetBSD_Version__ < 499001100
struct route_in6 ip6route;
struct sockaddr_in6 *dst6;
struct route_in6 *ro;
#else /* __NetBSD_Version__ < 499001100 */
struct route ip6route;
const struct sockaddr *dst;
union {
struct sockaddr dst;
struct sockaddr_in6 dst6;
} u;
struct route *ro;
#endif /* __NetBSD_Version__ < 499001100 */
struct rtentry *rt;
struct ifnet *ifp;
frentry_t *fr;
@ -1360,27 +1399,33 @@ frdest_t *fdp;
error = 0;
ro = &ip6route;
fr = fin->fin_fr;
bzero((void *)ro, sizeof(*ro));
dst6 = (struct sockaddr_in6 *)&ro->ro_dst;
dst6->sin6_family = AF_INET6;
dst6->sin6_len = sizeof(struct sockaddr_in6);
dst6->sin6_addr = fin->fin_fi.fi_dst.in6;
if (fdp != NULL)
ifp = fdp->fd_ifp;
else
ifp = fin->fin_ifp;
bzero((void *)ro, sizeof(*ro));
#if __NetBSD_Version__ < 499001100
dst6 = (struct sockaddr_in6 *)&ro->ro_dst;
dst6->sin6_family = AF_INET6;
dst6->sin6_len = sizeof(struct sockaddr_in6);
dst6->sin6_addr = fin->fin_fi.fi_dst.in6;
if (fdp != NULL) {
if (IP6_NOTZERO(&fdp->fd_ip6))
dst6->sin6_addr = fdp->fd_ip6.in6;
}
#if __NetBSD_Version__ >= 499001100
rtcache_init((struct route *)ro);
#else
rtalloc((struct route *)ro);
#endif
#else /* __NetBSD_Version__ < 499001100 */
if (fdp != NULL && IP6_NOTZERO(&fdp->fd_ip6))
sockaddr_in6_init(&u.dst6, &fdp->fd_ip6.in6, 0, 0, 0);
else
sockaddr_in6_init(&u.dst6, &fin->fin_fi.fi_dst.in6, 0, 0, 0);
dst = &u.dst;
rtcache_setdst(ro, dst);
rtcache_init(ro);
#endif /* __NetBSD_Version__ < 499001100 */
if ((ifp == NULL) && (ro->ro_rt != NULL))
ifp = ro->ro_rt->rt_ifp;
@ -1393,8 +1438,13 @@ frdest_t *fdp;
rt = fdp ? NULL : ro->ro_rt;
/* KAME */
#if __NetBSD_Version__ < 499001100
if (IN6_IS_ADDR_LINKLOCAL(&dst6->sin6_addr))
dst6->sin6_addr.s6_addr16[1] = htons(ifp->if_index);
#else /* __NetBSD_Version__ < 499001100 */
if (IN6_IS_ADDR_LINKLOCAL(&u.dst6.sin6_addr))
u.dst6.sin6_addr.s6_addr16[1] = htons(ifp->if_index);
#endif /* __NetBSD_Version__ < 499001100 */
{
#if (__NetBSD_Version__ >= 106010000)
@ -1405,8 +1455,13 @@ frdest_t *fdp;
int frag;
# endif
#endif
#if __NetBSD_Version__ < 499001100
if (ro->ro_rt->rt_flags & RTF_GATEWAY)
dst6 = (struct sockaddr_in6 *)ro->ro_rt->rt_gateway;
#else /* __NetBSD_Version__ < 499001100 */
if (ro->ro_rt->rt_flags & RTF_GATEWAY)
dst = ro->ro_rt->rt_gateway;
#endif /* __NetBSD_Version__ < 499001100 */
ro->ro_rt->rt_use++;
/* Determine path MTU. */
@ -1422,14 +1477,18 @@ frdest_t *fdp;
#endif
if ((error == 0) && (m0->m_pkthdr.len <= mtu)) {
*mpp = NULL;
#if __NetBSD_Version__ < 499001100
error = nd6_output(ifp, ifp, m0, dst6, rt);
#else /* __NetBSD_Version__ < 499001100 */
error = nd6_output(ifp, ifp, m0, satocsin6(dst), rt);
#endif /* __NetBSD_Version__ < 499001100 */
} else {
error = EMSGSIZE;
}
}
bad:
#if __NetBSD_Version__ >= 499001100
rtcache_free((struct route *)ro);
rtcache_free(ro);
#else
RTFREE(((struct route *)ro)->ro_rt);
#endif
@ -1442,25 +1501,35 @@ int fr_verifysrc(fin)
fr_info_t *fin;
{
int rc;
#if __NetBSD_Version__ < 499001100
struct sockaddr_in *dst;
#else /* __NetBSD_Version__ < 499001100 */
union {
struct sockaddr dst;
struct sockaddr_in dst4;
} u;
#endif /* __NetBSD_Version__ < 499001100 */
struct route iproute;
bzero((char *)&iproute, sizeof(iproute));
memset(&iproute, 0, sizeof(iproute));
#if __NetBSD_Version__ >= 499001100
sockaddr_in_init(&u.dst4, &fin->fin_src, 0);
rtcache_setdst(&iproute, &u.dst);
rtcache_init(&iproute);
if (iproute.ro_rt == NULL)
rc = 0;
else
rc = (fin->fin_ifp == iproute.ro_rt->rt_ifp);
rtcache_free(&iproute);
#else
dst = (struct sockaddr_in *)&iproute.ro_dst;
dst->sin_len = sizeof(*dst);
dst->sin_family = AF_INET;
dst->sin_addr = fin->fin_src;
#if __NetBSD_Version__ >= 499001100
rtcache_init(&iproute);
#else
rtalloc(&iproute);
#endif
if (iproute.ro_rt == NULL)
return 0;
rc = (fin->fin_ifp == iproute.ro_rt->rt_ifp);
#if __NetBSD_Version__ >= 499001100
rtcache_free(&iproute);
#else
RTFREE(iproute.ro_rt);
#endif
return rc;

95
sys/dist/pf/net/pf.c vendored
View File

@ -1,4 +1,4 @@
/* $NetBSD: pf.c,v 1.36 2007/03/04 06:02:58 christos Exp $ */
/* $NetBSD: pf.c,v 1.37 2007/05/02 20:40:22 dyoung Exp $ */
/* $OpenBSD: pf.c,v 1.487 2005/04/22 09:53:18 dhartmei Exp $ */
/*
@ -2693,41 +2693,32 @@ pf_get_mss(struct mbuf *m, int off, u_int16_t th_off, sa_family_t af)
u_int16_t
pf_calc_mss(struct pf_addr *addr, sa_family_t af, u_int16_t offer)
{
struct route *rop = NULL;
#ifdef INET
struct sockaddr_in *dst;
union {
struct sockaddr dst;
struct sockaddr_in dst4;
struct sockaddr_in6 dst6;
} u;
struct route ro;
#endif /* INET */
#ifdef INET6
struct sockaddr_in6 *dst6;
struct route_in6 ro6;
#endif /* INET6 */
struct route *rop = &ro;
int hlen;
u_int16_t mss = tcp_mssdflt;
hlen = 0; /* XXXGCC - -Wunitialized m68k */
memset(&ro, 0, sizeof(ro));
switch (af) {
#ifdef INET
case AF_INET:
hlen = sizeof(struct ip);
bzero(&ro, sizeof(ro));
dst = (struct sockaddr_in *)&ro.ro_dst;
dst->sin_family = AF_INET;
dst->sin_len = sizeof(*dst);
dst->sin_addr = addr->v4;
rop = &ro;
sockaddr_in_init(&u.dst4, &addr->v4, 0);
rtcache_setdst(rop, &u.dst);
break;
#endif /* INET */
#ifdef INET6
case AF_INET6:
hlen = sizeof(struct ip6_hdr);
bzero(&ro6, sizeof(ro6));
dst6 = (struct sockaddr_in6 *)&ro6.ro_dst;
dst6->sin6_family = AF_INET6;
dst6->sin6_len = sizeof(*dst6);
dst6->sin6_addr = addr->v6;
rop = (struct route *)&ro6;
sockaddr_in6_init(&u.dst6, &addr->v6, 0, 0, 0);
rtcache_setdst(rop, &u.dst);
break;
#endif /* INET6 */
}
@ -5268,33 +5259,28 @@ pf_pull_hdr(struct mbuf *m, int off, void *p, int len,
int
pf_routable(struct pf_addr *addr, sa_family_t af)
{
struct sockaddr_in *dst;
#ifdef INET6
struct sockaddr_in6 *dst6;
struct route_in6 ro;
#else
struct route ro;
#endif
int rc = 0;
union {
struct sockaddr dst;
struct sockaddr_in dst4;
struct sockaddr_in6 dst6;
} u;
struct route ro;
bzero(&ro, sizeof(ro));
switch (af) {
case AF_INET:
dst = satosin(&ro.ro_dst);
dst->sin_family = AF_INET;
dst->sin_len = sizeof(*dst);
dst->sin_addr = addr->v4;
sockaddr_in_init(&u.dst4, &addr->v4, 0);
break;
#ifdef INET6
case AF_INET6:
dst6 = (struct sockaddr_in6 *)&ro.ro_dst;
dst6->sin6_family = AF_INET6;
dst6->sin6_len = sizeof(*dst6);
dst6->sin6_addr = addr->v6;
sockaddr_in6_init(&u.dst6, &addr->v6, 0, 0, 0);
break;
#endif /* INET6 */
default:
return (0);
}
rtcache_setdst(&ro, &u.dst);
#ifdef __OpenBSD__
rtalloc_noclone((struct route *)&ro, NO_CLONING);
@ -5303,14 +5289,12 @@ pf_routable(struct pf_addr *addr, sa_family_t af)
return (1);
}
#else
rtcache_init((struct route *)&ro);
if (ro.ro_rt != NULL) {
rtcache_free((struct route *)&ro);
return (1);
}
rtcache_init(&ro);
rc = (ro.ro_rt != NULL) ? 1 : 0;
rtcache_free(&ro);
#endif
return (0);
return rc;
}
int
@ -5378,7 +5362,11 @@ pf_route(struct mbuf **m, struct pf_rule *r, int dir, struct ifnet *oifp,
struct m_tag *mtag;
struct route iproute;
struct route *ro = NULL;
struct sockaddr_in *dst;
const struct sockaddr *dst;
union {
struct sockaddr dst;
struct sockaddr_in dst4;
} u;
struct ip *ip;
struct ifnet *ifp = NULL;
struct pf_addr naddr;
@ -5425,11 +5413,10 @@ pf_route(struct mbuf **m, struct pf_rule *r, int dir, struct ifnet *oifp,
ip = mtod(m0, struct ip *);
ro = &iproute;
bzero((void *)ro, sizeof(*ro));
dst = satosin(&ro->ro_dst);
dst->sin_family = AF_INET;
dst->sin_len = sizeof(*dst);
dst->sin_addr = ip->ip_dst;
memset(ro, 0, sizeof(*ro));
sockaddr_in_init(&u.dst4, &ip->ip_dst, 0);
dst = &u.dst;
rtcache_setdst(ro, dst);
if (r->rt == PF_FASTROUTE) {
rtcache_init(ro);
@ -5442,7 +5429,7 @@ pf_route(struct mbuf **m, struct pf_rule *r, int dir, struct ifnet *oifp,
ro->ro_rt->rt_use++;
if (ro->ro_rt->rt_flags & RTF_GATEWAY)
dst = satosin(ro->ro_rt->rt_gateway);
dst = ro->ro_rt->rt_gateway;
} else {
if (TAILQ_EMPTY(&r->rpool.list)) {
DPFPRINTF(PF_DEBUG_URGENT,
@ -5454,13 +5441,12 @@ pf_route(struct mbuf **m, struct pf_rule *r, int dir, struct ifnet *oifp,
(const struct pf_addr *)&ip->ip_src,
&naddr, NULL, &sn);
if (!PF_AZERO(&naddr, AF_INET))
dst->sin_addr.s_addr = naddr.v4.s_addr;
u.dst4.sin_addr.s_addr = naddr.v4.s_addr;
ifp = r->rpool.cur->kif ?
r->rpool.cur->kif->pfik_ifp : NULL;
} else {
if (!PF_AZERO(&s->rt_addr, AF_INET))
dst->sin_addr.s_addr =
s->rt_addr.v4.s_addr;
u.dst4.sin_addr.s_addr = s->rt_addr.v4.s_addr;
ifp = s->rt_kif ? s->rt_kif->pfik_ifp : NULL;
}
}
@ -5539,7 +5525,7 @@ pf_route(struct mbuf **m, struct pf_rule *r, int dir, struct ifnet *oifp,
else if (m0->m_pkthdr.csum & M_UDPV4_CSUM_OUT)
udpstat.udps_outhwcsum++;
#endif
error = (*ifp->if_output)(ifp, m0, sintosa(dst), NULL);
error = (*ifp->if_output)(ifp, m0, dst, NULL);
goto done;
}
@ -5568,8 +5554,7 @@ pf_route(struct mbuf **m, struct pf_rule *r, int dir, struct ifnet *oifp,
m1 = m0->m_nextpkt;
m0->m_nextpkt = 0;
if (error == 0)
error = (*ifp->if_output)(ifp, m0, sintosa(dst),
NULL);
error = (*ifp->if_output)(ifp, m0, dst, NULL);
else
m_freem(m0);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: uipc_domain.c,v 1.63 2007/02/17 22:34:07 dyoung Exp $ */
/* $NetBSD: uipc_domain.c,v 1.64 2007/05/02 20:40:23 dyoung Exp $ */
/*
* Copyright (c) 1982, 1986, 1993
@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: uipc_domain.c,v 1.63 2007/02/17 22:34:07 dyoung Exp $");
__KERNEL_RCSID(0, "$NetBSD: uipc_domain.c,v 1.64 2007/05/02 20:40:23 dyoung Exp $");
#include <sys/param.h>
#include <sys/socket.h>
@ -56,6 +56,7 @@ void pffasttimo(void *);
void pfslowtimo(void *);
struct domainhead domains = STAILQ_HEAD_INITIALIZER(domains);
static struct domain *domain_array[AF_MAX];
struct callout pffasttimo_ch, pfslowtimo_ch;
@ -100,6 +101,8 @@ domain_attach(struct domain *dp)
const struct protosw *pr;
STAILQ_INSERT_TAIL(&domains, dp, dom_link);
if (dp->dom_family < __arraycount(domain_array))
domain_array[dp->dom_family] = dp;
if (dp->dom_init)
(*dp->dom_init)();
@ -127,6 +130,9 @@ pffinddomain(int family)
{
struct domain *dp;
if (family < __arraycount(domain_array) && domain_array[family] != NULL)
return domain_array[family];
DOMAIN_FOREACH(dp)
if (dp->dom_family == family)
return (dp);
@ -175,6 +181,74 @@ pffindproto(int family, int protocol, int type)
return (maybe);
}
struct sockaddr *
sockaddr_alloc(sa_family_t af, int flags)
{
const struct domain *dom;
struct sockaddr *sa;
if ((dom = pffinddomain(af)) == NULL)
return NULL;
if ((sa = pool_get(dom->dom_sa_pool, flags)) == NULL)
return NULL;
sa->sa_family = af;
sa->sa_len = dom->dom_sa_len;
return sa;
}
struct sockaddr *
sockaddr_copy(struct sockaddr *dst, const struct sockaddr *src)
{
KASSERT(dst->sa_family == src->sa_family);
memcpy(dst, src, src->sa_len);
return dst;
}
int
sockaddr_cmp(const struct sockaddr *sa1, const struct sockaddr *sa2)
{
int rc;
struct domain *dom;
if (sa1->sa_family != sa2->sa_family)
return sa1->sa_family - sa2->sa_family;
if ((dom = pffinddomain(sa1->sa_family)) != NULL &&
dom->dom_sockaddr_cmp != NULL)
return (*dom->dom_sockaddr_cmp)(sa1, sa2);
if ((rc = memcmp(sa1, sa2, MIN(sa1->sa_len, sa2->sa_len))) != 0)
return rc;
return sa1->sa_len - sa2->sa_len;
}
struct sockaddr *
sockaddr_dup(const struct sockaddr *src, int flags)
{
struct sockaddr *dst;
if ((dst = sockaddr_alloc(src->sa_family, flags)) == NULL)
return NULL;
KASSERT(dst->sa_len >= src->sa_len);
return sockaddr_copy(dst, src);
}
void
sockaddr_free(struct sockaddr *sa)
{
const struct domain *dom;
if ((dom = pffinddomain(sa->sa_family)) == NULL)
panic("%s: no such domain %d\n", __func__, sa->sa_family);
pool_put(dom->dom_sa_pool, sa);
}
/*
* sysctl helper to stuff PF_LOCAL pcbs into sysctl structures
*/

View File

@ -1,4 +1,4 @@
/* $NetBSD: uipc_socket.c,v 1.139 2007/04/15 05:25:48 yamt Exp $ */
/* $NetBSD: uipc_socket.c,v 1.140 2007/05/02 20:40:23 dyoung Exp $ */
/*-
* Copyright (c) 2002, 2007 The NetBSD Foundation, Inc.
@ -68,7 +68,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.139 2007/04/15 05:25:48 yamt Exp $");
__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.140 2007/05/02 20:40:23 dyoung Exp $");
#include "opt_sock_counters.h"
#include "opt_sosend_loan.h"
@ -461,29 +461,29 @@ socreate(int dom, struct socket **aso, int type, int proto, struct lwp *l)
error = kauth_authorize_network(l->l_cred, KAUTH_NETWORK_SOCKET,
KAUTH_REQ_NETWORK_SOCKET_OPEN, KAUTH_ARG(dom), KAUTH_ARG(type),
KAUTH_ARG(proto));
if (error)
return (error);
if (error != 0)
return error;
if (proto)
prp = pffindproto(dom, proto, type);
else
prp = pffindtype(dom, type);
if (prp == 0) {
if (prp == NULL) {
/* no support for domain */
if (pffinddomain(dom) == 0)
return (EAFNOSUPPORT);
return EAFNOSUPPORT;
/* no support for socket type */
if (proto == 0 && type != 0)
return (EPROTOTYPE);
return (EPROTONOSUPPORT);
return EPROTOTYPE;
return EPROTONOSUPPORT;
}
if (prp->pr_usrreq == 0)
return (EPROTONOSUPPORT);
if (prp->pr_usrreq == NULL)
return EPROTONOSUPPORT;
if (prp->pr_type != type)
return (EPROTOTYPE);
return EPROTOTYPE;
s = splsoftnet();
so = pool_get(&socket_pool, PR_WAITOK);
memset((void *)so, 0, sizeof(*so));
memset(so, 0, sizeof(*so));
TAILQ_INIT(&so->so_q0);
TAILQ_INIT(&so->so_q);
so->so_type = type;
@ -497,17 +497,17 @@ socreate(int dom, struct socket **aso, int type, int proto, struct lwp *l)
#endif
uid = kauth_cred_geteuid(l->l_cred);
so->so_uidinfo = uid_find(uid);
error = (*prp->pr_usrreq)(so, PRU_ATTACH, (struct mbuf *)0,
(struct mbuf *)(long)proto, (struct mbuf *)0, l);
if (error) {
error = (*prp->pr_usrreq)(so, PRU_ATTACH, NULL,
(struct mbuf *)(long)proto, NULL, l);
if (error != 0) {
so->so_state |= SS_NOFDREF;
sofree(so);
splx(s);
return (error);
return error;
}
splx(s);
*aso = so;
return (0);
return 0;
}
int
@ -516,10 +516,9 @@ sobind(struct socket *so, struct mbuf *nam, struct lwp *l)
int s, error;
s = splsoftnet();
error = (*so->so_proto->pr_usrreq)(so, PRU_BIND, (struct mbuf *)0,
nam, (struct mbuf *)0, l);
error = (*so->so_proto->pr_usrreq)(so, PRU_BIND, NULL, nam, NULL, l);
splx(s);
return (error);
return error;
}
int
@ -528,11 +527,11 @@ solisten(struct socket *so, int backlog)
int s, error;
s = splsoftnet();
error = (*so->so_proto->pr_usrreq)(so, PRU_LISTEN, (struct mbuf *)0,
(struct mbuf *)0, (struct mbuf *)0, (struct lwp *)0);
if (error) {
error = (*so->so_proto->pr_usrreq)(so, PRU_LISTEN, NULL,
NULL, NULL, NULL);
if (error != 0) {
splx(s);
return (error);
return error;
}
if (TAILQ_EMPTY(&so->so_q))
so->so_options |= SO_ACCEPTCONN;
@ -540,7 +539,7 @@ solisten(struct socket *so, int backlog)
backlog = 0;
so->so_qlimit = min(backlog, somaxconn);
splx(s);
return (0);
return 0;
}
void
@ -616,8 +615,7 @@ soclose(struct socket *so)
drop:
if (so->so_pcb) {
int error2 = (*so->so_proto->pr_usrreq)(so, PRU_DETACH,
(struct mbuf *)0, (struct mbuf *)0, (struct mbuf *)0,
(struct lwp *)0);
NULL, NULL, NULL, NULL);
if (error == 0)
error = error2;
}
@ -639,8 +637,8 @@ soabort(struct socket *so)
int error;
KASSERT(so->so_head == NULL);
error = (*so->so_proto->pr_usrreq)(so, PRU_ABORT, (struct mbuf *)0,
(struct mbuf *)0, (struct mbuf *)0, (struct lwp *)0);
error = (*so->so_proto->pr_usrreq)(so, PRU_ABORT, NULL,
NULL, NULL, NULL);
if (error) {
sofree(so);
}
@ -660,7 +658,7 @@ soaccept(struct socket *so, struct mbuf *nam)
if ((so->so_state & SS_ISDISCONNECTED) == 0 ||
(so->so_proto->pr_flags & PR_ABRTACPTDIS) == 0)
error = (*so->so_proto->pr_usrreq)(so, PRU_ACCEPT,
(struct mbuf *)0, nam, (struct mbuf *)0, (struct lwp *)0);
NULL, nam, NULL, NULL);
else
error = ECONNABORTED;
@ -688,7 +686,7 @@ soconnect(struct socket *so, struct mbuf *nam, struct lwp *l)
error = EISCONN;
else
error = (*so->so_proto->pr_usrreq)(so, PRU_CONNECT,
(struct mbuf *)0, nam, (struct mbuf *)0, l);
NULL, nam, NULL, l);
splx(s);
return (error);
}
@ -700,8 +698,7 @@ soconnect2(struct socket *so1, struct socket *so2)
s = splsoftnet();
error = (*so1->so_proto->pr_usrreq)(so1, PRU_CONNECT2,
(struct mbuf *)0, (struct mbuf *)so2, (struct mbuf *)0,
(struct lwp *)0);
NULL, (struct mbuf *)so2, NULL, NULL);
splx(s);
return (error);
}
@ -721,8 +718,7 @@ sodisconnect(struct socket *so)
goto bad;
}
error = (*so->so_proto->pr_usrreq)(so, PRU_DISCONNECT,
(struct mbuf *)0, (struct mbuf *)0, (struct mbuf *)0,
(struct lwp *)0);
NULL, NULL, NULL, NULL);
bad:
splx(s);
sodopendfree();
@ -839,7 +835,7 @@ sosend(struct socket *so, struct mbuf *addr, struct uio *uio, struct mbuf *top,
m = m_gethdr(M_WAIT, MT_DATA);
mlen = MHLEN;
m->m_pkthdr.len = 0;
m->m_pkthdr.rcvif = (struct ifnet *)0;
m->m_pkthdr.rcvif = NULL;
} else {
m = m_get(M_WAIT, MT_DATA);
mlen = MLEN;
@ -980,8 +976,7 @@ soreceive(struct socket *so, struct mbuf **paddr, struct uio *uio,
if (flags & MSG_OOB) {
m = m_get(M_WAIT, MT_DATA);
error = (*pr->pr_usrreq)(so, PRU_RCVOOB, m,
(struct mbuf *)(long)(flags & MSG_PEEK),
(struct mbuf *)0, l);
(struct mbuf *)(long)(flags & MSG_PEEK), NULL, l);
if (error)
goto bad;
do {
@ -995,10 +990,9 @@ soreceive(struct socket *so, struct mbuf **paddr, struct uio *uio,
return (error);
}
if (mp)
*mp = (struct mbuf *)0;
*mp = NULL;
if (so->so_state & SS_ISCONFIRMING && uio->uio_resid)
(*pr->pr_usrreq)(so, PRU_RCVD, (struct mbuf *)0,
(struct mbuf *)0, (struct mbuf *)0, l);
(*pr->pr_usrreq)(so, PRU_RCVD, NULL, NULL, NULL, l);
restart:
if ((error = sblock(&so->so_rcv, SBLOCKWAIT(flags))) != 0)
@ -1234,7 +1228,7 @@ soreceive(struct socket *so, struct mbuf **paddr, struct uio *uio,
*mp = m;
mp = &m->m_next;
so->so_rcv.sb_mb = m = m->m_next;
*mp = (struct mbuf *)0;
*mp = NULL;
} else {
MFREE(m, so->so_rcv.sb_mb);
m = so->so_rcv.sb_mb;
@ -1305,9 +1299,7 @@ soreceive(struct socket *so, struct mbuf **paddr, struct uio *uio,
*/
if ((pr->pr_flags & PR_WANTRCVD) && so->so_pcb)
(*pr->pr_usrreq)(so, PRU_RCVD,
(struct mbuf *)0,
(struct mbuf *)(long)flags,
(struct mbuf *)0, l);
NULL, (struct mbuf *)(long)flags, NULL, l);
SBLASTRECORDCHK(&so->so_rcv, "soreceive sbwait 2");
SBLASTMBUFCHK(&so->so_rcv, "soreceive sbwait 2");
error = sbwait(&so->so_rcv);
@ -1343,8 +1335,8 @@ soreceive(struct socket *so, struct mbuf **paddr, struct uio *uio,
SBLASTRECORDCHK(&so->so_rcv, "soreceive 4");
SBLASTMBUFCHK(&so->so_rcv, "soreceive 4");
if (pr->pr_flags & PR_WANTRCVD && so->so_pcb)
(*pr->pr_usrreq)(so, PRU_RCVD, (struct mbuf *)0,
(struct mbuf *)(long)flags, (struct mbuf *)0, l);
(*pr->pr_usrreq)(so, PRU_RCVD, NULL,
(struct mbuf *)(long)flags, NULL, l);
}
if (orig_resid == uio->uio_resid && orig_resid &&
(flags & MSG_EOR) == 0 && (so->so_state & SS_CANTRCVMORE) == 0) {
@ -1373,8 +1365,8 @@ soshutdown(struct socket *so, int how)
if (how == SHUT_RD || how == SHUT_RDWR)
sorflush(so);
if (how == SHUT_WR || how == SHUT_RDWR)
return (*pr->pr_usrreq)(so, PRU_SHUTDOWN, (struct mbuf *)0,
(struct mbuf *)0, (struct mbuf *)0, (struct lwp *)0);
return (*pr->pr_usrreq)(so, PRU_SHUTDOWN, NULL,
NULL, NULL, NULL);
return (0);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_etherip.h,v 1.2 2006/12/15 21:18:52 joerg Exp $ */
/* $NetBSD: if_etherip.h,v 1.3 2007/05/02 20:40:23 dyoung Exp $ */
/*
* Copyright (c) 2006, Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
@ -51,9 +51,6 @@ struct etherip_softc {
union {
#ifdef INET
struct route scr_ro; /* cached inet route */
#endif
#ifdef INET6
struct route_in6 scr_ro6; /* cached inet6 route */
#endif
} sc_scr;
#ifdef __HAVE_GENERIC_SOFT_INTERRUPTS
@ -62,7 +59,6 @@ struct etherip_softc {
LIST_ENTRY(etherip_softc) etherip_list; /* list of etherip tunnels */
};
#define sc_ro sc_scr.scr_ro
#define sc_ro6 sc_scr.scr_ro6
struct etherip_header {
u_int8_t eip_ver; /* version/reserved */

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_gif.h,v 1.16 2007/03/04 06:03:16 christos Exp $ */
/* $NetBSD: if_gif.h,v 1.17 2007/05/02 20:40:23 dyoung Exp $ */
/* $KAME: if_gif.h,v 1.23 2001/07/27 09:21:42 itojun Exp $ */
/*
@ -54,9 +54,6 @@ struct gif_softc {
struct sockaddr *gif_pdst; /* Physical dst addr */
union {
struct route gifscr_ro; /* xxx */
#ifdef INET6
struct route_in6 gifscr_ro6; /* xxx */
#endif
} gifsc_gifscr;
int gif_flags;
const struct encaptab *encap_cookie4;
@ -69,9 +66,6 @@ struct gif_softc {
#define GIF_ROUTE_TTL 10
#define gif_ro gifsc_gifscr.gifscr_ro
#ifdef INET6
#define gif_ro6 gifsc_gifscr.gifscr_ro6
#endif
#define GIF_MTU (1280) /* Default MTU */
#define GIF_MTU_MIN (1280) /* Minimum MTU */

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_gre.c,v 1.91 2007/04/14 22:41:42 dyoung Exp $ */
/* $NetBSD: if_gre.c,v 1.92 2007/05/02 20:40:23 dyoung Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -48,7 +48,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_gre.c,v 1.91 2007/04/14 22:41:42 dyoung Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_gre.c,v 1.92 2007/05/02 20:40:23 dyoung Exp $");
#include "opt_gre.h"
#include "opt_inet.h"
@ -787,11 +787,10 @@ gre_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
goto end;
}
if (sc->route.ro_rt->rt_ifp->if_softc == sc) {
rtcache_free(&sc->route);
rtcache_clear(&sc->route);
m_freem(m);
} else
error = ip_output(m, NULL, &sc->route, 0,
(struct ip_moptions *)NULL, (struct socket *)NULL);
error = ip_output(m, NULL, &sc->route, 0, NULL, NULL);
end:
if (error)
ifp->if_oerrors++;
@ -1148,19 +1147,22 @@ static int
gre_compute_route(struct gre_softc *sc)
{
struct route *ro;
union {
struct sockaddr dst;
struct sockaddr_in dst4;
} u;
ro = &sc->route;
memset(ro, 0, sizeof(struct route));
satosin(&ro->ro_dst)->sin_addr = sc->g_dst;
ro->ro_dst.sa_family = AF_INET;
ro->ro_dst.sa_len = sizeof(ro->ro_dst);
memset(ro, 0, sizeof(*ro));
sockaddr_in_init(&u.dst4, &sc->g_dst, 0);
rtcache_setdst(ro, &u.dst);
rtcache_init(ro);
if (ro->ro_rt == NULL || ro->ro_rt->rt_ifp->if_softc == sc) {
GRE_DPRINTF(sc, "%s: route to %s %s\n", sc->sc_if.if_xname,
inet_ntoa(satocsin(rtcache_getdst(ro))->sin_addr),
inet_ntoa(u.dst4.sin_addr),
(ro->ro_rt == NULL)
? "does not exist"
: "loops back to ourself");

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_stf.c,v 1.59 2007/03/29 16:51:21 ad Exp $ */
/* $NetBSD: if_stf.c,v 1.60 2007/05/02 20:40:23 dyoung Exp $ */
/* $KAME: if_stf.c,v 1.62 2001/06/07 22:32:16 itojun Exp $ */
/*
@ -75,7 +75,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_stf.c,v 1.59 2007/03/29 16:51:21 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_stf.c,v 1.60 2007/05/02 20:40:23 dyoung Exp $");
#include "opt_inet.h"
@ -135,11 +135,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_stf.c,v 1.59 2007/03/29 16:51:21 ad Exp $");
struct stf_softc {
struct ifnet sc_if; /* common area */
union {
struct route __sc_ro4;
struct route_in6 __sc_ro6; /* just for safety */
} __sc_ro46;
#define sc_ro __sc_ro46.__sc_ro4
struct route sc_ro;
const struct encaptab *encap_cookie;
LIST_ENTRY(stf_softc) sc_list;
};
@ -239,6 +235,7 @@ stf_clone_destroy(struct ifnet *ifp)
bpfdetach(ifp);
#endif
if_detach(ifp);
rtcache_free(&sc->sc_ro);
free(sc, M_DEVBUF);
return (0);
@ -338,11 +335,14 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
struct stf_softc *sc;
const struct sockaddr_in6 *dst6;
const struct in_addr *in4;
struct sockaddr_in *dst4;
u_int8_t tos;
struct ip *ip;
struct ip6_hdr *ip6;
struct in6_ifaddr *ia6;
union {
struct sockaddr dst;
struct sockaddr_in dst4;
} u;
sc = (struct stf_softc*)ifp;
dst6 = (const struct sockaddr_in6 *)dst;
@ -416,22 +416,11 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
else
ip_ecn_ingress(ECN_NOCARE, &ip->ip_tos, &tos);
dst4 = (struct sockaddr_in *)&sc->sc_ro.ro_dst;
if (dst4->sin_family != AF_INET ||
bcmp(&dst4->sin_addr, &ip->ip_dst, sizeof(ip->ip_dst)) != 0)
rtcache_free(&sc->sc_ro);
else
rtcache_check(&sc->sc_ro);
if (sc->sc_ro.ro_rt == NULL) {
dst4->sin_family = AF_INET;
dst4->sin_len = sizeof(struct sockaddr_in);
bcopy(&ip->ip_dst, &dst4->sin_addr, sizeof(dst4->sin_addr));
rtcache_init(&sc->sc_ro);
if (sc->sc_ro.ro_rt == NULL) {
m_freem(m);
ifp->if_oerrors++;
return ENETUNREACH;
}
sockaddr_in_init(&u.dst4, &ip->ip_dst, 0);
if (rtcache_lookup(&sc->sc_ro, &u.dst) == NULL) {
m_freem(m);
ifp->if_oerrors++;
return ENETUNREACH;
}
/* If the route constitutes infinite encapsulation, punt. */
@ -443,8 +432,7 @@ stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
}
ifp->if_opackets++;
return ip_output(m, NULL, &sc->sc_ro, 0,
(struct ip_moptions *)NULL, (struct socket *)NULL);
return ip_output(m, NULL, &sc->sc_ro, 0, NULL, NULL);
}
static int

View File

@ -1,4 +1,4 @@
/* $NetBSD: route.c,v 1.89 2007/04/22 13:05:21 xtraeme Exp $ */
/* $NetBSD: route.c,v 1.90 2007/05/02 20:40:23 dyoung Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -97,10 +97,13 @@
* @(#)route.c 8.3 (Berkeley) 1/9/95
*/
#include "opt_route.h"
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.89 2007/04/22 13:05:21 xtraeme Exp $");
__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.90 2007/05/02 20:40:23 dyoung Exp $");
#include <sys/param.h>
#include <sys/sysctl.h>
#include <sys/systm.h>
#include <sys/callout.h>
#include <sys/proc.h>
@ -120,6 +123,11 @@ __KERNEL_RCSID(0, "$NetBSD: route.c,v 1.89 2007/04/22 13:05:21 xtraeme Exp $");
#include <netinet/in.h>
#include <netinet/in_var.h>
#ifdef RTFLUSH_DEBUG
#define rtcache_debug() __predict_false(_rtcache_debug)
#else /* RTFLUSH_DEBUG */
#define rtcache_debug() 0
#endif /* RTFLUSH_DEBUG */
struct route_cb route_cb;
struct rtstat rtstat;
@ -135,10 +143,36 @@ POOL_INIT(rttimer_pool, sizeof(struct rttimer), 0, 0, 0, "rttmrpl", NULL,
struct callout rt_timer_ch; /* callout for rt_timer_timer() */
#ifdef RTFLUSH_DEBUG
static int _rtcache_debug = 0;
#endif /* RTFLUSH_DEBUG */
static int rtdeletemsg(struct rtentry *);
static int rtflushclone1(struct radix_node *, void *);
static void rtflushclone(struct radix_node_head *, struct rtentry *);
#ifdef RTFLUSH_DEBUG
SYSCTL_SETUP(sysctl_net_rtcache_setup, "sysctl net.rtcache.debug setup")
{
const struct sysctlnode *rnode;
/* XXX do not duplicate */
if (sysctl_createv(clog, 0, NULL, &rnode, CTLFLAG_PERMANENT,
CTLTYPE_NODE, "net", NULL, NULL, 0, NULL, 0, CTL_NET, CTL_EOL) != 0)
return;
if (sysctl_createv(clog, 0, &rnode, &rnode, CTLFLAG_PERMANENT,
CTLTYPE_NODE,
"rtcache", SYSCTL_DESCR("Route cache related settings"),
NULL, 0, NULL, 0, CTL_CREATE, CTL_EOL) != 0)
return;
if (sysctl_createv(clog, 0, &rnode, &rnode,
CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_INT,
"debug", SYSCTL_DESCR("Debug route caches"),
NULL, 0, &_rtcache_debug, 0, CTL_CREATE, CTL_EOL) != 0)
return;
}
#endif /* RTFLUSH_DEBUG */
struct ifaddr *
rt_get_ifa(struct rtentry *rt)
{
@ -203,37 +237,55 @@ route_init(void)
void
rtflushall(int family)
{
const struct domain *dom;
int s;
struct domain *dom;
struct route *ro;
if ((dom = pffinddomain(family)) != NULL && dom->dom_rtflushall != NULL)
(*dom->dom_rtflushall)();
if (rtcache_debug())
printf("%s: enter\n", __func__);
if ((dom = pffinddomain(family)) == NULL)
return;
s = splnet();
while ((ro = LIST_FIRST(&dom->dom_rtcache)) != NULL) {
KASSERT(ro->ro_rt != NULL);
rtcache_clear(ro);
}
splx(s);
}
void
rtflush(struct route *ro)
{
const struct domain *dom;
KASSERT(ro->ro_rt != NULL);
KASSERT(rtcache_getdst(ro) != NULL);
RTFREE(ro->ro_rt);
ro->ro_rt = NULL;
if ((dom = pffinddomain(rtcache_getdst(ro)->sa_family)) != NULL &&
dom->dom_rtflush != NULL)
(*dom->dom_rtflush)(ro);
LIST_REMOVE(ro, ro_rtcache_next);
#if 0
if (rtcache_debug()) {
printf("%s: flushing %s\n", __func__,
inet_ntoa((satocsin(rtcache_getdst(ro)))->sin_addr));
}
#endif
}
void
rtcache(struct route *ro)
{
const struct domain *dom;
struct domain *dom;
KASSERT(ro->ro_rt != NULL);
KASSERT(rtcache_getdst(ro) != NULL);
if ((dom = pffinddomain(rtcache_getdst(ro)->sa_family)) != NULL &&
dom->dom_rtcache != NULL)
(*dom->dom_rtcache)(ro);
if ((dom = pffinddomain(rtcache_getdst(ro)->sa_family)) == NULL)
return;
LIST_INSERT_HEAD(&dom->dom_rtcache, ro, ro_rtcache_next);
}
/*
@ -248,7 +300,8 @@ rtalloc(struct route *ro)
return;
rtflush(ro);
}
if ((ro->ro_rt = rtalloc1(rtcache_getdst(ro), 1)) == NULL)
if (rtcache_getdst(ro) == NULL ||
(ro->ro_rt = rtalloc1(rtcache_getdst(ro), 1)) == NULL)
return;
rtcache(ro);
}
@ -1109,6 +1162,8 @@ _rtcache_init(struct route *ro, int flag)
}
#endif
if (rtcache_getdst(ro) == NULL)
return;
ro->ro_rt = rtalloc1(rtcache_getdst(ro), flag);
if (ro->ro_rt != NULL) {
#ifdef RTCACHE_DEBUG
@ -1135,6 +1190,12 @@ rtcache_init_noclone_debug(const char *caller, struct route *ro)
_rtcache_init_debug(caller, ro, 0);
}
void
rtcache_update(struct route *ro, int clone)
{
rtcache_clear(ro);
_rtcache_init_debug(__func__, ro, clone);
}
#else
void
rtcache_init(struct route *ro)
@ -1147,16 +1208,24 @@ rtcache_init_noclone(struct route *ro)
{
_rtcache_init(ro, 0);
}
void
rtcache_update(struct route *ro, int clone)
{
rtcache_clear(ro);
_rtcache_init(ro, clone);
}
#endif
#ifdef RTCACHE_DEBUG
void
rtcache_copy_debug(const char *caller, struct route *new_ro, const struct route *old_ro, size_t new_len)
rtcache_copy_debug(const char *caller, struct route *new_ro, const struct route *old_ro)
#else
void
rtcache_copy(struct route *new_ro, const struct route *old_ro, size_t new_len)
rtcache_copy(struct route *new_ro, const struct route *old_ro)
#endif
{
/* XXX i doubt this DTRT any longer --dyoung */
#ifdef RTCACHE_DEBUG
size_t i;
@ -1166,15 +1235,9 @@ rtcache_copy(struct route *new_ro, const struct route *old_ro, size_t new_len)
}
#endif
memset(new_ro, 0, new_len);
#if 0
if (old_ro->ro_sa != NULL)
new_ro->ro_sa = sockaddr_dup(old_ro->ro_sa);
#else
if (old_ro->ro_dst.sa_len + offsetof(struct route, ro_dst) > new_len)
panic("rtcache_copy: dst address will overflow new route");
memcpy(&new_ro->ro_dst, &old_ro->ro_dst, old_ro->ro_dst.sa_len);
#endif
if (rtcache_getdst(old_ro) == NULL ||
rtcache_setdst(new_ro, rtcache_getdst(old_ro)) != 0)
return;
new_ro->ro_rt = old_ro->ro_rt;
if (new_ro->ro_rt != NULL) {
#ifdef RTCACHE_DEBUG
@ -1216,21 +1279,51 @@ rtcache_clear(struct route *ro)
ro->ro_rt = NULL;
}
struct rtentry *
rtcache_lookup1(struct route *ro, const struct sockaddr *dst, int clone)
{
const struct sockaddr *odst;
odst = rtcache_getdst(ro);
if (odst == NULL)
;
else if (sockaddr_cmp(odst, dst) != 0)
rtcache_free(ro);
else
rtcache_check1(ro, clone);
if (ro->ro_rt == NULL) {
rtcache_setdst(ro, dst);
_rtcache_init(ro, clone);
}
return ro->ro_rt;
}
void
rtcache_free(struct route *ro)
{
rtcache_clear(ro);
#if 0
if (ro->ro_sa != NULL) {
sockaddr_free(ro->ro_sa);
ro->ro_sa = NULL;
}
#endif
}
void
rtcache_update(struct route *ro)
int
rtcache_setdst(struct route *ro, const struct sockaddr *sa)
{
rtcache_clear(ro);
rtcache_init(ro);
KASSERT(sa != NULL);
if (ro->ro_sa != NULL && ro->ro_sa->sa_family == sa->sa_family) {
rtcache_clear(ro);
sockaddr_copy(ro->ro_sa, sa);
return 0;
} else if (ro->ro_sa != NULL)
rtcache_free(ro); /* free ro_sa, wrong family */
if ((ro->ro_sa = sockaddr_dup(sa, PR_NOWAIT)) == NULL)
return ENOMEM;
return 0;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: route.h,v 1.53 2007/04/22 13:05:21 xtraeme Exp $ */
/* $NetBSD: route.h,v 1.54 2007/05/02 20:40:23 dyoung Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@ -53,7 +53,7 @@
*/
struct route {
struct rtentry *ro_rt;
struct sockaddr ro_dst;
struct sockaddr *ro_sa;
LIST_ENTRY(route) ro_rtcache_next;
};
@ -330,47 +330,57 @@ struct rtentry *rtfindparent(struct radix_node_head *, struct route *);
#ifdef RTCACHE_DEBUG
#define rtcache_init(ro) rtcache_init_debug(__func__, ro)
#define rtcache_init_noclone(ro) rtcache_init_noclone_debug(__func__, ro)
#define rtcache_copy(ro, oro, len) rtcache_copy_debug(__func__, ro, oro, len)
#define rtcache_copy(ro, oro) rtcache_copy_debug(__func__, ro, oro)
void rtcache_init_debug(const char *, struct route *);
void rtcache_init_noclone_debug(const char *, struct route *);
void rtcache_copy_debug(const char *, struct route *, const struct route *, size_t);
void rtcache_copy_debug(const char *, struct route *, const struct route *);
#else
void rtcache_init(struct route *);
void rtcache_init_noclone(struct route *);
void rtcache_copy(struct route *, const struct route *, size_t);
void rtcache_copy(struct route *, const struct route *);
#endif
struct rtentry *rtcache_lookup1(struct route *, const struct sockaddr *, int);
void rtcache_clear(struct route *);
void rtcache_update(struct route *);
void rtcache_update(struct route *, int);
void rtcache_free(struct route *);
int rtcache_setdst(struct route *, const struct sockaddr *);
static inline struct rtentry *
rtcache_lookup_noclone(struct route *ro, const struct sockaddr *dst)
{
return rtcache_lookup1(ro, dst, 0);
}
static inline struct rtentry *
rtcache_lookup(struct route *ro, const struct sockaddr *dst)
{
return rtcache_lookup1(ro, dst, 1);
}
static inline const struct sockaddr *
rtcache_getdst(const struct route *ro)
{
return &ro->ro_dst;
return ro->ro_sa;
}
static inline void
rtcache_setdst(struct route *ro, struct sockaddr *sa)
{
#if 0
KASSERT(ro->ro_sa != sa);
rtcache_free(ro);
ro->ro_sa = sa;
#endif
}
static inline void
rtcache_check(struct route *ro)
rtcache_check1(struct route *ro, int clone)
{
/* XXX The rt_ifp check should be asserted. */
if (ro->ro_rt != NULL &&
((ro->ro_rt->rt_flags & RTF_UP) == 0 ||
ro->ro_rt->rt_ifp == NULL))
rtcache_update(ro);
rtcache_update(ro, clone);
KASSERT(ro->ro_rt == NULL || ro->ro_rt->rt_ifp != NULL);
}
static inline void
rtcache_check(struct route *ro)
{
return rtcache_check1(ro, 1);
}
static inline void
RTFREE(struct rtentry *rt)
{

View File

@ -1,4 +1,4 @@
/* $NetBSD: aarp.c,v 1.22 2007/02/17 22:34:10 dyoung Exp $ */
/* $NetBSD: aarp.c,v 1.23 2007/05/02 20:40:23 dyoung Exp $ */
/*
* Copyright (c) 1990,1991 Regents of The University of Michigan.
@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: aarp.c,v 1.22 2007/02/17 22:34:10 dyoung Exp $");
__KERNEL_RCSID(0, "$NetBSD: aarp.c,v 1.23 2007/05/02 20:40:23 dyoung Exp $");
#include "opt_mbuftrace.h"
@ -134,8 +134,7 @@ at_ifawithnet(sat, ifp)
struct sockaddr_at *sat2;
struct netrange *nr;
for (ifa = ifp->if_addrlist.tqh_first; ifa;
ifa = ifa->ifa_list.tqe_next) {
TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) {
if (ifa->ifa_addr->sa_family != AF_APPLETALK)
continue;
@ -329,6 +328,7 @@ at_aarpinput(ifp, m)
{
struct ether_aarp *ea;
struct at_ifaddr *aa;
struct ifaddr *ia;
struct aarptab *aat;
struct ether_header *eh;
struct llc *llc;
@ -364,13 +364,13 @@ at_aarpinput(ifp, m)
* Since we don't know the net, we just look for the first
* phase 1 address on the interface.
*/
for (aa = (struct at_ifaddr *) ifp->if_addrlist.tqh_first; aa;
aa = (struct at_ifaddr *) aa->aa_ifa.ifa_list.tqe_next) {
TAILQ_FOREACH(ia, &ifp->if_addrlist, ifa_list) {
aa = (struct at_ifaddr *)ia;
if (AA_SAT(aa)->sat_family == AF_APPLETALK &&
(aa->aa_flags & AFA_PHASE2) == 0)
break;
}
if (aa == NULL) {
if (ia == NULL) {
m_freem(m);
return;
}
@ -539,6 +539,7 @@ aarpprobe(arp)
struct mbuf *m;
struct ether_header *eh;
struct ether_aarp *ea;
struct ifaddr *ia;
struct at_ifaddr *aa;
struct llc *llc;
struct sockaddr sa;
@ -551,13 +552,13 @@ aarpprobe(arp)
* interface with the same address as we're looking for. If the
* net is phase 2, generate an 802.2 and SNAP header.
*/
for (aa = (struct at_ifaddr *) ifp->if_addrlist.tqh_first; aa;
aa = (struct at_ifaddr *) aa->aa_ifa.ifa_list.tqe_next) {
TAILQ_FOREACH(ia, &ifp->if_addrlist, ifa_list) {
aa = (struct at_ifaddr *)ia;
if (AA_SAT(aa)->sat_family == AF_APPLETALK &&
(aa->aa_flags & AFA_PROBING))
break;
}
if (aa == NULL) { /* serious error XXX */
if (ia == NULL) { /* serious error XXX */
printf("aarpprobe why did this happen?!\n");
return;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: at_proto.c,v 1.12 2007/02/18 23:06:11 matt Exp $ */
/* $NetBSD: at_proto.c,v 1.13 2007/05/02 20:40:23 dyoung Exp $ */
/*
* Copyright (c) 1990,1991 Regents of The University of Michigan.
@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: at_proto.c,v 1.12 2007/02/18 23:06:11 matt Exp $");
__KERNEL_RCSID(0, "$NetBSD: at_proto.c,v 1.13 2007/05/02 20:40:23 dyoung Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -62,6 +62,9 @@ const struct protosw atalksw[] = {
},
};
POOL_INIT(sockaddr_at_pool, sizeof(struct sockaddr_at), 0, 0, 0,
"sockaddr_at_pool", NULL, IPL_NET);
struct domain atalkdomain = {
.dom_family = PF_APPLETALK,
.dom_name = "appletalk",
@ -69,7 +72,7 @@ struct domain atalkdomain = {
.dom_externalize = NULL,
.dom_dispose = NULL,
.dom_protosw = atalksw,
.dom_protoswNPROTOSW = &atalksw[sizeof(atalksw)/sizeof(atalksw[0])],
.dom_protoswNPROTOSW = &atalksw[__arraycount(atalksw)],
.dom_rtattach = rn_inithead,
.dom_rtoffset = 32,
.dom_maxrtkey = sizeof(struct sockaddr_at),
@ -78,7 +81,29 @@ struct domain atalkdomain = {
.dom_ifqueues = { &atintrq1, &atintrq2 },
.dom_link = { NULL },
.dom_mowner = MOWNER_INIT("",""),
.dom_rtcache = NULL,
.dom_rtflush = NULL,
.dom_rtflushall = NULL
.dom_sa_pool = &sockaddr_at_pool,
.dom_sa_len = sizeof(struct sockaddr_at),
.dom_rtcache = LIST_HEAD_INITIALIZER(atalkdomain.dom_rtcache),
.dom_sockaddr_cmp = sockaddr_at_cmp
};
int
sockaddr_at_cmp(const struct sockaddr *sa1, const struct sockaddr *sa2)
{
int rc;
uint_fast8_t len;
const uint_fast8_t addrofs = offsetof(struct sockaddr_at, sat_addr),
addrend = addrofs + sizeof(struct at_addr);
const struct sockaddr_at *sat1, *sat2;
sat1 = satocsat(sa1);
sat2 = satocsat(sa2);
len = MIN(addrend, MIN(sat1->sat_len, sat2->sat_len));
if (len > addrofs &&
(rc = memcmp(&sat1->sat_addr, &sat2->sat_addr, len - addrofs)) != 0)
return rc;
return sat1->sat_len - sat2->sat_len;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: at_var.h,v 1.5 2007/02/17 22:34:10 dyoung Exp $ */
/* $NetBSD: at_var.h,v 1.6 2007/05/02 20:40:23 dyoung Exp $ */
/*
* Copyright (c) 1990,1991 Regents of The University of Michigan.
@ -67,6 +67,38 @@ struct at_aliasreq {
#define AFA_PHASE2 0x0004
#ifdef _KERNEL
int sockaddr_at_cmp(const struct sockaddr *, const struct sockaddr *);
static inline void
sockaddr_at_init1(struct sockaddr_at *sat, const struct at_addr *addr,
uint8_t port)
{
sat->sat_port = port;
sat->sat_addr = *addr;
memset(&sat->sat_range, 0, sizeof(sat->sat_range));
}
static inline void
sockaddr_at_init(struct sockaddr_at *sat, const struct at_addr *addr,
uint8_t port)
{
sat->sat_family = AF_APPLETALK;
sat->sat_len = sizeof(*sat);
sockaddr_at_init1(sat, addr, port);
}
static inline struct sockaddr *
sockaddr_at_alloc(const struct at_addr *addr, uint8_t port, int flags)
{
struct sockaddr *sa;
if ((sa = sockaddr_alloc(AF_APPLETALK, flags)) == NULL)
return NULL;
sockaddr_at_init1(satosat(sa), addr, port);
return sa;
}
TAILQ_HEAD(at_ifaddrhead, at_ifaddr);
extern struct at_ifaddrhead at_ifaddr;
extern struct ifqueue atintrq1, atintrq2;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ddp_input.c,v 1.14 2007/03/04 06:03:19 christos Exp $ */
/* $NetBSD: ddp_input.c,v 1.15 2007/05/02 20:40:23 dyoung Exp $ */
/*
* Copyright (c) 1990,1994 Regents of The University of Michigan.
@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ddp_input.c,v 1.14 2007/03/04 06:03:19 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: ddp_input.c,v 1.15 2007/05/02 20:40:23 dyoung Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -144,6 +144,10 @@ ddp_input(m, ifp, elh, phase)
struct ddpcb *ddp;
int dlen, mlen;
u_short cksum = 0;
union {
struct sockaddr dst;
struct sockaddr_at dsta;
} u;
bzero((void *) & from, sizeof(struct sockaddr_at));
if (elh) {
@ -267,27 +271,18 @@ ddp_input(m, ifp, elh, phase)
m_freem(m);
return;
}
if (satocsat(rtcache_getdst(&forwro))->sat_addr.s_net != to.sat_addr.s_net ||
satocsat(rtcache_getdst(&forwro))->sat_addr.s_node != to.sat_addr.s_node)
rtcache_free(&forwro);
else
rtcache_check(&forwro);
if (forwro.ro_rt == NULL) {
memset(&forwro.ro_dst, 0, sizeof(struct sockaddr_at));
forwro.ro_dst.sa_len = sizeof(struct sockaddr_at);
forwro.ro_dst.sa_family = AF_APPLETALK;
satosat(&forwro.ro_dst)->sat_addr.s_net =
to.sat_addr.s_net;
satosat(&forwro.ro_dst)->sat_addr.s_node =
to.sat_addr.s_node;
rtcache_init(&forwro);
}
sockaddr_at_init(&u.dsta, &to.sat_addr, 0);
(void)rtcache_lookup(&forwro, &u.dst);
#if 0 /* XXX The if-condition is always false. What was this
* actually trying to test?
*/
if (to.sat_addr.s_net !=
satocsat(rtcache_getdst(&forwro))->sat_addr.s_net &&
ddpe.deh_hops == DDP_MAXHOPS) {
m_freem(m);
return;
}
#endif
if (ddp_firewall &&
(forwro.ro_rt == NULL || forwro.ro_rt->rt_ifp != ifp)) {
m_freem(m);

View File

@ -1,4 +1,4 @@
/* $NetBSD: ddp_usrreq.c,v 1.24 2007/03/04 06:03:19 christos Exp $ */
/* $NetBSD: ddp_usrreq.c,v 1.25 2007/05/02 20:40:24 dyoung Exp $ */
/*
* Copyright (c) 1990,1991 Regents of The University of Michigan.
@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ddp_usrreq.c,v 1.24 2007/03/04 06:03:19 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: ddp_usrreq.c,v 1.25 2007/05/02 20:40:24 dyoung Exp $");
#include "opt_mbuftrace.h"
@ -37,6 +37,7 @@ __KERNEL_RCSID(0, "$NetBSD: ddp_usrreq.c,v 1.24 2007/03/04 06:03:19 christos Exp
#include <sys/proc.h>
#include <sys/mbuf.h>
#include <sys/ioctl.h>
#include <sys/queue.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/protosw.h>
@ -256,8 +257,7 @@ at_pcbsetaddr(ddp, addr, l)
if (sat->sat_addr.s_node != ATADDR_ANYNODE ||
sat->sat_addr.s_net != ATADDR_ANYNET) {
for (aa = at_ifaddr.tqh_first; aa;
aa = aa->aa_list.tqe_next) {
TAILQ_FOREACH(aa, &at_ifaddr, aa_list) {
if ((sat->sat_addr.s_net ==
AA_SAT(aa)->sat_addr.s_net) &&
(sat->sat_addr.s_node ==
@ -288,9 +288,9 @@ at_pcbsetaddr(ddp, addr, l)
if (sat->sat_addr.s_node == ATADDR_ANYNODE &&
sat->sat_addr.s_net == ATADDR_ANYNET) {
if (at_ifaddr.tqh_first == NULL)
return (EADDRNOTAVAIL);
sat->sat_addr = AA_SAT(at_ifaddr.tqh_first)->sat_addr;
if (TAILQ_EMPTY(&at_ifaddr))
return EADDRNOTAVAIL;
sat->sat_addr = AA_SAT(TAILQ_FIRST(&at_ifaddr))->sat_addr;
}
ddp->ddp_lsat = *sat;
@ -335,16 +335,17 @@ at_pcbconnect(ddp, addr, l)
struct mbuf *addr;
struct lwp *l;
{
const struct sockaddr_at *cdst;
struct sockaddr_at *sat = mtod(addr, struct sockaddr_at *);
struct route *ro;
struct at_ifaddr *aa = 0;
struct at_ifaddr *aa;
struct ifnet *ifp;
u_short hintnet = 0, net;
if (addr->m_len != sizeof(*sat))
return (EINVAL);
return EINVAL;
if (sat->sat_family != AF_APPLETALK) {
return (EAFNOSUPPORT);
return EAFNOSUPPORT;
}
/*
* Under phase 2, network 0 means "the network". We take "the
@ -354,7 +355,7 @@ at_pcbconnect(ddp, addr, l)
if (sat->sat_addr.s_net == ATADDR_ANYNET
&& sat->sat_addr.s_node != ATADDR_ANYNODE) {
if (ddp->ddp_lsat.sat_port == ATADDR_ANYPORT) {
return (EADDRNOTAVAIL);
return EADDRNOTAVAIL;
}
hintnet = ddp->ddp_lsat.sat_addr.s_net;
}
@ -371,58 +372,54 @@ at_pcbconnect(ddp, addr, l)
} else {
net = sat->sat_addr.s_net;
}
aa = 0;
if ((ifp = ro->ro_rt->rt_ifp) != NULL) {
for (aa = at_ifaddr.tqh_first; aa;
aa = aa->aa_list.tqe_next) {
TAILQ_FOREACH(aa, &at_ifaddr, aa_list) {
if (aa->aa_ifp == ifp &&
ntohs(net) >= ntohs(aa->aa_firstnet) &&
ntohs(net) <= ntohs(aa->aa_lastnet)) {
break;
}
}
}
if (aa == NULL || (satocsat(rtcache_getdst(ro))->sat_addr.s_net !=
} else
aa = NULL;
cdst = satocsat(rtcache_getdst(ro));
if (aa == NULL || (cdst->sat_addr.s_net !=
(hintnet ? hintnet : sat->sat_addr.s_net) ||
satocsat(rtcache_getdst(ro))->sat_addr.s_node !=
sat->sat_addr.s_node))
cdst->sat_addr.s_node != sat->sat_addr.s_node))
rtcache_free(ro);
}
/*
* If we've got no route for this interface, try to find one.
*/
if (ro->ro_rt == NULL) {
memset(&ro->ro_dst, 0, sizeof(struct sockaddr_at));
ro->ro_dst.sa_len = sizeof(struct sockaddr_at);
ro->ro_dst.sa_family = AF_APPLETALK;
if (hintnet) {
satosat(&ro->ro_dst)->sat_addr.s_net = hintnet;
} else {
satosat(&ro->ro_dst)->sat_addr.s_net =
sat->sat_addr.s_net;
}
satosat(&ro->ro_dst)->sat_addr.s_node = sat->sat_addr.s_node;
union {
struct sockaddr dst;
struct sockaddr_at dsta;
} u;
sockaddr_at_init(&u.dsta, &sat->sat_addr, 0);
if (hintnet)
u.dsta.sat_addr.s_net = hintnet;
rtcache_setdst(ro, &u.dst);
rtcache_init(ro);
}
/*
* Make sure any route that we have has a valid interface.
*/
aa = 0;
if (ro->ro_rt != NULL && (ifp = ro->ro_rt->rt_ifp) != NULL) {
for (aa = at_ifaddr.tqh_first; aa; aa = aa->aa_list.tqe_next) {
if (aa->aa_ifp == ifp) {
TAILQ_FOREACH(aa, &at_ifaddr, aa_list) {
if (aa->aa_ifp == ifp)
break;
}
}
}
if (aa == 0) {
return (ENETUNREACH);
}
} else
aa = NULL;
if (aa == NULL)
return ENETUNREACH;
ddp->ddp_fsat = *sat;
if (ddp->ddp_lsat.sat_port == ATADDR_ANYPORT) {
return (at_pcbsetaddr(ddp, (struct mbuf *) 0, l));
}
return (0);
if (ddp->ddp_lsat.sat_port == ATADDR_ANYPORT)
return at_pcbsetaddr(ddp, NULL, l);
return 0;
}
static void
@ -460,7 +457,7 @@ at_pcballoc(so)
so->so_rcv.sb_mowner = &atalk_rx_mowner;
so->so_snd.sb_mowner = &atalk_tx_mowner;
#endif
return (0);
return 0;
}
static void
@ -484,9 +481,7 @@ at_pcbdetach(so, ddp)
ddp->ddp_pnext->ddp_pprev = ddp->ddp_pprev;
}
}
if (ddp->ddp_route.ro_rt) {
rtfree(ddp->ddp_route.ro_rt);
}
rtcache_free(&ddp->ddp_route);
if (ddp->ddp_prev) {
ddp->ddp_prev->ddp_next = ddp->ddp_next;
} else {
@ -515,9 +510,9 @@ ddp_search(
/*
* Check for bad ports.
*/
if (to->sat_port < ATPORT_FIRST || to->sat_port >= ATPORT_LAST) {
return (NULL);
}
if (to->sat_port < ATPORT_FIRST || to->sat_port >= ATPORT_LAST)
return NULL;
/*
* Make sure the local address matches the sent address. What about
* the interface?

View File

@ -1,4 +1,4 @@
/* $NetBSD: bt_proto.c,v 1.7 2007/04/06 11:49:24 plunky Exp $ */
/* $NetBSD: bt_proto.c,v 1.8 2007/05/02 20:40:24 dyoung Exp $ */
/*-
* Copyright (c) 2005 Iain Hibbert.
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: bt_proto.c,v 1.7 2007/04/06 11:49:24 plunky Exp $");
__KERNEL_RCSID(0, "$NetBSD: bt_proto.c,v 1.8 2007/05/02 20:40:24 dyoung Exp $");
#include <sys/param.h>
#include <sys/domain.h>
@ -101,7 +101,5 @@ struct domain btdomain = {
.dom_ifqueues = { NULL, NULL },
.dom_link = { NULL },
.dom_mowner = MOWNER_INIT("",""),
.dom_rtcache = NULL,
.dom_rtflush = NULL,
.dom_rtflushall = NULL
.dom_rtcache = LIST_HEAD_INITIALIZER(btdomain.dom_rtcache)
};

View File

@ -1,4 +1,4 @@
/* $NetBSD: in.h,v 1.78 2007/02/17 22:34:11 dyoung Exp $ */
/* $NetBSD: in.h,v 1.79 2007/05/02 20:40:24 dyoung Exp $ */
/*
* Copyright (c) 1982, 1986, 1990, 1993
@ -552,7 +552,41 @@ void in_socktrim(struct sockaddr_in *);
#define satosin(sa) ((struct sockaddr_in *)(sa))
#define satocsin(sa) ((const struct sockaddr_in *)(sa))
#define sintosa(sin) ((struct sockaddr *)(sin))
#define sintocsa(sin) ((const struct sockaddr *)(sin))
#define ifatoia(ifa) ((struct in_ifaddr *)(ifa))
int sockaddr_in_cmp(const struct sockaddr *, const struct sockaddr *);
static inline void
sockaddr_in_init1(struct sockaddr_in *sin, const struct in_addr *addr,
in_port_t port)
{
sin->sin_port = port;
sin->sin_addr = *addr;
memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
}
static inline void
sockaddr_in_init(struct sockaddr_in *sin, const struct in_addr *addr,
in_port_t port)
{
sin->sin_family = AF_INET;
sin->sin_len = sizeof(*sin);
sockaddr_in_init1(sin, addr, port);
}
static inline struct sockaddr *
sockaddr_in_alloc(const struct in_addr *addr, in_port_t port, int flags)
{
struct sockaddr *sa;
if ((sa = sockaddr_alloc(AF_INET, flags)) == NULL)
return NULL;
sockaddr_in_init1(satosin(sa), addr, port);
return sa;
}
#endif /* _KERNEL */
#endif /* !_NETINET_IN_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: in_gif.c,v 1.55 2007/03/04 06:03:20 christos Exp $ */
/* $NetBSD: in_gif.c,v 1.56 2007/05/02 20:40:24 dyoung Exp $ */
/* $KAME: in_gif.c,v 1.66 2001/07/29 04:46:09 itojun Exp $ */
/*
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: in_gif.c,v 1.55 2007/03/04 06:03:20 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: in_gif.c,v 1.56 2007/05/02 20:40:24 dyoung Exp $");
#include "opt_inet.h"
#include "opt_iso.h"
@ -91,12 +91,15 @@ int
in_gif_output(struct ifnet *ifp, int family, struct mbuf *m)
{
struct gif_softc *sc = (struct gif_softc*)ifp;
struct sockaddr_in *dst = (struct sockaddr_in *)&sc->gif_ro.ro_dst;
struct sockaddr_in *sin_src = (struct sockaddr_in *)sc->gif_psrc;
struct sockaddr_in *sin_dst = (struct sockaddr_in *)sc->gif_pdst;
struct ip iphdr; /* capsule IP header, host byte ordered */
int proto, error;
u_int8_t tos;
union {
struct sockaddr dst;
struct sockaddr_in dst4;
} u;
if (sin_src == NULL || sin_dst == NULL ||
sin_src->sin_family != AF_INET ||
@ -179,21 +182,10 @@ in_gif_output(struct ifnet *ifp, int family, struct mbuf *m)
return ENOBUFS;
bcopy(&iphdr, mtod(m, struct ip *), sizeof(struct ip));
if (dst->sin_family != sin_dst->sin_family ||
!in_hosteq(dst->sin_addr, sin_dst->sin_addr))
rtcache_free(&sc->gif_ro);
else
rtcache_check(&sc->gif_ro);
if (sc->gif_ro.ro_rt == NULL) {
memset(dst, 0, sizeof(*dst));
dst->sin_family = sin_dst->sin_family;
dst->sin_len = sizeof(struct sockaddr_in);
dst->sin_addr = sin_dst->sin_addr;
rtcache_init(&sc->gif_ro);
if (sc->gif_ro.ro_rt == NULL) {
m_freem(m);
return ENETUNREACH;
}
sockaddr_in_init(&u.dst4, &sin_dst->sin_addr, 0);
if (rtcache_lookup(&sc->gif_ro, &u.dst) == NULL) {
m_freem(m);
return ENETUNREACH;
}
/* If the route constitutes infinite encapsulation, punt. */

View File

@ -1,4 +1,4 @@
/* $NetBSD: in_pcb.c,v 1.116 2007/03/12 18:18:35 ad Exp $ */
/* $NetBSD: in_pcb.c,v 1.117 2007/05/02 20:40:24 dyoung Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -98,7 +98,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: in_pcb.c,v 1.116 2007/03/12 18:18:35 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: in_pcb.c,v 1.117 2007/05/02 20:40:24 dyoung Exp $");
#include "opt_inet.h"
#include "opt_ipsec.h"
@ -875,24 +875,18 @@ struct rtentry *
in_pcbrtentry(struct inpcb *inp)
{
struct route *ro;
union {
struct sockaddr dst;
struct sockaddr_in dst4;
} u;
if (inp->inp_af != AF_INET)
return (NULL);
ro = &inp->inp_route;
if (!in_hosteq(satocsin(rtcache_getdst(ro))->sin_addr, inp->inp_faddr))
rtcache_free(ro);
else
rtcache_check(ro);
if (ro->ro_rt == NULL && !in_nullhost(inp->inp_faddr)) {
memset(&ro->ro_dst, 0, sizeof(ro->ro_dst));
ro->ro_dst.sa_family = AF_INET;
ro->ro_dst.sa_len = sizeof(ro->ro_dst);
satosin(&ro->ro_dst)->sin_addr = inp->inp_faddr;
rtcache_init(ro);
}
return ro->ro_rt;
sockaddr_in_init(&u.dst4, &inp->inp_faddr, 0);
return rtcache_lookup(ro, &u.dst);
}
struct sockaddr_in *
@ -902,25 +896,19 @@ in_selectsrc(struct sockaddr_in *sin, struct route *ro,
struct in_ifaddr *ia = NULL;
/*
* If route is known or can be allocated now,
* our src addr is taken from the i/f, else punt.
* Note that we should check the address family of the cached
* destination, in case of sharing the cache with IPv6.
* If route is known or can be allocated now, take the
* source address from the interface. Otherwise, punt.
*/
if (rtcache_getdst(ro)->sa_family != AF_INET ||
!in_hosteq(satocsin(rtcache_getdst(ro))->sin_addr, sin->sin_addr) ||
(soopts & SO_DONTROUTE) != 0)
if ((soopts & SO_DONTROUTE) != 0)
rtcache_free(ro);
else
rtcache_check(ro);
if ((soopts & SO_DONTROUTE) == 0 && /*XXX*/
ro->ro_rt == NULL) {
/* No route yet, so try to acquire one */
memset(&ro->ro_dst, 0, sizeof(ro->ro_dst));
ro->ro_dst.sa_family = AF_INET;
ro->ro_dst.sa_len = sizeof(struct sockaddr_in);
satosin(&ro->ro_dst)->sin_addr = sin->sin_addr;
rtcache_init(ro);
else {
union {
struct sockaddr dst;
struct sockaddr_in dst4;
} u;
sockaddr_in_init(&u.dst4, &sin->sin_addr, 0);
(void)rtcache_lookup(ro, &u.dst);
}
/*
* If we found a route, use the address
@ -938,7 +926,7 @@ in_selectsrc(struct sockaddr_in *sin, struct route *ro,
sin->sin_port = 0;
ia = ifatoia(ifa_ifwithladdr(sintosa(sin)));
sin->sin_port = fport;
if (ia == 0) {
if (ia == NULL) {
/* Find 1st non-loopback AF_INET address */
TAILQ_FOREACH(ia, &in_ifaddrhead, ia_list) {
if (!(ia->ia_ifp->if_flags & IFF_LOOPBACK))

View File

@ -1,4 +1,4 @@
/* $NetBSD: in_proto.c,v 1.83 2007/03/05 00:50:53 liamjfoy Exp $ */
/* $NetBSD: in_proto.c,v 1.84 2007/05/02 20:40:24 dyoung Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: in_proto.c,v 1.83 2007/03/05 00:50:53 liamjfoy Exp $");
__KERNEL_RCSID(0, "$NetBSD: in_proto.c,v 1.84 2007/05/02 20:40:24 dyoung Exp $");
#include "opt_mrouting.h"
#include "opt_eon.h" /* ISO CLNL over IP */
@ -405,6 +405,9 @@ const struct protosw inetsw[] = {
extern struct ifqueue ipintrq;
POOL_INIT(sockaddr_in_pool, sizeof(struct sockaddr_in), 0, 0, 0,
"sockaddr_in_pool", NULL, IPL_NET);
struct domain inetdomain = {
.dom_family = PF_INET, .dom_name = "internet", .dom_init = NULL,
.dom_externalize = NULL, .dom_dispose = NULL,
@ -422,11 +425,33 @@ struct domain inetdomain = {
.dom_ifqueues = { &ipintrq, NULL },
.dom_link = { NULL },
.dom_mowner = MOWNER_INIT("",""),
.dom_rtcache = in_rtcache,
.dom_rtflush = in_rtflush,
.dom_rtflushall = in_rtflushall
.dom_sa_pool = &sockaddr_in_pool,
.dom_sa_len = sizeof(struct sockaddr_in),
.dom_rtcache = LIST_HEAD_INITIALIZER(inetdomain.dom_rtcache)
};
u_char ip_protox[IPPROTO_MAX];
int icmperrppslim = 100; /* 100pps */
int
sockaddr_in_cmp(const struct sockaddr *sa1, const struct sockaddr *sa2)
{
uint_fast8_t len;
const uint_fast8_t addrofs = offsetof(struct sockaddr_in, sin_addr),
addrend = addrofs + sizeof(struct in_addr);
int rc;
const struct sockaddr_in *sin1, *sin2;
sin1 = satocsin(sa1);
sin2 = satocsin(sa2);
len = MIN(addrend, MIN(sin1->sin_len, sin2->sin_len));
if (len > addrofs &&
(rc = memcmp(&sin1->sin_addr, &sin2->sin_addr,
len - addrofs)) != 0)
return rc;
return sin1->sin_len - sin2->sin_len;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: in_route.c,v 1.6 2007/04/22 06:01:57 dyoung Exp $ */
/* $NetBSD: in_route.c,v 1.7 2007/05/02 20:40:24 dyoung Exp $ */
/*
* Copyright (c) 2006 David Young. All rights reserved.
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: in_route.c,v 1.6 2007/04/22 06:01:57 dyoung Exp $");
__KERNEL_RCSID(0, "$NetBSD: in_route.c,v 1.7 2007/05/02 20:40:24 dyoung Exp $");
#include "opt_inet.h"
#include "opt_in_route.h"
@ -60,86 +60,3 @@ __KERNEL_RCSID(0, "$NetBSD: in_route.c,v 1.6 2007/04/22 06:01:57 dyoung Exp $");
#include <netinet/in_proto.h>
#include <netinet/in_route.h>
LIST_HEAD(in_rtlist, route) in_rtcache_head =
LIST_HEAD_INITIALIZER(in_rtcache_head);
#ifdef IN_RTFLUSH_DEBUG
#define in_rtcache_debug() __predict_false(_in_rtcache_debug)
#else /* IN_RTFLUSH_DEBUG */
#define in_rtcache_debug() 0
#endif /* IN_RTFLUSH_DEBUG */
#ifdef IN_RTFLUSH_DEBUG
static int _in_rtcache_debug = 0;
SYSCTL_SETUP(sysctl_net_inet_ip_rtcache_setup,
"sysctl net.inet.ip.rtcache_debug setup")
{
/* XXX do not duplicate */
sysctl_createv(clog, 0, NULL, NULL,
CTLFLAG_PERMANENT,
CTLTYPE_NODE, "net", NULL,
NULL, 0, NULL, 0,
CTL_NET, CTL_EOL);
sysctl_createv(clog, 0, NULL, NULL,
CTLFLAG_PERMANENT,
CTLTYPE_NODE, "inet",
SYSCTL_DESCR("PF_INET related settings"),
NULL, 0, NULL, 0,
CTL_NET, PF_INET, CTL_EOL);
sysctl_createv(clog, 0, NULL, NULL,
CTLFLAG_PERMANENT,
CTLTYPE_NODE, "ip",
SYSCTL_DESCR("IPv4 related settings"),
NULL, 0, NULL, 0,
CTL_NET, PF_INET, IPPROTO_IP, CTL_EOL);
sysctl_createv(clog, 0, NULL, NULL,
CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_INT,
"rtcache_debug",
SYSCTL_DESCR("Debug IP route cache"),
NULL, 0, &_in_rtcache_debug, 0,
CTL_NET, PF_INET, IPPROTO_IP, CTL_CREATE, CTL_EOL);
}
#endif /* IN_RTFLUSH_DEBUG */
void
in_rtcache(struct route *ro)
{
KASSERT(ro->ro_rt != NULL);
KASSERT(rtcache_getdst(ro) != NULL);
KASSERT(rtcache_getdst(ro)->sa_family == AF_INET);
LIST_INSERT_HEAD(&in_rtcache_head, ro, ro_rtcache_next);
}
void
in_rtflush(struct route *ro)
{
KASSERT(rtcache_getdst(ro) != NULL);
KASSERT(rtcache_getdst(ro)->sa_family == AF_INET);
KASSERT(ro->ro_rt == NULL);
LIST_REMOVE(ro, ro_rtcache_next);
if (in_rtcache_debug()) {
printf("%s: flushing %s\n", __func__,
inet_ntoa((satocsin(rtcache_getdst(ro)))->sin_addr));
}
}
void
in_rtflushall(void)
{
int s;
struct route *ro;
s = splnet();
if (in_rtcache_debug())
printf("%s: enter\n", __func__);
while ((ro = LIST_FIRST(&in_rtcache_head)) != NULL) {
KASSERT(ro->ro_rt != NULL);
rtcache_clear(ro);
}
splx(s);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip_etherip.c,v 1.4 2007/02/17 22:34:11 dyoung Exp $ */
/* $NetBSD: ip_etherip.c,v 1.5 2007/05/02 20:40:24 dyoung Exp $ */
/*
* Copyright (c) 2006, Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
@ -97,6 +97,10 @@ ip_etherip_output(struct ifnet *ifp, struct mbuf *m)
struct ip iphdr; /* capsule IP header, host byte ordered */
struct etherip_header eiphdr;
int proto, error;
union {
struct sockaddr dst;
struct sockaddr_in dst4;
} u;
sin_src = (struct sockaddr_in *)sc->sc_src;
sin_dst = (struct sockaddr_in *)sc->sc_dst;
@ -152,24 +156,10 @@ ip_etherip_output(struct ifnet *ifp, struct mbuf *m)
m = m_pullup(m, sizeof(struct ip));
memcpy(mtod(m, struct ip *), &iphdr, sizeof(struct ip));
if (rtcache_getdst(&sc->sc_ro)->sa_family != sin_dst->sin_family ||
!in_hosteq(satocsin(rtcache_getdst(&sc->sc_ro))->sin_addr,
sin_dst->sin_addr))
rtcache_free(&sc->sc_ro);
else
rtcache_check(&sc->sc_ro);
if (sc->sc_ro.ro_rt == NULL) {
struct sockaddr_in *dst = satosin(&sc->sc_ro.ro_dst);
memset(dst, 0, sizeof(struct sockaddr_in));
dst->sin_family = sin_dst->sin_family;
dst->sin_len = sizeof(struct sockaddr_in);
dst->sin_addr = sin_dst->sin_addr;
rtcache_init(&sc->sc_ro);
if (sc->sc_ro.ro_rt == NULL) {
m_freem(m);
return ENETUNREACH ;
}
sockaddr_in_init(&u.dst4, &sin_dst->sin_addr, 0);
if (rtcache_lookup(&sc->sc_ro, &u.dst) == NULL) {
m_freem(m);
return ENETUNREACH;
}
/* if it constitutes infinite encapsulation, punt. */

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip_flow.c,v 1.45 2007/04/05 18:11:47 liamjfoy Exp $ */
/* $NetBSD: ip_flow.c,v 1.46 2007/05/02 20:40:24 dyoung Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ip_flow.c,v 1.45 2007/04/05 18:11:47 liamjfoy Exp $");
__KERNEL_RCSID(0, "$NetBSD: ip_flow.c,v 1.46 2007/05/02 20:40:24 dyoung Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -437,7 +437,7 @@ ipflow_create(const struct route *ro, struct mbuf *m)
/*
* Fill in the updated information.
*/
rtcache_copy(&ipf->ipf_ro, ro, sizeof(ipf->ipf_ro));
rtcache_copy(&ipf->ipf_ro, ro);
ipf->ipf_dst = ip->ip_dst;
ipf->ipf_src = ip->ip_src;
ipf->ipf_tos = ip->ip_tos;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip_input.c,v 1.248 2007/03/25 20:12:20 liamjfoy Exp $ */
/* $NetBSD: ip_input.c,v 1.249 2007/05/02 20:40:25 dyoung Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -98,7 +98,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.248 2007/03/25 20:12:20 liamjfoy Exp $");
__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.249 2007/05/02 20:40:25 dyoung Exp $");
#include "opt_inet.h"
#include "opt_gateway.h"
@ -1674,23 +1674,18 @@ bad:
struct in_ifaddr *
ip_rtaddr(struct in_addr dst)
{
if (!in_hosteq(dst, satocsin(rtcache_getdst(&ipforward_rt))->sin_addr))
rtcache_free(&ipforward_rt);
else
rtcache_check(&ipforward_rt);
struct rtentry *rt;
union {
struct sockaddr dst;
struct sockaddr_in dst4;
} u;
if (ipforward_rt.ro_rt == NULL) {
struct sockaddr_in *sin = satosin(&ipforward_rt.ro_dst);
sockaddr_in_init(&u.dst4, &dst, 0);
sin->sin_family = AF_INET;
sin->sin_len = sizeof(*sin);
sin->sin_addr = dst;
if ((rt = rtcache_lookup(&ipforward_rt, &u.dst)) == NULL)
return NULL;
rtcache_init(&ipforward_rt);
if (ipforward_rt.ro_rt == NULL)
return NULL;
}
return ifatoia(ipforward_rt.ro_rt->rt_ifa);
return ifatoia(rt->rt_ifa);
}
/*
@ -1841,6 +1836,10 @@ ip_forward(struct mbuf *m, int srcrt)
int error, type = 0, code = 0, destmtu = 0;
struct mbuf *mcopy;
n_long dest;
union {
struct sockaddr dst;
struct sockaddr_in dst4;
} u;
/*
* We are now in the output path.
@ -1869,25 +1868,11 @@ ip_forward(struct mbuf *m, int srcrt)
return;
}
if (!in_hosteq(ip->ip_dst,
satocsin(rtcache_getdst(&ipforward_rt))->sin_addr))
rtcache_free(&ipforward_rt);
else
rtcache_check(&ipforward_rt);
if (ipforward_rt.ro_rt == NULL) {
struct sockaddr_in *sin = satosin(&ipforward_rt.ro_dst);
sin->sin_family = AF_INET;
sin->sin_len = sizeof(*sin);
sin->sin_addr = ip->ip_dst;
rtcache_init(&ipforward_rt);
if (ipforward_rt.ro_rt == NULL) {
icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_NET, dest, 0);
return;
}
sockaddr_in_init(&u.dst4, &ip->ip_dst, 0);
if ((rt = rtcache_lookup(&ipforward_rt, &u.dst)) == NULL) {
icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_NET, dest, 0);
return;
}
rt = ipforward_rt.ro_rt;
/*
* Save at most 68 bytes of the packet in case

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip_output.c,v 1.179 2007/03/04 06:03:21 christos Exp $ */
/* $NetBSD: ip_output.c,v 1.180 2007/05/02 20:40:25 dyoung Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -98,7 +98,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.179 2007/03/04 06:03:21 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.180 2007/05/02 20:40:25 dyoung Exp $");
#include "opt_pfil_hooks.h"
#include "opt_inet.h"
@ -155,7 +155,8 @@ __KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.179 2007/03/04 06:03:21 christos Exp
static struct mbuf *ip_insertoptions(struct mbuf *, struct mbuf *, int *);
static struct ifnet *ip_multicast_if(struct in_addr *, int *);
static void ip_mloopback(struct ifnet *, struct mbuf *, struct sockaddr_in *);
static void ip_mloopback(struct ifnet *, struct mbuf *,
const struct sockaddr_in *);
static int ip_getoptval(struct mbuf *, u_int8_t *, u_int);
#ifdef PFIL_HOOKS
@ -185,7 +186,7 @@ ip_output(struct mbuf *m0, ...)
int hlen = sizeof (struct ip);
int len, error = 0;
struct route iproute;
struct sockaddr_in *dst;
const struct sockaddr_in *dst;
struct in_ifaddr *ia;
struct ifaddr *xifa;
struct mbuf *opt;
@ -210,6 +211,13 @@ ip_output(struct mbuf *m0, ...)
int s;
#endif
u_int16_t ip_len;
union {
struct sockaddr dst;
struct sockaddr_in dst4;
} u;
struct sockaddr *rdst = &u.dst; /* real IP destination, as opposed
* to the nexthop
*/
len = 0;
va_start(ap, m0);
@ -290,7 +298,8 @@ ip_output(struct mbuf *m0, ...)
memset(&iproute, 0, sizeof(iproute));
if (ro == NULL)
ro = &iproute;
dst = satosin(&ro->ro_dst);
sockaddr_in_init(&u.dst4, &ip->ip_dst, 0);
dst = satocsin(rtcache_getdst(ro));
/*
* If there is a cached route,
* check that it is to the same destination
@ -298,22 +307,23 @@ ip_output(struct mbuf *m0, ...)
* The address family should also be checked in case of sharing the
* cache with IPv6.
*/
if (dst->sin_family != AF_INET || !in_hosteq(dst->sin_addr, ip->ip_dst))
if (dst == NULL)
;
else if (dst->sin_family != AF_INET ||
!in_hosteq(dst->sin_addr, ip->ip_dst))
rtcache_free(ro);
else
rtcache_check(ro);
if (ro->ro_rt == NULL) {
memset(dst, 0, sizeof(*dst));
dst->sin_family = AF_INET;
dst->sin_len = sizeof(*dst);
dst->sin_addr = ip->ip_dst;
dst = &u.dst4;
rtcache_setdst(ro, &u.dst);
}
/*
* If routing to interface only,
* short circuit routing lookup.
*/
if (flags & IP_ROUTETOIF) {
if ((ia = ifatoia(ifa_ifwithladdr(sintosa(dst)))) == 0) {
if ((ia = ifatoia(ifa_ifwithladdr(sintocsa(dst)))) == NULL) {
ipstat.ips_noroute++;
error = ENETUNREACH;
goto bad;
@ -349,12 +359,6 @@ ip_output(struct mbuf *m0, ...)
m->m_flags |= (ip->ip_dst.s_addr == INADDR_BROADCAST) ?
M_BCAST : M_MCAST;
/*
* IP destination address is multicast. Make sure "dst"
* still points to the address in "ro". (It may have been
* changed to point to a gateway address, above.)
*/
dst = satosin(&ro->ro_dst);
/*
* See if the caller provided any multicast options
*/
@ -399,8 +403,7 @@ ip_output(struct mbuf *m0, ...)
}
xifa = &xia->ia_ifa;
if (xifa->ifa_getifa != NULL) {
xia = ifatoia((*xifa->ifa_getifa)(xifa,
rtcache_getdst(ro)));
xia = ifatoia((*xifa->ifa_getifa)(xifa, rdst));
}
ip->ip_src = xia->ia_addr.sin_addr;
}
@ -413,7 +416,7 @@ ip_output(struct mbuf *m0, ...)
* on the outgoing interface, and the caller did not
* forbid loopback, loop back a copy.
*/
ip_mloopback(ifp, m, dst);
ip_mloopback(ifp, m, &u.dst4);
}
#ifdef MROUTING
else {
@ -461,7 +464,7 @@ ip_output(struct mbuf *m0, ...)
if (in_nullhost(ip->ip_src)) {
xifa = &ia->ia_ifa;
if (xifa->ifa_getifa != NULL)
ia = ifatoia((*xifa->ifa_getifa)(xifa, rtcache_getdst(ro)));
ia = ifatoia((*xifa->ifa_getifa)(xifa, rdst));
ip->ip_src = ia->ia_addr.sin_addr;
}
@ -587,7 +590,7 @@ sendit:
memset(&iproute, 0, sizeof(iproute));
} else
state.ro = ro;
state.dst = (struct sockaddr *)dst;
state.dst = sintocsa(dst);
/*
* We can't defer the checksum of payload data if
@ -617,7 +620,7 @@ sendit:
}
} else
ro = state.ro;
dst = (struct sockaddr_in *)state.dst;
dst = satocsin(state.dst);
if (error) {
/* mbuf is already reclaimed in ipsec4_output. */
m0 = NULL;
@ -884,10 +887,10 @@ spd_done:
(m->m_pkthdr.csum_flags & M_CSUM_TSOv4) == 0 ||
(ifp->if_capenable & IFCAP_TSOv4) != 0)) {
error =
(*ifp->if_output)(ifp, m, sintosa(dst), ro->ro_rt);
(*ifp->if_output)(ifp, m, sintocsa(dst), ro->ro_rt);
} else {
error =
ip_tso_output(ifp, m, sintosa(dst), ro->ro_rt);
ip_tso_output(ifp, m, sintocsa(dst), ro->ro_rt);
}
goto done;
}
@ -953,7 +956,7 @@ spd_done:
{
KASSERT((m->m_pkthdr.csum_flags &
(M_CSUM_UDPv4 | M_CSUM_TCPv4)) == 0);
error = (*ifp->if_output)(ifp, m, sintosa(dst),
error = (*ifp->if_output)(ifp, m, sintocsa(dst),
ro->ro_rt);
}
} else
@ -1665,8 +1668,6 @@ ip_setmoptions(int optname, struct ip_moptions **imop, struct mbuf *m)
struct ip_mreq *mreq;
struct ifnet *ifp;
struct ip_moptions *imo = *imop;
struct route ro;
struct sockaddr_in *dst;
int ifindex;
if (imo == NULL) {
@ -1758,11 +1759,16 @@ ip_setmoptions(int optname, struct ip_moptions **imop, struct mbuf *m)
* the route to the given multicast address.
*/
if (in_nullhost(mreq->imr_interface)) {
union {
struct sockaddr dst;
struct sockaddr_in dst4;
} u;
struct route ro;
memset(&ro, 0, sizeof(ro));
dst = satosin(&ro.ro_dst);
dst->sin_len = sizeof(*dst);
dst->sin_family = AF_INET;
dst->sin_addr = mreq->imr_multiaddr;
sockaddr_in_init(&u.dst4, &mreq->imr_multiaddr, 0);
rtcache_setdst(&ro, &u.dst);
rtcache_init(&ro);
ifp = (ro.ro_rt != NULL) ? ro.ro_rt->rt_ifp : NULL;
rtcache_free(&ro);
@ -1950,7 +1956,7 @@ ip_freemoptions(struct ip_moptions *imo)
* pointer that might NOT be lo0ifp -- easier than replicating that code here.
*/
static void
ip_mloopback(struct ifnet *ifp, struct mbuf *m, struct sockaddr_in *dst)
ip_mloopback(struct ifnet *ifp, struct mbuf *m, const struct sockaddr_in *dst)
{
struct ip *ip;
struct mbuf *copym;
@ -1959,21 +1965,21 @@ ip_mloopback(struct ifnet *ifp, struct mbuf *m, struct sockaddr_in *dst)
if (copym != NULL
&& (copym->m_flags & M_EXT || copym->m_len < sizeof(struct ip)))
copym = m_pullup(copym, sizeof(struct ip));
if (copym != NULL) {
/*
* We don't bother to fragment if the IP length is greater
* than the interface's MTU. Can this possibly matter?
*/
ip = mtod(copym, struct ip *);
if (copym == NULL)
return;
/*
* We don't bother to fragment if the IP length is greater
* than the interface's MTU. Can this possibly matter?
*/
ip = mtod(copym, struct ip *);
if (copym->m_pkthdr.csum_flags & (M_CSUM_TCPv4|M_CSUM_UDPv4)) {
in_delayed_cksum(copym);
copym->m_pkthdr.csum_flags &=
~(M_CSUM_TCPv4|M_CSUM_UDPv4);
}
ip->ip_sum = 0;
ip->ip_sum = in_cksum(copym, ip->ip_hl << 2);
(void) looutput(ifp, copym, sintosa(dst), NULL);
if (copym->m_pkthdr.csum_flags & (M_CSUM_TCPv4|M_CSUM_UDPv4)) {
in_delayed_cksum(copym);
copym->m_pkthdr.csum_flags &=
~(M_CSUM_TCPv4|M_CSUM_UDPv4);
}
ip->ip_sum = 0;
ip->ip_sum = in_cksum(copym, ip->ip_hl << 2);
(void)looutput(ifp, copym, sintocsa(dst), NULL);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: tcp_input.c,v 1.263 2007/03/12 18:18:36 ad Exp $ */
/* $NetBSD: tcp_input.c,v 1.264 2007/05/02 20:40:25 dyoung Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -152,7 +152,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.263 2007/03/12 18:18:36 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.264 2007/05/02 20:40:25 dyoung Exp $");
#include "opt_inet.h"
#include "opt_ipsec.h"
@ -3214,7 +3214,7 @@ do { \
do { \
if ((sc)->sc_ipopts) \
(void) m_free((sc)->sc_ipopts); \
rtcache_free(&(sc)->sc_route4); \
rtcache_free(&(sc)->sc_route); \
if (callout_invoking(&(sc)->sc_timer)) \
(sc)->sc_flags |= SCF_DEAD; \
else \
@ -3631,14 +3631,13 @@ syn_cache_get(struct sockaddr *src, struct sockaddr *dst,
* Give the new socket our cached route reference.
*/
if (inp) {
rtcache_copy(&inp->inp_route, &sc->sc_route4, sizeof(inp->inp_route));
rtcache_free(&sc->sc_route4);
rtcache_copy(&inp->inp_route, &sc->sc_route);
rtcache_free(&sc->sc_route);
}
#ifdef INET6
else {
rtcache_copy((struct route *)&in6p->in6p_route,
(struct route *)&sc->sc_route6, sizeof(in6p->in6p_route));
rtcache_free((struct route *)&sc->sc_route6);
rtcache_copy(&in6p->in6p_route, &sc->sc_route);
rtcache_free(&sc->sc_route);
}
#endif
@ -4064,15 +4063,14 @@ syn_cache_respond(struct syn_cache *sc, struct mbuf *m)
u_int hlen;
struct socket *so;
ro = &sc->sc_route;
switch (sc->sc_src.sa.sa_family) {
case AF_INET:
hlen = sizeof(struct ip);
ro = &sc->sc_route4;
break;
#ifdef INET6
case AF_INET6:
hlen = sizeof(struct ip6_hdr);
ro = (struct route *)&sc->sc_route6;
break;
#endif
default:
@ -4336,8 +4334,7 @@ syn_cache_respond(struct syn_cache *sc, struct mbuf *m)
ip6->ip6_hlim = in6_selecthlim(NULL,
ro->ro_rt ? ro->ro_rt->rt_ifp : NULL);
error = ip6_output(m, NULL /*XXX*/, (struct route_in6 *)ro, 0,
(struct ip6_moptions *)0, so, NULL);
error = ip6_output(m, NULL /*XXX*/, ro, 0, NULL, so, NULL);
break;
#endif
default:

View File

@ -1,4 +1,4 @@
/* $NetBSD: tcp_output.c,v 1.157 2007/03/04 06:03:22 christos Exp $ */
/* $NetBSD: tcp_output.c,v 1.158 2007/05/02 20:40:25 dyoung Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -142,7 +142,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: tcp_output.c,v 1.157 2007/03/04 06:03:22 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: tcp_output.c,v 1.158 2007/05/02 20:40:25 dyoung Exp $");
#include "opt_inet.h"
#include "opt_ipsec.h"
@ -589,7 +589,7 @@ tcp_output(struct tcpcb *tp)
#ifdef INET6
else if (tp->t_in6pcb) {
so = tp->t_in6pcb->in6p_socket;
ro = (struct route *)&tp->t_in6pcb->in6p_route;
ro = &tp->t_in6pcb->in6p_route;
}
#endif
@ -1578,9 +1578,8 @@ timer:
opts = tp->t_in6pcb->in6p_outputopts;
else
opts = NULL;
error = ip6_output(m, opts, (struct route_in6 *)ro,
so->so_options & SO_DONTROUTE,
(struct ip6_moptions *)0, so, NULL);
error = ip6_output(m, opts, ro, so->so_options & SO_DONTROUTE,
NULL, so, NULL);
break;
}
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: tcp_subr.c,v 1.213 2007/03/12 18:18:36 ad Exp $ */
/* $NetBSD: tcp_subr.c,v 1.214 2007/05/02 20:40:25 dyoung Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -98,7 +98,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: tcp_subr.c,v 1.213 2007/03/12 18:18:36 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: tcp_subr.c,v 1.214 2007/05/02 20:40:25 dyoung Exp $");
#include "opt_inet.h"
#include "opt_ipsec.h"
@ -906,8 +906,7 @@ tcp_respond(struct tcpcb *tp, struct mbuf *template, struct mbuf *m,
#endif
#ifdef INET6
case AF_INET6:
error = ip6_output(m, NULL, (struct route_in6 *)ro, 0,
(struct ip6_moptions *)0, so, NULL);
error = ip6_output(m, NULL, ro, 0, NULL, so, NULL);
break;
#endif
default:

View File

@ -1,4 +1,4 @@
/* $NetBSD: tcp_var.h,v 1.145 2007/03/04 06:03:22 christos Exp $ */
/* $NetBSD: tcp_var.h,v 1.146 2007/05/02 20:40:25 dyoung Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -471,16 +471,7 @@ union syn_cache_sa {
struct syn_cache {
TAILQ_ENTRY(syn_cache) sc_bucketq; /* link on bucket list */
struct callout sc_timer; /* rexmt timer */
union { /* cached route */
struct route route4;
#ifdef INET6
struct route_in6 route6;
#endif
} sc_route_u;
#define sc_route4 sc_route_u.route4
#ifdef INET6
#define sc_route6 sc_route_u.route6
#endif
struct route sc_route;
long sc_win; /* advertised window */
int sc_bucketidx; /* our bucket index */
u_int32_t sc_hash;

View File

@ -1,4 +1,4 @@
/* $NetBSD: frag6.c,v 1.36 2007/03/04 06:03:25 christos Exp $ */
/* $NetBSD: frag6.c,v 1.37 2007/05/02 20:40:25 dyoung Exp $ */
/* $KAME: frag6.c,v 1.40 2002/05/27 21:40:31 itojun Exp $ */
/*
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: frag6.c,v 1.36 2007/03/04 06:03:25 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: frag6.c,v 1.37 2007/05/02 20:40:25 dyoung Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -187,8 +187,11 @@ frag6_input(struct mbuf **mp, int *offp, int proto)
int fragoff, frgpartlen; /* must be larger than u_int16_t */
struct ifnet *dstifp;
#ifdef IN6_IFSTAT_STRICT
static struct route_in6 ro;
const struct sockaddr_in6 *cdst;
static struct route ro;
union {
struct sockaddr dst;
struct sockaddr_in6 dst6;
} u;
#endif
ip6 = mtod(m, struct ip6_hdr *);
@ -199,21 +202,8 @@ frag6_input(struct mbuf **mp, int *offp, int proto)
dstifp = NULL;
#ifdef IN6_IFSTAT_STRICT
/* find the destination interface of the packet. */
cdst = (const struct sockaddr_in6 *)rtcache_getdst((struct route *)&ro);
if (!IN6_ARE_ADDR_EQUAL(&cdst->sin6_addr, &ip6->ip6_dst))
rtcache_free((struct route *)&ro);
else
rtcache_check((struct route *)&ro);
if (ro.ro_rt == NULL) {
struct sockaddr_in6 *dst;
dst = (struct sockaddr_in6 *)&ro.ro_dst;
memset(dst, 0, sizeof(*dst));
dst->sin6_family = AF_INET6;
dst->sin6_len = sizeof(struct sockaddr_in6);
dst->sin6_addr = ip6->ip6_dst;
rtcache_init((struct route *)&ro);
}
sockaddr_in6_init(&u.dst6, &ip6->ip6_dst, 0, 0, 0);
rtcache_lookup(&ro, &u.dst);
if (ro.ro_rt != NULL && ro.ro_rt->rt_ifa != NULL)
dstifp = ((struct in6_ifaddr *)ro.ro_rt->rt_ifa)->ia_ifp;
#else
@ -740,8 +730,8 @@ frag6_slowtimo()
* make sure we notice eventually, even if forwarding only for one
* destination and the cache is never replaced.
*/
rtcache_free((struct route *)&ip6_forward_rt);
rtcache_free((struct route *)&ipsrcchk_rt);
rtcache_free(&ip6_forward_rt);
rtcache_free(&ipsrcchk_rt);
#endif
splx(s);

View File

@ -1,4 +1,4 @@
/* $NetBSD: icmp6.c,v 1.131 2007/03/04 06:03:25 christos Exp $ */
/* $NetBSD: icmp6.c,v 1.132 2007/05/02 20:40:25 dyoung Exp $ */
/* $KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $ */
/*
@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.131 2007/03/04 06:03:25 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.132 2007/05/02 20:40:25 dyoung Exp $");
#include "opt_inet.h"
#include "opt_ipsec.h"
@ -2056,7 +2056,7 @@ icmp6_reflect(struct mbuf *m, size_t off)
if (src == NULL) {
int e;
struct sockaddr_in6 sin6;
struct route_in6 ro;
struct route ro;
/*
* This case matches to multicasts, our anycast, or unicasts
@ -2069,9 +2069,8 @@ icmp6_reflect(struct mbuf *m, size_t off)
sin6.sin6_addr = ip6->ip6_dst; /* zone ID should be embedded */
memset(&ro, 0, sizeof(ro));
src = in6_selectsrc(&sin6, NULL, NULL, (struct route *)&ro,
NULL, &outif, &e);
rtcache_free((struct route *)&ro);
src = in6_selectsrc(&sin6, NULL, NULL, &ro, NULL, &outif, &e);
rtcache_free(&ro);
if (src == NULL) {
nd6log((LOG_DEBUG,
"icmp6_reflect: source can't be determined: "

View File

@ -1,4 +1,4 @@
/* $NetBSD: in6.h,v 1.59 2007/02/17 22:34:13 dyoung Exp $ */
/* $NetBSD: in6.h,v 1.60 2007/05/02 20:40:26 dyoung Exp $ */
/* $KAME: in6.h,v 1.83 2001/03/29 02:55:07 jinmei Exp $ */
/*
@ -374,16 +374,6 @@ extern const struct in6_addr in6addr_linklocal_allrouters;
(a)->ia6_lifetime.ia6t_vltime)
#endif
/*
* IP6 route structure
*/
#if defined(_NETBSD_SOURCE)
struct route_in6 {
struct rtentry *ro_rt;
struct sockaddr_in6 ro_dst;
};
#endif
/*
* Options for use with [gs]etsockopt at the IPV6 level.
* First word of comment is data type; bool is stored in int.
@ -704,6 +694,7 @@ in6_cksum_phdr(const struct in6_addr *src, const struct in6_addr *dst,
struct mbuf;
struct ifnet;
int sockaddr_in6_cmp(const struct sockaddr *, const struct sockaddr *);
int in6_cksum __P((struct mbuf *, u_int8_t, u_int32_t, u_int32_t));
void in6_delayed_cksum __P((struct mbuf *));
int in6_localaddr __P((struct in6_addr *));
@ -719,7 +710,41 @@ extern u_char ip6_protox[];
#define satosin6(sa) ((struct sockaddr_in6 *)(sa))
#define satocsin6(sa) ((const struct sockaddr_in6 *)(sa))
#define sin6tosa(sin6) ((struct sockaddr *)(sin6))
#define sin6tocsa(sin6) ((const struct sockaddr *)(sin6))
#define ifatoia6(ifa) ((struct in6_ifaddr *)(ifa))
static inline void
sockaddr_in6_init1(struct sockaddr_in6 *sin6, const struct in6_addr *addr,
in_port_t port, uint32_t flowinfo, uint32_t scope_id)
{
sin6->sin6_port = port;
sin6->sin6_flowinfo = flowinfo;
sin6->sin6_addr = *addr;
sin6->sin6_scope_id = scope_id;
}
static inline void
sockaddr_in6_init(struct sockaddr_in6 *sin6, const struct in6_addr *addr,
in_port_t port, uint32_t flowinfo, uint32_t scope_id)
{
sin6->sin6_family = AF_INET6;
sin6->sin6_len = sizeof(*sin6);
sockaddr_in6_init1(sin6, addr, port, flowinfo, scope_id);
}
static inline struct sockaddr *
sockaddr_in6_alloc(const struct in6_addr *addr, in_port_t port,
uint32_t flowinfo, uint32_t scope_id, int flags)
{
struct sockaddr *sa;
if ((sa = sockaddr_alloc(AF_INET6, flags)) == NULL)
return NULL;
sockaddr_in6_init1(satosin6(sa), addr, port, flowinfo, scope_id);
return sa;
}
#endif /* _KERNEL */
#if defined(_NETBSD_SOURCE)

View File

@ -1,4 +1,4 @@
/* $NetBSD: in6_gif.c,v 1.50 2007/03/04 06:03:25 christos Exp $ */
/* $NetBSD: in6_gif.c,v 1.51 2007/05/02 20:40:26 dyoung Exp $ */
/* $KAME: in6_gif.c,v 1.62 2001/07/29 04:27:25 itojun Exp $ */
/*
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: in6_gif.c,v 1.50 2007/03/04 06:03:25 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: in6_gif.c,v 1.51 2007/05/02 20:40:26 dyoung Exp $");
#include "opt_inet.h"
#include "opt_iso.h"
@ -92,14 +92,15 @@ in6_gif_output(ifp, family, m)
struct mbuf *m;
{
struct gif_softc *sc = (struct gif_softc*)ifp;
const struct sockaddr_in6 *cdst =
(const struct sockaddr_in6 *)rtcache_getdst(
(struct route *)&sc->gif_ro6);
struct sockaddr_in6 *sin6_src = (struct sockaddr_in6 *)sc->gif_psrc;
struct sockaddr_in6 *sin6_dst = (struct sockaddr_in6 *)sc->gif_pdst;
struct ip6_hdr *ip6;
int proto, error;
u_int8_t itos, otos;
union {
struct sockaddr dst;
struct sockaddr_in6 dst6;
} u;
if (sin6_src == NULL || sin6_dst == NULL ||
sin6_src->sin6_family != AF_INET6 ||
@ -185,24 +186,10 @@ in6_gif_output(ifp, family, m)
ip6->ip6_flow &= ~ntohl(0xff00000);
ip6->ip6_flow |= htonl((u_int32_t)otos << 20);
if (cdst->sin6_family != sin6_dst->sin6_family ||
!IN6_ARE_ADDR_EQUAL(&cdst->sin6_addr, &sin6_dst->sin6_addr))
rtcache_free((struct route *)&sc->gif_ro6);
else
rtcache_check((struct route *)&sc->gif_ro6);
if (sc->gif_ro6.ro_rt == NULL) {
struct sockaddr_in6 *dst =
(struct sockaddr_in6 *)&sc->gif_ro6.ro_dst;
memset(dst, 0, sizeof(*dst));
dst->sin6_family = sin6_dst->sin6_family;
dst->sin6_len = sizeof(struct sockaddr_in6);
dst->sin6_addr = sin6_dst->sin6_addr;
rtcache_init((struct route *)&sc->gif_ro6);
if (sc->gif_ro6.ro_rt == NULL) {
m_freem(m);
return ENETUNREACH;
}
sockaddr_in6_init(&u.dst6, &sin6_dst->sin6_addr, 0, 0, 0);
if (rtcache_lookup(&sc->gif_ro, &u.dst) == NULL) {
m_freem(m);
return ENETUNREACH;
}
/* If the route constitutes infinite encapsulation, punt. */
@ -217,10 +204,10 @@ in6_gif_output(ifp, family, m)
* it is too painful to ask for resend of inner packet, to achieve
* path MTU discovery for encapsulated packets.
*/
error = ip6_output(m, 0, &sc->gif_ro6, IPV6_MINMTU,
error = ip6_output(m, 0, &sc->gif_ro, IPV6_MINMTU,
(struct ip6_moptions *)NULL, (struct socket *)NULL, NULL);
#else
error = ip6_output(m, 0, &sc->gif_ro6, 0,
error = ip6_output(m, 0, &sc->gif_ro, 0,
(struct ip6_moptions *)NULL, (struct socket *)NULL, NULL);
#endif
@ -421,7 +408,7 @@ in6_gif_detach(sc)
if (error == 0)
sc->encap_cookie6 = NULL;
rtcache_free((struct route *)&sc->gif_ro6);
rtcache_free(&sc->gif_ro);
return error;
}
@ -466,12 +453,14 @@ in6_gif_ctlinput(int cmd, const struct sockaddr *sa, void *d)
continue;
if (sc->gif_psrc->sa_family != AF_INET6)
continue;
if (sc->gif_ro6.ro_rt == NULL)
if (sc->gif_ro.ro_rt == NULL)
continue;
dst6 = satocsin6(rtcache_getdst((struct route *)&sc->gif_ro6));
dst6 = satocsin6(rtcache_getdst(&sc->gif_ro));
/* XXX scope */
if (IN6_ARE_ADDR_EQUAL(&ip6->ip6_dst, &dst6->sin6_addr))
rtcache_free((struct route *)&sc->gif_ro6);
if (dst6 == NULL)
;
else if (IN6_ARE_ADDR_EQUAL(&ip6->ip6_dst, &dst6->sin6_addr))
rtcache_free(&sc->gif_ro);
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: in6_offload.c,v 1.3 2007/04/25 20:40:20 dyoung Exp $ */
/* $NetBSD: in6_offload.c,v 1.4 2007/05/02 20:40:26 dyoung Exp $ */
/*-
* Copyright (c)2006 YAMAMOTO Takashi,
@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: in6_offload.c,v 1.3 2007/04/25 20:40:20 dyoung Exp $");
__KERNEL_RCSID(0, "$NetBSD: in6_offload.c,v 1.4 2007/05/02 20:40:26 dyoung Exp $");
#include <sys/param.h>
#include <sys/mbuf.h>
@ -45,7 +45,7 @@ __KERNEL_RCSID(0, "$NetBSD: in6_offload.c,v 1.3 2007/04/25 20:40:20 dyoung Exp $
struct ip6_tso_output_args {
struct ifnet *ifp;
struct ifnet *origifp;
struct sockaddr_in6 *dst;
const struct sockaddr_in6 *dst;
struct rtentry *rt;
};
@ -61,7 +61,7 @@ ip6_tso_output_callback(void *vp, struct mbuf *m)
int
ip6_tso_output(struct ifnet *ifp, struct ifnet *origifp, struct mbuf *m,
struct sockaddr_in6 *dst, struct rtentry *rt)
const struct sockaddr_in6 *dst, struct rtentry *rt)
{
struct ip6_tso_output_args args;

View File

@ -1,4 +1,4 @@
/* $NetBSD: in6_offload.h,v 1.4 2007/04/25 20:40:20 dyoung Exp $ */
/* $NetBSD: in6_offload.h,v 1.5 2007/05/02 20:40:26 dyoung Exp $ */
/*-
* Copyright (c)2005, 2006 YAMAMOTO Takashi,
@ -35,6 +35,6 @@
int tcp6_segment(struct mbuf *, int (*)(void *, struct mbuf *), void *);
int ip6_tso_output(struct ifnet *, struct ifnet *, struct mbuf *,
struct sockaddr_in6 *, struct rtentry *);
const struct sockaddr_in6 *, struct rtentry *);
#endif /* !defined(_NETINET6_IN6_OFFLOAD_H_) */

View File

@ -1,4 +1,4 @@
/* $NetBSD: in6_pcb.c,v 1.85 2007/03/12 18:18:36 ad Exp $ */
/* $NetBSD: in6_pcb.c,v 1.86 2007/05/02 20:40:26 dyoung Exp $ */
/* $KAME: in6_pcb.c,v 1.84 2001/02/08 18:02:08 itojun Exp $ */
/*
@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: in6_pcb.c,v 1.85 2007/03/12 18:18:36 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: in6_pcb.c,v 1.86 2007/05/02 20:40:26 dyoung Exp $");
#include "opt_inet.h"
#include "opt_ipsec.h"
@ -411,7 +411,7 @@ in6_pcbconnect(v, nam, l)
sin.sin_family = AF_INET;
bcopy(&sin6->sin6_addr.s6_addr32[3], &sin.sin_addr,
sizeof(sin.sin_addr));
sinp = in_selectsrc(&sin, (struct route *)&in6p->in6p_route,
sinp = in_selectsrc(&sin, &in6p->in6p_route,
in6p->in6p_socket->so_options, NULL, &error);
if (sinp == 0) {
if (error == 0)
@ -433,7 +433,7 @@ in6_pcbconnect(v, nam, l)
*/
in6a = in6_selectsrc(sin6, in6p->in6p_outputopts,
in6p->in6p_moptions,
(struct route *)&in6p->in6p_route,
&in6p->in6p_route,
&in6p->in6p_laddr, &ifp, &error);
if (ifp && scope_ambiguous &&
(error = in6_setscope(&sin6->sin6_addr, ifp, NULL)) != 0) {
@ -515,12 +515,12 @@ in6_pcbdetach(in6p)
m_freem(in6p->in6p_options);
if (in6p->in6p_outputopts) {
if (in6p->in6p_outputopts->ip6po_rthdr != NULL)
rtcache_free((struct route *)&in6p->in6p_outputopts->ip6po_route);
rtcache_free(&in6p->in6p_outputopts->ip6po_route);
if (in6p->in6p_outputopts->ip6po_m)
(void)m_free(in6p->in6p_outputopts->ip6po_m);
free(in6p->in6p_outputopts, M_IP6OPT);
}
rtcache_free((struct route *)&in6p->in6p_route);
rtcache_free(&in6p->in6p_route);
ip6_freemoptions(in6p->in6p_moptions);
s = splnet();
in6_pcbstate(in6p, IN6P_ATTACHED);
@ -675,8 +675,10 @@ in6_pcbnotify(struct inpcbtable *table, const struct sockaddr *dst,
const struct sockaddr_in6 *dst6;
dst6 = (const struct sockaddr_in6 *)
rtcache_getdst((struct route *)&in6p->in6p_route);
if (IN6_ARE_ADDR_EQUAL(&dst6->sin6_addr,
rtcache_getdst(&in6p->in6p_route);
if (dst6 == NULL)
;
else if (IN6_ARE_ADDR_EQUAL(&dst6->sin6_addr,
&sa6_dst->sin6_addr))
goto do_notify;
}
@ -808,8 +810,7 @@ in6_losing(in6p)
if ((rt = in6p->in6p_route.ro_rt) != NULL) {
memset(&info, 0, sizeof(info));
info.rti_info[RTAX_DST] =
rtcache_getdst((struct route *)&in6p->in6p_route);
info.rti_info[RTAX_DST] = rtcache_getdst(&in6p->in6p_route);
info.rti_info[RTAX_GATEWAY] = rt->rt_gateway;
info.rti_info[RTAX_NETMASK] = rt_mask(rt);
rt_missmsg(RTM_LOSING, &info, rt->rt_flags, 0);
@ -817,7 +818,7 @@ in6_losing(in6p)
(void)rtrequest(RTM_DELETE, rt_key(rt), rt->rt_gateway,
rt_mask(rt), rt->rt_flags, NULL);
}
rtcache_free((struct route *)&in6p->in6p_route);
rtcache_free(&in6p->in6p_route);
/*
* A new route can be allocated
* the next time output is attempted.
@ -835,7 +836,7 @@ in6_rtchange(struct in6pcb *in6p, int errno)
if (in6p->in6p_af != AF_INET6)
return;
rtcache_free((struct route *)&in6p->in6p_route);
rtcache_free(&in6p->in6p_route);
/*
* A new route can be allocated the next time
* output is attempted.
@ -934,7 +935,7 @@ struct rtentry *
in6_pcbrtentry(in6p)
struct in6pcb *in6p;
{
struct route_in6 *ro;
struct route *ro;
const struct sockaddr_in6 *cdst;
ro = &in6p->in6p_route;
@ -942,31 +943,39 @@ in6_pcbrtentry(in6p)
if (in6p->in6p_af != AF_INET6)
return (NULL);
cdst = (const struct sockaddr_in6 *)rtcache_getdst((struct route *)ro);
if (!IN6_ARE_ADDR_EQUAL(&cdst->sin6_addr, &in6p->in6p_faddr))
rtcache_free((struct route *)ro);
cdst = (const struct sockaddr_in6 *)rtcache_getdst(ro);
if (cdst == NULL)
;
else if (!IN6_ARE_ADDR_EQUAL(&cdst->sin6_addr, &in6p->in6p_faddr))
rtcache_free(ro);
else
rtcache_check((struct route *)ro);
rtcache_check(ro);
#ifdef INET
if (ro->ro_rt == NULL && IN6_IS_ADDR_V4MAPPED(&in6p->in6p_faddr)) {
struct sockaddr_in *dst = (struct sockaddr_in *)&ro->ro_dst;
union {
struct sockaddr dst;
struct sockaddr_in dst4;
} u;
struct in_addr addr;
memset(dst, 0, sizeof(*dst));
dst->sin_family = AF_INET;
dst->sin_len = sizeof(struct sockaddr_in);
dst->sin_addr.s_addr = in6p->in6p_faddr.s6_addr32[3];
rtcache_init((struct route *)ro);
addr.s_addr = in6p->in6p_faddr.s6_addr32[3];
sockaddr_in_init(&u.dst4, &addr, 0);
rtcache_setdst(ro, &u.dst);
rtcache_init(ro);
} else
#endif
if (ro->ro_rt == NULL && !IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_faddr)) {
struct sockaddr_in6 *dst6;
union {
struct sockaddr dst;
struct sockaddr_in6 dst6;
} u;
dst6 = (struct sockaddr_in6 *)&ro->ro_dst;
memset(dst6, 0, sizeof(*dst6));
dst6->sin6_family = AF_INET6;
dst6->sin6_len = sizeof(struct sockaddr_in6);
dst6->sin6_addr = in6p->in6p_faddr;
rtcache_init((struct route *)ro);
sockaddr_in6_init(&u.dst6, &in6p->in6p_faddr, 0, 0, 0);
rtcache_setdst(ro, &u.dst);
rtcache_init(ro);
}
return ro->ro_rt;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: in6_pcb.h,v 1.31 2007/02/17 22:34:13 dyoung Exp $ */
/* $NetBSD: in6_pcb.h,v 1.32 2007/05/02 20:40:26 dyoung Exp $ */
/* $KAME: in6_pcb.h,v 1.45 2001/02/09 05:59:46 itojun Exp $ */
/*
@ -86,7 +86,7 @@ struct in6pcb {
#define in6p_socket in6p_head.inph_socket
#define in6p_table in6p_head.inph_table
#define in6p_sp in6p_head.inph_sp
struct route_in6 in6p_route; /* placeholder for routing entry */
struct route in6p_route; /* placeholder for routing entry */
u_int16_t in6p_fport; /* foreign port */
u_int16_t in6p_lport; /* local port */
u_int32_t in6p_flowinfo; /* priority and flowlabel */

View File

@ -1,4 +1,4 @@
/* $NetBSD: in6_proto.c,v 1.75 2007/03/07 22:20:04 liamjfoy Exp $ */
/* $NetBSD: in6_proto.c,v 1.76 2007/05/02 20:40:26 dyoung Exp $ */
/* $KAME: in6_proto.c,v 1.66 2000/10/10 15:35:47 itojun Exp $ */
/*
@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: in6_proto.c,v 1.75 2007/03/07 22:20:04 liamjfoy Exp $");
__KERNEL_RCSID(0, "$NetBSD: in6_proto.c,v 1.76 2007/05/02 20:40:26 dyoung Exp $");
#include "opt_inet.h"
#include "opt_ipsec.h"
@ -350,6 +350,9 @@ const struct ip6protosw inet6sw[] = {
},
};
POOL_INIT(sockaddr_in6_pool, sizeof(struct sockaddr_in6), 0, 0, 0,
"sockaddr_in6_pool", NULL, IPL_NET);
struct domain inet6domain = {
.dom_family = AF_INET6, .dom_name = "internet6",
.dom_init = NULL, .dom_externalize = NULL, .dom_dispose = NULL,
@ -361,9 +364,35 @@ struct domain inet6domain = {
.dom_ifattach = in6_domifattach, .dom_ifdetach = in6_domifdetach,
.dom_ifqueues = { &ip6intrq, NULL },
.dom_link = { NULL },
.dom_mowner = MOWNER_INIT("","")
.dom_mowner = MOWNER_INIT("",""),
.dom_sa_pool = &sockaddr_in6_pool,
.dom_sa_len = sizeof(struct sockaddr_in6),
.dom_rtcache = LIST_HEAD_INITIALIZER(inet6domain.dom_rtcache),
.dom_sockaddr_cmp = sockaddr_in6_cmp
};
int
sockaddr_in6_cmp(const struct sockaddr *lsa, const struct sockaddr *rsa)
{
uint_fast8_t len;
const uint_fast8_t addrofs = offsetof(struct sockaddr_in6, sin6_addr),
addrend = addrofs + sizeof(struct in6_addr);
int rc;
const struct sockaddr_in6 *lsin6, *rsin6;
lsin6 = satocsin6(lsa);
rsin6 = satocsin6(rsa);
len = MIN(addrend, MIN(lsin6->sin6_len, rsin6->sin6_len));
if (len > addrofs &&
(rc = memcmp(&lsin6->sin6_addr, &rsin6->sin6_addr,
len - addrofs)) != 0)
return rc;
return lsin6->sin6_len - rsin6->sin6_len;
}
/*
* Internet configuration info
*/

View File

@ -65,7 +65,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: in6_src.c,v 1.36 2007/03/04 06:03:26 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: in6_src.c,v 1.37 2007/05/02 20:40:26 dyoung Exp $");
#include "opt_inet.h"
@ -659,25 +659,14 @@ selectroute(dstsock, opts, mopts, ro, retifp, retrt, clone, norouteok)
* If the next hop is an IPv6 address, then the node identified
* by that address must be a neighbor of the sending host.
*/
ron = (struct route *)&opts->ip6po_nextroute;
if (!IN6_ARE_ADDR_EQUAL(
&satocsin6(rtcache_getdst(ron))->sin6_addr,
&sin6_next->sin6_addr))
rtcache_free(ron);
else
rtcache_check(ron);
if (ron->ro_rt == NULL) {
*satosin6(&ron->ro_dst) = *sin6_next;
rtcache_init(ron);
}
if (ron->ro_rt == NULL ||
(ron->ro_rt->rt_flags & RTF_GATEWAY) != 0 ||
!nd6_is_addr_neighbor(sin6_next, ron->ro_rt->rt_ifp)) {
ron = &opts->ip6po_nextroute;
if ((rt = rtcache_lookup(ron, sin6tosa(sin6_next))) == NULL ||
(rt->rt_flags & RTF_GATEWAY) != 0 ||
!nd6_is_addr_neighbor(sin6_next, rt->rt_ifp)) {
rtcache_free(ron);
error = EHOSTUNREACH;
goto done;
}
rt = ron->ro_rt;
ifp = rt->rt_ifp;
/*
@ -695,23 +684,15 @@ selectroute(dstsock, opts, mopts, ro, retifp, retrt, clone, norouteok)
* cached destination, in case of sharing the cache with IPv4.
*/
if (ro != NULL) {
if (rtcache_getdst(ro)->sa_family != AF_INET6 ||
!IN6_ARE_ADDR_EQUAL(&satocsin6(rtcache_getdst(ro))->sin6_addr, dst))
rtcache_free(ro);
else
rtcache_check(ro);
if (ro->ro_rt == NULL) {
struct sockaddr_in6 *sa6;
union {
struct sockaddr dst;
struct sockaddr_in6 dst6;
} u;
/* No route yet, so try to acquire one */
sa6 = satosin6(&ro->ro_dst);
*sa6 = *dstsock;
sa6->sin6_scope_id = 0;
if (clone)
rtcache_init(ro);
else
rtcache_init_noclone(ro);
}
/* No route yet, so try to acquire one */
u.dst6 = *dstsock;
u.dst6.sin6_scope_id = 0;
rt = rtcache_lookup1(ro, &u.dst, clone);
/*
* do not care about the result if we have the nexthop
@ -720,11 +701,10 @@ selectroute(dstsock, opts, mopts, ro, retifp, retrt, clone, norouteok)
if (opts && opts->ip6po_nexthop)
goto done;
if (ro->ro_rt == NULL)
if (rt == NULL)
error = EHOSTUNREACH;
else
ifp = ro->ro_rt->rt_ifp;
rt = ro->ro_rt;
ifp = rt->rt_ifp;
/*
* Check if the outgoing interface conflicts with

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip6_etherip.c,v 1.4 2007/02/17 22:34:13 dyoung Exp $ */
/* $NetBSD: ip6_etherip.c,v 1.5 2007/05/02 20:40:26 dyoung Exp $ */
/*
* Copyright (c) 2006, Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
@ -98,14 +98,15 @@ int
ip6_etherip_output(struct ifnet *ifp, struct mbuf *m)
{
struct etherip_softc *sc = (struct etherip_softc *)ifp->if_softc;
struct sockaddr_in6 *dst, *sin6_src, *sin6_dst;
const struct sockaddr_in6 *cdst;
struct sockaddr_in6 *sin6_src, *sin6_dst;
struct ip6_hdr *ip6; /* capsule IP header, host byte ordered */
struct etherip_header eiphdr;
int proto, error;
union {
struct sockaddr dst;
struct sockaddr_in6 dst6;
} u;
dst = (struct sockaddr_in6 *)&sc->sc_ro.ro_dst;
cdst = satocsin6(rtcache_getdst(&sc->sc_ro));
sin6_src = (struct sockaddr_in6 *)sc->sc_src;
sin6_dst = (struct sockaddr_in6 *)sc->sc_dst;
@ -160,26 +161,14 @@ ip6_etherip_output(struct ifnet *ifp, struct mbuf *m)
return ENETUNREACH;
}
if (cdst->sin6_family != sin6_dst->sin6_family ||
!IN6_ARE_ADDR_EQUAL(&cdst->sin6_addr, &sin6_dst->sin6_addr))
rtcache_free((struct route *)&sc->sc_ro6);
else
rtcache_check((struct route *)&sc->sc_ro6);
if (sc->sc_ro6.ro_rt == NULL) {
memset(dst, 0, sizeof(*dst));
dst->sin6_family = sin6_dst->sin6_family;
dst->sin6_len = sizeof(struct sockaddr_in6);
dst->sin6_addr = sin6_dst->sin6_addr;
rtcache_init((struct route *)&sc->sc_ro6);
if (sc->sc_ro6.ro_rt == NULL) {
m_freem(m);
return ENETUNREACH;
}
sockaddr_in6_init(&u.dst6, &sin6_dst->sin6_addr, 0, 0, 0);
if (rtcache_lookup(&sc->sc_ro, &u.dst) == NULL) {
m_freem(m);
return ENETUNREACH;
}
/* if it constitutes infinite encapsulation, punt. */
if (sc->sc_ro.ro_rt->rt_ifp == ifp) {
rtcache_free((struct route *)&sc->sc_ro6);
rtcache_free(&sc->sc_ro);
m_freem(m);
return ENETUNREACH; /* XXX */
}
@ -189,8 +178,7 @@ ip6_etherip_output(struct ifnet *ifp, struct mbuf *m)
* it is too painful to ask for resend of inner packet, to achieve
* path MTU discovery for encapsulated packets.
*/
error = ip6_output(m, 0, &sc->sc_ro6, IPV6_MINMTU,
(struct ip6_moptions *)NULL, (struct socket *)NULL, NULL);
error = ip6_output(m, 0, &sc->sc_ro, IPV6_MINMTU, NULL, NULL, NULL);
return error;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip6_flow.c,v 1.6 2007/04/05 18:12:49 liamjfoy Exp $ */
/* $NetBSD: ip6_flow.c,v 1.7 2007/05/02 20:40:26 dyoung Exp $ */
/*-
* Copyright (c) 2007 The NetBSD Foundation, Inc.
@ -212,7 +212,7 @@ ip6flow_fastforward(struct mbuf *m)
struct ip6flow *ip6f;
struct ip6_hdr *ip6;
struct rtentry *rt;
struct sockaddr_in6 *dst;
const struct sockaddr *dst;
int error;
/*
@ -269,7 +269,7 @@ ip6flow_fastforward(struct mbuf *m)
/*
* Route and interface still up?
*/
rtcache_check((struct route *)&ip6f->ip6f_ro);
rtcache_check(&ip6f->ip6f_ro);
rt = ip6f->ip6f_ro.ro_rt;
if (rt == NULL || (rt->rt_ifp->if_flags & IFF_UP) == 0) {
/* Route or interface is down */
@ -291,17 +291,16 @@ ip6flow_fastforward(struct mbuf *m)
ip6->ip6_hlim -= IPV6_HLIMDEC;
if (rt->rt_flags & RTF_GATEWAY)
dst = (struct sockaddr_in6 *)rt->rt_gateway;
dst = rt->rt_gateway;
else
dst = &ip6f->ip6f_ro.ro_dst;
dst = rtcache_getdst(&ip6f->ip6f_ro);
PRT_SLOW_ARM(ip6f->ip6f_timer, IP6FLOW_TIMER);
ip6f->ip6f_uses++;
/* Send on its way - straight to the interface output routine. */
if ((error = (*rt->rt_ifp->if_output)(rt->rt_ifp, m,
(struct sockaddr *)dst, rt)) != 0) {
if ((error = (*rt->rt_ifp->if_output)(rt->rt_ifp, m, dst, rt)) != 0) {
ip6f->ip6f_dropped++;
} else {
ip6f->ip6f_forwarded++;
@ -316,7 +315,7 @@ ip6flow_fastforward(struct mbuf *m)
static void
ip6flow_addstats(struct ip6flow *ip6f)
{
rtcache_check((struct route *)&ip6f->ip6f_ro);
rtcache_check(&ip6f->ip6f_ro);
if (ip6f->ip6f_ro.ro_rt != NULL)
ip6f->ip6f_ro.ro_rt->rt_use += ip6f->ip6f_uses;
ip6stat.ip6s_fastforwardflows = ip6flow_inuse;
@ -345,7 +344,7 @@ ip6flow_free(struct ip6flow *ip6f)
splx(s);
ip6flow_inuse--;
ip6flow_addstats(ip6f);
rtcache_free((struct route *)&ip6f->ip6f_ro);
rtcache_free(&ip6f->ip6f_ro);
pool_put(&ip6flow_pool, ip6f);
}
@ -366,7 +365,7 @@ ip6flow_reap(int just_one)
* If this no longer points to a valid route -
* reclaim it.
*/
rtcache_check((struct route *)&ip6f->ip6f_ro);
rtcache_check(&ip6f->ip6f_ro);
if (ip6f->ip6f_ro.ro_rt == NULL)
goto done;
/*
@ -391,7 +390,7 @@ ip6flow_reap(int just_one)
s = splnet();
IP6FLOW_REMOVE(ip6f);
splx(s);
rtcache_free((struct route *)&ip6f->ip6f_ro);
rtcache_free(&ip6f->ip6f_ro);
if (just_one) {
ip6flow_addstats(ip6f);
return ip6f;
@ -410,7 +409,7 @@ ip6flow_slowtimo(void)
for (ip6f = LIST_FIRST(&ip6flowlist); ip6f != NULL; ip6f = next_ip6f) {
next_ip6f = LIST_NEXT(ip6f, ip6f_list);
rtcache_check((struct route *)&ip6f->ip6f_ro);
rtcache_check(&ip6f->ip6f_ro);
if (PRT_SLOW_ISEXPIRED(ip6f->ip6f_timer) ||
ip6f->ip6f_ro.ro_rt == NULL) {
ip6flow_free(ip6f);
@ -429,7 +428,7 @@ ip6flow_slowtimo(void)
* IPv6 stack. Now create/update a flow.
*/
void
ip6flow_create(const struct route_in6 *ro, struct mbuf *m)
ip6flow_create(const struct route *ro, struct mbuf *m)
{
struct ip6_hdr *ip6;
struct ip6flow *ip6f;
@ -474,7 +473,7 @@ ip6flow_create(const struct route_in6 *ro, struct mbuf *m)
IP6FLOW_REMOVE(ip6f);
splx(s);
ip6flow_addstats(ip6f);
rtcache_free((struct route *)&ip6f->ip6f_ro);
rtcache_free(&ip6f->ip6f_ro);
ip6f->ip6f_uses = 0;
ip6f->ip6f_last_uses = 0;
ip6f->ip6f_dropped = 0;
@ -484,8 +483,7 @@ ip6flow_create(const struct route_in6 *ro, struct mbuf *m)
/*
* Fill in the updated/new details.
*/
rtcache_copy((struct route *)&ip6f->ip6f_ro, (const struct route *)ro,
sizeof(ip6f->ip6f_ro));
rtcache_copy(&ip6f->ip6f_ro, ro);
ip6f->ip6f_dst = ip6->ip6_dst;
ip6f->ip6f_src = ip6->ip6_src;
ip6f->ip6f_flow = ip6->ip6_flow;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip6_forward.c,v 1.56 2007/03/07 22:20:04 liamjfoy Exp $ */
/* $NetBSD: ip6_forward.c,v 1.57 2007/05/02 20:40:26 dyoung Exp $ */
/* $KAME: ip6_forward.c,v 1.109 2002/09/11 08:10:17 sakane Exp $ */
/*
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ip6_forward.c,v 1.56 2007/03/07 22:20:04 liamjfoy Exp $");
__KERNEL_RCSID(0, "$NetBSD: ip6_forward.c,v 1.57 2007/05/02 20:40:26 dyoung Exp $");
#include "opt_ipsec.h"
#include "opt_pfil_hooks.h"
@ -78,7 +78,7 @@ __KERNEL_RCSID(0, "$NetBSD: ip6_forward.c,v 1.56 2007/03/07 22:20:04 liamjfoy Ex
#include <net/net_osdep.h>
struct route_in6 ip6_forward_rt;
struct route ip6_forward_rt;
#ifdef PFIL_HOOKS
extern struct pfil_head inet6_pfil_hook; /* XXX */
@ -103,7 +103,7 @@ ip6_forward(m, srcrt)
int srcrt;
{
struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *);
struct sockaddr_in6 *dst;
const struct sockaddr_in6 *dst;
struct rtentry *rt;
int error = 0, type = 0, code = 0;
struct mbuf *mcopy = NULL;
@ -337,7 +337,7 @@ ip6_forward(m, srcrt)
/* adjust pointer */
rt = state.ro ? state.ro->ro_rt : NULL;
dst = (struct sockaddr_in6 *)state.dst;
dst = (const struct sockaddr_in6 *)state.dst;
if (dst != NULL && rt != NULL) {
ipsecrt = 1;
goto skip_routing;
@ -362,16 +362,14 @@ ip6_forward(m, srcrt)
}
#endif /* FAST_IPSEC */
dst = &ip6_forward_rt.ro_dst;
if (!srcrt) {
/*
* ip6_forward_rt.ro_dst.sin6_addr is equal to ip6->ip6_dst
* rtcache_getdst(ip6_forward_rt)->sin6_addr is equal to
* ip6->ip6_dst
*/
rtcache_check((struct route *)&ip6_forward_rt);
rtcache_check(&ip6_forward_rt);
if (ip6_forward_rt.ro_rt == NULL) {
rtcache_init((struct route *)&ip6_forward_rt);
rtcache_init(&ip6_forward_rt);
if (ip6_forward_rt.ro_rt == NULL) {
ip6stat.ip6s_noroute++;
@ -385,18 +383,13 @@ ip6_forward(m, srcrt)
}
}
} else {
if (!IN6_ARE_ADDR_EQUAL(&ip6->ip6_dst, &dst->sin6_addr))
rtcache_free((struct route *)&ip6_forward_rt);
else
rtcache_check((struct route *)&ip6_forward_rt);
if (ip6_forward_rt.ro_rt == NULL) {
memset(dst, 0, sizeof(*dst));
dst->sin6_len = sizeof(struct sockaddr_in6);
dst->sin6_family = AF_INET6;
dst->sin6_addr = ip6->ip6_dst;
rtcache_init((struct route *)&ip6_forward_rt);
}
if (ip6_forward_rt.ro_rt == NULL) {
union {
struct sockaddr dst;
struct sockaddr_in6 dst6;
} u;
sockaddr_in6_init(&u.dst6, &ip6->ip6_dst, 0, 0, 0);
if (rtcache_lookup(&ip6_forward_rt, &u.dst) == NULL) {
ip6stat.ip6s_noroute++;
/* XXX in6_ifstat_inc(rt->rt_ifp, ifs6_in_noroute) */
if (mcopy) {
@ -407,6 +400,7 @@ ip6_forward(m, srcrt)
return;
}
}
dst = satocsin6(rtcache_getdst(&ip6_forward_rt));
rt = ip6_forward_rt.ro_rt;
#ifdef IPSEC
skip_routing:;
@ -553,7 +547,7 @@ ip6_forward(m, srcrt)
(rt->rt_flags & (RTF_DYNAMIC|RTF_MODIFIED)) == 0) {
if ((rt->rt_ifp->if_flags & IFF_POINTOPOINT) &&
nd6_is_addr_neighbor(
satocsin6(rtcache_getdst((struct route *)&ip6_forward_rt)),
satocsin6(rtcache_getdst(&ip6_forward_rt)),
rt->rt_ifp)) {
/*
* If the incoming interface is equal to the outgoing

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip6_input.c,v 1.102 2007/04/22 19:47:41 christos Exp $ */
/* $NetBSD: ip6_input.c,v 1.103 2007/05/02 20:40:27 dyoung Exp $ */
/* $KAME: ip6_input.c,v 1.188 2001/03/29 05:34:31 itojun Exp $ */
/*
@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ip6_input.c,v 1.102 2007/04/22 19:47:41 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: ip6_input.c,v 1.103 2007/05/02 20:40:27 dyoung Exp $");
#include "opt_inet.h"
#include "opt_inet6.h"
@ -237,7 +237,7 @@ ip6intr()
}
}
extern struct route_in6 ip6_forward_rt;
extern struct route ip6_forward_rt;
void
ip6_input(struct mbuf *m)
@ -249,6 +249,7 @@ ip6_input(struct mbuf *m)
int nxt, ours = 0;
struct ifnet *deliverifp = NULL;
int srcrt = 0;
const struct sockaddr_in6 *cdst;
#ifdef FAST_IPSEC
struct m_tag *mtag;
struct tdb_ident *tdbi;
@ -474,29 +475,31 @@ ip6_input(struct mbuf *m)
goto hbhcheck;
}
cdst = satocsin6(rtcache_getdst(&ip6_forward_rt));
/*
* Unicast check
*/
if (!IN6_ARE_ADDR_EQUAL(&ip6->ip6_dst,
&((const struct sockaddr_in6 *)rtcache_getdst((const struct route *)&ip6_forward_rt))->sin6_addr))
rtcache_free((struct route *)&ip6_forward_rt);
if (cdst == NULL)
;
else if (!IN6_ARE_ADDR_EQUAL(&ip6->ip6_dst, &cdst->sin6_addr))
rtcache_free(&ip6_forward_rt);
else
rtcache_check((struct route *)&ip6_forward_rt);
rtcache_check(&ip6_forward_rt);
if (ip6_forward_rt.ro_rt != NULL) {
/* XXX Revalidated route is accounted wrongly. */
ip6stat.ip6s_forward_cachehit++;
} else {
struct sockaddr_in6 *dst6;
union {
struct sockaddr dst;
struct sockaddr_in6 dst6;
} u;
ip6stat.ip6s_forward_cachemiss++;
dst6 = &ip6_forward_rt.ro_dst;
memset(dst6, 0, sizeof(*dst6));
dst6->sin6_len = sizeof(struct sockaddr_in6);
dst6->sin6_family = AF_INET6;
dst6->sin6_addr = ip6->ip6_dst;
sockaddr_in6_init(&u.dst6, &ip6->ip6_dst, 0, 0, 0);
rtcache_setdst(&ip6_forward_rt, &u.dst);
rtcache_init((struct route *)&ip6_forward_rt);
rtcache_init(&ip6_forward_rt);
}
#define rt6_key(r) ((struct sockaddr_in6 *)((r)->rt_nodes->rn_key))

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip6_mroute.c,v 1.79 2007/03/04 06:03:26 christos Exp $ */
/* $NetBSD: ip6_mroute.c,v 1.80 2007/05/02 20:40:27 dyoung Exp $ */
/* $KAME: ip6_mroute.c,v 1.49 2001/07/25 09:21:18 jinmei Exp $ */
/*
@ -117,7 +117,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ip6_mroute.c,v 1.79 2007/03/04 06:03:26 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: ip6_mroute.c,v 1.80 2007/05/02 20:40:27 dyoung Exp $");
#include "opt_inet.h"
#include "opt_mrouting.h"
@ -1553,7 +1553,7 @@ phyint_send(ip6, mifp, m)
struct ifnet *ifp = mifp->m6_ifp;
int error = 0;
int s;
static struct route_in6 ro;
static struct route ro;
struct in6_multi *in6m;
struct sockaddr_in6 dst6;
u_long linkmtu;
@ -1617,7 +1617,7 @@ phyint_send(ip6, mifp, m)
IN6_LOOKUP_MULTI(ip6->ip6_dst, ifp, in6m);
if (in6m != NULL) {
ip6_mloopback(ifp, m,
satocsin6(rtcache_getdst((struct route *)&ro)));
satocsin6(rtcache_getdst(&ro)));
}
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip6_output.c,v 1.117 2007/03/04 06:03:26 christos Exp $ */
/* $NetBSD: ip6_output.c,v 1.118 2007/05/02 20:40:27 dyoung Exp $ */
/* $KAME: ip6_output.c,v 1.172 2001/03/25 09:55:56 itojun Exp $ */
/*
@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ip6_output.c,v 1.117 2007/03/04 06:03:26 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: ip6_output.c,v 1.118 2007/05/02 20:40:27 dyoung Exp $");
#include "opt_inet.h"
#include "opt_inet6.h"
@ -137,7 +137,7 @@ static int ip6_insertfraghdr __P((struct mbuf *, struct mbuf *, int,
struct ip6_frag **));
static int ip6_insert_jumboopt __P((struct ip6_exthdrs *, u_int32_t));
static int ip6_splithdr __P((struct mbuf *, struct ip6_exthdrs *));
static int ip6_getpmtu(struct route_in6 *, struct route_in6 *, struct ifnet *,
static int ip6_getpmtu(struct route *, struct route *, struct ifnet *,
const struct in6_addr *, u_long *, int *);
static int copypktopts __P((struct ip6_pktopts *, struct ip6_pktopts *, int));
@ -166,7 +166,7 @@ int
ip6_output(
struct mbuf *m0,
struct ip6_pktopts *opt,
struct route_in6 *ro,
struct route *ro,
int flags,
struct ip6_moptions *im6o,
struct socket *so,
@ -178,9 +178,10 @@ ip6_output(
struct mbuf *m = m0;
int hlen, tlen, len, off;
bool tso;
struct route_in6 ip6route;
struct route ip6route;
struct rtentry *rt = NULL;
struct sockaddr_in6 *dst, src_sa, dst_sa;
const struct sockaddr_in6 *dst = NULL;
struct sockaddr_in6 src_sa, dst_sa;
int error = 0;
struct in6_ifaddr *ia = NULL;
u_long mtu;
@ -189,7 +190,7 @@ ip6_output(
struct ip6_exthdrs exthdrs;
struct in6_addr finaldst, src0, dst0;
u_int32_t zone;
struct route_in6 *ro_pmtu = NULL;
struct route *ro_pmtu = NULL;
int hdrsplit = 0;
int needipsec = 0;
#ifdef IPSEC
@ -575,7 +576,6 @@ skip_ipsec2:;
ro_pmtu = ro;
if (opt && opt->ip6po_rthdr)
ro = &opt->ip6po_route;
dst = (struct sockaddr_in6 *)&ro->ro_dst;
/*
* if specified, try to fill in the traffic class field.
@ -620,14 +620,14 @@ skip_ipsec2:;
bzero(&state, sizeof(state));
state.m = m;
state.ro = (struct route *)ro;
state.dst = (struct sockaddr *)dst;
state.ro = ro;
state.dst = rtcache_getdst(ro);
error = ipsec6_output_tunnel(&state, sp, flags);
m = state.m;
ro_pmtu = ro = (struct route_in6 *)state.ro;
dst = (struct sockaddr_in6 *)state.dst;
ro_pmtu = ro = state.ro;
dst = satocsin6(state.dst);
if (error) {
/* mbuf is already reclaimed in ipsec6_output_tunnel. */
m0 = m = NULL;
@ -668,7 +668,7 @@ skip_ipsec2:;
error = 0;
splx(s);
goto done;
}
}
#endif /* FAST_IPSEC */
@ -680,7 +680,7 @@ skip_ipsec2:;
dst_sa.sin6_family = AF_INET6;
dst_sa.sin6_len = sizeof(dst_sa);
dst_sa.sin6_addr = ip6->ip6_dst;
if ((error = in6_selectroute(&dst_sa, opt, im6o, (struct route *)ro,
if ((error = in6_selectroute(&dst_sa, opt, im6o, ro,
&ifp, &rt, 0)) != 0) {
switch (error) {
case EHOSTUNREACH:
@ -699,7 +699,7 @@ skip_ipsec2:;
* If in6_selectroute() does not return a route entry,
* dst may not have been updated.
*/
*dst = dst_sa; /* XXX */
rtcache_setdst(ro, sin6tosa(&dst_sa));
}
/*
@ -746,27 +746,22 @@ skip_ipsec2:;
goto badscope;
/* scope check is done. */
goto routefound;
badscope:
ip6stat.ip6s_badscope++;
in6_ifstat_inc(origifp, ifs6_out_discard);
if (error == 0)
error = EHOSTUNREACH; /* XXX */
goto bad;
routefound:
if (rt && !IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst)) {
if (opt && opt->ip6po_nextroute.ro_rt != NULL) {
/*
* The nexthop is explicitly specified by the
* application. We assume the next hop is an IPv6
* address.
*/
dst = (struct sockaddr_in6 *)opt->ip6po_nexthop;
} else if ((rt->rt_flags & RTF_GATEWAY))
dst = (struct sockaddr_in6 *)rt->rt_gateway;
}
if (rt == NULL || IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst)) {
if (dst == NULL)
dst = satocsin6(rtcache_getdst(ro));
KASSERT(dst != NULL);
} else if (opt && opt->ip6po_nextroute.ro_rt != NULL) {
/*
* The nexthop is explicitly specified by the
* application. We assume the next hop is an IPv6
* address.
*/
dst = (struct sockaddr_in6 *)opt->ip6po_nexthop;
} else if ((rt->rt_flags & RTF_GATEWAY))
dst = (struct sockaddr_in6 *)rt->rt_gateway;
else if (dst == NULL)
dst = satocsin6(rtcache_getdst(ro));
/*
* XXXXXX: original code follows:
@ -798,6 +793,7 @@ skip_ipsec2:;
* on the outgoing interface, and the caller did not
* forbid loopback, loop back a copy.
*/
KASSERT(dst != NULL);
ip6_mloopback(ifp, m, dst);
} else {
/*
@ -967,7 +963,7 @@ skip_ipsec2:;
bzero(&ip6cp, sizeof(ip6cp));
ip6cp.ip6c_cmdarg = (void *)&mtu32;
pfctlinput2(PRC_MSGSIZE,
rtcache_getdst((struct route *)ro_pmtu), &ip6cp);
rtcache_getdst(ro_pmtu), &ip6cp);
error = EMSGSIZE;
goto bad;
@ -1001,6 +997,7 @@ skip_ipsec2:;
m->m_pkthdr.csum_flags &= ~(M_CSUM_UDPv6|M_CSUM_TCPv6);
}
KASSERT(dst != NULL);
if (__predict_true(!tso ||
(ifp->if_capenable & IFCAP_TSOv6) != 0)) {
error = nd6_output(ifp, origifp, m, dst, rt);
@ -1063,7 +1060,7 @@ skip_ipsec2:;
bzero(&ip6cp, sizeof(ip6cp));
ip6cp.ip6c_cmdarg = (void *)&mtu32;
pfctlinput2(PRC_MSGSIZE,
rtcache_getdst((struct route *)ro_pmtu), &ip6cp);
rtcache_getdst(ro_pmtu), &ip6cp);
#endif
len = (mtu - hlen - sizeof(struct ip6_frag)) & ~7;
@ -1184,6 +1181,7 @@ sendorfree:
/* clean ipsec history once it goes out of the node */
ipsec_delaux(m);
#endif
KASSERT(dst != NULL);
error = nd6_output(ifp, origifp, m, dst, rt);
} else
m_freem(m);
@ -1195,9 +1193,9 @@ sendorfree:
done:
/* XXX Second if is invariant? */
if (ro == &ip6route)
rtcache_free((struct route *)ro);
rtcache_free(ro);
else if (ro_pmtu == &ip6route)
rtcache_free((struct route *)ro_pmtu);
rtcache_free(ro_pmtu);
#ifdef IPSEC
if (sp != NULL)
@ -1220,6 +1218,12 @@ freehdrs:
bad:
m_freem(m);
goto done;
badscope:
ip6stat.ip6s_badscope++;
in6_ifstat_inc(origifp, ifs6_out_discard);
if (error == 0)
error = EHOSTUNREACH; /* XXX */
goto bad;
}
static int
@ -1423,29 +1427,22 @@ ip6_insertfraghdr(m0, m, hlen, frghdrp)
}
static int
ip6_getpmtu(struct route_in6 *ro_pmtu, struct route_in6 *ro, struct ifnet *ifp,
ip6_getpmtu(struct route *ro_pmtu, struct route *ro, struct ifnet *ifp,
const struct in6_addr *dst, u_long *mtup, int *alwaysfragp)
{
u_int32_t mtu = 0;
int alwaysfrag = 0;
int error = 0;
const struct sockaddr_in6 *cdst;
if (ro_pmtu != ro) {
union {
struct sockaddr dst;
struct sockaddr_in6 dst6;
} u;
/* The first hop and the final destination may differ. */
cdst = (const struct sockaddr_in6 *)rtcache_getdst((struct route *)ro_pmtu);
if (!IN6_ARE_ADDR_EQUAL(&cdst->sin6_addr, dst))
rtcache_free((struct route *)ro_pmtu);
else
rtcache_check((struct route *)ro_pmtu);
if (ro_pmtu->ro_rt == NULL) {
struct sockaddr_in6 *sa6_dst = &ro_pmtu->ro_dst;
memset(sa6_dst, 0, sizeof(*sa6_dst)); /* for safety */
sa6_dst->sin6_family = AF_INET6;
sa6_dst->sin6_len = sizeof(struct sockaddr_in6);
sa6_dst->sin6_addr = *dst;
rtcache_init((struct route *)ro_pmtu);
}
sockaddr_in6_init(&u.dst6, dst, 0, 0, 0);
rtcache_lookup(ro_pmtu, &u.dst);
}
if (ro_pmtu->ro_rt != NULL) {
u_int32_t ifmtu;
@ -2002,8 +1999,7 @@ do { \
{
u_long pmtu = 0;
struct ip6_mtuinfo mtuinfo;
struct route_in6 *ro = (struct route_in6 *)&in6p
->in6p_route;
struct route *ro = &in6p->in6p_route;
if (!(so->so_state & SS_ISCONNECTED))
return (ENOTCONN);
@ -2389,7 +2385,7 @@ ip6_clearpktopts(struct ip6_pktopts *pktopt, int optname)
if (optname == -1 || optname == IPV6_TCLASS)
pktopt->ip6po_tclass = -1;
if (optname == -1 || optname == IPV6_NEXTHOP) {
rtcache_free((struct route *)&pktopt->ip6po_nextroute);
rtcache_free(&pktopt->ip6po_nextroute);
if (pktopt->ip6po_nexthop)
free(pktopt->ip6po_nexthop, M_IP6OPT);
pktopt->ip6po_nexthop = NULL;
@ -2408,7 +2404,7 @@ ip6_clearpktopts(struct ip6_pktopts *pktopt, int optname)
if (pktopt->ip6po_rhinfo.ip6po_rhi_rthdr)
free(pktopt->ip6po_rhinfo.ip6po_rhi_rthdr, M_IP6OPT);
pktopt->ip6po_rhinfo.ip6po_rhi_rthdr = NULL;
rtcache_free((struct route *)&pktopt->ip6po_route);
rtcache_free(&pktopt->ip6po_route);
}
if (optname == -1 || optname == IPV6_DSTOPTS) {
if (pktopt->ip6po_dest2)
@ -2511,7 +2507,7 @@ ip6_setmoptions(optname, im6op, m)
struct ipv6_mreq *mreq;
struct ifnet *ifp;
struct ip6_moptions *im6o = *im6op;
struct route_in6 ro;
struct route ro;
struct in6_multi_mship *imm;
struct lwp *l = curlwp; /* XXX */
@ -2627,7 +2623,10 @@ ip6_setmoptions(optname, im6op, m)
* appropriate one according to the given multicast address.
*/
if (mreq->ipv6mr_interface == 0) {
struct sockaddr_in6 *dst;
union {
struct sockaddr dst;
struct sockaddr_in6 dst6;
} u;
/*
* Look up the routing table for the
@ -2635,13 +2634,12 @@ ip6_setmoptions(optname, im6op, m)
* XXX: is it a good approach?
*/
memset(&ro, 0, sizeof(ro));
dst = &ro.ro_dst;
dst->sin6_family = AF_INET6;
dst->sin6_len = sizeof(*dst);
dst->sin6_addr = mreq->ipv6mr_multiaddr;
rtcache_init((struct route *)&ro);
sockaddr_in6_init(&u.dst6, &mreq->ipv6mr_multiaddr, 0,
0, 0);
rtcache_setdst(&ro, &u.dst);
rtcache_init(&ro);
ifp = (ro.ro_rt != NULL) ? ro.ro_rt->rt_ifp : NULL;
rtcache_free((struct route *)&ro);
rtcache_free(&ro);
} else {
/*
* If the interface is specified, validate it.

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip6_var.h,v 1.42 2007/04/22 20:06:07 christos Exp $ */
/* $NetBSD: ip6_var.h,v 1.43 2007/05/02 20:40:27 dyoung Exp $ */
/* $KAME: ip6_var.h,v 1.33 2000/06/11 14:59:20 jinmei Exp $ */
/*
@ -64,6 +64,8 @@
#ifndef _NETINET6_IP6_VAR_H_
#define _NETINET6_IP6_VAR_H_
#include <net/route.h>
/*
* IP6 reassembly queue structure. Each fragment
* being reassembled is attached to one of these structures.
@ -119,7 +121,7 @@ struct ip6_moptions {
/* Routing header related info */
struct ip6po_rhinfo {
struct ip6_rthdr *ip6po_rhi_rthdr; /* Routing header */
struct route_in6 ip6po_rhi_route; /* Route to the 1st hop */
struct route ip6po_rhi_route; /* Route to the 1st hop */
};
#define ip6po_rthdr ip6po_rhinfo.ip6po_rhi_rthdr
#define ip6po_route ip6po_rhinfo.ip6po_rhi_route
@ -127,7 +129,7 @@ struct ip6po_rhinfo {
/* Nexthop related info */
struct ip6po_nhinfo {
struct sockaddr *ip6po_nhi_nexthop;
struct route_in6 ip6po_nhi_route; /* Route to the nexthop */
struct route ip6po_nhi_route; /* Route to the nexthop */
};
#define ip6po_nexthop ip6po_nhinfo.ip6po_nhi_nexthop
#define ip6po_nextroute ip6po_nhinfo.ip6po_nhi_route
@ -228,7 +230,7 @@ struct ip6flow {
LIST_ENTRY(ip6flow) ip6f_hash; /* next ip6flow in bucket */
struct in6_addr ip6f_dst; /* destination address */
struct in6_addr ip6f_src; /* source address */
struct route_in6 ip6f_ro; /* associated route entry */
struct route ip6f_ro; /* associated route entry */
u_int32_t ip6f_flow; /* flow (tos) */
u_quad_t ip6f_uses; /* number of uses in this period */
u_quad_t ip6f_last_uses; /* number of uses in last period */
@ -339,7 +341,7 @@ void ip6_forward(struct mbuf *, int);
void ip6_mloopback(struct ifnet *, struct mbuf *,
const struct sockaddr_in6 *);
int ip6_output(struct mbuf *, struct ip6_pktopts *,
struct route_in6 *, int,
struct route *, int,
struct ip6_moptions *, struct socket *,
struct ifnet **);
int ip6_ctloutput(int, struct socket *, int, int, struct mbuf **);
@ -360,7 +362,7 @@ void frag6_drain(void);
int ip6flow_init(int);
struct ip6flow *ip6flow_reap(int);
void ip6flow_create(const struct route_in6 *, struct mbuf *);
void ip6flow_create(const struct route *, struct mbuf *);
void ip6flow_slowtimo(void);
int ip6flow_invalidate_all(int);

View File

@ -1,4 +1,4 @@
/* $NetBSD: ipsec.c,v 1.116 2007/03/25 12:46:42 degroote Exp $ */
/* $NetBSD: ipsec.c,v 1.117 2007/05/02 20:40:27 dyoung Exp $ */
/* $KAME: ipsec.c,v 1.136 2002/05/19 00:36:39 itojun Exp $ */
/*
@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ipsec.c,v 1.116 2007/03/25 12:46:42 degroote Exp $");
__KERNEL_RCSID(0, "$NetBSD: ipsec.c,v 1.117 2007/05/02 20:40:27 dyoung Exp $");
#include "opt_inet.h"
#include "opt_ipsec.h"
@ -2621,14 +2621,16 @@ ipsec4_checksa(isr, state)
* IPsec output logic for IPv4.
*/
int
ipsec4_output(struct ipsec_output_state *state, struct secpolicy *sp,
int flags)
ipsec4_output(struct ipsec_output_state *state, struct secpolicy *sp, int flags)
{
struct ip *ip = NULL;
struct ipsecrequest *isr = NULL;
int s;
int error;
struct sockaddr_in *dst4;
union {
struct sockaddr dst;
struct sockaddr_in dst4;
} u;
if (!state)
panic("state == NULL in ipsec4_output");
@ -2732,28 +2734,20 @@ ipsec4_output(struct ipsec_output_state *state, struct secpolicy *sp,
ip = mtod(state->m, struct ip *);
state->ro = &isr->sav->sah->sa_route;
state->dst = (struct sockaddr *)&state->ro->ro_dst;
dst4 = (struct sockaddr_in *)state->dst;
if (dst4->sin_addr.s_addr != ip->ip_dst.s_addr)
sockaddr_in_init(&u.dst4, &ip->ip_dst, 0);
if (rtcache_lookup(state->ro, &u.dst) == NULL) {
rtcache_free(state->ro);
else
rtcache_check(state->ro);
if (state->ro->ro_rt == NULL) {
dst4->sin_family = AF_INET;
dst4->sin_len = sizeof(*dst4);
dst4->sin_addr = ip->ip_dst;
rtcache_init(state->ro);
if (state->ro->ro_rt == NULL) {
ipstat.ips_noroute++;
error = EHOSTUNREACH;
goto bad;
}
ipstat.ips_noroute++;
error = EHOSTUNREACH;
goto bad;
}
/* adjust state->dst if tunnel endpoint is offlink */
if (state->ro->ro_rt->rt_flags & RTF_GATEWAY) {
state->dst = (struct sockaddr *)state->ro->ro_rt->rt_gateway;
dst4 = (struct sockaddr_in *)state->dst;
state->dst = state->ro->ro_rt->rt_gateway;
} else {
state->dst = rtcache_getdst(state->ro);
}
state->encap++;
@ -3023,7 +3017,6 @@ ipsec6_output_tunnel(struct ipsec_output_state *state, struct secpolicy *sp,
struct ipsecrequest *isr = NULL;
int error = 0;
int plen;
struct sockaddr_in6* dst6;
int s;
if (!state)
@ -3120,31 +3113,26 @@ ipsec6_output_tunnel(struct ipsec_output_state *state, struct secpolicy *sp,
ip6 = mtod(state->m, struct ip6_hdr *);
state->ro = &isr->sav->sah->sa_route;
state->dst = (struct sockaddr *)&state->ro->ro_dst;
dst6 = (struct sockaddr_in6 *)state->dst;
if (!IN6_ARE_ADDR_EQUAL(&dst6->sin6_addr, &ip6->ip6_dst))
rtcache_free(state->ro);
else
rtcache_check(state->ro);
union {
struct sockaddr dst;
struct sockaddr_in6 dst6;
} u;
sockaddr_in6_init(&u.dst6, &ip6->ip6_dst, 0, 0, 0);
rtcache_lookup(state->ro, &u.dst);
if (state->ro->ro_rt == NULL) {
bzero(dst6, sizeof(*dst6));
dst6->sin6_family = AF_INET6;
dst6->sin6_len = sizeof(*dst6);
dst6->sin6_addr = ip6->ip6_dst;
rtcache_init(state->ro);
if (state->ro->ro_rt == NULL) {
ip6stat.ip6s_noroute++;
ipsec6stat.out_noroute++;
error = EHOSTUNREACH;
goto bad;
}
rtcache_free(state->ro);
ip6stat.ip6s_noroute++;
ipsec6stat.out_noroute++;
error = EHOSTUNREACH;
goto bad;
}
/* adjust state->dst if tunnel endpoint is offlink */
if (state->ro->ro_rt->rt_flags & RTF_GATEWAY) {
state->dst = (struct sockaddr *)state->ro->ro_rt->rt_gateway;
dst6 = (struct sockaddr_in6 *)state->dst;
}
state->dst = state->ro->ro_rt->rt_gateway;
} else
state->dst = rtcache_getdst(state->ro);
} else
splx(s);

View File

@ -1,4 +1,4 @@
/* $NetBSD: ipsec.h,v 1.46 2007/03/04 06:03:27 christos Exp $ */
/* $NetBSD: ipsec.h,v 1.47 2007/05/02 20:40:27 dyoung Exp $ */
/* $KAME: ipsec.h,v 1.51 2001/08/05 04:52:58 itojun Exp $ */
/*
@ -308,7 +308,7 @@ struct ipsecstat {
struct ipsec_output_state {
struct mbuf *m;
struct route *ro;
struct sockaddr *dst;
const struct sockaddr *dst;
int encap;
};

View File

@ -1,4 +1,4 @@
/* $NetBSD: nd6.c,v 1.113 2007/03/17 06:32:46 dyoung Exp $ */
/* $NetBSD: nd6.c,v 1.114 2007/05/02 20:40:27 dyoung 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.113 2007/03/17 06:32:46 dyoung Exp $");
__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.114 2007/05/02 20:40:27 dyoung Exp $");
#include "opt_ipsec.h"
@ -1864,7 +1864,7 @@ nd6_slowtimo(void *ignored_arg)
#define senderr(e) { error = (e); goto bad;}
int
nd6_output(struct ifnet *ifp, struct ifnet *origifp, struct mbuf *m0,
struct sockaddr_in6 *dst, struct rtentry *rt0)
const struct sockaddr_in6 *dst, struct rtentry *rt0)
{
struct mbuf *m = m0;
struct rtentry *rt = rt0;
@ -1883,9 +1883,7 @@ nd6_output(struct ifnet *ifp, struct ifnet *origifp, struct mbuf *m0,
*/
if (rt) {
if ((rt->rt_flags & RTF_UP) == 0) {
if ((rt0 = rt = rtalloc1((struct sockaddr *)dst,
1)) != NULL)
{
if ((rt0 = rt = rtalloc1(sin6tocsa(dst), 1)) != NULL) {
rt->rt_refcnt--;
if (rt->rt_ifp != ifp)
senderr(EHOSTUNREACH);
@ -2052,13 +2050,12 @@ nd6_output(struct ifnet *ifp, struct ifnet *origifp, struct mbuf *m0,
ipsec_delaux(m);
#endif
if ((ifp->if_flags & IFF_LOOPBACK) != 0) {
return (*ifp->if_output)(origifp, m, (struct sockaddr *)dst,
rt);
return (*ifp->if_output)(origifp, m, sin6tocsa(dst), rt);
}
return (*ifp->if_output)(ifp, m, (struct sockaddr *)dst, rt);
return (*ifp->if_output)(ifp, m, sin6tocsa(dst), rt);
bad:
if (m)
if (m != NULL)
m_freem(m);
return error;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: nd6.h,v 1.45 2007/03/15 23:35:45 dyoung Exp $ */
/* $NetBSD: nd6.h,v 1.46 2007/05/02 20:40:28 dyoung Exp $ */
/* $KAME: nd6.h,v 1.95 2002/06/08 11:31:06 itojun Exp $ */
/*
@ -397,7 +397,7 @@ int nd6_ioctl(u_long, void *, struct ifnet *);
struct rtentry *nd6_cache_lladdr(struct ifnet *, struct in6_addr *,
char *, int, int, int);
int nd6_output(struct ifnet *, struct ifnet *, struct mbuf *,
struct sockaddr_in6 *, struct rtentry *);
const struct sockaddr_in6 *, struct rtentry *);
int nd6_storelladdr(const struct ifnet *, const struct rtentry *, struct mbuf *,
const struct sockaddr *, uint8_t *, size_t);
int nd6_sysctl(int, void *, size_t *, void *, size_t);

View File

@ -1,4 +1,4 @@
/* $NetBSD: nd6_nbr.c,v 1.72 2007/03/15 23:39:51 dyoung Exp $ */
/* $NetBSD: nd6_nbr.c,v 1.73 2007/05/02 20:40:28 dyoung Exp $ */
/* $KAME: nd6_nbr.c,v 1.61 2001/02/10 16:06:14 jinmei Exp $ */
/*
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: nd6_nbr.c,v 1.72 2007/03/15 23:39:51 dyoung Exp $");
__KERNEL_RCSID(0, "$NetBSD: nd6_nbr.c,v 1.73 2007/05/02 20:40:28 dyoung Exp $");
#include "opt_inet.h"
#include "opt_ipsec.h"
@ -354,7 +354,7 @@ nd6_ns_output(struct ifnet *ifp, const struct in6_addr *daddr6,
int icmp6len;
int maxlen;
void *mac;
struct route_in6 ro;
struct route ro;
memset(&ro, 0, sizeof(ro));
@ -459,7 +459,7 @@ nd6_ns_output(struct ifnet *ifp, const struct in6_addr *daddr6,
dst_sa.sin6_addr = ip6->ip6_dst;
src = in6_selectsrc(&dst_sa, NULL,
NULL, (struct route *)&ro, NULL, NULL, &error);
NULL, &ro, NULL, NULL, &error);
if (src == NULL) {
nd6log((LOG_DEBUG,
"nd6_ns_output: source can't be "
@ -524,11 +524,11 @@ nd6_ns_output(struct ifnet *ifp, const struct in6_addr *daddr6,
icmp6_ifstat_inc(ifp, ifs6_out_neighborsolicit);
icmp6stat.icp6s_outhist[ND_NEIGHBOR_SOLICIT]++;
rtcache_free((struct route *)&ro);
rtcache_free(&ro);
return;
bad:
rtcache_free((struct route *)&ro);
rtcache_free(&ro);
m_freem(m);
return;
}
@ -859,11 +859,15 @@ nd6_na_output(ifp, daddr6_0, taddr6, flags, tlladdr, sdl0)
struct ip6_hdr *ip6;
struct nd_neighbor_advert *nd_na;
struct ip6_moptions im6o;
struct sockaddr_in6 dst_sa;
struct sockaddr *dst;
union {
struct sockaddr dst;
struct sockaddr_in6 dst6;
} u;
struct in6_addr *src, daddr6;
int icmp6len, maxlen, error;
void *mac;
struct route_in6 ro;
struct route ro;
mac = NULL;
memset(&ro, 0, sizeof(ro));
@ -925,21 +929,19 @@ nd6_na_output(ifp, daddr6_0, taddr6, flags, tlladdr, sdl0)
flags &= ~ND_NA_FLAG_SOLICITED;
}
ip6->ip6_dst = daddr6;
memset(&dst_sa, 0, sizeof(dst_sa));
dst_sa.sin6_family = AF_INET6;
dst_sa.sin6_len = sizeof(struct sockaddr_in6);
dst_sa.sin6_addr = daddr6;
sockaddr_in6_init(&u.dst6, &daddr6, 0, 0, 0);
dst = &u.dst;
rtcache_setdst(&ro, dst);
/*
* Select a source whose scope is the same as that of the dest.
*/
ro.ro_dst = dst_sa;
src = in6_selectsrc(&dst_sa, NULL, NULL, (struct route *)&ro, NULL,
NULL, &error);
src = in6_selectsrc(satosin6(dst), NULL, NULL, &ro, NULL, NULL,
&error);
if (src == NULL) {
nd6log((LOG_DEBUG, "nd6_na_output: source can't be "
"determined: dst=%s, error=%d\n",
ip6_sprintf(&dst_sa.sin6_addr), error));
ip6_sprintf(&satocsin6(dst)->sin6_addr), error));
goto bad;
}
ip6->ip6_src = *src;
@ -999,11 +1001,11 @@ nd6_na_output(ifp, daddr6_0, taddr6, flags, tlladdr, sdl0)
icmp6_ifstat_inc(ifp, ifs6_out_neighboradvert);
icmp6stat.icp6s_outhist[ND_NEIGHBOR_ADVERT]++;
rtcache_free((struct route *)&ro);
rtcache_free(&ro);
return;
bad:
rtcache_free((struct route *)&ro);
rtcache_free(&ro);
m_freem(m);
return;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: clnp.h,v 1.23 2007/03/04 06:03:31 christos Exp $ */
/* $NetBSD: clnp.h,v 1.24 2007/05/02 20:40:28 dyoung Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@ -57,6 +57,8 @@ SOFTWARE.
#ifndef _NETISO_CLNP_H_
#define _NETISO_CLNP_H_
#include <net/route.h>
/*
* ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison
*/
@ -446,7 +448,7 @@ struct clnp_cache {
int clc_segoff; /* offset of seg part of header */
struct rtentry *clc_rt; /* ptr to rtentry (points into the route
* structure) */
struct sockaddr *clc_firsthop; /* first hop of packet */
const struct sockaddr *clc_firsthop; /* first hop of packet */
struct ifnet *clc_ifp;/* ptr to interface structure */
struct iso_ifaddr
*clc_ifa;/* ptr to interface address */
@ -465,7 +467,6 @@ struct clnp_optidx;
struct isopcb;
struct snpa_hdr;
struct iso_ifaddr;
struct route_iso;
/* clnp_debug.c */
char *clnp_hexp (const char *, int, char *);
@ -478,7 +479,7 @@ void clnp_discard (struct mbuf *, u_int);
void clnp_emit_er (struct mbuf *, u_int);
int clnp_er_index (u_int);
int clnp_fragment (struct ifnet *, struct mbuf *, struct sockaddr *,
int clnp_fragment (struct ifnet *, struct mbuf *, const struct sockaddr *,
int, int, int, struct rtentry *);
struct mbuf *clnp_reass (struct mbuf *, struct iso_addr *,
struct iso_addr *, struct clnp_segment *);
@ -524,10 +525,10 @@ int clnp_ours (struct iso_addr *);
void clnp_forward (struct mbuf *, int, struct iso_addr *,
struct clnp_optidx *, int, struct snpa_hdr *);
void *clnp_insert_addr (void *, struct iso_addr *, struct iso_addr *);
int clnp_route (struct iso_addr *, struct route_iso *, int,
struct sockaddr **, struct iso_ifaddr **);
int clnp_srcroute (struct mbuf *, struct clnp_optidx *, struct route_iso *,
struct sockaddr **, struct iso_ifaddr **,
int clnp_route (struct iso_addr *, struct route *, int,
const struct sockaddr **, struct iso_ifaddr **);
int clnp_srcroute (struct mbuf *, struct clnp_optidx *, struct route *,
const struct sockaddr **, struct iso_ifaddr **,
struct iso_addr *);
int clnp_echoreply (struct mbuf *, int, struct sockaddr_iso *,
struct sockaddr_iso *, struct clnp_optidx *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: clnp_er.c,v 1.21 2007/03/04 06:03:31 christos Exp $ */
/* $NetBSD: clnp_er.c,v 1.22 2007/05/02 20:40:28 dyoung Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -59,7 +59,7 @@ SOFTWARE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: clnp_er.c,v 1.21 2007/03/04 06:03:31 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: clnp_er.c,v 1.22 2007/05/02 20:40:28 dyoung Exp $");
#include <sys/param.h>
#include <sys/mbuf.h>
@ -246,9 +246,9 @@ clnp_emit_er(m, reason)
{
struct clnp_fixed *clnp = mtod(m, struct clnp_fixed *);
struct clnp_fixed *er;
struct route_iso route;
struct route route;
struct ifnet *ifp;
struct sockaddr *first_hop;
const struct sockaddr *first_hop;
struct iso_addr src, dst, *our_addr;
char *hoff, *hend;
int total_len; /* total len of dg */
@ -261,7 +261,7 @@ clnp_emit_er(m, reason)
}
#endif
bzero((void *) & route, sizeof(route));
memset(&route, 0, sizeof(route));
/*
* If header length is incorrect, or entire header is not contained
@ -321,7 +321,7 @@ clnp_emit_er(m, reason)
#ifdef ARGO_DEBUG
if (argo_debug[D_DISCARD]) {
printf("clnp_emit_er: packet routed to %s\n",
clnp_iso_addrp(&satosiso(first_hop)->siso_addr));
clnp_iso_addrp(&satocsiso(first_hop)->siso_addr));
}
#endif
@ -378,7 +378,7 @@ bad:
done:
/* free route if it is a temp */
rtcache_free((struct route *)&route);
rtcache_free(&route);
}
int

View File

@ -1,4 +1,4 @@
/* $NetBSD: clnp_frag.c,v 1.19 2007/03/04 06:03:31 christos Exp $ */
/* $NetBSD: clnp_frag.c,v 1.20 2007/05/02 20:40:28 dyoung Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -59,7 +59,7 @@ SOFTWARE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: clnp_frag.c,v 1.19 2007/03/04 06:03:31 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: clnp_frag.c,v 1.20 2007/05/02 20:40:28 dyoung Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -105,7 +105,7 @@ int
clnp_fragment(
struct ifnet *ifp, /* ptr to outgoing interface */
struct mbuf *m, /* ptr to packet */
struct sockaddr *first_hop, /* ptr to first hop */
const struct sockaddr *first_hop, /* ptr to first hop */
int total_len, /* length of datagram */
int segoff, /* offset of segpart in hdr */
int flags, /* flags passed to clnp_output */
@ -903,7 +903,7 @@ int
troll_output(ifp, m, dst, rt)
struct ifnet *ifp;
struct mbuf *m;
struct sockaddr *dst;
const struct sockaddr *dst;
struct rtentry *rt;
{
int err = 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: clnp_output.c,v 1.19 2007/03/04 06:03:31 christos Exp $ */
/* $NetBSD: clnp_output.c,v 1.20 2007/05/02 20:40:28 dyoung Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -59,7 +59,7 @@ SOFTWARE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: clnp_output.c,v 1.19 2007/03/04 06:03:31 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: clnp_output.c,v 1.20 2007/05/02 20:40:28 dyoung Exp $");
#include <sys/param.h>
#include <sys/mbuf.h>
@ -466,7 +466,7 @@ clnp_output(struct mbuf *m0, ...)
if (argo_debug[D_OUTPUT]) {
printf("clnp_output: packet routed to %s\n",
clnp_iso_addrp(
&satosiso(clcp->clc_firsthop)->siso_addr));
&satocsiso(clcp->clc_firsthop)->siso_addr));
}
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: clnp_raw.c,v 1.27 2007/03/04 06:03:31 christos Exp $ */
/* $NetBSD: clnp_raw.c,v 1.28 2007/05/02 20:40:28 dyoung Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -59,7 +59,7 @@ SOFTWARE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: clnp_raw.c,v 1.27 2007/03/04 06:03:31 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: clnp_raw.c,v 1.28 2007/05/02 20:40:28 dyoung Exp $");
#include <sys/param.h>
#include <sys/mbuf.h>
@ -313,7 +313,7 @@ clnp_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam,
case PRU_DETACH:
if (rp->risop_isop.isop_options)
m_freem(rp->risop_isop.isop_options);
rtcache_free((struct route *)&rp->risop_isop.isop_route);
rtcache_free(&rp->risop_isop.isop_route);
if (rp->risop_rcb.rcb_laddr)
rp->risop_rcb.rcb_laddr = 0;
/* free clnp cached hdr if necessary */

View File

@ -1,4 +1,4 @@
/* $NetBSD: clnp_subr.c,v 1.27 2007/03/29 08:19:20 adrianp Exp $ */
/* $NetBSD: clnp_subr.c,v 1.28 2007/05/02 20:40:28 dyoung Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -59,7 +59,7 @@ SOFTWARE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: clnp_subr.c,v 1.27 2007/03/29 08:19:20 adrianp Exp $");
__KERNEL_RCSID(0, "$NetBSD: clnp_subr.c,v 1.28 2007/05/02 20:40:28 dyoung Exp $");
#include "opt_iso.h"
@ -259,10 +259,10 @@ clnp_forward(
{
struct clnp_fixed *clnp; /* ptr to fixed part of header */
int error; /* return value of route function */
struct sockaddr *next_hop; /* next hop for dgram */
const struct sockaddr *next_hop; /* next hop for dgram */
struct ifnet *ifp; /* ptr to outgoing interface */
struct iso_ifaddr *ia = 0; /* ptr to iso name for ifp */
struct route_iso route; /* filled in by clnp_route */
struct route route; /* filled in by clnp_route */
extern int iso_systype;
clnp = mtod(m, struct clnp_fixed *);
@ -332,7 +332,7 @@ clnp_forward(
#ifdef ARGO_DEBUG
if (argo_debug[D_FORWARD]) {
printf("clnp_forward: packet routed to %s\n",
clnp_iso_addrp(&satosiso(next_hop)->siso_addr));
clnp_iso_addrp(&satocsiso(next_hop)->siso_addr));
}
#endif
@ -402,7 +402,7 @@ done:
/*
* Free route
*/
rtcache_free((struct route *)&route);
rtcache_free(&route);
}
#ifdef notdef
@ -458,58 +458,43 @@ clnp_insert_addr(
int
clnp_route(
struct iso_addr *dst, /* ptr to datagram destination */
struct route_iso *ro, /* existing route structure */
struct route *ro, /* existing route structure */
int flags, /* flags for routing */
struct sockaddr **first_hop, /* result: fill in with ptr to
* firsthop */
const struct sockaddr **first_hop, /* result: fill in with ptr to
* firsthop */
struct iso_ifaddr **ifa) /* result: fill in with ptr to ifa */
{
int rc;
union {
struct sockaddr dst;
struct sockaddr_iso dsti;
} u;
if (flags & SO_DONTROUTE) {
struct iso_ifaddr *ia;
size_t len = 1 + (unsigned)dst->isoa_len;
rtcache_free((struct route *)ro);
if (sizeof(ro->ro_dst.siso_addr) < len)
return EINVAL;
(void)memset(&ro->ro_dst, 0, sizeof(ro->ro_dst));
(void)memcpy(&ro->ro_dst.siso_addr, dst, len);
ro->ro_dst.siso_family = AF_ISO;
ro->ro_dst.siso_len = sizeof(ro->ro_dst);
ia = iso_localifa(&ro->ro_dst);
if ((rc = sockaddr_iso_init(&u.dsti, dst)) != 0)
return rc;
rtcache_setdst(ro, &u.dst);
if (rtcache_getdst(ro) == NULL)
return EADDRNOTAVAIL;
ia = iso_localifa(satocsiso(rtcache_getdst(ro)));
if (ia == NULL)
return EADDRNOTAVAIL;
if (ifa != NULL)
*ifa = ia;
if (first_hop != NULL)
*first_hop = sisotosa(&ro->ro_dst);
*first_hop = rtcache_getdst(ro);
return 0;
}
if (memcmp(ro->ro_dst.siso_data, dst->isoa_genaddr, dst->isoa_len) != 0)
rtcache_free((struct route *)ro);
else
rtcache_check((struct route *)ro);
if (ro->ro_rt == NULL) {
size_t len = 1 + (unsigned)dst->isoa_len;
/* set up new route structure */
if (sizeof(ro->ro_dst.siso_addr) < len)
return EINVAL;
(void)memset(&ro->ro_dst, 0, sizeof(ro->ro_dst));
ro->ro_dst.siso_len = sizeof(ro->ro_dst);
ro->ro_dst.siso_family = AF_ISO;
(void)memcpy(&ro->ro_dst.siso_addr, dst, len);
/* allocate new route */
#ifdef ARGO_DEBUG
if (argo_debug[D_ROUTE]) {
printf("clnp_route: allocating new route to %s\n",
clnp_iso_addrp(dst));
}
#endif
rtcache_init((struct route *)ro);
if (ro->ro_rt == NULL)
return ENETUNREACH;
/* set up new route structure */
if ((rc = sockaddr_iso_init(&u.dsti, dst)) != 0)
return rc;
if (rtcache_lookup(ro, &u.dst) == NULL) {
rtcache_free(ro);
return ENETUNREACH;
}
ro->ro_rt->rt_use++;
if (ifa != NULL)
@ -519,7 +504,7 @@ clnp_route(
if (ro->ro_rt->rt_flags & RTF_GATEWAY)
*first_hop = ro->ro_rt->rt_gateway;
else
*first_hop = sisotosa(&ro->ro_dst);
*first_hop = rtcache_getdst(ro);
}
return 0;
}
@ -545,9 +530,9 @@ int
clnp_srcroute(
struct mbuf *options, /* ptr to options */
struct clnp_optidx *oidx, /* index to options */
struct route_iso *ro, /* route structure */
struct sockaddr **first_hop, /* RETURN: fill in with ptr to
* firsthop */
struct route *ro, /* route structure */
const struct sockaddr **first_hop, /* RETURN: fill in with ptr to
* firsthop */
struct iso_ifaddr **ifa, /* RETURN: fill in with ptr to ifa */
struct iso_addr *final_dst) /* final destination */
{
@ -587,7 +572,7 @@ clnp_srcroute(
* If complete src rt, first hop must be equal to dst
*/
if ((CLNPSRCRT_TYPE(oidx, options) == CLNPOVAL_COMPRT) &&
(!iso_addrmatch1(&satosiso(*first_hop)->siso_addr, &dst))) {
(!iso_addrmatch1(&satocsiso(*first_hop)->siso_addr, &dst))) {
#ifdef ARGO_DEBUG
if (argo_debug[D_OPTIONS]) {
printf("clnp_srcroute: complete src route failed\n");

View File

@ -1,4 +1,4 @@
/* $NetBSD: eonvar.h,v 1.16 2007/03/04 06:03:31 christos Exp $ */
/* $NetBSD: eonvar.h,v 1.17 2007/05/02 20:40:28 dyoung Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -179,7 +179,7 @@ struct eon_llinfo {
void eonprotoinit (void);
void eonattach (void);
int eonioctl (struct ifnet *, u_long, void *);
void eoniphdr (struct eon_iphdr *, const void *, struct route *, int, int);
void eoniphdr(struct eon_iphdr *, const void *, struct route *, int);
void eonrtrequest (int, struct rtentry *, struct rt_addrinfo *);
int eonoutput(struct ifnet *, struct mbuf *, const struct sockaddr *,
struct rtentry *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_eon.c,v 1.57 2007/03/04 06:03:32 christos Exp $ */
/* $NetBSD: if_eon.c,v 1.58 2007/05/02 20:40:28 dyoung Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -67,7 +67,7 @@ SOFTWARE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_eon.c,v 1.57 2007/03/04 06:03:32 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_eon.c,v 1.58 2007/05/02 20:40:28 dyoung Exp $");
#include "opt_eon.h"
@ -209,30 +209,23 @@ eonioctl(struct ifnet *ifp, u_long cmd, void *data)
void
eoniphdr(struct eon_iphdr *hdr, const void *loc, struct route *ro,
int class, int zero)
eoniphdr(struct eon_iphdr *hdr, const void *loc, struct route *ro, int class)
{
struct mbuf mhead;
struct sockaddr_in *sin = satosin(&ro->ro_dst);
if (zero) {
memset(hdr, 0, sizeof(*hdr));
memset(ro, 0, sizeof(*ro));
}
sin->sin_family = AF_INET;
sin->sin_len = sizeof(*sin);
(void)memcpy(&sin->sin_addr, loc, sizeof(struct in_addr));
/* XXX Does this check make any sense? */
rtcache_check(ro);
if (ro->ro_rt != NULL) {
struct sockaddr_in *dst = satosin(rt_key(ro->ro_rt));
if (sin->sin_addr.s_addr != dst->sin_addr.s_addr)
rtcache_free(ro);
}
if (ro->ro_rt == NULL)
rtcache_init(ro);
union {
struct sockaddr dst;
struct sockaddr_in dst4;
} u;
struct in_addr addr;
(void)memcpy(&addr, loc, sizeof(addr));
sockaddr_in_init(&u.dst4, &addr, 0);
rtcache_setdst(ro, &u.dst);
rtcache_init(ro);
if (ro->ro_rt != NULL)
ro->ro_rt->rt_use++;
hdr->ei_ip.ip_dst = sin->sin_addr;
hdr->ei_ip.ip_dst = u.dst4.sin_addr;
hdr->ei_ip.ip_p = IPPROTO_EON;
hdr->ei_ip.ip_ttl = MAXTTL;
hdr->ei_eh.eonh_class = class;
@ -311,7 +304,7 @@ eonrtrequest(int cmd, struct rtentry *rt, struct rt_addrinfo *info)
}
}
el->el_flags |= RTF_UP;
eoniphdr(&el->el_ei, ipaddrloc, &el->el_iproute, EON_NORMAL_ADDR, 0);
eoniphdr(&el->el_ei, ipaddrloc, &el->el_iproute, EON_NORMAL_ADDR);
if (el->el_iproute.ro_rt != NULL)
rt->rt_rmx.rmx_mtu = el->el_iproute.ro_rt->rt_rmx.rmx_mtu
- sizeof(el->el_ei);
@ -371,7 +364,8 @@ eonoutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *sdst,
case 4:
ro = &route;
ei = &eon_iphdr;
eoniphdr(ei, ipaddrloc, ro, class, 1);
memset(ei, 0, sizeof(*ei));
eoniphdr(ei, ipaddrloc, ro, class);
goto send;
}
einval:

View File

@ -1,4 +1,4 @@
/* $NetBSD: iso.c,v 1.41 2007/03/04 06:03:32 christos Exp $ */
/* $NetBSD: iso.c,v 1.42 2007/05/02 20:40:28 dyoung Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -62,7 +62,7 @@ SOFTWARE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: iso.c,v 1.41 2007/03/04 06:03:32 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: iso.c,v 1.42 2007/05/02 20:40:28 dyoung Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -454,7 +454,7 @@ iso_control(struct socket *so, u_long cmd, void *data, struct ifnet *ifp,
* Find address for this interface, if it exists.
*/
if (ifp)
for (ia = iso_ifaddr.tqh_first; ia != 0; ia = ia->ia_list.tqe_next)
TAILQ_FOREACH(ia, &iso_ifaddr, ia_list)
if (ia->ia_ifp == ifp)
break;
@ -694,14 +694,13 @@ iso_ifwithidi(struct sockaddr *addr)
printf("\n");
}
#endif
for (ifp = ifnet.tqh_first; ifp != 0; ifp = ifp->if_list.tqe_next) {
TAILQ_FOREACH(ifp, &ifnet, if_list) {
#ifdef ARGO_DEBUG
if (argo_debug[D_ROUTE]) {
printf("iso_ifwithidi ifnet %s\n", ifp->if_name);
}
#endif
for (ifa = ifp->if_addrlist.tqh_first; ifa != 0;
ifa = ifa->ifa_list.tqe_next) {
TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) {
#ifdef ARGO_DEBUG
if (argo_debug[D_ROUTE]) {
printf("iso_ifwithidi address ");
@ -803,17 +802,17 @@ iso_eqtype(
* NOTES:
*/
struct iso_ifaddr *
iso_localifa(struct sockaddr_iso *siso)
iso_localifa(const struct sockaddr_iso *siso)
{
struct iso_ifaddr *ia;
char *cp1, *cp2, *cp3;
const char *cp1, *cp2, *cp3;
struct ifnet *ifp;
struct iso_ifaddr *ia_maybe = 0;
/*
* We make one pass looking for both net matches and an exact
* dst addr.
*/
for (ia = iso_ifaddr.tqh_first; ia != 0; ia = ia->ia_list.tqe_next) {
TAILQ_FOREACH(ia, &iso_ifaddr, ia_list) {
if ((ifp = ia->ia_ifp) == 0 || ((ifp->if_flags & IFF_UP) == 0))
continue;
if (ifp->if_flags & IFF_POINTOPOINT) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: iso.h,v 1.19 2007/02/18 00:56:53 hubertf Exp $ */
/* $NetBSD: iso.h,v 1.20 2007/05/02 20:40:28 dyoung Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -142,22 +142,22 @@ typedef __sa_family_t sa_family_t;
* routines
*/
struct iso_addr {
u_char isoa_len; /* length (in bytes) */
char isoa_genaddr[20]; /* general opaque address */
uint8_t isoa_len; /* length (in bytes) */
char isoa_genaddr[20]; /* general opaque address */
};
struct sockaddr_iso {
u_char siso_len; /* length */
sa_family_t siso_family; /* family */
u_char siso_plen; /* presentation selector length */
u_char siso_slen; /* session selector length */
u_char siso_tlen; /* transport selector length */
uint8_t siso_len; /* length */
sa_family_t siso_family; /* family */
uint8_t siso_plen; /* presentation selector length */
uint8_t siso_slen; /* session selector length */
uint8_t siso_tlen; /* transport selector length */
struct iso_addr siso_addr; /* network address */
u_char siso_pad[6]; /* space for gosip v2 sels */
uint8_t siso_pad[6]; /* space for gosip v2 sels */
/* makes struct 32 bytes long */
};
#define siso_nlen siso_addr.isoa_len
#define siso_data siso_addr.isoa_genaddr
#define siso_nlen siso_addr.isoa_len
#define siso_data siso_addr.isoa_genaddr
static inline void *
WRITABLE_TSEL(struct sockaddr_iso *siso)
@ -195,6 +195,45 @@ extern const struct protosw isosw[];
#define satocsiso(sa) ((const struct sockaddr_iso *)(sa))
#define sisotosa(siso) ((struct sockaddr *)(siso))
int sockaddr_iso_cmp(const struct sockaddr *, const struct sockaddr *);
static inline int
sockaddr_iso_init1(struct sockaddr_iso *siso, const struct iso_addr *addr)
{
memset(&siso->siso_plen, 0,
sizeof(*siso) - offsetof(struct sockaddr_iso, siso_plen));
if (offsetof(struct iso_addr, isoa_genaddr[addr->isoa_len]) >
sizeof(struct iso_addr))
return EINVAL;
memcpy(&siso->siso_addr, addr,
offsetof(struct iso_addr, isoa_genaddr[addr->isoa_len]));
return 0;
}
static inline int
sockaddr_iso_init(struct sockaddr_iso *siso, const struct iso_addr *addr)
{
siso->siso_family = AF_ISO;
siso->siso_len = sizeof(*siso);
return sockaddr_iso_init1(siso, addr);
}
static inline struct sockaddr *
sockaddr_iso_alloc(const struct iso_addr *addr, int flags)
{
struct sockaddr *sa;
if ((sa = sockaddr_alloc(AF_ISO, flags)) == NULL)
return NULL;
if (sockaddr_iso_init1(satosiso(sa), addr) != 0) {
sockaddr_free(sa);
return NULL;
}
return sa;
}
#else
/* user utilities definitions from the iso library */

View File

@ -1,4 +1,4 @@
/* $NetBSD: iso_pcb.c,v 1.38 2007/03/04 06:03:32 christos Exp $ */
/* $NetBSD: iso_pcb.c,v 1.39 2007/05/02 20:40:29 dyoung Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -62,7 +62,7 @@ SOFTWARE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: iso_pcb.c,v 1.38 2007/03/04 06:03:32 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: iso_pcb.c,v 1.39 2007/05/02 20:40:29 dyoung Exp $");
#include "opt_iso.h"
@ -515,7 +515,7 @@ iso_pcbdetach(void *v)
printf("iso_pcbdetach 3 \n");
}
#endif
rtcache_free((struct route *)&isop->isop_route);
rtcache_free(&isop->isop_route);
#ifdef ARGO_DEBUG
if (argo_debug[D_ISO]) {
printf("iso_pcbdetach 3.1\n");

View File

@ -1,4 +1,4 @@
/* $NetBSD: iso_pcb.h,v 1.16 2007/03/04 06:03:32 christos Exp $ */
/* $NetBSD: iso_pcb.h,v 1.17 2007/05/02 20:40:29 dyoung Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -61,6 +61,8 @@ SOFTWARE.
#ifndef _NETISO_ISO_PCB_H_
#define _NETISO_ISO_PCB_H_
#include <net/route.h>
#define MAXX25CRUDLEN 16 /* 16 bytes of call request user data */
/*
@ -73,10 +75,7 @@ struct isopcb {
struct socket *isop_socket; /* back pointer to socket */
struct sockaddr_iso *isop_laddr;
struct sockaddr_iso *isop_faddr;
struct route_iso {
struct rtentry *ro_rt;
struct sockaddr_iso ro_dst;
} isop_route; /* CLNP routing entry */
struct route isop_route; /* CLNP routing entry */
struct mbuf *isop_options; /* CLNP options */
struct mbuf *isop_optindex; /* CLNP options index */
struct mbuf *isop_clnpcache; /* CLNP cached hdr */

View File

@ -1,4 +1,4 @@
/* $NetBSD: iso_proto.c,v 1.22 2006/12/09 05:33:09 dyoung Exp $ */
/* $NetBSD: iso_proto.c,v 1.23 2007/05/02 20:40:29 dyoung Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -65,7 +65,7 @@ SOFTWARE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: iso_proto.c,v 1.22 2006/12/09 05:33:09 dyoung Exp $");
__KERNEL_RCSID(0, "$NetBSD: iso_proto.c,v 1.23 2007/05/02 20:40:29 dyoung Exp $");
#include <sys/param.h>
@ -173,6 +173,9 @@ const struct protosw isosw[] = {
extern struct ifqueue clnlintrq;
POOL_INIT(sockaddr_iso_pool, sizeof(struct sockaddr_iso), 0, 0, 0,
"sockaddr_iso_pool", NULL, IPL_NET);
struct domain isodomain = {
.dom_family = PF_ISO,
.dom_name = "iso-domain",
@ -189,7 +192,31 @@ struct domain isodomain = {
.dom_ifqueues = { &clnlintrq, NULL }, /* ifqueues */
.dom_link = { NULL },
.dom_mowner = MOWNER_INIT("",""),
.dom_rtcache = NULL,
.dom_rtflush = NULL,
.dom_rtflushall = NULL
.dom_sa_pool = &sockaddr_iso_pool,
.dom_sa_len = sizeof(struct sockaddr_iso),
.dom_rtcache = LIST_HEAD_INITIALIZER(isodomain.dom_rtcache)
};
int
sockaddr_iso_cmp(const struct sockaddr *sa1, const struct sockaddr *sa2)
{
int rc;
uint_fast8_t len, nlen;
const uint_fast8_t addrofs = offsetof(struct sockaddr_iso, siso_data);
const struct sockaddr_iso *siso1, *siso2;
siso1 = satocsiso(sa1);
siso2 = satocsiso(sa2);
len = MIN(siso1->siso_len, siso2->siso_len);
/* No siso_nlen present? */
if (len < addrofs)
return siso1->siso_len - siso2->siso_len;
nlen = MIN(siso1->siso_nlen, siso2->siso_nlen);
if (nlen > addrofs &&
(rc = memcmp(siso1->siso_data, siso2->siso_data, nlen)) != 0)
return rc;
return siso1->siso_nlen - siso2->siso_nlen;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: iso_var.h,v 1.25 2007/03/04 06:03:32 christos Exp $ */
/* $NetBSD: iso_var.h,v 1.26 2007/05/02 20:40:29 dyoung Exp $ */
/*-
* Copyright (c) 1988, 1991, 1993
@ -157,7 +157,7 @@ int iso_ifinit (struct ifnet *, struct iso_ifaddr *, struct sockaddr_iso *,
struct ifaddr *iso_ifwithidi (struct sockaddr *);
int iso_ck_addr (struct iso_addr *);
int iso_eqtype (struct iso_addr *, struct iso_addr *);
struct iso_ifaddr *iso_localifa (struct sockaddr_iso *);
struct iso_ifaddr *iso_localifa (const struct sockaddr_iso *);
int iso_nlctloutput (int, int, void *, struct mbuf *);
void dump_isoaddr(const struct sockaddr_iso *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: tp_iso.c,v 1.30 2007/03/04 06:03:33 christos Exp $ */
/* $NetBSD: tp_iso.c,v 1.31 2007/05/02 20:40:29 dyoung Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -75,7 +75,7 @@ SOFTWARE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: tp_iso.c,v 1.30 2007/03/04 06:03:33 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: tp_iso.c,v 1.31 2007/05/02 20:40:29 dyoung Exp $");
#include "opt_iso.h"
#ifdef ISO
@ -466,7 +466,7 @@ tpclnp_output_dg(struct mbuf *m0, ...)
/*
* Free route allocated by clnp (if the route was indeed allocated)
*/
rtcache_free((struct route *)&tmppcb.isop_route);
rtcache_free(&tmppcb.isop_route);
return (err);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: keydb.h,v 1.27 2007/03/04 06:03:35 christos Exp $ */
/* $NetBSD: keydb.h,v 1.28 2007/05/02 20:40:29 dyoung Exp $ */
/* $KAME: keydb.h,v 1.23 2003/09/07 05:25:20 itojun Exp $ */
/*
@ -70,11 +70,7 @@ struct secashead {
/* SA chain */
/* The first of this list is newer SA */
union {
struct route sau_route;
struct route_in6 sau_route6;
} sa_u;
#define sa_route sa_u.sau_route
struct route sa_route;
};
/* Security Association */

View File

@ -1,4 +1,4 @@
/* $NetBSD: natm_proto.c,v 1.10 2007/01/13 18:52:04 cube Exp $ */
/* $NetBSD: natm_proto.c,v 1.11 2007/05/02 20:40:29 dyoung Exp $ */
/*
*
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: natm_proto.c,v 1.10 2007/01/13 18:52:04 cube Exp $");
__KERNEL_RCSID(0, "$NetBSD: natm_proto.c,v 1.11 2007/05/02 20:40:29 dyoung Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -89,6 +89,7 @@ struct domain natmdomain = {
.dom_protosw = natmsw,
.dom_protoswNPROTOSW = &natmsw[sizeof(natmsw)/sizeof(natmsw[0])],
.dom_ifqueues = { &natmintrq, NULL },
.dom_rtcache = LIST_HEAD_INITIALIZER(natmdomain.dom_rtcache)
};
#ifdef NATM_STAT
u_int natm_sodropcnt = 0; /* # mbufs dropped due to full sb */

View File

@ -1,4 +1,4 @@
/* $NetBSD: domain.h,v 1.24 2006/12/09 05:33:09 dyoung Exp $ */
/* $NetBSD: domain.h,v 1.25 2007/05/02 20:40:29 dyoung Exp $ */
/*
* Copyright (c) 1982, 1986, 1993
@ -46,7 +46,10 @@ struct lwp;
struct mbuf;
struct ifnet;
struct ifqueue;
struct route;
struct route;
struct sockaddr;
LIST_HEAD(dom_rtlist, route);
struct domain {
int dom_family; /* AF_xxx */
@ -66,12 +69,16 @@ struct domain {
(struct ifnet *);
void (*dom_ifdetach) /* detach af-dependent data on ifnet */
(struct ifnet *, void *);
int (*dom_sockaddr_cmp)(const struct sockaddr *,
const struct sockaddr *);
struct ifqueue *dom_ifqueues[2]; /* ifqueue for domain */
STAILQ_ENTRY(domain) dom_link;
struct mowner dom_mowner;
void (*dom_rtcache)(struct route *);
void (*dom_rtflush)(struct route *);
void (*dom_rtflushall)(void);
struct pool *dom_sa_pool;
uint_fast8_t dom_sa_len;
uint_fast8_t dom_sa_cmpofs;
uint_fast8_t dom_sa_cmplen;
struct dom_rtlist dom_rtcache;
};
STAILQ_HEAD(domainhead,domain);

View File

@ -1,4 +1,4 @@
/* $NetBSD: socket.h,v 1.84 2007/03/04 06:03:41 christos Exp $ */
/* $NetBSD: socket.h,v 1.85 2007/05/02 20:40:29 dyoung Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -537,6 +537,16 @@ __BEGIN_DECLS
int __cmsg_alignbytes(void);
__END_DECLS
#ifdef _KERNEL
__BEGIN_DECLS
struct sockaddr *sockaddr_copy(struct sockaddr *, const struct sockaddr *);
struct sockaddr *sockaddr_alloc(sa_family_t, int);
int sockaddr_cmp(const struct sockaddr *, const struct sockaddr *);
struct sockaddr *sockaddr_dup(const struct sockaddr *, int);
void sockaddr_free(struct sockaddr *);
__END_DECLS
#endif /* _KERNEL */
#ifndef _KERNEL
__BEGIN_DECLS