summaryrefslogtreecommitdiffstats
path: root/sys/netinet/ip_fw_pfil.c
Commit message (Collapse)AuthorAgeFilesLines
* Add IPv6 support to IPFW and Dummynet.brooks2005-04-181-2/+33
| | | | Submitted by: Mariano Tortoriello and Raffaele De Lorenzo (via luigi)
* When a packet has been reinjected into ipfw(4) after dummynet(4) processingglebius2005-04-061-2/+6
| | | | | | | | | | | | | | | | we have a non-NULL args.rule. If the same packet later is subject to "tee" rule, its original is sent again into ipfw_chk() and it reenters at the same rule. This leads to infinite loop and frozen router. Assign args.rule to NULL, any time we are going to send packet back to ipfw_chk() after a tee rule. This is a temporary workaround, which we will leave for RELENG_5. In HEAD we are going to make divert(4) save next rule the same way as dummynet(4) does. PR: kern/79546 Submitted by: Oleg Bulyzhin Reviewed by: maxim, andre MFC after: 3 days
* Add a ng_ipfw node, implementing a quick and simple interface betweenglebius2005-02-051-0/+47
| | | | | | ipfw(4) and netgraph(4) facilities. Reviewed by: andre, brooks, julian
* - Reduce number of arguments passed to dummynet_io(), we already have cookieglebius2005-01-161-2/+2
| | | | | in struct ip_fw_args itself. - Remove redundant &= 0xffff from dummynet_io().
* o Clean up interface between ip_fw_chk() and its callers:glebius2005-01-141-52/+74
| | | | | | | | | | | | | | | | - ip_fw_chk() returns action as function return value. Field retval is removed from args structure. Action is not flag any more. It is one of integer constants. - Any action-specific cookies are returned either in new "cookie" field in args structure (dummynet, future netgraph glue), or in mbuf tag attached to packet (divert, tee, some future action). o Convert parsing of return value from ip_fw_chk() in ipfw_check_{in,out}() to a switch structure, so that the functions are more readable, and a future actions can be added with less modifications. Approved by: andre MFC after: 2 months
* /* -> /*- for license, minor formatting changesimp2005-01-071-1/+1
|
* Revert last change.glebius2004-12-101-4/+4
| | | | | | | | | Andre: First lets get major new features into the kernel in a clean and nice way, and then start optimizing. In this case we don't have any obfusication that makes later profiling and/or optimizing difficult in any way. Requested by: csjp, sam
* Check that DUMMYNET_LOADED before seeking dummynet m_tag.glebius2004-12-091-4/+4
| | | | | Reviewed by: andre MFC after: 1 week
* Convert IPDIVERT into a loadable module. This makes use of the dynamic ↵andre2004-10-191-8/+13
| | | | | | | | | | | loadability of protocols. The call to divert_packet() is done through a function pointer. All semantics of IPDIVERT remain intact. If IPDIVERT is not loaded ipfw will refuse to install divert rules and natd will complain about 'protocol not supported'. Once it is loaded both will work and accept rules and open the divert socket. The module can only be unloaded if no divert sockets are open. It does not close any divert sockets when an unload is requested but will return EBUSY instead.
* Add an additional struct inpcb * argument to pfil(9) in order to enablemlaier2004-09-291-2/+6
| | | | | | | | | | | | | | | | | | | 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)
* If we have to 'ipfw fwd'-tag a packet the second time in ipfw_pfil_out() don'tandre2004-09-131-3/+5
| | | | | | | prepend an already existing tag again. Instead unlink it and prepend it again to have it as the first tag in the chain. PR: kern/71380
* Make 'ipfw tee' behave as inteded and designed. A tee'd packet is copiedandre2004-09-131-11/+11
| | | | | | | | | | and sent to the DIVERT socket while the original packet continues with the next rule. Unlike a normally diverted packet no IP reassembly attemts are made on tee'd packets and they are passed upwards totally unmodified. Note: This will not be MFC'd to 4.x because of major infrastucture changes. PR: kern/64240 (and many others collapsed into that one)
* Always compile PFIL_HOOKS into the kernel and remove the associated kernelandre2004-08-271-5/+1
| | | | | | | | | | | compile option. All FreeBSD packet filters now use the PFIL_HOOKS API and thus it becomes a standard part of the network stack. If no hooks are connected the entire packet filter hooks section and related activities are jumped over. This removes any performance impact if no hooks are active. Both OpenBSD and DragonFlyBSD have integrated PFIL_HOOKS permanently as well.
* Revert the last change to sys/modules/ipfw/Makefile and fix aru2004-08-261-1/+3
| | | | | | | standalone module build in a better way. Silence from: andre MFC after: 3 days
* Fix a stupid typo which prevented an ipfw KLD unload from successfully cleaningandre2004-08-201-1/+1
| | | | | | | up its remains. Do not terminate 'if' lines with ';'. Spotted by: claudio@OpenBSD.ORG (sitting 3m from my desk) Pointy hat to: andre
* Give a useful error message if someone tries to compile IPFIREWALL into theandre2004-08-191-0/+4
| | | | kernel without specifying PFIL_HOOKS as well.
* Do not unconditionally ignore IPDIVERT and IPFIREWALL_FORWARD when buildingandre2004-08-191-2/+0
| | | | | | | | | | | | the ipfw KLD. For IPFIREWALL_FORWARD this does not have any side effects. If the module has it but not the kernel it just doesn't do anything. For IPDIVERT the KLD will be unloadable if the kernel doesn't have IPDIVERT compiled in too. However this is the least disturbing behaviour. The user can just recompile either module or the kernel to match the other one. The access to the machine is not denied if ipfw refuses to load.
* Bring back the sysctl 'net.inet.ip.fw.enable' to unbreak the startup scriptsandre2004-08-191-0/+6
| | | | and to be able to disable ipfw if it was compiled directly into the kernel.
* Convert ipfw to use PFIL_HOOKS. This is change is transparent to userlandandre2004-08-171-0/+402
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)
OpenPOWER on IntegriCloud