summaryrefslogtreecommitdiff
path: root/sys/net/pf.c
AgeCommit message (Collapse)Author
2007-10-31'block return' must not send anything on blocked icmp packets.Marco Pfatschbacher
Noticed by Kai_Doernemann_at_genua.de OK henning@, deraadt@
2007-10-25Fix probability rules w/ numbers (e.g probability 0.4).Marco Pfatschbacher
Add support for probablities of 0% and 100%. With and OK deraadt@
2007-09-18allow state reuse for tcp if both sides are in FIN_WAIT_2 and a new SYNMarkus Friedl
arrives; ok dhartmei, henning, feedback aaron
2007-09-07Do not recalculate TCP payload length in pf_test_rule() as it hasAlexander Bluhm
been cached in pd->p_len. ok henning@ markus@
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-08-30handle address ranges in skip step calculationDaniel Hartmeier
2007-08-30add support for address ranges ("from 10.1.2.50 - 10.1.3.75") in from/toDaniel Hartmeier
criteria. ok mcbride@
2007-08-28showing this diff is shameful...Henning Brauer
if (r != NULL && r->rtableid >= 0) - m->m_pkthdr.pf.rtableid = m->m_pkthdr.pf.rtableid; + m->m_pkthdr.pf.rtableid = r->rtableid; fortunately it is in pf_send_tcp and thus the effect is very limited, RSTs sent due to "block return(-rst)" could be routed using the main routing table instead of an alternate one specified on the block rule. spotted by Janjaap van Velthooven <janjaap@stack.nl>
2007-08-23allow RSTs with th_seq == seqlo +- 1, reduces the amount of 'loose state'Daniel Hartmeier
messages, add 'dir=' part to 'loose state' message, ok henning@, markus@
2007-08-21don't access th_flags when it isn't available (only 8 bytes of theDaniel Hartmeier
header are required in the ICMP error). ok deraadt@, henning@
2007-07-18Don't drop outgoing packets in case of a congested input queue.Marco Pfatschbacher
OK markus@, mcbride@, "sounds reasonable" henning@
2007-07-10adjust pf_find_state_all() so that it works correctly for the new globalKurt Miller
table/state tail queue design. corrects ftp-proxy errors "server lookup failed (no rdr?)" okay henning@
2007-07-04No m_copyback for ICMP and "other" protocols on rdr/binat.Marco Pfatschbacher
Fixes ICMP packet payload corruption on rdr. OK henning@, markus@
2007-06-25pretty mechanical change: now that the state tables use seperate stateHenning Brauer
keys that can map to multiple states (last not least for ifbound) we don't need state tables hanging off each struct kif representing an interface any more. use two globals for the two tables. ok markus ryan
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-21reimplement interface bound states in a non-retarded way.Henning Brauer
previously, we had a set of state tables attached to each interface. so for every packet we had to do a lookup in the tables for the interface, and afterwards in the global tables. since we split state keys and states now, use only the global tables, and put the actual states in a tail queue attached to the state key. sort the list so that ifbound states come before global ones. on lookup, we only have to compare the interface pointer on the actual states and use the first one where either the interface matches or the state is not interface bound. thus, if you don't actually use ifbound states, and there is only one state per state key, the overhead is close to zero, where we had extra lookups before. in addition to a much cleaner design (that'll allow for more goodies later) this gives us ~12.5% more forwarding performance. mostly hacked at c2k7, lots of help, testing and ok mcbride & markus
2007-06-20Allow "log" for nat rules without "pass".Marco Pfatschbacher
OK henning@, ``passt scho'' markus@
2007-06-15in pf_test_rule, before handling IPPROTO_ICMP / IPPROTO_ICMPV6, check thatHenning Brauer
the packet is of the expected address family (AF_INET / AF_INET6). crafted IPv4 packets with IPPROTO_ICMPV6 can make us crash otherwise. misbehaviour provoked by Adrian Close <adrian@close.wattle.id.au> playing with nmap; he also helped us big time debugging the problem. thanks! ok ryan
2007-06-09fix wrong argument passing to m_copyback for the log caseHenning Brauer
(&ptr instead of ptr). should fix pflog breakage seen by bob
2007-06-09sizeof(ptr) is no good if you want sizeof(*ptr). icmp/icmpv6.Henning Brauer
2007-06-02pf_set_rt_ifp accesses state key data, so must be called laterHenning Brauer
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-06-01fold pf_test_tcp(), pf_test_udp(), pf_test_icmp(), pf_test_other() intoHenning Brauer
one - pf_test_rule(). now we have one place to make things clearer and maybe find another few performance bits :) shrinks i386 GENERIC by 11K, no measurable performance impact or gain. lots lots lots lots lots of testing and headbanging with ryan, performance testing ckuethe. ok ryan
2007-06-01apply the "skip ipsec if there are no flows" speedup diff to IPv6 too.Henning Brauer
we need a pointer to the inpcb to decide, which was not previously passed to ip6_output, so this diff is a little bigger. from itojun, ok ryan
2007-05-31Move the state id and creatorid (used mainly by pfsync) into struct pf_state.Ryan Thomas McBride
ok henning@
2007-05-31Unbreak pf.c compilation on gcc 2.95 architectures. Found by todd@Ryan Thomas McBride
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-29gain us another 10+% of performance.Henning Brauer
boring details: long time ago (in r1.313) code was added to handle protocol checksums: > Check protocol (TCP/UDP/ICMP/ICMP6) checksums of all incoming packets, > and drop packets with invalid checksums. Without such a check, pf would > return RST/ICMP errors even for packets with invalid checksums, which > could be used to detect the presence of the firewall, reported by > "Ed White" in http://www.phrack.org/phrack/60/p60-0x0c.txt. that meant we did the checksumming for each and every packet traversing pf. now only do the checksumming right before we send an RST back, so in all other cases we save that work. ok bob theo
2007-05-28double pf performance.Henning Brauer
boring details: pf used to use an mbuf tag to keep track of route-to etc, altq, tags, routing table IDs, packets redirected to localhost etc. so each and every packet going through pf got an mbuf tag. mbuf tags use malloc'd memory, and that is knda slow. instead, stuff the information into the mbuf header directly. bridging soekris with just "pass" as ruleset went from 29 MBit/s to 58 MBit/s with that (before ryan's randomness fix, now it is even betterer) thanks to chris for the test setup! ok ryan ryan ckuethe reyk
2007-05-27get rid of static.David Gwynne
ok claudio@ reyk@ henning@ ja ja ja mcbride@
2007-05-27clarify things by passing kif->pfik_ifp around in pf_test{,6} insteadPierre-Yves Ritschard
of reassigning a struct ifnet pointer. discussed with and ok mcbride@
2007-05-26add comments indicating why we do m = *m0; again after pf_normalize, ryan okHenning Brauer
2007-05-08block ALL packets with rthdr0 in pf_test6(). We already do thisRyan Thomas McBride
in ip6_input(), but pf_test6() is called from bridge code as well. ok dhartmei@ henning@ deraadt@ claudio@
2007-05-08Routing headers are dangerous. Deal with them the same way as IPv4 options:Ryan Thomas McBride
drop all packets with routing headers unless the matching rule explicitly specifies 'allow-opts'. ok dhartmei@ henning@ deraadt@ claudio@
2007-02-22make urpf-failed work with multipath routes.Pierre-Yves Ritschard
ok claudio@
2007-02-19add handling of skip steps for urpf-failed addresses.Pierre-Yves Ritschard
ok dharthmei@, henning@
2007-02-14Consistently spell FALLTHROUGH to appease lint.Jonathan Gray
ok kettenis@ cloder@ tom@ henning@
2007-02-08compute pseudo-header checksum based on flnal destination asJun-ichiro itojun Hagino
ip6_dst (i'm bit skeptical about checksumming when the box is not the final destination). drop IPv6 jumbograms, as it could cause various funny symptoms due to ip6_plen being 0 (yup, we should properly handle it instead). ok by deraadt, naddy, hshoexer
2006-12-22add special handling for "urpf-failed" with carp interfaces. theReyk Floeter
unicast reverse path forwarding (URPF) check drops packets coming in on an interface other than that which holds the route back to the packet's source address. this caused problems with routes bound to a carp interface instead of the underlying interface. this diff validates the underlying carpdev if the route is bound to a carp interface. from Pierre-Yves Ritschard (pyr at spootnik.org) ok henning@
2006-12-21in pf_route(), initialize ro to NULL at the beginning. if left un-Daniel Hartmeier
initialized, it might equal &iproute by chance, causing a panic when rtfree() is then mistakenly called.
2006-12-14in "BAD/loose state" messages, also print the packet's original sequenceDaniel Hartmeier
number, it can differ from the sequence number being tested (for packets without payload), and both matter in explaining why a packet mismatched.
2006-12-13use IN6_IS_SCOPE_EMBED to check kernel-internal form addressesJun-ichiro itojun Hagino
(s6_addr16[1] filled) ok dhartmei
2006-11-16conditional for appending the pf mbuf tag in pf_test/pf_test6 was wrong,Henning Brauer
we need to do so whenever we do have a (pf) tag != 0 on the state OR (that part was missing) when rtableid on the rule is nonzero. problem noticed by Andreas Lundin <lunde@dreamhosted.se> testing the multiple routing tables enabling diff, ok mcbride
2006-10-31make pfsync a clonable too, but prevent more than one instance fromHenning Brauer
beeing created for now - much more work would be required to change that input & ok ryan
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-11Allow the 'quick' keyword on an anchor. IFF there is a matching rule insideRyan Thomas McBride
the anchor, terminate ruleset evaluation when stepping out of the anchor. This means that if you absolutely want the anchor to be terminal, you probably want to use a 'block all' or 'pass all' rule at the start of the anchor. ok dhartmei@ henning@ deraadt@
2006-09-18allow RST from TCP client, even if client does not send data after SYN;Markus Friedl
ok frantzen, dhartmei, henning
2006-09-18fix tos (type-of-service) comparisons. for rules which use 'tos x', compareDaniel Hartmeier
for equality (ip_tos == x). for priority queue assignment, compare AND-wise (ip_tos & IPTOS_LOWDELAY). this matters mostly for cases where the reserved bits in ip_tos are used (RFC791, 1349) and more than a single bit is set. from Steve Welham, closes PR5226 and PR5227.
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-17missing rtlabel support in pf_addr_wrap_neq()Henning Brauer
PR5122 Jann Fischer <jfi@openbsd.de>, thanks!