freebsd-dev/sys/conf
Andre Oppermann 9b932e9e04 Convert ipfw to use PFIL_HOOKS. This is change is transparent to userland
and preserves the ipfw ABI.  The ipfw core packet inspection and filtering
functions have not been changed, only how ipfw is invoked is different.

However there are many changes how ipfw is and its add-on's are handled:

 In general ipfw is now called through the PFIL_HOOKS and most associated
 magic, that was in ip_input() or ip_output() previously, is now done in
 ipfw_check_[in|out]() in the ipfw PFIL handler.

 IPDIVERT is entirely handled within the ipfw PFIL handlers.  A packet to
 be diverted is checked if it is fragmented, if yes, ip_reass() gets in for
 reassembly.  If not, or all fragments arrived and the packet is complete,
 divert_packet is called directly.  For 'tee' no reassembly attempt is made
 and a copy of the packet is sent to the divert socket unmodified.  The
 original packet continues its way through ip_input/output().

 ipfw 'forward' is done via m_tag's.  The ipfw PFIL handlers tag the packet
 with the new destination sockaddr_in.  A check if the new destination is a
 local IP address is made and the m_flags are set appropriately.  ip_input()
 and ip_output() have some more work to do here.  For ip_input() the m_flags
 are checked and a packet for us is directly sent to the 'ours' section for
 further processing.  Destination changes on the input path are only tagged
 and the 'srcrt' flag to ip_forward() is set to disable destination checks
 and ICMP replies at this stage.  The tag is going to be handled on output.
 ip_output() again checks for m_flags and the 'ours' tag.  If found, the
 packet will be dropped back to the IP netisr where it is going to be picked
 up by ip_input() again and the directly sent to the 'ours' section.  When
 only the destination changes, the route's 'dst' is overwritten with the
 new destination from the forward m_tag.  Then it jumps back at the route
 lookup again and skips the firewall check because it has been marked with
 M_SKIP_FIREWALL.  ipfw 'forward' has to be compiled into the kernel with
 'option IPFIREWALL_FORWARD' to enable it.

 DUMMYNET is entirely handled within the ipfw PFIL handlers.  A packet for
 a dummynet pipe or queue is directly sent to dummynet_io().  Dummynet will
 then inject it back into ip_input/ip_output() after it has served its time.
 Dummynet packets are tagged and will continue from the next rule when they
 hit the ipfw PFIL handlers again after re-injection.

 BRIDGING and IPFW_ETHER are not changed yet and use ipfw_chk() directly as
 they did before.  Later this will be changed to dedicated ETHER PFIL_HOOKS.

More detailed changes to the code:

 conf/files
	Add netinet/ip_fw_pfil.c.

 conf/options
	Add IPFIREWALL_FORWARD option.

 modules/ipfw/Makefile
	Add ip_fw_pfil.c.

 net/bridge.c
	Disable PFIL_HOOKS if ipfw for bridging is active.  Bridging ipfw
	is still directly invoked to handle layer2 headers and packets would
	get a double ipfw when run through PFIL_HOOKS as well.

 netinet/ip_divert.c
	Removed divert_clone() function.  It is no longer used.

 netinet/ip_dummynet.[ch]
	Neither the route 'ro' nor the destination 'dst' need to be stored
	while in dummynet transit.  Structure members and associated macros
	are removed.

 netinet/ip_fastfwd.c
	Removed all direct ipfw handling code and replace it with the new
	'ipfw forward' handling code.

 netinet/ip_fw.h
	Removed 'ro' and 'dst' from struct ip_fw_args.

 netinet/ip_fw2.c
	(Re)moved some global variables and the module handling.

 netinet/ip_fw_pfil.c
	New file containing the ipfw PFIL handlers and module initialization.

 netinet/ip_input.c
	Removed all direct ipfw handling code and replace it with the new
	'ipfw forward' handling code.  ip_forward() does not longer require
	the 'next_hop' struct sockaddr_in argument.  Disable early checks
	if 'srcrt' is set.

 netinet/ip_output.c
	Removed all direct ipfw handling code and replace it with the new
	'ipfw forward' handling code.

 netinet/ip_var.h
	Add ip_reass() as general function.  (Used from ipfw PFIL handlers
	for IPDIVERT.)

 netinet/raw_ip.c
	Directly check if ipfw and dummynet control pointers are active.

 netinet/tcp_input.c
	Rework the 'ipfw forward' to local code to work with the new way of
	forward tags.

 netinet/tcp_sack.c
	Remove include 'opt_ipfw.h' which is not needed here.

 sys/mbuf.h
	Remove m_claim_next() macro which was exclusively for ipfw 'forward'
	and is no longer needed.

