Commit Graph

1389 Commits

Author SHA1 Message Date
jonathan 9339ef0381 Change KAME code for ip_output()/ip6_output() to obtain struct socket*
from the explicit inpcb*/in6pcb* argument.  set_socket() becomes redundant.
2003-08-22 20:29:00 +00:00
jonathan 902669955f Replace the set_socket() method of passing an extra struct socket*
argument to ip6_output() with a new explicit struct in6pcb* argument.
(The underlying socket can be obtained via in6pcb->inp6_socket.)

In preparation for fast-ipsec.  Reviewed by itojun.
2003-08-22 20:20:09 +00:00
jonathan 6196bbe72d Honour the M_CSUM_NO_PSEUDOHDR, if set on inbound TCP and UDP packets.
Tested against  bcm5700 with patched if_bge.c.
2003-08-21 14:49:49 +00:00
itojun b83dd2f98b remove unneeded #ifdef __NetBSD__ 2003-08-19 08:00:54 +00:00
itojun ade8129bdc make ip_fragment public (it is for coming PF integration) 2003-08-19 01:20:03 +00:00
christos ae572737ba make ip_fragment static and add prototype. 2003-08-19 00:54:41 +00:00
itojun 4f8ba921cd correct ip_multicast_if fix to always set ifp (tnx Shiva) 2003-08-19 00:17:38 +00:00
itojun 449b5c43d4 since we cope with packets with addess on !IFF_UP interface in ip_input()
properly, IFF_UP check in INADDR_TO_IA is obsolete (or too much).
2003-08-18 22:28:51 +00:00
itojun 122edbc337 fix problem we can't drop membership on !IFF_UP interface.
reported by Shiva Shenoy

