NetBSD/sys/netinet
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
..
files.ipfilter defflag IPFILTER_LOOKUP. 2006-09-17 13:43:15 +00:00
files.netinet Here are various changes designed to protect against bad IPv4 2006-12-09 05:33:04 +00:00
icmp6.h 'advertisment' -> 'advertisement', from leonardo chiquitto filho 2006-03-07 18:15:28 +00:00
icmp_var.h Multiple inclusion protection, as suggested by christos@ on tech-kern@ 2005-12-10 23:31:41 +00:00
if_arp.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_atm.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_atm.h KNF: de-__P, bzero -> memset, bcmp -> memcmp. Remove extraneous 2007-02-17 22:34:07 +00:00
if_ether.h typo. 2006-09-25 12:24:47 +00:00
if_inarp.h Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
igmp_var.h Multiple inclusion protection, as suggested by christos@ on tech-kern@ 2005-12-10 23:31:41 +00:00
igmp.c Get rid of some gratuitous casts and join some lines. 2007-04-25 00:11:18 +00:00
igmp.h Multiple inclusion protection, as suggested by christos@ on tech-kern@ 2005-12-10 23:31:41 +00:00
in4_cksum.c Pass (char *) to mtod(9) on address calculation. 2007-03-04 10:53:32 +00:00
in_cksum.c merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
in_gif.c Eliminate address family-specific route caches (struct route, struct 2007-05-02 20:40:22 +00:00
in_gif.h New EtherIP driver based on tap(4) and gif(4) by Hans Rosenfeld. 2006-11-23 04:07:07 +00:00
in_ifattach.h Add a source-address selection policy mechanism to the kernel. 2006-11-13 05:13:38 +00:00
in_offload.c Constify. 2007-04-24 23:43:50 +00:00
in_offload.h Constify. 2007-04-24 23:43:50 +00:00
in_pcb_hdr.h Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
in_pcb.c Eliminate address family-specific route caches (struct route, struct 2007-05-02 20:40:22 +00:00
in_pcb.h Use the LWP cached credentials where sane. 2006-07-23 22:06:03 +00:00
in_proto.c Eliminate address family-specific route caches (struct route, struct 2007-05-02 20:40:22 +00:00
in_proto.h Multiple inclusion protection, as suggested by christos@ on tech-kern@ 2005-12-10 23:31:41 +00:00
in_route.c Eliminate address family-specific route caches (struct route, struct 2007-05-02 20:40:22 +00:00
in_route.h Here are various changes designed to protect against bad IPv4 2006-12-09 05:33:04 +00:00
in_selsrc.c Reverse sense of preference numbers: prefer source addresses with 2007-02-22 08:08:40 +00:00
in_selsrc.h Add a source-address selection policy mechanism to the kernel. 2006-11-13 05:13:38 +00:00
in_systm.h Multiple inclusion protection, as suggested by christos@ on tech-kern@ 2005-12-10 23:31:41 +00:00
in_var.h Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
in.c Cosmetic: shorten a staircase. bzero -> memset. KNF. 2007-04-15 06:15:58 +00:00
in.h Eliminate address family-specific route caches (struct route, struct 2007-05-02 20:40:22 +00:00
ip6.h Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
ip_carp.c Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
ip_carp.h KNF: de-__P, bzero -> memset, bcmp -> memcmp. Remove extraneous 2007-02-17 22:34:07 +00:00
ip_ecn.c Import of TCP ECN algorithm for congestion control. 2006-09-05 00:29:35 +00:00
ip_ecn.h Multiple inclusion protection, as suggested by christos@ on tech-kern@ 2005-12-10 23:31:41 +00:00
ip_encap.c Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
ip_encap.h KNF: de-__P, bzero -> memset, bcmp -> memcmp. Remove extraneous 2007-02-17 22:34:07 +00:00
ip_etherip.c Eliminate address family-specific route caches (struct route, struct 2007-05-02 20:40:22 +00:00
ip_etherip.h New EtherIP driver based on tap(4) and gif(4) by Hans Rosenfeld. 2006-11-23 04:07:07 +00:00
ip_flow.c Eliminate address family-specific route caches (struct route, struct 2007-05-02 20:40:22 +00:00
ip_gre.c If we do not recognize the protocol of a received packet, then 2007-03-21 01:56:05 +00:00
ip_gre.h Multiple inclusion protection, as suggested by christos@ on tech-kern@ 2005-12-10 23:31:41 +00:00
ip_icmp.c Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
ip_icmp.h Comment out attribute packed. Gcc4 warns us that the field is too narrow 2006-05-14 02:34:41 +00:00
ip_id.c static comes first 2006-08-30 18:54:19 +00:00
ip_input.c Eliminate address family-specific route caches (struct route, struct 2007-05-02 20:40:22 +00:00
ip_mroute.c Get rid of some gratuitous casts and join some lines. 2007-04-25 00:11:18 +00:00
ip_mroute.h Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
ip_output.c Eliminate address family-specific route caches (struct route, struct 2007-05-02 20:40:22 +00:00
ip_var.h Add net.inet.ip.hashsize to control the IPv4 fast forward hash table size. 2007-03-25 20:12:20 +00:00
ip.h According to ANSI c the only portably defined bitfields are unsigned int ones. 2006-12-17 20:07:36 +00:00
Makefile Here are various changes designed to protect against bad IPv4 2006-12-09 05:33:04 +00:00
pim_var.h Multiple inclusion protection, as suggested by christos@ on tech-kern@ 2005-12-10 23:31:41 +00:00
pim.h Multiple inclusion protection, as suggested by christos@ on tech-kern@ 2005-12-10 23:31:41 +00:00
raw_ip.c Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
tcp_congctl.c __unused removal on arguments; approved by core. 2006-11-16 01:32:37 +00:00
tcp_congctl.h constify. 2006-10-21 10:24:47 +00:00
tcp_debug.c Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
tcp_debug.h Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
tcp_fsm.h Multiple inclusion protection, as suggested by christos@ on tech-kern@ 2005-12-10 23:31:41 +00:00
tcp_input.c Eliminate address family-specific route caches (struct route, struct 2007-05-02 20:40:22 +00:00
tcp_output.c Eliminate address family-specific route caches (struct route, struct 2007-05-02 20:40:22 +00:00
tcp_sack.c Pass an ipl argument to pool_init/POOL_INIT to be used when initializing 2007-03-12 18:18:22 +00:00
tcp_seq.h Multiple inclusion protection, as suggested by christos@ on tech-kern@ 2005-12-10 23:31:41 +00:00
tcp_subr.c Eliminate address family-specific route caches (struct route, struct 2007-05-02 20:40:22 +00:00
tcp_timer.c Modular (I tried ;-) TCP congestion control API. Whenever certain conditions 2006-10-09 16:27:07 +00:00
tcp_timer.h Fixed a bug in the timeout range constraint macro that can cause a timeout 2006-09-26 06:39:22 +00:00
tcp_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
tcp_var.h Eliminate address family-specific route caches (struct route, struct 2007-05-02 20:40:22 +00:00
tcp.h Modular (I tried ;-) TCP congestion control API. Whenever certain conditions 2006-10-09 16:27:07 +00:00
tcpip.h Multiple inclusion protection, as suggested by christos@ on tech-kern@ 2005-12-10 23:31:41 +00:00
udp_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
udp_var.h KNF: de-__P, bzero -> memset, bcmp -> memcmp. Remove extraneous 2007-02-17 22:34:07 +00:00
udp.h Multiple inclusion protection, as suggested by christos@ on tech-kern@ 2005-12-10 23:31:41 +00:00