Commit Graph

1778 Commits

Author SHA1 Message Date
dyoung 2fe02c923a Constify. 2007-04-24 23:43:50 +00:00
dyoung 1c9313a294 In in_rtflushall(), clear the route caches using rtcache_clear()
instead of rtcache_free().  It is not desirable to clear the cached
destination as well as the route, however, rtcache_free() will
eventually release all resources held by the cache, including the
destination.

Add some additional diagnostic assertions.
2007-04-22 06:01:57 +00:00
dyoung d8fb0f4dac Add optimization hint for compiler. In a debug printf,
s/freeing/flushing/.
2007-04-18 23:22:26 +00:00
dyoung d60552baa5 Cosmetic: shorten a staircase. bzero -> memset. KNF. 2007-04-15 06:15:58 +00:00
liamjfoy 39b3c7f047 use size_t for indexes
just pass a *ip to ipflow_hash instead of members

ok christos@
2007-04-05 18:11:47 +00:00
liamjfoy 68880dffbf Add a small note regarding further commented code in netinet6/ip6_flow.c 2007-03-26 00:29:15 +00:00
liamjfoy b8ef59d720 Add net.inet.ip.hashsize to control the IPv4 fast forward hash table size. 2007-03-25 20:12:20 +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
dyoung 271d77fa58 If we do not recognize the protocol of a received packet, then
increase ifi_noproto.  If the GRE header contains routing options,
increase the input-error count, ifi_ierrors.

While I am here, make some cosmetic changes: remove unnecessary
'proto' argument from gre_input3().  Shorten some staircases.
2007-03-21 01:56:05 +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 5aa6f5addf Move ipflow_slowtimo from ip_slowtimo and into in_proto.c
ok matt@
2007-03-05 00:50:53 +00:00
liamjfoy f84185c912 inet6domain -> inetdomain
thanks simon
2007-03-04 23:53:36 +00:00
liamjfoy a461422cd5 Initialize protocol switch with structure initializers.
ok christos@
2007-03-04 20:17:05 +00:00
tsutsui 6f8d4c537b Pass (char *) to mtod(9) on address calculation. 2007-03-04 10:53:32 +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
dyoung bc99546f43 Reverse sense of preference numbers: prefer source addresses with
higher preference numbers.  Thanks to Mihai Chelaru for pointing
out my mistake.
2007-02-22 08:08:40 +00:00
dyoung 9111c8b6e3 Add net.inet.ip.selectsrc.default even if GETIFA_DEBUG is not
#define'd.
2007-02-22 07:33:48 +00:00
thorpej 7cc07e11dc TRUE -> true, FALSE -> false 2007-02-22 06:16:03 +00:00
matt 93feeb1203 Fix lossage from boolean_t -> bool and updated x86 bus_dma. 2007-02-22 04:38:02 +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 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 c80b247b25 Join lines. 2007-02-17 05:36:29 +00:00
dyoung 7ed406393a s/in_rtflush/in_rtcache/g 2007-02-17 05:35:50 +00:00
dyoung f272db0899 bzero -> memset 2007-02-17 05:31:39 +00:00
dyoung 08f386424b bcopy -> memcpy
Use NULL instead of (struct rtentry *)0.
2007-02-17 05:31:15 +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 ad4f290a37 bzero -> memset. 2007-01-29 06:00:11 +00:00
dyoung 24c98aa46f In ip_setmoptions(), don't leave a route cache (struct route) on
the stack if we exit with EADDRNOTAVAIL.
2007-01-29 05:59:30 +00:00
dyoung 0468886560 Cosmetic: remove extraneous, non-KNF parentheses. Change a
sizeof(type) to a sizeof(*ptr) so the correctness of the statement
is correct "at a glance" (or so I hope).
2007-01-29 05:48:56 +00:00
dyoung 4921da146d bzero -> memset 2007-01-29 05:46:33 +00:00
dyoung d8316ce94e KNF: bzero -> memset, change (struct in_ifaddr *)0 to NULL. 2007-01-26 19:15:26 +00:00
dyoung 3cd4307b24 bzero -> memset 2007-01-26 19:12:21 +00:00
joerg 7645663790 Unconditionally zero and free iproute. Before IPsec tunnel packets e.g.
from ICMP could end up in leaking the reference in iproute, as
ipsec4_output would overwrite the ro pointer in state.

