History log of /freebsd-11-stable/sys/contrib/ipfilter/netinet/
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
370346 19-Aug-2021 emaste

ipfilter: remove doubled semicolons

Local commit; ipfilter upstream is inactive.

Discussed with: cy
MFC after: 3 days

(cherry picked from commit 8fa63f44e64ebac444a4ac6451ac5e150cdcf8b1)

Git Hash: f3616c6d7ff5168d2e7883a831b60bbdc31367c6
Git Author: emaste@FreeBSD.org

369541 01-Apr-2021 git2svn

MFC 874b1a35486b570513680c3d456b062ba097e1d9:

ipfilter: simplify ipf_proxy_check() return codes

ipf_proxy_check() returns -1 for an error and 0 or 1 for success.
ipf_proxy_check()'s callers check for error and if the return code
is 0, they change it to 1 prior to returning to their callers. Simply
by returning -1 or 1 we reduce complexity and cycles burned changing
0 to 1.

(cherry picked from commit 874b1a35486b570513680c3d456b062ba097e1d9)

Git Hash: f4722627bce29607179fa566c620cdda13fd96df
Git Author: cy@FreeBSD.org

369277 16-Feb-2021 cy

MFC 57785538c6e0d7e8ca0f161ab95bae10fd304047 and
1e811efbc591699b872bea42b9de419c373199df:

57785538c6e0d7e8ca0f161ab95bae10fd304047)

Simplify the FreeBSD check using __FreeBSD__ compiler macro.

Rather than rely on __FreeBSD_version, defined in sys/param.h, use
__FreeBSD__ defined by the compiler.

Reported by: emaste
MFC after: 1 week

(cherry picked from commit 57785538c6e0d7e8ca0f161ab95bae10fd304047)

1e811efbc591699b872bea42b9de419c373199df:

Fix non-IPv6 build post 57785538c6e0d7e8ca0f161ab95bae10fd304047.

57785538c6e0d7e8ca0f161ab95bae10fd304047 change the test for FreeBSD
from __FreeBSD_version to __FreeBSD__. However this test was performed
before sys/param.h was included, therefore __FreeBSD_version was never
defined. As the test was never true opt_random_ip_id.h was never included.

Submitted by: bdragon
Reported by: bdragon

(cherry picked from commit 1e811efbc591699b872bea42b9de419c373199df)

Git Hash: 62607e8680e944f89cd7b5b7bca10698c66908b2
Git Author: cy@FreeBSD.org

369275 16-Feb-2021 cy

MFC 344f1083e128d8d41ca31853dac513ca3efd9d1f:

ipfilter: Use the softn (NAT softc) host map size in ip_nat6 calculation.

The ipfilter NAT table host map size is a tunable that defaults to
a macro value defined at build time. HOSTMAP_SIZE is saved in softn
(the ipnat softc) at initialization. It can be tuned (changed) at runtime
using the ipf -T command. If the hostmap_size tunable is adjusted the
calculation to determine where to put new entries in the table was
incorrect. Use the tunable in the NAT softc instead of the static build
time value.

(cherry picked from commit 344f1083e128d8d41ca31853dac513ca3efd9d1f)

Git Hash: e7a431c229eafe52240f4a62e6d87a4b8187c351
Git Author: cy@FreeBSD.org

369273 16-Feb-2021 cy

MFC e673debe7db8ba95e4ee3b549d2570e71d19b596:

Simplify BSD macro tests.

All FreeBSD and NetBSD are BSD >= 199306 and have been for a long time.

(cherry picked from commit e673debe7db8ba95e4ee3b549d2570e71d19b596)

Git Hash: ba6bb2487a7e159556d8ef9ba773fb4fa65dd823
Git Author: cy@FreeBSD.org

369272 16-Feb-2021 cy

MFC 0f34c80f376345b98a972940dd4757e58d7beb06:

Replace the redundant MENTAT macro with SOLARIS.

MENTAT and SOLARIS are synonymous. Remove the extraneous duplicate
macro.

(cherry picked from commit 0f34c80f376345b98a972940dd4757e58d7beb06)

Git Hash: 8d6da0aae1c4ca288537c9875eaed1f65988e51f
Git Author: cy@FreeBSD.org

369246 09-Feb-2021 cy

MFC7071734fae6019d1e3e44daf7deb4478582081cc:

Indentation cleanup resulting from the cleanup of #ifdefs.

The conscious decision was made not to perform any indentation or
whitespace cleanup while cleaning out old redunant #ifdefs. The
reason for this was to avoid confusing future readers of history and
diffs with cosmetic changes, making bisection of any possible bugs
introduced more difficult. This commit cleans up the whitespace
detritus left behind from the previous #ifdef cleanup commits.

(cherry picked from commit 7071734fae6019d1e3e44daf7deb4478582081cc)

Git Hash: 19bebaed370c527b531c79a7abbb9efcf8f37af1
Git Author: cy@FreeBSD.org

369245 09-Feb-2021 git2svn

MFC 4cd1807c7d2a67b633dd0c0bfde15091543a2514:

Retire the K&R/STD C __P prototype declarations.

In the old days when K&R C and STD C were each in use a workaround
(read hack) was required to allow the same code to work on each
without modification. All C compilers support STD C. We can finally
put the __P prototype to rest.

(cherry picked from commit 4cd1807c7d2a67b633dd0c0bfde15091543a2514)

Git Hash: 0c7a33852aa5cd28a9d9b19b8f8034d60a9cb50f
Git Author: cy@FreeBSD.org


/freebsd-11-stable/contrib/ipfilter/bpf_filter.c
/freebsd-11-stable/contrib/ipfilter/ip_dstlist.c
/freebsd-11-stable/contrib/ipfilter/ip_dstlist.h
/freebsd-11-stable/contrib/ipfilter/ip_fil.c
/freebsd-11-stable/contrib/ipfilter/ip_fil_compat.c
/freebsd-11-stable/contrib/ipfilter/ip_msnrpc_pxy.c
/freebsd-11-stable/contrib/ipfilter/ipf.h
/freebsd-11-stable/contrib/ipfilter/iplang/iplang.h
/freebsd-11-stable/contrib/ipfilter/iplang/iplang_l.l
/freebsd-11-stable/contrib/ipfilter/iplang/iplang_y.y
/freebsd-11-stable/contrib/ipfilter/ipmon.h
/freebsd-11-stable/contrib/ipfilter/ipsend/ipresend.c
/freebsd-11-stable/contrib/ipfilter/ipsend/ipsend.c
/freebsd-11-stable/contrib/ipfilter/ipsend/ipsend.h
/freebsd-11-stable/contrib/ipfilter/ipsend/iptest.c
/freebsd-11-stable/contrib/ipfilter/ipsend/resend.c
/freebsd-11-stable/contrib/ipfilter/ipsend/sock.c
/freebsd-11-stable/contrib/ipfilter/ipt.h
/freebsd-11-stable/contrib/ipfilter/kmem.h
/freebsd-11-stable/contrib/ipfilter/lib/facpri.h
/freebsd-11-stable/contrib/ipfilter/lib/inet_addr.c
/freebsd-11-stable/contrib/ipfilter/lib/initparse.c
/freebsd-11-stable/contrib/ipfilter/lib/interror.c
/freebsd-11-stable/contrib/ipfilter/lib/ipft_hx.c
/freebsd-11-stable/contrib/ipfilter/lib/ipft_pc.c
/freebsd-11-stable/contrib/ipfilter/lib/ipft_tx.c
/freebsd-11-stable/contrib/ipfilter/lib/kmem.h
/freebsd-11-stable/contrib/ipfilter/lib/printipfexpr.c
/freebsd-11-stable/contrib/ipfilter/lib/save_execute.c
/freebsd-11-stable/contrib/ipfilter/lib/save_file.c
/freebsd-11-stable/contrib/ipfilter/lib/save_nothing.c
/freebsd-11-stable/contrib/ipfilter/lib/save_syslog.c
/freebsd-11-stable/contrib/ipfilter/lib/save_v1trap.c
/freebsd-11-stable/contrib/ipfilter/lib/save_v2trap.c
/freebsd-11-stable/contrib/ipfilter/lib/var.c
/freebsd-11-stable/contrib/ipfilter/man/ipf.4
/freebsd-11-stable/contrib/ipfilter/md5.c
/freebsd-11-stable/contrib/ipfilter/md5.h
/freebsd-11-stable/contrib/ipfilter/radix_ipf.c
/freebsd-11-stable/contrib/ipfilter/radix_ipf.h
/freebsd-11-stable/contrib/ipfilter/tools/ipf.c
/freebsd-11-stable/contrib/ipfilter/tools/ipf_y.y
/freebsd-11-stable/contrib/ipfilter/tools/ipfcomp.c
/freebsd-11-stable/contrib/ipfilter/tools/ipfs.c
/freebsd-11-stable/contrib/ipfilter/tools/ipfstat.c
/freebsd-11-stable/contrib/ipfilter/tools/ipfsyncd.c
/freebsd-11-stable/contrib/ipfilter/tools/ipftest.c
/freebsd-11-stable/contrib/ipfilter/tools/ipmon.c
/freebsd-11-stable/contrib/ipfilter/tools/ipmon_y.y
/freebsd-11-stable/contrib/ipfilter/tools/ipnat.c
/freebsd-11-stable/contrib/ipfilter/tools/ipnat_y.y
/freebsd-11-stable/contrib/ipfilter/tools/ippool.c
/freebsd-11-stable/contrib/ipfilter/tools/ippool_y.y
/freebsd-11-stable/contrib/ipfilter/tools/ipscan_y.y
/freebsd-11-stable/contrib/ipfilter/tools/ipsyncm.c
/freebsd-11-stable/contrib/ipfilter/tools/ipsyncs.c
/freebsd-11-stable/contrib/ipfilter/tools/lexer.c
/freebsd-11-stable/contrib/ipfilter/tools/lexer.h
fil.c
ip_auth.c
ip_auth.h
ip_compat.h
ip_dns_pxy.c
ip_dstlist.c
ip_dstlist.h
ip_fil.h
ip_fil_freebsd.c
ip_frag.c
ip_frag.h
ip_ftp_pxy.c
ip_htable.c
ip_htable.h
ip_ipsec_pxy.c
ip_irc_pxy.c
ip_lookup.c
ip_lookup.h
ip_nat.c
ip_nat.h
ip_nat6.c
ip_netbios_pxy.c
ip_pool.c
ip_pool.h
ip_pptp_pxy.c
ip_proxy.c
ip_proxy.h
ip_raudio_pxy.c
ip_rcmd_pxy.c
ip_rpcb_pxy.c
ip_rules.h
ip_scan.c
ip_scan.h
ip_state.c
ip_state.h
ip_sync.c
ip_sync.h
ip_tftp_pxy.c
mlfk_ipl.c
radix_ipf.c
radix_ipf.h
369186 31-Jan-2021 cy

MFC: 83edbc3cb54fba6b37a68270c232df7b785bd222

ipfilter: Retire pre-standard C support.

All C compilers in 2021 support standard C and architectures that did
not were retired long ago. Simplify by removing now redundant
pre-standard C code.

MFC after: 1 week

(cherry picked from commit 83edbc3cb54fba6b37a68270c232df7b785bd222)

Git Hash: 58e43f89f17cf807b77270e15b91c46bfdfd1e77
Git Author: cy@FreeBSD.org

366531 08-Oct-2020 cy

MFC r366287:

Continued ipfilter #ifdef cleanup. The r343701 log entry contains a
complete description.

366282 30-Sep-2020 cy

MFC r366204:

Remove extraneous bracket.

363769 02-Aug-2020 cy

MFC r363284-r363285, r363670

r363284:
pfil_run_hooks() can be called recursively, so we have to
define FASTROUTE_RECURSION in fil.c

Submitted by: christos@NetBSD.org
Reported by: christos@NetBSD.org
Obtained from: NetBSD r1.31

r363285:
Fix incorrect byte order in ipfstat -f output.
- make sure frag is initialized to 0
- initialize ipfr_p field

NetBSD PR: 55137
Submitted by: christos@NetBSD.org
Reported by: christos@NetBSD.org
Obtained from: NetBSD fil.c r1.32, ip_frag.c r1.8

r363670:
Continued ipfilter #ifdef cleanup. The r343701 log entry contains a
complete description.

360591 03-May-2020 cy

MFC r360100:

fib4_free_nh_ext is an empty function. It does nothing. Don't call it.

358666 05-Mar-2020 cy

MFC r358560:

Retire macros:

BSD_GE_YEAR
BSD_GT_YEAR
BSD_LT_YEAR

358665 05-Mar-2020 cy

MFC r358559:

Remove the now unused FREEBSD_GE_REV, FREEBSD_GT_REV, and FREEBSD_LT_REV
macros.

358664 05-Mar-2020 cy

MFC r358558:

Continuing the effort started in r343701, #ifdef cleanup, checking for
__FreeBSD_version > 3.0 and 5.0 is redundant.

355795 16-Dec-2019 cy

MFC r355670:

Rather than pass the address of the packet information control block to
ipf_pcksum6(), directly pass the adddress of the mbuf to it. This reduces
one pointer dereference. ipf_pcksum6() doesn't use the packet information
control block except to obtain the mbuf address.

355785 15-Dec-2019 cy

MFC r355669:

in6_cksum() returns zero when checksums are good.

355306 02-Dec-2019 cy

MFC r355156:

Include fin, the packet information structure (fr_info_t), in the
l4sums DTrace probe, making more information available for the diagnosis
of IPv6 checksum errors.

