Commit Graph

333 Commits

Author SHA1 Message Date
Kristof Provost
d9ab899931 pf: migrate DIOCGETLIMIT/DIOCSETLIMIT to netlink
Event:		Kitchener-Waterloo Hackathon 202406
2024-06-07 20:59:02 +02:00
Kristof Provost
cd2054d48b libpfctl: add pfctl_get_rule_h()
Add a handle variant of pfctl_get_rule(). This converts us from using
the nvlist variant to the netlink variant, and also moves us closer to a
world where all libpfctl functions take the handle.

While here have pfctl use the new function.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2024-05-28 22:27:22 +02:00
Kristof Provost
f1612e7087 libpfctl: fix file descriptor leak
pfctl_get_rules_info() opened a netlink socket, but failed to close it again.
Fix this by factoring out the netlink-based function into a _h variant that
takes struct pfctl_handle, and implement pfctl_get_rules_info() based on that,
remembering to close the fd.

While here migrate all in-tree consumers to the _h variant.

MFC after:	3 days
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2024-05-09 14:07:07 +02:00
Kristof Provost
5824df8d99 pf: convert DIOCGETSTATUS to netlink
Introduce pfctl_get_status_h() because we need the pfctl_handle. In this variant
use netlink to obtain the information.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2024-04-29 16:32:23 +02:00
Kristof Provost
2905d10b39 snmp_pf: use libpfctl's pfctl_get_rules_info() rather than DIOCGETRULES
Prefer libpfctl functions over direct access to the ioctl whenever
possible.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-11-27 21:36:48 +01:00
Warner Losh
4d65a7c695 usr.sbin: Automated cleanup of cdefs and other formatting
Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by:		Netflix
2023-11-26 22:24:01 -07:00
John Baldwin
cc61bf9ecc snmp_wlan: Fix a couple of type mismatches in function prototypes
Reported by:	GCC 13 via -Wenum-int-mismatch
Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D42582
2023-11-14 18:36:03 -08:00
Kristof Provost
6fbb9fbf7d snmp_pf: use libpfctl's pfctl_get_status() rather than DIOCGETSTATUS
Prefer libpfctl functions over direct access to the ioctl whenever
possible. This will allow subsequent removal of DIOCGETSTATUS (in 15) as
there already is an nvlist-based alternative.

MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D41650
2023-08-31 10:56:32 +02:00
Eugene Grosbein
872e894056 unbreak BEGEMOT-LM75-MIB.txt
The MIB has several bugs making it unusable. Fix it.

Reported-by:	Eugene M. Zheganin <eugene@zhegan.in>
MFC-after:	2 weeks
2023-08-31 09:47:57 +07:00
Warner Losh
9636a14538 Remove $FreeBSD$: two-line lua tag
Remove /^--\n--\s*\$FreeBSD\$.*$\n/
2023-08-16 11:55:30 -06:00
Warner Losh
fa9896e082 Remove $FreeBSD$: two-line nroff pattern
Remove /^\.\\"\n\.\\"\s*\$FreeBSD\$$\n/
2023-08-16 11:55:10 -06:00
Warner Losh
d0b2dbfa0e Remove $FreeBSD$: one-line sh pattern
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
2023-08-16 11:55:03 -06:00
Warner Losh
1d386b48a5 Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:42 -06:00
Warner Losh
b3e7694832 Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
2023-08-16 11:54:16 -06:00
John Baldwin
eca9714e4b libbsnmptools: Fully comment out set but unused count variable.
These functions all end with 'return (2/* count */);'.

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D40670
2023-06-27 10:19:32 -07:00
John Baldwin
afb001df81 bsnmpd snmp_bridge: Remove set but unused variable. 2023-06-20 09:29:00 -07:00
Elyes Haouas
8883fd2c4b bsnmpd/modules/snmp_lm75: Fix typos
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/653
2023-06-01 20:33:40 -06:00
Elyes Haouas
8b223768d1 bsnmpd/tools/libbsnmptools: Fix typos
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/653
2023-06-01 20:33:39 -06:00
Elyes Haouas
de8b490010 bsnmpd/modules/snmp_hostres: Fix typos
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/653
2023-06-01 20:33:39 -06:00
Elyes Haouas
8c9946be52 bsnmpd/modules/snmp_bridge: Fix typos
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/653
2023-06-01 20:33:38 -06:00
Warner Losh
4d846d260e spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD
The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with:		pfg
MFC After:		3 days
Sponsored by:		Netflix
2023-05-12 10:44:03 -06:00
Simon J. Gerraty
d9a4274795 Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
Gordon Bergling
7a184a41c6 bsnmpget.1: Fix a typo in the man page
- s/ingore/ignore/

