summaryrefslogtreecommitdiffstats
path: root/sys/contrib/ipfilter/netinet
Commit message (Collapse)AuthorAgeFilesLines
...
* | Retire the MALLOC and FREE macros. They are an abomination unto style(9).des2008-10-231-5/+16
| | | | | | | | MFC after: 3 months
* | Step 1.5 of importing the network stack virtualization infrastructurezec2008-10-021-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | from the vimage project, as per plan established at devsummit 08/08: http://wiki.freebsd.org/Image/Notes200808DevSummit Introduce INIT_VNET_*() initializer macros, VNET_FOREACH() iterator macros, and CURVNET_SET() context setting macros, all currently resolving to NOPs. Prepare for virtualization of selected SYSCTL objects by introducing a family of SYSCTL_V_*() macros, currently resolving to their global counterparts, i.e. SYSCTL_V_INT() == SYSCTL_INT(). Move selected #defines from sys/sys/vimage.h to newly introduced header files specific to virtualized subsystems (sys/net/vnet.h, sys/netinet/vinet.h etc.). All the changes are verified to have zero functional impact at this point in time by doing MD5 comparision between pre- and post-change object files(*). (*) netipsec/keysock.c did not validate depending on compile time options. Implemented by: julian, bz, brooks, zec Reviewed by: julian, bz, brooks, kris, rwatson, ... Approved by: julian (mentor) Obtained from: //depot/projects/vimage-commit2/... X-MFC after: never Sponsored by: NLnet Foundation, The FreeBSD Foundation
* | Replace all calls to minor() with dev2unit().ed2008-09-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After I removed all the unit2minor()/minor2unit() calls from the kernel yesterday, I realised calling minor() everywhere is quite confusing. Character devices now only have the ability to store a unit number, not a minor number. Remove the confusion by using dev2unit() everywhere. This commit could also be considered as a bug fix. A lot of drivers call minor(), while they should actually be calling dev2unit(). In -CURRENT this isn't a problem, but it turns out we never had any problem reports related to that issue in the past. I suspect not many people connect more than 256 pieces of the same hardware. Reviewed by: kib
* | Commit step 1 of the vimage project, (network stack)bz2008-08-172-4/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | virtualization work done by Marko Zec (zec@). This is the first in a series of commits over the course of the next few weeks. Mark all uses of global variables to be virtualized with a V_ prefix. Use macros to map them back to their global names for now, so this is a NOP change only. We hope to have caught at least 85-90% of what is needed so we do not invalidate a lot of outstanding patches again. Obtained from: //depot/projects/vimage-commit2/... Reviewed by: brooks, des, ed, mav, julian, jamie, kris, rwatson, zec, ... (various people I forgot, different versions) md5 (with a bit of help) Sponsored by: NLnet Foundation, The FreeBSD Foundation X-MFC after: never V_Commit_Message_Reviewed_By: more people than the patch
* | 2020447 IPFilter's NAT can undo name server random port selectiondarrenr2008-07-261-1/+3
| | | | | | | | | | | | | | (fix output port range, was a random number in [0,max-min] (byteswapped on litle endian), instead of [min,max]) Submitted by: darrenr
* | 2020447 IPFilter's NAT can undo name server random port selectiondarrenr2008-07-245-6/+51
| | | | | | | | | | | | Approved by: darrenr MFC after: 1 week Security: CERT VU#521769
* | Add code to allow the system to handle multiple routing tables.julian2008-05-091-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Fix 3 issues relating to the use of "auth" rules in IPFilter, from sourceforge:darrenr2007-11-263-18/+11
| | | | | | | | | | | | | | | | | | | | | | | | 1837014 Kernel panics after authentication of an outgoing packet 1836992 Potential bugs in packet auth code (w/patches) 1836967 Kernel panic when using auth rule with keep state and another reported only to FreeBSD by Andiry (see PR) PR: kern/118251 Submitted by: Andriy Syrovenko <andriys@gmail.com> Reviewed by: darrenr MFC after: 5 days
* | Apply a few changes from ipfilter-current:darrenr2007-10-307-44/+69
| | | | | | | | | | | | | | | | * Do not hold any locks over calls to copyin/copyout. * Clean up some #ifdefs * fix a possible mbuf leak when NAT fails on policy routed packets PR: 117216
* | Pullup IPFilter 4.1.28 from the vendor branch into HEAD.darrenr2007-10-1816-585/+863
| | | | | | | | MFC after: 7 days
* | This commit was generated by cvs2svn to compensate for changes in r172771,darrenr2007-10-186-64/+88
|\ \ | |/ | | | | which included commits to RCS files with non-trunk default branches.
| * Import IPFilter 4.1.28darrenr2007-10-1822-650/+953
| |
* | Pointer to an ICMP header was getting left behind after doing a pullup.darrenr2007-06-091-0/+1
| |
* | Merge IPFilter 4.1.23 back to HEADdarrenr2007-06-0422-1346/+3701
| | | | | | | | See src/contrib/ipfilter/HISTORY for details of changes since 4.1.13
* | This commit was generated by cvs2svn to compensate for changes in r170263,darrenr2007-06-0412-154/+555
|\ \ | |/ | | | | which included commits to RCS files with non-trunk default branches.
| * Import IPFilter 4.1.23 to vendor branch.darrenr2007-06-0434-1527/+4276
| | | | | | | | See src/contrib/ipfilter/HISTORY for details of changes since 4.1.13
* | TCP Window scaling was being recognised but the recorded settings were beingdarrenr2006-12-241-19/+7
| | | | | | | | | | | | clobbered and thus effectively disabled. MFC after: 7 days
* | Workaround bad locking design:oleg2006-10-051-3/+9
| | | | | | | | | | | | | | | | | | | | do not try to lock/unlock destroyed/non-existsing mutex. PR: kern/103569 Reviewed by: guido Approved by: glebius (mentor) Silence from: darrenr MFC: 2 week
* | Resolve conflictsguido2006-08-1616-361/+501
| | | | | | | | MFC after: 2 weeks
* | This commit was generated by cvs2svn to compensate for changes in r161351,guido2006-08-163-10/+23
|\ \ | |/ | | | | which included commits to RCS files with non-trunk default branches.
| * Import IP Filter 4.1.13guido2006-08-1621-402/+557
| |
* | fix "ipf -Z" reporting rubbish and possibly panic'ing boxdarrenr2006-04-181-1/+1
| | | | | | | | MFC after: 4 days
* | Add mcopywrap prototype to ip_compat.hguido2005-12-302-1/+1
| | | | | | | | Remove h323 proxy from ip_proxy (copyright issue)
* | Resolve conflictsguido2005-12-3021-509/+916
| |
* | This commit was generated by cvs2svn to compensate for changes in r153872,guido2005-12-3013-64/+41
|\ \ | |/ | | | | which included commits to RCS files with non-trunk default branches.
| * Import IP Filter version 4.1.10guido2005-12-3035-651/+1053
| |
* | Fix -Wundef from compiling the amd64 LINT.ru2005-12-045-21/+26
| |
* | Normalize a significant number of kernel malloc type names:rwatson2005-10-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Prefer '_' to ' ', as it results in more easily parsed results in memory monitoring tools such as vmstat. - Remove punctuation that is incompatible with using memory type names as file names, such as '/' characters. - Disambiguate some collisions by adding subsystem prefixes to some memory types. - Generally prefer lower case to upper case. - If the same type is defined in multiple architecture directories, attempt to use the same name in additional cases. Not all instances were caught in this change, so more work is required to finish this conversion. Similar changes are required for UMA zone names.
* | Fix some minor problems before release:darrenr2005-06-232-15/+54
| | | | | | | | | | | | | | | | (1) "ipf -T" is broken for fetching single entries and (2) loading rules with numbered collections does not order insertion right. (3) stats aren't accumulated for hash table memory failures Approved by: re (dwhite)
* | locking on exit of reading from ip_sync is not correct for all instancesdarrenr2005-06-141-4/+9
| | | | | | | | Approved by: re (dwhite)
* | Enable building /sbin/ipf (but not the rescue version) with the ability todarrenr2005-05-161-0/+4
| | | | | | | | parse bpf strings for filter rules in ipf.conf
* | Enable IPFilter to correctly determine if BPF has been optioned into thedarrenr2005-05-151-2/+2
| | | | | | | | | | kernel it is being compiled against and subsequently enable using BPF for packet matching in ipf rules.
* | Fix the following warnings on amd64:ru2005-04-291-2/+2
| | | | | | | | | | | | | | /usr/src/sbin/ipf/ipftest/../../../sys/contrib/ipfilter/netinet/ip_frag.c: In function `fr_ipid_newfrag': /usr/src/sbin/ipf/ipftest/../../../sys/contrib/ipfilter/netinet/ip_frag.c:397: warning: cast to pointer from integer of different size /usr/src/sbin/ipf/ipftest/../../../sys/contrib/ipfilter/netinet/ip_frag.c: In function `fr_ipid_knownfrag': /usr/src/sbin/ipf/ipftest/../../../sys/contrib/ipfilter/netinet/ip_frag.c:582: warning: cast from pointer to integer of different size
* | Don't use quad_t on FreeBSD (deprecated) so use "long long" instead.darrenr2005-04-281-3/+3
| | | | | | | | | | Someday this should be converted to uint64_t and printstate.c changed to use those horrid PRiud64 things.
* | The current H.323 proxy source has a license that isn't suitable for inclusiondarrenr2005-04-271-1/+3
| | | | | | | | with FreeBSD so we shouldn't be trying to include it here.
* | - Comment out duplicate rcsid strings in *.c filesdarrenr2005-04-276-11/+18
| | | | | | | | | | - Move SIOCPROXY from ip_nat.h to ip_proxy.h and fix ip_proxy.h so that it can be easily compiled into kdump, et al.
* | Add an include for netinet/ip_compat.h directly so that we don't need todarrenr2005-04-261-0/+2
| | | | | | | | add another special file in the creation of ioctls.c for kdump.
* | Merge the changes from 3.4.35 to 4.1.8 into the kernel source treedarrenr2005-04-2520-9332/+17345
| |
* | This commit was generated by cvs2svn to compensate for changes in r145516,darrenr2005-04-2518-111/+8348
|\ \ | |/ | | | | which included commits to RCS files with non-trunk default branches.
| * import ipfilter 4.1.8 into the kernel source treedarrenr2005-04-2538-7136/+25763
| |
| * Import ipfilter 3.4.35 (destinated for RELENG_4) to vendor branchdarrenr2004-06-2116-414/+736
| |
* | Use dynamic major number allocation.phk2005-02-271-2/+0
| |
* | Elminate 1 LOR (actually a recursive mutex grab) involving ipfilter wheredarrenr2005-01-081-25/+2
| | | | | | | | | | we loop through all the list of NICs (struct ifnet), holding the lock on it and then do a name lookup with ifunit() whilst holding it.
* | * Remove some code that's in a #ifndef FreeBSD that's no longer used.darrenr2004-12-261-5/+0
| |
* | * The #ifdef's to cause mutex's for freebsd to be declared were meant to pickdarrenr2004-12-262-19/+4
| | | | | | | | | | up on USE_MUTEX being defined, but this patch * Remove some code that's in a #ifndef FreeBSD that's no longer used.
* | Darnit, through a maze of twisty passages, ipfilter needs to have PFIL_HOOKSscottl2004-12-251-1/+1
| | | | | | | | defined. Revert part of the previous commit to fix this.
* | Sprinkle in some __FreeBSD_version checks so that this compiles again. Don'tscottl2004-12-253-3/+6
| | | | | | | | | | | | define PFIL_HOOKS anymore. Submitted by: keramida
* | Enable fine grained locking within IPFilter, using mtx(9) and sx(9) allowingdarrenr2004-12-249-27/+81
| | | | | | | | the the "needs giant" flag to be removed from the driver.
* | Make ip_nat compile again. Should read #if->n<-def LARGE_NAT as in ipf 4.xmlaier2004-12-181-1/+1
| |
* | Move two variables that are unused if LARGE_NAT is defined inside an #ifdefdarrenr2004-12-171-1/+4
| | | | | | | | | | | | to keep them out of harms way when compiling. PR: 72783
OpenPOWER on IntegriCloud