summaryrefslogtreecommitdiffstats
path: root/sbin/ipfw
Commit message (Collapse)AuthorAgeFilesLines
* move a variable declaration to the beginning of the blockluigi2009-03-051-1/+1
| | | | | (unfortunately, it is far away; we need to pack this code in a better way).
* remove some signed/unsigned and one const/!const warningluigi2009-03-051-5/+5
|
* mark a function static, as it isluigi2009-03-051-1/+1
|
* Add SCTP NAT support.piso2009-02-072-16/+218
|\ | | | | | | Submitted by: CAIA (http://caia.swin.edu.au)
| * Import sctp nat support in ipfw obtained from CAIA - http://caia.swin.edu.au.piso2008-12-281-1/+49
| |
* | Explain that we assume AF_INET and only use the addr and port fieldluigi2009-02-021-1/+4
| | | | | | | | from a struct sockaddr_in, so there is no need to initialize sin_len
* | remove duplicate #includeluigi2009-02-021-1/+0
| |
* | put the altq-related functions into a separate file.luigi2009-02-016-122/+167
| | | | | | | | | | Minor cleanup of the includes used by the various source files, including annotations of why certain headers are used.
* | Avoid the use of duplicated typedefs -- see the comment for details.luigi2009-01-281-15/+21
| |
* | fix printing of uint64_t values, so we can use WARNS=2luigi2009-01-274-11/+27
| |
* | fix wrong variable usage...luigi2009-01-271-2/+1
| |
* | Put nat and ipv6 support in their own files.luigi2009-01-275-1320/+1436
| | | | | | | | | | | | | | | | Usual moving of code with no changes from ipfw2.c to the newly created files, and addition of prototypes to ipfw2.h I have added forward declarations for ipfw_insn_* in ipfw2.h to avoid a global dependency on ip_fw.h
* | Put dummynet-related code in a separate file.luigi2009-01-273-785/+853
| | | | | | | | | | To this purpose, add prototypes for global functions in ipfw2.h and move there also the list of tokens used in various places in the code.
* | never mind, for the time being let's stick with WARNS=0 untilluigi2009-01-271-2/+2
| | | | | | | | we sort out all proper printf formats.
* | Start splitting the monster file in smaller blocks.luigi2009-01-274-589/+681
| | | | | | | | | | | | | | | | | | | | | | | | In this episode: - introduce a common header with a minimal set of common definitions; - bring the main() function and options parser in main.c - rename the main functions with an ipfw_ prefix No code changes except for the introduction of a global variable, resvd_set_number, which stores the RESVD_SET value from ip_fw.h and is used to remove the dependency of main.c from ip_fw.h (and the subtree of dependencies) for just a single constant.
* | put the usage() function inline, it was only 1 line and used once;luigi2009-01-271-19/+10
| | | | | | | | | | slightly reformat the help() text; slightly correct the text for the 'extraneous filename' error message;
* | put all options in a single struct, and document them.luigi2009-01-271-126/+146
| | | | | | | | | | This will allow us to easily restore the original values when processing commands from a file (where each individual line can have its own options).
* | I believe this is safe to build with WARNS=2 nowluigi2009-01-271-1/+1
| |
* | remove a couple of rarely used #define;luigi2009-01-271-13/+12
| | | | | | | | | | change PRINT_UINT from a macro to a function (renaming is postponed to reduce clutter)
* | wrap all malloc/calloc/realloc calls so they exit on failureluigi2009-01-261-23/+33
| | | | | | | | | | | | without having to check in each place. Remove an wrong strdup from previous commit.
* | Some implementations of getopt() expect that argv[0] is always theluigi2009-01-261-27/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | program name, and ignore that entry. ipfw2.c code instead skips this entry and starts with options at offset 0, relying on a more tolerant implementation of the library. This change fixes the issue by always passing a program name in the first entry to getopt. The motivation for this change is to remove a potential compatibility issue should we use a different getopt() implementation in the future. No functional changes. Submitted by: Marta Carbone (parts) MFC after: 4 weeks
* | remove some useless #include,luigi2009-01-221-8/+2
| | | | | | | | | | | | document why timeconv.h is needed MFC after: 3 days
* | Fix a number of (innocuous) warnings, and remove a useless test.luigi2009-01-201-18/+18
|/ | | | | | | | | | | | | There are still several signed/unsigned warnings left, which require a bit more study for a proper fix. This file has grown beyond reasonable limits. We really need to split it into separate components (ipv4, ipv6, dummynet, nat, table, userland-kernel communication ...) so we can make mainteinance easier. MFC after: 1 weeks
* Update the ipfw man page to reflect last change (-q option with nat option).piso2008-12-181-0/+2
| | | | MFC after: 3 days
* Honor the quiet (-q) option while adding a nat rule.piso2008-12-181-4/+6
| | | | | Submitted by: Andrey V. Elsukov<bu7cher@yandex.ru> MFC after: 3 days
* o Remove a debug code and restore an accidentally deleted codemaxim2008-10-141-1/+8
| | | | in a previous commit.
* o Do nothing in show_nat() for a test mode (-n). This preventsmaxim2008-10-141-8/+4
| | | | | | | | show_nat() from endless loop and makes work ipfw -n nat <...>. PR: bin/128064 Submitted by: sem MFC after: 1 month
* Fix the build.rik2008-09-271-1/+1
| | | | Noted by: ganbold@
* * add all keyword for table list & flush actions.rik2008-09-271-3/+14
| | | | | | | * add tables_max sysctl. * add default_rule sysctl. PR: 127058 (partially)
* Add keyword all in addtion to the table number for the 'list' and therik2008-09-271-8/+29
| | | | | | | 'flush' actions on tables. Part of PR: 127058. PR: 127058 (based on) MFC after: 1 month
* Unbreak the build.keramida2008-09-221-1/+1
|
* Add the check of the table number.rik2008-09-211-0/+17
|
* Move table list to a separate function.rik2008-09-211-35/+44
|
* Free allocated memory.rik2008-09-201-0/+1
|
* Remove some unused variables.rik2008-09-201-4/+3
|
* Style(9) the show_nat() function.rik2008-09-201-1/+2
|
* Do not do the useless job for an empty table.rik2008-09-201-0/+5
| | | | MFC after: 1 month
* Use IPFW_DEFAULT_RULE instead of hardcoded value since now it isrik2008-09-061-8/+9
| | | | | | available. MFC after: 5 days.
* Trivial typo fix.ivoras2008-08-271-1/+1
| | | | Approved by: gnn (mentor)
* Slight wordsmithing. prompted by danger@julian2008-08-011-2/+5
|
* Document the use of the tablearg keyword together with the skipto command.julian2008-08-011-3/+16
|
* Note that setfib is not a terminal rule.julian2008-07-241-1/+2
|
* Change two variables to size_t to improve portability.julian2008-05-101-1/+2
| | | | Submitted by: Xin Li
* Add code to allow the system to handle multiple routing tables.julian2008-05-092-2/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Dummynet has a limit of 100 slots queue size (or 1MB, if you givedwmalone2008-02-272-5/+32
| | | | | | | | | | | | | | | the limit in bytes) hard coded into both the kernel and userland. Make both these limits a sysctl, so it is easy to change the limit. If the userland part of ipfw finds that the sysctls don't exist, it will just fall back to the traditional limits. (100 packets is quite a small limit these days. If you want to test TCP at 100Mbps, 100 packets can only accommodate a DBP of 12ms.) Note these sysctls in the man page and warn against increasing them without thinking first. MFC after: 3 weeks
* Add table/tablearg support to ipfw's nat.piso2008-02-242-10/+6
| | | | MFC After: 1 week
* -Fix display of nat range.piso2008-02-211-6/+5
| | | | | | | -Whitespace elimination. Bug spotted by: Luiz Otavio O Souza MFC After: 3 days
* Fix display of multiple nat rules.piso2008-02-181-4/+4
| | | | | | Bug spotted by: Luiz Otavio O Souza PR: 120734 MFC After: 3 days
* Instead of using a heuristic to decide whether to displayjulian2008-02-182-6/+14
| | | | | | | | | | | table 'values' as IP addresses, use an explicit argument (-i). This is a 'POLA' issue. This is a low risk change and should be MFC'd to RELENG_6 and RELENG 7. it might be put as an errata item for 6.3. (not sure about 6.2). Fix suggested by: Eugene Grosbein PR: 120720 MFC After: 3 days
* Add a note that ipfw states do not implicitly match ICMP error messages.yar2008-02-071-0/+6
|
OpenPOWER on IntegriCloud