MFC after:	3 days
2023-01-19 14:18:52 +01:00
Gordon Bergling
c7b9006af5 snmp_hostres(3): Fix a typo in a debug message
- s/atempt/attempt/

MFC after:	3 days
2022-07-03 14:57:12 +02:00
Warner Losh
cbe9faa50b Remove DS_BUSY case
DS_BUSY is no longer a device state. Remove it from here.

Sponsored by:		Netflix
2021-11-30 16:35:48 -07:00
Ed Maste
5fff2859ec bsnmpd: Remove "All Rights Reserved" from FreeBSD Foundation copyrights
Sponsored by:	The FreeBSD Foundation
2021-10-22 18:53:35 -04:00
Emmanuel Vadot
af5e40770e pkgbase: Put the mibs and defs in the bnsmp package
Differential Revision:	https://reviews.freebsd.org/D30756
Sponsored by:	Diablotin Systems
2021-06-19 17:50:03 +02:00
Kristof Provost
67cef6d411 bsnmp: Fix incorrect use of libpfctl
When we introduced libpfctl in bnsmpd this was done incorrectly, and a
GETRULE call was replaced by pfctl_add_rule().
Change it to pfctl_get_rule().

Reviewed by:	donner
MFC after:	3 days
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2021-06-17 10:53:40 +02:00
Warner Losh
f009aedae4 bsnmpd: Return the correct uptime.
Do not assume that the kernel boot time is invariant. It is not. FreeBSD
uses the formula:
	wall_time = boot_time + uptime
where uptime is monotinically increasing and boot_time is adjusted to
get the proper time of day.  FreeBSD offers a way to retrieve the uptime
directly, so use that instead of trying to compute it by subtracting
boot_time from wall_time.

Sponsored by:		Netflix
Reviewed by:		cy@
Differential Revision:	https://reviews.freebsd.org/D30114
2021-05-05 15:12:38 -06:00
Kristof Provost
6fcc8e042a pf: Allow multiple labels to be set on a rule
Allow up to 5 labels to be set on each rule.
This offers more flexibility in using labels. For example, it replaces
the customer 'schedule' keyword used by pfSense to terminate states
according to a schedule.

Reviewed by:	glebius
MFC after:	2 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D29936
2021-04-26 14:14:21 +02:00
Kristof Provost
e9eb09414a libpfctl: Switch to pfctl_rule
Stop using the kernel's struct pf_rule, switch to libpfctl's pfctl_rule.
Now that we use nvlists to communicate with the kernel these structures
can be fully decoupled.

Reviewed by:	glebius
MFC after:	4 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D29644
2021-04-10 11:16:02 +02:00
Kristof Provost
956e7d2325 bsnmp: Use libpfctl
Reviewed by:	glebius
MFC after:	4 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D29642
2021-04-10 11:16:02 +02:00
Gordon Bergling
dbac569b41 snmp_wlan(3): Fix mandoc warnings
- new sentence, new line
2020-11-20 16:46:51 +00:00
Stefan Eßer
1f474190fc Replace literal uses of /usr/local in C sources with _PATH_LOCALBASE
Literal references to /usr/local exist in a large number of files in
the FreeBSD base system. Many are in contributed software, in configuration
files, or in the documentation, but 19 uses have been identified in C
source files or headers outside the contrib and sys/contrib directories.