Tested by Juraj Hercek and supposed to fix PR kern/35273 and kern/35318.
2007-01-13 23:13:46 +00:00
yamt 48bbcc400d ip_output: reload ip_len after running pfil_run_hooks.
pf "fragment reassemble" rule can change it, at least.
2007-01-08 04:14:54 +00:00
joerg fbd2dfee02 Use rtcache_free for consistency. 2007-01-05 15:47:33 +00:00
elad b2eb9a5389 Consistent usage of KAUTH_GENERIC_ISSUSER. 2007-01-04 19:07:03 +00:00
ad dd85fd121f ipintr(): check if the queue is empty before looping. Hardly a giant
win, but removed 30% of splnet() calls in one local test.
2006-12-22 05:34:02 +00:00
christos ae91f9ec0a According to ANSI c the only portably defined bitfields are unsigned int ones. 2006-12-17 20:07:36 +00:00
joerg eb04733c4e Introduce new helper functions to abstract the route caching.
rtcache_init and rtcache_init_noclone lookup ro_dst and store
the result in ro_rt, taking care of the reference counting and
calling the domain specific route cache.
rtcache_free checks if a route was cashed and frees the reference.
rtcache_copy copies ro_dst of the given struct route, checking that
enough space is available and incrementing the reference count of the
cached rtentry if necessary.
rtcache_check validates that the cached route is still up. If it isn't,
it tries to look it up again. Afterwards ro_rt is either a valid again
or NULL.
rtcache_copy is used internally.

Adjust to callers of rtalloc/rtflush in the tree to check the sanity of
ro_dst first (if necessary). If it doesn't fit the expectations, free
the cache, otherwise check if the cached route is still valid. After
that combination, a single check for ro_rt == NULL is enough to decide
whether a new lookup needs to be done with a different ro_dst.
Make the route checking in gre stricter by repeating the loop check
after revalidation.
Remove some unused RADIX_MPATH code in in6_src.c. The logic is slightly
changed here to first validate the route and check RTF_GATEWAY
afterwards. This is sementically equivalent though.
etherip doesn't need sc_route_expire similiar to the gif changes from
dyoung@ earlier.

Based on the earlier patch from dyoung@, reviewed and discussed with
him.
2006-12-15 21:18:52 +00:00
dyoung c308b1c661 Here are various changes designed to protect against bad IPv4
routing caused by stale route caches (struct route).  Route caches
are sprinkled throughout PCBs, the IP fast-forwarding table, and
IP tunnel interfaces (gre, gif, stf).

Stale IPv6 and ISO route caches will be treated by separate patches.

Thank you to Christoph Badura for suggesting the general approach
to invalidating route caches that I take here.

Here are the details:

Add hooks to struct domain for tracking and for invalidating each
domain's route caches: dom_rtcache, dom_rtflush, and dom_rtflushall.

Introduce helper subroutines, rtflush(ro) for invalidating a route
cache, rtflushall(family) for invalidating all route caches in a
routing domain, and rtcache(ro) for notifying the domain of a new
cached route.

Chain together all IPv4 route caches where ro_rt != NULL.  Provide
in_rtcache() for adding a route to the chain.  Provide in_rtflush()
and in_rtflushall() for invalidating IPv4 route caches.  In
in_rtflush(), set ro_rt to NULL, and remove the route from the
chain.  In in_rtflushall(), walk the chain and remove every route
cache.

In rtrequest1(), call rtflushall() to invalidate route caches when
a route is added.

In gif(4), discard the workaround for stale caches that involves
expiring them every so often.

Replace the pattern 'RTFREE(ro->ro_rt); ro->ro_rt = NULL;' with a
call to rtflush(ro).

Update ipflow_fastforward() and all other users of route caches so
that they expect a cached route, ro->ro_rt, to turn to NULL.

Take care when moving a 'struct route' to rtflush() the source and
to rtcache() the destination.

In domain initializers, use .dom_xxx tags.

