diff options
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/bsnmpd/bsnmpd/Makefile | 2 | ||||
-rw-r--r-- | usr.sbin/bsnmpd/modules/snmp_pf/BEGEMOT-PF-MIB.txt | 14 | ||||
-rw-r--r-- | usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c | 60 | ||||
-rw-r--r-- | usr.sbin/bsnmpd/modules/snmp_pf/pf_tree.def | 2 | ||||
-rw-r--r-- | usr.sbin/trim/Makefile | 3 |
5 files changed, 34 insertions, 47 deletions
diff --git a/usr.sbin/bsnmpd/bsnmpd/Makefile b/usr.sbin/bsnmpd/bsnmpd/Makefile index 245ffc51002f..e7c7a87eec7c 100644 --- a/usr.sbin/bsnmpd/bsnmpd/Makefile +++ b/usr.sbin/bsnmpd/bsnmpd/Makefile @@ -131,7 +131,7 @@ CFLAGS+= -I${CONTRIB}/lib -I${CONTRIB}/snmpd -I. -DUSE_LIBBEGEMOT CFLAGS+= -DHAVE_STDINT_H -DHAVE_INTTYPES_H -DHAVE_ERR_H -DHAVE_STRLCPY LIBADD= begemot bsnmp -LDFLAGS= -Wl,-export-dynamic +LDFLAGS+= -Wl,-export-dynamic .if ${MK_OPENSSL} != "no" CFLAGS+= -DHAVE_LIBCRYPTO diff --git a/usr.sbin/bsnmpd/modules/snmp_pf/BEGEMOT-PF-MIB.txt b/usr.sbin/bsnmpd/modules/snmp_pf/BEGEMOT-PF-MIB.txt index 13a4a646a669..8127eb92601f 100644 --- a/usr.sbin/bsnmpd/modules/snmp_pf/BEGEMOT-PF-MIB.txt +++ b/usr.sbin/bsnmpd/modules/snmp_pf/BEGEMOT-PF-MIB.txt @@ -21,19 +21,17 @@ IMPORTS FROM BEGEMOT-MIB; begemotPf MODULE-IDENTITY - LAST-UPDATED "201003180000Z" - ORGANIZATION "NixSys BVBA" + LAST-UPDATED "202503190000Z" + ORGANIZATION "Alternative Enterprises (HK) Limited" CONTACT-INFO " Philip Paeps - Postal: NixSys BVBA - Louizastraat 14 - BE-2800 Mechelen - Belgium - E-Mail: philip@FreeBSD.org" DESCRIPTION "The Begemot MIB for the pf packet filter." + REVISION "202503190000Z" + DESCRIPTION + "Reverted pfInterfacesIfRefsState to Unsigned32" REVISION "201003180000Z" DESCRIPTION "Modified pfTablesAddrEntry to support IPv6 @@ -583,7 +581,7 @@ PfInterfacesIfEntry ::= SEQUENCE { pfInterfacesIfDescr OCTET STRING, pfInterfacesIfType INTEGER, pfInterfacesIfTZero TimeTicks, - pfInterfacesIfRefsState Null, + pfInterfacesIfRefsState Unsigned32, pfInterfacesIfRefsRule Unsigned32, pfInterfacesIf4BytesInPass Counter64, pfInterfacesIf4BytesInBlock Counter64, diff --git a/usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c b/usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c index 0e40bcfb843e..f0f9e0f0e149 100644 --- a/usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c +++ b/usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c @@ -1298,10 +1298,27 @@ pfs_refresh(void) } static int +pft_add_tstats(const struct pfr_tstats *t, void *arg) +{ + struct pft_entry *e; + int *index = arg; + + e = malloc(sizeof(struct pft_entry)); + if (e == NULL) + return (ENOMEM); + + e->index = (*index) + 1; + (*index)++; + memcpy(&e->pft, t, sizeof(struct pfr_tstats)); + TAILQ_INSERT_TAIL(&pft_table, e, link); + + return (0); +} + +static int pft_refresh(void) { - struct pfioc_table io; - struct pfr_tstats *t = NULL; + struct pfr_table filter; struct pft_entry *e; int i, numtbls = 1; @@ -1314,45 +1331,18 @@ pft_refresh(void) free(e); } - bzero(&io, sizeof(io)); - io.pfrio_esize = sizeof(struct pfr_tstats); - - for (;;) { - t = reallocf(t, numtbls * sizeof(struct pfr_tstats)); - if (t == NULL) { - syslog(LOG_ERR, "pft_refresh(): reallocf() numtbls=%d: %s", - numtbls, strerror(errno)); - goto err2; - } - io.pfrio_size = numtbls; - io.pfrio_buffer = t; + bzero(&filter, sizeof(filter)); - if (ioctl(pfctl_fd(pfh), DIOCRGETTSTATS, &io)) { - syslog(LOG_ERR, "pft_refresh(): ioctl(): %s", - strerror(errno)); - goto err2; - } - - if (numtbls >= io.pfrio_size) - break; - - numtbls = io.pfrio_size; - } - - for (i = 0; i < numtbls; i++) { - e = malloc(sizeof(struct pft_entry)); - if (e == NULL) - goto err1; - e->index = i + 1; - memcpy(&e->pft, t+i, sizeof(struct pfr_tstats)); - TAILQ_INSERT_TAIL(&pft_table, e, link); + if (pfctl_get_tstats(pfh, &filter, pft_add_tstats, &i)) { + syslog(LOG_ERR, "pft_refresh(): pfctl_get_tstats(): %s", + strerror(errno)); + goto err1; } pft_table_age = time(NULL); pft_table_count = numtbls; pf_tick = this_tick; - free(t); return (0); err1: while (!TAILQ_EMPTY(&pft_table)) { @@ -1360,8 +1350,6 @@ err1: TAILQ_REMOVE(&pft_table, e, link); free(e); } -err2: - free(t); return(-1); } diff --git a/usr.sbin/bsnmpd/modules/snmp_pf/pf_tree.def b/usr.sbin/bsnmpd/modules/snmp_pf/pf_tree.def index dcdf676aa752..7a517a876fab 100644 --- a/usr.sbin/bsnmpd/modules/snmp_pf/pf_tree.def +++ b/usr.sbin/bsnmpd/modules/snmp_pf/pf_tree.def @@ -107,7 +107,7 @@ (2 pfInterfacesIfDescr OCTETSTRING GET) (3 pfInterfacesIfType ENUM ( 0 group 1 instance 2 detached ) GET) (4 pfInterfacesIfTZero TIMETICKS GET) - (5 pfInterfacesIfRefsState NULL GET) + (5 pfInterfacesIfRefsState UNSIGNED32 GET) (6 pfInterfacesIfRefsRule UNSIGNED32 GET) (7 pfInterfacesIf4BytesInPass COUNTER64 GET) (8 pfInterfacesIf4BytesInBlock COUNTER64 GET) diff --git a/usr.sbin/trim/Makefile b/usr.sbin/trim/Makefile index 1263c0c6819e..1329c7f79690 100644 --- a/usr.sbin/trim/Makefile +++ b/usr.sbin/trim/Makefile @@ -1,6 +1,7 @@ +.include <src.opts.mk> + PROG= trim MAN= trim.8 LIBADD= util -LDFLAGS= -lutil .include <bsd.prog.mk> |