summaryrefslogtreecommitdiffstats
path: root/sys/netgraph/netgraph.h
Commit message (Collapse)AuthorAgeFilesLines
* sys/netgraph: spelling fixes in comments.pfg2016-04-291-3/+3
| | | | No functional change.
* CALLOUT_MPSAFE has lost its meaning since r141428, i.e., for more than tenjkim2015-05-221-1/+1
| | | | | | | | | | years for head. However, it is continuously misused as the mpsafe argument for callout_init(9). Deprecate the flag and clean up callout_init() calls to make them more consistent. Differential Revision: https://reviews.freebsd.org/D2613 Reviewed by: jhb MFC after: 2 weeks
* Refactor the name hash and the ID hash, that are used to address nodes:glebius2012-02-161-5/+1
| | | | | | | | | | | | | | | | | | - Make hash sizes growable, to satisfy users running large mpd installations, having thousands of nodes. - NG_NAMEHASH() proved to give a very bad distribution in real life name sets, while generic hash32_str(name, HASHINIT) proved to give an even one, so you the latter for name hash. - Do not store unnamed nodes in slot 0 of name hash, no reason for that. - Use the ID hash in cases when we need to run through all nodes: the NGM_LISTNODES command and in the vnet_netgraph_uninit(). - Implement NGM_LISTNODES and NGM_LISTNAMES as separate code, the former iterates through the ID hash, and the latter through the name hash. - Keep count of all nodes and of named nodes, so that we don't need to count nodes in NGM_LISTNODES and NGM_LISTNAMES. The counters are also used to estimate whether we need to grow hashes. - Close a race between two threads running ng_name_node() assigning same name to different nodes.
* Constify "address" argument of ng_address_path().fjoe2011-11-061-1/+1
|
* - If KDB & NETGRAPH_DEBUG are on, print traces on discovered failedglebius2011-10-271-2/+3
| | | | | invariants. - Reduce tautology in NETGRAPH_DEBUG output.
* Fix build with NETGRAPH_DEBUG.glebius2011-07-041-1/+1
|
* Fix build with NETGRAPH_DEBUG.glebius2011-07-041-2/+2
|
* - Use refcount(9) API to manage node and hook refcounting.glebius2011-07-041-3/+4
| | | | | | | | - Make ng_unref_node() void, since caller shouldn't be interested in whether node is valid after call or not, since it can't be guaranteed to be valid. [1] Ok from: julian [1]
* Introduce and use a sysinit-based initialization scheme for virtualrwatson2009-07-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | network stacks, VNET_SYSINIT: - Add VNET_SYSINIT and VNET_SYSUNINIT macros to declare events that will occur each time a network stack is instantiated and destroyed. In the !VIMAGE case, these are simply mapped into regular SYSINIT/SYSUNINIT. For the VIMAGE case, we instead use SYSINIT's to track their order and properties on registration, using them for each vnet when created/ destroyed, or immediately on module load for already-started vnets. - Remove vnet_modinfo mechanism that existed to serve this purpose previously, as well as its dependency scheme: we now just use the SYSINIT ordering scheme. - Implement VNET_DOMAIN_SET() to allow protocol domains to declare that they want init functions to be called for each virtual network stack rather than just once at boot, compiling down to DOMAIN_SET() in the non-VIMAGE case. - Walk all virtualized kernel subsystems and make use of these instead of modinfo or DOMAIN_SET() for init/uninit events. In some cases, convert modular components from using modevent to using sysinit (where appropriate). In some cases, do minor rejuggling of SYSINIT ordering to make room for or better manage events. Portions submitted by: jhb (VNET_SYSINIT), bz (cleanup) Discussed with: jhb, bz, julian, zec Reviewed by: bz Approved by: re (VIMAGE blanket)
* Build on Jeff Roberson's linker-set based dynamic per-CPU allocatorrwatson2009-07-141-32/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (DPCPU), as suggested by Peter Wemm, and implement a new per-virtual network stack memory allocator. Modify vnet to use the allocator instead of monolithic global container structures (vinet, ...). This change solves many binary compatibility problems associated with VIMAGE, and restores ELF symbols for virtualized global variables. Each virtualized global variable exists as a "reference copy", and also once per virtual network stack. Virtualized global variables are tagged at compile-time, placing the in a special linker set, which is loaded into a contiguous region of kernel memory. Virtualized global variables in the base kernel are linked as normal, but those in modules are copied and relocated to a reserved portion of the kernel's vnet region with the help of a the kernel linker. Virtualized global variables exist in per-vnet memory set up when the network stack instance is created, and are initialized statically from the reference copy. Run-time access occurs via an accessor macro, which converts from the current vnet and requested symbol to a per-vnet address. When "options VIMAGE" is not compiled into the kernel, normal global ELF symbols will be used instead and indirection is avoided. This change restores static initialization for network stack global variables, restores support for non-global symbols and types, eliminates the need for many subsystem constructors, eliminates large per-subsystem structures that caused many binary compatibility issues both for monitoring applications (netstat) and kernel modules, removes the per-function INIT_VNET_*() macros throughout the stack, eliminates the need for vnet_symmap ksym(2) munging, and eliminates duplicate definitions of virtualized globals under VIMAGE_GLOBALS. Bump __FreeBSD_version and update UPDATING. Portions submitted by: bz Reviewed by: bz, zec Discussed with: gnn, jamie, jeff, jhb, julian, sam Suggested by: peter Approved by: re (kensmith)
* Introduce a mechanism for detecting calls from outbound path of thezec2009-06-111-2/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | network stack when reentering the inbound path from netgraph, and force queueing of mbufs at the outbound netgraph node. The mechanism relies on two components. First, in netgraph nodes where outbound path of the network stack calls into netgraph, the current thread has to be appropriately marked using the new NG_OUTBOUND_THREAD_REF() macro before proceeding to call further into the netgraph topology, and unmarked using the NG_OUTBOUND_THREAD_UNREF() macro before returning to the caller. Second, netgraph nodes which can potentially reenter the network stack in the inbound path have to mark their inbound hooks using NG_HOOK_SET_TO_INBOUND() macro. The netgraph framework will then detect when there is a danger of a call graph looping back from outbound to inbound path via netgraph, and defer handing off the mbufs to the "inbound" node to a worker thread with a clean stack. In this first pass only the most obvious netgraph nodes have been updated to ensure no outbound to inbound calls can occur. Nodes such as ng_ipfw, ng_gif etc. should be further examined whether a potential for outbound to inbound call looping exists. This commit changes the layout of struct thread, but due to __FreeBSD_version number shortage a version bump has been omitted at this time, nevertheless kernel and modules have to be rebuilt. Reviewed by: julian, rwatson, bz Approved by: julian (mentor)
* Change the curvnet variable from a global const struct vnet *,zec2009-05-051-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | previously always pointing to the default vnet context, to a dynamically changing thread-local one. The currvnet context should be set on entry to networking code via CURVNET_SET() macros, and reverted to previous state via CURVNET_RESTORE(). Recursions on curvnet are permitted, though strongly discuouraged. This change should have no functional impact on nooptions VIMAGE kernel builds, where CURVNET_* macros expand to whitespace. The curthread->td_vnet (aka curvnet) variable's purpose is to be an indicator of the vnet context in which the current network-related operation takes place, in case we cannot deduce the current vnet context from any other source, such as by looking at mbuf's m->m_pkthdr.rcvif->if_vnet, sockets's so->so_vnet etc. Moreover, so far curvnet has turned out to be an invaluable consistency checking aid: it helps to catch cases when sockets, ifnets or any other vnet-aware structures may have leaked from one vnet to another. The exact placement of the CURVNET_SET() / CURVNET_RESTORE() macros was a result of an empirical iterative process, whith an aim to reduce recursions on CURVNET_SET() to a minimum, while still reducing the scope of CURVNET_SET() to networking only operations - the alternative would be calling CURVNET_SET() on each system call entry. In general, curvnet has to be set in three typicall cases: when processing socket-related requests from userspace or from within the kernel; when processing inbound traffic flowing from device drivers to upper layers of the networking stack, and when executing timer-driven networking functions. This change also introduces a DDB subcommand to show the list of all vnet instances. Approved by: julian (mentor)
* In preparation to make options VIMAGE operational, where needed,zec2009-04-261-0/+1
| | | | | | | | | | | | | initialize / release netgraph related state in iattach() / idetach() functions called via the vnet module registration / initialization framework, instead of initialization / cleanups being done in mod_event handlers. While here, introduce a crude hack aimed at preventing ng_ether to autoattach to ng_eiface ifnets, which are also netgraph nodes already. Reviewed by: bz Approved by: julian (mentor)
* Revert rev. 183277:mav2008-12-131-1/+0
| | | | | | | | | | Remove ng_rmnode_flags() function. ng_rmnode_self() was made to be called only while having node locked. When node is properly locked, any function call sent to it will always be queued. So turning ng_rmnode_self() into the ng_rmnode_flags() is not just meaningless, but incorrent, as it violates node locking when called outside. No objections: julian, thompsa
* Conditionally compile out V_ globals while instantiating the appropriatezec2008-12-101-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | container structures, depending on VIMAGE_GLOBALS compile time option. Make VIMAGE_GLOBALS a new compile-time option, which by default will not be defined, resulting in instatiations of global variables selected for V_irtualization (enclosed in #ifdef VIMAGE_GLOBALS blocks) to be effectively compiled out. Instantiate new global container structures to hold V_irtualized variables: vnet_net_0, vnet_inet_0, vnet_inet6_0, vnet_ipsec_0, vnet_netgraph_0, and vnet_gif_0. Update the VSYM() macro so that depending on VIMAGE_GLOBALS the V_ macros resolve either to the original globals, or to fields inside container structures, i.e. effectively #ifdef VIMAGE_GLOBALS #define V_rt_tables rt_tables #else #define V_rt_tables vnet_net_0._rt_tables #endif Update SYSCTL_V_*() macros to operate either on globals or on fields inside container structs. Extend the internal kldsym() lookups with the ability to resolve selected fields inside the virtualization container structs. This applies only to the fields which are explicitly registered for kldsym() visibility via VNET_MOD_DECLARE() and vnet_mod_register(), currently this is done only in sys/net/if.c. Fix a few broken instances of MODULE_GLOBAL() macro use in SCTP code, and modify the MODULE_GLOBAL() macro to resolve to V_ macros, which in turn result in proper code being generated depending on VIMAGE_GLOBALS. De-virtualize local static variables in sys/contrib/pf/net/pf_subr.c which were prematurely V_irtualized by automated V_ prepending scripts during earlier merging steps. PF virtualization will be done separately, most probably after next PF import. Convert a few variable initializations at instantiation to initialization in init functions, most notably in ipfw. Also convert TUNABLE_INT() initializers for V_ variables to TUNABLE_FETCH_INT() in initializer functions. 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
* Unhide declarations of network stack virtualization structs fromzec2008-11-281-0/+11
| | | | | | | | | | | | | | | | | | underneath #ifdef VIMAGE blocks. This change introduces some churn in #include ordering and nesting throughout the network stack and drivers but is not expected to cause any additional issues. In the next step this will allow us to instantiate the virtualization container structures and switch from using global variables to their "containerized" counterparts. 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
* Retire the MALLOC and FREE macros. They are an abomination unto style(9).des2008-10-231-1/+1
| | | | MFC after: 3 months
* Step 1.5 of importing the network stack virtualization infrastructurezec2008-10-021-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Add ng_rmnode_flags() so the caller can pass NG_QUEUE and have the nodethompsa2008-09-221-0/+1
| | | | | | destroyed asynchronously due to locking or other constraints. Reviewed by: julian
* 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
* Several changes breaking netgraph module ABI collected together:mav2008-04-151-12/+9
| | | | | | | | | | | | | | | | | | | | | | - 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
* Improve apply callback error reporting:mav2008-03-111-1/+2
| | | | | | | | | | | 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.
* Implement stack protection based on GET_STACK_USAGE() macro.mav2008-01-311-0/+23
| | | | | This fixes system panics possible with complicated netgraph setups and allows to avoid unneded extra queueing for stack unwrapping.
* - Merge all the ng_send_fn2* functions into one - ng_send_fn2(),glebius2007-11-141-15/+7
| | | | | | | | removing some copy&pasted code. - Reduce copy and paste in ng_apply_item(). - Resurrect ng_send_fn() as a valid symbol, not a define. Reviewed by: mav, julian
* Implement new apply callback mechanism to handle item forwarding.mav2007-10-191-5/+37
| | | | | | | | When item forwarded refence counter is incremented, when item processed, counter decremented. When counter reaches zero, apply handler is getting called. Now it allows to report right connect() call status from user-level at the right time.
* Replace references to NET_CALLOUT_MPSAFE with CALLOUT_MPSAFE, and removerwatson2007-07-281-1/+1
| | | | | | | | definition of NET_CALLOUT_MPSAFE, which is no longer required now that debug.mpsafenet has been removed. The once over: bz Approved by: re (kensmith)
* - ng_address_ID() has already freed the message, don't do double free.glebius2006-10-171-6/+2
| | | | | | - Get error from ng_address_ID(). Reported by: Coverity via pjd
* Use NET_CALLOUT_MPSAFE for netgraph callout initializer.glebius2006-06-061-1/+1
|
* Provide additional macros for sending netgraph items, which allowglebius2006-01-121-9/+17
| | | | | to use non-default flags for netgraph functions. Implement current macros via new ones.
* Remove old debugging leftover.glebius2006-01-121-3/+1
| | | | Reviewed by: julian
* Some whitespace and style cleanup.glebius2005-11-151-29/+29
|
* Rework the ng_item queueing on nodes:glebius2005-11-021-3/+12
| | | | | | | | | | | | | - Introduce a new flags NGQF_QREADER and NGQF_QWRITER, which tell how the item should be actually applied, overriding NGQF_READER/NGQF_WRITER flags. - Do not differ between pending reader or writer. Use only one flag that is raised, when there are pending items. - Schedule netgraph ISR in ng_queue_rw(), so that callers do not need to do this job. - Fix several comments. Submitted by: julian
* Remove ng_callout_init_mtx() macro. Mutexed callouts are incompatibleglebius2005-09-121-1/+0
| | | | with netgraph(4).
* Add ng_callout_ini_mtx() macro.glebius2005-08-301-0/+1
|
* reorder a couple of cases of void __inline to __inline voidjulian2005-08-081-3/+3
| | | | | | | to silence warnings from compilig with -W Submitted by: sandvine inc MFC after: 1 week
* Fix up the comment.ru2005-08-021-2/+2
|
* Bump NG_ABI_VERSION. A number of ABI breakeges had been done sinceglebius2005-07-211-1/+1
| | | | RELENG_5 fork.
* Enhance struct ng_hook - add hk_type field. This field will describeglebius2005-07-211-0/+1
| | | | | | data link type of the hook. It will be used to ease autoconfiguration of netgraph and also to print warning messages, when incompatoble nodes are connected together.
* In the splnet times, netgraph was functional and synchronous. Nowadays,glebius2005-07-051-0/+8
| | | | | | | | | | | | | | | | | | | | | | an item may be queued and processed later. While this is OK for mbufs, this is a problem for control messages. In the framework: - Add optional callback function pointer to an item. When item gets applied the callback is executed from ng_apply_item(). - Add new flag NG_PROGRESS. If this flag is supplied, then return EINPROGRESS instead of 0 in case if item failed to deliver synchronously and was queued. - Honor NG_PROGRESS in ng_snd_item(). In ng_socket: - When userland sends control message add callback to the item. - If ng_snd_item() returns EINPROGRESS, then sleep. This change fixes possible races in ngctl(8) scripts. Reviewed by: julian Approved by: re (scottl)
* Use NG_QUEUE instead of constant.glebius2005-05-161-1/+1
|
* - Extend interface of ng_getqblk(), so that malloc wait flags areglebius2005-05-161-10/+15
| | | | | | | | | | | | specified by caller. - Change ng_send_item() interface - use 'flags' argument instead of boolean 'queue'. - Extend ng_send_fn(), ng_package_data() and ng_package_msg() interface - add possibility to pass flags. Rename ng_send_fn() to ng_send_fn1(). Create macro for ng_send_fn(). - Update all macros, that use ng_package_data() and ng_package_msg(). Reviewed by: julian
* Make NETGRAPH_DEBUG a kernel option, so that it can't be turned offglebius2005-05-161-1/+3
| | | | | | without hacking source. In collaboration with: ru, julian
* Use uma(9) for allocating netgraph items:glebius2005-05-141-7/+1
| | | | | | | | | | | - ng_getqblk() simply runs uma_zalloc(). - ng_free_item() simply frees. - ngq_mtx is pushed down under NETGRAPH_DEBUG. - NGQF_FREE is removed. Increase default maxalloc to 512. Reviewed by: julian
* Since there is no way to queue a function call to node, createglebius2005-05-131-0/+2
| | | | ng_queue_fn() - a queue version of ng_send_fn().
* Plug item leak in macro NG_RESPOND_MSG. Item was leaked when destinationglebius2005-03-101-0/+1
| | | | | | node couldn't be addressed. Submitted by: Roselyn Lee
* Make netgraph ISR and callout MPSAFE.glebius2005-02-121-2/+1
| | | | Reviewed by: rwatson, ru
* /* -> /*- for license, minor formatting changesimp2005-01-071-1/+3
|
* Mechanically rename s/ng_timeout/ng_callout/g, s/ng_untimeout/ng_uncallout/g.glebius2004-12-011-2/+2
| | | | | | | This is done to keep both versions in RELENG_5 and support both APIs. Reviewed by: scottl Approved by: julian (mentor), implicitly
* - Make ng_timeout() to use callout() interface instead of timeout().glebius2004-11-021-3/+4
| | | | | | | - Remove callout-hacking from ng_untimeout(). Approved by: julian (mentor) MFC after: 1 month
* Align netgraph message fields ready for 64-bit (and 128 bit :-) machines.julian2004-08-201-1/+1
| | | | | | | | | | requires a recompile of netgraph users. Also change the size of a field in the bluetooth code that was waiting for the next change that needed recompiles so it could piggyback its way in. Submitted by: jdp, maksim MFC after: 2 days
OpenPOWER on IntegriCloud