summaryrefslogtreecommitdiffstats
path: root/sys/netatalk/ddp_usrreq.c
Commit message (Collapse)AuthorAgeFilesLines
* Use queue(9) instead of hand-crafted link lists for the global netatalkrwatson2009-06-241-0/+1
| | | | | | | address list. Generally follow the style and convention of similar parts in netinet. MFC after: 6 weeks
* Reimplement the netisr framework in order to support parallel netisrrwatson2009-06-011-11/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | threads: - Support up to one netisr thread per CPU, each processings its own workstream, or set of per-protocol queues. Threads may be bound to specific CPUs, or allowed to migrate, based on a global policy. In the future it would be desirable to support topology-centric policies, such as "one netisr per package". - Allow each protocol to advertise an ordering policy, which can currently be one of: NETISR_POLICY_SOURCE: packets must maintain ordering with respect to an implicit or explicit source (such as an interface or socket). NETISR_POLICY_FLOW: make use of mbuf flow identifiers to place work, as well as allowing protocols to provide a flow generation function for mbufs without flow identifers (m2flow). Falls back on NETISR_POLICY_SOURCE if now flow ID is available. NETISR_POLICY_CPU: allow protocols to inspect and assign a CPU for each packet handled by netisr (m2cpuid). - Provide utility functions for querying the number of workstreams being used, as well as a mapping function from workstream to CPU ID, which protocols may use in work placement decisions. - Add explicit interfaces to get and set per-protocol queue limits, and get and clear drop counters, which query data or apply changes across all workstreams. - Add a more extensible netisr registration interface, in which protocols declare 'struct netisr_handler' structures for each registered NETISR_ type. These include name, handler function, optional mbuf to flow ID function, optional mbuf to CPU ID function, queue limit, and ordering policy. Padding is present to allow these to be expanded in the future. If no queue limit is declared, then a default is used. - Queue limits are now per-workstream, and raised from the previous IFQ_MAXLEN default of 50 to 256. - All protocols are updated to use the new registration interface, and with the exception of netnatm, default queue limits. Most protocols register as NETISR_POLICY_SOURCE, except IPv4 and IPv6, which use NETISR_POLICY_FLOW, and will therefore take advantage of driver- generated flow IDs if present. - Formalize a non-packet based interface between interface polling and the netisr, rather than having polling pretend to be two protocols. Provide two explicit hooks in the netisr worker for start and end events for runs: netisr_poll() and netisr_pollmore(), as well as a function, netisr_sched_poll(), to allow the polling code to schedule netisr execution. DEVICE_POLLING still embeds single-netisr assumptions in its implementation, so for now if it is compiled into the kernel, a single and un-bound netisr thread is enforced regardless of tunable configuration. In the default configuration, the new netisr implementation maintains the same basic assumptions as the previous implementation: a single, un-bound worker thread processes all deferred work, and direct dispatch is enabled by default wherever possible. Performance measurement shows a marginal performance improvement over the old implementation due to the use of batched dequeue. An rmlock is used to synchronize use and registration/unregistration using the framework; currently, synchronized use is disabled (replicating current netisr policy) due to a measurable 3%-6% hit in ping-pong micro-benchmarking. It will be enabled once further rmlock optimization has taken place. However, in practice, netisrs are rarely registered or unregistered at runtime. A new man page for netisr will follow, but since one doesn't currently exist, it hasn't been updated. This change is not appropriate for MFC, although the polling shutdown handler should be merged to 7-STABLE. Bump __FreeBSD_version. Reviewed by: bz
* Remove local variable 'ddp' from DDP's attach and detach routines; theyrwatson2009-02-041-6/+2
| | | | | | | | were used only for assertions, and rather than ifdef'ing them INVARIANTS and using local variables, just directly access so_pcb. Submitted by: Christoph Mallon <christoph dot mallon at gmx dot de> MFC after: 1 week
* Remove NETISR_MPSAFE, which allows specific netisr handlers to be directlyrwatson2008-07-041-3/+3
| | | | | | | | | | | | | | | | | | | | | | | 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.
* Reduce network stack oddness: implement .pru_sockaddr and .pru_peeraddrrwatson2007-05-111-5/+5
| | | | | | | | protocol entry points using functions named proto_getsockaddr and proto_getpeeraddr rather than proto_setsockaddr and proto_setpeeraddr. While it's true that sockaddrs are allocated and set, the net effect is to retrieve (get) the socket address or peer address from a socket, not set it, so align names to that intent.
* Clean up DDP layer netatalk code:rwatson2007-01-121-24/+24
| | | | | | | | | - General style(9) cleanup -- white space, braces, line wraps, etc. - Annotate a lack of synchronization the global route cache if the input routine is invoked with parallelism. - Remove unused debugging code.
* Break out my copyrights with our 2-clause BSD license from the UMichrwatson2007-01-081-0/+23
| | | | | | copyright, which while similar, is different. MFC after: 3 days
* Since soisdisconnected() is no longer called in pru_detach(), call itrwatson2006-08-051-0/+2
| | | | near consumers of at_pcbdisconnect() (_close, _abort).
* Change semantics of socket close and detach. Add a new protocol switchrwatson2006-07-211-3/+20
| | | | | | | | | | | | | | | | | | | function, pru_close, to notify protocols that the file descriptor or other consumer of a socket is closing the socket. pru_abort is now a notification of close also, and no longer detaches. pru_detach is no longer used to notify of close, and will be called during socket tear-down by sofree() when all references to a socket evaporate after an earlier call to abort or close the socket. This means detach is now an unconditional teardown of a socket, whereas previously sockets could persist after detach of the protocol retained a reference. This faciliates sharing mutexes between layers of the network stack as the mutex is required during the checking and removal of references at the head of sofree(). With this change, pru_detach can now assume that the mutex will no longer be required by the socket layer after completion, whereas before this was not necessarily true. Reviewed by: gnn
* White space consistency with kasserts. Minor style tweaks.rwatson2006-04-011-2/+6
| | | | MFC after: 3 months
* Chance protocol switch method pru_detach() so that it returns voidrwatson2006-04-011-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | rather than an error. Detaches do not "fail", they other occur or the protocol flags SS_PROTOREF to take ownership of the socket. soclose() no longer looks at so_pcb to see if it's NULL, relying entirely on the protocol to decide whether it's time to free the socket or not using SS_PROTOREF. so_pcb is now entirely owned and managed by the protocol code. Likewise, no longer test so_pcb in other socket functions, such as soreceive(), which have no business digging into protocol internals. Protocol detach routines no longer try to free the socket on detach, this is performed in the socket code if the protocol permits it. In rts_detach(), no longer test for rp != NULL in detach, and likewise in other protocols that don't permit a NULL so_pcb, reduce the incidence of testing for it during detach. netinet and netinet6 are not fully updated to this change, which will be in an upcoming commit. In their current state they may leak memory or panic. MFC after: 3 months
* Change protocol switch pru_abort() API so that it returns void ratherrwatson2006-04-011-3/+1
| | | | | | | | | | | | | | than an int, as an error here is not meaningful. Modify soabort() to unconditionally free the socket on the return of pru_abort(), and modify most protocols to no longer conditionally free the socket, since the caller will do this. This commit likely leaves parts of netinet and netinet6 in a situation where they may panic or leak memory, as they have not are not fully updated by this commit. This will be corrected shortly in followup commits to these components. MFC after: 3 months
* In at_setsockaddr(), assert that ddp != NULL, rather than returning anrwatson2006-03-251-3/+2
| | | | error if it's NULL, as so_pcb != NULL is now an invariant.
* Modify netatalk to ensure, and assert, that pcb's remain attached torwatson2006-03-171-23/+9
| | | | | | | | | | sockets as long as the sockets have not been aborted or detached. Do not try to free the socket in pru_detach(), since sofree() will do so, if needed, once pru_detach() returns. Annotate a bug in ddp_abort(), which fails to free the socket; this is probably OK as ddp_abort() should never be called, so should instead be deleted.
* Run the netatalk netisrs without Giant.rwatson2005-02-181-4/+4
| | | | MFC after: 1 week
* /* -> /*- for license, minor formatting changes, insert COPYRIGHT into filesimp2005-01-071-2/+23
|
* Initialize struct pr_userreqs in new/sparse style and fill in commonphk2004-11-081-21/+11
| | | | | | default elements in net_init_domain(). This makes it possible to grep these structures and see any bogosities.
* Procotol control block locking for netatalk DDP.rwatson2004-07-121-23/+56
|
* Remove spl's from netatalk in preparation to merge locking.rwatson2004-07-121-23/+0
|
* Remove redundant call to soisdisconnected() from ddp_abort(), as itrwatson2004-05-051-1/+0
| | | | calls at_pcbdetach() which also immediately calls soisdisconnected().
* Rename 'ddpcb' variable to 'ddpcb_list' to better distinguish it fromrwatson2004-03-221-1/+1
| | | | 'struct ddpcb'.
* Compare pointers with NULL rather than 0, or treating them as boolans inrwatson2004-03-221-2/+2
| | | | | | | if statements. at_rmx gets a $FreeBSD$ out of the deal also (this code appears to be unused).
* Since I have my hands all over netatalk adding locking and restructuringrwatson2004-03-221-68/+68
| | | | | | | | | | it, cinch the file's style closer to style(9) with regard to parenthesis: s/( /(/g s/ )/)/g s/return(/return (/g s/return 0/return (0)/ s/return 1/return (1)/
* Isolate PCB-specific ethertalk DDP functions in ddp_pcb.c, removing themrwatson2004-03-191-340/+18
| | | | | | | | | | | | | | | from ddp_usrreq.c. Functions moved are: at_pcballoc() at_pcbconnect() at_pcbdetach() at_pcbdisconnect() at_pcbsetaddr() at_sockaddr() Also moved are ddp_ports and ddpcb, global variables associated with DDP pcbs. This makes PCB implementation more parallel to inet, inet6, and ipx.
* Make ddp_ports static, as it's not used outside of ddp_usrreq.c.rwatson2004-03-171-1/+1
| | | | | Inspired by: Day spent hiking to hot springs in Taiwan Powered by: Asia BSDCon 2004
* Rename dup_sockaddr() to sodupsockaddr() for consistency with otherrwatson2004-03-011-1/+1
| | | | | | | | | | | | functions in kern_socket.c. Rename the "canwait" field to "mflags" and pass M_WAITOK and M_NOWAIT in from the caller context rather than "1" or "0". Correct mflags pass into mac_init_socket() from previous commit to not include M_ZERO. Submitted by: sam
* Introduce a MAC label reference in 'struct inpcb', which cachesrwatson2003-11-181-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | the MAC label referenced from 'struct socket' in the IPv4 and IPv6-based protocols. This permits MAC labels to be checked during network delivery operations without dereferencing inp->inp_socket to get to so->so_label, which will eventually avoid our having to grab the socket lock during delivery at the network layer. This change introduces 'struct inpcb' as a labeled object to the MAC Framework, along with the normal circus of entry points: initialization, creation from socket, destruction, as well as a delivery access control check. For most policies, the inpcb label will simply be a cache of the socket label, so a new protocol switch method is introduced, pr_sosetlabel() to notify protocols that the socket layer label has been updated so that the cache can be updated while holding appropriate locks. Most protocols implement this using pru_sosetlabel_null(), but IPv4/IPv6 protocols using inpcbs use the the worker function in_pcbsosetlabel(), which calls into the MAC Framework to perform a cache update. Biba, LOMAC, and MLS implement these entry points, as do the stub policy, and test policy. Reviewed by: sam, bms Obtained from: TrustedBSD Project Sponsored by: DARPA, Network Associates Laboratories
* o add a flags parameter to netisr_register that is used to specifysam2003-11-081-3/+3
| | | | | | | | | | | | | | | | whether or not the isr needs to hold Giant when running; Giant-less operation is also controlled by the setting of debug_mpsafenet o mark all netisr's except NETISR_IP as needing Giant o add a GIANT_REQUIRED assertion to the top of netisr's that need Giant o pickup Giant (when debug_mpsafenet is 1) inside ip_input before calling up with a packet o change netisr handling so swi_net runs w/o Giant; instead we grab Giant before invoking handlers based on whether the handler needs Giant o change netisr handling so that netisr's that are marked MPSAFE may have multiple instances active at a time o add netisr statistics for packets dropped because the isr is inactive Supported by: FreeBSD Foundation
* must use RTFREE instead of rtfree for proper lockingsam2003-11-081-1/+1
|
* Update netisr handling; Each SWI now registers its queue, and all queuejlemon2003-03-041-9/+13
| | | | | | | | | | drain routines are done by swi_net, which allows for better queue control at some future point. Packets may also be directly dispatched to a netisr instead of queued, this may be of interest at some installations, but currently defaults to off. Reviewed by: hsu, silby, jayanth, sam Sponsored by: DARPA, NAI Labs
* Back out M_* changes, per decision of the TRB.imp2003-02-191-1/+1
| | | | Approved by: trb
* Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.alfred2003-01-211-1/+1
| | | | Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT.
* Back out my lats commit of locking down a socket, it conflicts with hsu's work.tanimura2002-05-311-9/+1
| | | | Requested by: hsu
* Lock down a socket, milestone 1.tanimura2002-05-201-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | o Add a mutex (sb_mtx) to struct sockbuf. This protects the data in a socket buffer. The mutex in the receive buffer also protects the data in struct socket. o Determine the lock strategy for each members in struct socket. o Lock down the following members: - so_count - so_options - so_linger - so_state o Remove *_locked() socket APIs. Make the following socket APIs touching the members above now require a locked socket: - sodisconnect() - soisconnected() - soisconnecting() - soisdisconnected() - soisdisconnecting() - sofree() - soref() - sorele() - sorwakeup() - sotryfree() - sowakeup() - sowwakeup() Reviewed by: alfred
* Change callers of mtx_init() to pass in an appropriate lock type name. Injhb2002-04-041-2/+2
| | | | | | | most cases NULL is passed, but in some cases such as network driver locks (which use the MTX_NETWORK_LOCK macro) and UMA zone locks, a name is used. Tested on: i386, alpha, sparc64
* Change the suser() API to take advantage of td_ucred as well as do ajhb2002-04-011-1/+1
| | | | | | | | | | | | general cleanup of the API. The entire API now consists of two functions similar to the pre-KSE API. The suser() function takes a thread pointer as its only argument. The td_ucred member of this thread must be valid so the only valid thread pointers are curthread and a few kernel threads such as thread0. The suser_cred() function takes a pointer to a struct ucred as its first argument and an integer flag as its second argument. The flag is currently only used for the PRISON_ROOT flag. Discussed on: smp@
* Make `options NETATALK' compile after the -fno-common changes.iedowse2002-01-161-0/+3
| | | | Tested by: Emiel Kollof <coolvibe@hackerheaven.org>
* Give struct socket structures a ref counting interface similar todillon2001-11-171-1/+1
| | | | | | | vnodes. This will hopefully serve as a base from which we can expand the MP code. We currently do not attempt to obtain any mutex or SX locks, but the door is open to add them when we nail down exactly how that part of it is going to work.
* KSE Milestone 2julian2001-09-121-13/+13
| | | | | | | | | | | | | | Note ALL MODULES MUST BE RECOMPILED make the kernel aware that there are smaller units of scheduling than the process. (but only allow one thread per process at this time). This is functionally equivalent to teh previousl -current except that there is a thread associated with each process. Sorry john! (your next MFC will be a doosie!) Reviewed by: peter@freebsd.org, dillon@freebsd.org X-MFC after: ha ha ha ha
* Convert more malloc+bzero to malloc+M_ZERO.dwmalone2000-12-081-2/+1
| | | | | Submitted by: josh@zipperup.org Submitted by: Robert Drehmel <robd@gmx.net>
* Lock down the network interface queues. The queue mutex must be obtainedjlemon2000-11-251-0/+2
| | | | | | | | | | | | | | before adding/removing packets from the queue. Also, the if_obytes and if_omcasts fields should only be manipulated under protection of the mutex. IF_ENQUEUE, IF_PREPEND, and IF_DEQUEUE perform all necessary locking on the queue. An IF_LOCK macro is provided, as well as the old (mutex-less) versions of the macros in the form _IF_ENQUEUE, _IF_QFULL, for code which needs them, but their use is discouraged. Two new macros are introduced: IF_DRAIN() to drain a queue, and IF_HANDOFF, which takes care of locking/enqueue, and also statistics updating/start if necessary.
* Move suser() and suser_xxx() prototypes and a related #define fromphk2000-10-291-1/+2
| | | | | | | | | <sys/proc.h> to <sys/systm.h>. Correctly document the #includes needed in the manpage. Add one now needed #include of <sys/systm.h>. Remove the consequent 48 unused #includes of <sys/proc.h>.
* Change suser_xxx() to suser() where it applies.phk1999-04-271-1/+1
|
* Suser() simplification:phk1999-04-271-1/+1
| | | | | | | | | | | | | | | | | | | 1: s/suser/suser_xxx/ 2: Add new function: suser(struct proc *), prototyped in <sys/proc.h>. 3: s/suser_xxx(\([a-zA-Z0-9_]*\)->p_ucred, \&\1->p_acflag)/suser(\1)/ The remaining suser_xxx() calls will be scrutinized and dealt with later. There may be some unneeded #include <sys/cred.h>, but they are left as an exercise for Bruce. More changes to the suser() API will come along with the "jail" code.
* Fix warnings in preparation for adding -Wall -Wcast-qual to thedillon1999-01-271-1/+1
| | | | kernel compile
* The "easy" fixes for compiling the kernel -Wunused: remove unreferenced staticarchie1998-12-071-8/+2
| | | | and local variables, goto labels, and functions declared but not defined.
* Staticize.eivind1998-02-091-2/+2
|
* Remove dereference of uninitialized (and unused) variable. This enablesjlemon1997-10-061-3/+0
| | | | netatalk to work again.
* Update network code to use poll support.peter1997-09-141-1/+1
|
* Added used #include - don't depend on <sys/mbuf.h> includingbde1997-09-021-0/+1
| | | | <sys/malloc.h> (unless we only use the bogusly shared M*WAIT flags).
OpenPOWER on IntegriCloud