Commit Graph

1022 Commits

Author SHA1 Message Date
dyoung
3cfc66e506 Persuasive programming: check M_UNWRITABLE(m, len) instead of
m->m_len<len before pulling up, because that helps make it clear
that we m_pullup() in order to guarantee that the contiguous region
is *writable*.
2007-06-13 05:03:19 +00:00
dyoung
ab5517c0d4 Convert from rn_walktree() to rt_walktree(). While I am here,
de-__P().
2007-06-09 03:25:32 +00:00
alc
3a676de695 don't increment `ip6stat.ip6s_noroute' here, it has already been done in
in6_src:in6_selectroute().

ok dyoung@
2007-06-02 23:26:26 +00:00
cube
8b523203e0 Tyop. 2007-05-27 16:58:17 +00:00
christos
68a6db0f0b fix typos in previous 2007-05-23 17:32:46 +00:00
christos
72cfe7327b Ansify + add a few comments, from Karl Sjödahl 2007-05-23 17:14:59 +00:00
yamt
c8a34d8e58 remove net.inet6.ip6.rht0 sysctl.
it's too dangerous compared to its benefit.

strongly requested by itojun@.  ok'ed by core@.
2007-05-17 11:48:42 +00:00
dyoung
1db31a59af Fix the memory leak reported in kern/36337. Thanks Matthias Scheler
for the heads-up.  My fix is based on the following patches from
FreeBSD, however, I extracted the code into a subroutine,
nd6_llinfo_release_pkts():

http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/netinet6/nd6.c.diff?r1=1.48.2.18;r2=1.48.2.19
http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/netinet6/nd6_nbr.c.diff?r1=1.29.2.8;r2=1.29.2.9
2007-05-17 00:53:26 +00:00
dyoung
e1d4e2922e In AppleTalk, IPv4, and IPv6 routing domains, help sockaddr_cmp()
avoid an indirect function call by comparing the family, length,
and bytes [dom->dom_sa_cmpofs, dom->dom_sa_cmpofs + dom->dom_sa_cmplen),
corresponding to the the sockaddrs' "address" members.

For ISO, actually use sockaddr_iso_cmp, for a change.  Thanks to
yamt@ for pointing out my error.
2007-05-06 02:56:37 +00:00
dyoung
d91019e5e5 Use rtcache_lookup2(), and fix cache hit/miss accounting.
While I am here, introduce an rtentry pointer, 'rt', and set it
equal to ip6_forward.ro_rt.  Replace several occurrences of
'ip6_forward.ro_rt' with 'rt'.
2007-05-06 02:29:33 +00:00
yamt
10d3aa5cdf from kame:
> Revision 1.371
> Thu May 3 22:07:39 2007 UTC (47 hours, 7 minutes ago) by itojun
>
> drop packets with more than 1 routing headers.
> from claudio@openbsd

(and increment ifs6_in_hdrerr on ip6s_toomanyhdr.)
2007-05-05 21:23:50 +00:00
dyoung
8b646d9bb9 Remove obsolete files netinet/in_route.[ch]. 2007-05-02 22:39:03 +00:00
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
dyoung
60ead1a452 Back out last. To compile, it depends on changes that I am not
ready to commit, yet.
2007-04-25 20:40:20 +00:00
dyoung
e82cadce1c Remove unused member 'm6_route' from struct mif6. 2007-04-25 01:12:46 +00:00
dyoung
4f86563948 Constify. 2007-04-25 00:24:05 +00:00
christos
30921e7925 fix typo. 2007-04-22 20:06:07 +00:00
christos
08cd17ec8b Disable processing of routing header type 0 packets since they can be used
of DoS attacks. Provide a sysctl to re-enable them (net.inet6.ip6.rht0).

Information from:
	http://www.secdev.org/conf/IPv6_RH_security-csw07.pdf
2007-04-22 19:47:41 +00:00
liamjfoy
72a3be8fc7 use size_t for indexes
ok christos@
2007-04-05 18:12:49 +00:00
degroote
40cf3d18fa Make an exact match when we are looking for a cached sp for an unconnected
socket. If we don't make an exact match, we may use a cached rule which
has lower priority than a rule that would otherwise have matched the
packet.

Code submitted by Karl Knutsson in PR/36051
2007-03-25 12:46:42 +00:00
liamjfoy
64f6a30122 Minor change - be a little more consistant in sysctl handlers names 2007-03-24 00:42:14 +00:00
liamjfoy
ac43382f1f Don't call ip*flow_reap if we're just looking up maxflows 2007-03-24 00:27:58 +00:00
macallan
cc085574cb caddr_t -> void * 2007-03-23 17:35:02 +00:00
liamjfoy
a3580ff06f Add a new sysctl net.inet6.ip6.hashsize to control the hash table size.
The sysctl handler will ensure this value is a power of 2