while we're here, fix another problem when the same interface address is
assigned to !IFF_MULTICAST and IFF_MULTICAST interface.  if ip_multicast_if()
returns the first one, join/leave will fail, which is not an desired effect.
2003-08-18 22:23:22 +00:00
itojun 3bcba4f62b do not disconnect L4 connections on IP address removal. the behavior
is too extreme (consider DHCP/PPP-based fixed address allocation).
see tech-net for more info.
2003-08-16 11:30:35 +00:00
martti 03506a6ef3 Fix return-rst for IPv6 (PR#22157 by Peter Postma). 2003-08-15 08:11:09 +00:00
jonathan 28b5f5dfab (fast-ipsec): Add hooks to pass IPv4 IPsec traffic into fast-ipsec, if
configured with ``options FAST_IPSEC''.  Kernels with KAME IPsec or
with no IPsec should work as before.

All calls to ip_output() now always pass an additional compulsory
argument: the inpcb associated with the packet being sent,
or 0 if no inpcb is available.

Fast-ipsec tested with ICMP or UDP over ESP. TCP doesn't work, yet.
2003-08-15 03:42:00 +00:00
itojun fd3f06dabb enforce ipsec policy on raw wildcard. 2003-08-14 07:57:40 +00:00
agc aad01611e7 Move UCB-licensed code from 4-clause to 3-clause licence.
Patches provided by Joel Baker in PR 22364, verified by myself.
2003-08-07 16:26:28 +00:00
itojun e4feda72ab avoid code dup when check broadcast addr in bind(2) 2003-07-22 02:09:30 +00:00
itojun 074166110c permit bind(2) to broadcast address, as it was permitted before.
(for instance, "ntpd -b" was broken since revision 1.82)
found report on http://pc.2ch.net/unix
2003-07-21 07:02:35 +00:00
he 80ccb5520c As a temporary workaround, apply the fix from PR#20390, thereby
cooperating with the callout code in working around the race
condition caused by the TCP code's use of the callout facility.

Instead of unconditionally releasing memory in tcp_close() and
SYN_CACHE_PUT(), check whether any of the related callout handlers
are about to be invoked (but have not yet done callout_ack()), and
if so, just mark the associated data structure (tcpcb or syn cache
entry) as "dead", and test for this (and release storage) in the
callout handler functions.
2003-07-20 16:35:07 +00:00
itojun 4c19286f97 correct igmp. from love 2003-07-14 16:39:43 +00:00
ragge 9e2d68cb61 Make it possible to set TCP_INIT_WIN and TCP_INIT_WIN_LOCAL in the config
file as options.
2003-07-03 08:28:16 +00:00
itojun 022df20c75 minor KNF 2003-07-03 05:03:53 +00:00
ragge cb6b5a36c4 Make the fast-search stuff an option. There are still reports on
problem with it.
2003-07-02 21:43:49 +00:00
ragge c6308a0598 Fix previous bug. Thanks to Enami for spotting the (obvious) error, and
to other people with much help with bug reports etc.
While fixing, change some of the code I added last time to make it
cleaner and simpler.
2003-07-02 19:33:20 +00:00
ragge c04e1a5756 Disable the code I checked in yesterday; reports that samba (!) are crashing
machines with it. Will do some more tests.
2003-06-30 14:51:06 +00:00
itojun 7e53aaa8dd better ip_mrouter_detach(). by ono@kame 2003-06-30 10:34:53 +00:00
itojun 38d08be727 do not generate ICMP redirect when packet filter alters ip_dst to an
address that reside on the same link.  Cedric Berger convinced me that
it is necessary.
2003-06-30 07:54:28 +00:00
itojun 1db5330c52 freebsd code somehow crept in 2003-06-30 02:08:28 +00:00
itojun 7ded9690f4 after pfil_run_hooks, need to fix hlen as well 2003-06-30 01:22:51 +00:00
itojun 868bbd9978 fix indent 2003-06-30 01:21:11 +00:00
itojun 725c585956 remove IPv4 hook if IPv6 hook fails (seems to be cut-and-paste error). 2003-06-30 00:15:12 +00:00
fvdl d5aece61d6 Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
2003-06-29 22:28:00 +00:00
ragge 679db94879 Add code to remember where in the send queue of mbufs the last packet was
sent from. This change avoid a linear search through all mbufs when using
large TCP windows, and therefore permit high-speed connections on long
distances.

Tested on a 1 Gigabit connection between Luleå and San Francisco, a distance
of about 15000km.  With TCP windows of just over 20 Mbytes it could keep up
with 950Mbit/s.

After discussions with Matt Thomas and Jason Thorpe.
2003-06-29 18:58:26 +00:00
simonb 130b423e90 Fix a nit in a comment. 2003-06-29 12:00:47 +00:00
darrenr 960df3c8d1 Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records.  The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
2003-06-28 14:20:43 +00:00
itojun 73ed908c03 fix stats to meet 4.4BSD practice 2003-06-26 21:49:17 +00:00
itojun 08740c2691 fix comment 2003-06-26 21:43:39 +00:00
christos 8924cfdcba abuse the mib instead of abusing the new pointer. Idea from simon burge.
It allows the tcp_sysctl_ident to run by non-super-users. No backwards
compatibility provided.
2003-06-26 17:32:22 +00:00
itojun c077e299a8 expire mrt if mrt_stall goes empty. ono@kame 2003-06-26 07:41:48 +00:00
itojun 4f7d642336 cleanup multicast routing stuff on if_detach().
XXX sideeffect to running instance of multicast routing daemon unknown
2003-06-26 03:35:00 +00:00
itojun 0888779b69 put meaningful count into in_multientries.
(or we could remove this variable - noone seem to use it)
2003-06-26 03:17:32 +00:00
itojun bef80abb93 purge rti structure (in igmp.c) for removed ifp on if_detach(). 2003-06-26 03:11:08 +00:00
itojun d1fcb86326 tabify 2003-06-26 00:43:31 +00:00
itojun ab5963ee1f check if INADDR_TO_IA gets us valid in_ifaddr or not. hopefully fix PR21964 2003-06-26 00:19:13 +00:00
martin 864f19482a #ifdef _KERNEL_OPT police 2003-06-23 14:59:21 +00:00
martin 1f875208a7 Protect opt_*.h includes by _KERNEL_OPT 2003-06-23 13:58:06 +00:00
martin d505b18964 Make sure to include opt_foo.h if a defflag option FOO is used. 2003-06-23 11:00:59 +00:00
itojun faef0b82e9 install host route for p2p interface even if there's connected net route
by broadcast interface.  PR 21903.
2003-06-18 06:42:34 +00:00
matt 27e1742142 Change the way multicasts are kept. They now use a hash table in the same
manner as the ifaddr hash table.  By doing this, the mkludge code can go
away.  At the same time, keep track of what pcbs are using what ifaddr and
when an address is deleted from an interface, notify/abort all sockets
that have that address as a source.  Switch IGMP and multicasts to use pools
for allocation.  Fix a number of potential problems in the igmp code where
allocation failures could cause a trap/panic.
2003-06-15 02:49:32 +00:00
onoe 7dad9f7d8a For loopback interface, assign ia_dstaddr instead of just changing reference
to ifa_dstaddr.  This fixes the problem that assigning more than 2 IPv4
aliases to loopback interface fails to create routing table entry.
2003-06-13 07:59:57 +00:00
itojun f05831c62a separate RFC2292 decls for MLD; sync w/ kame 2003-06-06 09:37:29 +00:00
itojun 7a5741651c - sync up MLD declaration with RFC3542 (s/MLD6/MLD/)
- routing header declaration with RFC3542
  (note: sizeof(ip6_rthdr0) has changed!)
  also, sync up with RFC2460 routing header definition (no "strict" source
  routing mode any more)

part of advanced API update (RFC2292 -> 3542).
2003-06-06 08:13:43 +00:00
itojun 7cc3e999f7 inherit IPV6_V6ONLY from listening socket. PR 21713 2003-05-30 01:15:04 +00:00
itojun f46a719b5c can't use M_WAIT here, i believe. 2003-05-27 22:36:38 +00:00
yamt 63cb165a80 - don't pass mbufs with M_CSUM_* flags which isn't supported by the interface
to if_output.
- offload ip-checksumming for each fragmented packets as well.
2003-05-26 15:12:11 +00:00
itojun 6ca34aa391 no need for ip_v recovery in output path too
(tcp_template includes ip_v setting)
2003-05-17 17:16:20 +00:00
itojun b29a40989d ip checksum logic no longer damage ip_v 2003-05-17 17:08:15 +00:00
itojun 4008ec1218 use strlcpy 2003-05-16 03:56:49 +00:00
itojun f41cda35e4 more KNF 2003-05-14 17:28:31 +00:00
itojun 560bd2fe2e more KNF 2003-05-14 17:18:36 +00:00
itojun f53c3317b8 wrap multiline macro by do {} while (0) 2003-05-14 16:57:03 +00:00
itojun caa10ced69 constcond 2003-05-14 16:52:53 +00:00
itojun 716a9823dd KNF 2003-05-14 16:43:44 +00:00
itojun 346e0198f0 always use PULLDOWN_TEST codepath. 2003-05-14 06:47:33 +00:00
bjh21 ff81b6d549 Header cleanup: Hide all of this file apart from the socket options
from POSIX/XNS applications.
2003-05-05 14:36:13 +00:00
itojun e6eb2671ed clear m_flags just for safety 2003-05-02 02:13:16 +00:00
bjh21 4be7a2dcf3 Add a new feature-test macro, _NETBSD_SOURCE. If this is defined
by the application, all NetBSD interfaces are made visible, even
if some other feature-test macro (like _POSIX_C_SOURCE) is defined.
<sys/featuretest.h> defined _NETBSD_SOURCE if none of _ANSI_SOURCE,
_POSIX_C_SOURCE and _XOPEN_SOURCE is defined, so as to preserve
existing behaviour.

This has two major advantages:
+ Programs that require non-POSIX facilities but define _POSIX_C_SOURCE
  can trivially be overruled by putting -D_NETBSD_SOURCE in their CFLAGS.
+ It makes most of the #ifs simpler, in that they're all now ORs of the
  various macros, rather than having checks for (!defined(_ANSI_SOURCE) ||
  !defined(_POSIX_C_SOURCE) || !defined(_XOPEN_SOURCE)) all over the place.

I've tried not to change the semantics of the headers in any case where
_NETBSD_SOURCE wasn't defined, but there were some places where the
current semantics were clearly mad, and retaining them was harder than
correcting them.  In particular, I've mostly normalised things so that
_ANSI_SOURCE gets you the smallest set of stuff, then _POSIX_C_SOURCE,
_XOPEN_SOURCE and _NETBSD_SOURCE in that order.

Tested by building for vax, encouraged by thorpej, and uncontested in
tech-userlevel for a week.
2003-04-28 23:16:11 +00:00
itojun afdd63b90b remove redundant adjustment of m->m_pkthdr.len 2003-04-21 08:14:45 +00:00
itojun cb30d7ce0b correct arg to m_pullup (need to count IP header size as well) 2003-04-21 07:02:31 +00:00
itojun a81c148373 correct (false) assumptions on mbuf chain. not sure if it really helps, but
anyways, it is necessary to perform m_pullup.
2003-04-21 06:52:47 +00:00
christos 9b6eb382c2 PR/2352: Tor Egge: Add sysctl to get uid of connected socket. 2003-04-19 20:58:35 +00:00
tron 2dcd4d2952 Clear hardware checksum flags before reusing a mbuf for an ICMP reply as
suggested by Enami Tsugutomo. This fixes PR kern/21203 by myself.
2003-04-17 16:57:49 +00:00
dogcow 6045dfd329 PR/991: Darren Reed: Add a sysctl (checkinteface) to implement this. This
implementation is taken from FreeBSD, but we default to off.
XXX: We should really do this on a per ifaddr basis as jason suggested.
2003-04-12 00:17:49 +00:00
christos 565d9732ff PR/991: Darren Reed: Add a sysctl (checkinteface) to implement this. This
implementation is taken from FreeBSD, but we default to off.
XXX: We should really do this on a per ifaddr basis as jason suggested.
2003-04-11 19:41:37 +00:00
dogcow 5ee791c103 bring into conformance with RFC 3514 2003-04-01 07:39:47 +00:00
lukem b1026bf11c Enable check in in_pcbbind() to enforce sin_family == AF_INET.
If there are any "old programs which incorrectly set this" left,
they will now fail with EAFNOSUPPORT.
This make in_pcbbind() consistent with in_pcbconnect() and the other
protocol families.

As per my PR [kern/4441], which has the comment:
	Steven's "TCP/IP Illustrated, Volume 2", page 730, notes that
	in_pcbbind() has the check which determines if sin_family == AF_INET
	commented out, but the same check in in_pcbconnect() is still active.
2003-03-16 03:33:28 +00:00
ragge be084ba94f vax -> __vax__. Didn't I fix this a year ago? 2003-03-05 13:19:59 +00:00
thorpej cdf1b0026c Allow TCP connections to hosts on a local network to use a larger
slow start initial window.  Default this larger initial window to
4 packets, allowing it to be adjusted with net.inet.tcp.init_win_local.
2003-03-01 04:40:27 +00:00
matt 65e5548a17 Add MBUFTRACE kernel option.
Do a little mbuf rework while here.  Change all uses of MGET*(*, M_WAIT, *)
to m_get*(M_WAIT, *).  These are not performance critical and making them
call m_get saves considerable space.  Add m_clget analogue of MCLGET and
make corresponding change for M_WAIT uses.
Modify netinet, gem, fxp, tulip, nfs to support MBUFTRACE.
Begin to change netstat to use sysctl.
2003-02-26 06:31:08 +00:00
he 27bc436921 Swap neighboring lines of callout_init() and bzero() of container
struct in syn_cache_add(); the bzero() invalidates whatever
callout_init() has done (which might matter, but presently doesn't).
2003-02-25 22:12:24 +00:00
thorpej 73fe03a9d6 Comment out the inclusion of <uvm/uvm_extern.h> -- the header is not
necessary.
2003-02-24 22:12:57 +00:00
thorpej 2ee9a875f2 Use callout_setfunc() and callout_schedule(). 2003-02-04 03:31:32 +00:00
thorpej 882dec6ba3 Test callout_pending(), not callout_active(), and eliminate now-unnecessary
callout_deactivate() calls.
2003-02-03 23:50:59 +00:00
thorpej d133a4da92 M_SOOPTS -> MT_SOOPTS 2003-01-30 23:43:33 +00:00
wiz 9115df8c49 success, not sucess. Noted by mjl. 2003-01-28 22:35:02 +00:00
kleink 8fb0c069dc C++ does not permit static a data member to have the same name as its
class, so in a C++ environment rename the ip_opts member to Ip_opts as
observed in several other implementations; from Jon Olsson in
PR toolchain/19880.
2003-01-27 09:57:09 +00:00
itojun 4d7a2eb391 correct panic when ip-in-ip encapsulation is used. found by Masanori Kanaoka 2003-01-21 03:23:44 +00:00
simonb f16a426a0f Remove variables that are only assigned too but not referenced. 2003-01-19 23:57:01 +00:00
itojun 40606ab8f2 switch from kame-based m_aux mbuf auxiliary data, to openbsd m_tag
implementation.  it will simplify porting across *bsd (such as kame/altq),
and make us more synchronized.  from Joel Wilsson
2003-01-17 08:11:49 +00:00
wiz 617b132aac Spell output with two ts. 2003-01-04 23:43:02 +00:00
atatat 89b889a8a7 Always recompute the IP checksum, otherwise fast-routed packets that
also get natted leave with an invalid checksum which can prevent
things from working properly.
2002-12-11 16:33:11 +00:00
lukem 0635de35a3 Remove KDIR=, since SYS_INCLUDE=symlinks and KDIR are not supported any more. 2002-11-26 23:30:07 +00:00
simonb 85a8258aac The "osrc" variable in gre_mobile_input() is only ever set but not
referenced; remove it.
2002-11-25 23:37:08 +00:00
thorpej d6f8cc841d Avoid strict-alias warnings. 2002-11-25 01:55:21 +00:00
scw 5521093d4b Quell an uninitialised variable warning. 2002-11-24 10:52:47 +00:00
scw 5b169b8d2e Fix a genuine uninitialised variable warning. 2002-11-24 10:51:56 +00:00
dyoung 9a9deae382 Squash a panic: do not try to print the name of a NULL interface. 2002-11-20 03:52:08 +00:00
itojun 50a545a34b remove all entries in rt timer queue on ip_mtudisc change, instead of
destroying the queue.
2002-11-12 02:10:13 +00:00
itojun 6a151fcce1 ckout previous - doesn't compile 2002-11-12 01:57:07 +00:00
itojun 9a8b644578 update ip_mtudisc sysctl change handling. 2002-11-12 01:38:09 +00:00
itojun c8a8326600 make USE_ENCAPCHECK (in netinet*/*gif.c) to global option, GIF_ENCAPCHECK.
#ifdef out unneeded code when possible.
From: Krister Walfridsson <cato@df.lth.se>
2002-11-11 18:35:27 +00:00
itojun e80a17da7b always create pmtud timeout queue, as ip_mtudisc can be tweaked via
sysctl at runtime.  From lha@stacken.kth.se
2002-11-10 19:52:16 +00:00
thorpej 55cd2960c9 In the IP_HDRINCL case of rip_output(), if the mbuf is read-only
then copy the header into a new mbuf before modifying it.

Fixes PR 18809.  Thanks to Chuq Silvers for diagnosing it.
2002-11-07 17:49:08 +00:00
thorpej 62b2879585 Fix signed/unsigned comparison warnings. 2002-11-07 07:15:19 +00:00
itojun 29ef3e950d improve gif lookup performance, when there are many of those,
by using radix tree for lookups.  tested by yshimizu@iij.
2002-11-05 16:58:11 +00:00
fair caee39d926 Add required IPSEC #include files that prevented this from compiling. 2002-11-05 02:07:25 +00:00
itojun 61eed162b2 cleanup ipsec.h dependency. commented by perry, sync w/kame 2002-11-02 19:03:44 +00:00
perry 6858187df6 /*CONTCOND*/ while (0)'ed macros 2002-11-02 07:20:42 +00:00
jdolecek e0cc03a09b merge kqueue branch into -current
kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe
2002-10-23 09:10:23 +00:00
lukem 3b5f6123fa fix typo in previous: s/tip/top/ 2002-10-22 07:22:19 +00:00
thorpej 163bdfc19e Make sure TF_REQ_TSTMP and TF_REQ_SCALE get set correctly in the new
TCPCB in the passive-open case.

Fixes PR 18677.
2002-10-22 04:24:50 +00:00
simonb d79a5f79da Guard use of "ostate" with #ifdef TCP_DEBUG in tcp_usrreq().
Don't put semicolons at the end of "#define token value".
2002-10-22 03:14:16 +00:00
simonb 4dd4549b31 Guard use of "so" in tcp_timer_persist() and tcp_timer_2msl() with
#ifdef TCP_DEBUG.
2002-10-22 03:11:03 +00:00
simonb ce9de06a5d In tcp_input():
Remove the set-but-not-used "proto" variable.
 Guard the "ostate" variable in #ifdef TCP_DEBUG.
Remove the set-but-not-used "parentinpcb" variable in syn_cache_get().
2002-10-22 03:07:06 +00:00
simonb 8b9702b758 Micro-optimisation: don't check if the high bit is set and then mask it
off - just mask it off anyways.  Saves a branch 50% of the time.
2002-10-22 02:53:59 +00:00
simonb ddac8bbac4 Oops, still need the call to va_arg() to advance the args pointer. 2002-10-22 02:44:34 +00:00
simonb da0d919807 "off" in rip_input() is set but not used, remove it.
static global "ripsrc" is never used, remove it.
2002-10-22 02:34:47 +00:00
simonb e6a79d25e7 "error" in in_pcbbind() was only ever set but not used, remove it. 2002-10-22 02:31:16 +00:00
simonb dc50de01ff "newifaddr" in in_control() was set but never used, remove it. 2002-10-22 02:28:47 +00:00
itojun 2fffb9beb4 correct log_refused check (TH_SYN, !TH_RST and !TH_ACK). PR 18669 2002-10-16 15:15:28 +00:00
thorpej d0eadcfb84 Add missing "needs-flag". 2002-10-11 15:58:20 +00:00
thorpej 5b2b587c85 Move netinet, netinet6, ipsec, and ipfilter config defns to
netinet/files.ipfilter, etinet/files.netinet, netinet6/files.netinet6,
and netinet6/files.netipsec.

XXX There are still a few stragglers in conf/files, which are entangled
with other network protocols.
2002-10-10 22:45:45 +00:00
martti 5aaa8070be Remove unused ipl_usec. 2002-09-29 17:55:14 +00:00
itojun 167b0b8ebd minor KNF 2002-09-25 11:19:23 +00:00
itojun 9d27b7540e one too many whitespace 2002-09-25 07:37:12 +00:00
martti 15e6ca78da Fix ipmon problems on 64-bit platforms (PR#17403 and PR#17404). 2002-09-25 06:43:17 +00:00
sommerfeld 17aee57321 Relax overly-conservative TCP option parsing used by ipnat when
hunting for an MSS option to clamp.  The previous code assumed that at least
one more byte of options (such as a TCPOPT_EOL) would follow the MSS
option; now, we allow the MSS option to end on the last byte of the
TCP header.

Packets have been observed "in the wild" with a TCP header length of
'6' (24 bytes.. 20 bytes fixed header, 4 bytes options) with a 4-byte
MSS option exactly filling the 4 bytes of options payload and no
following TCPOPT_EOL.

RFC793 is quite explicit that the EOL byte:

	" .. need only be used if the end of the options would not
	otherwise coincide with the end of the TCP header."
2002-09-24 14:14:25 +00:00
itojun 38e6856368 revert mtudisc_timeout value to the old one if update falis 2002-09-23 13:43:27 +00:00
simonb 4e3613273b Remove breaks after returns, unreachable returns and returns after
returns(!).
2002-09-23 05:51:10 +00:00
martti b69124b84c Resync with official IPF 2002-09-19 08:12:43 +00:00
martti 87f18f024e Upgraded IPFilter to 3.4.29 2002-09-19 08:08:14 +00:00
darrenr 04978010b2 From FreeBSD (1.164) courtesy of Maxim Konovalov:
"In rare cases when there is no room for ip options ip_insertoptions()
can fail and corrupt a header length.  Initialize len and check what
ip_insertoptions() returns."
2002-09-17 13:10:59 +00:00
mycroft 129af72834 In the txsegsize bounding code, it is not necessary to adjust for the options
length.
2002-09-13 18:26:55 +00:00
itojun 9401012487 KNF - return is not a function. sync w/kame. 2002-09-11 02:46:42 +00:00
itojun 6dedde045a correct signedness mixup in pointer passing. sync w/kame 2002-09-11 02:41:19 +00:00
enami c2428db9db Make usr.sbin/ipf/ipftest compiles again. 2002-09-07 00:10:24 +00:00
gehenna 5747ad0039 The device switch ``ipl_cdevsw'' is defined after 1.6H. 2002-09-06 14:00:00 +00:00
gehenna 77a6b82b27 Merge the gehenna-devsw branch into the trunk.
This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

	device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
  by using this grammer.

- Added the new naming convention.
  The name of the device switch must be <prefix>_[bc]devsw for auto-generation
  of device switch tables.

- The backward compatibility of loading block/character device
  switch by LKM framework is broken. This is necessary to convert
  from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
  We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
  the LKM framework will refer it to assign device major number dynamically.
2002-09-06 13:18:43 +00:00
itojun 530771e5ef always consult SS_CANTRCVMORE. PR 18185 2002-09-05 23:02:18 +00:00
itojun 98ba20f9e4 backout 1.78, ioctl(SIOCSIFADDR) is needed to test if the interface
supports AF_INET or not
2002-09-04 03:45:01 +00:00
itojun 91d888cd38 avoid SIOCSIFADDR if there's an IPv4 address already.
the comment doesn't match the behavior, it seems that the code assumed that
there's only one IPv4 address on an interface.  sync w/kame
2002-09-04 00:03:58 +00:00
thorpej ec09d2df2a Fix a problem introduced in rev 1.103, where we recycle a TIME_WAIT
TCPCB .. the fields need to be converted back to net-order, because
the packet is checksummed after the TCPCB lookup happens.

From YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>.
2002-08-28 02:23:57 +00:00
thorpej c23fa5a752 Never send more than half a socket buffer of data. This insures that
we can always keep 2 packets on the wire, no matter what SO_SNDBUF is,
and therefore ACKs will never be delayed unless we run out of data to
transmit.  The problem is quite easy to tickle when the MTU of the
outgoing interface is larger than the socket buffer size (e.g. loopback).

Fix from Charles Hannum.
2002-08-20 16:29:42 +00:00
itojun 436f2a58ac better sync w/kame on deprecated address handling. check af == AF_INET6. 2002-08-19 02:17:54 +00:00
itojun f00291d88b pull in deprecated address handling from KAME sys/netinet6/tcp6_input.c. 2002-08-19 02:13:46 +00:00
itojun c00fa8dfd9 avoid swapping endian of ip_len and ip_off on mbuf, to meet with M_LEADINGSPACE
optimization made last year.  should solve PR 17867 and 10195.

IP_HDRINCL behavior of raw ip socket is kept unchanged.  we may want to
provide IP_HDRINCL variant that does not swap endian.
2002-08-14 00:23:27 +00:00
itojun 6446feb7a7 inject GRE packet to raw ip socket input, to support userland GRE decapsulator.
discussed on openbsd developers list.
2002-08-10 05:40:54 +00:00
itojun fc50f2e011 bring back old copyright notice lost in rev 1.15 (which is the authors' intent). 2002-07-31 04:07:20 +00:00
itojun d5e0a4aba9 remove packed attribute as it will cause data be unaligned 2002-07-31 03:18:04 +00:00
itojun f8e5e9c295 be friendly with gcc-3.1.1 -O2, which takes advantage of ANSI C
pointer aliasing rule (gcc optimization/7427).  from tsubai, sync w/kame
2002-07-29 09:14:36 +00:00
wrstuden 332b66d974 When a new connection arrives on a listening port, copy over the
value of the TCP_NODELAY socket option from the listener to the
newly connected connection. Agrees with how Linux & FreeBSD behave,
and goes more with the spirit of accept(2) creating a socket with
the same properties as the listener.

Analysis by Kevin Lahey. Closes PR 17616 by myself.
2002-07-18 03:23:01 +00:00
itojun 572c4c4a3f need to bzero() before rtalloc. KAME PR 432 2002-07-14 21:09:17 +00:00
thorpej 668640a43d Rename sbappend_stream() to sbappendstream(), per suggestion from
Jonathan Stone.
2002-07-03 21:36:57 +00:00
thorpej 0585ce1489 Make insertion of data into socket buffers O(C):
* Keep pointers to the first and last mbufs of the last record in the
  socket buffer.
* Use the sb_lastrecord pointer in the sbappend*() family of functions
  to avoid traversing the packet chain to find the last record.
* Add a new sbappend_stream() function for stream protocols which
  guarantee that there will never be more than one record in the
  socket buffer.  This function uses the sb_mbtail pointer to perform
  the data insertion.  Make TCP use sbappend_stream().

On a profiling run, this makes sbappend of a TCP transmission using
a 1M socket buffer go from 50% of the time to .02% of the time.

Thanks to Bill Sommerfeld and YAMAMOTO Takashi for their debugging
assistance!
2002-07-03 19:06:47 +00:00
itojun 390ee363bd check AF_INET6 socketes when IPv4 "too big" messages arrive.
PR 17448
2002-07-01 20:51:25 +00:00
christos dad84218d6 Fix iplog problem on sparc64 [from Tomi Nylund]
1. size_t is 64 bits, so use a u_32_t for iplused
	2. microtime() and friends expect a struct timeval,
	   passing the first of two unsigned longs will not cut it.
2002-07-01 13:55:35 +00:00
thorpej 10c252ba47 Changes to allow the IPv4 and IPv6 layers to align headers themseves,
as necessary:
* Implement a new mbuf utility routine, m_copyup(), is is like
  m_pullup(), except that it always prepends and copies, rather
  than only doing so if the desired length is larger than m->m_len.
  m_copyup() also allows an offset into the destination mbuf, which
  allows space for packet headers, in the forwarding case.
* Add *_HDR_ALIGNED_P() macros for IP, IPv6, ICMP, and IGMP.  These
  macros expand to 1 if __NO_STRICT_ALIGNMENT is defined, so that
  architectures which do not have strict alignment constraints don't
  pay for the test or visit the new align-if-needed path.
* Use the new macros to check if a header needs to be aligned, or to
  assert that it already is, as appropriate.

Note: This code is still somewhat experimental.  However, the new
code path won't be visited if individual device drivers continue
to guarantee that packets are delivered to layer 3 already properly
aligned (which are rules that are already in use).
2002-06-30 22:40:32 +00:00
yamt 58077442ae split logging code in order to reduce maximum stack usage. 2002-06-29 04:13:21 +00:00
enami 6aad1636a8 If we need to fix up ar_hrd field, we must do it before using ar_tpa/tha. 2002-06-25 04:16:31 +00:00
itojun a5b52729e6 in arprequest(), fill ar_hrd only for IEEE1394. for other cases,
ifp->if_output will fill it for us.
2002-06-25 04:04:53 +00:00
enami 96fe4d7666 No need to include same file twice. 2002-06-25 02:55:14 +00:00
enami 4b27343d39 Use if_addrlen macro rather than if_data.ifi_addrlen. 2002-06-25 02:53:27 +00:00
enami 37f335b28b The ieee1394 arp reply should be broadcast. 2002-06-24 21:25:34 +00:00
enami 36f1c19838 Don't use a pointer before it is initialized. 2002-06-24 10:52:15 +00:00
itojun 570a3e1f3d set ar_hrd for RFC-defined cases 2002-06-24 08:42:33 +00:00
itojun e03a874f74 set ia as well 2002-06-24 08:11:30 +00:00
itojun 0143dfc42f integrate IEEE1394 ARP into generic ARP logic.
XXX there's no check at all in ar_hrd, and we don't set ar_hrd on outgoing.
it seems like a bad thing.
2002-06-24 08:06:20 +00:00
itojun c474c560dd do not consult routing table under the following condition:
- the destination is IPv4 multicast or 255.255.255.255, and
- outgoing interface is specified via socket option

this simplifies operation of routed
(no longer reqiure 224.0.0.0/4 to be set up)
2002-06-24 08:01:35 +00:00
thorpej 8038dd2cbe Disable TCP Congestion Window Monitoring by default; there are
performance problems in the face of tinygrams.
2002-06-13 16:31:05 +00:00
itojun 9368c444df set IPv4 parameter to modern value.
- turn on path MTU discovery (previous: turned off)
- ICMPv4 redirect entry timeout = 600 sec (previous: never timeout)
2002-06-13 16:25:54 +00:00
itojun fa53d749ff share policy-on-pcb for listening socket. sync w/kame
todo: share even more, avoid frequent updates of spidx
2002-06-11 19:39:59 +00:00
itojun 2a8a7da29d style 2002-06-09 19:49:49 +00:00
itojun f192b66b94 whitespace 2002-06-09 16:33:36 +00:00
itojun 39af55e317 enforce IPv4 link MTU for FDDI and ARCNET even in RTF_GATEWAY case.
PR 17151.
2002-06-09 05:09:26 +00:00
itojun 6d8d0d63d8 sync with latest KAME in6_ifaddr/prefix/default router manipulation.
behavior changes:
- two iocts used by ndp(8) are now obsolete (backward compat provided).
  use sysctl path instead.
- lo0 does not get ::1 automatically.  it will get ::1 when lo0 comes up.
2002-06-08 21:22:29 +00:00
itojun 14df31ceb3 look at rmx_mtu on IPsec tunnel MTU computation.
From: David Waitzman <djw@bbn.com>
2002-06-07 13:43:47 +00:00
itojun f45a8e9eb0 typo/bound check fix from YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp> 2002-06-05 13:11:34 +00:00
itojun fb9b52398c in mss clamping code, do not go past TCPOPT_EOL. enforce stricter
boundary checking.  discussed on tech-net
2002-06-04 10:06:27 +00:00
yamt 0f40d327f4 make "keep state" work for SYN without win scale option. 2002-06-01 07:21:11 +00:00
itojun 02dd12d915 since if_mtu is u_long, use u_long for mtu. 2002-05-31 05:26:42 +00:00
itojun 5c1df51d53 attach nd_ifinfo structure into if_afdata.
split IPv6 link MTU (advertised by RA) from real link MTU.
sync with kame
2002-05-29 07:53:39 +00:00
itojun ede265fffd move per-interface ip6/icmp6 stat to ifnet->if_afdata. sync w/kame 2002-05-29 02:58:28 +00:00
itojun bbc84065b6 use arc4random 2002-05-29 01:33:45 +00:00
itojun 4121fa09fc correct in*_pcbrtentry. check cached value correctly. 2002-05-28 11:10:52 +00:00
itojun b9f810de55 use arc4random() on tcp iss generation 2002-05-28 10:17:27 +00:00
itojun d208a22daa use arc4random() where possible.
XXX is it necessary to do microtime() on tcp syn cache?
2002-05-28 10:11:49 +00:00
itojun 7410ea60ca in in*_pcbrtentry(), check if route is still valid (RTF_UP),
and address family is still valid.
2002-05-28 10:07:51 +00:00
itojun 3e7ae517e0 path MTU discovery blackhole detection.
PR 12790 (sorry for not committing it for a long time)
2002-05-26 16:05:43 +00:00
kleink 1b8d8d79a8 Define uint{8,32}_t locally, per XNS5.2/POSIX-2001, and use them in this
header where applicable; use private fixed-width integer types otherwise.
2002-05-13 13:34:32 +00:00
kleink 602066c0d6 Provide local definitions of in_{addr,port}_t in <netinet/in.h> and use
them where deemed appropriate by XNS5.2/POSIX-2001.
2002-05-12 23:04:15 +00:00
matt c03e11f081 Eliminate commons. 2002-05-12 20:33:50 +00:00
wiz d30d25dc1a Spelling fixes, from Sergey Svishchev in kern/16650. 2002-05-12 15:48:36 +00:00
itojun 31a6ad2757 backout 1.72. it is not correct for the kernel to remove routes by itself,
and the code was buggy (dereferenced null pointer when IFAFREE removes the
route).
2002-05-09 06:49:15 +00:00
matt e5555e5c26 Change struct ipqe to use TAILQ's instead of LIST's (primarily for TCP's
benefit currently).  Rework tcp_reass code to optimize the 4 most likely causes
of out-of-order packets: first OoO pkt, next OoO pkt in seq, OoO pkt is part
of new chuck of OoO packets, and the OoO pkt fills the first hole.  Add evcnts
to instrument tcp_reass (enabled by the options TCP_REASS_COUNTERS).  This is
part 1/2 of tcp_reass changes.
2002-05-07 02:59:38 +00:00
martti 6f5d858e4b Fix compilation problems 2002-05-02 17:13:27 +00:00
martti e74092de02 Upgraded IPFilter to 3.4.27 2002-05-02 17:11:37 +00:00
thorpej 9054daca3e * Instrument tcp_build_datapkt().
* Remove the code that allocates a cluster if the packet would
  fit in one; it totally defeats doing references to M_EXT mbufs
  in the socket buffer.  This drastically reduces the number of
  data copies in the tcp_output() path for applications which use
  large writes.  Kudos to Matt Thomas for pointing me in the right
  direction.
2002-04-27 01:47:58 +00:00
matt 79b1afa490 Change test for M_EXT to M_READONLY for MROUTING. We only need to to do
a pullup if we aren't allowed to modify the packet.
2002-04-18 22:33:21 +00:00
itojun 45451927ec correct variable initialization. reported by fujitsu folks 2002-04-10 09:18:57 +00:00
thorpej f0bde82437 Add missing #else 2002-04-09 02:20:10 +00:00
jdolecek b10eb8758b Disable the H.323 proxy again - it's too buggy to be supported option
for now. Suggested by Matthew Green and Bernd Ernesti.
2002-04-01 18:07:10 +00:00
jdolecek af2aedbe22 put back ip_h323_pxy.c - the QNX licence seems to be okay upon
further examination
2002-04-01 16:50:08 +00:00
jdolecek c56211c431 add __KERNEL_RCSID() 2002-04-01 16:47:46 +00:00
jdolecek 69b18217c3 add RCS IDs 2002-04-01 16:45:24 +00:00
jdolecek 905b8db7c7 add __KERNEL_RCSID() 2002-04-01 16:44:28 +00:00
jdolecek cedc0276dc Import H.323 proxy of IPFilter 3.4.25. Upon closer examination,
the QNX licence seems to be allow both non-commercial and commercial
use actually.

According to Darren, the H.323 proxy code is buggy ATM, but is imported
here for reference anyway.
2002-04-01 16:29:31 +00:00
itojun 2f227734df do not consider /32 address itself as broadcast.
with /32 address, in_addr == in_broadaddr.
2002-03-30 00:40:32 +00:00
christos 4f0742e306 Change the multicast/broadcast test to happen later, and when we are
in listen mode. Fixes panic with telnet ::1 port, where the port is an
ipv4 open port.
2002-03-24 17:09:01 +00:00
itojun bd5373f4e2 no need to check in_broadaddr/IN_MULTICAST in dropwithreset label.
suggested by enami
2002-03-22 04:31:01 +00:00
itojun 1f14081709 make sure we don't touch "ip" in IPv6 path 2002-03-22 03:21:13 +00:00
christos 9c8babbd46 Drop connections to the broadcast address. From BUGTRAQ. This is a security
issue because it can by-pass ipf rules unintentionally.
2002-03-19 14:35:20 +00:00
itojun 38f3d28842 have tcp6_drain 2002-03-15 09:25:41 +00:00
martin 58d564bc8c Add MSS clamping to the IP Filter NAT subsystem.
Configured by a new option "mssclamp" in NAT rules, like:

 map pppoe0 192.168.1.0/24 -> 0/32 mssclamp 1452

This is based on work by Xiaodan Tang <xtang@qnx.com>.
2002-03-14 21:46:54 +00:00
martti dd7a744e5a Added (char *) for pointer arithmetic 2002-03-14 12:34:29 +00:00
martti 3e033bc0f1 Removed unused proxy file 2002-03-14 12:34:25 +00:00
martti 83b3487b70 Upgraded IPFilter to 3.4.25 2002-03-14 12:32:36 +00:00
itojun 7f7fe98c2c support tcp_log_refused for IPv6. From: Andrew Brown <atatat@atatdot.net> 2002-03-12 04:36:47 +00:00
martin 0039b1300a KNFify my last change. 2002-03-11 10:06:12 +00:00
thorpej a180cee23b Pool deals fairly well with physical memory shortage, but it doesn't
deal with shortages of the VM maps where the backing pages are mapped
(usually kmem_map).  Try to deal with this:

* Group all information about the backend allocator for a pool in a
  separate structure.  The pool references this structure, rather than
  the individual fields.
* Change the pool_init() API accordingly, and adjust all callers.
* Link all pools using the same backend allocator on a list.
* The backend allocator is responsible for waiting for physical memory
  to become available, but will still fail if it cannot callocate KVA
  space for the pages.  If this happens, carefully drain all pools using
  the same backend allocator, so that some KVA space can be freed.
* Change pool_reclaim() to indicate if it actually succeeded in freeing
  some pages, and use that information to make draining easier and more
  efficient.
* Get rid of PR_URGENT.  There was only one use of it, and it could be
  dealt with by the caller.

From art@openbsd.org.
2002-03-08 20:48:27 +00:00
itojun ac36f7cb2c bring in latest ALTQ from kjc. ALTQify some of the drivers. 2002-03-05 04:12:57 +00:00
sommerfeld 3406f0a3dd The "gif*" tunnelling interface does everything ipip does.
Move usage example from ipip.4 to gif.4
Excise ipip and stitch up the scars.
2002-03-04 13:24:06 +00:00
thorpej 1caa35aa0f In tcp_segsize(), move a label so that option length is considered
when using the default TCP MSS as well.  From Matt Thomas.
2002-03-01 22:54:09 +00:00
thorpej 10444ca48f In in_savemkludge() and in_restoremkludge(), don't insert into a new
list without removing from the old one first.

From Matt Thomas.
2002-03-01 22:51:28 +00:00
martin 75c5a16cfc Enforce a lower bound of 32 for tcp_mssdflt.
This avoids kernel crashes when we don't handle nonsensial values
like 0 gracefully. Better check here once beforehand than having to
check for non meaningful values in time critical paths (like tcp_output).

Fixes PR 15709.
2002-02-28 20:26:17 +00:00
itojun 8832af6e59 correctly enforce ipsec policy check on forwarding case.
From: Greg Troxel <gdt@ir.bbn.com>, Bill Chiarchiaro <wjc@work.cleartech.com>
2002-02-25 02:17:55 +00:00
martin a7d662b71c Clear M_BCAST and M_MCAST on outgoing mbufs.
Don't copy ttl from the inner packet to the encapsulating packet. Make
the outer ttl sysctl'able. This should close PR 14269 from Jasper Wallace
(change partly from there) and it makes traceroute work over gre tunnels.
2002-02-24 17:22:20 +00:00
christos 61e29fb60a Sean amended his patch not to include the IFAFREE() 2002-02-21 22:39:17 +00:00
christos 2446cd0b68 PR/15662: Sean Boudreau: make sure we clean all routes of an interface when
we change its ip address.
2002-02-21 21:59:16 +00:00
itojun 9c68db2bfc suppress source quence message, based on router-req RFC (also could be abused
as DoS traffic generator).  from kjc/kame
2002-02-21 08:39:33 +00:00
thorpej 35a343b018 IFF_POINTTOPOINT interfaces can also transmit packets to broadcast
destinations.
2002-02-07 21:47:45 +00:00
thorpej eb79ee01a8 ip_mloopback(): process the delayed checksum on the copy, not
the original mbuf.
2002-02-06 18:00:01 +00:00
itojun d303c80bfb correct bad ip checksum on multicast loopback packet. PR14597 2002-01-31 07:45:22 +00:00
martti b035470c38 Fixed initialization 2002-01-24 08:24:59 +00:00
martti 7a8f11612c Re-sync with IPFilter 2002-01-24 08:23:40 +00:00
martti b9920d0f43 Upgraded IPFilter to 3.4.23 2002-01-24 08:21:30 +00:00
martti b0499f9062 Import IPFilter 3.4.23 2002-01-24 08:18:28 +00:00
itojun a709c83618 place NRL copyright notice itself, not a reference to it. 2002-01-24 02:12:29 +00:00
itojun ae1b9c29e9 make sure to check address family on route cache. with IPv4 mapped
address we can see both AF_INET/INET6.
2002-01-22 03:53:55 +00:00
itojun 1cc58965b6 don't panic when there's no interface address exist for the specified multicast
outgoing interface (ia == NULL after IFP_TO_IA).

historic behavior (up to revision 1.43) was to use 0.0.0.0 as source address,
but it seems like a mistake according to RFC1112/1122.
2002-01-08 10:05:13 +00:00
itojun 28922b9973 use radix table for inbound tunnel lookup (would increase performance
for machines with a lot of tunnels).
update route cache for IPvX-over-IPv6 tunnel on path MTU discovery.
snyc with kame
2001-12-21 06:30:43 +00:00
itojun af7e7f7b93 whitespace. protect from multiple inclusion. sync with kame 2001-12-21 04:11:24 +00:00
itojun 9fe96e61e6 call rip_ctlinput on icmp4 inputs 2001-12-21 04:07:25 +00:00
itojun 745e191850 move protosw fragment for gif/stf to their own source code.
reduce #ifdef in stf code.  sync with kame
2001-12-21 03:21:50 +00:00
itojun f05aaf1533 have packed attribute to protocol structs. sync with kame 2001-12-21 02:52:18 +00:00
itojun dde7f16c1c have rip_ctlinput to notify routing changes to raw sockets
(protosw change to be done).  sync with kame
2001-12-21 02:51:47 +00:00
itojun f504aee318 comment and whitespace. sync with kame 2001-12-21 02:51:08 +00:00
itojun a36173e7a6 whitespace. sync with kame 2001-12-21 02:50:28 +00:00
itojun 33429d0612 correct timing to increment icmp6 MIB variables. sync with kame 2001-12-07 10:10:43 +00:00
jmcneill 078a8c0cc3 Fix TCP segment size computation. From Rick Byersm, PR kern/14799. 2001-12-03 01:45:43 +00:00
darrenr dd626d89c9 recompute hlen after calling pfil_run_hooks() in case ip_hl was changed. 2001-11-28 09:25:13 +00:00
itojun c23ea6c341 update outgoing ifp, only if tunnel mode ipsec is used. this is to
honor IP_MULTICAST_IF setsockopt on ipsec-over-multicast.  sync with kame
2001-11-21 06:28:08 +00:00
lukem 0fa231134c - replace "defopt" with "defparam" for options which must take a value,
as config(8) will warn for value-less defparam options
- minor whitespace/formatting cleanup
- consolidate opt_tcp_recvspace.h and opt_tcp_sendspace.h into opt_tcp_space.h
2001-11-20 14:34:18 +00:00