KNF here and there.
2006-12-09 05:33:04 +00:00
joerg c882b2cbc1 When a dynamic route is deleted in in_losing and in6_losing, rtrequest
is called, but the current reference via the PCB is not removed. This
is effectively a leaked reference. Call rtfree unconditional.
2006-12-08 16:06:22 +00:00
jdc 6d7a98c7bc Explicitly include <sys/device.h>, which we need for `struct device'.
This allows us to compile on !i386.  (On i386, <machine/cpu.h> pulled
in <sys/device.h> for us, thus hiding the compilation problem.)

OK by rpaulo@.
2006-12-06 21:42:38 +00:00
yamt 8836e5995d add some more tcp mowners. 2006-12-06 09:10:45 +00:00
yamt f5830ee995 - make tcp_reass static.
- constify.
2006-12-06 09:08:27 +00:00
dyoung 2bbeb90e43 Remove stray curly brace. Thanks, yamt! 2006-12-06 04:29:09 +00:00
dyoung d7a8741d84 KNF. 2006-12-06 00:39:56 +00:00
dyoung 0394fe1e42 KNF. 2006-12-06 00:38:16 +00:00
yamt 401e606d0d move tso-by-software code to their own files. no functional changes. 2006-11-25 18:41:36 +00:00
christos 3d98aa3f4b fix spelling of accidentally; from Zapher 2006-11-24 19:37:02 +00:00
martin 54b769f306 Make it compile on IPv4-only kernels 2006-11-23 23:12:59 +00:00
yamt 809ec70bcf implement ipv6 TSO.
partly from Matthias Scheler.  tested by him.
2006-11-23 19:41:58 +00:00
tron 9506122aab Backout accidental commit which broke kernel builds. 2006-11-23 09:43:56 +00:00
rpaulo 5423539f94 New EtherIP driver based on tap(4) and gif(4) by Hans Rosenfeld.
Notable changes:
	* Fixes PR 34268.
	* Separates the code from gif(4) (which is more cleaner).
	* Allows the usage of STP (Spanning Tree Protocol).
	* Removed EtherIP implementation from gif(4)/tap(4).

Some input from Christos.
2006-11-23 04:07:07 +00:00
dyoung 8cfa750e0f Use LIST_FOREACH(). 2006-11-16 22:54:14 +00:00
dyoung 641edc65f1 Cosmetic: s/g_proto/sc_proto/. Remove superfluous parentheses and
curly braces.
2006-11-16 22:26:35 +00:00
christos 168cd830d2 __unused removal on arguments; approved by core. 2006-11-16 01:32:37 +00:00
rpaulo 7c10983a54 Remove ifndef COMPAT_42. No objections in tech-net. 2006-11-14 12:05:55 +00:00
dyoung 2d1d707101 Plug memory leak. 2006-11-13 05:48:00 +00:00
dyoung a25eaede91 Add a source-address selection policy mechanism to the kernel.
Also, add ioctls SIOCGIFADDRPREF/SIOCSIFADDRPREF to get/set preference
numbers for addresses.  Make ifconfig(8) set/display preference
numbers.

To activate source-address selection policies in your kernel, add
'options IPSELSRC' to your kernel configuration.

Miscellaneous changes in support of source-address selection:

        1 Factor out some common code, producing rt_replace_ifa().

        2 Abbreviate a for-loop with TAILQ_FOREACH().

        3 Add the predicates on IPv4 addresses IN_LINKLOCAL() and
          IN_PRIVATE(), that are true for link-local unicast
          (169.254/16) and RFC1918 private addresses, respectively.
          Add the predicate IN_ANY_LOCAL() that is true for link-local
          unicast and multicast.

        4 Add IPv4-specific interface attach/detach routines,
          in_domifattach and in_domifdetach, which build #ifdef
          IPSELSRC.

See in_getifa(9) for a more thorough description of source-address
selection policy.
2006-11-13 05:13:38 +00:00
yamt d4d55c3dc9 tcp_ctloutput: when called for a socket which is not AF_INET or AF_INET6,
panic rather than returning possibly leaking an mbuf.
2006-11-10 13:19:16 +00:00
yamt 22ffb8ee31 udp_ctloutput: plug a memory leak. 2006-11-10 13:02:32 +00:00
yamt 850e08319b remove some __unused in function parameters. 2006-11-10 13:01:55 +00:00
yamt d547c3b722 udp_ctloutput: remove unnecessary goto and break. 2006-11-10 13:00:23 +00:00
yamt 511f1a8ff8 udp_ctloutput: ansify. 2006-11-10 12:59:59 +00:00
christos 9217ff877d Fix typo (hi Elad) 2006-10-30 00:58:21 +00:00
elad adf8d7aab2 Introduce KAUTH_REQ_NETWORK_SOCKET_OPEN, to check if opening a socket is
allowed. It takes three int * arguments indicating domain, type, and
protocol. Replace previous KAUTH_REQ_NETWORK_SOCKET_RAWSOCK with it (but
keep it still).

Places that used to explicitly check for privileged context now don't
need it anymore, so I replaced these with XXX comment indiacting it for
future reference.

Documented and updated examples as well.
2006-10-25 22:49:22 +00:00
elad f2ce4f0704 Kill some KAUTH_GENERIC_ISSUSER. 2006-10-25 18:11:22 +00:00
elad 75939147ff Kill some KAUTH_GENERIC_ISSUSER. 2006-10-25 12:48:44 +00:00
yamt 80e1bbb713 add sack_dump(), a function to dump sack holes, if defined(DDB). 2006-10-21 10:26:21 +00:00
yamt 7253aad93f constify. 2006-10-21 10:24:47 +00:00
yamt c31e22237d - constify.
- make tcp_dooptions and tcpipqent_pool static.
2006-10-21 10:08:54 +00:00
liamjfoy cd64dacbef Remove some dead code - From OpenBSD Rev. 1.129 2006-10-20 19:13:02 +00:00
reinoud 78f5b5f9d5 Fix alignment problems causing regular panics in tpc_sack_option on
NetBSD/alpha and NetBSD/sparc. This fixes PR#34751.

The problem most likely started to show in gcc4 and is caused by the use of
a casting to an uint32_t pointer that is later copied from using memcpy.
Gcc detects the copying of 4 bytes from an uint32_t pointer and decides to
just replace it with an aligned copy causing the trap.

Fix provided by Izumi Tsutsui and ok'd by Martin.
2006-10-20 13:11:09 +00:00
rpaulo 8106a506d3 Use a better way to create sysctl subtrees for ECN and Congctl.
Inspired on ABC subtree.
2006-10-19 14:14:34 +00:00
yamt c549acefec tcp_reno_newack: remove an __unused because it's now used. 2006-10-19 11:42:32 +00:00
yamt df8e5bddfa tcp_reno_newack: regardless of sysctl setting, use L=1*SMSS when
we are doing retransmission.
2006-10-19 11:42:02 +00:00
yamt 81463c93c7 implement RFC3465 appropriate byte counting.
from Kentaro A. Kurahone, with minor adjustments by me.
the ack prediction part of the original patch was omitted because
it's a separate change.  reviewed by Rui Paulo.
2006-10-19 11:40:51 +00:00
dogcow 372e6ef309 now that we have -Wno-unused-parameter, back out all the tremendously ugly
code to gratuitously access said parameters.
2006-10-17 18:21:29 +00:00
yamt 389488e9b6 tcp_output: as a comment in tcp_sack_newack says, actually send
one or two segments on partial acks.  even if sack_bytes_rxmt==0,
if we are in fast recovory with sack, snd_cwnd has somewhat special
meaning here.  PR/34749.
2006-10-17 11:11:40 +00:00
yamt e1c6fffb40 tcp_input: if we have SACK, don't enter fastrecovery on three dupacks.
otherwise, we can enter fastrecovery due to DSACKs, which we treat
as dupacks here.  PR/34748.  reviewed by Rui Paulo.
2006-10-17 09:31:17 +00:00
rpaulo 21df8206df Export the tcp_do_rfc1948 variable to userland via sysctl.
The code to generate an ISS via an MD5 hash has been present in the
NetBSD kernel since 2001, but it wasn't even exported to userland at
that time. It was agreed on tech-net with the original author <thorpej>
that we should let the user decide if he wants to enable it or not.
Not enabled by default.
2006-10-16 18:13:56 +00:00
rpaulo 1c1f230e81 Move comments to proper places. 2006-10-15 17:53:30 +00:00
rpaulo a70594d346 Add a new tcp_congctl(9) structure member for congestion experienced callback.
Needed by HSTCP.
2006-10-15 17:45:06 +00:00
dogcow 44603cac1f more unused variable fallout. 2006-10-13 18:28:06 +00:00
elad 8c494ca741 Introduce KAUTH_REQ_NETWORK_SOCKET_CANSEE. Since we're not gonna be having
credentials on sockets, at least not anytime soon, this is a way to check
if we can "look" at a socket. Later on when (and if) we do have socket
credentials, the interface usage remains the same because we pass the
socket.

This also fixes sysctl for inet/inet6 pcblist.
2006-10-13 15:39:18 +00:00
rpaulo c1fc16d084 PR 34776: don't accept TCP connections to broadcast addresses.
Move the multicast/broadcast check above (before creating a syn_cache entry)
By Yasuoka Yasuoka.
2006-10-12 11:46:30 +00:00
christos 4d595fd7b1 - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
2006-10-12 01:30:41 +00:00
dogcow 55ddfc9aae change the MOWNER_INIT define to take two args; fix extant struct mowner
decls to use it. Makes options MBUFTRACE compile again and not whinge about
missing structure declarations. (Also makes initialization consistent.)
2006-10-10 21:49:14 +00:00
rpaulo a6762e54d7 Revert previous. The check is now done in tcp_congctl. 2006-10-10 11:13:02 +00:00
rpaulo e1b1f65f6b tcp_reno_newack(): bring the exact original code.
tcp_newreno_newack(): call tcp_reno_newack() if partialacks < 0.
2006-10-10 11:12:39 +00:00
yamt f5209007e9 tcp_input: don't call congctl->newack when doing fast retransmit. 2006-10-10 09:19:40 +00:00
yamt 2f7740a31e tcp_reno_newack/tcp_newreno_newack: remove stale comments. 2006-10-10 09:19:13 +00:00
yamt 8afc246107 tcp_newreno_newack: actually inflate cwnd as it used to do. 2006-10-10 08:31:02 +00:00
rpaulo f3330397f0 Modular (I tried ;-) TCP congestion control API. Whenever certain conditions
happen in the TCP stack, this interface calls the specified callback to
handle the situation according to the currently selected congestion
control algorithm.
A new sysctl node was created: net.inet.tcp.congctl.{available,selected}
with obvious meanings.
The old net.inet.tcp.newreno MIB was removed.
The API is discussed in tcp_congctl(9).

In the near future, it will be possible to selected a congestion control
algorithm on a per-socket basis.

Discussed on tech-net and reviewed by <yamt>.
2006-10-09 16:27:07 +00:00
yamt ce8b831234 tcp_output: don't make TSO duplicate CWR/ECE. 2006-10-08 11:10:59 +00:00
yamt 713f438722 tcp_output: don't try to send SACK option larger than txsegsize.
fix a panic like "panic: m_copydata: off 0, len -7".
2006-10-08 11:01:46 +00:00
yamt 94e70819e1 - make sackhole_pool static.
- unify duplicated hole allocation and accounting code.
(no functional changes.)
2006-10-07 20:16:04 +00:00
yamt 5a0a4d9df3 revert tcp_sack.c rev.1.15 because it's unnecessary.
all callers of these functions are at splsoftnet already:
	tcp_sack_option
		tcp_input ok

	tcp_del_sackholes
		tcp_input ok

	tcp_free_sackholes
		tcp_close ok
		tcp_timer_rexmt ok
		tcp_timer_2msl ok
2006-10-07 19:56:14 +00:00
yamt 38fb8d4a38 revert tcp_close part of tcp_subr.c rev.1.200 because it's unnecessary.
all callers of tcp_close are at splsoftnet already:
	tcp_close
		tcp_input ok
		tcp_disconnect
			tcp_usrreq ok
		tcp_usrclosed
			tcp_usrreq ok
			tcp_disconnect
		tcp_timer_2msl ok
		tcp_drop
			tcp_usrreq
			tcp_disconnect
			tcp_timer_rexmt ok
			tcp_timer_persist ok
			tcp_timer_keep ok
			tcp_input
			syn_cache_get
				tcp_input
2006-10-07 19:53:42 +00:00
yamt 8f0e8c48af tcp_sack_output: whitespace. 2006-10-07 19:26:45 +00:00