summaryrefslogtreecommitdiff
path: root/sbin/pfctl
AgeCommit message (Collapse)Author
2019-01-03Unbreak build under OPT_DEBUGkn
In r1.39 I removed the `af' parameter from `unmask()' but accidently zapped the macro's closing paranthese. Since DEBUG() is needlessly under an OPT_DEBUG guard, this was not effecting normal builds. Add the missing ')' and remove the ifdef. OK sashan
2019-01-02Error out on missing table command, zap internal wrapper functionkn
Table name and table command require each other as reflected in the synopsis [-t table -T command [address ...]], so print usage and exit if only one of them is given. By moving the inter-dependence check right after option parsing is done, we can bail out even before opening pf(4) and drop the internal wrapper pfctl_command_tables() as unneeded indirection with now duplicate checks. OK sashan
2019-01-02Zap unused segment struct definitionkn
There since import and last used by ALTQ which henning removed in 2004. OK sashan
2018-12-31Explicitly mention that tables created by -T{add,replace} are persistentkn
pf.conf(5)'s TABLE section explains it, but lets be clear about it in the table command descriptions, too. "go for it" jmc
2018-12-27Zap duplicate struct declarationkn
These are in <net/pfvar.h> already. OK sashan
2018-12-21DIOCIGETIFACES provides interfaces and groups, not driverskn
"driver" is a left-over from earlier implementations. Nowadays each driver such as lo(4) has it's respective interface group of the same name ("lo"), but additional driver-independent groups exist, too: # ifconfig lo0 group foo # pfctl -s I -i foo foo lo0 OK henning
2018-11-15scrub opts dont set tos, so remove it from the scrub_opts structDavid Gwynne
ok deraadt@
2018-11-10Unbreak `-D macro=value' (r1.686 regression)kn
Zap trailing semicolon introduced with miko's cmdline_symset() leading to unconditional err(3). Zap trailing tab while here.
2018-11-07sync cmdline_symset() changes with src/usr.sbin; OK sashan@ claudio@miko
2018-11-01- odd condition/test in PF lexerAlexandr Nedvedicky
(and other lexers too) This commit rectifies earlier change: in the lex... even inside quotes, a \ followed by space or tab should expand to space or tab, and a \ followed by newline should be ignored (as a line continuation). compatible with the needs of hoststated (which has the most strict quoted string requirements), and ifstated (where one commonly does line continuations in strings). OK deraadt@, OK millert@
2018-10-15use PFR_RB_NONE consistentlykn
Replace hardcoded 0 and implicit checks with enum as done in all other use cases of `pfra_fback'. No object change. OK sashan
2018-09-18fix table commands under anchorskn
With r1.358 I simplified anchor handling but also broke semantics with regard to tables: # pfctl -a aname -t tname -T show pfctl: anchors apply to -f, -F and -s only Unbreak this by checking for table commands as well. OK bluhm
2018-09-16The kernel does not set the address family for the socket addressesAlexander Bluhm
that are used for netmask, broadcast, and destination address. In pfctl(8) take the family of the interface address and write it to the other addresses. This fixes some bugs when copy_satopfaddr() copied only part of IPv6 addresses. Print a warning if the address family is unknown. OK kn@
2018-09-16Use uid_from_user(3) and gid_from_group(3) in utilities thatTodd C. Miller
do repeated lookups. OK tb@
2018-09-13Avoid unneeded variable in gen_dynnode()kn
OK bluhm
2018-09-11Fix netmask regression in get_dynnode()kn
I introduced this error with r1.330 while removing the af parameter from unmask(). `pass inet from (lo0)/24' would result in `pass inet from (lo0)', sorry.
2018-09-11Remove unused buffer from host()kn
Left-over from pre-host_ip() times. While here, use __func__. OK henning benno
2018-09-10Merge host_v{4,6}() into simpler host_ip()kn
Except for networks such as "10/8" host_ip() now handles addresses in an AF-agnostic way with more duplicate code removed/merged. OK sashan (as for earlier copy_satopfaddr() diff) henning
2018-09-10Introduce copy_satopfaddr()kn
Move the same dance around v4/v6 for copying IP addresses from sockaddr into pf_addr to avoid duplicate code and improve readability. Feedback and OK bluhm
2018-09-08Allocate path only when needed, use __func__kn
2018-09-08Error out early on bad anchor usagekn
`pfctl -a foo' would do nothing with the non-existent anchor and exit 0. This implements behaviour as documented in pfctl(8): -a anchor Apply flags -f, -F, and -s only to the rules in the specified anchor. While here, hoist a duplicate "_" check by using the more mnemonic `mode'. OK henning sashan
2018-09-07More __func__ to fix error messageskn
2018-09-07Fix function name in error messages by using __func__kn
2018-09-07Remove wildcard address on loopack remnantskn
henning@ removed this functionality years ago, see the share/man/man4/lo.4 revision 1.27. OK jca claudio
2018-09-07Make print_hostname() less AF-specifickn
Reduce differences address families and replace strlcpy() with simpler if/else logic as done in print_addr_str(). OK sashan
2018-09-06Remove unused af argument from unmask()kn
This has been unused for years. While here, zap the duplicate function signature from pfctl.h (already present in pfctl_parser.h); spotted by sashan, thanks. OK sashan
2018-09-06Fill netmask AF-independently in print_host()kn
Instead of masking the host address in two different ways, just fill it no matter the address family. In case of AF_INET, setting the extra 96 bit does not hurt. While here, stop resetting `af' for no reason and move up the variable declaration. OK benno sashan
2018-09-05Move AF-specific mask logic from callers into set_ipmask()kn
Instead of doing the same dance with every caller, check for user provided mask or address familiy specific maximum inside the function itself. Feedback and OK claudio
2018-09-05Use error label in host_if()kn
This brings it in line with host() and host_dns(). OK sashan miko
2018-08-10Zap bits in host_v4(), use mask parameterkn
This avoids a duplicate strrchr() call and makes the function consistent with host_v6() regarding mask handling. While here, use the destination's size in memcpy instead of hardcoding its type. OK sashan
2018-07-31Zap v4mask and v6mask in host()kn
Simply defer checks whether a mask has been specified to where it's set in host_*(); this is to reduce address family specific code. OK sashan
2018-07-30Simplify host()kn
Get rid of the `cont' flag, zap obvious comments, add error label. OK benno sashan
2018-07-28Use strtonum in host()kn
This is simpler than checking three cases for `q' and gives nicer error messages. While here, use `v6mask' as maximum netmask instead of hardcoding it. OK sashan
2018-07-24Move duplicate code into new helper print_addr_str()kn
This simply puts the wiggle around inet_ntop() from four into one location. OK benno
2018-07-24Simplify getaddrinfo() error handlingkn
`error' is not used so drop it and jump to the end. OK sashan
2018-07-20Stop checking table commands for `create'kn
Tiny left over from 2003 when it was removed. Twist the logic by checking for `show' and `test' to make it even simpler. OK sashan henning
2018-07-16reduce duplicate code, fix typo/free correct bufferkn
In filteropts_to_rule(): * Merge `once' handling from `anchorrule' and `pfrule' * Remove/shorten duplicate code block * Fix typo I introduced with r1.678 that frees the wrong buffer (twice) OK sashan
2018-07-13Fix regression on child queue definitionskn
I comitted the wrong diff in 1.680 which turned `queue cq parent pq ...' into invalid syntax by changing `interface' to `ON if_item'. Found by bket, thanks!
2018-07-11Prevent invalid interface specifiers on queue ruleskn
pf.conf(5) states that queues attach to actual interfaces only, yet the following parses: # echo queue eq on egress bandwidth 1G default | pfctl -f- # pfctl -sq pfctl: DIOCGETQSTATS: Bad file descriptor # echo queue rq on rdomain 0 bandwidth 1G default | pfctl -vf- queue rq bandwidth 1G default # pfctl -sq pfctl: DIOCGETQSTATS: Bad file descriptor On rdomains, ifa_exists() returns NULL. On interface groups, ifa_exists() returns non-NULL but af is never set to AF_LINK. OK henning sashan
2018-07-11Do for most running out of memory err() what was done for most runningKenneth R Westerback
out of memory log_warn(). i.e. ("%s", __func__) instead of manual function names and redundant verbiage about which wrapper detected the out of memory condition. ok henning@
2018-07-10'set delay' for the generic packet delay mechanism, ok benno sashanHenning Brauer
2018-07-10Add "listenrepv2" for MLDv2 Listener Reports from RFC3810Jeremie Courreges-Anglas
ok benno@
2018-07-10fix anchor rules with filter opts, introduce filteropts_to_rule()kn
Some filter options were parsed but not set on anchor rules due to missing copies of the respective struct members: $ cat pf.conf queue rq on trunk0 bandwidth 1G queue dq parent rq bandwidth 1G default anchor a set queue dq $ pfctl -vnf pf.conf | fgrep queue anchor "a" all Fix this by moving common code from `anchorrule' and `pfrule' into a new helper filteropts_to_rule(). Input from henning and benno OK henning sashan jca
2018-07-09Zap dead codekn
Commented since r1.465 (2004). OK deraadt benno jca sashan
2018-07-09No need to mention which memory allocation entry point failed (malloc,Kenneth R Westerback
calloc or strdup), we just need to log that we ran out of memory in a particular function. Recommended by florian@ and deraadt@ ok benno@ henning@ tb@
2018-07-08Be consistent in warn() and log_warn() usage whenKenneth R Westerback
running out of memory. Next step, be correct *and* consistent. ok dennis@ tb@ benno@ schwarze@
2018-05-19Revert change that benno apparently commited by mistake and breaks buildMatthieu Herrb
on gcc architectures. ok florian@
2018-05-18A pf rule with a "on rdomain n" with nonexisting rdomain n will cause anSebastian Benoit
pfctl: DIOCADDRULE: Device busy error when loading the ruleset, with no information which rule caused the problem and no indication that the problem is the rdomain <nonexisting>. This diff makes pfctl check if the rdomain really exists when parsing the config. ok bluhm@
2018-05-09Fix (include file ) line number counting by keeping track of the ungetOtto Moerbeek
buffer per file; also use that buffer to expand macros. ok sashan@ dennis@ krw@
2018-04-26Plug leak in error case of the common 'varset' implementations.Kenneth R Westerback
ok benno@