2007-10-29 19:54:42 +03:00
|
|
|
/* $NetBSD: ip6_var.h,v 1.46 2007/10/29 16:54:43 dyoung Exp $ */
|
2000-07-06 16:36:18 +04:00
|
|
|
/* $KAME: ip6_var.h,v 1.33 2000/06/11 14:59:20 jinmei Exp $ */
|
1999-07-04 01:24:45 +04:00
|
|
|
|
1999-06-28 10:36:47 +04:00
|
|
|
/*
|
|
|
|
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
|
|
|
* All rights reserved.
|
2000-07-06 16:36:18 +04:00
|
|
|
*
|
1999-06-28 10:36:47 +04:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. Neither the name of the project nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
2000-07-06 16:36:18 +04:00
|
|
|
*
|
1999-06-28 10:36:47 +04:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 1982, 1986, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
2003-08-07 20:26:28 +04:00
|
|
|
* 3. Neither the name of the University nor the names of its contributors
|
1999-06-28 10:36:47 +04:00
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* @(#)ip_var.h 8.1 (Berkeley) 6/10/93
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _NETINET6_IP6_VAR_H_
|
|
|
|
#define _NETINET6_IP6_VAR_H_
|
|
|
|
|
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.
2007-05-03 00:40:22 +04:00
|
|
|
#include <net/route.h>
|
|
|
|
|
1999-06-28 10:36:47 +04:00
|
|
|
/*
|
|
|
|
* IP6 reassembly queue structure. Each fragment
|
|
|
|
* being reassembled is attached to one of these structures.
|
|
|
|
*/
|
|
|
|
struct ip6q {
|
2000-02-03 21:13:01 +03:00
|
|
|
u_int32_t ip6q_head;
|
|
|
|
u_int16_t ip6q_len;
|
|
|
|
u_int8_t ip6q_nxt; /* ip6f_nxt in first fragment */
|
|
|
|
u_int8_t ip6q_hlim;
|
|
|
|
struct ip6asfrag *ip6q_down;
|
|
|
|
struct ip6asfrag *ip6q_up;
|
|
|
|
u_int32_t ip6q_ident;
|
|
|
|
u_int8_t ip6q_arrive;
|
|
|
|
u_int8_t ip6q_ttl;
|
|
|
|
struct in6_addr ip6q_src, ip6q_dst;
|
|
|
|
struct ip6q *ip6q_next;
|
|
|
|
struct ip6q *ip6q_prev;
|
|
|
|
int ip6q_unfrglen; /* len of unfragmentable part */
|
1999-06-28 10:36:47 +04:00
|
|
|
#ifdef notyet
|
2000-02-03 21:13:01 +03:00
|
|
|
u_char *ip6q_nxtp;
|
1999-06-28 10:36:47 +04:00
|
|
|
#endif
|
2002-05-28 07:04:05 +04:00
|
|
|
int ip6q_nfrag; /* # of fragments */
|
1999-06-28 10:36:47 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ip6asfrag {
|
2000-02-03 21:13:01 +03:00
|
|
|
u_int32_t ip6af_head;
|
|
|
|
u_int16_t ip6af_len;
|
|
|
|
u_int8_t ip6af_nxt;
|
|
|
|
u_int8_t ip6af_hlim;
|
1999-06-28 10:36:47 +04:00
|
|
|
/* must not override the above members during reassembling */
|
2000-02-03 21:13:01 +03:00
|
|
|
struct ip6asfrag *ip6af_down;
|
|
|
|
struct ip6asfrag *ip6af_up;
|
|
|
|
struct mbuf *ip6af_m;
|
|
|
|
int ip6af_offset; /* offset in ip6af_m to next header */
|
|
|
|
int ip6af_frglen; /* fragmentable part length */
|
|
|
|
int ip6af_off; /* fragment offset */
|
|
|
|
u_int16_t ip6af_mff; /* more fragment bit in frag off */
|
1999-06-28 10:36:47 +04:00
|
|
|
};
|
|
|
|
|
2002-06-09 01:22:29 +04:00
|
|
|
#define IP6_REASS_MBUF(ip6af) ((ip6af)->ip6af_m)
|
1999-06-28 10:36:47 +04:00
|
|
|
|
|
|
|
struct ip6_moptions {
|
|
|
|
struct ifnet *im6o_multicast_ifp; /* ifp for outgoing multicasts */
|
|
|
|
u_char im6o_multicast_hlim; /* hoplimit for outgoing multicasts */
|
|
|
|
u_char im6o_multicast_loop; /* 1 >= hear sends if a member */
|
|
|
|
LIST_HEAD(, in6_multi_mship) im6o_memberships;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Control options for outgoing packets
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Routing header related info */
|
|
|
|
struct ip6po_rhinfo {
|
|
|
|
struct ip6_rthdr *ip6po_rhi_rthdr; /* Routing header */
|
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.
2007-05-03 00:40:22 +04:00
|
|
|
struct route ip6po_rhi_route; /* Route to the 1st hop */
|
1999-06-28 10:36:47 +04:00
|
|
|
};
|
|
|
|
#define ip6po_rthdr ip6po_rhinfo.ip6po_rhi_rthdr
|
|
|
|
#define ip6po_route ip6po_rhinfo.ip6po_rhi_route
|
|
|
|
|
2006-05-05 04:03:21 +04:00
|
|
|
/* Nexthop related info */
|
|
|
|
struct ip6po_nhinfo {
|
|
|
|
struct sockaddr *ip6po_nhi_nexthop;
|
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.
2007-05-03 00:40:22 +04:00
|
|
|
struct route ip6po_nhi_route; /* Route to the nexthop */
|
2006-05-05 04:03:21 +04:00
|
|
|
};
|
|
|
|
#define ip6po_nexthop ip6po_nhinfo.ip6po_nhi_nexthop
|
|
|
|
#define ip6po_nextroute ip6po_nhinfo.ip6po_nhi_route
|
|
|
|
|
1999-06-28 10:36:47 +04:00
|
|
|
struct ip6_pktopts {
|
|
|
|
struct mbuf *ip6po_m; /* Pointer to mbuf storing the data */
|
|
|
|
int ip6po_hlim; /* Hoplimit for outgoing packets */
|
|
|
|
struct in6_pktinfo *ip6po_pktinfo; /* Outgoing IF/address information */
|
2006-05-05 04:03:21 +04:00
|
|
|
struct ip6po_nhinfo ip6po_nhinfo; /* Next-hop address information */
|
1999-06-28 10:36:47 +04:00
|
|
|
struct ip6_hbh *ip6po_hbh; /* Hop-by-Hop options header */
|
|
|
|
struct ip6_dest *ip6po_dest1; /* Destination options header(1st part) */
|
|
|
|
struct ip6po_rhinfo ip6po_rhinfo; /* Routing header related info. */
|
|
|
|
struct ip6_dest *ip6po_dest2; /* Destination options header(2nd part) */
|
2006-05-05 04:03:21 +04:00
|
|
|
int ip6po_tclass; /* traffic class */
|
|
|
|
int ip6po_minmtu; /* fragment vs PMTU discovery policy */
|
|
|
|
#define IP6PO_MINMTU_MCASTONLY -1 /* default; send at min MTU for multicast*/
|
|
|
|
#define IP6PO_MINMTU_DISABLE 0 /* always perform pmtu disc */
|
|
|
|
#define IP6PO_MINMTU_ALL 1 /* always send at min MTU */
|
|
|
|
int ip6po_flags;
|
|
|
|
#if 0 /* parameters in this block is obsolete. do not reuse the values. */
|
|
|
|
#define IP6PO_REACHCONF 0x01 /* upper-layer reachability confirmation. */
|
|
|
|
#define IP6PO_MINMTU 0x02 /* use minimum MTU (IPV6_USE_MIN_MTU) */
|
|
|
|
#endif
|
|
|
|
#define IP6PO_DONTFRAG 0x04 /* disable fragmentation (IPV6_DONTFRAG) */
|
1999-06-28 10:36:47 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ip6stat {
|
1999-11-19 13:41:41 +03:00
|
|
|
u_quad_t ip6s_total; /* total packets received */
|
|
|
|
u_quad_t ip6s_tooshort; /* packet too short */
|
|
|
|
u_quad_t ip6s_toosmall; /* not enough data */
|
|
|
|
u_quad_t ip6s_fragments; /* fragments received */
|
|
|
|
u_quad_t ip6s_fragdropped; /* frags dropped(dups, out of space) */
|
|
|
|
u_quad_t ip6s_fragtimeout; /* fragments timed out */
|
|
|
|
u_quad_t ip6s_fragoverflow; /* fragments that exceeded limit */
|
|
|
|
u_quad_t ip6s_forward; /* packets forwarded */
|
|
|
|
u_quad_t ip6s_cantforward; /* packets rcvd for unreachable dest */
|
|
|
|
u_quad_t ip6s_redirectsent; /* packets forwarded on same net */
|
1999-12-13 18:17:17 +03:00
|
|
|
u_quad_t ip6s_delivered; /* datagrams delivered to upper level*/
|
1999-11-19 13:41:41 +03:00
|
|
|
u_quad_t ip6s_localout; /* total ip packets generated here */
|
|
|
|
u_quad_t ip6s_odropped; /* lost packets due to nobufs, etc. */
|
|
|
|
u_quad_t ip6s_reassembled; /* total packets reassembled ok */
|
2003-01-29 01:35:02 +03:00
|
|
|
u_quad_t ip6s_fragmented; /* datagrams successfully fragmented */
|
1999-11-19 13:41:41 +03:00
|
|
|
u_quad_t ip6s_ofragments; /* output fragments created */
|
|
|
|
u_quad_t ip6s_cantfrag; /* don't fragment flag was set, etc. */
|
|
|
|
u_quad_t ip6s_badoptions; /* error in option processing */
|
|
|
|
u_quad_t ip6s_noroute; /* packets discarded due to no route */
|
|
|
|
u_quad_t ip6s_badvers; /* ip6 version != 6 */
|
|
|
|
u_quad_t ip6s_rawout; /* total raw ip packets generated */
|
|
|
|
u_quad_t ip6s_badscope; /* scope error */
|
|
|
|
u_quad_t ip6s_notmember; /* don't join this multicast group */
|
|
|
|
u_quad_t ip6s_nxthist[256]; /* next header history */
|
|
|
|
u_quad_t ip6s_m1; /* one mbuf */
|
|
|
|
u_quad_t ip6s_m2m[32]; /* two or more mbuf */
|
|
|
|
u_quad_t ip6s_mext1; /* one ext mbuf */
|
|
|
|
u_quad_t ip6s_mext2m; /* two or more ext mbuf */
|
|
|
|
u_quad_t ip6s_exthdrtoolong; /* ext hdr are not continuous */
|
|
|
|
u_quad_t ip6s_nogif; /* no match gif found */
|
|
|
|
u_quad_t ip6s_toomanyhdr; /* discarded due to too many headers */
|
2000-02-26 11:39:18 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* statistics for improvement of the source address selection
|
|
|
|
* algorithm:
|
|
|
|
* XXX: hardcoded 16 = # of ip6 multicast scope types + 1
|
|
|
|
*/
|
|
|
|
/* number of times that address selection fails */
|
|
|
|
u_quad_t ip6s_sources_none;
|
|
|
|
/* number of times that an address on the outgoing I/F is chosen */
|
|
|
|
u_quad_t ip6s_sources_sameif[16];
|
|
|
|
/* number of times that an address on a non-outgoing I/F is chosen */
|
|
|
|
u_quad_t ip6s_sources_otherif[16];
|
|
|
|
/*
|
|
|
|
* number of times that an address that has the same scope
|
|
|
|
* from the destination is chosen.
|
|
|
|
*/
|
|
|
|
u_quad_t ip6s_sources_samescope[16];
|
|
|
|
/*
|
|
|
|
* number of times that an address that has a different scope
|
|
|
|
* from the destination is chosen.
|
|
|
|
*/
|
|
|
|
u_quad_t ip6s_sources_otherscope[16];
|
|
|
|
/* number of times that an deprecated address is chosen */
|
|
|
|
u_quad_t ip6s_sources_deprecated[16];
|
2000-07-06 16:36:18 +04:00
|
|
|
|
|
|
|
u_quad_t ip6s_forward_cachehit;
|
|
|
|
u_quad_t ip6s_forward_cachemiss;
|
2007-03-08 01:20:04 +03:00
|
|
|
|
|
|
|
u_quad_t ip6s_fastforward; /* packets fast forwarded */
|
|
|
|
u_quad_t ip6s_fastforwardflows; /* number of fast forward flows*/
|
|
|
|
};
|
|
|
|
|
|
|
|
#define IP6FLOW_HASHBITS 6 /* should not be a multiple of 8 */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Structure for an IPv6 flow (ip6_fastforward).
|
|
|
|
*/
|
|
|
|
struct ip6flow {
|
|
|
|
LIST_ENTRY(ip6flow) ip6f_list; /* next in active list */
|
|
|
|
LIST_ENTRY(ip6flow) ip6f_hash; /* next ip6flow in bucket */
|
|
|
|
struct in6_addr ip6f_dst; /* destination address */
|
|
|
|
struct in6_addr ip6f_src; /* source address */
|
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.
2007-05-03 00:40:22 +04:00
|
|
|
struct route ip6f_ro; /* associated route entry */
|
2007-03-08 01:20:04 +03:00
|
|
|
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 */
|
|
|
|
u_quad_t ip6f_dropped; /* ENOBUFS returned by if_output */
|
|
|
|
u_quad_t ip6f_forwarded; /* packets forwarded */
|
|
|
|
u_int ip6f_timer; /* lifetime timer */
|
|
|
|
time_t ip6f_start; /* creation time */
|
1999-06-28 10:36:47 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef _KERNEL
|
Better support of IPv6 scoped addresses.
- most of the kernel code will not care about the actual encoding of
scope zone IDs and won't touch "s6_addr16[1]" directly.
- similarly, most of the kernel code will not care about link-local
scoped addresses as a special case.
- scope boundary check will be stricter. For example, the current
*BSD code allows a packet with src=::1 and dst=(some global IPv6
address) to be sent outside of the node, if the application do:
s = socket(AF_INET6);
bind(s, "::1");
sendto(s, some_global_IPv6_addr);
This is clearly wrong, since ::1 is only meaningful within a single
node, but the current implementation of the *BSD kernel cannot
reject this attempt.
- and, while there, don't try to remove the ff02::/32 interface route
entry in in6_ifdetach() as it's already gone.
This also includes some level of support for the standard source
address selection algorithm defined in RFC3484, which will be
completed on in the future.
From the KAME project via JINMEI Tatuya.
Approved by core@.
2006-01-21 03:15:35 +03:00
|
|
|
/*
|
|
|
|
* Auxiliary attributes of incoming IPv6 packets, which is initialized when we
|
|
|
|
* come into ip6_input().
|
|
|
|
* XXX do not make it a kitchen sink!
|
|
|
|
*/
|
|
|
|
struct ip6aux {
|
|
|
|
/* ip6.ip6_dst */
|
2007-10-29 19:54:42 +03:00
|
|
|
struct in6_addr ip6a_src;
|
|
|
|
uint32_t ip6a_scope_id;
|
|
|
|
int ip6a_flags;
|
Better support of IPv6 scoped addresses.
- most of the kernel code will not care about the actual encoding of
scope zone IDs and won't touch "s6_addr16[1]" directly.
- similarly, most of the kernel code will not care about link-local
scoped addresses as a special case.
- scope boundary check will be stricter. For example, the current
*BSD code allows a packet with src=::1 and dst=(some global IPv6
address) to be sent outside of the node, if the application do:
s = socket(AF_INET6);
bind(s, "::1");
sendto(s, some_global_IPv6_addr);
This is clearly wrong, since ::1 is only meaningful within a single
node, but the current implementation of the *BSD kernel cannot
reject this attempt.
- and, while there, don't try to remove the ff02::/32 interface route
entry in in6_ifdetach() as it's already gone.
This also includes some level of support for the standard source
address selection algorithm defined in RFC3484, which will be
completed on in the future.
From the KAME project via JINMEI Tatuya.
Approved by core@.
2006-01-21 03:15:35 +03:00
|
|
|
};
|
|
|
|
|
1999-06-28 10:36:47 +04:00
|
|
|
/* flags passed to ip6_output as last parameter */
|
2002-06-09 01:22:29 +04:00
|
|
|
#define IPV6_UNSPECSRC 0x01 /* allow :: as the source address */
|
1999-06-28 10:36:47 +04:00
|
|
|
#define IPV6_FORWARDING 0x02 /* most of IPv6 header exists */
|
2001-12-20 10:26:36 +03:00
|
|
|
#define IPV6_MINMTU 0x04 /* use minimum MTU (IPV6_USE_MIN_MTU) */
|
1999-06-28 10:36:47 +04:00
|
|
|
|
Changes to allow the IPv4 and IPv6 layers to align headers themseves,
as necessary:
* Implement a new mbuf utility routine, m_copyup(), is is like
m_pullup(), except that it always prepends and copies, rather
than only doing so if the desired length is larger than m->m_len.
m_copyup() also allows an offset into the destination mbuf, which
allows space for packet headers, in the forwarding case.
* Add *_HDR_ALIGNED_P() macros for IP, IPv6, ICMP, and IGMP. These
macros expand to 1 if __NO_STRICT_ALIGNMENT is defined, so that
architectures which do not have strict alignment constraints don't
pay for the test or visit the new align-if-needed path.
* Use the new macros to check if a header needs to be aligned, or to
assert that it already is, as appropriate.
Note: This code is still somewhat experimental. However, the new
code path won't be visited if individual device drivers continue
to guarantee that packets are delivered to layer 3 already properly
aligned (which are rules that are already in use).
2002-07-01 02:40:32 +04:00
|
|
|
#ifdef __NO_STRICT_ALIGNMENT
|
|
|
|
#define IP6_HDR_ALIGNED_P(ip) 1
|
|
|
|
#else
|
|
|
|
#define IP6_HDR_ALIGNED_P(ip) ((((vaddr_t) (ip)) & 3) == 0)
|
|
|
|
#endif
|
|
|
|
|
1999-06-28 10:36:47 +04:00
|
|
|
extern struct ip6stat ip6stat; /* statistics */
|
1999-07-22 07:59:42 +04:00
|
|
|
extern u_int32_t ip6_id; /* fragment identifier */
|
1999-06-28 10:36:47 +04:00
|
|
|
extern int ip6_defhlim; /* default hop limit */
|
|
|
|
extern int ip6_defmcasthlim; /* default multicast hop limit */
|
|
|
|
extern int ip6_forwarding; /* act as router? */
|
2003-08-07 12:52:32 +04:00
|
|
|
extern int ip6_sendredirect; /* send ICMPv6 redirect? */
|
1999-06-28 10:36:47 +04:00
|
|
|
extern int ip6_forward_srcrt; /* forward src-routed? */
|
1999-12-13 18:17:17 +03:00
|
|
|
extern int ip6_use_deprecated; /* allow deprecated addr as source */
|
|
|
|
extern int ip6_rr_prune; /* router renumbering prefix
|
|
|
|
* walk list every 5 sec. */
|
2006-03-06 02:47:08 +03:00
|
|
|
extern int ip6_mcast_pmtu; /* enable pMTU discovery for multicast? */
|
2001-10-15 13:51:15 +04:00
|
|
|
extern int ip6_v6only;
|
1999-12-13 18:17:17 +03:00
|
|
|
|
1999-06-28 10:36:47 +04:00
|
|
|
extern struct socket *ip6_mrouter; /* multicast routing daemon */
|
|
|
|
extern int ip6_sendredirects; /* send IP redirects when forwarding? */
|
|
|
|
extern int ip6_maxfragpackets; /* Maximum packets in reassembly queue */
|
2002-05-28 07:04:05 +04:00
|
|
|
extern int ip6_maxfrags; /* Maximum fragments in reassembly queue */
|
1999-06-28 10:36:47 +04:00
|
|
|
extern int ip6_sourcecheck; /* Verify source interface */
|
|
|
|
extern int ip6_sourcecheck_interval; /* Interval between log messages */
|
|
|
|
extern int ip6_accept_rtadv; /* Acts as a host not a router */
|
|
|
|
extern int ip6_keepfaith; /* Firewall Aided Internet Translator */
|
|
|
|
extern int ip6_log_interval;
|
|
|
|
extern time_t ip6_log_time;
|
|
|
|
extern int ip6_hdrnestlimit; /* upper limit of # of extension headers */
|
|
|
|
extern int ip6_dad_count; /* DupAddrDetectionTransmits */
|
|
|
|
|
|
|
|
extern int ip6_auto_flowlabel;
|
2002-06-09 01:22:29 +04:00
|
|
|
extern int ip6_auto_linklocal;
|
1999-06-28 10:36:47 +04:00
|
|
|
|
2000-08-26 15:03:45 +04:00
|
|
|
extern int ip6_anonportmin; /* minimum ephemeral port */
|
|
|
|
extern int ip6_anonportmax; /* maximum ephemeral port */
|
|
|
|
extern int ip6_lowportmin; /* minimum reserved port */
|
|
|
|
extern int ip6_lowportmax; /* maximum reserved port */
|
|
|
|
|
2006-03-06 02:47:08 +03:00
|
|
|
extern int ip6_use_tempaddr; /* whether to use temporary addresses. */
|
|
|
|
extern int ip6_prefer_tempaddr; /* whether to prefer temporary addresses
|
|
|
|
in the source address selection */
|
Better support of IPv6 scoped addresses.
- most of the kernel code will not care about the actual encoding of
scope zone IDs and won't touch "s6_addr16[1]" directly.
- similarly, most of the kernel code will not care about link-local
scoped addresses as a special case.
- scope boundary check will be stricter. For example, the current
*BSD code allows a packet with src=::1 and dst=(some global IPv6
address) to be sent outside of the node, if the application do:
s = socket(AF_INET6);
bind(s, "::1");
sendto(s, some_global_IPv6_addr);
This is clearly wrong, since ::1 is only meaningful within a single
node, but the current implementation of the *BSD kernel cannot
reject this attempt.
- and, while there, don't try to remove the ff02::/32 interface route
entry in in6_ifdetach() as it's already gone.
This also includes some level of support for the standard source
address selection algorithm defined in RFC3484, which will be
completed on in the future.
From the KAME project via JINMEI Tatuya.
Approved by core@.
2006-01-21 03:15:35 +03:00
|
|
|
extern int ip6_use_defzone; /* whether to use the default scope zone
|
|
|
|
when unspecified */
|
|
|
|
|
2007-03-08 01:20:04 +03:00
|
|
|
#ifdef GATEWAY
|
|
|
|
extern int ip6_maxflows; /* maximum amount of flows for ip6ff */
|
2007-03-23 17:24:22 +03:00
|
|
|
extern int ip6_hashsize; /* size of hash table */
|
2007-03-08 01:20:04 +03:00
|
|
|
#endif
|
|
|
|
|
1999-06-28 10:36:47 +04:00
|
|
|
struct in6pcb;
|
1999-12-13 18:17:17 +03:00
|
|
|
|
KNF: de-__P, bzero -> memset, bcmp -> memcmp. Remove extraneous
parentheses in return statements.
Cosmetic: don't open-code TAILQ_FOREACH().
Cosmetic: change types of variables to avoid oodles of casts: in
in6_src.c, avoid casts by changing several route_in6 pointers
to struct route pointers. Remove unnecessary casts to caddr_t
elsewhere.
Pave the way for eliminating address family-specific route caches:
soon, struct route will not embed a sockaddr, but it will hold
a reference to an external sockaddr, instead. We will set the
destination sockaddr using rtcache_setdst(). (I created a stub
for it, but it isn't used anywhere, yet.) rtcache_free() will
free the sockaddr. I have extracted from rtcache_free() a helper
subroutine, rtcache_clear(). rtcache_clear() will "forget" a
cached route, but it will not forget the destination by releasing
the sockaddr. I use rtcache_clear() instead of rtcache_free()
in rtcache_update(), because rtcache_update() is not supposed
to forget the destination.
Constify:
1 Introduce const accessor for route->ro_dst, rtcache_getdst().
2 Constify the 'dst' argument to ifnet->if_output(). This
led me to constify a lot of code called by output routines.
3 Constify the sockaddr argument to protosw->pr_ctlinput. This
led me to constify a lot of code called by ctlinput routines.
4 Introduce const macros for converting from a generic sockaddr
to family-specific sockaddrs, e.g., sockaddr_in: satocsin6,
satocsin, et cetera.
2007-02-18 01:34:07 +03:00
|
|
|
int icmp6_ctloutput(int, struct socket *, int, int, struct mbuf **);
|
|
|
|
|
|
|
|
void ip6_init(void);
|
|
|
|
void ip6intr(void);
|
|
|
|
void ip6_input(struct mbuf *);
|
2007-10-29 19:54:42 +03:00
|
|
|
const struct ip6aux *ip6_getdstifaddr(struct mbuf *);
|
KNF: de-__P, bzero -> memset, bcmp -> memcmp. Remove extraneous
parentheses in return statements.
Cosmetic: don't open-code TAILQ_FOREACH().
Cosmetic: change types of variables to avoid oodles of casts: in
in6_src.c, avoid casts by changing several route_in6 pointers
to struct route pointers. Remove unnecessary casts to caddr_t
elsewhere.
Pave the way for eliminating address family-specific route caches:
soon, struct route will not embed a sockaddr, but it will hold
a reference to an external sockaddr, instead. We will set the
destination sockaddr using rtcache_setdst(). (I created a stub
for it, but it isn't used anywhere, yet.) rtcache_free() will
free the sockaddr. I have extracted from rtcache_free() a helper
subroutine, rtcache_clear(). rtcache_clear() will "forget" a
cached route, but it will not forget the destination by releasing
the sockaddr. I use rtcache_clear() instead of rtcache_free()
in rtcache_update(), because rtcache_update() is not supposed
to forget the destination.
Constify:
1 Introduce const accessor for route->ro_dst, rtcache_getdst().
2 Constify the 'dst' argument to ifnet->if_output(). This
led me to constify a lot of code called by output routines.
3 Constify the sockaddr argument to protosw->pr_ctlinput. This
led me to constify a lot of code called by ctlinput routines.
4 Introduce const macros for converting from a generic sockaddr
to family-specific sockaddrs, e.g., sockaddr_in: satocsin6,
satocsin, et cetera.
2007-02-18 01:34:07 +03:00
|
|
|
void ip6_freepcbopts(struct ip6_pktopts *);
|
|
|
|
void ip6_freemoptions(struct ip6_moptions *);
|
|
|
|
int ip6_unknown_opt(u_int8_t *, struct mbuf *, int);
|
|
|
|
u_int8_t *ip6_get_prevhdr(struct mbuf *, int);
|
|
|
|
int ip6_nexthdr(struct mbuf *, int, int, int *);
|
|
|
|
int ip6_lasthdr(struct mbuf *, int, int, int *);
|
|
|
|
|
|
|
|
struct m_tag *ip6_addaux(struct mbuf *);
|
|
|
|
struct m_tag *ip6_findaux(struct mbuf *);
|
|
|
|
void ip6_delaux(struct mbuf *);
|
|
|
|
|
|
|
|
int ip6_mforward(struct ip6_hdr *, struct ifnet *, struct mbuf *);
|
|
|
|
int ip6_process_hopopts(struct mbuf *, u_int8_t *, int, u_int32_t *,
|
|
|
|
u_int32_t *);
|
|
|
|
void ip6_savecontrol(struct in6pcb *, struct mbuf **, struct ip6_hdr *,
|
|
|
|
struct mbuf *);
|
|
|
|
void ip6_notify_pmtu(struct in6pcb *, const struct sockaddr_in6 *,
|
|
|
|
u_int32_t *);
|
|
|
|
int ip6_sysctl(int *, u_int, void *, size_t *, void *, size_t);
|
|
|
|
|
|
|
|
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 *,
|
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.
2007-05-03 00:40:22 +04:00
|
|
|
struct route *, int,
|
2003-08-23 01:53:01 +04:00
|
|
|
struct ip6_moptions *, struct socket *,
|
KNF: de-__P, bzero -> memset, bcmp -> memcmp. Remove extraneous
parentheses in return statements.
Cosmetic: don't open-code TAILQ_FOREACH().
Cosmetic: change types of variables to avoid oodles of casts: in
in6_src.c, avoid casts by changing several route_in6 pointers
to struct route pointers. Remove unnecessary casts to caddr_t
elsewhere.
Pave the way for eliminating address family-specific route caches:
soon, struct route will not embed a sockaddr, but it will hold
a reference to an external sockaddr, instead. We will set the
destination sockaddr using rtcache_setdst(). (I created a stub
for it, but it isn't used anywhere, yet.) rtcache_free() will
free the sockaddr. I have extracted from rtcache_free() a helper
subroutine, rtcache_clear(). rtcache_clear() will "forget" a
cached route, but it will not forget the destination by releasing
the sockaddr. I use rtcache_clear() instead of rtcache_free()
in rtcache_update(), because rtcache_update() is not supposed
to forget the destination.
Constify:
1 Introduce const accessor for route->ro_dst, rtcache_getdst().
2 Constify the 'dst' argument to ifnet->if_output(). This
led me to constify a lot of code called by output routines.
3 Constify the sockaddr argument to protosw->pr_ctlinput. This
led me to constify a lot of code called by ctlinput routines.
4 Introduce const macros for converting from a generic sockaddr
to family-specific sockaddrs, e.g., sockaddr_in: satocsin6,
satocsin, et cetera.
2007-02-18 01:34:07 +03:00
|
|
|
struct ifnet **);
|
|
|
|
int ip6_ctloutput(int, struct socket *, int, int, struct mbuf **);
|
|
|
|
int ip6_raw_ctloutput(int, struct socket *, int, int, struct mbuf **);
|
|
|
|
void ip6_initpktopts(struct ip6_pktopts *);
|
|
|
|
int ip6_setpktopts(struct mbuf *, struct ip6_pktopts *,
|
|
|
|
struct ip6_pktopts *, int, int);
|
|
|
|
void ip6_clearpktopts(struct ip6_pktopts *, int);
|
|
|
|
struct ip6_pktopts *ip6_copypktopts(struct ip6_pktopts *, int);
|
|
|
|
int ip6_optlen(struct in6pcb *);
|
|
|
|
|
|
|
|
int route6_input(struct mbuf **, int *, int);
|
|
|
|
|
|
|
|
void frag6_init(void);
|
|
|
|
int frag6_input(struct mbuf **, int *, int);
|
|
|
|
void frag6_slowtimo(void);
|
|
|
|
void frag6_drain(void);
|
|
|
|
|
2007-03-23 17:24:22 +03:00
|
|
|
int ip6flow_init(int);
|
2007-03-08 01:20:04 +03:00
|
|
|
struct ip6flow *ip6flow_reap(int);
|
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.
2007-05-03 00:40:22 +04:00
|
|
|
void ip6flow_create(const struct route *, struct mbuf *);
|
2007-03-08 01:20:04 +03:00
|
|
|
void ip6flow_slowtimo(void);
|
2007-03-23 17:24:22 +03:00
|
|
|
int ip6flow_invalidate_all(int);
|
2007-03-08 01:20:04 +03:00
|
|
|
|
KNF: de-__P, bzero -> memset, bcmp -> memcmp. Remove extraneous
parentheses in return statements.
Cosmetic: don't open-code TAILQ_FOREACH().
Cosmetic: change types of variables to avoid oodles of casts: in
in6_src.c, avoid casts by changing several route_in6 pointers
to struct route pointers. Remove unnecessary casts to caddr_t
elsewhere.
Pave the way for eliminating address family-specific route caches:
soon, struct route will not embed a sockaddr, but it will hold
a reference to an external sockaddr, instead. We will set the
destination sockaddr using rtcache_setdst(). (I created a stub
for it, but it isn't used anywhere, yet.) rtcache_free() will
free the sockaddr. I have extracted from rtcache_free() a helper
subroutine, rtcache_clear(). rtcache_clear() will "forget" a
cached route, but it will not forget the destination by releasing
the sockaddr. I use rtcache_clear() instead of rtcache_free()
in rtcache_update(), because rtcache_update() is not supposed
to forget the destination.
Constify:
1 Introduce const accessor for route->ro_dst, rtcache_getdst().
2 Constify the 'dst' argument to ifnet->if_output(). This
led me to constify a lot of code called by output routines.
3 Constify the sockaddr argument to protosw->pr_ctlinput. This
led me to constify a lot of code called by ctlinput routines.
4 Introduce const macros for converting from a generic sockaddr
to family-specific sockaddrs, e.g., sockaddr_in: satocsin6,
satocsin, et cetera.
2007-02-18 01:34:07 +03:00
|
|
|
void rip6_init(void);
|
|
|
|
int rip6_input(struct mbuf **, int *, int);
|
|
|
|
void rip6_ctlinput(int, const struct sockaddr *, void *);
|
|
|
|
int rip6_ctloutput(int, struct socket *, int, int, struct mbuf **);
|
Take steps to hide the radix_node implementation of the forwarding table
from the forwarding table's users:
Introduce rt_walktree() for walking the routing table and
applying a function to each rtentry. Replace most
rn_walktree() calls with it.
Use rt_getkey()/rt_setkey() to get/set a route's destination.
Keep a pointer to the sockaddr key in the rtentry, so that
rtentry users do not have to grovel in the radix_node for
the key.
Add a RTM_GET method to rtrequest. Use that instead of
radix_node lookups in, e.g., carp(4).
Add sys/net/link_proto.c, which supplies sockaddr routines for
link-layer socket addresses (sockaddr_dl).
Cosmetic:
Constify. KNF. Stop open-coding LIST_FOREACH, TAILQ_FOREACH,
et cetera. Use NULL instead of 0 for null pointers. Use
__arraycount(). Reduce gratuitous parenthesization.
Stop using variadic arguments for rip6_output(), it is
unnecessary.
Remove the unnecessary rtentry member rt_genmask and the
code to maintain it, since nothing actually used it.
Make rt_maskedcopy() easier to read by using meaningful variable
names.
Extract a subroutine intern_netmask() for looking up a netmask in
the masks table.
Start converting backslash-ridden IPv6 macros in
sys/netinet6/in6_var.h into inline subroutines that one
can read without special eyeglasses.
One functional change: when the kernel serves an RTM_GET, RTM_LOCK,
or RTM_CHANGE request, it applies the netmask (if supplied) to a
destination before searching for it in the forwarding table.
I have changed sys/netinet/ip_carp.c, carp_setroute(), to remove
the unlawful radix_node knowledge.
Apart from the changes to carp(4), netiso, ATM, and strip(4), I
have run the changes on three nodes in my wireless routing testbed,
which involves IPv4 + IPv6 dynamic routing acrobatics, and it's
working beautifully so far.
2007-07-20 00:48:52 +04:00
|
|
|
int rip6_output(struct mbuf *, struct socket *, struct sockaddr_in6 *,
|
|
|
|
struct mbuf *);
|
KNF: de-__P, bzero -> memset, bcmp -> memcmp. Remove extraneous
parentheses in return statements.
Cosmetic: don't open-code TAILQ_FOREACH().
Cosmetic: change types of variables to avoid oodles of casts: in
in6_src.c, avoid casts by changing several route_in6 pointers
to struct route pointers. Remove unnecessary casts to caddr_t
elsewhere.
Pave the way for eliminating address family-specific route caches:
soon, struct route will not embed a sockaddr, but it will hold
a reference to an external sockaddr, instead. We will set the
destination sockaddr using rtcache_setdst(). (I created a stub
for it, but it isn't used anywhere, yet.) rtcache_free() will
free the sockaddr. I have extracted from rtcache_free() a helper
subroutine, rtcache_clear(). rtcache_clear() will "forget" a
cached route, but it will not forget the destination by releasing
the sockaddr. I use rtcache_clear() instead of rtcache_free()
in rtcache_update(), because rtcache_update() is not supposed
to forget the destination.
Constify:
1 Introduce const accessor for route->ro_dst, rtcache_getdst().
2 Constify the 'dst' argument to ifnet->if_output(). This
led me to constify a lot of code called by output routines.
3 Constify the sockaddr argument to protosw->pr_ctlinput. This
led me to constify a lot of code called by ctlinput routines.
4 Introduce const macros for converting from a generic sockaddr
to family-specific sockaddrs, e.g., sockaddr_in: satocsin6,
satocsin, et cetera.
2007-02-18 01:34:07 +03:00
|
|
|
int rip6_usrreq(struct socket *,
|
|
|
|
int, struct mbuf *, struct mbuf *, struct mbuf *, struct lwp *);
|
|
|
|
|
|
|
|
int dest6_input(struct mbuf **, int *, int);
|
|
|
|
int none_input(struct mbuf **, int *, int);
|
|
|
|
|
|
|
|
struct route;
|
|
|
|
|
|
|
|
struct in6_addr *in6_selectsrc(struct sockaddr_in6 *,
|
|
|
|
struct ip6_pktopts *, struct ip6_moptions *, struct route *,
|
|
|
|
struct in6_addr *, struct ifnet **, int *);
|
|
|
|
int in6_selectroute(struct sockaddr_in6 *, struct ip6_pktopts *,
|
|
|
|
struct ip6_moptions *, struct route *, struct ifnet **,
|
|
|
|
struct rtentry **, int);
|
|
|
|
|
|
|
|
u_int32_t ip6_randomid(void);
|
|
|
|
u_int32_t ip6_randomflowlabel(void);
|
1999-06-28 10:36:47 +04:00
|
|
|
#endif /* _KERNEL */
|
|
|
|
|
|
|
|
#endif /* !_NETINET6_IP6_VAR_H_ */
|