de240d1013
and remove all O(N) sequences from kernel critical sections in ipfw. In detail: 1. introduce a IPFW_UH_LOCK to arbitrate requests from the upper half of the kernel. Some things, such as 'ipfw show', can be done holding this lock in read mode, whereas insert and delete require IPFW_UH_WLOCK. 2. introduce a mapping structure to keep rules together. This replaces the 'next' chain currently used in ipfw rules. At the moment the map is a simple array (sorted by rule number and then rule_id), so we can find a rule quickly instead of having to scan the list. This reduces many expensive lookups from O(N) to O(log N). 3. when an expensive operation (such as insert or delete) is done by userland, we grab IPFW_UH_WLOCK, create a new copy of the map without blocking the bottom half of the kernel, then acquire IPFW_WLOCK and quickly update pointers to the map and related info. After dropping IPFW_LOCK we can then continue the cleanup protected by IPFW_UH_LOCK. So userland still costs O(N) but the kernel side is only blocked for O(1). 4. do not pass pointers to rules through dummynet, netgraph, divert etc, but rather pass a <slot, chain_id, rulenum, rule_id> tuple. We validate the slot index (in the array of #2) with chain_id, and if successful do a O(1) dereference; otherwise, we can find the rule in O(log N) through <rulenum, rule_id> All the above does not change the userland/kernel ABI, though there are some disgusting casts between pointers and uint32_t Operation costs now are as follows: Function Old Now Planned ------------------------------------------------------------------- + skipto X, non cached O(N) O(log N) + skipto X, cached O(1) O(1) XXX dynamic rule lookup O(1) O(log N) O(1) + skipto tablearg O(N) O(1) + reinject, non cached O(N) O(log N) + reinject, cached O(1) O(1) + kernel blocked during setsockopt() O(N) O(1) ------------------------------------------------------------------- The only (very small) regression is on dynamic rule lookup and this will be fixed in a day or two, without changing the userland/kernel ABI Supported by: Valeria Paoli MFC after: 1 month |
||
---|---|---|
.. | ||
atm | ||
bluetooth | ||
netflow | ||
netgraph.h | ||
ng_async.c | ||
ng_async.h | ||
ng_atmllc.c | ||
ng_atmllc.h | ||
ng_base.c | ||
ng_bpf.c | ||
ng_bpf.h | ||
ng_bridge.c | ||
ng_bridge.h | ||
ng_car.c | ||
ng_car.h | ||
ng_cisco.c | ||
ng_cisco.h | ||
ng_deflate.c | ||
ng_deflate.h | ||
ng_device.c | ||
ng_device.h | ||
ng_echo.c | ||
ng_echo.h | ||
ng_eiface.c | ||
ng_eiface.h | ||
ng_etf.c | ||
ng_etf.h | ||
ng_ether_echo.c | ||
ng_ether_echo.h | ||
ng_ether.c | ||
ng_ether.h | ||
ng_fec.c | ||
ng_fec.h | ||
ng_frame_relay.c | ||
ng_frame_relay.h | ||
ng_gif_demux.c | ||
ng_gif_demux.h | ||
ng_gif.c | ||
ng_gif.h | ||
ng_hole.c | ||
ng_hole.h | ||
ng_hub.c | ||
ng_hub.h | ||
ng_iface.c | ||
ng_iface.h | ||
ng_ip_input.c | ||
ng_ip_input.h | ||
ng_ipfw.c | ||
ng_ipfw.h | ||
ng_ksocket.c | ||
ng_ksocket.h | ||
ng_l2tp.c | ||
ng_l2tp.h | ||
ng_lmi.c | ||
ng_lmi.h | ||
ng_message.h | ||
ng_mppc.c | ||
ng_mppc.h | ||
ng_nat.c | ||
ng_nat.h | ||
ng_one2many.c | ||
ng_one2many.h | ||
ng_parse.c | ||
ng_parse.h | ||
ng_pipe.c | ||
ng_pipe.h | ||
ng_ppp.c | ||
ng_ppp.h | ||
ng_pppoe.c | ||
ng_pppoe.h | ||
ng_pptpgre.c | ||
ng_pptpgre.h | ||
ng_pred1.c | ||
ng_pred1.h | ||
ng_rfc1490.c | ||
ng_rfc1490.h | ||
ng_sample.c | ||
ng_sample.h | ||
ng_socket.c | ||
ng_socket.h | ||
ng_socketvar.h | ||
ng_source.c | ||
ng_source.h | ||
ng_split.c | ||
ng_split.h | ||
ng_sppp.c | ||
ng_sppp.h | ||
ng_tag.c | ||
ng_tag.h | ||
ng_tcpmss.c | ||
ng_tcpmss.h | ||
ng_tee.c | ||
ng_tee.h | ||
ng_tty.c | ||
ng_tty.h | ||
ng_UI.c | ||
ng_UI.h | ||
ng_vjc.c | ||
ng_vjc.h | ||
ng_vlan.c | ||
ng_vlan.h | ||
NOTES |