summaryrefslogtreecommitdiff
path: root/sys/net/pf_ioctl.c
AgeCommit message (Collapse)Author
2009-02-15Revert previous.Marc Balmer
2009-02-15Fix compilation of kernels that have pf, but not pfsync.Marc Balmer
ok dlg, henning, sthen
2008-11-24Fix splasserts seen in pr 5987 by propagating a flag that discribesMike Belopuhov
whether we're called from the interrupt context to the functions performing allocations. Looked at by mpf@ and henning@, tested by mpf@ and Antti Harri, the pr originator. ok tedu
2008-10-23use the correct idiom for NFOO things which come from "foo.h" filesTheo de Raadt
ok dlg
2008-06-29Simplify state creation code; merge state import/export code between pfsyncRyan Thomas McBride
and the state-related pf(4) ioctls, and make functions in state creation and destruction paths more robust in error conditions. All values in struct pfsync_state now in network byte order, as with pfsync. testing by david ok henning, systat parts ok canacar
2008-06-22Revert 1.203; it's not safe to blindly walk the tailq instead of the rbtreeRyan Thomas McBride
for picking states to unlink as the tailq may contain unlinked states.
2008-06-14Include "pflog.h" so that we get NPFLOG.Joel Sing
ok henning@
2008-06-14pool_get()s not in interrupt context should not be PR_NOWAIT, butHenning Brauer
PR_WAITOK | PR_LIMITFAIL. from discussion with art. ok ryan claudio thib
2008-06-11Split address setup operations into a separate function. More to come.Ryan Thomas McBride
ok henning
2008-06-10Simplify code slightly; use PR_ZERO with pool_get() rather than bzero().Ryan Thomas McBride
ok mpf henning
2008-06-10when walking the entire state table it makes much more sense to walkHenning Brauer
the tailq instead of the rb tree. pt out by kjell some time ago, ok ryan
2008-06-10save somespace in the state by collapsing two 8 bit ints used as booleansHenning Brauer
into one 8 bit flags field. shrinks the state structure by 4 bytes on 32bit archs ryan ok
2008-06-10implement a sloppy tcpstate tracker which does not look at sequenceHenning Brauer
numbers at all. scary consequences; only tobe used in very specific situations where you don't see all packets of a connection, e. g. asymmetric routing. ok ryan reyk theo
2008-05-30trivial KNF before we go furtherHenning Brauer
2008-05-29Second half of PF state table rearrangement.Ryan Thomas McBride
- Mechanical change: Use arrays for state key pointers in pf_state, and addr/port in pf_state_key, to allow the use of indexes. - Fix NAT, pfsync, pfctl, and tcpdump to handle the new state structures. In struct pfsync_state, both state keys are included even when identical. - Also fix some bugs discovered in the existing code during testing. (in particular, "block return" for TCP packets was not returning an RST) ok henning beck deraadt tested by otto dlg beck laurent Special thanks to users Manuel Pata and Emilio Perea who did enough testing to actually find some bugs.
2008-05-29rewrite the state table logic.Henning Brauer
complete the split off of the layer 3/4 adressing information from the extra information in the actual state. a state key holds a list of states, and a state points to two state keys - they're only different in the NAT case. More specificially, it deprecates the (often difficult to understand) concept of lan, ext, and gwy addresses, replacing them with WIRE and STACK side address tuples. (af, proto, saddr, daddr, sport, dport). Concept first brought up some years ago on a ferry ride in bc by ryan and me, I spent some time over the last year getting closer, and finally got it completed in japan with ryan. dlg also took part, helped a lot, and saved us 8 bytes. This commit removes support for any kind of NAT as well as pfsync. It also paves the road for some code simplification and some very cool future stuff. ok ryan beck, tested by many
2008-05-18KNFRyan Thomas McBride
2008-05-09Add support to kill states by rule label or state id.Marco Pfatschbacher
Fix printing of the state id in pfctl -ss -vv. Remove the psnk_af hack to return the number of killed states. OK markus, beck. "I like it" henning, deraadt. Manpage help from jmc.
2008-05-06Add a counter to record how many states have been created by a rule.Marco Pfatschbacher
It shows up in pfctl verbose mode and in the 7th field of the labels output. Also remove the label printing for scrub rules, as they do not support labels. OK dhartmei@ (on an earlier version), henning@, mcbride@
2008-05-06Prevent possible overflow of int variable on large memory machines.Tobias Weingartner
ok kettenis@
2007-12-02DIOC{GET,ADD}STATE incorrectly use a user provided pointer without usingChristopher Pascoe
copyin/out. Change the API so that the state is included in the ioctl argument, so the ioctl wrappers take care of copying memory as appropriate. Also change the DIOCGETSTATE API to be more useful. Instead of getting an arbitrarily "numbered" state (using numbering that can change between calls), instead search based on id and creatorid. If you want to monitor only a particular state, you can now use the bulk functions first to find the appropriate id/creatorid and then fetch it directly from then on. ok dlg@ henning@
2007-12-02When pf_insert_state state succeeds, increase the state count on theChristopher Pascoe
default rule. When pf_insert_state fails, it's because a matching state already exists. Return a better error code to the user in this case. ok henning@ dlg@
2007-12-02initialize altq->altq_disc to NULL, from Max LaierDaniel Hartmeier
2007-12-02Don't put state key if pf_insert_state fails. pf_detach_state would haveChristopher Pascoe
put it for us already. Also, fix cut-n-paste error in previous commit. ok dlg@ henning@
2007-12-02Don't leak state if key allocation fails during add.Christopher Pascoe
ok dlg@ henning@
2007-12-02Set expiry timestamp when importing a state, otherwise it expires on theChristopher Pascoe
next expiry run. ok dlg@ henning@
2007-12-02DIOCADDSTATE would always dereference a NULL pointer during this copyChristopher Pascoe
and what it was copying would get overwritten anyway. Remove the copy and avoid a panic. DIOCGETSTATE would incorrectly dereference a pointer to a pointer, causing another panic. Fix this.
2007-09-27Add loginterface support for groups.Marco Pfatschbacher
Using a group sums up the statistics of all members. Modify pfctl(1) slightly to allow a groupname "all", which gives us an overall pf(4) statistic. OK henning@, markus@
2007-09-15malloc sweep:Henning Brauer
-remove useless casts -MALLOC/FREE -> malloc/free -use M_ZERO where appropriate instead of seperate bzero feedback & ok krw, hshoexer
2007-09-01replace the machine dependant bytes-to-clicks macro by the MI ptoa()Martin Reindl
version for i386 more architectures and ctob() replacement is being worked on prodded by and ok miod
2007-08-30mechanic change:Henning Brauer
there is a 1:1 mapping between direction and the tree the states get attached to. there is no need to have anything outside the state insertion/ deletion/lookup routinbes know about these internals. so just pass the direction to the lookup functions and let them pick the right tree. ok dhartmei markus
2007-06-24Save some bytes and make code more readable by removing junk union andRyan Thomas McBride
unused ifname (this information is in struct pf_state_sync now). Also a bit of KNF on the pf_state struct. ok mpf@ henning@
2007-06-21force logif to zero if no logging is asked forHenning Brauer
check the logif when changing a rule from max laier, ok ryan
2007-06-07PR 5502 From: Marc Huber <Marc.Huber@web.de>Henning Brauer
pfioctl()'s DIOCKILLSTATES triggers panic due to wrong test variable in for() loop. well analyzed and fixed, excellent PR, applied verbatim, thanks! (this was fallout from the state - state key split)
2007-06-01factor out duplicated code to allocate state key and cross-reference itHenning Brauer
with a state entry into a new pf_alloc_state_key() function and use it everywhere. makes upcoming changes way easier and is cleaner anyway. conceptually agreed by ryan, but he's on the road now ;(
2007-05-31Move the state id and creatorid (used mainly by pfsync) into struct pf_state.Ryan Thomas McBride
ok henning@
2007-05-31First step of rearranging pf's state table internals...Ryan Thomas McBride
- Split pf_state into pf_state (used for tracking connection information), and pf_state_key (used for searching the state table) - Use pfsync_state in the ioctl for userland access to the state table. This will sheild userland somewhat from future changes. ok henning@ toby@ pyr@
2007-05-29Add a name argument to the RWLOCK_INITIALIZER macro.Thordur I. Bjornsson
Pick reasonble names for the locks involved.. ok tedu@, art@
2007-02-26because sparc has variable pagesize, ctob() varies between machines, and weTheo de Raadt
need uvm/uvm_extern.h to get at uvmexp. oops.
2007-02-23if machine has more than 100MB of physmem, default the max table entriesTheo de Raadt
to 200,000 instead of the conservative 100,000; ok dhartmei beck tested by ckuethe
2007-02-09allow counters to be reset with DIOCGETRULES.Henning Brauer
this allows an atomic read and reset counters, instead of read, reset in a later ioctl and lose everything in between. use the previously unused of pr->action. When it is set to PF_GET_CLR_CNTR, the ioctl requires write permissions and counters are reset after they have been copied out to userland. obsoletes DIOCCLRRULECTRS, which only works for the main ruleset, but not within anchors (yeah, that's how it all started) ok dhartmei, mcbride and theo agree as well
2006-11-20ioctl to explicitly remove source tracking nodes,Ryan Thomas McBride
diff from Berk D. Demir <bdd@mindcast.org> ok henning dhartmei
2006-10-27Split ruleset manipulation functions out into pf_ruleset.c to allow them toRyan Thomas McBride
be imported into pfctl. This is a precursor to separating ruleset parsing from loading in pfctl, and tons of good things will come from it. 2 minor changes aside from cut-n-paste and #define portability magic: - instead of defining the global pf_main_ruleset, define pf_main_anchor (which contains the pf_main_ruleset) - allow pf_find_or_create_ruleset() to return the pf_main_ruleset if it's passed an empty anchor name. ok henning dhartmei
2006-10-25add a "u_int8_t logif" to struct pfrule to select to which pflog interfaceHenning Brauer
logs go. ok mcbride
2006-08-30allow DIOCNATLOOK to look up NAT states for protocols without portDamien Miller
numbers, reported by Raja Subramanian; ok henning@
2006-07-21fix a bug in the input sanity check of DIOCCHANGERULE (not used by pfctl,Daniel Hartmeier
but third-party tools). a rule must have a non-empty replacement address list when it's a translation rule but not an anchor call (i.e. "nat ... ->" needs a replacement address, but "nat-anchor ..." doesn't). the check confused "rule is an anchor call" with "rule is defined within an anchor". report from Michal Mertl, Max Laier.
2006-07-06allow rules to point to an alternate routing table, and tag packetsHenning Brauer
matching that rule so that the forwarding code later can use the alternate routing table fo lookups (not implemented yet). the tagging is "sticky", every matching rule modifies, just like the regular "tag". ok claudio hshoexer, hacked at r2k6
2006-05-28Enable adaptive timeouts by default, with adaptive.start of 60% of theRyan Thomas McBride
state limit and adaptive.end of 120% of the state limit. Explicitly setting the adaptive timeouts will override the default, and it can be disabled by setting both adaptive.start and adaptive.end to 0. ok henning@
2006-03-04With the exception of two other small uncommited diffs this movesBrad Smith
the remainder of the network stack from splimp to splnet. ok miod@
2006-01-06DIOCNATLOOK was forgotten in the second access control switch. it's aDaniel Hartmeier
read-only operation (looking up one state entry), so allow it when /dev/pf is opened read-only (allows squid to work read-only). from Andrey Matveev.