2011-05-24 22:07:11 +04:00
|
|
|
/* $NetBSD: nd6.h,v 1.54 2011/05/24 18:07:11 spz Exp $ */
|
2002-06-09 01:22:29 +04:00
|
|
|
/* $KAME: nd6.h,v 1.95 2002/06/08 11:31:06 itojun 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-04-16 19:00:56 +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-04-16 19:00:56 +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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _NETINET6_ND6_H_
|
|
|
|
#define _NETINET6_ND6_H_
|
|
|
|
|
2000-02-26 11:39:18 +03:00
|
|
|
/* see net/route.h, or net/if_inarp.h */
|
|
|
|
#ifndef RTF_ANNOUNCE
|
|
|
|
#define RTF_ANNOUNCE RTF_PROTO2
|
|
|
|
#endif
|
|
|
|
|
1999-06-28 10:36:47 +04:00
|
|
|
#include <sys/queue.h>
|
2000-03-23 10:01:25 +03:00
|
|
|
#include <sys/callout.h>
|
1999-06-28 10:36:47 +04:00
|
|
|
|
|
|
|
struct llinfo_nd6 {
|
|
|
|
struct llinfo_nd6 *ln_next;
|
|
|
|
struct llinfo_nd6 *ln_prev;
|
|
|
|
struct rtentry *ln_rt;
|
|
|
|
struct mbuf *ln_hold; /* last packet until resolved/timeout */
|
|
|
|
long ln_asked; /* number of queries already sent for this addr */
|
|
|
|
u_long ln_expire; /* lifetime for NDP state transition */
|
|
|
|
short ln_state; /* reachability state */
|
|
|
|
short ln_router; /* 2^0: ND6 router bit */
|
2000-07-06 16:36:18 +04:00
|
|
|
int ln_byhint; /* # of times we made it reachable by UL hint */
|
2003-06-27 12:41:08 +04:00
|
|
|
|
|
|
|
long ln_ntick;
|
|
|
|
struct callout ln_timer_ch;
|
1999-06-28 10:36:47 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#define ND6_LLINFO_NOSTATE -2
|
2001-02-23 09:41:50 +03:00
|
|
|
/*
|
|
|
|
* We don't need the WAITDELETE state any more, but we keep the definition
|
|
|
|
* in a comment line instead of removing it. This is necessary to avoid
|
|
|
|
* unintentionally reusing the value for another purpose, which might
|
|
|
|
* affect backward compatibility with old applications.
|
|
|
|
* (20000711 jinmei@kame.net)
|
|
|
|
*/
|
|
|
|
/* #define ND6_LLINFO_WAITDELETE -1 */
|
1999-06-28 10:36:47 +04:00
|
|
|
#define ND6_LLINFO_INCOMPLETE 0
|
|
|
|
#define ND6_LLINFO_REACHABLE 1
|
|
|
|
#define ND6_LLINFO_STALE 2
|
|
|
|
#define ND6_LLINFO_DELAY 3
|
|
|
|
#define ND6_LLINFO_PROBE 4
|
|
|
|
|
1999-12-13 18:17:17 +03:00
|
|
|
#define ND6_IS_LLINFO_PROBREACH(n) ((n)->ln_state > ND6_LLINFO_INCOMPLETE)
|
2006-03-06 02:47:08 +03:00
|
|
|
#define ND6_LLINFO_PERMANENT(n) (((n)->ln_expire == 0) && ((n)->ln_state > ND6_LLINFO_INCOMPLETE))
|
2002-05-29 11:53:39 +04:00
|
|
|
|
1999-06-28 10:36:47 +04:00
|
|
|
struct nd_ifinfo {
|
|
|
|
u_int32_t linkmtu; /* LinkMTU */
|
|
|
|
u_int32_t maxmtu; /* Upper bound of LinkMTU */
|
|
|
|
u_int32_t basereachable; /* BaseReachableTime */
|
|
|
|
u_int32_t reachable; /* Reachable Time */
|
|
|
|
u_int32_t retrans; /* Retrans Timer */
|
2000-04-16 19:27:59 +04:00
|
|
|
u_int32_t flags; /* Flags */
|
1999-12-13 18:17:17 +03:00
|
|
|
int recalctm; /* BaseReacable re-calculation timer */
|
1999-06-28 10:36:47 +04:00
|
|
|
u_int8_t chlim; /* CurHopLimit */
|
2002-05-29 11:53:39 +04:00
|
|
|
u_int8_t initialized; /* Flag to see the entry is initialized */
|
|
|
|
/* the following 3 members are for privacy extension for addrconf */
|
|
|
|
u_int8_t randomseed0[8]; /* upper 64 bits of MD5 digest */
|
|
|
|
u_int8_t randomseed1[8]; /* lower 64 bits (usually the EUI64 IFID) */
|
|
|
|
u_int8_t randomid[8]; /* current random ID */
|
1999-06-28 10:36:47 +04:00
|
|
|
};
|
|
|
|
|
2009-11-06 23:41:22 +03:00
|
|
|
#define ND6_IFF_PERFORMNUD 0x01
|
|
|
|
#define ND6_IFF_ACCEPT_RTADV 0x02 /* See "RTADV Key", below. */
|
|
|
|
#define ND6_IFF_PREFER_SOURCE 0x04 /* XXX: not related to ND. */
|
|
|
|
#define ND6_IFF_IFDISABLED 0x08 /* IPv6 operation is disabled due to
|
|
|
|
* DAD failure. (XXX: not ND-specific)
|
|
|
|
*/
|
|
|
|
#define ND6_IFF_OVERRIDE_RTADV 0x10 /* See "RTADV Key", below. */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* RTADV Key
|
|
|
|
*
|
|
|
|
* The flags ND6_IFF_ACCEPT_RTADV and ND6_IFF_OVERRIDE_RTADV form a
|
|
|
|
* tri-state variable. (There are actually four different states, but
|
|
|
|
* two of the states are functionally identical.)
|
|
|
|
*
|
|
|
|
* ND6_IFF_OVERRIDE_RTADV or 0: This interface does not accept
|
|
|
|
* Router Advertisements.
|
|
|
|
*
|
|
|
|
* ND6_IFF_OVERRIDE_RTADV|
|
|
|
|
* ND6_IFF_ACCEPT_RTADV: This interface accepts Router
|
|
|
|
* Advertisements regardless of the
|
|
|
|
* global setting, ip6_accept_rtadv.
|
|
|
|
*
|
|
|
|
* ND6_IFF_ACCEPT_RTADV: This interface follows the global setting,
|
|
|
|
* ip6_accept_rtadv. If ip6_accept_rtadv == 0,
|
|
|
|
* this interface does not accept Router
|
|
|
|
* Advertisements. If ip6_accept_rtadv != 0,
|
|
|
|
* this interface does accept them.
|
|
|
|
*/
|
2000-04-16 19:27:59 +04:00
|
|
|
|
2002-05-29 11:53:39 +04:00
|
|
|
#ifdef _KERNEL
|
|
|
|
#define ND_IFINFO(ifp) \
|
|
|
|
(((struct in6_ifextra *)(ifp)->if_afdata[AF_INET6])->nd_ifinfo)
|
|
|
|
#define IN6_LINKMTU(ifp) \
|
|
|
|
((ND_IFINFO(ifp)->linkmtu && ND_IFINFO(ifp)->linkmtu < (ifp)->if_mtu) \
|
2002-06-05 05:10:54 +04:00
|
|
|
? ND_IFINFO(ifp)->linkmtu \
|
2002-06-07 06:31:04 +04:00
|
|
|
: ((ND_IFINFO(ifp)->maxmtu && ND_IFINFO(ifp)->maxmtu < (ifp)->if_mtu) \
|
2002-06-05 05:10:54 +04:00
|
|
|
? ND_IFINFO(ifp)->maxmtu : (ifp)->if_mtu))
|
2002-05-29 11:53:39 +04:00
|
|
|
#endif
|
|
|
|
|
1999-06-28 10:36:47 +04:00
|
|
|
struct in6_nbrinfo {
|
|
|
|
char ifname[IFNAMSIZ]; /* if name, e.g. "en0" */
|
|
|
|
struct in6_addr addr; /* IPv6 address of the neighbor */
|
|
|
|
long asked; /* number of queries already sent for this addr */
|
|
|
|
int isrouter; /* if it acts as a router */
|
|
|
|
int state; /* reachability state */
|
|
|
|
int expire; /* lifetime for NDP state transition */
|
|
|
|
};
|
|
|
|
|
|
|
|
#define DRLSTSIZ 10
|
|
|
|
#define PRLSTSIZ 10
|
|
|
|
struct in6_drlist {
|
|
|
|
char ifname[IFNAMSIZ];
|
|
|
|
struct {
|
|
|
|
struct in6_addr rtaddr;
|
|
|
|
u_char flags;
|
|
|
|
u_short rtlifetime;
|
|
|
|
u_long expire;
|
|
|
|
u_short if_index;
|
|
|
|
} defrouter[DRLSTSIZ];
|
|
|
|
};
|
|
|
|
|
2002-06-09 01:22:29 +04:00
|
|
|
struct in6_defrouter {
|
|
|
|
struct sockaddr_in6 rtaddr;
|
|
|
|
u_char flags;
|
|
|
|
u_short rtlifetime;
|
|
|
|
u_long expire;
|
|
|
|
u_short if_index;
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef _KERNEL
|
|
|
|
struct in6_oprlist {
|
|
|
|
char ifname[IFNAMSIZ];
|
|
|
|
struct {
|
|
|
|
struct in6_addr prefix;
|
|
|
|
struct prf_ra raflags;
|
|
|
|
u_char prefixlen;
|
|
|
|
u_char origin;
|
|
|
|
u_long vltime;
|
|
|
|
u_long pltime;
|
|
|
|
u_long expire;
|
|
|
|
u_short if_index;
|
|
|
|
u_short advrtrs; /* number of advertisement routers */
|
|
|
|
struct in6_addr advrtr[DRLSTSIZ]; /* XXX: explicit limit */
|
|
|
|
} prefix[PRLSTSIZ];
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
1999-06-28 10:36:47 +04:00
|
|
|
struct in6_prlist {
|
|
|
|
char ifname[IFNAMSIZ];
|
|
|
|
struct {
|
|
|
|
struct in6_addr prefix;
|
|
|
|
struct prf_ra raflags;
|
|
|
|
u_char prefixlen;
|
2000-02-26 11:39:18 +03:00
|
|
|
u_char origin;
|
2002-06-09 01:22:29 +04:00
|
|
|
u_int32_t vltime;
|
|
|
|
u_int32_t pltime;
|
|
|
|
time_t expire;
|
1999-06-28 10:36:47 +04:00
|
|
|
u_short if_index;
|
|
|
|
u_short advrtrs; /* number of advertisement routers */
|
|
|
|
struct in6_addr advrtr[DRLSTSIZ]; /* XXX: explicit limit */
|
|
|
|
} prefix[PRLSTSIZ];
|
|
|
|
};
|
|
|
|
|
2002-06-09 01:22:29 +04:00
|
|
|
struct in6_prefix {
|
|
|
|
struct sockaddr_in6 prefix;
|
|
|
|
struct prf_ra raflags;
|
|
|
|
u_char prefixlen;
|
|
|
|
u_char origin;
|
|
|
|
u_int32_t vltime;
|
|
|
|
u_int32_t pltime;
|
|
|
|
time_t expire;
|
|
|
|
u_int32_t flags;
|
|
|
|
int refcnt;
|
|
|
|
u_short if_index;
|
|
|
|
u_short advrtrs; /* number of advertisement routers */
|
|
|
|
/* struct sockaddr_in6 advrtr[] */
|
|
|
|
};
|
|
|
|
|
2002-05-29 11:53:39 +04:00
|
|
|
#ifdef _KERNEL
|
|
|
|
struct in6_ondireq {
|
|
|
|
char ifname[IFNAMSIZ];
|
|
|
|
struct {
|
|
|
|
u_int32_t linkmtu; /* LinkMTU */
|
|
|
|
u_int32_t maxmtu; /* Upper bound of LinkMTU */
|
|
|
|
u_int32_t basereachable; /* BaseReachableTime */
|
|
|
|
u_int32_t reachable; /* Reachable Time */
|
|
|
|
u_int32_t retrans; /* Retrans Timer */
|
|
|
|
u_int32_t flags; /* Flags */
|
|
|
|
int recalctm; /* BaseReacable re-calculation timer */
|
|
|
|
u_int8_t chlim; /* CurHopLimit */
|
|
|
|
u_int8_t receivedra;
|
|
|
|
} ndi;
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
1999-06-28 10:36:47 +04:00
|
|
|
struct in6_ndireq {
|
|
|
|
char ifname[IFNAMSIZ];
|
|
|
|
struct nd_ifinfo ndi;
|
|
|
|
};
|
|
|
|
|
1999-12-13 18:17:17 +03:00
|
|
|
struct in6_ndifreq {
|
|
|
|
char ifname[IFNAMSIZ];
|
|
|
|
u_long ifindex;
|
|
|
|
};
|
|
|
|
|
2002-06-09 01:22:29 +04:00
|
|
|
/* Prefix status */
|
|
|
|
#define NDPRF_ONLINK 0x1
|
|
|
|
#define NDPRF_DETACHED 0x2
|
|
|
|
#define NDPRF_HOME 0x4
|
1999-12-13 18:17:17 +03:00
|
|
|
|
1999-06-28 10:36:47 +04:00
|
|
|
/* protocol constants */
|
2001-12-18 06:04:02 +03:00
|
|
|
#define MAX_RTR_SOLICITATION_DELAY 1 /* 1sec */
|
|
|
|
#define RTR_SOLICITATION_INTERVAL 4 /* 4sec */
|
1999-06-28 10:36:47 +04:00
|
|
|
#define MAX_RTR_SOLICITATIONS 3
|
|
|
|
|
2009-01-15 21:20:48 +03:00
|
|
|
#define ND6_INFINITE_LIFETIME ((u_int32_t)~0)
|
1999-06-28 10:36:47 +04:00
|
|
|
|
|
|
|
#ifdef _KERNEL
|
|
|
|
/* node constants */
|
|
|
|
#define MAX_REACHABLE_TIME 3600000 /* msec */
|
|
|
|
#define REACHABLE_TIME 30000 /* msec */
|
|
|
|
#define RETRANS_TIMER 1000 /* msec */
|
|
|
|
#define MIN_RANDOM_FACTOR 512 /* 1024 * 0.5 */
|
|
|
|
#define MAX_RANDOM_FACTOR 1536 /* 1024 * 1.5 */
|
2006-03-06 02:47:08 +03:00
|
|
|
#define DEF_TEMP_VALID_LIFETIME 604800 /* 1 week */
|
|
|
|
#define DEF_TEMP_PREFERRED_LIFETIME 86400 /* 1 day */
|
|
|
|
#define TEMPADDR_REGEN_ADVANCE 5 /* sec */
|
|
|
|
#define MAX_TEMP_DESYNC_FACTOR 600 /* 10 min */
|
1999-06-28 10:36:47 +04:00
|
|
|
#define ND_COMPUTE_RTIME(x) \
|
2002-05-28 15:19:17 +04:00
|
|
|
(((MIN_RANDOM_FACTOR * (x >> 10)) + (arc4random() & \
|
1999-06-28 10:36:47 +04:00
|
|
|
((MAX_RANDOM_FACTOR - MIN_RANDOM_FACTOR) * (x >> 10)))) /1000)
|
|
|
|
|
1999-12-13 18:17:17 +03:00
|
|
|
TAILQ_HEAD(nd_drhead, nd_defrouter);
|
1999-06-28 10:36:47 +04:00
|
|
|
struct nd_defrouter {
|
1999-12-13 18:17:17 +03:00
|
|
|
TAILQ_ENTRY(nd_defrouter) dr_entry;
|
1999-06-28 10:36:47 +04:00
|
|
|
struct in6_addr rtaddr;
|
2002-06-09 01:22:29 +04:00
|
|
|
u_char flags; /* flags on RA message */
|
1999-06-28 10:36:47 +04:00
|
|
|
u_short rtlifetime;
|
|
|
|
u_long expire;
|
|
|
|
struct ifnet *ifp;
|
2002-06-09 01:22:29 +04:00
|
|
|
int installed; /* is installed into kernel routing table */
|
1999-06-28 10:36:47 +04:00
|
|
|
};
|
|
|
|
|
2006-03-06 02:47:08 +03:00
|
|
|
struct nd_prefixctl {
|
|
|
|
struct ifnet *ndpr_ifp;
|
|
|
|
|
|
|
|
/* prefix */
|
|
|
|
struct sockaddr_in6 ndpr_prefix;
|
|
|
|
u_char ndpr_plen;
|
|
|
|
|
|
|
|
u_int32_t ndpr_vltime; /* advertised valid lifetime */
|
|
|
|
u_int32_t ndpr_pltime; /* advertised preferred lifetime */
|
|
|
|
|
|
|
|
struct prf_ra ndpr_flags;
|
|
|
|
};
|
|
|
|
|
1999-06-28 10:36:47 +04:00
|
|
|
struct nd_prefix {
|
1999-12-13 18:17:17 +03:00
|
|
|
struct ifnet *ndpr_ifp;
|
1999-06-28 10:36:47 +04:00
|
|
|
LIST_ENTRY(nd_prefix) ndpr_entry;
|
|
|
|
struct sockaddr_in6 ndpr_prefix; /* prefix */
|
|
|
|
struct in6_addr ndpr_mask; /* netmask derived from the prefix */
|
2002-06-09 01:22:29 +04:00
|
|
|
|
1999-06-28 10:36:47 +04:00
|
|
|
u_int32_t ndpr_vltime; /* advertised valid lifetime */
|
|
|
|
u_int32_t ndpr_pltime; /* advertised preferred lifetime */
|
2002-06-09 01:22:29 +04:00
|
|
|
|
1999-06-28 10:36:47 +04:00
|
|
|
time_t ndpr_expire; /* expiration time of the prefix */
|
|
|
|
time_t ndpr_preferred; /* preferred time of the prefix */
|
2002-06-09 01:22:29 +04:00
|
|
|
time_t ndpr_lastupdate; /* reception time of last advertisement */
|
|
|
|
|
1999-12-13 18:17:17 +03:00
|
|
|
struct prf_ra ndpr_flags;
|
2002-06-09 01:22:29 +04:00
|
|
|
u_int32_t ndpr_stateflags; /* actual state flags */
|
1999-06-28 10:36:47 +04:00
|
|
|
/* list of routers that advertise the prefix: */
|
|
|
|
LIST_HEAD(pr_rtrhead, nd_pfxrouter) ndpr_advrtrs;
|
1999-12-13 18:17:17 +03:00
|
|
|
u_char ndpr_plen;
|
2002-06-09 01:22:29 +04:00
|
|
|
int ndpr_refcnt; /* reference couter from addresses */
|
1999-06-28 10:36:47 +04:00
|
|
|
};
|
|
|
|
|
1999-12-13 18:17:17 +03:00
|
|
|
#define ndpr_raf ndpr_flags
|
|
|
|
#define ndpr_raf_onlink ndpr_flags.onlink
|
|
|
|
#define ndpr_raf_auto ndpr_flags.autonomous
|
2002-06-09 01:22:29 +04:00
|
|
|
#define ndpr_raf_router ndpr_flags.router
|
1999-06-28 10:36:47 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Message format for use in obtaining information about prefixes
|
|
|
|
* from inet6 sysctl function
|
|
|
|
*/
|
|
|
|
struct inet6_ndpr_msghdr {
|
|
|
|
u_short inpm_msglen; /* to skip over non-understood messages */
|
2001-06-11 05:50:48 +04:00
|
|
|
u_char inpm_version; /* future binary compatibility */
|
1999-06-28 10:36:47 +04:00
|
|
|
u_char inpm_type; /* message type */
|
|
|
|
struct in6_addr inpm_prefix;
|
|
|
|
u_long prm_vltim;
|
|
|
|
u_long prm_pltime;
|
|
|
|
u_long prm_expire;
|
|
|
|
u_long prm_preferred;
|
|
|
|
struct in6_prflags prm_flags;
|
|
|
|
u_short prm_index; /* index for associated ifp */
|
|
|
|
u_char prm_plen; /* length of prefix in bits */
|
|
|
|
};
|
|
|
|
|
|
|
|
#define prm_raf_onlink prm_flags.prf_ra.onlink
|
|
|
|
#define prm_raf_auto prm_flags.prf_ra.autonomous
|
|
|
|
|
|
|
|
#define prm_statef_onlink prm_flags.prf_state.onlink
|
|
|
|
|
|
|
|
#define prm_rrf_decrvalid prm_flags.prf_rr.decrvalid
|
|
|
|
#define prm_rrf_decrprefd prm_flags.prf_rr.decrprefd
|
|
|
|
|
|
|
|
struct nd_pfxrouter {
|
|
|
|
LIST_ENTRY(nd_pfxrouter) pfr_entry;
|
|
|
|
struct nd_defrouter *router;
|
|
|
|
};
|
|
|
|
|
|
|
|
LIST_HEAD(nd_prhead, nd_prefix);
|
|
|
|
|
2003-02-01 09:23:35 +03:00
|
|
|
#include <sys/mallocvar.h>
|
|
|
|
MALLOC_DECLARE(M_IP6NDP);
|
|
|
|
|
1999-06-28 10:36:47 +04:00
|
|
|
/* nd6.c */
|
|
|
|
extern int nd6_prune;
|
|
|
|
extern int nd6_delay;
|
|
|
|
extern int nd6_umaxtries;
|
|
|
|
extern int nd6_mmaxtries;
|
|
|
|
extern int nd6_useloopback;
|
2000-07-06 16:36:18 +04:00
|
|
|
extern int nd6_maxnudhint;
|
2001-02-23 11:02:41 +03:00
|
|
|
extern int nd6_gctimer;
|
1999-06-28 10:36:47 +04:00
|
|
|
extern struct llinfo_nd6 llinfo_nd6;
|
|
|
|
extern struct nd_drhead nd_defrouter;
|
|
|
|
extern struct nd_prhead nd_prefix;
|
2001-02-07 11:59:47 +03:00
|
|
|
extern int nd6_debug;
|
|
|
|
|
2002-11-02 10:30:55 +03:00
|
|
|
#define nd6log(x) do { if (nd6_debug) log x; } while (/*CONSTCOND*/ 0)
|
1999-06-28 10:36:47 +04:00
|
|
|
|
2000-03-23 10:01:25 +03:00
|
|
|
extern struct callout nd6_timer_ch;
|
|
|
|
|
1999-12-13 18:17:17 +03:00
|
|
|
/* nd6_rtr.c */
|
|
|
|
extern int nd6_defifindex;
|
2006-03-06 02:47:08 +03:00
|
|
|
extern int ip6_desync_factor; /* seconds */
|
|
|
|
extern u_int32_t ip6_temp_preferred_lifetime; /* seconds */
|
|
|
|
extern u_int32_t ip6_temp_valid_lifetime; /* seconds */
|
|
|
|
extern int ip6_temp_regen_advance; /* seconds */
|
2011-05-24 22:07:11 +04:00
|
|
|
extern int nd6_numroutes;
|
1999-12-13 18:17:17 +03:00
|
|
|
|
1999-06-28 10:36:47 +04:00
|
|
|
union nd_opts {
|
2001-12-18 06:04:02 +03:00
|
|
|
struct nd_opt_hdr *nd_opt_array[8];
|
1999-06-28 10:36:47 +04:00
|
|
|
struct {
|
|
|
|
struct nd_opt_hdr *zero;
|
|
|
|
struct nd_opt_hdr *src_lladdr;
|
|
|
|
struct nd_opt_hdr *tgt_lladdr;
|
2002-05-29 11:53:39 +04:00
|
|
|
struct nd_opt_prefix_info *pi_beg; /* multiple opts, start */
|
1999-06-28 10:36:47 +04:00
|
|
|
struct nd_opt_rd_hdr *rh;
|
|
|
|
struct nd_opt_mtu *mtu;
|
|
|
|
struct nd_opt_hdr *search; /* multiple opts */
|
|
|
|
struct nd_opt_hdr *last; /* multiple opts */
|
|
|
|
int done;
|
|
|
|
struct nd_opt_prefix_info *pi_end;/* multiple opts, end */
|
|
|
|
} nd_opt_each;
|
|
|
|
};
|
|
|
|
#define nd_opts_src_lladdr nd_opt_each.src_lladdr
|
|
|
|
#define nd_opts_tgt_lladdr nd_opt_each.tgt_lladdr
|
|
|
|
#define nd_opts_pi nd_opt_each.pi_beg
|
|
|
|
#define nd_opts_pi_end nd_opt_each.pi_end
|
|
|
|
#define nd_opts_rh nd_opt_each.rh
|
|
|
|
#define nd_opts_mtu nd_opt_each.mtu
|
|
|
|
#define nd_opts_search nd_opt_each.search
|
|
|
|
#define nd_opts_last nd_opt_each.last
|
|
|
|
#define nd_opts_done nd_opt_each.done
|
|
|
|
|
|
|
|
/* XXX: need nd6_var.h?? */
|
|
|
|
/* nd6.c */
|
2007-03-16 02:35:25 +03:00
|
|
|
void nd6_init(void);
|
|
|
|
struct nd_ifinfo *nd6_ifattach(struct ifnet *);
|
|
|
|
void nd6_ifdetach(struct nd_ifinfo *);
|
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 nd6_is_addr_neighbor(const struct sockaddr_in6 *, struct ifnet *);
|
2007-03-16 02:35:25 +03:00
|
|
|
void nd6_option_init(void *, int, union nd_opts *);
|
|
|
|
struct nd_opt_hdr *nd6_option(union nd_opts *);
|
|
|
|
int nd6_options(union nd_opts *);
|
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 rtentry *nd6_lookup(const struct in6_addr *, int, struct ifnet *);
|
2007-03-16 02:35:25 +03:00
|
|
|
void nd6_setmtu(struct ifnet *);
|
|
|
|
void nd6_llinfo_settimer(struct llinfo_nd6 *, long);
|
|
|
|
void nd6_timer(void *);
|
|
|
|
void nd6_purge(struct ifnet *);
|
|
|
|
void nd6_nud_hint(struct rtentry *, struct in6_addr *, int);
|
|
|
|
int nd6_resolve(struct ifnet *, struct rtentry *,
|
|
|
|
struct mbuf *, struct sockaddr *, u_char *);
|
2008-10-24 21:07:33 +04:00
|
|
|
void nd6_rtrequest(int, struct rtentry *, const struct rt_addrinfo *);
|
2007-03-16 02:35:25 +03:00
|
|
|
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 *,
|
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
|
|
|
const struct sockaddr_in6 *, struct rtentry *);
|
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 nd6_storelladdr(const struct ifnet *, const struct rtentry *, struct mbuf *,
|
|
|
|
const struct sockaddr *, uint8_t *, size_t);
|
2007-03-16 02:35:25 +03:00
|
|
|
int nd6_sysctl(int, void *, size_t *, void *, size_t);
|
|
|
|
int nd6_need_cache(struct ifnet *);
|
2007-05-17 04:53:26 +04:00
|
|
|
void nd6_llinfo_release_pkts(struct llinfo_nd6 *, struct ifnet *,
|
|
|
|
struct rtentry *);
|
1999-06-28 10:36:47 +04:00
|
|
|
|
|
|
|
/* nd6_nbr.c */
|
2007-03-16 02:35:25 +03:00
|
|
|
void nd6_na_input(struct mbuf *, int, int);
|
|
|
|
void nd6_na_output(struct ifnet *, const struct in6_addr *,
|
2007-08-07 08:35:42 +04:00
|
|
|
const struct in6_addr *, u_long, int, const struct sockaddr *);
|
2007-03-16 02:35:25 +03:00
|
|
|
void nd6_ns_input(struct mbuf *, int, int);
|
|
|
|
void nd6_ns_output(struct ifnet *, const struct in6_addr *,
|
|
|
|
const struct in6_addr *, struct llinfo_nd6 *, int);
|
Use malloc(9) for sockaddrs instead of pool(9), and remove dom_sa_pool
and dom_sa_len members from struct domain. Pools of fixed-size
objects are too rigid for sockaddr_dls, whose size can vary over
a wide range.
Return sockaddr_dl to its "historical" size. Now that I'm using
malloc(9) instead of pool(9) to allocate sockaddr_dl, I can create
a sockaddr_dl of any size in the kernel, so expanding sockaddr_dl
is useless.
Avoid using sizeof(struct sockaddr_dl) in the kernel.
Introduce sockaddr_dl_alloc() for allocating & initializing an
arbitrary sockaddr_dl on the heap.
Add an argument, the sockaddr length, to sockaddr_alloc(),
sockaddr_copy(), and sockaddr_dl_setaddr().
Constify: LLADDR() -> CLLADDR().
Where the kernel overwrites LLADDR(), use sockaddr_dl_setaddr(),
instead. Used properly, sockaddr_dl_setaddr() will not overrun
the end of the sockaddr.
2007-08-30 06:17:34 +04:00
|
|
|
const void *nd6_ifptomac(const struct ifnet *);
|
2007-03-16 02:35:25 +03:00
|
|
|
void nd6_dad_start(struct ifaddr *, int);
|
|
|
|
void nd6_dad_stop(struct ifaddr *);
|
|
|
|
void nd6_dad_duplicated(struct ifaddr *);
|
1999-06-28 10:36:47 +04:00
|
|
|
|
|
|
|
/* nd6_rtr.c */
|
2007-03-16 02:35:25 +03:00
|
|
|
void nd6_rs_input(struct mbuf *, int, int);
|
|
|
|
void nd6_ra_input(struct mbuf *, int, int);
|
|
|
|
void prelist_del(struct nd_prefix *);
|
|
|
|
void defrouter_addreq(struct nd_defrouter *);
|
|
|
|
void defrouter_reset(void);
|
|
|
|
void defrouter_select(void);
|
|
|
|
void defrtrlist_del(struct nd_defrouter *);
|
|
|
|
void prelist_remove(struct nd_prefix *);
|
|
|
|
int nd6_prelist_add(struct nd_prefixctl *, struct nd_defrouter *,
|
|
|
|
struct nd_prefix **);
|
|
|
|
int nd6_prefix_onlink(struct nd_prefix *);
|
|
|
|
int nd6_prefix_offlink(struct nd_prefix *);
|
|
|
|
void pfxlist_onlink_check(void);
|
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
|
|
|
struct nd_defrouter *defrouter_lookup(const struct in6_addr *, struct ifnet *);
|
2007-03-16 02:35:25 +03:00
|
|
|
struct nd_prefix *nd6_prefix_lookup(struct nd_prefixctl *);
|
|
|
|
int in6_ifdel(struct ifnet *, struct in6_addr *);
|
|
|
|
void rt6_flush(struct in6_addr *, struct ifnet *);
|
|
|
|
int nd6_setdefaultiface(int);
|
|
|
|
int in6_tmpifadd(const struct in6_ifaddr *, int, int);
|
2009-11-06 23:41:22 +03:00
|
|
|
bool nd6_accepts_rtadv(const struct nd_ifinfo *);
|
1999-06-28 10:36:47 +04:00
|
|
|
|
|
|
|
#endif /* _KERNEL */
|
|
|
|
|
2005-12-11 02:31:41 +03:00
|
|
|
#endif /* !_NETINET6_ND6_H_ */
|