ok dyoung@
2007-03-23 14:24:22 +00:00
dyoung
95b277379f In nd6_rtrequest(), when we lookup/create a route whose destination
is equal to one of the host's IPv6 addresses, do not stop at setting
the route's interface to lo0, but also clear the route's RTF_CLONED
flag, if it is present, so that ip6_input() will accept packets
sent to that destination.  This is necessary because ip6_input()
will not accept a packet if it looks up the packet's destination
and finds a route with RTF_CLONED set.

I believe this will help IPv6 networking survive '/etc/rc.d/network
restart'.  See the problem report, kern/33279.
2007-03-17 06:32:46 +00:00
dyoung
ab751193cc Don't open-code TAILQ_FOREACH(). KNF: Fix K&R prototypes and
parameter-type declarations.
2007-03-15 23:39:51 +00:00
dyoung
833cc39940 In nd6_lookup, shorten a staircase. KNF: change return (expr); to
return expr; throughout.  Fix K&R prototypes and parameter type
declarations.
2007-03-15 23:35:25 +00:00
dyoung
f1c68f17f4 Bark if we cannot assign a link-local address. While I am here,
fix the grammar in a comment.
2007-03-15 23:26:04 +00:00
dyoung
e75050de27 KNF: compare pointer w/ NULL, don't "check truth". Fix K&R parameter
types declaration.
2007-03-15 23:22:30 +00:00
ad
59d979c5f1 Pass an ipl argument to pool_init/POOL_INIT to be used when initializing
the pool's lock.
2007-03-12 18:18:22 +00:00
liamjfoy
d0d904ff73 Use ip6flowtable when looking up 2007-03-08 17:09:15 +00:00
liamjfoy
8aa640dadd Add IPv6 Fast Forward - the IPv4 counterpart:
If ip6_forward successfully forwards a packet, a cache, in this case a
ip6flow struct entry, will be created. ether_input and friends will
then be able to call ip6flow_fastforward with the packet which will then
be passed to if_output (unless an issue is found - in that case the packet
is passed back to ip6_input).

ok matt@ christos@ dyoung@ and joerg@
2007-03-07 22:20:04 +00:00
liamjfoy
f9af4def67 Fix some style issues - no functional change 2007-03-06 12:12:24 +00:00
christos
53524e44ef Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
degroote
768d7886ca Initialize fast_ipsec entry in the protocol switch with structure
initializers as other entries.
2007-02-27 22:19:05 +00:00
dyoung
fef0ee84d5 Cosmetic: remove extraneous () on return statements, break a line
in two, join lines, compare pointers with NULL instead of testing
their "truth."
2007-02-22 09:30:33 +00:00
dyoung
c4e796de1c Cosmetic: use TAILQ_FOREACH(). Remove extraneous () from return
statements.
2007-02-22 08:52:57 +00:00
dyoung
09fc9f4d08 Cosmetic: use TAILQ_FOREACH(). Join lines. 2007-02-22 08:43:43 +00:00
dyoung
d3f547d96d Cosmetic: use __arraycount. In ip6_input, move type of parameter
into parentheses.
2007-02-22 08:39:27 +00:00
thorpej
712239e366 Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
2007-02-21 22:59:35 +00:00
dyoung
531d50c86a Initialize protocol switch with structure initializers. 2007-02-19 07:28:58 +00:00
dyoung
5493f188c7 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-17 22:34:07 +00:00
dyoung
8d267ee73a 0 -> NULL 2007-02-17 20:38:05 +00:00
dyoung
05b0abac15 Don't open-code LIST_FOREACH(). 2007-02-17 06:11:25 +00:00
seanb
d51aaad793 Typo in comment. 2007-02-15 16:28:37 +00:00
degroote
e2211411a4 Commit my SoC work
Add ipv6 support for fast_ipsec
Note that currently, packet with extensions headers are not correctly
supported
Change the ipcomp logic
2007-02-10 09:43:05 +00:00
dyoung
741e438b04 Cosmetic: bzero -> memset. Change a bcopy() to a struct assignment. 2007-01-29 06:20:43 +00:00
dyoung
7218cc6856 Cosmetic: bzero -> memset, remove gratuitous cast, compare pointer
with NULL instead of 0.
2007-01-29 06:13:58 +00:00
dyoung
347073533b In In ip6_setmoptions(), don't leave a route cache (struct route_in6)
on the stack if we exit with EADDRNOTAVAIL.

(I already fixed this bug once tonight.  Clearly, ip6_setmoptions
was cut-and-pasted from ip_setmoptions.)
2007-01-29 06:12:48 +00:00
dyoung
40d75dce06 Cosmetic: move an splsoftnet() call out of the variable declarations,
get rid of a gratuitous cast, change (struct socket *)0 to NULL.
2007-01-29 06:05:10 +00:00