1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-19 10:53:58 +00:00
freebsd/sys/netinet
Luigi Rizzo 9758b77ff1 The new ipfw code.
This code makes use of variable-size kernel representation of rules
(exactly the same concept of BPF instructions, as used in the BSDI's
firewall), which makes firewall operation a lot faster, and the
code more readable and easier to extend and debug.

The interface with the rest of the system is unchanged, as witnessed
by this commit. The only extra kernel files that I am touching
are if_fw.h and ip_dummynet.c, which is quite tied to ipfw. In
userland I only had to touch those programs which manipulate the
internal representation of firewall rules).

The code is almost entirely new (and I believe I have written the
vast majority of those sections which were taken from the former
ip_fw.c), so rather than modifying the old ip_fw.c I decided to
create a new file, sys/netinet/ip_fw2.c .  Same for the user
interface, which is in sbin/ipfw/ipfw2.c (it still compiles to
/sbin/ipfw).  The old files are still there, and will be removed
in due time.

I have not renamed the header file because it would have required
touching a one-line change to a number of kernel files.

In terms of user interface, the new "ipfw" is supposed to accepts
the old syntax for ipfw rules (and produce the same output with
"ipfw show". Only a couple of the old options (out of some 30 of
them) has not been implemented, but they will be soon.

On the other hand, the new code has some very powerful extensions.
First, you can put "or" connectives between match fields (and soon
also between options), and write things like

ipfw add allow ip from { 1.2.3.4/27 or 5.6.7.8/30 } 10-23,25,1024-3000 to any

This should make rulesets slightly more compact (and lines longer!),
by condensing 2 or more of the old rules into single ones.

Also, as an example of how easy the rules can be extended, I have
implemented an 'address set' match pattern, where you can specify
an IP address in a format like this:

        10.20.30.0/26{18,44,33,22,9}

which will match the set of hosts listed in braces belonging to the
subnet 10.20.30.0/26 . The match is done using a bitmap, so it is
essentially a constant time operation requiring a handful of CPU
instructions (and a very small amount of memmory -- for a full /24
subnet, the instruction only consumes 40 bytes).

Again, in this commit I have focused on functionality and tried
to minimize changes to the other parts of the system. Some performance
improvement can be achieved with minor changes to the interface of
ip_fw_chk_t. This will be done later when this code is settled.

The code is meant to compile unmodified on RELENG_4 (once the
PACKET_TAG_* changes have been merged), for this reason
you will see #ifdef __FreeBSD_version in a couple of places.
This should minimize errors when (hopefully soon) it will be time
to do the MFC.
2002-06-27 23:02:18 +00:00
..
libalias The new ipfw code. 2002-06-27 23:02:18 +00:00
accf_data.c Remove so*_locked(), which were backed out by mistake. 2002-06-18 07:42:02 +00:00
accf_http.c Remove so*_locked(), which were backed out by mistake. 2002-06-18 07:42:02 +00:00
icmp6.h
icmp_var.h
if_atm.c - Change the newly turned INVARIANTS #ifdef blocks (they were changed from 2002-05-21 18:52:24 +00:00
if_atm.h
if_ether.c Solve the 'unregistered netisr 18' information notice with a sledgehammer. 2002-06-20 01:27:40 +00:00
if_ether.h
igmp_var.h
igmp.c
igmp.h
in_cksum.c
in_gif.c
in_gif.h
in_pcb.c Notify functions can destroy the pcb, so they have to return an 2002-06-14 08:35:21 +00:00
in_pcb.h Notify functions can destroy the pcb, so they have to return an 2002-06-14 08:35:21 +00:00
in_proto.c
in_rmx.c
in_systm.h
in_var.h
in.c Lock up inpcb. 2002-06-10 20:05:46 +00:00
in.h
ip6.h
ip_divert.c fix a typo in a comment 2002-06-23 09:13:46 +00:00
ip_dummynet.c The new ipfw code. 2002-06-27 23:02:18 +00:00
ip_dummynet.h fix indentation of a comment 2002-06-23 09:14:24 +00:00
ip_ecn.c
ip_ecn.h
ip_encap.c
ip_encap.h
ip_flow.c
ip_flow.h
ip_fw2.c The new ipfw code. 2002-06-27 23:02:18 +00:00
ip_fw.c Remove (almost all) global variables that were used to hold 2002-06-22 11:51:02 +00:00
ip_fw.h The new ipfw code. 2002-06-27 23:02:18 +00:00
ip_icmp.c
ip_icmp.h
ip_id.c
ip_input.c Warning fixes for 64 bits platforms. With this last fix, 2002-06-27 11:02:06 +00:00
ip_mroute.c Just a comment on some additional consistency checks that could 2002-06-26 21:00:53 +00:00
ip_mroute.h
ip_output.c Warning fixes for 64 bits platforms. With this last fix, 2002-06-27 11:02:06 +00:00
ip_var.h Remove ip_fw_fwd_addr (forgotten in previous commit) 2002-06-23 09:03:42 +00:00
ip.h
ipprotosw.h
raw_ip.c Remember to initialize the control block head mutex. 2002-06-11 10:58:57 +00:00
tcp_debug.c
tcp_debug.h
tcp_fsm.h
tcp_input.c Avoid unlocking the inp twice if badport_bandlim() returns -1. 2002-06-24 22:25:00 +00:00
tcp_output.c Slightly restructure the #ifdef INET6 sections to make the code 2002-06-23 21:25:36 +00:00
tcp_reass.c Avoid unlocking the inp twice if badport_bandlim() returns -1. 2002-06-24 22:25:00 +00:00
tcp_seq.h
tcp_subr.c TCP notify functions can change the pcb list. 2002-06-21 22:52:48 +00:00
tcp_syncache.c Re-commit w/fix: 2002-06-14 03:08:05 +00:00
tcp_timer.c Lock up inpcb. 2002-06-10 20:05:46 +00:00
tcp_timer.h
tcp_timewait.c TCP notify functions can change the pcb list. 2002-06-21 22:52:48 +00:00
tcp_usrreq.c Because we're holding an exclusive write lock on the head, references to 2002-06-13 23:14:58 +00:00
tcp_var.h Notify functions can destroy the pcb, so they have to return an 2002-06-14 08:35:21 +00:00
tcp.h
tcpip.h
udp_usrreq.c Fix logic which resulted in missing a call to INP_UNLOCK(). 2002-06-21 22:54:16 +00:00
udp_var.h Notify functions can destroy the pcb, so they have to return an 2002-06-14 08:35:21 +00:00
udp.h