Approved by:	re (scottl)
2004-08-17 22:05:54 +00:00
..
defines
files Convert ipfw to use PFIL_HOOKS. This is change is transparent to userland 2004-08-17 22:05:54 +00:00
files.alpha Break out the MI part of the /dev/[k]mem and /dev/io drivers into 2004-08-01 11:40:54 +00:00
files.amd64 Complete 'IA32' -> 'COMPAT_IA32' change for the Linuxulator32. 2004-08-16 12:51:33 +00:00
files.arm Remove libkern/mem* 2004-05-14 23:42:54 +00:00
files.i386 AMD64 on-CPU GART support. 2004-08-16 12:25:48 +00:00
files.ia64 Catch up with the drive-by renaming of IA32 to COMPAT_IA32. It must 2004-08-16 18:54:23 +00:00
files.pc98 Add MP_WATCHDOG option information to pc98, as it uses the i386 2004-08-16 13:59:01 +00:00
files.powerpc Add /dev/mem and /dev/kmem to powerpc. 2004-08-16 13:07:40 +00:00
files.sparc64 Add a kludge for building SBus-only kernels, i.e. kernels without support 2004-08-15 22:59:34 +00:00
kern.mk Define INLINE_LIMIT for arm. 2004-05-14 13:35:46 +00:00
kern.post.mk We don't need GEN_M_CFILES. Fold it into GEN_CFILES definition and 2004-06-27 23:03:43 +00:00
kern.pre.mk Removed COPTS support from kmod.mk and kern.pre.mk. 2004-08-13 14:30:26 +00:00
kmod_syms.awk Our awk does not implement the ARGIND variable, so we were attempting 2002-08-06 19:31:04 +00:00
kmod.mk Add sparc64/pci/ofw_pci_if.m to the list of MFILES so modules can use 2004-08-14 23:53:04 +00:00
ldscript.alpha Don't override the standard SYSTEM_LD setting from kern.pre.mk. 2004-02-13 12:28:53 +00:00
ldscript.amd64 Provide the _start_ctors and _stop_ctors symbols. As on i386, the addresses 2004-05-29 01:09:00 +00:00
ldscript.arm Add config magic for arm. 2004-05-14 11:49:40 +00:00
ldscript.i386 Align the .ctors section correctly. 2003-12-03 07:40:03 +00:00
ldscript.ia64 Fix the following error: 2004-06-20 22:32:19 +00:00
ldscript.powerpc
ldscript.sparc64 Use the same SEARCH_DIR as other platforms. 2003-06-07 18:23:50 +00:00
majors 1. Spell Cronyx Sigma-ISA and Cronyx Tau-ISA correctly. 2004-05-05 13:09:11 +00:00
majors.awk Add necessary awk magic to create a table of major numbers allocated 2003-02-27 08:52:11 +00:00
Makefile.alpha Change required config(8) version. 2004-05-09 22:29:38 +00:00
Makefile.amd64 Change required config(8) version. 2004-05-09 22:29:38 +00:00
Makefile.arm Add config magic for arm. 2004-05-14 11:49:40 +00:00
Makefile.i386 Change required config(8) version. 2004-05-09 22:29:38 +00:00
Makefile.ia64 Change required config(8) version. 2004-05-09 22:29:38 +00:00
Makefile.pc98 Change required config(8) version. 2004-05-09 22:29:38 +00:00
Makefile.powerpc Removed COPTS support from kmod.mk and kern.pre.mk. 2004-08-13 14:30:26 +00:00
Makefile.sparc64 Change required config(8) version. 2004-05-09 22:29:38 +00:00
makeLINT.mk Implemented "nooption" and "nomakeoption" config(8) tokens. 2003-02-26 23:36:59 +00:00
makeLINT.sed Implemented "nooption" and "nomakeoption" config(8) tokens. 2003-02-26 23:36:59 +00:00
newvers.sh When building a kernel or the loader, let the hostname be overridden 2004-07-01 06:40:12 +00:00
NOTES Connect RAID3 GEOM class to the build. 2004-08-16 06:36:21 +00:00
options Convert ipfw to use PFIL_HOOKS. This is change is transparent to userland 2004-08-17 22:05:54 +00:00
options.alpha Update for the KDB framework. Sanitize the alpha console code now that 2004-07-10 22:29:41 +00:00
options.amd64 I'm not sure what tjr envisioned for turning on FreeBSD/i386 rt support, 2004-08-16 11:09:59 +00:00
options.arm Add config magic for arm. 2004-05-14 11:49:40 +00:00
options.i386 AMD64 on-CPU GART support. 2004-08-16 12:25:48 +00:00
options.ia64 Catch up with the drive-by renaming of IA32 to COMPAT_IA32. It must 2004-08-16 18:54:23 +00:00
options.pc98 Add MP_WATCHDOG option information to pc98, as it uses the i386 2004-08-16 13:59:01 +00:00
options.powerpc Catch up with sparc64 OFWCONS_POLL_HZ change 2004-06-25 13:44:34 +00:00
options.sparc64 Better OFW console support on Sun Ultra2 machines. 2004-06-24 02:57:11 +00:00
systags.sh Remove advertising clause from University of California Regent's 2004-04-07 20:46:16 +00:00