summaryrefslogtreecommitdiffstats
path: root/sbin/ipfw
Commit message (Collapse)AuthorAgeFilesLines
* 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
|
* Hide ipfw internal data structures behind IPFW_INTERNAL rather thanrwatson2008-01-251-0/+2
| | | | | | | | | | exposing them to all consumers of ip_fw.h. These structures are used in both ipfw(8) and ipfw(4), but not part of the user<->kernel interface for other applications to use, rather, shared implementation. MFC after: 3 days Reported by: Paul Vixie <paul at vix dot com>
* o Fix ipfw(8) command line parser bug: "ipfw nat 1 config if" ↵maxim2008-01-201-0/+2
| | | | | | | | requires an argument. PR: bin/119815 Submitted by: Dierk Sacher MFC after: 1 week
* Calculate p.fs.lookup_step correctly. This should prevent zeroing ofoleg2007-12-171-3/+3
| | | | | | w_q_lookup table (used in RED algorithm for (1 - w_q)^t computation). MFC after: 1 months
* Polish this manual page a bit:danger2007-11-261-73/+110
| | | | | | | | | | - refer to the dummynet(4) man page only once, later use rather the .Nm macro. - use .Va macro when refering to the sysctl variables - grammar and markup fixes Reviewed by: keramida, trhodes, ru (roughly) MFC-after: 1 week
* - New sysctl variable: net.inet.ip.dummynet.io_fastoleg2007-11-171-1/+19
| | | | | | | | | | | | | | If it is set to zero value (default) dummynet module will try to emulate real link as close as possible (bandwidth & latency): packet will not leave pipe faster than it should be on real link with given bandwidth. (This is original behaviour of dummynet which was altered in previous commit) If it is set to non-zero value only bandwidth is enforced: packet's latency can be lower comparing to real link with given bandwidth. - Document recently introduced dummynet(4) sysctl variables. Requested by: luigi, julian MFC after: 3 month
* o Fix indentation. No functional changes.maxim2007-10-271-10/+10
|
* Change IPTOS_CE to IPTOS_ECN_CE.rpaulo2007-10-191-2/+2
| | | | Approved by: njl (mentor)
* Comply with the removal of IPTOS_CE and IPTOS_ECT.rpaulo2007-10-191-2/+2
| | | | | | Discussed on freebsd-net with no objections. Approved by: njl (mentor), rwatson
* o Fix a typo in ipfw table usage example.maxim2007-10-141-1/+1
| | | | | | PR: docs/117172 Submitted by: novel MFC after: 1 week
* o Cosmetic: fix the issue when "ipfw(8) show" produces "not" twice:maxim2007-09-231-2/+2
| | | | | | | | | | $ ipfw -n add 1 allow layer2 not mac-type ip 00001 allow ip from any to any layer2 not not mac-type 0x0800 PR: bin/115372 Submitted by: Andrey V. Elsukov Approved by: re (hrs) MFC after: 3 weeks
* o Fix bug I introduced in the previous commit (ipfw set extention):maxim2007-08-261-3/+3
| | | | | | | | | | | | pack a set number correctly. Submitted by: oleg o Plug a memory leak. Submitted by: oleg and Andrey V. Elsukov Approved by: re (kensmith) MFC after: 1 week
* Rename option IPSEC_FILTERGIF to IPSEC_FILTERTUNNEL.bz2007-08-051-2/+2
| | | | | | | | | | | | | | | | | | | | | Also rename the related functions in a similar way. There are no functional changes. For a packet coming in with IPsec tunnel mode, the default is to only call into the firewall with the "outer" IP header and payload. With this option turned on, in addition to the "outer" parts, the "inner" IP header and payload are passed to the firewall too when going through ip_input() the second time. The option was never only related to a gif(4) tunnel within an IPsec tunnel and thus the name was very misleading. Discussed at: BSDCan 2007 Best new name suggested by: rwatson Reviewed by: rwatson Approved by: re (bmah)
* Remove references to mpsafenet. This option no longer exists.csjp2007-08-041-14/+1
| | | | Approved by: re@ (bmah)
* o Make ipfw set more robust -- now it is possible:maxim2007-06-182-41/+131
| | | | | | | | | | | | - to show a specific set: ipfw set 3 show - to delete rules from the set: ipfw set 9 delete 100 200 300 - to flush the set: ipfw set 4 flush - to reset rules counters in the set: ipfw set 1 zero PR: kern/113388 Submitted by: Andrey V. Elsukov Approved by: re (kensmith) MFC after: 6 weeks
* o Teach get_mac_addr_mask() to not silently accept incorrect MACmaxim2007-05-091-22/+38
| | | | | | | | | addresses. o Swap a couple of magic 6s by ETHER_ADDR_LEN. PR: bin/80913 Submitted by: Andrey V. Elsukov MFC after: 1 month
* Add support for filtering on Routing Header Type 0 andbz2007-05-042-3/+25
| | | | | | | Mobile IPv6 Routing Header Type 2 in addition to filter on the non-differentiated presence of any Routing Header. MFC after: 3 weeks
* o Make ipfw(8) show rules with mac/mac-type options correctly.maxim2007-04-301-36/+17
| | | | | | | | | | | | | | | | | | | | Before: $ ipfw -n add 100 count icmp from any to any mac-type 0x01 00100 count icmp 0x0001 $ ipfw -n add 100 count icmp from any to any mac any any 00100 count icmp MAC any any any After: $ ipfw -n add 100 count icmp from any to any mac-type 0x01 00100 count icmp from any to any mac-type 0x0001 $ ipfw -n add 100 count icmp from any to any mac any any 00100 count icmp from any to any MAC any any PR: bin/112244 Submitted by: Andrey V. Elsukov MFC after: 1 month
* o Add missed w/space in the error message.maxim2007-04-171-1/+1
| | | | | Spotted by: Ivan Voras MFC after: 1 week
* Mention the nat command in the synopsis and in the action section.piso2007-02-151-0/+13
| | | | Approved by: glebius (mentor)
* Fix a parsing bug when specifying more than one address with dotted decimalmlaier2007-01-071-2/+8
| | | | | | | | netmask. Reported by: Igor Anishchuk PR: kern/107565 MFC after: 3 days
* Summer of Code 2005: improve libalias - part 2 of 2piso2006-12-292-9/+1022
| | | | | | | | | | | | | | | | | | | | | | | | | | | | With the second (and last) part of my previous Summer of Code work, we get: -ipfw's in kernel nat -redirect_* and LSNAT support General information about nat syntax and some examples are available in the ipfw (8) man page. The redirect and LSNAT syntax are identical to natd, so please refer to natd (8) man page. To enable in kernel nat in rc.conf, two options were added: o firewall_nat_enable: equivalent to natd_enable o firewall_nat_interface: equivalent to natd_interface Remember to set net.inet.ip.fw.one_pass to 0, if you want the packet to continue being checked by the firewall ruleset after being (de)aliased. NOTA BENE: due to some problems with libalias architecture, in kernel nat won't work with TSO enabled nic, thus you have to disable TSO via ifconfig (ifconfig foo0 -tso). Approved by: glebius (mentor)
* Add a note about rule syntax compared to the shell used so users do not gettrhodes2006-10-091-0/+4
| | | | | | | | frustraited when: ipfw add 201 deny ip from any to table(2) in via xl1 returns "Badly placed ( )'s" PR: 73638
* When addr/mask examples are given, show both a host and networkkeramida2006-10-041-5/+6
| | | | | | | | address, to avoid confusing the users that a full address is always required. Submitted by: Josh Paetzel <josh@tcbug.org> (through freebsd-doc) MFC after: 3 days
* o Check for a required "pathname" argument presence.maxim2006-09-291-0/+2
| | | | | | PR: bin/95146 Submitted by: candy-sendpr@kgc.co.jp MFC after: 3 weeks
* Markup fixes.ru2006-09-181-2/+4
|
OpenPOWER on IntegriCloud