summaryrefslogtreecommitdiffstats
path: root/sys/netgraph
Commit message (Collapse)AuthorAgeFilesLines
* Introduce support for Bluetooth SCO sockets. This is based on olderemax2008-07-303-1/+2132
| | | | | | code that was revisted. MFC after: 3 months
* Simplify ubt_isoc_in_complete2(). Also should fix off by 1 bug.emax2008-07-291-28/+18
| | | | MFC after: 3 months
* Don't use memcpy() to copy several bytes.mav2008-07-281-40/+22
| | | | | Store IDs is host order. It is not so important to bloat code for it. Combine m_adj() and M_PREPEND() into single M_PREPEND().
* Fill in the string portion of the bluetooth stack version sysctl.trhodes2008-07-141-1/+1
| | | | Approved by: emax
* Dust off old code for support of USB isochronous transfers.emax2008-07-113-215/+341
| | | | | | | | | USB isochronous transfer support is required for Bluetooth SCO. While i'm here change u_int to uint and update TODO. This should produce no visible changes unless the device is broken (or really old). MFC after: 3 months
* Get in some basic infrastructure for Bluetooth SCO support.emax2008-07-103-0/+59
| | | | MFC after: 3 months
* Back out r180370. It was not discussed with subsystem maintainers.gonzo2008-07-082-2/+2
|
* Queue decapsulated packed instead of performing direct dispatch. Somegonzo2008-07-082-2/+2
| | | | | | | | execution pathes might hit stack limit under certain circumstances (e.g. ng_mppc). PR: kern/125314 Reported by: Illya Klymov <ilia dot klimov at gmail dot com>
* Remove NETISR_MPSAFE, which allows specific netisr handlers to be directlyrwatson2008-07-041-2/+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.
* Make it simpler to build netgraph modules outside of the kernel sourcegnn2008-06-241-0/+2
| | | | | | tree. This change follows similar ones in the device tree. MFC after: 2 weeks
* Pass really available buffer size to libalias instead of MCLBYTES constant.mav2008-06-011-2/+2
| | | | | MCLBYTES constant were used with believe that m_megapullup() always moves date into a fresh cluster that may become not so.
* Remove netatm from HEAD as it is not MPSAFE and relies on the now removedrwatson2008-05-254-1961/+0
| | | | | | | | | | | | | | | | | | | NET_NEEDS_GIANT. netatm has been disconnected from the build for ten months in HEAD/RELENG_7. Specifics: - netatm include files - netatm command line management tools - libatm - ATM parts in rescue and sysinstall - sample configuration files and documents - kernel support as a module or in NOTES - netgraph wrapper nodes for netatm - ctags data for netatm. - netatm-specific device drivers. MFC after: 3 weeks Reviewed by: bz Discussed with: bms, bz, harti
* Add code to allow the system to handle multiple routing tables.julian2008-05-091-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* ng_address_hook() microoptimization. Use local variables as they should be.mav2008-04-191-7/+5
| | | | It helps compiller to avoid some extra memory accesses.
* Use separate UMA zone for data items allocation. It is a partialmav2008-04-161-40/+70
| | | | | | | | | rev. 1.149 rework. It allows to save several percents of CPU time on SMP by using UMA's internal per-CPU allocation limits instead of own global variable each time updated with atomics. Tested with: Netperf cluster
* Replace callout_init(..., 1) with callout_init(..., CALLOUT_MPSAFE) forkris2008-04-161-1/+1
| | | | | | | better grep-compliance and to standardize with the rest of the kernel. Reviewed by: jhb MFC after: 1 week
* Several changes breaking netgraph module ABI collected together:mav2008-04-153-139/+115
| | | | | | | | | | | | | | | | | | | | | | - reorder structures fields (XX_refs) a bit to group fields modified same time together. According to my tests it gives up to 10% SMP performance benefit on real workload due to reduced inter-CPU cache trashing. - change q_flags from long to int as long is not really needed there and it's usage with atomics is argued by some people. - move NGF_WORKQ flag into the separate field q_flags2 as it protected by queue mutex instead of node writer protection used by the rest of flags. - move nd_work queue entry to ng_queue structure to which it is more related and make it STAILQ instead of TAILQ as now it is a classic FIFO. - remove q_node pointer from ng_queue structure as it is not really needed. - reimplement item queue using STAILQ instead of own equal implementation. As soon as BT subsystem has own item queues using ng_item.el_next update it also. - change depth field in ng_item from uintptr_t to u_int. It was made uintptr_t to keep ABI compatibility. Reviewed by: julian, emax Tested with: Netperf cluster
* Add memory barriers to the node locking operations.mav2008-04-091-18/+32
| | | | Add some comments.
* Rewrite node's r/w/q-lock semantics using only atomics instead of mutexmav2008-04-061-247/+76
| | | | | and atomics combination. Mutex is now used only for queue protection. Also avoid unneded extra swi scheduling calls.
* - Account all node stats at the shape mode.mav2008-03-301-35/+27
| | | | | | - Do not check destination hook presence, it will be done by netgraph. - Use u_int instead of int in some places to simplify type conversions. - Use NG_SEND_DATA_ONLY() macro instead of selfmade equivalent.
* Use new atomic_fetchadd() primitive instead of looping atomic_cmpset().mav2008-03-301-8/+5
|
* There is no need to erase hook->hk_node before freing hook.mav2008-03-291-3/+1
|
* Remove ng_setisr() call from ng_dequeue(). It is useless as we any waymav2008-03-271-11/+0
| | | | | | | | will never exit ngintr(), while there is some ready requests on the queue. It was made years ago with hope of parallel queue processing by several net threads. But even if we have several threads sometimes, we have no rights to process queue in parallel as it will break original requests serialization that is critically important for some setups.
* Switch from timeval to bintime, to use 1/(2^20) of seconds instead ofmav2008-03-271-22/+23
| | | | | microseconds. It allows to use bit shifts instead of some heavy 64bit mul/div math operations.
* Some minor code and math optimizations.mav2008-03-261-40/+21
|
* Rewrite node to support multiple hooks, alike to ng_l2tp, to use one pairmav2008-03-242-241/+284
| | | | | | | | | | | | | | of pptpgre and ksocket nodes for all calls between two peers. This patch modifies node's API by adding new "session_%04x" hook names support, while keeping backward compatibility. Together with appropriate user-level support (by latest mpd5) it gives huge performance benefits for case of multiple active calls between two peers because of avoiding data duplication and extra socket processing. On my benchmarks I have got more then 10 times speedup for the 200 simultaneous PPTP calls between two peers. In conclusion, it allows now to build effective "clients <=> PAC <=> PNS" setups.
* Remove impossible (hk_peer == NULL) check from ng_address_hook().mav2008-03-161-1/+0
| | | | | Valid hook can't have NULL peer. Even invalid one can't, as it is resets to deadhook, but not NULL.
* Add session ID hashing to speedup incoming packets dispatch in casemav2008-03-161-38/+47
| | | | | of many connections working via the same tunnel. For example, in case of full "client <-> LAC <-> LNS" setup.
* Improve apply callback error reporting:mav2008-03-113-10/+28
| | | | | | | | | | | Before this patch callback returned result of the last finished call chain. Now it returns last nonzero result from all call chain results in this request. As soon as this improvement gives reliable error reporting, it is now possible to remove dirty workaround in ng_socket, made to return ENOBUFS error statuses of request-response operations. That workaround was responsible for returning ENOBUFS errors to completely unrelated requests working at the same time on socket.
* Addition to the previous commit. Release inproc in case of memory error.mav2008-03-091-0/+1
|
* To avoid control data losses do not acknowledge recieving of control packetmav2008-03-081-54/+44
| | | | | | if netgraph reported error while delivering to destination. Reset 'next send' counter to the last requested by peer on ack timeout to resend all subsequest packets after lost one again without additional hints.
* Send only one incoming notification at a time to reduce queuemav2008-03-071-32/+26
| | | | | | | | trashing and improve performance. Remove waitflag argument from ng_ksocket_incoming2(), it means nothing as function call was queued by netgraph. Remove node validity check, as node validity guarantied by netgraph. Update comments.
* Increase default queue items allocation limit from 512 to 4096 itemsmav2008-03-051-2/+16
| | | | | | | | | to avoid terrible unpredicted effects for netgraph operation of their exhaustion while allocating control messages. Add separate configurable 512 items limit for data items allocation for DoS/overload protection. Discussed with: julian
* Implement 128 items node name hash for faster name search.mav2008-03-041-47/+70
| | | | Increase node ID hash size from 32 to 128 items.
* Fix incorrect field name.mav2008-03-041-1/+1
|
* Use more compact LIST instead of TAILQ for session hash.mav2008-03-031-62/+32
| | | | | Add all listening hooks into LIST to simplify searches. Use ng_findhook() instead of own equal implementation.
* Make session ID generator to use session ID hash.mav2008-03-021-40/+37
| | | | Make session ID generator thread-safe.
* Add support for the libalias redirect functionality.mav2008-03-012-1/+558
| | | | Submitted by: Vadim Goncharov <vadim_nuclight@mail.ru>
* Fix incorrect constant used in rev. 1.146 that broke node writer locking.mav2008-02-251-1/+1
|
* Fix shutdown bug made by previous commit.mav2008-02-241-0/+1
|
* Use rtalloc1() instead of rtalloc_ign(). It returns a lockedglebius2008-02-071-24/+17
| | | | | | rtentry. We quickly copy the fields of interest, and then RTFREE_LOCKED(). This should be faster then lock & unlock the rtentry twice.
* Do not use bcmp() to compare two bytes with constants.mav2008-02-062-4/+4
|
* Cleanup and tune ng_snd_item() function as it is one of themav2008-02-061-95/+42
| | | | | most busy netgraph functions. Tune stack protection constants to avoid division operation.
* Prepare hooks direct pointers on setup to avoid heavy ng_findhook() callsmav2008-02-041-27/+66
| | | | during operarion.
* Move all possible node logic out of the rcvdata() functionmav2008-02-031-96/+90
| | | | | to the newhook()/disconnect(). Unify function names with other nodes.
* Revert previous commit.mav2008-02-031-4/+8
| | | | glebius@ noticed that it was not a bug, but undocumented feature.
* Fix one more grammo.marck2008-02-021-1/+1
| | | | Noticed by: ru
* Reword recent comment a bit.marck2008-02-011-3/+3
|
* Add comments about stack protection mechanism.mav2008-02-011-0/+8
|
* Tune the message for better informativity.mav2008-02-011-1/+2
| | | | Print the hook pointer as other functions do.
OpenPOWER on IntegriCloud