This commit makes it possible to set _PATH_LOCALBASE in paths.h to use
a different prefix for locally installed software.

In order to avoid changes to openssh source files, LOCALBASE is passed to
the build via Makefiles under src/secure. While _PATH_LOCALBASE could have
been used here, there is precedent in the construction of the path used to
a xauth program which depends on the LOCALBASE value passed on the compiler
command line to select a non-default directory.

This could be changed in a later commit to make the openssh build
consistently use _PATH_LOCALBASE. It is considered out-of-scope for this
commit.

Reviewed by:	imp
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D26942
2020-10-27 11:29:11 +00:00
Gordon Bergling
3d265fce43 Fix a few mandoc issues
- skipping paragraph macro: Pp after Sh
- sections out of conventional order: Sh EXAMPLES
- whitespace at end of input line
- normalizing date format
2020-10-09 19:12:44 +00:00
Kyle Evans
7cc42f6d25 Do a sweep and remove most WARNS=6 settings
Repeating the default WARNS here makes it slightly more difficult to
experiment with default WARNS changes, e.g. if we did something absolutely
bananas and introduced a WARNS=7 and wanted to try lifting the default to
that.

Drop most of them; there is one in the blake2 kernel module, but I suspect
it should be dropped -- the default WARNS in the rest of the build doesn't
currently apply to kernel modules, and I haven't put too much thought into
whether it makes sense to make it so.
2020-10-01 01:10:51 +00:00
Eugene Grosbein
dca51295b2 bsnmptools: make it print protocol errors to stderr instead of stdout
Reviewed by:		syrinx, bz
MFC after:		1 week
Differential Revision:	https://reviews.freebsd.org/D25911
2020-08-05 09:19:41 +00:00
Warner Losh
0d94b31ad3 Fix a comment for the SUN geom class.
Reivewed by: cy@, bcr@
Differential Revision: https://reviews.freebsd.org/D23593
2020-02-10 17:16:50 +00:00
Warner Losh
f8f33808c0 Fix comment. It mentioned sparc64 specifically, but alignment issues
are present elsewhere.

Reivewed by: cy@, bcr@
Differential Revision: https://reviews.freebsd.org/D23593
2020-02-10 17:16:45 +00:00
Dimitry Andric
303c0aad7d Fix the following -Werror warning from clang 10.0.0 in bsnmpd:
usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c:1661:4: error: misleading indentation; statement is not part of the previous 'else' [-Werror,-Wmisleading-indentation]
                        return (-1);
                        ^
usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c:1658:5: note: previous statement is here
                } else
                  ^

The intent was to group the return statement with the previous syslog()
call.

MFC after:	3 days
2020-01-31 18:09:27 +00:00
Dimitry Andric
3fd49cf90e Fix the following -Werror warning from clang 10.0.0 in bsnmpd:
usr.sbin/bsnmpd/modules/snmp_bridge/bridge_port.c:1235:43: error: overlapping comparisons always evaluate to true [-Werror,-Wtautological-overlap-compare]
                            begemotBridgeStpPortEnable_enabled ||
                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~

Work around it by casting the enum values to the type of val->v.integer.

MFC after:	3 days
2020-01-29 21:40:35 +00:00
Simon J. Gerraty
2c9a9dfc18 Update Makefile.depend files
Update a bunch of Makefile.depend files as
a result of adding Makefile.depend.options files

Reviewed by:	 bdrewery
MFC after:	1 week
Sponsored by:   Juniper Networks
Differential Revision:  https://reviews.freebsd.org/D22494
2019-12-11 17:37:53 +00:00
Simon J. Gerraty
5ab1c5846f Add Makefile.depend.options
Leaf directories that have dependencies impacted
by options need a Makefile.depend.options file
to avoid churn in Makefile.depend

DIRDEPS for cases such as OPENSSL, TCP_WRAPPERS etc
can be set in local.dirdeps-options.mk
which can add to those set in Makefile.depend.options

