NetBSD/sys/net
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
..
agr Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
bpf_filter.c Use be16dec() and be32dec() instead of reimplementing them. 2007-01-27 07:16:01 +00:00
bpf.c Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
bpf.h Multiple inclusion protection, as suggested by christos@ on tech-kern@ 2005-12-10 23:21:38 +00:00
bpfdesc.h Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
bridgestp.c Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
bsd-comp.c __unused removal on arguments; approved by core. 2006-11-16 01:32:37 +00:00
dlt.h add missing DLTs from the libpcap-0.9.4 distribution 2006-02-27 14:22:26 +00:00
ethertypes.h Multiple inclusion protection, as suggested by christos@ on tech-kern@ 2005-12-10 23:21:38 +00:00
files.pf merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
if_arc.h argument type conflict. 2005-12-14 00:28:08 +00:00
if_arcsubr.c Remove unused #define SIN(). From he@. 2007-02-19 21:18:23 +00:00
if_arp.h Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
if_atm.h KNF: de-__P, bzero -> memset, bcmp -> memcmp. Remove extraneous 2007-02-17 22:34:07 +00:00
if_atmsubr.c Add IPv6 Fast Forward - the IPv4 counterpart: 2007-03-07 22:20:04 +00:00
if_bridge.c Pass an ipl argument to pool_init/POOL_INIT to be used when initializing 2007-03-12 18:18:22 +00:00
if_bridgevar.h Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
if_dl.h ANSI function decls and application of static. 2005-12-11 23:05:24 +00:00
if_eco.h Multiple inclusion protection, as suggested by christos@ on tech-kern@ 2005-12-10 23:21:38 +00:00
if_ecosubr.c Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
if_ether.h Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
if_etherip.c Free route cache after detaching an etherip(4) instance. 2007-04-23 05:05:03 +00:00
if_etherip.h Eliminate address family-specific route caches (struct route, struct 2007-05-02 20:40:22 +00:00
if_ethersubr.c Add IPv6 Fast Forward - the IPv4 counterpart: 2007-03-07 22:20:04 +00:00
if_faith.c Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
if_faith.h ANSI function decls and application of static. 2005-12-11 23:05:24 +00:00
if_fddi.h Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
if_fddisubr.c Add IPv6 Fast Forward - the IPv4 counterpart: 2007-03-07 22:20:04 +00:00
if_gif.c bcopy -> memcpy, bcmp -> memcmp. 2007-03-17 06:36:05 +00:00
if_gif.h Eliminate address family-specific route caches (struct route, struct 2007-05-02 20:40:22 +00:00
if_gre.c Eliminate address family-specific route caches (struct route, struct 2007-05-02 20:40:22 +00:00
if_gre.h If we do not recognize the protocol of a received packet, then 2007-03-21 01:56:05 +00:00
if_hippi.h Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
if_hippisubr.c Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
if_ieee1394.h Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
if_ieee1394subr.c Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
if_llc.h define some more magic LLC constants 2006-12-10 11:35:36 +00:00
if_loop.c Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
if_media.c merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
if_media.h Add IFM_10G_SR and IFM_10G_CX4, to keep in sync with FreeBSD. 2006-06-03 12:43:28 +00:00
if_ppp.c Add IPv6 Fast Forward - the IPv4 counterpart: 2007-03-07 22:20:04 +00:00
if_ppp.h ANSI function decls and application of static. 2005-12-11 23:05:24 +00:00
if_pppoe.c caddr_t fallout (only visible with options PPPOE_SERVER) 2007-03-31 11:00:23 +00:00
if_pppoe.h Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
if_pppvar.h Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
if_sl.c Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
if_slvar.h merge FreeBSD timecounters from branch simonb-timecounters 2006-06-07 22:33:33 +00:00
if_sppp.h Multiple inclusion protection, as suggested by christos@ on tech-kern@ 2005-12-10 23:21:38 +00:00
if_spppsubr.c Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
if_spppvar.h Multiple inclusion protection, as suggested by christos@ on tech-kern@ 2005-12-10 23:21:38 +00:00
if_srt.c Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
if_srt.h Add RCS Id. 2006-12-29 10:39:59 +00:00
if_stf.c Eliminate address family-specific route caches (struct route, struct 2007-05-02 20:40:22 +00:00
if_stf.h ANSI function decls and application of static. 2005-12-11 23:05:24 +00:00
if_strip.c Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
if_stripvar.h merge FreeBSD timecounters from branch simonb-timecounters 2006-06-07 22:33:33 +00:00
if_tap.c don't use DVUNIT_ANY as unit number to attach pseudo devices, 2007-03-09 18:42:22 +00:00
if_tap.h Multiple inclusion protection, as suggested by christos@ on tech-kern@ 2005-12-10 23:21:38 +00:00
if_token.h Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
if_tokensubr.c Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
if_tun.c Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
if_tun.h Change the number of TUN[GS]IFHEAD to avoid collision with if_pp. 2006-04-04 11:23:59 +00:00
if_types.h Integrate Common Address Redundancy Procotol (CARP) from OpenBSD 2006-05-18 09:05:49 +00:00
if_vlan.c Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
if_vlanvar.h merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
if.c KNF: compare pointers with NULL instead of 0, and do not "test 2007-03-18 20:59:38 +00:00
if.h Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
Makefile Install <net/if_pflog.h>. 2007-01-13 14:13:53 +00:00
net_osdep.h Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
netisr_dispatch.h remove more vestiges of CCITT, LLC, HDLC, NS, and NSIP. 2006-09-07 02:40:31 +00:00
netisr.h remove more vestiges of CCITT, LLC, HDLC, NS, and NSIP. 2006-09-07 02:40:31 +00:00
pfil.c merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
pfil.h Change "inline" back to "__inline" in .h files -- C99 is still too 2006-02-16 20:17:12 +00:00
pfkeyv2.h Multiple inclusion protection, as suggested by christos@ on tech-kern@ 2005-12-10 23:21:38 +00:00
ppp_defs.h KNF: de-__P, bzero -> memset, bcmp -> memcmp. Remove extraneous 2007-02-17 22:34:07 +00:00
ppp_tty.c Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
ppp-comp.h ANSI function decls and application of static. 2005-12-11 23:05:24 +00:00
ppp-deflate.c __unused removal on arguments; approved by core. 2006-11-16 01:32:37 +00:00
radix.c Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
radix.h Clean this code up some. 2007-02-17 07:46:38 +00:00
raw_cb.c Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
raw_cb.h KNF: de-__P, bzero -> memset, bcmp -> memcmp. Remove extraneous 2007-02-17 22:34:07 +00:00
raw_usrreq.c Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
route.c Eliminate address family-specific route caches (struct route, struct 2007-05-02 20:40:22 +00:00
route.h Eliminate address family-specific route caches (struct route, struct 2007-05-02 20:40:22 +00:00
rtsock.c Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
slcompress.c Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
slcompress.h ANSI function decls and application of static. 2005-12-11 23:05:24 +00:00
slip.h Multiple inclusion protection, as suggested by christos@ on tech-kern@ 2005-12-10 23:21:38 +00:00
zlib.c __unused removal on arguments; approved by core. 2006-11-16 01:32:37 +00:00
zlib.h zlib 1.2.3 changed the include protection variable names; adjust. 2006-01-14 20:17:12 +00:00