1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-24 11:29:10 +00:00
freebsd/lib
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
..
compat Add these libs from the 4.6-RELEASE. 2002-06-27 18:53:50 +00:00
csu WARNS=6'ify. 2002-06-25 18:05:16 +00:00
libalias The new ipfw code. 2002-06-27 23:02:18 +00:00
libatm - Remove UM_* memory handling macros as they just obfuscate code. 2002-06-24 22:29:01 +00:00
libbind Removed now unused INTERNALSTATICLIB. 2002-05-13 11:09:07 +00:00
libbz2 I somehow managed to forgot to commit this in my INCS sweep. 2002-05-14 11:41:23 +00:00
libc Fix style bugs I added in last commit. 2002-06-27 14:16:21 +00:00
libc_r Fix a bug which prevented the duplication of the standard i/o 2002-06-23 20:41:30 +00:00
libcalendar
libcam string cleanup: 2002-05-14 04:32:02 +00:00
libcom_err
libcompat Assume __STDC__, remove non-__STDC__ code. 2002-05-28 17:03:12 +00:00
libcrypt
libdevinfo MAN[1-9] -> MAN. 2002-05-13 12:11:54 +00:00
libdevstat
libdisk Use correct printf format specifier to print unsigned longs. 2002-05-30 21:00:42 +00:00
libedit Restore local bits lost in recent merge from NetBSD. 2002-06-16 08:29:35 +00:00
libfetch Reintroduce debugging code that somehow got lost in a previous revision. 2002-06-24 12:18:41 +00:00
libform Make this a little easier to build standalone. (same change as libpanel) 2002-05-21 07:08:30 +00:00
libftpio
libio
libipsec
libipx
libisc
libkse Missed in earlier commit -- I did cvs commit src/lib/libc. Oops. 2002-06-14 04:02:25 +00:00
libkvm Assume __STDC__, remove non-__STDC__ code. 2002-05-28 17:03:12 +00:00
libmd Add missing const's. 2002-06-24 13:52:26 +00:00
libmenu Make this a little easier to build standalone. (same change as libpanel) 2002-05-21 07:08:30 +00:00
libmilter
libmp MAN[1-9] -> MAN. 2002-05-13 12:11:54 +00:00
libncp Add missing newline at end of file. 2002-05-30 20:51:53 +00:00
libncurses Add NCURSES_OSPEED replace command to MANFILTER 2002-06-02 16:11:57 +00:00
libnetgraph
libopie
libpam Tidy up. 2002-06-06 13:55:01 +00:00
libpanel Initial update of bmake glue for ncurses-5.2-20020518 2002-05-21 05:41:07 +00:00
libpcap Update for libpcap 0.7.1 2002-06-21 01:35:37 +00:00
libpthread Missed in earlier commit -- I did cvs commit src/lib/libc. Oops. 2002-06-14 04:02:25 +00:00
libradius Add the following functions: 2002-06-12 00:21:07 +00:00
librpcsvc New cpp(1) doesn't like -I${DESTDIR}/usr/include. 2002-05-14 11:37:10 +00:00
libsbuf
libsm Removed now unused INTERNALSTATICLIB. 2002-05-13 11:09:07 +00:00
libsmb
libsmdb Removed now unused INTERNALSTATICLIB. 2002-05-13 11:09:07 +00:00
libsmutil Removed now unused INTERNALSTATICLIB. 2002-05-13 11:09:07 +00:00
libstand This commit adds basic support for the UFS2 filesystem. The UFS2 2002-06-21 06:18:05 +00:00
libtacplus
libtelnet Removed now unused INTERNALSTATICLIB. 2002-05-13 11:09:07 +00:00
libusbhid mdoc(7) police: Tidy up the markup. 2002-05-30 12:16:01 +00:00
libutil Backout previous delta (addition of -I${.CURDIR}/../../sys). 2002-06-26 13:25:23 +00:00
libvgl Fix typo in the BSD copyright: s/withough/without/ 2002-06-02 20:05:59 +00:00
libwrap
libxpg4
liby
libypclnt
libz
msun e_pow.c: 2002-06-17 15:28:59 +00:00
ncurses Add NCURSES_OSPEED replace command to MANFILTER 2002-06-02 16:11:57 +00:00
Makefile Don't try to build libc_r on sparc64, the _atomic_lock.S file isn't implemented. 2002-05-18 09:14:36 +00:00
Makefile.inc