355305 02-Dec-2019 cy

MFC r355142:

Move ipf_pcksum6() to its rightful place, in ip_fil_freebsd.c. This
FreeBSD-only function should live in the O/S specific source file.

This essentially reverts r349929 Now that ipftest and ipfreplay are
disabled in FreeBSD 11-stable.

355303 02-Dec-2019 cy

MFC r355141:

Save a little stack by removing a used once intermediate variable.

355302 02-Dec-2019 cy

MFC r355140:

Remove redundant #ifdef'd function definitions.

353164 07-Oct-2019 cy

MFC r353116:

Add missing definition in DEBUG code.

352866 29-Sep-2019 cy

MFC r352737:

ipf mistakenly regards UDP packets with a checksum of 0xffff as bad.

Obtained from: NetBSD fil.c r1.30, NetBSD PR/54443

351775 03-Sep-2019 cy

MFC r350882:

Initialize the frentry (the control block that defines a rule) checksum
to zero. Matching checksums save time and effort by mitigating the need
for full rule compare.

351636 31-Aug-2019 cy

MFC r351563:

Document ipf_nat_hashtab_add() return codes.

351635 31-Aug-2019 cy

MFC r351562:

Destroy the mutex in case of error.

Obtained from: NetBSD ip_nat.c r1.7

351634 31-Aug-2019 cy

MFC r351561:

Fixup typo in comment.

Obtained from: NetBSD ip_nat.c r1.7

351479 25-Aug-2019 cy

MFC r350881:

Calculate the number interface array elements using the new FR_NUM macro
instead of the hard-coded value of 4. This is a precursor to increasing
the number of interfaces speficied in "on {interface, ..., interface}".
Note that though this feature is coded in ipf_y.y, it is partially
supported in the ipfilter kld, meaning it does not work yet (and is yet
to be documented in ipf.5 too).

351470 25-Aug-2019 cy

MFC r350880:

