summaryrefslogtreecommitdiffstats
path: root/sys/netgraph/ng_base.c
Commit message (Collapse)AuthorAgeFilesLines
* Despite several examples in the kernel, the third argument ofdwmalone2007-06-041-1/+1
| | | | | | | | | | | | | sysctl_handle_int is not sizeof the int type you want to export. The type must always be an int or an unsigned int. Remove the instances where a sizeof(variable) is passed to stop people accidently cut and pasting these examples. In a few places this was sysctl_handle_int was being used on 64 bit types, which would truncate the value to be exported. In these cases use sysctl_handle_quad to export them and change the format to Q so that sysctl(1) can still print them.
* Partially back out rev. 1.127, to restore broken functionality. Thisglebius2007-06-011-5/+4
| | | | | | should be redesigned, but better enter RELENG_7 with a working ngctl(8). Agreed by: julian
* Universally adopt most conventional spelling of acquire.rwatson2007-05-271-1/+2
|
* We don't need spinning locks here. Change them to the adaptive mutexes. Thiswkoszek2007-03-311-6/+6
| | | | | | | change should bring no performance decrease, as it did not in my tests. Reviewed by: julian, glebius Approved by: cognet (mentor)
* Instead of direct manipulation on queue and worklist mutexes, bring macroswkoszek2007-03-301-27/+40
| | | | | | | | for doing this job. This change will make it easy to migrate from using spinning locks to adaptive ones. Reviewed by: glebius, julian Approved by: cognet (mentor)
* Prefer more traditional spellings of some words in comments.rwatson2007-03-181-15/+15
|
* oops committed the wrong patch.julian2007-03-101-6/+10
| | | | try this one..
* ng_apply_item should be void. It is called from the interrupt source orjulian2007-03-091-14/+85
| | | | | | | | | | from whoever has dequeued the item from the queue. Generally they have no interest in the result, and even if it is called by the queuer, it should still pretend that it was queued. The queuer should be assuming that the call was queued and giving them the false confidence that they are getting status leads to hard to find bugs. Make it a void and remove all the code that tried to return status through it.
* Do not leak hooks in ng_bypass().glebius2006-10-111-0/+3
| | | | Submitted by: Alexander Motin <mav alkar.net>
* When counting nodes second time, use the same criteria as forglebius2006-06-071-4/+4
| | | | | | | the first time. PR: kern/98529 Submitted by: Michael Heyman
* Use NET_CALLOUT_MPSAFE for netgraph callout initializer.glebius2006-06-061-2/+0
|
* Conditionally acquire Giant in netgraph callouts to honor mpsafenet=0.jhb2006-06-021-0/+2
| | | | | Reported by: sekes <gexlie at gmail dot com> MFC after: 1 week
* - Print also node ID in ktr(9) messages. [1]glebius2006-01-121-29/+33
| | | | | | | - Use fixed length for function name, making ktrdump(8) output easier to read. Suggested by: julian [1]
* Remove old debugging leftover.glebius2006-01-121-8/+0
| | | | Reviewed by: julian
* Fix wording in last commit.glebius2006-01-121-1/+1
| | | | Submitted by: julian
* Add ktr(9) hooks to easier tracing of the netgraph item flow throughglebius2006-01-111-2/+36
| | | | netgraph.
* Some whitespace and style cleanup.glebius2005-11-151-60/+59
|
* Fix two races which happen when netgraph is restructuring:glebius2005-11-021-8/+47
| | | | | | | | | | | | - Introduce ng_topo_mtx, a mutex to protect topology changes. - In ng_destroy_node() protect with ng_topo_mtx the process of checking and pointing at ng_deadnode. [1] - In ng_con_part2() check that our peer is not a ng_deadnode, and protect the check with ng_topo_mtx. - Add KASSERTs to ng_acquire_read/write, to make more understandible synopsis in case if called on ng_deadnode. Reported by: Roselyn Lee [1]
* Rework the ng_item queueing on nodes:glebius2005-11-021-121/+106
| | | | | | | | | | | | | - 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
* - When flushing node input queue, check whether item has a callback. Ifglebius2005-10-131-0/+6
| | | | | it does, then call it suppling ENOENT as error value. - Add assert, that helped to catch the above error.
* After rev. 1.103 the oitem and ierror are no longer needed, remove them.glebius2005-10-121-18/+4
|
* Fix a regression introduced in rev. 1.107. If an item once had a writerglebius2005-10-111-22/+28
| | | | | | | | | | | | | | | | semantics, and then was reused for next node, it still would be applied as writer again. To fix the regression the decision is made never to alter item->el_flags after the item has been allocated. This requires checking for overrides both in ng_dequeue() and in ng_snd_item(). Details: - Caller of the ng_apply_item() knows what is the current access to node and specifies it to ng_apply_item(). The latter drops the given access after item has beem applied. - ng_dequeue() needs to be supplied with int pointer, where it stores the obtained access on node. - Check for node/hook access overrides in ng_dequeue().
* Fix an item leak, that happens when some node calls ng_callout() twoglebius2005-09-081-2/+6
| | | | | | | | | | | times consequently, without checking whether callout has been serviced or not. (ng_pptpgre and ng_ppp were catched in this behavior). - In ng_callout() save old item before calling callout_reset(). If the latter has returned 1, then free this item. - In ng_uncallout() clear c->c_arg. Problem reported by: Alexandre Kardanev
* Fix build.glebius2005-09-061-1/+1
|
* In INVARIANTS case also check that nodes do not pass queues of mbufsglebius2005-09-061-1/+5
| | | | each other.
* Raise one more bit in READER_MASK. I believe that before this changeglebius2005-09-061-1/+1
| | | | | | | it was possible to have 1 reader and 1 writer thread working on a node simultaneously. Reviewed by: julian
* Use non-debug macros inside debugging functions, to preventglebius2005-09-021-4/+4
| | | | important information from being rewritten.
* Cleanup the reader/writer policy in netgraph(4). Assignglebius2005-08-261-24/+25
| | | | | | | | either reader or writer flag on item in the function, that allocates the item. Do not modify these flags when item is applied or queued. The only exceptions are node and hook overrides - they can change item flags to writer.
* In ng_callout() assert that supplied arguments are non-NULL.glebius2005-08-211-3/+4
|
* Fix cut-n-paste error, introduced in rev. 1.103.glebius2005-07-211-1/+1
|
* Catch up with netgraph.h rev. 1.57 and fix build.glebius2005-07-211-0/+1
|
* Problem description:glebius2005-07-211-67/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | At the end of ng_snd_item(), node queue is processed. In certain netgraph setups deep recursive calls can occur. For example this happens, when two nodes are connected and can send items to each other in both directions. If, for some reason, both nodes have a lot of items in their queues, then the processing thread will recurse between these two nodes, delivering items left and right, going deeper in the stack. Other setups can suffer from deep recursion, too. The following factors can influence risk of deep netgraph call: - periodical write-access events on node - combination of slow link and fast one in one graph - net.inet.ip.fastforwarding Changes made: - In ng_acquire_{read,write}() do not dequeue another item. Instead, call ng_setisr() for this node. - At the end of ng_snd_item(), do not process queue. Call ng_setisr(), if there are any dequeueable items on node queue. - In ng_setisr() narrow worklist mutex holding. - In ng_setisr() assert queue mutex. Theoretically, the first two changes should negatively affect performance. To check this, some profiling was made: 1) In general real tasks, no noticable performance difference was found. 2) The following test was made: two multithreaded nodes and one single-threaded were connected into a ring. A large queues of packets were sent around this ring. Time to pass the ring N times was measured. This is a very vacuous test: no items/mbufs are allocated, no upcalls or downcalls outside of netgraph. It doesn't represent a real load, it is a stress test for ng_acquire_{read,write}() and item queueing functions. Surprisingly, the performance impact was positive! New code is 13% faster on UP and 17% faster on SMP, in this particular test. The problem was originally found, described, analyzed and original patch was written by Roselyn Lee from Vernier Networks. Thanks! Submitted by: Roselyn Lee <rosel verniernetworks com>
* In the splnet times, netgraph was functional and synchronous. Nowadays,glebius2005-07-051-2/+28
| | | | | | | | | | | | | | | | | | | | | | 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)
* - Extend interface of ng_getqblk(), so that malloc wait flags areglebius2005-05-161-26/+19
| | | | | | | | | | | | 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
* Move queue element routines upper, so that all relatedglebius2005-05-141-85/+85
| | | | | declarations are in one place, to improve readability. No functional changes.
* Use uma(9) for allocating netgraph items:glebius2005-05-141-102/+47
| | | | | | | | | | | - 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-3/+16
| | | | ng_queue_fn() - a queue version of ng_send_fn().
* Plug item leak in case when NGI_FN is applied to invalid node.glebius2005-03-101-0/+1
| | | | | Submitted by: Roselyn Lee MFC after: 3 days
* Make netgraph ISR and callout MPSAFE.glebius2005-02-121-2/+2
| | | | Reviewed by: rwatson, ru
* Rename ng_callout_trapoline to ng_callout_trampoline.glebius2005-01-261-3/+3
| | | | Requested by: ru
* With recent changes to _callout_stop_safe() we can remove a hackglebius2005-01-251-6/+1
| | | | in ng_uncallout().
* Fix an evil typo.glebius2005-01-241-1/+1
| | | | | Submitted by: Roselyn Lee MFC after: 3 days
* /* -> /*- for license, minor formatting changesimp2005-01-071-1/+3
|
* Introduce new startup level SI_SUB_NETGRAPH that is afteremax2005-01-061-1/+1
| | | | | | | | | | | | | | SI_SUB_INIT_IF but before SI_SUB_DRIVERS. Make Netgraph(4) framework initialize at SI_SUB_NETGRAPH level. This does not address the bigger problem: MODULE_DEPEND does not seem to work when modules are compiled in the kernel, but it fixes the problem with Netgraph Bluetooth device drivers reported by a few folks. PR: i386/69876 Reviewed by: julian, rik, scottl MFC after: 3 days
* Move systm.h up, since it is required by mbuf.h.glebius2004-12-231-1/+1
| | | | Requested by: ru
* - sort includesglebius2004-12-231-5/+4
| | | | - remove duplicate include sys/sysctl.h
* Assert queue mutex in ng_dequeue() and ng_queue_rw().glebius2004-12-191-0/+4
|
* Mechanically rename s/ng_timeout/ng_callout/g, s/ng_untimeout/ng_uncallout/g.glebius2004-12-011-5/+5
| | | | | | | This is done to keep both versions in RELENG_5 and support both APIs. Reviewed by: scottl Approved by: julian (mentor), implicitly
* Partically backout previous commit. Since _callout_stop_safe() clearsglebius2004-11-041-2/+7
| | | | | | | | | | out c->c_func, we can't take it after callout_stop(). To take it before we need to acquire callout_lock, to avoid race. This commit narrows down area where lock is held, but hack is still present. This should be redesigned. Approved by: julian (mentor)
* - Make ng_timeout() to use callout() interface instead of timeout().glebius2004-11-021-19/+17
| | | | | | | - Remove callout-hacking from ng_untimeout(). Approved by: julian (mentor) MFC after: 1 month
OpenPOWER on IntegriCloud