Commit graph

279 commits

Author SHA1 Message Date
Cy Schubert 95daf09d07 ipfilter: Move userland bits to sbin
Through fixes and improvements our ipfilter sources have diverged
enough to warrant move from contrib into sbin/ipf. Now that I'm
planning on implementing MSS clamping as in iptables it makes more
sense to move ipfilter to sbin.

This is the second of three commits of the ipfilter move.

Suggested by glebius on two occaions.

Suggested by and discussed with:	glebius
Reviewed by:				glebius, kp (for #network)
Differential Revision:		https://reviews.freebsd.org/D33510

(cherry picked from commit 41edb306f0)
2022-02-07 05:51:14 -08:00
Cy Schubert 324dbffbb4 ipfilter userland: Revert the ipmon part of a6fb9bbea7
a6fb9bbea7 caused incorrect formatting of ipmon log output.

Fixes:		a6fb9bbea7

(cherry picked from commit d740faa30a)
2021-12-27 01:20:41 -08:00
Cy Schubert ee680288bc ipfilter: MSN RPC proxy is not complete
The MSN RPC proxy is incomplete and does not do any address
translation. Remove it.

(cherry picked from commit c610426c4d)
2021-12-21 15:34:41 -08:00
Cy Schubert c92983b03f ipfilter: ipf_dstlist is a kernel source file
Remove duplicate ipf_dstlist.* files. They live in sys/.

(cherry picked from commit 7aec934fff)
2021-12-21 15:34:41 -08:00
Cy Schubert 60aa737df9 ipfilter userland: Replace sprintf with range checking version (snprintf)
(cherry picked from commit a6fb9bbea7)
2021-12-21 15:34:40 -08:00
Cy Schubert 6802e5f783 ipfilter: radix_ipf is a kernel source file
Remove duplicate radix_ipf.* files. They live in sys/.

(cherry picked from commit 9a563c5e48)
2021-12-21 15:34:40 -08:00
Cy Schubert 277e5da4c5 ipfilter printfieldhdr: remove set-but-not-unused vars
(cherry picked from commit edcdd4f644)
2021-12-13 17:14:28 -08:00
Cy Schubert d1dc555984 ipft_pc: remove set-but-not-unused vars
(cherry picked from commit 712b938661)
2021-12-13 17:13:33 -08:00
Cy Schubert e34975c5c6 ipft_tx: remove set-but-not-unused vars
(cherry picked from commit 9018f7fa45)
2021-12-13 17:13:17 -08:00
Cy Schubert dad871e744 ipfcomp: remove set-but-not-unused vars
(cherry picked from commit fe5b077c9e)
2021-12-13 17:12:50 -08:00
Cy Schubert e5174c8929 ipft_hx: remove set-but-not-unused vars
(cherry picked from commit ece1946c1f)
2021-12-13 17:12:32 -08:00
Cy Schubert f786ca5901 ippool: remove set-but-not-unused vars
Display of stats from a kernel core dump was never fully implemented.
Remove the dangling vars and remove the documentation.

(cherry picked from commit 2169572e74)
2021-12-13 17:12:16 -08:00
Gordon Bergling f9346ed0c0 ipfilter(4): Fix a typo in an error message
- s/addresss/address/

This is a direct commit to contrib since the upstream is
no longer active.

(cherry picked from commit e10ac08631)
2021-12-07 19:52:58 +01:00
Cy Schubert 6bb08afcf9 MFC 57785538c6 and
1e811efbc5:

57785538c6:

Simplify the FreeBSD check using __FreeBSD__ compiler macro.

Rather than rely on __FreeBSD_version, defined in sys/param.h, use
__FreeBSD__ defined by the compiler.

Reported by:	emaste
MFC after:	1 week

(cherry picked from commit 57785538c6)

1e811efbc5:

Fix non-IPv6 build post 57785538c6.

57785538c6 change the test for FreeBSD
from __FreeBSD_version to __FreeBSD__. However this test was performed
before sys/param.h was included, therefore __FreeBSD_version was never
defined. As the test was never true opt_random_ip_id.h was never included.

Submitted by:	bdragon
Reported by:	bdragon

(cherry picked from commit 1e811efbc5)
2021-02-15 16:40:50 -08:00
Cy Schubert b3e0463c74 MFC d20f7a5a3d:
Simply FreeBSD check using __FreeBSD__ and remove OpenBSD

(cherry picked from commit d20f7a5a3d)
2021-02-15 16:40:50 -08:00
Cy Schubert 5c32dfaaa1 MFC 10990cb460:
Simplify FreeBSD check.

(cherry picked from commit 10990cb460)
2021-02-15 16:40:50 -08:00
Cy Schubert d751393cdd MFC e673debe7d:
Simplify BSD macro tests.

All FreeBSD and NetBSD are BSD >= 199306 and have been for a long time.

(cherry picked from commit e673debe7d)
2021-02-15 16:40:49 -08:00
Cy Schubert d81409e2b9 MFC 0f34c80f37:
Replace the redundant MENTAT macro with SOLARIS.

MENTAT and SOLARIS are synonymous. Remove the extraneous duplicate
macro.

(cherry picked from commit 0f34c80f37)
2021-02-15 16:40:49 -08:00
Cy Schubert 422b6a3048 MFC 4cd1807c7d:
Retire the K&R/STD C __P prototype declarations.

In the old days when K&R C and STD C were each in use a workaround
(read hack) was required to allow the same code to work on each
without modification. All C compilers support STD C. We can finally
put the __P prototype to rest.

(cherry picked from commit 4cd1807c7d)
2021-02-15 16:40:48 -08:00
Cy Schubert 514caf57cd MFC: 83edbc3cb5
ipfilter: Retire pre-standard C support.

All C compilers in 2021 support standard C and architectures that did
not were retired long ago. Simplify by removing now redundant
pre-standard C code.

(cherry picked from commit 83edbc3cb5)
2021-01-30 20:28:06 -08:00
Cy Schubert 7d8ff32452 Sync ippool.8 man page synopsis with reality and the rest of the
man page..

MFC after:	3 days
2020-12-23 17:04:34 -08:00
Cy Schubert b85540d0a3 Remove a random equal sign from the example. It should not be there.
It's a syntax error.

PR:		210303
Reported by:	leventelist at gmail.com
MFC after:	3 days
2020-10-27 04:35:47 +00:00
Cy Schubert bbd1103c30 Continued ipfilter #ifdef cleanup. The r343701 log entry contains a
complete description.

MFC after:	3 days
2020-10-27 04:35:36 +00:00
Cy Schubert 6dbd2fb858 ipfilter getifname ifdef cleanup.
MFC after:	2 months
2020-09-30 08:26:22 +00:00
Cy Schubert 2c1685f369 Resurrect ipfilter's getifname, replacing the stub with the real
function.

MFC after:	2 months
2020-09-30 08:26:00 +00:00
Cy Schubert 15dc17b8d5 Remove Linux and IRIX specific files.
MFC after:	1 week
2020-09-27 18:39:12 +00:00
Cy Schubert 2e93aaa766 Continuing the effort started in r343701, #ifdef cleanup, remove
never to be used again checks.

MFC after:	1 week
2020-09-27 18:39:09 +00:00
Cy Schubert a5849fa4ab Continued ipfilter #ifdef cleanup. The r343701 log entry contains a
complete description.

MFC after:	1 week
2020-08-05 15:33:32 +00:00
Cy Schubert 12b2f3daaa Continued ipfilter #ifdef cleanup. The r343701 log entry contains a
complete description.

MFC after:	1 week
2020-07-29 19:36:24 +00:00
Cy Schubert f0276e8c38 Document the IPFILTER_PREDEFINED environment variable.
PR:		248088
Reported by:	joeb1@a1poweruser.com
MFC after:	1 week
2020-07-23 17:39:49 +00:00
Cy Schubert 64a1886d5c -4 and -6 only make sense with -i, -o, and -t.
PR:		247952
MFC after:	1 week
2020-07-17 19:07:53 +00:00
Cy Schubert ebdefe6cb4 The output from usage() need not contain usage for -t when STATETOP
is not compiled in.

PR:		247952
MFC after:	1 week
2020-07-17 19:07:50 +00:00
Cy Schubert e082c89385 Make ipfstat -t header generic when IPv4 and IPv6 output are
displayed in the same display.

PR:		247952
MFC after:	1 week
2020-07-17 19:07:47 +00:00
Cy Schubert 08c24e2f88 ipfstat -t defaults to IPv4 output. Make consistent with ipfstat -i
and ipfstat -o where without an argument IPv4 and IPv6 states are
shown. Use -4 and -6 to limit the display to IPv4 or IPv6 respectively.

PR:		247952
MFC after:	1 week
2020-07-17 19:07:44 +00:00
Cy Schubert 88b86bb0f3 Historically ipfstat listings and stats only listed IPv4 or IPv6 output.
ipfstat would list IPv4 outputs by default while -6 would produce IPv6
outputs. This commit combines the ipfstat -i and -o outputs into one
listing of IPv4 and IPv6 rules. The -4 option lists only IPv4 rules
(as the default before) while -6 continues to list only rules that affect
IPv6.

PR:		247952
Reported by:	joeb1@a1poweruser.com
MFC after:	1 week
2020-07-17 19:07:40 +00:00
Cy Schubert 5317660176 fr_family (the protocol family) must be AF_INET or AF_INET6, as in
the kernel, not an arbitrary 4 or 6.

This only affected printing ipfilter stats and rules from a kernel
dump. (This is currently undocumented.)

PR:		247952
MFC after:	1 week
2020-07-17 19:07:37 +00:00
Cy Schubert ce1c2aafce Only use the use_inet6 variable when INET6 is a build option.
This is a prerequisite to upcoming argument processing cleanups which
will resolve consistency as was done with ippool previously.

PR:		247952
MFC after:	1 week
2020-07-17 19:07:34 +00:00
Cy Schubert 9543f281e8 Per-rule hit counts (-h) can be used with either -i (input) or -o (output)
filter rule lists.

MFC after:	3 days
2020-06-02 03:44:22 +00:00
Kyle Evans 0690ee732a ipfilter: remove duplicate definition of 'thishost'
thishost is already defined in lib/initparse.c; no need for this one. This
fixes the ipfilter build with -fno-common.

-fno-common will become the default in GCC10/LLVM11.

MFC after:	3 days
2020-03-29 02:26:58 +00:00
Cy Schubert 9658b6b3f4 As with ipf(8), give ippool(8) the ability to load IP pools from multiple
files. This allows for loading, during the same invocation of ippool, of
multiple sources of input using multiple tools to concurrently maintain the
files such as fail2ban, macro preprocessors, and manually.

MFC after:	1 week
2020-02-18 11:26:49 +00:00
Cy Schubert 87b60ffe39 Fix a typo (upto --> up to) and reword to improve word flow.
MFC after:	3 days
2019-12-02 20:39:40 +00:00
Cy Schubert a97e8d2fe4 Implement the dynamic add (-A) and removal (-R) of ippool pools
from the command line. Prior to this the functionality was mostly there
however since the pool type (-t) was not recognized by the -A and -R
command options -- not recognized by getopt(). Additionally the code to
implement the dynamic add and removal of pools didn't work.

When dynamically adding (-A) a pool a type (-t) to specify if the pool
is a tree or hash pool must  be specified. When dynamically removing (-R)
a pool, omitting -t will cause a search-and-destroy which will remove
both types of pools matching the name given (-m).

PR:		218433
MFC after:	1 week
2019-09-27 00:29:12 +00:00
Cy Schubert e7257e1499 The no resolve (OPT_NORESOLVE) does nothing. Additionally, it (-R)
conflicts with the command option of the same name (also -R).
Remove the superfluous and confusing non-global non-command -R option.

PR:		218433
MFC after:	1 week
2019-09-27 00:29:09 +00:00
Cy Schubert 80aa6435f0 Sync with source:
Only a role of "ipf" is currentlysupported as the other documented
(and undocumented) roles are #ifdef'd out.

The plan is to complete ippool(8) as it is even in its current state
a powerful feature/tool.

PR:		218433
MFC after:	1 month
2019-09-27 00:29:06 +00:00
Cy Schubert a263199455 Fix a typo.
MFC after:	3 days
2019-09-27 00:29:03 +00:00
Cy Schubert 4fcb870612 Teach the ippool parser about address families. This is a precursor
to implementing IPv6 support within ippool which requires reworking
radix_ipf.c.

MFC after:	1 month
2019-09-26 03:09:45 +00:00
Cy Schubert 9aa0318d3c Fix a typo.
PR:		238816
MFC after:	1 week
X-MFC with:	r349503
2019-06-28 04:52:24 +00:00
Cy Schubert 76af5effde Document the -B, binary logfile, and the -C config file options.
Reference the ipmon.5 man page and ipmon.conf.

PR:		238816
MFC after:	1 week
2019-06-28 04:28:32 +00:00
Cy Schubert 358e680a67 Return a return code scripts might expect. I missed this while
reviewing and rewriting a patch in PR/238816.

PR:		238816
Reported by:	rgrimes@
Pointy hat to:	cy@
MFC after:	1 week
X-MFC with:	r349450
2019-06-27 03:50:13 +00:00
Cy Schubert accc4633db Update usage() to refect the current state of ipmon.
PR:		238816
MFC after:	1 week
2019-06-27 02:43:30 +00:00