See share/mk/dirdeps-options.mk

Reviewed by:	 bdrewery
MFC after:	1 week
Sponsored by:   Juniper Networks
Differential Revision:  https://reviews.freebsd.org/D22469
2019-12-11 17:37:37 +00:00
Shteryana Shopova
9a8070808e No need for each bsnmpd(1) module to open connection to syslog
bsnmpd(1) main does that early on init and the connection is available
to all loaded modules

Event:		Vienna Hackathon 2019
PR:		233431 , 221487
MFC after:	2 weeks
2019-06-21 07:45:58 +00:00
Shteryana Shopova
65a184e091 Unbreak snmp_pf(3) after the changes introduced in r338209
PR:		237011
Event:		Vienna Hackathon 2019
MFC after:	2 weeks
2019-06-21 07:29:02 +00:00
Andrey V. Elsukov
04d1781439 Add IPv6 transport for bsnmp.
This patch adds a new table begemotSnmpdTransInetTable that uses the
InetAddressType textual convention and can be used to create listening
ports for IPv4, IPv6, zoned IPv6 and based on DNS names. It also supports
future extension beyond UDP by adding a protocol identifier to the table
index. In order to support this gensnmptree had to be modified.

Submitted by:   harti
MFC after:      1 month
Relnotes:       yes
Differential Revision:  https://reviews.freebsd.org/D16654
2019-04-02 12:50:01 +00:00
Andriy Voskoboinyk
e5cb99d5a2 snmp_hostres(3): fix a typo in sanity checks in handle_chunk()
PR:		204253
Submitted by:	David Binderman <dcb314@hotmail.com>
MFC after:	5 days
2019-02-18 03:23:10 +00:00
Patrick Kelsey
249cc75fd1 Extended pf(4) ioctl interface and pfctl(8) to allow bandwidths of
2^32 bps or greater to be used.  Prior to this, bandwidth parameters
would simply wrap at the 2^32 boundary.  The computations in the HFSC
scheduler and token bucket regulator have been modified to operate
correctly up to at least 100 Gbps.  No other algorithms have been
examined or modified for correct operation above 2^32 bps (some may
have existing computation resolution or overflow issues at rates below
that threshold).  pfctl(8) will now limit non-HFSC bandwidth
parameters to 2^32 - 1 before passing them to the kernel.

The extensions to the pf(4) ioctl interface have been made in a
backwards-compatible way by versioning affected data structures,
supporting all versions in the kernel, and implementing macros that
will cause existing code that consumes that interface to use version 0
without source modifications.  If version 0 consumers of the interface
are used against a new kernel that has had bandwidth parameters of
2^32 or greater configured by updated tools, such bandwidth parameters
will be reported as 2^32 - 1 bps by those old consumers.

All in-tree consumers of the pf(4) interface have been updated.  To
update out-of-tree consumers to the latest version of the interface,
define PFIOC_USE_LATEST ahead of any includes and use the code of
pfctl(8) as a guide for the ioctls of interest.

PR:	211730
Reviewed by:	jmallett, kp, loos
MFC after:	2 weeks
Relnotes:	yes
Sponsored by:	RG Nets
Differential Revision:	https://reviews.freebsd.org/D16782
2018-08-22 19:38:48 +00:00
Brad Davis
c2d948fa77 Move snmpd.config to usr.sbin/bsnmpd/bsnmpd/
This helps with pkgbase as this config file will now be tagged as a config
file

Approved by:	allanjude (mentor)
Sponsored by:	Essen Hackathon
Differential Revision:	https://reviews.freebsd.org/D16674
2018-08-11 13:47:28 +00:00
Hartmut Brandt
8e9b3e7071 Update bsnmp to version 1.13. This does not bring user-visible changes.
For developers gensnmptree can now generate functions for enums to convert
between enums and strings and to check the validity of a value.
The sources in FreeBSD are now in sync with the upstream which allows to
bring in IPv6 modifications.
2018-07-03 08:44:40 +00:00