NetBSD/sys/sys
dyoung 72f0a6dfb0 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-02 20:40:22 +00:00
..
acct.h u_intN_t -> uintN_t 2005-12-26 18:41:36 +00:00
agpio.h u_intN_t -> uintN_t 2005-12-26 18:41:36 +00:00
aio.h Import of POSIX Asynchronous I/O. 2007-04-30 14:44:28 +00:00
ansi.h merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
ataio.h Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
audioio.h Pull in <string.h> if !_KERNEL, otherwise gcc4 complains about no 2006-06-18 20:45:09 +00:00
blist.h merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
boot_flag.h merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
bootblock.h Add a magic number for fatboot.S 2007-01-01 22:13:18 +00:00
bswap.h make sure bswap64() returns an uint64_t, not an unsigned long long, 2006-05-22 16:28:27 +00:00
buf.h Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
bufq_impl.h Change "inline" back to "__inline" in .h files -- C99 is still too 2006-02-16 20:17:12 +00:00
bufq.h merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
callback.h make callback.h include necessary headers by itself 2006-08-28 13:40:44 +00:00
callout.h Merge newlock2 to head. 2007-02-09 21:55:00 +00:00
cc_microtime.h merge FreeBSD timecounters from branch simonb-timecounters 2006-06-07 22:33:33 +00:00
cdefs_aout.h Add __weak_reference macro in a way that it works with both gcc < 4 and 2006-05-18 17:55:38 +00:00
cdefs_elf.h Add __weak_reference macro in a way that it works with both gcc < 4 and 2006-05-18 17:55:38 +00:00
cdefs.h Cosmetic: join lines. 2006-11-13 05:44:37 +00:00
cdio.h Fix small comment's missing hyphen 2006-08-10 14:49:14 +00:00
chio.h u_intN_t -> uintN_t 2005-12-26 18:41:36 +00:00
clockctl.h Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
condvar.h Make cv_has_waiters() return type bool. 2007-03-29 17:39:34 +00:00
conf.h Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
core.h u_intN_t -> uintN_t 2005-12-26 18:41:36 +00:00
cpu_data.h Merge newlock2 to head. 2007-02-09 21:55:00 +00:00
debug.h Merge newlock2 to head. 2007-02-09 21:55:00 +00:00
device.h Make the attach functions for real and pseudo devices share as much code 2007-03-05 20:32:43 +00:00
dir.h merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
dirent.h u_intN_t -> uintN_t 2005-12-26 18:41:36 +00:00
disk.h Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
disklabel_acorn.h merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
disklabel_gpt.h Add the Apple HFS UUID for the Intel based mac's. From FreeBSD. 2006-08-13 15:31:21 +00:00
disklabel.h Chech for _LOCORE (aka asm source) before defining some enums instead 2007-03-10 16:42:04 +00:00
dkbad.h u_intN_t -> uintN_t 2005-12-26 18:41:36 +00:00
dkio.h - Add a new disk ioctl (DIOCGDISKINFO) to get the disk-info dictionary 2006-10-25 04:04:45 +00:00
dkstat.h u_intN_t -> uintN_t 2005-12-26 18:41:36 +00:00
domain.h Eliminate address family-specific route caches (struct route, struct 2007-05-02 20:40:22 +00:00
drvctlio.h - Add a new DRVCTLCOMMAND ioctl to /dev/drvctl. This is a generic 2006-09-22 04:37:36 +00:00
dvdio.h u_intN_t -> uintN_t 2005-12-26 18:41:36 +00:00
endian.h More efficient endian conversion functions when compiling with GCC as 2007-01-27 03:57:44 +00:00
envsys.h Add bio(4) and associated bioctl(8) from OpenBSD, a driver control block 2007-05-01 17:18:52 +00:00
errno.h Changed error message of ENOPROTOOPT to "Protocol option not available". 2006-10-31 00:38:06 +00:00
evcnt.h Add missing initializer 2006-08-28 00:16:54 +00:00
event.h merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
eventvar.h merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
exec_aout.h u_intN_t -> uintN_t 2005-12-26 18:41:36 +00:00
exec_coff.h merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
exec_ecoff.h merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
exec_elf.h Make sys/exec_elf.h and machine/elf_machdep.h available to host 2006-11-22 15:08:47 +00:00
exec_macho.h u_intN_t -> uintN_t 2005-12-26 18:41:36 +00:00
exec_script.h merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
exec.h Change the way that emulations locate files within the emulation root to 2007-04-22 08:29:55 +00:00
extattr.h integrate kauth. 2006-05-14 21:31:52 +00:00
extent.h Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
fcntl.h add support for O_DIRECT (I/O directly to application memory, 2006-10-05 14:48:32 +00:00
fd_set.h merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
fdio.h
featuretest.h merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
file.h integrate kauth. 2006-05-14 21:31:52 +00:00
fileassoc.h PR/35253: YAMAMOTO Takashi: fileassoc hash size problem 2007-02-06 01:09:48 +00:00
filedesc.h Change the way that emulations locate files within the emulation root to 2007-04-22 08:29:55 +00:00
filio.h merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
float_ieee754.h merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
fstrans.h Change fstrans enum types to upper case. 2007-01-29 15:42:50 +00:00
fstypes.h Remove now obsolete vn_start_write() and vn_finished_write() and 2007-04-08 11:20:42 +00:00
gmon.h delete ROUNDUP/ROUNDDOWN; they don't belong here and ROUNDUP is a copy 2006-10-04 14:22:58 +00:00
gpio.h merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
hash.h Change "inline" back to "__inline" in .h files -- C99 is still too 2006-02-16 20:17:12 +00:00
ieee754.h add constants used by gdtoa 2007-02-02 23:08:22 +00:00
inttypes.h
ioccom.h merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
ioctl_compat.h Make sure that multiple header inclusion is done, it uses consistent names, 2005-12-03 17:10:46 +00:00
ioctl.h merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
iostat.h iostat: avoid sleeping with a held simple_lock. 2006-12-07 20:23:38 +00:00
ipc.h integrate kauth. 2006-05-14 21:31:52 +00:00
joystick.h Make sure that multiple header inclusion is done, it uses consistent names, 2005-12-03 17:10:46 +00:00
kauth.h The pre-kauth 'struct ucread' and 'struct pcred' are now only used in the 2007-02-18 15:20:34 +00:00
kcont.h Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
kcore.h u_intN_t -> uintN_t 2005-12-26 18:41:36 +00:00
kernel.h make the public declaration of "hardclock_ticks" signed again; other 2006-06-08 17:23:11 +00:00
kgdb.h merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
kmem.h implement kmem_zalloc. 2006-06-25 08:10:04 +00:00
kprintf.h merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
ksem.h Change the way semid_t values are chosen. Instead of using kernel 2006-03-05 00:49:19 +00:00
ksyms.h Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
kthread.h
ktrace.h Move the ktrace (and systrace) in namei() inside the retry loop for 2007-04-26 16:27:32 +00:00
lkm.h Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
localedef.h Drop `const' from a couple of declarations to comply with the latest 2007-03-30 15:55:38 +00:00
lock.h Put the simplelock stuff into its own header file to simplify dependencies. 2007-03-12 16:31:54 +00:00
lockdebug.h lockdebug_abort: s/int/u_int/ for lock id as the rest of code. 2007-05-02 14:07:02 +00:00
lockf.h move lockf implementation details from sys/lockf.h to kern/vfs_lockf.c. 2006-05-20 12:02:47 +00:00
lwp.h - cv_wakeup: remove this. There are ~zero situations where it's useful. 2007-03-29 17:34:39 +00:00
Makefile Import of POSIX Asynchronous I/O. 2007-04-30 14:44:28 +00:00
malloc.h Remove unneeded includes. 2007-03-12 16:48:50 +00:00
mallocvar.h Introduce MALLOC_JUSTDEFINE{,_LIMIT} which act like their JUSTless 2007-03-29 16:29:08 +00:00
mbuf.h Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
md4.h u_intN_t -> uintN_t 2005-12-26 18:41:36 +00:00
md5.h u_intN_t -> uintN_t 2005-12-26 18:41:36 +00:00
midiio.h Ankh-Morpork, we have a MIDI driver.... 2006-06-30 13:56:25 +00:00
mman.h Regen. 2006-08-30 11:35:21 +00:00
mount.h update prototype of vfs_vptofh 2007-04-11 21:06:32 +00:00
msg.h Merge newlock2 to head. 2007-02-09 21:55:00 +00:00
msgbuf.h merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
mtio.h u_intN_t -> uintN_t 2005-12-26 18:41:36 +00:00
mutex.h Add a MUTEX_NODEBUG type that avoids allocating debugging resources for 2007-03-10 16:01:13 +00:00
namei.h Change the way that emulations locate files within the emulation root to 2007-04-22 08:29:55 +00:00
null.h Make sure that multiple header inclusion is done, it uses consistent names, 2005-12-03 17:10:46 +00:00
once.h - tweak RUN_ONCE api to allow init_func returns an error. 2006-01-16 21:45:38 +00:00
optstr.h Replace the Mach-derived boolean_t type with the C99 bool type. A 2007-02-21 22:59:35 +00:00
param.h Welcome to NetBSD 4.99.19: Added support for POSIX Asynchronous I/O. 2007-04-30 15:14:13 +00:00
pax.h Replace the Mach-derived boolean_t type with the C99 bool type. A 2007-02-21 22:59:35 +00:00
pipe.h Put a lock around pipe->pipe_peer. 2007-03-12 21:31:03 +00:00
pmc.h merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
poll.h merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
pool.h Pass an ipl argument to pool_init/POOL_INIT to be used when initializing 2007-03-12 18:18:22 +00:00
power.h merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
proc.h Remove proc->p_ru and the 'rusage' pool. 2007-04-30 20:11:41 +00:00
protosw.h change declaration for protosw.h const symbolic strings to static, so that 2007-03-31 18:17:13 +00:00
ptrace.h Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
pty.h Use the LWP cached credentials where sane. 2006-07-23 22:06:03 +00:00
queue.h implement priority inheritance. 2007-02-26 09:20:52 +00:00
radioio.h u_intN_t -> uintN_t 2005-12-26 18:41:36 +00:00
ras.h Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
reboot.h merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
resource.h Use the LWP cached credentials where sane. 2006-07-23 22:06:03 +00:00
resourcevar.h Remove comment about process stats not always being resident. 2007-04-30 16:30:56 +00:00
rmd160.h Merge kernel and userland rmd160 and sha2 implementation. 2006-10-27 21:20:48 +00:00
rnd.h Constification. 2006-09-20 05:21:37 +00:00
rwlock.h Merge newlock2 to head. 2007-02-09 21:55:00 +00:00
scanio.h
sched.h typedef pri_t and use it instead of int and u_char. 2007-02-27 15:07:28 +00:00
scsiio.h Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
select.h Change "inline" back to "__inline" in .h files -- C99 is still too 2006-02-16 20:17:12 +00:00
selinfo.h merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
sem.h Use the LWP cached credentials where sane. 2006-07-23 22:06:03 +00:00
sha1.h u_intN_t -> uintN_t 2005-12-26 18:41:36 +00:00
sha2.h Merge kernel and userland rmd160 and sha2 implementation. 2006-10-27 21:20:48 +00:00
shm.h PR/34837: Mindaguas: Add SysV SHM dynamic reallocation and locking to the 2006-11-25 21:40:04 +00:00
siginfo.h Merge newlock2 to head. 2007-02-09 21:55:00 +00:00
signal.h Introduce SA_NOKERNINFO, a flag for SIGINFO not to print kernel messages. 2006-06-03 18:18:26 +00:00
signalvar.h Merge newlock2 to head. 2007-02-09 21:55:00 +00:00
sigtypes.h merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
simplelock.h Add missing #ifdef _KERNEL 2007-03-13 15:58:26 +00:00
sleepq.h - cv_wakeup: remove this. There are ~zero situations where it's useful. 2007-03-29 17:34:39 +00:00
socket.h Eliminate address family-specific route caches (struct route, struct 2007-05-02 20:40:22 +00:00
socketvar.h don't use the same number for SS_ISDISCONNECTED and SS_ISAPIPE. 2007-04-15 05:24:33 +00:00
sockio.h Add a source-address selection policy mechanism to the kernel. 2006-11-13 05:13:38 +00:00
specificdata.h - Add specificdata_setspecific_nowait(). Not exposed by the wrappers yet 2006-10-11 05:37:32 +00:00
spl.h merge yamt-splraiseipl branch. 2006-12-21 15:55:21 +00:00
stat.h Add commented out UF_NOUNLINK and SF_NOUNLINK. These flags are defined 2006-02-24 22:01:30 +00:00
statvfs.h Make filehandles opaque to userland 2006-07-31 16:34:42 +00:00
stdint.h merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
swap.h Add a new swapctl(2) command to unset the dump device. 2006-08-22 14:07:07 +00:00
syncobj.h typedef pri_t and use it instead of int and u_char. 2007-02-27 15:07:28 +00:00
syscall_stats.h Add code to support per-system call statistics: 2007-02-18 16:58:15 +00:00
syscall.h Regen syscalls for AIO. 2007-04-30 14:47:32 +00:00
syscallargs.h Regen syscalls for AIO. 2007-04-30 14:47:32 +00:00
sysctl.h Add the LWP's runtime to kinfo_lwp. 2007-03-11 21:38:38 +00:00
syslimits.h merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
syslog.h Don't expose _ss functions for 4.0. Requested by core. 2006-11-22 17:23:24 +00:00
systm.h Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
systrace.h Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
tape.h u_intN_t -> uintN_t 2005-12-26 18:41:36 +00:00
termios.h merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
time.h Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
timeb.h merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
timepps.h Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
times.h merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
timetc.h move MAX_TCNAMELEN from kern_tc.c into timetc.h 2006-09-02 13:47:03 +00:00
timevar.h Merge newlock2 to head. 2007-02-09 21:55:00 +00:00
timex.h merge FreeBSD timecounters from branch simonb-timecounters 2006-06-07 22:33:33 +00:00
tprintf.h Make sure that multiple header inclusion is done, it uses consistent names, 2005-12-03 17:10:46 +00:00
trace.h merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
tree.h From FreeBSD: add the RB_PROTOTYPE_STATIC and RB_GENERATE_STATIC macros. 2007-01-20 20:15:13 +00:00
tty.h Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
ttychars.h merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
ttycom.h merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
ttydefaults.h constify ttydefchars. 2006-09-30 11:58:44 +00:00
ttydev.h merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
types.h prevent caddr_t use in the kernel so that it does not creep in again. 2007-03-22 18:00:39 +00:00
ucontext.h Remove the _UCONTEXT_TO_SIGCONTEXT() and _SIGCONTEXT_TO_UCONTEXT() macros 2006-08-20 08:02:21 +00:00
ucred.h The pre-kauth 'struct ucread' and 'struct pcred' are now only used in the 2007-02-18 15:20:34 +00:00
uio.h merge yamt-uio_vmspace branch. 2006-03-01 12:38:10 +00:00
un.h Use the LWP cached credentials where sane. 2006-07-23 22:06:03 +00:00
unistd.h - Create sysctl nodes for AIO. 2007-05-01 01:01:25 +00:00
unpcb.h merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
user.h cleanup user.h. 2006-05-11 11:54:36 +00:00
userconf.h merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
userret.h Change the process/lwp flags seen by userland via sysctl back to the 2007-02-17 22:31:36 +00:00
utsname.h merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
uuid.h merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
vadvise.h merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
verified_exec.h Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
vfs_syscalls.h Split the statvfs functions so that the 'work' is done to a kernel buffer 2007-04-30 08:32:14 +00:00
vmem.h Replace the Mach-derived boolean_t type with the C99 bool type. A 2007-02-21 22:59:35 +00:00
vmmeter.h merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
vnode_if.h regen 2007-04-09 15:00:42 +00:00
vnode.h Remove now obsolete vn_start_write() and vn_finished_write() and 2007-04-08 11:20:42 +00:00
wait.h merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
wdog.h merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
workqueue.h typedef pri_t and use it instead of int and u_char. 2007-02-27 15:07:28 +00:00
xattr.h merge ktrace-lwp. 2005-12-11 12:16:03 +00:00