summaryrefslogtreecommitdiffstats
path: root/sys/netgraph/ng_base.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Commit step 1 of the vimage project, (network stack)bz2008-08-171-8/+9
| | | | | | | | | | | | | | | | | | | | | | | | 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
* 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.
* 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
* Several changes breaking netgraph module ABI collected together:mav2008-04-151-104/+91
| | | | | | | | | | | | | | | | | | | | | | - 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.
* 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.
* 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.
* Improve apply callback error reporting:mav2008-03-111-8/+25
| | | | | | | | | | | 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.
* 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 constant used in rev. 1.146 that broke node writer locking.mav2008-02-251-1/+1
|
* 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.
* 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
|
* Some code reformat.mav2008-01-311-55/+38
|
* Implement stack protection based on GET_STACK_USAGE() macro.mav2008-01-311-8/+22
| | | | | This fixes system panics possible with complicated netgraph setups and allows to avoid unneded extra queueing for stack unwrapping.
* Add a new 'why' argument to kdb_enter(), and a set of constants to userwatson2007-12-251-2/+2
| | | | | | | | | for that argument. This will allow DDB to detect the broad category of reason why the debugger has been entered, which it can use for the purposes of deciding which DDB script to run. Assign approximate why values to all current consumers of the kdb_enter() interface.
* - Merge all the ng_send_fn2* functions into one - ng_send_fn2(),glebius2007-11-141-77/+36
| | | | | | | | 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
* Minor debug message fix.mav2007-10-281-1/+1
|
* Fix build with NETGRAPH_DEBUG.ru2007-10-191-1/+9
|
* Implement new apply callback mechanism to handle item forwarding.mav2007-10-191-65/+182
| | | | | | | | 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.
* Add ng_send_fn() error handeling inside ng_con_nodes().mav2007-08-181-2/+5
| | | | | | | | Without it some errors may left unnoticed and unhandeled that will lead to hooks left in half-connected state. Reviewed by: julian@ Approved by: re (kensmith), glebius (mentor)
* 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
OpenPOWER on IntegriCloud