summaryrefslogtreecommitdiff
path: root/sys/net/pf.c
AgeCommit message (Collapse)Author
2009-06-26invert direction for inner icmp state lookups (e.g. traceroute with icmp)Markus Friedl
ok henning, jsing
2009-06-22Check that the address family is appropriate before processing ICMPv4 andJoel Sing
ICMPv6 messages. ok henning@
2009-06-22Always drop ICMPv6 in IPv4 datagrams, not only when compiled with INET6.Joel Sing
Suggested by Max Laier. ok henning@
2009-06-22Fix scrub max-mss for IPv6 traffic.Joel Sing
spotted by naddy@ ok henning@
2009-06-08in pf_print_state_parts, do not use skw->proto to print the protocolHenning Brauer
but our local copy proto that we very carefully set beforehands. skw being NULL is perfectly valid there.
2009-06-08"do not call PF_ANEQ with af=0, dragons". fixes a problem with skipStuart Henderson
steps found with the recent pfvar.h commit to check address families. from & commit req by henning.
2009-06-05Initial support for routing domains. This allows to bind interfaces toClaudio Jeker
alternate routing table and separate them from other interfaces in distinct routing tables. The same network can now be used in any doamin at the same time without causing conflicts. This diff is mostly mechanical and adds the necessary rdomain checks accross net and netinet. L2 and IPv4 are mostly covered still missing pf and IPv6. input and tested by jsg@, phessler@ and reyk@. "put it in" deraadt@
2009-05-18The routing table index rtableid has type unsigned int in the routingAlexander Bluhm
code. In pf rtableid == -1 means don't change the rtableid because of this rule. So it has to be signed int there. Before the value is passed from pf to route it is always checked to be >= 0. Change the type to int in pf and to u_int in netinet and netinet6 to make the checks work. Otherwise -1 may be used as an array index and the kernel crashes. ok henning@
2009-04-30treat log as what it is, a flag variable. effectively a noop now but stopsHenning Brauer
us relying on where we are setting it. ok ryan dlg
2009-04-23print the type of the icmp message we're bitching about when debugging isDavid Gwynne
turned up in pf_icmp_state_lookup. ok sthen@
2009-04-17move the lastr = r assignment behind the anchor rule check so we don'tHenning Brauer
ever try to aplly options from the anchor rule if it was the last matching one but the last matching real rule. it is right but despite begging nobody has the balls to ok it ;(
2009-04-15little dose of scrubbing after the monster changes:Henning Brauer
correctly inherit queue stuff, tag, rtableid from the rule if we have no state some logic simplification and removal of redundant checks ok dlg
2009-04-15move OK ICMP to NOISY level, makes it easier to run at MISC level; ok henning@David Krause
2009-04-14Correctly handle the case when state might be NULL in pf_test likeAlexander Yurchenko
all other code do. Should fix pr 6121. ok henning@
2009-04-11Avoid dereferencing a null pointer when pf attempts to translate aJoel Sing
specifically crafted IP datagram. Problem noted by Sebastian Rother. ok henning@ mcbride@ sthen@
2009-04-061) scrub rules are completely gone.Henning Brauer
2) packet reassembly: only one method remains, full reassembly. crop and drop-ovl are gone. . set reassemble yes|no [no-df] if no-df is given fragments (and only fragments!) with the df bit set have it cleared before entering the fragment cache, and thus the reassembled packet doesn't have df set either. it does NOT touch non-fragmented packets. 3) regular rules can have scrub options. . pass scrub(no-df, min-ttl 64, max-mss 1400, set-tos lowdelay) . match scrub(reassemble tcp, random-id) of course all options are optional. the individual options still do what they used to do on scrub rules, but everything is stateful now. 4) match rules "match" is a new action, just like pass and block are, and can be used like they do. opposed to pass or block, they do NOT change the pass/block state of a packet. i. e. . pass . match passes the packet, and . block . match blocks it. Every time (!) a match rule matches, i. e. not only when it is the last matching rule, the following actions are set: -queue assignment. can be overwritten later, the last rule that set a queue wins. note how this is different from the last matching rule wins, if the last matching rule has no queue assignments and the second last matching rule was a match rule with queue assignments, these assignments are taken. -rtable assignments. works the same as queue assignments. -set-tos, min-ttl, max-mss, no-df, random-id, reassemble tcp, all work like the above -logging. every matching rule causes the packet to be logged. this means a single packet can get logged more than once (think multiple log interfaces with different receivers, like pflogd and spamlogd) . almost entirely hacked at n2k9 in basel, could not be committed close to release. this really should have been multiple diffs, but splitting them now is not feasible any more. input from mcbride and dlg, and frantzen about the fragment handling. speedup around 7% for the common case, the more the more scrub rules were in use. manpage not up to date, being worked on.
2009-03-15Introduce splsoftassert(), similar to splassert() but for soft interruptMiod Vallat
levels. This will allow for platforms where soft interrupt levels do not map to real hardware interrupt levels to have soft ipl values overlapping hard ipl values without breaking spl asserts.
2009-03-14Some ICMP types that also have icmp_id, pointed out by markus@Ryan Thomas McBride
ok henning markus
2009-03-09Make the DIOCSETIFFLAG, DIOCSETLIMIT, and DIOCSETTIMEOUT ioctlsRyan Thomas McBride
transactional, closing PRs 4941 and 5910. Minor flag day, requires rebuild of userland tools that use struct pfi_kif. ok henning deraadt
2009-03-07Make sure pd2 has a pointer to the icmp header in the payload; fixesRyan Thomas McBride
panic seen with some some icmp types in icmp error message payloads. Reported by david@ and insan.praja@gmail.com
2009-03-05Stricter state checking for ICMP and ICMPv6 packets: include the ICMP typeRyan Thomas McBride
in one port of the state key, using the type to determine which side should be the id, and which should be the type. Also: - Handle ICMP6 messages which are typically sent to multicast addresses but recieve unicast replies, by doing fallthrough lookups against the correct multicast address. - Clear up some mistaken assumptions in the PF code: - Not all ICMP packets have an icmp_id, so simulate one based on other data if we can, otherwise set it to 0. - Don't modify the icmp id field in NAT unless it's echo - Use the full range of possible id's when NATing icmp6 echoy ok henning marco testing matthieu todd
2009-02-27fix quick reuse of tcp states.Henning Brauer
when we, for a new state, hit an existing tcp state which is in FIN_WAIT_2 on both ends do not fail but insert the new state anyway and unlink the old one afterwards. pimp error message a bit, too. problem found with NAT by viq <viq@viq.ath.cx> ok theo markus
2009-02-16pfsync v5, mostly written at n2k9, but based on work done at n2k8.David Gwynne
WARNING: THIS BREAKS COMPATIBILITY WITH THE PREVIOUS VERSION OF PFSYNC this is a new variant of the protocol and a large reworking of the pfsync code to address some performance issues. the single largest benefit comes from having multiple pfsync messages of different types handled in a single packet. pfsyncs handling of pf states is highly optimised now, along with packet parsing and construction. huggz for beck@ for testing. huge thanks to mcbride@ for his help during development and for finding all the bugs during the initial tests. thanks to peter sutton for letting me get credit for this work. ok beck@ mcbride@ "good." deraadt@
2009-01-30sync the part copied from ip_output: always initialize IP checksumChristian Weisgerber
to zero for checksum offload; ok henning@
2009-01-30sprinkle splassert(IPL_SOFTNET) around the code that inserts, unlinks, andDavid Gwynne
frees pf states. ok mcbride@
2009-01-29Split the address selection from pools away from pf.c and put it inPierre-Yves Ritschard
pf_lb.c. This will ease the process of adding more selection types without bloatening pf.c even more. ok and a weird death threat, henning@ raised eyebrow, dlg@
2009-01-27If a packet translation was a NOP, undo separate NAT key andMarco Pfatschbacher
pretend there was no match. This prevents pf_state_insert() to fail with duplicate keys. OK henning@, mcbride@
2009-01-16In pf_test_rule(), if we don't create a state, free any state keys thatDavid Krause
may have been allocated earlier by pf_get_translation(). Fixes a pf_state_key_pl leak triggered by certain ICMP types matching a NAT rule. Finally located with the help of pool_walk(). ok henning@ dlg@ mcbride@
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-11-21Change rn_mpath_next() to be able to walk over the full multipath listClaudio Jeker
not only over routes of the same prio. This makes it possible to modify rt_mpath_matchgate() so that if only gateway is specified without a specific priority it will scan the full list and not only the first routes. This is also needed for upcoming link state tracking.
2008-10-28Always skip "urpf-failed" test for IPv6 link local addresses.Marco Pfatschbacher
We could re-embed the scope-id before we do the route lookup, but then we would just find the very interface we've received the packet on anyway. OK markus@, claudio@, henning@
2008-10-23use the correct idiom for NFOO things which come from "foo.h" filesTheo de Raadt
ok dlg
2008-10-02When redirect is used with sticky-address and a matching pass rule usesJoel Sing
reply-to, the sticky-address in the source tracking pool is overwritten with the reply-to address, resulting in new connections being incorrectly redirected to the reply-to host (instead of the sticky-address host). Prevent this by passing a NULL source node reference to pf_map_addr() when looking up the reply-to host, thus preventing the NAT source node from being overwritten. ok mcbride@ henning@
2008-09-28Teach PF pf_print_state_parts() about IPv4 in IP and IPv6 in IPJoel Sing
encapsulation. Decapitalise the 'v' in ICMPv6 whilst here. ok henning@
2008-09-17remove dead stores and newly created unused variables.Charles Longeau
fix potential use of uninitialized value in trunk_port_ioctl() function. Found by LLVM/Clang Static Analyzer. ok mpf@ henning@
2008-09-10re-enable the state key linking. i believe the bugs that hit us shortlyHenning Brauer
before release are fixed, and the extra check i added prevents incorrect linking if there are still cases with tunnels, tho none of the testers saw these yet, except for an icmp case that will be fixed shortly. the extra check prevents misbehavior there. if you see 'pf: state key linking mismatch' messages please report them to me along with ifconfig -A and mention if you do any routing or nat tricks. ok deraadt
2008-09-09welcome pflow(4), a netflow v5 compatible flow export interface.Henning Brauer
flows export data gathered from pf states. initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many changes by me. 'put it in' theo
2008-09-03before linking state keys compare them to verify they actually are theHenning Brauer
exact reverse of each other. if there is a mismatch don't erstablish the link and print enough so that we should be able to find the culprit.
2008-09-02remove dead stores and newly created unused variables.Charles Longeau
Found by LLVM/Clang Static Analyzer. ok henning@ mpf@
2008-08-26introduce a function to be called when addressing information has changed,Henning Brauer
pf_pkt_addr_changed. atm just clears the state key pointer. calling this is cleaner than having other parts of the stack clearing pointers in the pf part of the mbuf packet header directly.
2008-08-22Make pf_print_host() print IPv6 addresses correctly.Alexander Bluhm
ok mpf
2008-08-02do not write the pf state key pointer to the pkhdr.Henning Brauer
effectively disables state key linking and pcb linking - unfortunatly, there seems to be a bug somewhere in there or triggered by it that we haven't tracked down yet, so we disable this for now to be on the safe side for release. lots of testing and analysis from todd and david.
2008-07-22after pf_state_key_atach nothing must use the state keys passed to it anyHenning Brauer
more, since they might have been invalidated and free'd. one synproxy errorpath did so, however. just get the state keys from the state itself. ok david mcbride
2008-07-21some whitespace cleanup I did while looking through the codeDavid Krause
ok mcbride@ henning@
2008-07-21fix typo that broke rdr rules (without pass) with non-TCP/UDP/ICMP protocolsDavid Krause
ok mcbride@ henning@
2008-07-14m_copy can return NULL, so check for itHenning Brauer
problem found by "Adrian M. Whatley" <amw> and "Stephan A. Rickauer" <stephan.rickauer>, both @ni.phys.ethz.ch fix by me, ok mpf
2008-07-10check pf NAT source port allocation against net.inet.(tcp|udp).baddynamicDamien Miller
lists; prevents use of ports corresponding to well-known services. replace a couple of arc4random()%N with arc4random_uniform(N) that missed the first round. ok mcbride@
2008-07-10In pf_state_insert(), if the first pf_state_key_attach() fails, theDavid Krause
state key is freed by pf_state_key_attach(). But in the case of NAT, there are two state keys allocated, so we must free the second key manually. Fixes a pf_state_key_pl leak seen in certain cases with pfsync or with pf state-insert errors. ok mcbride@ henning@
2008-07-05in pf_state_key_attach(), when there is already an existing state key thatDavid Krause
can be used and we return the state key back to the pool, don't insert state items into the tailq using that garbage state key. this makes things much happier for me. ok henning@
2008-07-04in pf_state_key_attach(), when we find that there already is a state keyHenning Brauer
that we can attach the state to, make sure to not overwrite the state key pointer in the state that was just set to the existing state key with the state key that was supplied with the state and just free'd (well, pool_put'd). by the time we clean up the state and try to follow it to RB_REMOVE etc we'd follow that garbage pointer to either an unrelated state key or the old state key still sitting unused in the pool. should fix the RB_REMOVE panics some people have been seeing. "clearly ok, please commit" ryan