aboutsummaryrefslogtreecommitdiff
path: root/sys/netinet6
Commit message (Collapse)AuthorAgeFilesLines
* Change the initialization methodology for global variables scheduledMarko Zec2008-11-1916-112/+256
| | | | | | | | | | | | | | | | | | | | | | | | | | | for virtualization. Instead of initializing the affected global variables at instatiation, assign initial values to them in initializer functions. As a rule, initialization at instatiation for such variables should never be introduced again from now on. Furthermore, enclose all instantiations of such global variables in #ifdef VIMAGE_GLOBALS blocks. Essentialy, this change should have zero functional impact. In the next phase of merging network stack virtualization infrastructure from p4/vimage branch, the new initialization methology will allow us to switch between using global variables and their counterparts residing in virtualization containers with minimum code churn, and in the long run allow us to intialize multiple instances of such container structures. Discussed at: devsummit Strassburg Reviewed by: bz, julian Approved by: julian (mentor) Obtained from: //depot/projects/vimage-commit2/... X-MFC after: never Sponsored by: NLnet Foundation, The FreeBSD Foundation Notes: svn path=/head/; revision=185088
* Add a MAC label, MAC Framework, and MAC policy entry points for IPv6Robert Watson2008-10-262-2/+31
| | | | | | | | | | | | | | fragment reassembly queues. This allows policies to label reassembly queues, perform access control checks when matching fragments to a queue, update a queue label when fragments are matched, and label the resulting reassembled datagram. Obtained from: TrustedBSD Project Notes: svn path=/head/; revision=184307
* Fix a number of style issues in the MALLOC / FREE commit. I've tried toDag-Erling Smørgrav2008-10-231-1/+1
| | | | | | | | be careful not to fix anything that was already broken; the NFSv4 code is particularly bad in this respect. Notes: svn path=/head/; revision=184214
* Retire the MALLOC and FREE macros. They are an abomination unto style(9).Dag-Erling Smørgrav2008-10-234-10/+9
| | | | | | | MFC after: 3 months Notes: svn path=/head/; revision=184205
* Bring over the change switching from using sequential to randomBjoern A. Zeeb2008-10-201-47/+52
| | | | | | | | | | | | | | ephemeral port allocation as implemented in netinet/in_pcb.c rev. 1.143 (initially from OpenBSD) and follow-up commits during the last four and a half years including rev. 1.157, 1.162 and 1.199. This now is relying on the same infrastructure as has been implemented in in_pcb.c since rev. 1.199. Reviewed by: silby, rpaulo, mlaier MFC after: 2 months Notes: svn path=/head/; revision=184096
* Check that the mbuf len is positive (like we do in the v4 case).Bjoern A. Zeeb2008-10-151-1/+1
| | | | | | | | | | | | | | | | | Read the other way round this means that even with the checks the m_len turned negative in some cases which led to panics. The reason to my understanding seems to be that the checks are wrong (also for v4) ignoring possible padding when checking cmsg_len or padding after data when adjusting the mbuf. Doing proper cheks seems to break applications like named so further investigation and regression tests are needed. PR: kern/119123 Tested by: Ashish Shukla wahjava gmail.com MFC after: 3 days Notes: svn path=/head/; revision=183923
* When disconnecting a UDPv6 socket, acquire the socket lock around theRobert Watson2008-10-121-1/+2
| | | | | | | | | | changing of the so_state field, as is done in UDPv4. Remove XXX locking comment. MFC after: 3 days Notes: svn path=/head/; revision=183807
* Style changes: compare pointer to NULL and move a }.Bjoern A. Zeeb2008-10-041-3/+2
| | | | | | | MFC after: 6 weeks Notes: svn path=/head/; revision=183611
* Cache so_cred as inp_cred in the inpcb.Bjoern A. Zeeb2008-10-042-7/+7
| | | | | | | | | | | | | | | This means that inp_cred is always there, even after the socket has gone away. It also means that it is constant for the lifetime of the inp. Both facts lead to simpler code and possibly less locking. Suggested by: rwatson Reviewed by: rwatson MFC after: 6 weeks X-MFC Note: use a inp_pspare for inp_cred Notes: svn path=/head/; revision=183606
* Step 1.5 of importing the network stack virtualization infrastructureMarko Zec2008-10-0224-106/+591
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=183550
* Default to ignoring potentially evil IPv6 Neighbor SolicitationColin Percival2008-10-024-1/+26
| | | | | | | | | | | | messages. Approved by: so (cperciva) Approved by: re (kensmith) Security: FreeBSD-SA-08:10.nd6 Thanks to: jinmei, bz Notes: svn path=/head/; revision=183529
* When invoking the udp_send() from udp6_send() due to use of a v6-mappedRobert Watson2008-09-221-3/+13
| | | | | | | | | | | | IPv4 address, first drop the udbinfo and inpcb locks, which will otherwise be recursed. This leads to a potential minor race, but is preferable to a deadlock when acquiring a read lock after a write lock on the inpcb. MFC after: 3 days Reported by: Norbert Papke <fbsd-ml@scrapper.ca>, lioux Notes: svn path=/head/; revision=183265
* mld_timerresid() returns ms so instead of doing the maths in usecBjoern A. Zeeb2008-09-101-1/+1
| | | | | | | | | | and then dividing down to ms, do the maths in ms. Obtained from: NetBSD mld6.c rev. 1.47 MFC after: 2 months Notes: svn path=/head/; revision=182915
* - Fix amd64 local privilege escalation. [08:07]Simon L. B. Nielsen2008-09-031-0/+9
| | | | | | | | | | | | | | | | | | | - Fix nmount(2) local privilege escalation. [08:08] - Fix IPv6 remote kernel panics. [08:09] Fix for [08:07] is merge of r181823. Submitted by: kib [08:07], csjp [08:08], bz [08:09] Reviewed by: peter [08:07], jhb [08:07] Reviewed by: jinmei [08:09], rwatson [08:09] Approved by: re (SA blanket) Approved by: so (simon) Security: FreeBSD-SA-08:07.amd64 Security: FreeBSD-SA-08:08.nmount Security: FreeBSD-SA-08:09.icmp6 Notes: svn path=/head/; revision=182740
* Fix a bug, when a specially crafted ICMPV6 MLD packet could leadBjoern A. Zeeb2008-09-031-4/+4
| | | | | | | | | | | | | | | | to an integer divide by zero panic in the kernel, if the kernel was run with hz<1000. Neither i386, pc98, amd64 or sparc64 are affected in the currently supported branches and default configuration. Submitted by: Miikka Saukko, Ossi Herrala and Jukka Taimisto from the CROSS project at Codenomicon Ltd. via CERT-FI. Reviewed by: bz, rwatson Security: CVE-2008-2464 MFC after: 8 hours Notes: svn path=/head/; revision=182713
* In UDPv6, reduce scope of global udbinfo lock during append to lastRobert Watson2008-08-311-3/+1
| | | | | | | | | | matching socket by dropping it before udp6_append(), and remove duplicate unlocks of udbinfo and inpcb in sysctl return path. MFC after: 3 days Notes: svn path=/head/; revision=182537
* another missed V_Julian Elischer2008-08-251-1/+1
| | | | Notes: svn path=/head/; revision=182150
* Fix some of the formatting fixes.. It's amazing how some thing stand outJulian Elischer2008-08-204-4/+4
| | | | | | | in a commit message. Notes: svn path=/head/; revision=181888
* A bunch of formatting fixes brough to light by, or created by the Vimage commitJulian Elischer2008-08-206-10/+12
| | | | | | | a few days ago. Notes: svn path=/head/; revision=181887
* As part of step 1.5 of the vimage framework resolve conflicts withBjoern A. Zeeb2008-08-181-19/+19
| | | | | | | | | | file local static globals which would be folded onto the same name with the V_ macros. Reviewed by: kris, brooks, simon Notes: svn path=/head/; revision=181832
* Commit step 1 of the vimage project, (network stack)Bjoern A. Zeeb2008-08-1724-631/+654
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=181803
* Fix a regression introduced in r179289 splitting up ip6_savecontrol()Bjoern A. Zeeb2008-08-162-7/+16
| | | | | | | | | | | | | | | into v4-only vs. v6-only inp_flags processing. When ip6_savecontrol_v4() is called from ip6_savecontrol() we were not passing back the **mp thus the information will be missing in userland. Istead of going with a *** as suggested in the PR we are returning **mp now and passing in the v4only flag as a pointer argument. PR: kern/126349 Reviewed by: rwatson, dwmalone Notes: svn path=/head/; revision=181782
* Adopt the slightly weaker consistency locking approach used in IPv4 rawRobert Watson2008-07-301-7/+3
| | | | | | | | | | | | | | sockets for IPv6 raw sockets: separately lock the inpcb for determining the destination address for a connect()'d raw socket at the rip6_send() layer, and then re-acquire the inpcb lock in the rip6_output() layer to query other options on the socket. Previously, the global raw IP socket lock was used, which while correct and marginally more consistent, could add significantly to global raw IP socket lock contention. MFC after: 1 week Notes: svn path=/head/; revision=180990
* When copying in and out current ICMPv6 filters on a raw IPv6 socket,Robert Watson2008-07-291-6/+14
| | | | | | | | | | | | | | | lock the inpcb and use a local stack variable to copy to/from userspace so that sooptcopyin()/sooptcopyout() aren't called while holding an rwlock. While here, fix a bug in which a failed sooptcopyin() might lead to partially consistent ICMPv6 filters on the socket by not ignoring the error returned by sooptcopyin(). MFC after: 2 weeks Notes: svn path=/head/; revision=180968
* Since we fail IPv6 raw socket allocation if inp->in6p_icmp6filt can'tRobert Watson2008-07-292-15/+3
| | | | | | | | | | be allocated, there's no need to conditionize use and freeing of it later. MFC after: 1 week Notes: svn path=/head/; revision=180965
* Marginally decomplicate set/getsockopt code in ip6_output.c by simplyRobert Watson2008-07-291-18/+11
| | | | | | | | | | | using the passed arguments explicitly and unconditionally rather than testing them and calling panic(). The result is the same but easier to read. MFC after: 3 days Notes: svn path=/head/; revision=180957
* Move inpcb lock higher to protect some nonbinding fields reading.Alexander Motin2008-07-282-3/+6
| | | | | | | It fixes nothing at this time, but decided to be more correct. Notes: svn path=/head/; revision=180932
* According to in_pcb.h protocol binding information has double locking.Alexander Motin2008-07-272-20/+14
| | | | | | | It allows access it while list travercing holding only global pcbinfo lock. Notes: svn path=/head/; revision=180850
* Pass the ucred along into in{,6}_pcblookup_local for upcomingBjoern A. Zeeb2008-07-103-10/+11
| | | | | | | | | prison checks. Reviewed by: rwatson Notes: svn path=/head/; revision=180427
* For consistency take lport as u_short in in{,6}_pcblookup_local.Bjoern A. Zeeb2008-07-102-3/+2
| | | | | | | | | All callers either pass in an u_short or u_int16_t. Reviewed by: rwatson Notes: svn path=/head/; revision=180425
* 1) Adds the rest of the VIMAGE change macrosRandall Stewart2008-07-092-4/+5
| | | | | | | | | | | | | | | 2) Adds some __UserSpace__ on some of the common defines that the user space code needs 3) Fixes a bug when we send up data to a user that failed. We need to a) trim off the data chunk headers, if present, and b) make sure the frag bit is communicated properly for the msgs coming off the stream queues... i.e. we see if some of the msg has been taken. Obtained from: jeli contributed the VIMAGE changes on this pass Thanks Julain! Notes: svn path=/head/; revision=180387
* Document required locking in in6_sleectsrc() in case an inp isBjoern A. Zeeb2008-07-091-2/+4
| | | | | | | | | | passed in by adding an assert. Requested by: rwatson Reviewed by: rwatson Notes: svn path=/head/; revision=180386
* Change the parameters to in6_selectsrc():Bjoern A. Zeeb2008-07-085-15/+23
| | | | | | | | | | - pass in the inp instead of both in6p_moptions and laddr. - pass in cred for upcoming prison checks. Reviewed by: rwatson Notes: svn path=/head/; revision=180371
* Use soreceive_dgram() and sosend_dgram() with UDPv6, as we do with UDPv4.Robert Watson2008-07-081-0/+2
| | | | | | | | Tested by: ps MFC after: 3 months Notes: svn path=/head/; revision=180365
* Drop read lock on udbinfo earlier during delivery to the last matchingRobert Watson2008-07-071-1/+1
| | | | | | | | | | UDP socket for a datagram; the inpcb read lock is sufficient to provide inpcb stability during udp6_append(). MFC after: 1 month Notes: svn path=/head/; revision=180343
* Improve approximation of style(9) in raw socket code.Robert Watson2008-07-051-57/+75
| | | | Notes: svn path=/head/; revision=180305
* Introduce a new lock, hostname_mtx, and use it to synchronize accessRobert Watson2008-07-053-2/+14
| | | | | | | | | | | | | | | to global hostname and domainname variables. Where necessary, copy to or from a stack-local buffer before performing copyin() or copyout(). A few uses, such as in cd9660 and daemon_saver, remain under-synchronized and will require further updates. Correct a bug in which a failed copyin() of domainname would leave domainname potentially corrupted. MFC after: 3 weeks Notes: svn path=/head/; revision=180291
* Remove NETISR_MPSAFE, which allows specific netisr handlers to be directlyRobert Watson2008-07-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | dispatched without Giant, and add NETISR_FORCEQUEUE, which allows specific netisr handlers to always be dispatched via a queue (deferred). Mark the usb and if_ppp netisr handlers as NETISR_FORCEQUEUE, and explicitly acquire Giant in those handlers. Previously, any netisr handler not marked NETISR_MPSAFE would necessarily run deferred and with Giant acquired. This change removes Giant scaffolding from the netisr infrastructure, but NETISR_FORCEQUEUE allows non-MPSAFE handlers to continue to force deferred dispatch so as to avoid lock order reversals between their acqusition of Giant and any calling context. It is likely we will be able to remove NETISR_FORCEQUEUE once IFF_NEEDSGIANT is removed, as non-MPSAFE usb and if_ppp drivers will no longer be supported. Reviewed by: bz MFC after: 1 month X-MFC note: We can't remove NETISR_MPSAFE from stable/7 for KPI reasons, but the rest can go back. Notes: svn path=/head/; revision=180239
* Remove GIANT_REQUIRED from IPv6 input, forward, and frag6 code. The frag6Robert Watson2008-07-033-7/+1
| | | | | | | | | code is believed to be MPSAFE, and leaving aside the IPv6 route cache in forwarding, Giant appears not to adequately synchronize the data structures in the input or forwarding paths. Notes: svn path=/head/; revision=180214
* Set the IPv6 netisr handler as NETISR_MPSAFE on the basis that, despiteRobert Watson2008-07-021-1/+1
| | | | | | | | | there still being some well-known races in mld6 and nd6, running with Giant over the netisr handler provides little or not additional synchronization that might cause mld6 and nd6 to behave better. Notes: svn path=/head/; revision=180197
* Try to fix errors introduced in svn180085/cvs rev. 1.10:Bjoern A. Zeeb2008-06-291-1/+2
| | | | | | | | | | | * Include ip6_var.h for ip6stat. * Use the correct name under ip6stat: `ip6s_cantforward' instead of its IPv4 counterpart. MFC after: 10 days Notes: svn path=/head/; revision=180090
* Repair botched variable rename.Alexander Kabaev2008-06-291-4/+4
| | | | | | | Pointy hat to: julian Notes: svn path=/head/; revision=180088
* Oops, we've been incrementing the wrong cantforward variable.Julian Elischer2008-06-291-1/+2
| | | | | | | Obtained from: vimage tree Notes: svn path=/head/; revision=180085
* Rename two vars so that they are different from the same vars in ipv4.Julian Elischer2008-06-291-7/+7
| | | | | | | | | | They are static so it was not a problem 'per se' but it was confusing to the reader. Obtained from: vimage tree Notes: svn path=/head/; revision=180084
* - Macro-izes the packed declaration in all headers.Randall Stewart2008-06-141-6/+20
| | | | | | | | | | | | | | | | | | | | | - Vimage prep - these are major restructures to move all global variables to be accessed via a macro or two. The variables all go into a single structure. - Asconf address addition tweaks (add_or_del Interfaces) - Fix rwnd calcualtion to be more conservative. - Support SACK_IMMEDIATE flag to skip delayed sack by demand of peer. - Comment updates in the sack mapping calculations - Invarients panic added. - Pre-support for UDP tunneling (we can do this on MAC but will need added support from UDP to get a "pipe" of UDP packets in. - clear trace buffer sysctl added when local tracing on. Note the majority of this huge patch is all the vimage prep stuff :-) Notes: svn path=/head/; revision=179783
* Employ read locks on UDP inpcbs, rather than write locks, whenRobert Watson2008-05-291-11/+12
| | | | | | | | | | | monitoring UDP connections using sysctls. In some cases, add previously missing locking of inpcbs, as inp_socket is followed, which also allows us to drop global locks more quickly. MFC after: 1 week Notes: svn path=/head/; revision=179412
* Factor out the v4-only vs. the v6-only inp_flags processing inBjoern A. Zeeb2008-05-242-16/+34
| | | | | | | | | | | | ip6_savecontrol in preparation for udp_append() to no longer need an WLOCK as we will no longer be modifying socket options. Requested by: rwatson Reviewed by: gnn MFC after: 10 days Notes: svn path=/head/; revision=179289
* - Adds support for the multi-asconf (From Kozuka-san)Randall Stewart2008-05-201-3/+3
| | | | | | | | | | | | | | | | | | | | | - Adds some prepwork (Not all yet) for vimage in particular support the delete the sctppcbinfo.xx structs. There is still a leak in here if it were to be called plus we stil need the regrouping (From Me and Michael Tuexen) - Adds support for UDP tunneling. For BSD there is no socket yet setup so its disabled, but major argument changes are in here to emcompass the passing of the port number (zero when you don't have a udp tunnel, the default for BSD). Will add some hooks in UDP here shortly (discussed with Robert) that will allow easy tunneling. (Mainly from Peter Lei and Michael Tuexen with some BSD work from me :-D) - Some ease for windows, evidently leave is reserved by their compile move label leave: -> out: MFC after: 1 week Notes: svn path=/head/; revision=179157
* Add code to allow the system to handle multiple routing tables.Julian Elischer2008-05-094-9/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=178888
* Acquire a read lock, rather than a write lock, on a UDPv6 inpcb whenRobert Watson2008-04-221-9/+9
| | | | | | | | | | delivering to the socket or extracting socket details for monitoring purposes. MFC after: 3 months Notes: svn path=/head/; revision=178419