r272552 applied the patch from ipfilter upstream fil.c r1.129 to fix
broken ipfilter rule matches (upstream bug #554). The upstream patch
was incomplete, it resolved all but one rule compare issue. The issue
fixed here is when "{to, reply-to, dup-to} interface" are used in
conjuncion with "on interface". The match was only made if the on keyword
was specified in the same order in each case referencing the same rule.
This commit fixes this.

The reason for this is that interface name strings and comment keyword
comments are stored in a a variable length field starting at fr_names
in the frentry struct. These strings are placed into this variable length
in the order they are encountered by ipf_y.y and indexed through index
pointers in fr_ifnames, fr_comment or one of the frdest struct fd_name
fields. (Three frdest structs are within frentry.) Order matters and
this patch takes this into account.

While in here it was discovered that though ipfilter is designed to
pport multiple interface specifiations per rule (up to four), this
undocumented (the man page makes no mention of it) feature does not work.
A todo is to fix the multiple interfaces feature at a later date. To
understand the design decision as to why only four were intended, it is
suspected that the decision was made because Sun workstations and PCs
rarely if ever exceeded four NICs at the time, this is not true in 2019.

PR: 238796
Reported by: WHR <msl0000023508@gmail.com>

351468 25-Aug-2019 cy

MFC r351380:

Specifying array sizes for fully initialized tables at compile time is
redundant.

350669 07-Aug-2019 cy

Revert 350668 from stable/11 only. It is not at the level of VNET support.

350668 07-Aug-2019 cy

MFC r350568:

Resolve ipfilter kld unload issues related to VNET jails.

When the ipfilter kld is loaded, used within VNET jail, and unloaded,
then subsequent loading, use, and unloading of another packet filters
will cause the subsequently loaded netpfil kld's to panic.

The scenario is as follows:

cd /usr/tests/sys/netpfil/common

kldunload ipl
kldunload pfsync
kldunload ipfw

kyua test pass_block

kldload ipl
kyua test pass_block
kldunload ipl

kldload pfsync
kyua test pass_block
kldunload pfsync
-- page fault panic occurs here --

Reported by: "Ahsan Barkati" <ahsanbarkati@g.....com> via kp@
Discussed with: kp@
Tested by: kp@

350667 07-Aug-2019 cy

MFC r350567:

Returning an uninitialized error is a bad thing.

350577 05-Aug-2019 cy

MFC r350548:

#include whitespace adjustments.

350434 30-Jul-2019 cy

MFC r350064:

As of upstream fil.c CVS r1.53 (March 1, 2009), prior to the import of
ipfilter 5.1.2 into FreeBSD-10, the fix for, 2580062 from/to targets
should be able to use any interface name, moved frentry.fr_cksum to
prior to frentry.fr_func thereby making this code redundant. After
investigating whether this fix to move fr_cksum was correct and if it
broke anything, it has been determined that the fix is correct and this
code is redundant. We remove it here.

350234 23-Jul-2019 cy

MFC r350063:

Refactor, removing one compare.

This changes the return code however the caller only tests for 0 and != 0.
One might ask then, why multiple return codes when the caller only tests
for 0 and != 0? From what I can tell, Darren probably passed various
return codes for sake of debugging. The debugging code is long gone
however we can still use the different return codes using DTrace FBT
traces. We can still determine why the compare failed by examining the
differences between the fr1 and fr2 frentry structs, which is a simple
test in DTrace. This allows reducing the number of tests, improving the
code while not affecting our ability to capture information for
diagnostic purposes.

350189 21-Jul-2019 cy

MFC r349980:

Calculate the offset of the interface name using FR_NAME rather than
calclulating it "by hand". This improves consistency with the rest of
the code and is in line with planned fixes and other work.

350188 21-Jul-2019 cy

MFC r349979:

Recycle the unused FR_CMPSIZ macro which became orphaned in ipfilter 5
prior to its import into FreeBSD. This macro calculates the size to be
compared within the frentry structure. The ipfilter 4 version of the
macro calculated the compare size based upon the static size of the
frentry struct. Today it uses the ipfilter 5 method of calculating the
size based upon the new to ipfilter 5 fr_size value found in the
frentry struct itself.

No effective change in code is intended.

350111 18-Jul-2019 cy

MFC r349917:

Remove a tautological test for adding a rule in the block that
adds rules.

350110 18-Jul-2019 cy

MFC r349898, r349916:

ipfilter commands, in this case ipf(8), passes its operations and rules
via an ioctl interface. Rules can be added or removed and stats and
counters can be zeroed out. As the ipfilter interprets these
instructions or operations they are stored in an integer called
addrem (add/remove). 0 is add, 1 is remove, and 2 is clear stats and
counters. Much of this is not documented. This commit documents these
operations by replacing simple integers with a self documenting
enum along with a few basic comments.

350073 17-Jul-2019 cy

MFC r349978:

style(9)

349931 12-Jul-2019 cy

MFC r349927, r349929:

r349927:
Resolve IPv6 checksum errors with stateful inspection. According to
PR/203585 this appears to have been broken by r235959, which predates
the ipfilter 5.1.2 import into FreeBSD.

The IPv6 checksum calculation is incorrect. To resolve this we call
in6_cksum() to do the the heavy lifting for us, through a new function
ipf_pcksum6(). Should we need to revisit this area again, a DTrace probe
is added to aid with future debugging.

Plus whitespace adjustments (r348989).

PR: 203275, 203585
Differential Revision: https://reviews.freebsd.org/D20583

r349929:
Move the new ipf_pcksum6() function from ip_fil_freebsd.c to fil.c.
The reason for this is that ipftest(8), which still works on FreeBSD-11,
fails to link to it, breaking stable/11 builds.

ipftest(8) was broken (segfault) sometime during the FreeBSD-12 cycle.
glebius@ suggested we disable building it until I can get around to
fixing it. Hence this was not caught in -current.

The intention is to fix ipftest(8) as it is used by the netbsd-tests
(imported by ngie@ many moons ago) for regression testing.

349927 12-Jul-2019 cy

MFC r348987, r348989:

Resolve IPv6 checksum errors with stateful inspection. According to
PR/203585 this appears to have been broken by r235959, which predates
the ipfilter 5.1.2 import into FreeBSD.

The IPv6 checksum calculation is incorrect. To resolve this we call
in6_cksum() to do the the heavy lifting for us, through a new function
ipf_pcksum6(). Should we need to revisit this area again, a DTrace probe
is added to aid with future debugging.

Plus whitespace adjustments (r348989).

PR: 203275, 203585
Differential Revision: https://reviews.freebsd.org/D20583

349903 11-Jul-2019 cy

MFC 349843:

Update frtuc struct comments. It not only defines TCP things we are
interested in but also UDP.

While at it document the source and destination port variables.

349902 11-Jul-2019 cy

MFC r349842:

Correct the description for the low port in the port compare struct.

Adjust the high port description to match that of the low port
description.

349655 03-Jul-2019 cy

MFC r349401:

While working on PR/238796 I discovered an unused variable in frdest,
the next hop structure. It is likely this contributes to PR/238796
though other factors remain to be investigated.

PR: 238796

349654 03-Jul-2019 cy

MFC r349399-349400,349567-349568:

Prompted by r349366, ipfilter is also does not conform to RFC 3128
by dropping TCP fragments with offset = 1.

In addition to dropping these fragments, add a DTrace probe to allow
for more detailed monitoring and diagnosis if required.

349653 03-Jul-2019 cy

MFC r349362:

The definition of icmptypes in ip_compt.h is dead code as it already
use the icmptypes in ip_icmp.h.

349652 03-Jul-2019 cy

MFC r349331:

Clean out duplicate definitions of TCP macros also found in netinet/tcp.h.

349223 20-Jun-2019 cy

MFC r349152:

Make ipf_objbytes a constant. ipf_objbytes is a table of internal data
structures that are saved across reboots by ipfs(8). The table is not
changed at runtime.

349182 19-Jun-2019 cy

MFC r348985:

Enclose a long multi-line single conditional statement in braces to
improve legibility and aesthetics.

348892 11-Jun-2019 cy

MFC r348667:

While working on a PR, more are discovered.
Remove more #ifdefs missed in r343701.

Approved by: re (gjb@)

348891 11-Jun-2019 cy

MFC r348666:

Clean up #ifdefs from old unsupported releases of FreeBSD.

Approved by: re (gjb@)

348850 10-Jun-2019 cy

MFC r348575:

Properly define the fourth argument to ipf_check, the main entry point
into ipfilter. A proper definition simplifies dtrace scripts a little.

Approved by: re (delphij@)

348822 08-Jun-2019 cy

MFC r348320:

Contuation of r343701, removal of irrelevant #ifdefs.

Approved by: re (gjb@)

348821 08-Jun-2019 cy

MFC r348312:

style(9)

Approved by: re (gjb@)

348820 08-Jun-2019 cy

MFC r348311:

Fix indentation and while at it simplfy the code.

Reported by: lwhsu@
Approved by: re (gjb@)

348819 08-Jun-2019 cy

MFC r348310:

Remove compile-time tests for unsupported versions of FreeBSD.

Approved by: re (gjb@)

346982 01-May-2019 cy

MFC r346804:

Left justify a function header brace as it should be.
No functional change.

344837 06-Mar-2019 cy

MFC r343705:

new_kmem_alloc(9) is a Solaris/illumos malloc(9). FreeBSD and NetBSD
never get here, however a test for SOLARIS, as redundant as this test is,
serves to document that this is the illumos definition. This should help
those who come after me to follow the code more easily.

344835 06-Mar-2019 cy

MFC r343703

Remove a reference to HP-UX in a comment.

344833 06-Mar-2019 cy

MFC r343701 & r343732:

ipfilter #ifdef cleanup.

Remove #ifdefs for ancient and irrelevant operating systems from
ipfilter.

When ipfilter was written the UNIX and UNIX-like systems in use
were diverse and plentiful. IRIX, Tru64 (OSF/1) don't exist any
more. OpenBSD removed ipfilter shortly after the first time the
ipfilter license terms changed in the early 2000's. ipfilter on AIX,
HP/UX, and Linux never really caught on. Removal of code for operating
systems that ipfilter will never run on again will simplify the code
making it easier to fix bugs, complete partially implemented features,
and extend ipfilter.

Unsupported previous version FreeBSD code and some older NetBSD code
has also been removed.

What remains is supported FreeBSD, NetBSD, and illumos. FreeBSD and
NetBSD have collaborated exchanging patches, while illumos has expressed
willingness to have their ipfilter updated to 5.1.2, provided their
zone-specific updates to their ipfilter are merged (which are of interest
to FreeBSD to allow control of ipfilters in jails from the global zone).

Reviewed by: glebius@
Differential Revision: https://reviews.freebsd.org/D19006


/freebsd-11-stable/contrib/ipfilter/arc4random.c
/freebsd-11-stable/contrib/ipfilter/ip_dstlist.c
/freebsd-11-stable/contrib/ipfilter/ip_fil.c
/freebsd-11-stable/contrib/ipfilter/ip_fil_compat.c
/freebsd-11-stable/contrib/ipfilter/ipf.h
/freebsd-11-stable/contrib/ipfilter/ipsend/.OLD/ip_compat.h
/freebsd-11-stable/contrib/ipfilter/ipsend/44arp.c
/freebsd-11-stable/contrib/ipfilter/ipsend/arp.c
/freebsd-11-stable/contrib/ipfilter/ipsend/dlcommon.c
/freebsd-11-stable/contrib/ipfilter/ipsend/ip.c
/freebsd-11-stable/contrib/ipfilter/ipsend/ipresend.c
/freebsd-11-stable/contrib/ipfilter/ipsend/ipsend.c
/freebsd-11-stable/contrib/ipfilter/ipsend/ipsend.h
/freebsd-11-stable/contrib/ipfilter/ipsend/ipsopt.c
/freebsd-11-stable/contrib/ipfilter/ipsend/iptest.c
/freebsd-11-stable/contrib/ipfilter/ipsend/iptests.c
/freebsd-11-stable/contrib/ipfilter/ipsend/resend.c
/freebsd-11-stable/contrib/ipfilter/ipsend/sdlpi.c
/freebsd-11-stable/contrib/ipfilter/ipsend/sock.c
/freebsd-11-stable/contrib/ipfilter/lib/getifname.c
/freebsd-11-stable/contrib/ipfilter/lib/getproto.c
/freebsd-11-stable/contrib/ipfilter/lib/inet_addr.c
/freebsd-11-stable/contrib/ipfilter/lib/kmem.c
/freebsd-11-stable/contrib/ipfilter/lib/printproto.c
/freebsd-11-stable/contrib/ipfilter/md5.c
/freebsd-11-stable/contrib/ipfilter/tools/ipf.c
/freebsd-11-stable/contrib/ipfilter/tools/ipfs.c
/freebsd-11-stable/contrib/ipfilter/tools/ipfstat.c
/freebsd-11-stable/contrib/ipfilter/tools/ipftest.c
/freebsd-11-stable/contrib/ipfilter/tools/ipmon.c
/freebsd-11-stable/contrib/ipfilter/tools/ipnat.c
/freebsd-11-stable/contrib/ipfilter/tools/ipnat_y.y
/freebsd-11-stable/contrib/ipfilter/tools/ippool.c
/freebsd-11-stable/contrib/ipfilter/tools/ippool_y.y
fil.c
ip_auth.c
ip_compat.h
ip_dstlist.c
ip_fil.h
ip_frag.c
ip_ftp_pxy.c
ip_htable.c
ip_irc_pxy.c
ip_log.c
ip_lookup.c
ip_nat.c
ip_nat.h
ip_nat6.c
ip_pool.c
ip_proxy.c
ip_raudio_pxy.c
ip_scan.c
ip_state.c
ip_sync.c
344113 14-Feb-2019 cy

MFC r343591:

Do not obtain an already held read lock. This causes a witness panic when
ipfs is invoked. This is the second of two panics resolving PR 235110.

PR: 235110
Reported by: David.Boyd49@twc.com

343691 03-Feb-2019 cy

MFC r343600:

Document the instance context pointer.

342685 02-Jan-2019 cy

MFC r342596:

Remove duplicate include of sys/mbuf.h.

Reported by: Trond Endrest <Trond.Endrestol@ximalas.info>

342641 31-Dec-2018 cy

MFC r342385:

Remove an empty #if block.

The interesting thing is that looking through Darren's commit logs,
the line containing an extern ppsratecheck() definition was removed
from the v5-1-RELEASE branch but not from HEAD (I have taken his
CVS tree and converted it to GIT). There is a commit adding an
additional #if defined to the empty block. I can only assume that
this was intentional for something later. Looking through HEAD the
extern ppsratecheck() is there. However if we put it back it would
conflict with a static ppsratecheck() definition in fil.c when
building ipftest.

Therefore we remove this empty block.

ppsratecheck() is a function in the FreeBSD kernel. However ipftest
cannot call the ppsratecheck() in the kernel. Therefore one exists in
fil.c for use when building the userland ipftest utility which
approximates the packet filter in userland for testing of ipfilter
rules against packets captured with tcpdump.

342608 30-Dec-2018 cy

MFC r342547:

Remove another empty #ifdef block. This empty block also exists in
the upstream HEAD.

342607 30-Dec-2018 cy

MFC r342377:

Remove NETBSD_PF. NETBSD_PF is a flag that defines whether the pfil(9)
framework is available. pfil(9) has been in FreeBSD since FreeBSD 5
and according to svn log was first committed to HEAD in 2000, therefore
it is safe to say the check is no longer needed in FreeBSD.

pfil(9) first appeared in NetBSD 1.3 (hence the name NETBSD_PF).
Therefore it is safe to say that it is supported by every NetBSD system
today. The framework also exists in illumos.

As ipfilter code is shared and exchanged between FreeBSD and NetBSD, and
at some point in the future illumos too, and as all three platforms have
pfil(9), the redundant NETBSD_PF #defines and #ifdefs are removed.

342606 30-Dec-2018 cy

MFC r341279:

Clean up a redundant non-redefinition of IFNAMSIZ. IFNAMSIZ
is defined in net/if.h, therefore the condition is never met and
confusing to those who follow.

342588 29-Dec-2018 cy

MFC r342374:

Remove the last vestiges of HP/UX from a FreeBSD-only ipfilter
source file.

342023 13-Dec-2018 cy

MFC r341650:

Remove an ugly Ultrix hack. Ultrix has been AWOL since the last ice
age, more to come.

341740 08-Dec-2018 cy

MFC r341377, r341388 (fixup):

Restore handling of PMTU discovery, removed through an unifdef(1)
following the MFV of r254219 into r255332. In addition the 'FreeBSD'
macro was never defined in ipfilter 5.1.2 thus it never would have
been enabled in the first place.

This work is prompted by a general cleanup of the IP Filter code
prompted by working to resolve a PR. More to follow.

341739 08-Dec-2018 cy

MFC r341384:

Remove IFF_DRVRLOCK as it is used in IRIX only (and we all know IRIX
is dead). This includes collaterally removing code shared by HP/UX,
SGI, and Linux, where IP Filter will in all likelihood for various
reasons never run again.

341708 07-Dec-2018 cy

MFC r341280:

Clean up a rather useless conditional structure member definition.

341615 06-Dec-2018 cy

MFC r341265:

Remove an old comment/code and replace with a comment that
directly references a NetBSD commit.

341380 01-Dec-2018 cy

MFC r340867:

FreeBSD 7 has been history for many moons. Remove some dead code.

341379 01-Dec-2018 cy

MFC r340868:

An OSF/1 ifdef makes absolutley no sense in a FreeBSD specific source
file.

341378 01-Dec-2018 cy

MFC r340909:

Combine two lines into one following unifdef for r255332.

338171 22-Aug-2018 cy

MFC r338047:

The bucket index is subtracted by one at lines 2304 and 2314. When 0 it
becomes -1, except these are unsigned integers, so they become very large
numbers. Thus are always larger than the maximum bucket; the hash table
insertion fails causing NAT to fail.

This commit ensures that if the index is already zero it is not reduced
prior to insertion into the hash table.

PR: 208566

338170 22-Aug-2018 cy

MFC r338046:

Add handy DTrace probes useful in diagnosing NAT issues. DTrace probes
are situated next to error counters and/or in one instance prior to the
-1 return from various functions. This was useful in diagnosis of
PR/208566 and will be handy in the future diagnosing NAT failures.

PR: 208566

338169 22-Aug-2018 cy

MFC r338045:

Expose np (nat_t - an entry in the nat table structure) in the DTrace
probe when nat fails (label badnat). This is useful in diagnosing
failed NAT issues and was used in PR/208566.

PR: 208566

338123 21-Aug-2018 cy

MFC r337410:

Remove redundant and incorrect default definition of AF_INET6. AF_INET6
is defined in sys/socket.h where it's defined as 28.

A bit of trivia: On NetBSD AF_INET6 is defined as 24. On Solaris it is
defined as 26. This is probably why Darren defaulted to 26, because
ipfilter was originally written for SunOS 4 and Solaris many moons ago.

337948 17-Aug-2018 cy

MFC r337558, r337560

r337558:
Identify the return value (rval) that led to the IPv4 NAT failure
in ipf_nat_checkout() and report it in the frb_natv4out and frb_natv4in
dtrace probes.

This is currently being used to diagnose NAT failures in PR/208566. It's
rather handy so this commit makes it available for future diagnosis and
debugging efforts.

PR: 208566

r337560:
Correct a comment. Should have been detected by ipf_nat_in() not
ipf_nat_out().

334201 25-May-2018 cy

MFC r333392-r333393, r333427

r333392:
Fix memory leak. (CID 1199373).

r333393:
Document intentional fallthrough. (CID 976535)

r333427:
Fix style error introduced in r333393.

Reported by: jhb, imp, phk

Approved by: re (delphij)

330475 05-Mar-2018 eadler

MFC r306449:

Remove an extra etter.

328274 23-Jan-2018 cy

MFC r327718:

When growing the state, also grow the seed array. Otherwise memory
that was not allocated will be accessed.

This necessitated refactoring state seed allocation from
ipf_state_soft_init() into a new common ipf_state_seed_alloc() function
as it is now also used by ipf_state_rehash() when changing the size of
the state hash table in addition to by ipf_state_soft_init() during
initialization.

According to Christos Zoulas <christos@NetBSD.org>:

The bug was encountered by a NetBSD vendor who's customer machines had
large ipfilter states. The bug was reliably triggered by resizing the
state variables using "ipf -T".

Submitted by: Christos Zoulas <christos@NetBSD.org>
Reviewed by: delphij, rgrimes
Obtained from: NetBSD ip_state.c CVS revs r1.9 and r1.10
Differential Revision: https://reviews.freebsd.org/D13755

328204 20-Jan-2018 cy

MFC r327913:

Remove redundant variable.

328203 20-Jan-2018 cy

MFC r327912:

Though this block of code is not used by FreeBSD, correct a call to
sprintf() with a macro call to SNPRINTF similar to other calls to
SNPRINTF within this same block.

327717 09-Jan-2018 cy

MFC r327540:

Correct function name in description block.

324513 11-Oct-2017 cy

MFC r323945 and 323962

Fix misspellings, typos and /* border misalignments.

323842 21-Sep-2017 cy

MFC r323715:

Don't use an apostrophe in a possesive pronoun.

323694 18-Sep-2017 cy

MFC r323478:

Improve the wording of a comment describing why EAGAIN is the error code.

323199 06-Sep-2017 cy

MFC r322073:

Fix matchcing of NATed ICMP queries (resolving NATed MTU discovery).

319632 06-Jun-2017 cy

MFC r318998:

Fix return value of ip_sync_nat. Previously, regardless of error it
always returned a return code of 0.

Obtained from: NetBSD ip_sync.c r1.5
Approved by: re (delphij)

319179 30-May-2017 cy

MFC r318606:

Refactor & compact struct i6addr_t #ifdef: remove redundant structure
definintion when USE_INET6 is false.

319176 30-May-2017 cy

MFC r318745:

Remove redundant variable declaration.

317434 26-Apr-2017 cy

MFC r316810, r316814, r316816, r316991:

Keep state incorrectly assumes keep frags. This is counter to the
ipfilter man pages. This also currently restricts keep frags to only when
keep state is used, which is redundant because keep state currently
assumes keep frags. This commit fixes this.

To the user this change means that to maintain the current behaviour
one must add keep frags to any ipfilter keep state rule (as documented
in the man pages).

This patch also allows the flexability to specify and use keep frags
separate from keep state, as documented in an example in ipf.conf.5,
instead of the currently broken behaviour.

MFC suggested by: rgrimes
Relnotes: yes

317242 21-Apr-2017 cy

MFC r316811, r317139:

Add missing free()'s after calls to randomize().

PR: NetBSD PR/50559
Obtained from: Netbsd radix_ipf.c r1.6

317241 21-Apr-2017 cy

MFC r316809:

Fix a use after free panic in ipfilter's fragment processing.
Memory is malloc'd, then a search for a match in the fragment table
is made and if the fragment matches, the wrong fragment table is
freed, causing a use after free panic. This commit fixes this.

A symptom of the problem is a kernel page fault in bcopy() called by
ipf_frag_lookup() at line 715 in ip_frag.c. Another symptom is a
kernel page fault in ipf_frag_delete() when called by ipf_frag_expire()
via ipf_slowtimer().

315079 11-Mar-2017 cy

MFC r312886:

Fix lookup of original destination address when using a redirect rule.
Transparent proxying, e.g. to squid, is an example of this.

Obtained from: NetBSD ip_nat.c r1.17, ip_nat6.c r1.10

314251 25-Feb-2017 cy

MFC r312787:

Currently the fragment info is placed at the top of the linked list
under a shared read lock. This patch attempts to upgrade the lock to
an exclusive write lock. If the exclusive write lock fails to be
obtained, the current fragment is not placed at the head of the list.

This portion of the patch was inspired by NetBSD ip_frag.c r1.4 (which
effectively removed the section of code that performed the reordering).

The patch to sys/contrib/ipfilter/netinet/ip_compat.h adds the
MUTEX_TRY_UPGRADE macro to support the patch to ip_frag.c.

The patch to contrib/ipfilter/lib/rwlock_emul.c supports this patch
by emulating the mutex in userspace when exercised by ipftest(1).

Inspired by: NetBSD ip_frag.c r1.4

312413 19-Jan-2017 bz

MFC r311950:

Get rid of a compiler warning which I saw too often.
Include netinet/in.h before ip_compat.t which will then check if
IPPROTO_IPIP is defined or not. Doing it the other way round,
ip_compat.h would not find it defined and netinet/in.h then
redefine it.

305138 31-Aug-2016 dim

MFC r304953:

Define ipfilter's SOLARIS macro in a defined and portable way.

Reviewed by: cy
Differential Revision: https://reviews.freebsd.org/D7671

MFC r304959 (by kib):

Complete r304953.

Sponsored by: The FreeBSD Foundation

MFC r304964:

Follow-up to r304953, in which I broke the build: apparently the SOLARIS
macro is defined in lots of different places in ipfilter, so replace all
of the nonportable definitions with portable ones.

Pointy hat to: dim

302408 08-Jul-2016 gjb

Copy head@r302406 to stable/11 as part of the 11.0-RELEASE cycle.
Prune svn:mergeinfo from the new branch, as nothing has been merged
here.

Additional commits post-branch will follow.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation


/freebsd-11-stable/MAINTAINERS
/freebsd-11-stable/cddl
/freebsd-11-stable/cddl/contrib/opensolaris
/freebsd-11-stable/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/print
/freebsd-11-stable/cddl/contrib/opensolaris/cmd/zfs
/freebsd-11-stable/cddl/contrib/opensolaris/lib/libzfs
/freebsd-11-stable/contrib/amd
/freebsd-11-stable/contrib/apr
/freebsd-11-stable/contrib/apr-util
/freebsd-11-stable/contrib/atf
/freebsd-11-stable/contrib/binutils
/freebsd-11-stable/contrib/bmake
/freebsd-11-stable/contrib/byacc
/freebsd-11-stable/contrib/bzip2
/freebsd-11-stable/contrib/com_err
/freebsd-11-stable/contrib/compiler-rt
/freebsd-11-stable/contrib/dialog
/freebsd-11-stable/contrib/dma
/freebsd-11-stable/contrib/dtc
/freebsd-11-stable/contrib/ee
/freebsd-11-stable/contrib/elftoolchain
/freebsd-11-stable/contrib/elftoolchain/ar
/freebsd-11-stable/contrib/elftoolchain/brandelf
/freebsd-11-stable/contrib/elftoolchain/elfdump
/freebsd-11-stable/contrib/expat
/freebsd-11-stable/contrib/file
/freebsd-11-stable/contrib/gcc
/freebsd-11-stable/contrib/gcclibs/libgomp
/freebsd-11-stable/contrib/gdb
/freebsd-11-stable/contrib/gdtoa
/freebsd-11-stable/contrib/groff
/freebsd-11-stable/contrib/ipfilter
/freebsd-11-stable/contrib/ldns
/freebsd-11-stable/contrib/ldns-host
/freebsd-11-stable/contrib/less
/freebsd-11-stable/contrib/libarchive
/freebsd-11-stable/contrib/libarchive/cpio
/freebsd-11-stable/contrib/libarchive/libarchive
/freebsd-11-stable/contrib/libarchive/libarchive_fe
/freebsd-11-stable/contrib/libarchive/tar
/freebsd-11-stable/contrib/libc++
/freebsd-11-stable/contrib/libc-vis
/freebsd-11-stable/contrib/libcxxrt
/freebsd-11-stable/contrib/libexecinfo
/freebsd-11-stable/contrib/libpcap
/freebsd-11-stable/contrib/libstdc++
/freebsd-11-stable/contrib/libucl
/freebsd-11-stable/contrib/libxo
/freebsd-11-stable/contrib/llvm
/freebsd-11-stable/contrib/llvm/projects/libunwind
/freebsd-11-stable/contrib/llvm/tools/clang
/freebsd-11-stable/contrib/llvm/tools/lldb
/freebsd-11-stable/contrib/llvm/tools/llvm-dwarfdump
/freebsd-11-stable/contrib/llvm/tools/llvm-lto
/freebsd-11-stable/contrib/mdocml
/freebsd-11-stable/contrib/mtree
/freebsd-11-stable/contrib/ncurses
/freebsd-11-stable/contrib/netcat
/freebsd-11-stable/contrib/ntp
/freebsd-11-stable/contrib/nvi
/freebsd-11-stable/contrib/one-true-awk
/freebsd-11-stable/contrib/openbsm
/freebsd-11-stable/contrib/openpam
/freebsd-11-stable/contrib/openresolv
/freebsd-11-stable/contrib/pf
/freebsd-11-stable/contrib/sendmail
/freebsd-11-stable/contrib/serf
/freebsd-11-stable/contrib/sqlite3
/freebsd-11-stable/contrib/subversion
/freebsd-11-stable/contrib/tcpdump
/freebsd-11-stable/contrib/tcsh
/freebsd-11-stable/contrib/tnftp
/freebsd-11-stable/contrib/top
/freebsd-11-stable/contrib/top/install-sh
/freebsd-11-stable/contrib/tzcode/stdtime
/freebsd-11-stable/contrib/tzcode/zic
/freebsd-11-stable/contrib/tzdata
/freebsd-11-stable/contrib/unbound
/freebsd-11-stable/contrib/vis
/freebsd-11-stable/contrib/wpa
/freebsd-11-stable/contrib/xz
/freebsd-11-stable/crypto/heimdal
/freebsd-11-stable/crypto/openssh
/freebsd-11-stable/crypto/openssl
/freebsd-11-stable/gnu/lib
/freebsd-11-stable/gnu/usr.bin/binutils
/freebsd-11-stable/gnu/usr.bin/cc/cc_tools
/freebsd-11-stable/gnu/usr.bin/gdb
/freebsd-11-stable/lib/libc/locale/ascii.c
/freebsd-11-stable/sys/cddl/contrib/opensolaris
/freebsd-11-stable/sys/contrib/dev/acpica
/freebsd-11-stable/sys/contrib/ipfilter
/freebsd-11-stable/sys/contrib/libfdt
/freebsd-11-stable/sys/contrib/octeon-sdk
/freebsd-11-stable/sys/contrib/x86emu
/freebsd-11-stable/sys/contrib/xz-embedded
/freebsd-11-stable/usr.sbin/bhyve/atkbdc.h
/freebsd-11-stable/usr.sbin/bhyve/bhyvegc.c
/freebsd-11-stable/usr.sbin/bhyve/bhyvegc.h
/freebsd-11-stable/usr.sbin/bhyve/console.c
/freebsd-11-stable/usr.sbin/bhyve/console.h
/freebsd-11-stable/usr.sbin/bhyve/pci_fbuf.c
/freebsd-11-stable/usr.sbin/bhyve/pci_xhci.c
/freebsd-11-stable/usr.sbin/bhyve/pci_xhci.h
/freebsd-11-stable/usr.sbin/bhyve/ps2kbd.c
/freebsd-11-stable/usr.sbin/bhyve/ps2kbd.h
/freebsd-11-stable/usr.sbin/bhyve/ps2mouse.c
/freebsd-11-stable/usr.sbin/bhyve/ps2mouse.h
/freebsd-11-stable/usr.sbin/bhyve/rfb.c
/freebsd-11-stable/usr.sbin/bhyve/rfb.h
/freebsd-11-stable/usr.sbin/bhyve/sockstream.c
/freebsd-11-stable/usr.sbin/bhyve/sockstream.h
/freebsd-11-stable/usr.sbin/bhyve/usb_emul.c
/freebsd-11-stable/usr.sbin/bhyve/usb_emul.h
/freebsd-11-stable/usr.sbin/bhyve/usb_mouse.c
/freebsd-11-stable/usr.sbin/bhyve/vga.c
/freebsd-11-stable/usr.sbin/bhyve/vga.h
302370 06-Jul-2016 bz

Only set the ipfilter running state to 'not running' if we are
doing the teardown. ipf_destroy_all() may free ipfmain in case
of ipf_dynamic_softc being true, thus we are avoiding a possible
memory modified after free as well.

Reported by: Coverity
Coverity CID: 1357320
Approved by: re (hrs)
MFC after: 10 days


302298 30-Jun-2016 bz

Virtualise ipfilter.
Split initializzation an teardown into module (global state) and VNET
(per virtual network stack) parts. Virtualise global state, which is
not "const".

Cleanup eventhandlers, so that we can make use of the passed in argument
to get the vnet state from the ifp; disable the "cloner" event as it is
too early, has no state, and can fire before initialisation (see comment
in the source).

Handle the dynamic sysctls specially. The problem is that "ipmain"
is the virtualized struct, but the fields used for the sysctls are
hanging off memory allocated and attached to the virtualized "ipmain"
thus standard VNET macros and sysctl handling do not work.
We still say it is VNET sysctls to get the proper protection checks
in the VIMAGE case; to solve the problem of accessing the right bit
of memory hanging of each per-VNET ipmain, we use a dedicated handler
function wrapping around sysctl_ipf_int() undoing the base calculation
from kern_sysctl.c and then adding the passed-in offset into the right
struct depending on handler. A bit of a mess exposing VNET-internals
this way but the only way to keep the code without having to massively
restructure ipf internals.

Approved by: re (hrs)
Sponsored by: The FreeBSD Foundation
Obtained from: projects/vnet
MFC after: 2 weeks
Reviewed by: cy
Differential Revision: https://reviews.freebsd.org/D7000


302289 30-Jun-2016 bz

Remove unused global variables as well as unused memory
allocations from ipfilter in preparation for VNET support.

Suggested by: cy (see D7000)
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Approved by: re (gjb)


302054 21-Jun-2016 bz

Get closer to a VIMAGE network stack teardown from top to bottom rather
than removing the network interfaces first. This change is rather larger
and convoluted as the ordering requirements cannot be separated.

Move the pfil(9) framework to SI_SUB_PROTO_PFIL, move Firewalls and
related modules to their own SI_SUB_PROTO_FIREWALL.
Move initialization of "physical" interfaces to SI_SUB_DRIVERS,
move virtual (cloned) interfaces to SI_SUB_PSEUDO.
Move Multicast to SI_SUB_PROTO_MC.

Re-work parts of multicast initialisation and teardown, not taking the
huge amount of memory into account if used as a module yet.

For interface teardown we try to do as many of them as we can on
SI_SUB_INIT_IF, but for some this makes no sense, e.g., when tunnelling
over a higher layer protocol such as IP. In that case the interface
has to go along (or before) the higher layer protocol is shutdown.

Kernel hhooks need to go last on teardown as they may be used at various
higher layers and we cannot remove them before we cleaned up the higher
layers.

For interface teardown there are multiple paths:
(a) a cloned interface is destroyed (inside a VIMAGE or in the base system),
(b) any interface is moved from a virtual network stack to a different
network stack ("vmove"), or (c) a virtual network stack is being shut down.
All code paths go through if_detach_internal() where we, depending on the
vmove flag or the vnet state, make a decision on how much to shut down;
in case we are destroying a VNET the individual protocol layers will
cleanup their own parts thus we cannot do so again for each interface as
we end up with, e.g., double-frees, destroying locks twice or acquiring
already destroyed locks.
When calling into protocol cleanups we equally have to tell them
whether they need to detach upper layer protocols ("ulp") or not
(e.g., in6_ifdetach()).

Provide or enahnce helper functions to do proper cleanup at a protocol
rather than at an interface level.

Approved by: re (hrs)
Obtained from: projects/vnet
Reviewed by: gnn, jhb
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D6747


300260 20-May-2016 cy

Remove extraneous blank line.

MFC after: 1 month
X-MFC with: r300259


300259 20-May-2016 cy

Enable the two ip_frag tuneables. The code is there but the two
ip_frag tuneables aren't registered in the ipf_tuners linked list.
This commmit enables the two existing ip_frag tuneables by registering
them.

MFC after: 1 month


299870 15-May-2016 cy

Make subsequent code reachable.

Reported by: Coverity CID 1354625
MFC after: 3 days


298094 16-Apr-2016 gjb

Remove svn:mergeinfo on files with which it should never have
existed.

Sponsored by: The FreeBSD Foundation


298030 15-Apr-2016 cy

Use NULL instead of 0 for pointer comparison.

MFC after: 4 weeks


297632 07-Apr-2016 cy

Add DTrace probes for packets flagged as bad by ipfilter. All probes
for bad packets are named ipf_fi_bad_*. An example of its use might be:

dtrace -n 'sdt:::ipf_fi_bad_* { stack(); }'

Reviewed by: Darren Reed <darrenr@reed.wattle.id.au>


296417 05-Mar-2016 dim

Upgrade our copies of clang, llvm, lldb and compiler-rt to 3.8.0
release.

Please note that from 3.5.0 onwards, clang, llvm and lldb require C++11
support to build; see UPDATING for more information.

Release notes for llvm and clang will soon be available here:
<http://llvm.org/releases/3.8.0/docs/ReleaseNotes.html>
<http://llvm.org/releases/3.8.0/tools/clang/docs/ReleaseNotes.html>

Thanks to Ed Maste, Roman Divacky, Davide Italiano and Antoine Brodin
for their help.

Relnotes: yes


296299 02-Mar-2016 cy

Remove redundant NULL pointer comparison.

Reported by: PVS-Studio (V595) in D5245
Differential Revision: D5245


295126 01-Feb-2016 glebius

These files were getting sys/malloc.h and vm/uma.h with header pollution
via sys/mbuf.h


293628 10-Jan-2016 melifaro

Convert ipfilter to the new routing KPI.

Differential Revision: D4764


292813 28-Dec-2015 cy

Correct __FreeBSD__ check.

MFC after: 3 days


292518 20-Dec-2015 cy

Don't assume checksums will be calculated later when fastfoward is
enabled (by default in r290383).

PR: 72210
MFC after: 1 week


290494 07-Nov-2015 bapt

Improve collation string and locales support

Merge collation support from Illumos and DragonflyBSD.

Locales are now generated with the new localedef(1) tool from CLDR POSIX files.
The generated files are now identified as "BSD 1.0" format.

The libc now only read "BSD 1.0" locales definitions, all other version will be
set to "C"
The localedef(1) tool has been imported from Illumos and modified to use tree(3)
instead of the CDDL avl(3)
A set of tool created by edwin@ and extended by marino@ for dragonfly has been
added to be able to generate locales and the Makefiles from the vanilla CLDR
unicode databases + a universal UTF-8 charmap (by marino@)
Update the locales to unicode v27
Given our regex(3) does not support multibyte (yet) it has been forced to always
use locale C
Remove now unused colldef(1) and mklocale(1)
Finish implementing the numeric BSD extension for ctypes
The number of supported locales has grown from 175 to 250 locales. Among the new
locales: 6 Arabic locales (AE EG JO MA QA SA), Different variations of spanish
locales.
Added new 3 components locales for mn_Cyrl_MN, sr_Cyrl_RS sr_Latn_RS,
zh_Hans_CN, zh_Hant_HK and zh_Hant_TW. Some aliases has been for 2 components
version when possible.

Thanks: Garrett D'Amore (Illumos) who made sure all his work was done under
BSD license!, Edwin Groothuis (edwin@) for the work he made on tools to be able
to generate locales definition usable in freebsd sources out of vanilla CLDR
definitions, John Marino (DragonflyBSD) who first merge the Illumos work into
Dragonfly and spent hours tracking down bugs.


290102 28-Oct-2015 bapt

Merge mpsutil(8) branch

mpsutil(8)/mprutil(8) are new utilities for managing LSI Fusion-MPT
2/3 controllers (mps(4) and mpr(4))

For now only informational commands have been implemented.

This utility has been written by scottl@ [1] and polished by myself[2]

Submitted by: scottl
Discussed with: scottl
Relnotes: yes
Sponsored by: Netflix [1]
Sponsored by: Gandi.net [2]


289480 18-Oct-2015 cy

Really fix ipfilter bug 3600459.

Obtained from: ipfilter cvs repo r1.48.2.25, r1.72 and NetBSD repo r1.4
MFC after: 3 days


288943 06-Oct-2015 dim

Upgrade our copies of clang, llvm, lldb, compiler-rt and libc++ to 3.7.0
release.

Please note that from 3.5.0 onwards, clang, llvm and lldb require C++11
support to build; see UPDATING for more information.

Release notes for llvm and clang can be found here:
<http://llvm.org/releases/3.7.0/docs/ReleaseNotes.html>
<http://llvm.org/releases/3.7.0/tools/clang/docs/ReleaseNotes.html>

Thanks to Ed Maste, Andrew Turner and Antoine Brodin for their help.

Exp-run: antoine
Relnotes: yes


288910 06-Oct-2015 cy

On some interfaces, ipfilter drops UDP packets with zero checkum.
This commit fixes that.

PR: 166372
Submitted by: mk@neon1.net
Reviewed by: Darren Reed <darrenr@reed.wattle.id.au>
MFC after: 1 week


288242 25-Sep-2015 bz

Compare the newly allocated array elements to NULL in order to see
if the malloc succeeded.

Spotted by: reading kernel compile time log
MFC after: 2 weeks


287675 11-Sep-2015 cy

Revert ip_fil_freebsd.c -r287674. This should not have gone in yet.


287674 11-Sep-2015 cy

Fix ipfilter bug 3600459 NAT bucket count wrong.

Obtained from: ipfilter cvs repo r1.48.2.25
MFC after: 2 weeks


287653 11-Sep-2015 cy

Revert $FreeBSD$.


287652 11-Sep-2015 cy

Fix mutex errors.

Obtained from: NetBSD r1.4.
MFC after: 1 week


287651 11-Sep-2015 cy

Fixup typos in comments.

Obtained from: NetBSD r1.4.
MFC after: 1 week


283291 22-May-2015 jkim

CALLOUT_MPSAFE has lost its meaning since r141428, i.e., for more than ten
years for head. However, it is continuously misused as the mpsafe argument
for callout_init(9). Deprecate the flag and clean up callout_init() calls
to make them more consistent.

Differential Revision: https://reviews.freebsd.org/D2613
Reviewed by: jhb
MFC after: 2 weeks


281192 07-Apr-2015 glebius

In ipfilter(4) there is the ipftest(1) program, that compiles half of the
ipfilter code as userland application. To reduce kernel structure knowledge
include if_var.h only if a file is compiled with _KERNEL defined.
In !_KERNEL case, provide our own definition of struct ifnet, that will
satisfy ipftest(1). This was already done earlier to struct ifaddr in
r279029. Protect the definition with _NET_IF_VAR_H_, since kernel part
of ipfilter may include if_var.h and ip_compat.h.

Sponsored by: Netflix
Sponsored by: Nginx, Inc.


280971 01-Apr-2015 glebius

o Use new function ip_fillid() in all places throughout the kernel,
where we want to create a new IP datagram.
o Add support for RFC6864, which allows to set IP ID for atomic IP
datagrams to any value, to improve performance. The behaviour is
controlled by net.inet.ip.rfc6864 sysctl knob, which is enabled by
default.
o In case if we generate IP ID, use counter(9) to improve performance.
o Gather all code related to IP ID into ip_id.c.

Differential Revision: https://reviews.freebsd.org/D2177
Reviewed by: adrian, cy, rpaulo
Tested by: Emeric POUPON <emeric.poupon stormshield.eu>
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
Relnotes: yes


276750 06-Jan-2015 rwatson

In order to reduce use of M_EXT outside of the mbuf allocator and
socket-buffer implementations, introduce a return value for MCLGET()
(and m_cljget() that underlies it) to allow the caller to avoid testing
M_EXT itself. Update all callers to use the return value.

With this change, very few network device drivers remain aware of
M_EXT; the primary exceptions lie in mbuf-chain pretty printers for
debugging, and in a few cases, custom mbuf and cluster allocation
implementations.

NB: This is a difficult-to-test change as it touches many drivers for
which I don't have physical devices. Instead we've gone for intensive
review, but further post-commit review would definitely be appreciated
to spot errors where changes could not easily be made mechanically,
but were largely mechanical in nature.

Differential Revision: https://reviews.freebsd.org/D1440
Reviewed by: adrian, bz, gnn
Sponsored by: EMC / Isilon Storage Division


276479 31-Dec-2014 dim

Upgrade our copy of clang, llvm and lldb to 3.5.0 release.

Please note that this version now requires C++11 support to build; see
UPDATING for more information.

Release notes for llvm and clang can be found here:
<http://llvm.org/releases/3.5.0/docs/ReleaseNotes.html>
<http://llvm.org/releases/3.5.0/tools/clang/docs/ReleaseNotes.html>

Thanks to Ed Maste, Roman Divacky, Andrew Turner, Justin Hibbits and
Antoine Brodin for their invaluable help with this import.

Approved by: portmgr (antoine)
MFC after: 1 month


275199 28-Nov-2014 cy

Correctly define constants.

MFC after: 1 week


274744 20-Nov-2014 rodrigc

Set the current vnet inside the ioctl handler for ipfilter.

Without this fix, the vnet was NULL and would crash.
This fix is similar to what was done inside the ioctl handler for PF.

Tested by:
(1) Boot a kernel with "options VIMAGE" enabled
(2) Type:

echo "map lo0 from 10.0.0.0/24 to ! 10.0.0.0/24 -> 127.0.0.1/32" > /etc/ipnat.rules ; service ipnat onerestart

PR: 176992
Differential Revision: https://reviews.freebsd.org/D1191
Reviewed by: cy


272555 05-Oct-2014 cy

ipfilter bug #537 NAT rules with sticky have incorrect hostmap IP address.
This fixes when an IP address mapping is put in the hostmap table for
sticky NAT rules, it ends up having the wrong byte order.

Obtained from: ipfilter CVS repo (r1.102), NetBSD CVS repo (r1.12)


272554 05-Oct-2014 cy

ipfilter bug #534 destination list hashing not endian neutral

Obtained from: ipfilter CVS repo (r1.26), NetBSD CVS repo (r1.8)


272553 05-Oct-2014 cy

ipfilter bug #538 ipf_p_dns_del should return void

Obtained from: ipfilter cvs repo (r1.8)


272552 05-Oct-2014 cy

ipfilter bug #554 Determining why a ipf rule matches is hard -- replace
ipfilter rule compare with new ipf_rule_compare() function.

Obtained from: ipfilter CVS rep (r1.129)


272551 05-Oct-2014 cy

ipfiler bug #550 filter rule list corrupted with inserted rules

Obtained from: ipfilter CVS repo (r1.128); NetBSD CVS repo (r1.15)


272052 24-Sep-2014 cy

ipfilter bug #558 add in some missing frag table function comments.

Approved by: glebius (mentor)
Obtained from: ipfilter CVS repo (r1.36)


271980 22-Sep-2014 cy

Check for NULL before de-refencing; in particular sel is assigned to NULL,
in the default case, and then couple of lines down we do sel->

Approved by: glebius (mentor)
Obtained from: NetBSD CVS repo (r1.5)


269585 05-Aug-2014 cy

Honour WITH and WITHOUT_INET6_SUPPORT.

Approved by: glebius (mentor)
MFC after: 3 days


268532 11-Jul-2014 cy

Remove redundant USE_INET6 test that enables INET6 in the ipfilter userland
regardless of the setting in make.conf.

PR: 190964
Approved by: glebius (mentor)
MFC after: 1 week


267634 19-Jun-2014 cy

Fix case where fastroute or "to interface" is used with incorrect FIB.

PR: 183065
Submitted by: p-freebsd-bugs@ziemba.us
Approved by: glebius
MFC after: 1 week


266605 24-May-2014 cy

Move mutex creation from ipf_log_soft_init() to ipf_log_soft_create()
to be consistent with mutex destruction in ipf_log_soft_destroy(). As a
result mutex destruction in ipf_log_soft_fini() is redundant.

Approved by: glebius (mentor)
Obtained from: darrenr (author)


264235 07-Apr-2014 cy

Implement the final missing sysctls by moving ipf_auth_softc_t from
ip_auth.c to ip_auth.h. ip_frag_soft_t moves from ip_frag.c to
ip_frag.h. mlfk_ipl.c creates sysctl MIBs that reference control blocks
that are dynamically created when IP Filter is loaded. This necessitated
creating them on-the-fly rather than statically at compile time.

Approved by: glebius (mentor)


262763 05-Mar-2014 glebius

- Remove rt_metrics_lite and simply put its members into rtentry.
- Use counter(9) for rt_pksent (former rt_rmx.rmx_pksent). This
removes another cache trashing ++ from packet forwarding path.
- Create zini/fini methods for the rtentry UMA zone. Via initialize
mutex and counter in them.
- Fix reporting of rmx_pksent to routing socket.
- Fix netstat(1) to report "Use" both in kvm(3) and sysctl(3) mode.

The change is mostly targeted for stable/10 merge. For head,
rt_pksent is expected to just disappear.

Discussed with: melifaro
Sponsored by: Netflix
Sponsored by: Nginx, Inc.


260715 16-Jan-2014 glebius

Substitute flags from historical mbuf(9) allocator with modern ones.

Sponsored by: Nginx, Inc.


257256 28-Oct-2013 glebius

Fix build. We need to include systm.h before if_var.h.

Pointy hat to: glebius


257218 27-Oct-2013 glebius

Include lock.h before mutex.h.


256253 10-Oct-2013 dim

Initialize a variable in sys/contrib/ipfilter/netinet/ip_tftp_pxy.c, to
silence a gcc warning.

Approved by: re (rodrigc)
X-MFC-With: r255332


256199 09-Oct-2013 dim

Initialize a variable in sys/contrib/ipfilter/netinet/ip_rcmd_pxy.c, to
silence a gcc warning.

Approved by: re (gjb)
X-MFC-With: r255332


255757 21-Sep-2013 cy

Address double init of ip_log mutex, fixing a panic after ipfilter is
re-enabled following it being disabled.

Approved by: glebius (mentor)
Approved by: re (blanket)


255756 21-Sep-2013 cy

Enable main ipfilter sysctl MIBs.

Approved by: glebius (mentor)
Approved by: re (blanket)


255755 21-Sep-2013 cy

Convert ipfilter from timeout(9) to callout(9).

Submitted by: jhb
Approved by: glebius (mentor)
Approved by: re (blanket)


255754 21-Sep-2013 cy

Remove additional non-FreeBSD code.

Approved by: glebius (mentor)
Approved by: re (blanket)


255355 07-Sep-2013 glebius

Fix !INET6 build.


255332 06-Sep-2013 cy

Update ipfilter 4.1.28 --> 5.1.2.

Approved by: glebius (mentor)
BSD Licensed by: Darren Reed <darrenr@reed.wattle.id.au> (author)


249266 08-Apr-2013 glebius

Forcibly defining _KERNEL is bad idea. Toss some code so that ip_var.h
isn't included with forced _KERNEL define.


241546 14-Oct-2012 glebius

Fix defines in r241245. We actually don't define FreeBSD.

Reported & tested by: Oleg Ginzburg


241394 10-Oct-2012 kevlo

Revert previous commit...

Pointyhat to: kevlo (myself)


241370 09-Oct-2012 kevlo

Prefer NULL over 0 for pointers


241245 06-Oct-2012 glebius

A step in resolving mess with byte ordering for AF_INET. After this change:

- All packets in NETISR_IP queue are in net byte order.
- ip_input() is entered in net byte order and converts packet
to host byte order right _after_ processing pfil(9) hooks.
- ip_output() is entered in host byte order and converts packet
to net byte order right _before_ processing pfil(9) hooks.
- ip_fragment() accepts and emits packet in net byte order.
- ip_forward(), ip_mloopback() use host byte order (untouched actually).
- ip_fastforward() no longer modifies packet at all (except ip_ttl).
- Swapping of byte order there and back removed from the following modules:
pf(4), ipfw(4), enc(4), if_bridge(4).
- Swapping of byte order added to ipfilter(4), based on __FreeBSD_version
- __FreeBSD_version bumped.
- pfil(9) manual page updated.

Reviewed by: ray, luigi, eri, melifaro
Tested by: glebius (LE), ray (BE)


241002 27-Sep-2012 fjoe

Fix pseudo checksum calculation.

This fixes ipfilter w/ network controllers that implement only
partial rx csum offloading.

PR: 106438
Obtained from: upstream
MFC after: 1 week


240725 20-Sep-2012 kevlo

Fix typo: s/pakcet/packet


227957 24-Nov-2011 rmh

Adjust a few old checks to use __FreeBSD_version macro to
determine which version of FreeBSD kernel we're compiling.

Approved by: kib (mentor)


213782 13-Oct-2010 rpaulo

Pass a format string to make_dev().

Found by: clang


207369 29-Apr-2010 bz

MFP4: @176978-176982, 176984, 176990-176994, 177441

"Whitspace" churn after the VIMAGE/VNET whirls.

Remove the need for some "init" functions within the network
stack, like pim6_init(), icmp_init() or significantly shorten
others like ip6_init() and nd6_init(), using static initialization
again where possible and formerly missed.

Move (most) variables back to the place they used to be before the
container structs and VIMAGE_GLOABLS (before r185088) and try to
reduce the diff to stable/7 and earlier as good as possible,
to help out-of-tree consumers to update from 6.x or 7.x to 8 or 9.

This also removes some header file pollution for putatively
static global variables.

Revert VIMAGE specific changes in ipfilter::ip_auth.c, that are
no longer needed.

Reviewed by: jhb
Discussed with: rwatson
Sponsored by: The FreeBSD Foundation
Sponsored by: CK Software GmbH
MFC after: 6 days


206627 14-Apr-2010 imp

We don't need the definition for in_cksum repeated here since we get
it from machine/in_cksum.h. This definition prevents us from using
hand-tuned assembler versions of in_cksum.

# this fixes the modules build on arm for ipfilter.


196019 01-Aug-2009 rwatson

Merge the remainder of kern_vimage.c and vimage.h into vnet.c and
vnet.h, we now use jails (rather than vimages) as the abstraction
for virtualization management, and what remained was specific to
virtual network stacks. Minor cleanups are done in the process,
and comments updated to reflect these changes.

Reviewed by: bz
Approved by: re (vimage blanket)


195699 14-Jul-2009 rwatson

Build on Jeff Roberson's linker-set based dynamic per-CPU allocator
(DPCPU), as suggested by Peter Wemm, and implement a new per-virtual
network stack memory allocator. Modify vnet to use the allocator
instead of monolithic global container structures (vinet, ...). This
change solves many binary compatibility problems associated with
VIMAGE, and restores ELF symbols for virtualized global variables.

Each virtualized global variable exists as a "reference copy", and also
once per virtual network stack. Virtualized global variables are
tagged at compile-time, placing the in a special linker set, which is
loaded into a contiguous region of kernel memory. Virtualized global
variables in the base kernel are linked as normal, but those in modules
are copied and relocated to a reserved portion of the kernel's vnet
region with the help of a the kernel linker.

Virtualized global variables exist in per-vnet memory set up when the
network stack instance is created, and are initialized statically from
the reference copy. Run-time access occurs via an accessor macro, which
converts from the current vnet and requested symbol to a per-vnet
address. When "options VIMAGE" is not compiled into the kernel, normal
global ELF symbols will be used instead and indirection is avoided.

This change restores static initialization for network stack global
variables, restores support for non-global symbols and types, eliminates
the need for many subsystem constructors, eliminates large per-subsystem
structures that caused many binary compatibility issues both for
monitoring applications (netstat) and kernel modules, removes the
per-function INIT_VNET_*() macros throughout the stack, eliminates the
need for vnet_symmap ksym(2) munging, and eliminates duplicate
definitions of virtualized globals under VIMAGE_GLOBALS.

Bump __FreeBSD_version and update UPDATING.

Portions submitted by: bz
Reviewed by: bz, zec
Discussed with: gnn, jamie, jeff, jhb, julian, sam
Suggested by: peter
Approved by: re (kensmith)


192895 27-May-2009 jamie

Add hierarchical jails. A jail may further virtualize its environment
by creating a child jail, which is visible to that jail and to any
parent jails. Child jails may be restricted more than their parents,
but never less. Jail names reflect this hierarchy, being MIB-style
dot-separated strings.

Every thread now points to a jail, the default being prison0, which
contains information about the physical system. Prison0's root
directory is the same as rootvnode; its hostname is the same as the
global hostname, and its securelevel replaces the global securelevel.
Note that the variable "securelevel" has actually gone away, which
should not cause any problems for code that properly uses
securelevel_gt() and securelevel_ge().

Some jail-related permissions that were kept in global variables and
set via sysctls are now per-jail settings. The sysctls still exist for
backward compatibility, used only by the now-deprecated jail(2) system
call.

Approved by: bz (mentor)


191548 26-Apr-2009 zec

In preparation for turning on options VIMAGE in next commits,
rearrange / replace / adjust several INIT_VNET_* initializer
macros, all of which currently resolve to whitespace.

Reviewed by: bz (an older version of the patch)
Approved by: julian (mentor)


191148 16-Apr-2009 kmacy

Change if_output to take a struct route as its fourth argument in order
to allow passing a cached struct llentry * down to L2

Reviewed by: rwatson


189105 27-Feb-2009 bz

Move the include of vinet.h further up before the ipfilter includes.


186436 23-Dec-2008 bz

Check for ipprotosw.h more precisely.
It hasn't been needed for more than 5 years, since r120386.

MFC after: 4 weeks


185571 02-Dec-2008 bz

Rather than using hidden includes (with cicular dependencies),
directly include only the header files needed. This reduces the
unneeded spamming of various headers into lots of files.

For now, this leaves us with very few modules including vnet.h
and thus needing to depend on opt_route.h.

Reviewed by: brooks, gnn, des, zec, imp
Sponsored by: The FreeBSD Foundation


185419 28-Nov-2008 zec

Unhide declarations of network stack virtualization structs from
underneath #ifdef VIMAGE blocks.

This change introduces some churn in #include ordering and nesting
throughout the network stack and drivers but is not expected to cause
any additional issues.

In the next step this will allow us to instantiate the virtualization
container structures and switch from using global variables to their
"containerized" counterparts.

Reviewed by: bz, julian
Approved by: julian (mentor)
Obtained from: //depot/projects/vimage-commit2/...
X-MFC after: never
Sponsored by: NLnet Foundation, The FreeBSD Foundation


184205 23-Oct-2008 des

Retire the MALLOC and FREE macros. They are an abomination unto style(9).

MFC after: 3 months


183550 02-Oct-2008 zec

Step 1.5 of importing the network stack virtualization infrastructure
from the vimage project, as per plan established at devsummit 08/08:
http://wiki.freebsd.org/Image/Notes200808DevSummit

Introduce INIT_VNET_*() initializer macros, VNET_FOREACH() iterator
macros, and CURVNET_SET() context setting macros, all currently
resolving to NOPs.

Prepare for virtualization of selected SYSCTL objects by introducing a
family of SYSCTL_V_*() macros, currently resolving to their global
counterparts, i.e. SYSCTL_V_INT() == SYSCTL_INT().

Move selected #defines from sys/sys/vimage.h to newly introduced header
files specific to virtualized subsystems (sys/net/vnet.h,
sys/netinet/vinet.h etc.).

All the changes are verified to have zero functional impact at this
point in time by doing MD5 comparision between pre- and post-change
object files(*).

(*) netipsec/keysock.c did not validate depending on compile time options.

Implemented by: julian, bz, brooks, zec
Reviewed by: julian, bz, brooks, kris, rwatson, ...
Approved by: julian (mentor)
Obtained from: //depot/projects/vimage-commit2/...
X-MFC after: never
Sponsored by: NLnet Foundation, The FreeBSD Foundation


183397 27-Sep-2008 ed

Replace all calls to minor() with dev2unit().

After I removed all the unit2minor()/minor2unit() calls from the kernel
yesterday, I realised calling minor() everywhere is quite confusing.
Character devices now only have the ability to store a unit number, not
a minor number. Remove the confusion by using dev2unit() everywhere.

This commit could also be considered as a bug fix. A lot of drivers call
minor(), while they should actually be calling dev2unit(). In -CURRENT
this isn't a problem, but it turns out we never had any problem reports
related to that issue in the past. I suspect not many people connect
more than 256 pieces of the same hardware.

Reviewed by: kib


181803 17-Aug-2008 bz

Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).

This is the first in a series of commits over the course
of the next few weeks.

Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.

We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.

Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch


180832 26-Jul-2008 darrenr

2020447 IPFilter's NAT can undo name server random port selection
(fix output port range, was a random number in [0,max-min]
(byteswapped on litle endian), instead of [min,max])

Submitted by: darrenr


180778 24-Jul-2008 darrenr

2020447 IPFilter's NAT can undo name server random port selection

Approved by: darrenr
MFC after: 1 week
Security: CERT VU#521769


178888 09-May-2008 julian

Add code to allow the system to handle multiple routing tables.
This particular implementation is designed to be fully backwards compatible
and to be MFC-able to 7.x (and 6.x)

Currently the only protocol that can make use of the multiple tables is IPv4
Similar functionality exists in OpenBSD and Linux.

From my notes:

-----

One thing where FreeBSD has been falling behind, and which by chance I
have some time to work on is "policy based routing", which allows
different
packet streams to be routed by more than just the destination address.

Constraints:
------------

I want to make some form of this available in the 6.x tree
(and by extension 7.x) , but FreeBSD in general needs it so I might as
well do it in -current and back port the portions I need.

One of the ways that this can be done is to have the ability to
instantiate multiple kernel routing tables (which I will now
refer to as "Forwarding Information Bases" or "FIBs" for political
correctness reasons). Which FIB a particular packet uses to make
the next hop decision can be decided by a number of mechanisms.
The policies these mechanisms implement are the "Policies" referred
to in "Policy based routing".

One of the constraints I have if I try to back port this work to
6.x is that it must be implemented as a EXTENSION to the existing
ABIs in 6.x so that third party applications do not need to be
recompiled in timespan of the branch.

This first version will not have some of the bells and whistles that
will come with later versions. It will, for example, be limited to 16
tables in the first commit.
Implementation method, Compatible version. (part 1)
-------------------------------
For this reason I have implemented a "sufficient subset" of a
multiple routing table solution in Perforce, and back-ported it
to 6.x. (also in Perforce though not always caught up with what I
have done in -current/P4). The subset allows a number of FIBs
to be defined at compile time (8 is sufficient for my purposes in 6.x)
and implements the changes needed to allow IPV4 to use them. I have not
done the changes for ipv6 simply because I do not need it, and I do not
have enough knowledge of ipv6 (e.g. neighbor discovery) needed to do it.

Other protocol families are left untouched and should there be
users with proprietary protocol families, they should continue to work
and be oblivious to the existence of the extra FIBs.

To understand how this is done, one must know that the current FIB
code starts everything off with a single dimensional array of
pointers to FIB head structures (One per protocol family), each of
which in turn points to the trie of routes available to that family.

The basic change in the ABI compatible version of the change is to
extent that array to be a 2 dimensional array, so that
instead of protocol family X looking at rt_tables[X] for the
table it needs, it looks at rt_tables[Y][X] when for all
protocol families except ipv4 Y is always 0.
Code that is unaware of the change always just sees the first row
of the table, which of course looks just like the one dimensional
array that existed before.

The entry points rtrequest(), rtalloc(), rtalloc1(), rtalloc_ign()
are all maintained, but refer only to the first row of the array,
so that existing callers in proprietary protocols can continue to
do the "right thing".
Some new entry points are added, for the exclusive use of ipv4 code
called in_rtrequest(), in_rtalloc(), in_rtalloc1() and in_rtalloc_ign(),
which have an extra argument which refers the code to the correct row.

In addition, there are some new entry points (currently called
rtalloc_fib() and friends) that check the Address family being
looked up and call either rtalloc() (and friends) if the protocol
is not IPv4 forcing the action to row 0 or to the appropriate row
if it IS IPv4 (and that info is available). These are for calling
from code that is not specific to any particular protocol. The way
these are implemented would change in the non ABI preserving code
to be added later.

One feature of the first version of the code is that for ipv4,
the interface routes show up automatically on all the FIBs, so
that no matter what FIB you select you always have the basic
direct attached hosts available to you. (rtinit() does this
automatically).

You CAN delete an interface route from one FIB should you want
to but by default it's there. ARP information is also available
in each FIB. It's assumed that the same machine would have the
same MAC address, regardless of which FIB you are using to get
to it.

This brings us as to how the correct FIB is selected for an outgoing
IPV4 packet.

Firstly, all packets have a FIB associated with them. if nothing
has been done to change it, it will be FIB 0. The FIB is changed
in the following ways.

Packets fall into one of a number of classes.

1/ locally generated packets, coming from a socket/PCB.
Such packets select a FIB from a number associated with the
socket/PCB. This in turn is inherited from the process,
but can be changed by a socket option. The process in turn
inherits it on fork. I have written a utility call setfib
that acts a bit like nice..

setfib -3 ping target.example.com # will use fib 3 for ping.

It is an obvious extension to make it a property of a jail
but I have not done so. It can be achieved by combining the setfib and
jail commands.

2/ packets received on an interface for forwarding.
By default these packets would use table 0,
(or possibly a number settable in a sysctl(not yet)).
but prior to routing the firewall can inspect them (see below).
(possibly in the future you may be able to associate a FIB
with packets received on an interface.. An ifconfig arg, but not yet.)

3/ packets inspected by a packet classifier, which can arbitrarily
associate a fib with it on a packet by packet basis.
A fib assigned to a packet by a packet classifier
(such as ipfw) would over-ride a fib associated by
a more default source. (such as cases 1 or 2).

4/ a tcp listen socket associated with a fib will generate
accept sockets that are associated with that same fib.

5/ Packets generated in response to some other packet (e.g. reset
or icmp packets). These should use the FIB associated with the
packet being reponded to.

6/ Packets generated during encapsulation.
gif, tun and other tunnel interfaces will encapsulate using the FIB
that was in effect withthe proces that set up the tunnel.
thus setfib 1 ifconfig gif0 [tunnel instructions]
will set the fib for the tunnel to use to be fib 1.

Routing messages would be associated with their
process, and thus select one FIB or another.
messages from the kernel would be associated with the fib they
refer to and would only be received by a routing socket associated
with that fib. (not yet implemented)

In addition Netstat has been edited to be able to cope with the
fact that the array is now 2 dimensional. (It looks in system
memory using libkvm (!)). Old versions of netstat see only the first FIB.

In addition two sysctls are added to give:
a) the number of FIBs compiled in (active)
b) the default FIB of the calling process.

Early testing experience:
-------------------------

Basically our (IronPort's) appliance does this functionality already
using ipfw fwd but that method has some drawbacks.

For example,
It can't fully simulate a routing table because it can't influence the
socket's choice of local address when a connect() is done.

Testing during the generating of these changes has been
remarkably smooth so far. Multiple tables have co-existed
with no notable side effects, and packets have been routes
accordingly.

ipfw has grown 2 new keywords:

setfib N ip from anay to any
count ip from any to any fib N

In pf there seems to be a requirement to be able to give symbolic names to the
fibs but I do not have that capacity. I am not sure if it is required.

SCTP has interestingly enough built in support for this, called VRFs
in Cisco parlance. it will be interesting to see how that handles it
when it suddenly actually does something.

Where to next:
--------------------

After committing the ABI compatible version and MFCing it, I'd
like to proceed in a forward direction in -current. this will
result in some roto-tilling in the routing code.

Firstly: the current code's idea of having a separate tree per
protocol family, all of the same format, and pointed to by the
1 dimensional array is a bit silly. Especially when one considers that
there is code that makes assumptions about every protocol having the
same internal structures there. Some protocols don't WANT that
sort of structure. (for example the whole idea of a netmask is foreign
to appletalk). This needs to be made opaque to the external code.

My suggested first change is to add routing method pointers to the
'domain' structure, along with information pointing the data.
instead of having an array of pointers to uniform structures,
there would be an array pointing to the 'domain' structures
for each protocol address domain (protocol family),
and the methods this reached would be called. The methods would have
an argument that gives FIB number, but the protocol would be free
to ignore it.

When the ABI can be changed it raises the possibilty of the
addition of a fib entry into the "struct route". Currently,
the structure contains the sockaddr of the desination, and the resulting
fib entry. To make this work fully, one could add a fib number
so that given an address and a fib, one can find the third element, the
fib entry.

Interaction with the ARP layer/ LL layer would need to be
revisited as well. Qing Li has been working on this already.

This work was sponsored by Ironport Systems/Cisco

Reviewed by: several including rwatson, bz and mlair (parts each)
Obtained from: Ironport systems/Cisco


173931 26-Nov-2007 darrenr

Fix 3 issues relating to the use of "auth" rules in IPFilter, from sourceforge:
1837014 Kernel panics after authentication of an outgoing packet
1836992 Potential bugs in packet auth code (w/patches)
1836967 Kernel panic when using auth rule with keep state
and another reported only to FreeBSD by Andiry (see PR)

PR: kern/118251
Submitted by: Andriy Syrovenko <andriys@gmail.com>
Reviewed by: darrenr
MFC after: 5 days


173181 30-Oct-2007 darrenr

Apply a few changes from ipfilter-current:
* Do not hold any locks over calls to copyin/copyout.
* Clean up some #ifdefs
* fix a possible mbuf leak when NAT fails on policy routed packets

PR: 117216


172776 18-Oct-2007 darrenr

Pullup IPFilter 4.1.28 from the vendor branch into HEAD.

MFC after: 7 days


172772 18-Oct-2007 darrenr

This commit was generated by cvs2svn to compensate for changes in r172771,
which included commits to RCS files with non-trunk default branches.


170459 09-Jun-2007 darrenr

Pointer to an ICMP header was getting left behind after doing a pullup.


170268 04-Jun-2007 darrenr

Merge IPFilter 4.1.23 back to HEAD
See src/contrib/ipfilter/HISTORY for details of changes since 4.1.13


170264 04-Jun-2007 darrenr

This commit was generated by cvs2svn to compensate for changes in r170263,
which included commits to RCS files with non-trunk default branches.


165515 24-Dec-2006 darrenr

TCP Window scaling was being recognised but the recorded settings were being
clobbered and thus effectively disabled.

MFC after: 7 days


163027 05-Oct-2006 oleg

Workaround bad locking design:
do not try to lock/unlock destroyed/non-existsing mutex.

PR: kern/103569
Reviewed by: guido
Approved by: glebius (mentor)
Silence from: darrenr
MFC: 2 week


161356 16-Aug-2006 guido

Resolve conflicts

MFC after: 2 weeks


161352 16-Aug-2006 guido

This commit was generated by cvs2svn to compensate for changes in r161351,
which included commits to RCS files with non-trunk default branches.


157836 18-Apr-2006 darrenr

fix "ipf -Z" reporting rubbish and possibly panic'ing box

MFC after: 4 days


153882 30-Dec-2005 guido

Add mcopywrap prototype to ip_compat.h
Remove h323 proxy from ip_proxy (copyright issue)


153876 30-Dec-2005 guido

Resolve conflicts


153873 30-Dec-2005 guido

This commit was generated by cvs2svn to compensate for changes in r153872,
which included commits to RCS files with non-trunk default branches.


153084 04-Dec-2005 ru

Fix -Wundef from compiling the amd64 LINT.


151897 31-Oct-2005 rwatson

Normalize a significant number of kernel malloc type names:

- Prefer '_' to ' ', as it results in more easily parsed results in
memory monitoring tools such as vmstat.

- Remove punctuation that is incompatible with using memory type names
as file names, such as '/' characters.

- Disambiguate some collisions by adding subsystem prefixes to some
memory types.

- Generally prefer lower case to upper case.

- If the same type is defined in multiple architecture directories,
attempt to use the same name in additional cases.

Not all instances were caught in this change, so more work is required to
finish this conversion. Similar changes are required for UMA zone names.


147547 23-Jun-2005 darrenr

Fix some minor problems before release:
(1) "ipf -T" is broken for fetching single entries and
(2) loading rules with numbered collections does not order insertion right.
(3) stats aren't accumulated for hash table memory failures

Approved by: re (dwhite)


147367 14-Jun-2005 darrenr

locking on exit of reading from ip_sync is not correct for all instances

Approved by: re (dwhite)


146277 16-May-2005 darrenr

Enable building /sbin/ipf (but not the rescue version) with the ability to
parse bpf strings for filter rules in ipf.conf


146229 15-May-2005 darrenr

Enable IPFilter to correctly determine if BPF has been optioned into the
kernel it is being compiled against and subsequently enable using BPF for
packet matching in ipf rules.


145660 29-Apr-2005 ru

Fix the following warnings on amd64:

/usr/src/sbin/ipf/ipftest/../../../sys/contrib/ipfilter/netinet/ip_frag.c: In function `fr_ipid_newfrag':
/usr/src/sbin/ipf/ipftest/../../../sys/contrib/ipfilter/netinet/ip_frag.c:397: warning: cast to pointer from integer of different size
/usr/src/sbin/ipf/ipftest/../../../sys/contrib/ipfilter/netinet/ip_frag.c: In function `fr_ipid_knownfrag':
/usr/src/sbin/ipf/ipftest/../../../sys/contrib/ipfilter/netinet/ip_frag.c:582: warning: cast from pointer to integer of different size


145640 28-Apr-2005 darrenr

Don't use quad_t on FreeBSD (deprecated) so use "long long" instead.
Someday this should be converted to uint64_t and printstate.c changed to
use those horrid PRiud64 things.


145582 27-Apr-2005 darrenr

The current H.323 proxy source has a license that isn't suitable for inclusion
with FreeBSD so we shouldn't be trying to include it here.


145579 27-Apr-2005 darrenr

- Comment out duplicate rcsid strings in *.c files
- Move SIOCPROXY from ip_nat.h to ip_proxy.h and fix ip_proxy.h so that it
can be easily compiled into kdump, et al.


145562 26-Apr-2005 darrenr

Add an include for netinet/ip_compat.h directly so that we don't need to
add another special file in the creation of ioctls.c for kdump.


145522 25-Apr-2005 darrenr

Merge the changes from 3.4.35 to 4.1.8 into the kernel source tree


145517 25-Apr-2005 darrenr

This commit was generated by cvs2svn to compensate for changes in r145516,
which included commits to RCS files with non-trunk default branches.


142720 27-Feb-2005 phk

Use dynamic major number allocation.


139894 08-Jan-2005 darrenr

Elminate 1 LOR (actually a recursive mutex grab) involving ipfilter where
we loop through all the list of NICs (struct ifnet), holding the lock on
it and then do a name lookup with ifunit() whilst holding it.


139327 26-Dec-2004 darrenr

* Remove some code that's in a #ifndef FreeBSD that's no longer used.


139326 26-Dec-2004 darrenr

* The #ifdef's to cause mutex's for freebsd to be declared were meant to pick
up on USE_MUTEX being defined, but this patch
* Remove some code that's in a #ifndef FreeBSD that's no longer used.


139284 25-Dec-2004 scottl

Darnit, through a maze of twisty passages, ipfilter needs to have PFIL_HOOKS
defined. Revert part of the previous commit to fix this.


139282 25-Dec-2004 scottl

Sprinkle in some __FreeBSD_version checks so that this compiles again. Don't
define PFIL_HOOKS anymore.

Submitted by: keramida


139255 24-Dec-2004 darrenr

Enable fine grained locking within IPFilter, using mtx(9) and sx(9) allowing
the the "needs giant" flag to be removed from the driver.


139005 18-Dec-2004 mlaier

Make ip_nat compile again. Should read #if->n<-def LARGE_NAT as in ipf 4.x


138979 17-Dec-2004 darrenr

Move two variables that are unused if LARGE_NAT is defined inside an #ifdef
to keep them out of harms way when compiling.

PR: 72783


138947 17-Dec-2004 darrenr

Allow ipnat redirect rules to work for non-TCP/UDP packets.

PR: 70038
Submitted by: fming@borderware.com
Reviewed by: darrenr
Obtained from: fming@borderware.com


138928 16-Dec-2004 darrenr

Using just m_pullup to get all of the interesting bits in packet into one
buffer doesn't work for ipv6 packets, so use m_defrag() here instead as an
easy drop-in replacement.

PR: 70399


135920 29-Sep-2004 mlaier

Add an additional struct inpcb * argument to pfil(9) in order to enable
passing along socket information. This is required to work around a LOR with
the socket code which results in an easy reproducible hard lockup with
debug.mpsafenet=1. This commit does *not* fix the LOR, but enables us to do
so later. The missing piece is to turn the filter locking into a leaf lock
and will follow in a seperate (later) commit.

This will hopefully be MT5'ed in order to fix the problem for RELENG_5 in
forseeable future.

Suggested by: rwatson
A lot of work by: csjp (he'd be even more helpful w/o mentor-reviews ;)
Reviewed by: rwatson, csjp
Tested by: -pf, -ipfw, LINT, csjp and myself
MFC after: 3 days

LOR IDs: 14 - 17 (not fixed yet)


134402 27-Aug-2004 andre

From __FreeBSD_version 600001 on PFIL_HOOKS is permanently in the kernel and
doesn't require to include opt_pfil_hooks.h.


131974 11-Jul-2004 darrenr

Clean up a bunch of white-space difference with IPFilter source as well as
remove some superfluous assignments for .d_version/.d_flags in a cdevsw
structure initialisation that never sees the light of day in FreeBSD.


131262 29-Jun-2004 darrenr

Mess from update & merge - don't release the ifnet lock twice, just once
and after we're finished with it.


130911 22-Jun-2004 darrenr

revert section of code that calls netisr_queue() to match v1.33 of this file


130910 22-Jun-2004 darrenr

#ifdef's for FreeBSD are wrong, causing too many variable declaractions to
disappear.


130898 22-Jun-2004 darrenr

one too many #endif's from the update broke the build


130886 21-Jun-2004 darrenr

Update ipfilter from 3.4.31 -> 3.4.35. Some important changes:
* block packets that fail to create state table entries
* only allow non-fragmented packets to influence whether or not a logged
packet is the same as the one logged before.
* correct the ICMP packet checksum fixing up when processing ICMP errors for NAT
* implement a maximum for the number of entries in the NAT table (NAT_TABLE_MAX
and ipf_nattable_max)
* frsynclist() wasn't paying attention to all the places where interface
names are, like it should.
* fix comparing ICMP packets with established TCP state where only 8 bytes
of header are returned in the ICMP error.

MFC after: 1 week


130585 16-Jun-2004 phk

Do the dreaded s/dev_t/struct cdev */
Bump __FreeBSD_version accordingly.


130253 08-Jun-2004 darrenr

Recognise NOINET6 as an indication to not build IPv6 enabled source even
if FreeBSD header files, etc, support it.

Submitted by: Sergey Mokryshev <mokr@mokr.net>


128019 07-Apr-2004 imp

Remove advertising clause from University of California Regent's
license, per letter dated July 22, 1999 and email from Peter Wemm,
Alan Cox and Robert Watson.

Approved by: core, peter, alc, rwatson


126080 21-Feb-2004 phk

Device megapatch 4/6:

Introduce d_version field in struct cdevsw, this must always be
initialized to D_VERSION.

Flip sense of D_NOGIANT flag to D_NEEDGIANT, this involves removing
four D_NOGIANT flags and adding 145 D_NEEDGIANT flags.


123108 02-Dec-2003 brooks

Use parens more reasionably so we match the vendor code. This is part
of the if_xname change.

Submitted by: darrenr
Approved by: re (scottl)


121816 31-Oct-2003 brooks

Replace the if_name and if_unit members of struct ifnet with new members
if_xname, if_dname, and if_dunit. if_xname is the name of the interface
and if_dname/unit are the driver name and instance.

This change paves the way for interface renaming and enhanced pseudo
device creation and configuration symantics.

Approved By: re (in principle)
Reviewed By: njl, imp
Tested On: i386, amd64, sparc64
Obtained From: NetBSD (if_xname)


121170 17-Oct-2003 ume

use ND_IFINFO().


120399 24-Sep-2003 sam

o remove extraneous include of <net/pfil.h>
o guard wrapper code against user-mode compilation

Sponsored by: FreeBSD Foundation


120387 23-Sep-2003 sam

update to reflect PFIL_HOOKS api changes

Supported by: FreeBSD Foundation


113799 21-Apr-2003 obrien

Explicitly declare 'int' parameters.


111888 04-Mar-2003 jlemon

Update netisr handling; Each SWI now registers its queue, and all queue
drain routines are done by swi_net, which allows for better queue control
at some future point. Packets may also be directly dispatched to a netisr
instead of queued, this may be of interest at some installations, but
currently defaults to off.

Reviewed by: hsu, silby, jayanth, sam
Sponsored by: DARPA, NAI Labs


111815 03-Mar-2003 phk

Gigacommit to improve device-driver source compatibility between
branches:

Initialize struct cdevsw using C99 sparse initializtion and remove
all initializations to default values.

This patch is automatically generated and has been tested by compiling
LINT with all the fields in struct cdevsw in reverse order on alpha,
sparc64 and i386.

Approved by: re(scottl)


111119 19-Feb-2003 imp

Back out M_* changes, per decision of the TRB.

Approved by: trb


110921 15-Feb-2003 darrenr

fix bug in updating of interface pointers when resyncing state


110916 15-Feb-2003 darrenr

Commit import changed from vendor branch of ipfilter to -current head


110915 15-Feb-2003 darrenr

Commit import changed from vendor branch of ipfilter to -current head


110914 15-Feb-2003 darrenr

sometimes i hate it when you leave temp files in a directory you import from


110912 15-Feb-2003 darrenr

This commit was generated by cvs2svn to compensate for changes in r110911,
which included commits to RCS files with non-trunk default branches.


110232 02-Feb-2003 alfred

Consolidate MIN/MAX macros into one place (param.h).

Submitted by: Hiten Pandya <hiten@unixdaemons.com>


109623 21-Jan-2003 alfred

Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.
Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT.


108172 22-Dec-2002 hsu

SMP locking for ifnet list.


105194 16-Oct-2002 sam

Replace aux mbufs with packet tags:

o instead of a list of mbufs use a list of m_tag structures a la openbsd
o for netgraph et. al. extend the stock openbsd m_tag to include a 32-bit
ABI/module number cookie
o for openbsd compatibility define a well-known cookie MTAG_ABI_COMPAT and
use this in defining openbsd-compatible m_tag_find and m_tag_get routines
o rewrite KAME use of aux mbufs in terms of packet tags
o eliminate the most heavily used aux mbufs by adding an additional struct
inpcb parameter to ip_output and ip6_output to allow the IPsec code to
locate the security policy to apply to outbound packets
o bump __FreeBSD_version so code can be conditionalized
o fixup ipfilter's call to ip_output based on __FreeBSD_version

Reviewed by: julian, luigi (silent), -arch, -net, darren
Approved by: julian, silence from everyone else
Obtained from: openbsd (mostly)
MFC after: 1 month


102520 28-Aug-2002 darrenr

Finally merge in the changes from ipfilter 3.4.29 to freebsd-current.
Main changes here are related to the ftp proxy and making that work better.


102326 23-Aug-2002 archie

Don't use "NULL" when "0" is really meant.
But in this case, "-1" is really meant.

Reviewed by: darrenr


98004 07-Jun-2002 darrenr

Commit changes that happened in IPFilter versions 3.4.27 - 3.4.28


95563 27-Apr-2002 darrenr

Merge updates from 3.4.26 - 3.4.27.


95418 25-Apr-2002 darrenr

bring in changes from 3.4.26.


95416 25-Apr-2002 darrenr

This commit was generated by cvs2svn to compensate for changes in r95415,
which included commits to RCS files with non-trunk default branches.


93224 26-Mar-2002 ru

We don't need ip_ipsec_pxy.c in userland.


92703 19-Mar-2002 darrenr

do not include the missing ip_h323_pxy.c


92685 19-Mar-2002 darrenr

fix conflicts (mostly damn rcs id's) generated by import


92684 19-Mar-2002 darrenr

This file is being removed pending the all clear on its licence by someone
else.


92681 19-Mar-2002 darrenr

This commit was generated by cvs2svn to compensate for changes in r92680,
which included commits to RCS files with non-trunk default branches.


91478 28-Feb-2002 mike

Change two occurrences of HTONS() to use htons().


91441 27-Feb-2002 peter

Fix warning (unused variable)

Submitted by: LINT, -Werror


89336 14-Jan-2002 alfred

Backout inclusion of queue.h since rev 1.38 sys/file.h now has it
included in the right order.


89316 13-Jan-2002 alfred

Include sys/_lock.h and sys/_mutex.h to reduce namespace pollution.

Requested by: jhb


88876 04-Jan-2002 darrenr

Import this patch to address user concerns.

PR: 27615
Submitted by: Andria Thomas <andria@tovaris.com>
Approved by: Me.
MFC after: 7 days


87394 05-Dec-2001 guido

Fix initialisation of struct nat entry, to solve a panic that occurs
when reloading a nat table after reboot

Submitted by: Arjan de Vet <devet@devet.org>
Reviewed by: IP Filter mailing list
MFC after: 3 days


83380 12-Sep-2001 darrenr

IPFilter munges multicast address packets on the loopback interface.

Submitted by: Frank Zolf
Approved by: jkh
MFC after: 0


83377 12-Sep-2001 darrenr

Add IPFLITER.LICENCE to the kernel (requested by rwatson)


83366 12-Sep-2001 julian

KSE Milestone 2
Note ALL MODULES MUST BE RECOMPILED
make the kernel aware that there are smaller units of scheduling than the
process. (but only allow one thread per process at this time).
This is functionally equivalent to teh previousl -current except
that there is a thread associated with each process.

Sorry john! (your next MFC will be a doosie!)

Reviewed by: peter@freebsd.org, dillon@freebsd.org

X-MFC after: ha ha ha ha


80625 30-Jul-2001 darrenr

fix import/merge related code problems


80482 28-Jul-2001 darrenr

fix conflicts created by import


75262 06-Apr-2001 darrenr

fix security hole created by fragment cache


74810 26-Mar-2001 phk

Send the remains (such as I have located) of "block major numbers" to
the bit-bucket.


72010 04-Feb-2001 darrenr

fix duplicate rcsid


72006 04-Feb-2001 darrenr

fix conflicts


69152 25-Nov-2000 jlemon

Lock down the network interface queues. The queue mutex must be obtained
before adding/removing packets from the queue. Also, the if_obytes and
if_omcasts fields should only be manipulated under protection of the mutex.

IF_ENQUEUE, IF_PREPEND, and IF_DEQUEUE perform all necessary locking on
the queue. An IF_LOCK macro is provided, as well as the old (mutex-less)
versions of the macros in the form _IF_ENQUEUE, _IF_QFULL, for code which
needs them, but their use is discouraged.

Two new macros are introduced: IF_DRAIN() to drain a queue, and IF_HANDOFF,
which takes care of locking/enqueue, and also statistics updating/start
if necessary.


68619 11-Nov-2000 bmilekic

While I'm here, get rid of (now useless) MCLISREFERENCED and use MEXT_IS_REF
instead.
Also, fix a small set of "avail." If we're setting `avail,' we shouldn't
be re-checking whether m_flags is M_EXT, because we know that it is, as if
it wasn't, we would have already returned several lines above.

Reviewed by: jlemon


67853 29-Oct-2000 darrenr

Fix conflicts creted by import.


67711 27-Oct-2000 obrien

Include sys/param.h for `__FreeBSD_version' rather than the non-existent
osreldate.h.

Submitted by: dougb


67614 26-Oct-2000 darrenr

fix conflicts from rcsids


67564 25-Oct-2000 ru

We now keep the ip_id field in network byte order all the
time, so there is no need to make the distinction between
ip_output() and ip_input() cases.

Reviewed by: silence on freebsd-net


67287 18-Oct-2000 ru

If we do not byte-swap the ip_id in the first place, don't do it in
the second. NetBSD (from where I've taken this originally) needs
to fix this too.


65837 14-Sep-2000 ru

Follow BSD/OS and NetBSD, keep the ip_id field in network order all the time.

Requested by: wollman


64580 13-Aug-2000 darrenr

resolve conflicts


64105 01-Aug-2000 roberto

Change __FreeBSD_Version into the proper __FreeBSD_version.

Submitted by: Alain.Thivillon@hsc.fr (Alain Thivillon) (for ip_fil.c)


64078 01-Aug-2000 ache

Add missing '0' to FreeBSD_version test: 50011 -> 500011


64060 31-Jul-2000 darrenr

activate pfil_hooks and covert ipfilter to use it


63523 19-Jul-2000 darrenr

fix conflicts


60944 26-May-2000 darrenr

define CSUM_DELAY_DATA to match merge


60925 25-May-2000 darrenr

fix up #ifdef jungle for FreeBSD


60923 25-May-2000 darrenr

remove duplicate prototypes


60883 24-May-2000 darrenr

fix duplicate rcsid's


60865 24-May-2000 peter

It would have been nice if this actually compiled. Close the header
comment */.


60857 24-May-2000 darrenr

fix up conflicts


60855 24-May-2000 darrenr

fix conflicts


60854 24-May-2000 darrenr

fix conflicts


60853 24-May-2000 darrenr

fix conflicts


60852 24-May-2000 darrenr

fix conflicts


60851 24-May-2000 darrenr

fix conflicts


60850 24-May-2000 darrenr

fix conflicts


60765 21-May-2000 jlemon

Compute the checksum before handing the packet off to IPFilter.

Tested by: Cy Schubert <Cy.Schubert@uumail.gov.bc.ca>


60295 09-May-2000 darrenr

Fix bug in dealing with "hlen == 1 and opt > 1"


60265 09-May-2000 ps

Add missing include machine/in_cksum.h.

Submitted by: n_hibma


59874 01-May-2000 peter

Add $FreeBSD$


57126 10-Feb-2000 guido

Re add rev 1.11 diffs to ip_fil.h Also discover that I did not undefine
CVS_FUBAR (which no longer exists) and thus forgot to add $FreeBSD's.
Add them.

Approved by: jkh (is part of ipfilter upgrade)


57096 09-Feb-2000 guido

Bring over ipfilter v3_3_8 kernel sources, including merging the
local modifications.
Also fix initializing fr_running in KLD case.
Rename ipl_inited to fr_runninhg in mlfk_ipl

Approved by: jkh


55990 14-Jan-2000 guido

Apply patches in rev 1.2 and 1.9 that I forgot

Pointe out by: bde


55929 13-Jan-2000 guido

Bring over ipfilter kernel sources, including merging the local modifications.


55460 05-Jan-2000 eivind

KERNEL -> _KERNEL


54892 20-Dec-1999 peter

The ipfilter module name wasn't exactly conventional..


54228 06-Dec-1999 guido

Last minute patch that I forgot to apply: check return code of iplattach()


54221 06-Dec-1999 guido

Revive mlfk_ipl here. This version is slightly changed from
the old one: an unnecessary define (KLD_MODULE) has been deleted and
the initialisation of the module is done after domaininit was called
to be sure inet is running.

Some slight changed were made to ip_auth.c and ip_state.c in order
to assure including of sys/systm.h in case we make a kld

Make sure ip_fil does nmot include osreldate in kernel mode

Remove mlfk_ipl.c from here: no sources allowed in these directories!


53645 23-Nov-1999 guido

Get rid of useless osreldate include for KLD/LKM modules (sys/param.h
already carries what is needed).
This is needed for the KLD support.


53642 23-Nov-1999 guido

Add kernel parts of revived ipfilter (3.3.3.)