summaryrefslogtreecommitdiff
path: root/sys/net/pf.c
AgeCommit message (Collapse)Author
2003-02-25- Handle src and dst comparisons correctly for binat so that it worksRyan Thomas McBride
properly in _both_ directions. - Handle skip steps properly with binat. (since we're swapping around src and dst comparisons, we can't use them in all cases) fix from dhartmei@ ok dhartmei@ henning@ cedric@
2003-02-16KNFTheo de Raadt
2003-02-12Remove commons; inspired by netbsd.Jason Wright
2003-02-12Make r.rpool.proxy_port[] a consistent byte order to match cleanup inRyan Thomas McBride
pfctl. ok dhartmei@
2003-02-12Fix a bunch of pf_route() bugs:Ryan Thomas McBride
- pass back a pointer to state created in pf_test_{tcp|udp|icmp|other}() so that pf_route()/pf_route6() can peek at it. - put the PACKET_TAG_PF_ROUTED tag onto the packets _before_ we call pf_test()/pf_test6() again to prevent looping. - Call pf_test6() in pf_route6() instead of pf_test() for obvious reasons. ok dhartmei@
2003-02-09Slightly less noisy debug printf from pf_map_addr(), ok mcbride@Daniel Hartmeier
2003-02-05Remove the confusing and more-or-less unnecessary temporaryRyan Thomas McBride
struct pf_pooladdr *cur. It was being used incorrectly in the round-robin case, which meant that the previous address was being selected, rather than the reall current one. ok dhartmei@
2003-02-01Make it build without INET6 again.Daniel Hartmeier
2003-01-31The fix introduced with 1.294 to solve issues with route-to inDaniel Hartmeier
combination with translations was too broad and broke some more complex setups (creating two states for one connection on two interfaces, using modulate state for each, and additionally using route-to/reply-to on one of them), so narrow it to the cases where it's needed. Reported by henric@.
2003-01-31Check protocol (TCP/UDP/ICMP/ICMP6) checksums of all incoming packets,Daniel Hartmeier
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. To minimize the cost of checksum calculations, mbuf flags set by network interfaces capable of hardware checksumming are honoured, and set when pf performs the calculation, so the TCP/IP stack itself will not repeat the calculation for the same packet later on. ok mcbride@ and henning@
2003-01-31Send a RST when an invalid packet matches a TCP state during theDaniel Hartmeier
handshake. Solves the issues with the "ACK+1000000 cookie scheme", which depends on RFC 763 (p39, Reset Generation, 2. non-synchronized state, "reset is sent"). ok henning@, camield@ and (I guess ;) frantzen@
2003-01-25Fix the behaviour of rdr rules which redirect to a range of ports;Ryan Thomas McBride
Stop overloading PF_OP_RRG as a flag where it doesn't make sense, and makes the port mapping more flexble, allows mapping a destination port range of one size to an other of a different size. Fixes and additional testing courtesy of dhartmei@ ok dhartmei@
2003-01-24Sigh, pf_pull_hdr (aka pf_pull_hair) doesn't do an m_pullup, it merelyDaniel Hartmeier
copies the data to the specified buffer. So, for TCP options, provide an sufficiently large buffer and copy to there.
2003-01-24Move the mbuf pullup for TCP options to the beginning of TCP handling,Daniel Hartmeier
doing it later can invalidate pointers to mbuf data. This fixes subtle breakage just introduced (with 1.306).
2003-01-24Fix wscale support, the first version didn't really work right.Daniel Hartmeier
Interestingly, our own stack uses wscale 1 quite regularly, and I now suspect that this is what caused most of the state failures I've seen. They were quite rare, but with working wscale support, they are reduced even more. ok henning@
2003-01-23Fix a bug where the kernel crashes when translating IPv6 ICMP packets.Daniel Hartmeier
This only happens when using nat/rdr/binat on IPv6 connections, which hasn't been used before, obviously. But it does work now. Reported and confirmed by evilted@efnet, ok mcbride@
2003-01-21Support for TCP window scaling (RFC 1323). ok frantzen@Daniel Hartmeier
2003-01-19format string fixesHenning Brauer
inspired by Thorsten Glaser via fries@ ok theo
2003-01-18Argh! KNF.Ryan Thomas McBride
pointed out in advance by dhartmei@
2003-01-18Make nat behave the way it used to by copying back the random source portRyan Thomas McBride
correctly. Also remove some extra cruft in pf_get_sport related to the "static-port" behaviour. bug report from mpech@ and form@ testing cedric@ "looks sane to me" henning@ ok dhartmei@
2003-01-09(whitespace) KNF, re-fold -w 80Daniel Hartmeier
2003-01-09Add support for active/inactive tablesets in the kernel.Cedric Berger
Add table definition/initialisation construct in pfctl parser. Add and fix documentation for pf.4 and pf.conf.5. Tested on i386 and sparc64 by myself, macppc by Daniel. ok dhartmei@
2003-01-07Remove table name hashing (pass the name in each ioctl instead), andDaniel Hartmeier
introduce reference counting for tables, they are now automatically created and deleted through referencing rules. Diff partly from cedric@. ok mcbride@, henning@, cedric@
2003-01-06knfTheo de Raadt
2003-01-05Move ifname from pf_addr to pf_addr_wrap, prepare pf_addr_wrap for tableDaniel Hartmeier
name. ok henning@, mcbride@, cedric@
2003-01-04move noroute from flag in pf_rule_addr into type in pf_addr_wrap.Daniel Hartmeier
ok henning@, mcbride@
2003-01-04Honour noroute in skip step calculation, found by cedric@Daniel Hartmeier
2003-01-03KNFTheo de Raadt
2003-01-02When route-to/reply-to is used in combination with address translation,Daniel Hartmeier
pf_test() may be called twice for the same packet. In this case, make sure the translation is only applied in the second call. This solves the problem with state insert failures where the second pf_test() call tried to insert another state entry after the first call's translation. ok henning@, mcbride@, thanks to Joe Nall for additional testing.
2003-01-01use a #define for the default state table sizeHenning Brauer
2003-01-01Remove skip step for action (scrub vs. non-scrub), as scrub rules areDaniel Hartmeier
stored in a separate list now. Regress tests still pass after sed "s/ a=end / /g", other skip steps are not affected.
2003-01-01Fix breakage from PF_RULESET_MAX increase, regress tests match again.Daniel Hartmeier
2002-12-31Split scrub rules out from the filter rules in the kernel.Ryan Thomas McBride
Precursor to removing rule.action from skip steps. Also a couple of other small fixes: - s/PF_RULESET_RULE/PF_RULESET_FILTER/ - replacement of 4 with PF_RULESET_MAX in pfvar.h struct ruleset { - error handling in ioctl of an invalid value in rule.action - counting evaluations and matching packets for scrub rules ok henning@ dhartmei@
2002-12-31Use a default state table limit of 10000 entries. This is safe for allDaniel Hartmeier
normal configurations, and sufficient for many. You can always increase it, if you need more concurrent states and have enough memory (65000 for 64MB RAM, for instance). Suggested earlier by henning@. ok mcbride@
2002-12-29Add support for radix tables for source and destination of PF rules.Cedric Berger
ok dhartmei@, mcbride@, henning@
2002-12-27Fixups for pf_route and pf_route6.Ryan Thomas McBride
- pull the route-to ifp from the current pf_pooladdr (not the last one) with stateful rules - remove unnecessary PF_ACPY and PF_AZERO ok dhartme@ on pf_route version, pf_route6 is the same.
2002-12-27Handle binat-anchor rules in pf_match_translation(), they don't have aDaniel Hartmeier
redirection target address. Reported by Michael Lucas. ok mcbride@
2002-12-27Initialize rt_ifp in newly allocated pf_state objects to NULL.Daniel Hartmeier
Solves the crashes in pf_route() with -current. Reports from Michael Lucas and Bjorn Runaker.
2002-12-26Prettier debug printing in pf_map_addr.Ryan Thomas McBride
2002-12-26Additional sanity checks for pf_route(). Please report when any of theseDaniel Hartmeier
panics should occur. ok mcbride@
2002-12-23Change from array to single pf_pabuf (no longer need multiple buffers asRyan Thomas McBride
we don't need the second list of addresses for DIOCCHANGE* operations) Also get rid of a bug where DIOCBEGINADDRS clears pabuf[1] when pabuf[0] is the one being used. ok henning@ dhartmei@
2002-12-22Handle rdr rules with unspecified proxy ports correctly. Also don'tRyan Thomas McBride
print the port number in pf_print_host if it's 0 (like when pf_print_host is called from pf_map_addr) ok dhartmei@
2002-12-19Replace skip step calculation so it scales O(n) instead of O(n*n).Daniel Hartmeier
Loading large rulesets consists of two phases. First, the rules are parsed and added, one by one, to the inactive ruleset. The machine remains responsive during that phase. Then, the new ruleset is activated, and the skip steps are calculated. The machine locks up during that phase. This second phase is greatly reduced with the new algorithm. With the old one, calculation could take 30s for 12k rules, with the new one, 100k rules take less than 1s. For small rulesets (less than 1000 rules), the gain is insignificant. ok mcbride@, henning@
2002-12-19fix 'no nat/rdr/binat' evaluation. from mcbride@, slightly modified :)Daniel Hartmeier
2002-12-19Initialize pf_state.nat_rule to NULL if there's no translation used.Daniel Hartmeier
Found by markus@
2002-12-18Store translation rule pointer in state entries, so pfctl -vsn can printDaniel Hartmeier
evaluation, packet, byte and state entry counters similar to -vsr. Helps verify whether/how often translation rules are evaluated/matched. ok frantzen@, henning@
2002-12-18When logging packets matched by rules within anchors, use the anchor ruleDaniel Hartmeier
(in the main set) number, not the number of the rule within the anchor. Eventually, both will get logged. But as long as we only log one number, this makes more sense.
2002-12-18big KNF roundHenning Brauer
2002-12-18Pass skip step values through ioctl interface, pfctl -vvsr shows them,Daniel Hartmeier
main purpose is making them regress-testable.
2002-12-18KNFHenning Brauer