aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristof Provost <kp@freebsd.org>2023-09-18 06:18:57 +0000
committerMuhammad Moinur Rahman <bofh@FreeBSD.org>2023-09-19 06:24:59 +0000
commita36ac4ec4f06a1d6a14f63972aaa1399035f55a6 (patch)
tree8d9fb4f964a70088454adcc3b2aea8d16c34934b
parentf13d6252ad3d0540ecb49d8e523abb28372083ef (diff)
downloadports-a36ac4ec4f06a1d6a14f63972aaa1399035f55a6.tar.gz
ports-a36ac4ec4f06a1d6a14f63972aaa1399035f55a6.zip
net/libdnet: Use libpfctl
Several old ioctl commands have been removed in 15/main, which broke compilation for this port. Rely on libpfctl instead. There are some breaking pf API changes in 14 which involves regarding the ioctl syscalls. This port is an old outdated port which explicitly used those older syscalls. This port also is dependency of net/scapy which is run in our CI for testing. So fix it with blanket approval. For more information see: https://lists.freebsd.org/archives/freebsd-pf/2023-April/000345.html PR: 273899 Approved by: portmgr (just-fix-it) Sponsored by: Rubicon Communications, LLC ("Netgate")
-rw-r--r--net/libdnet/Makefile8
-rw-r--r--net/libdnet/files/patch-src_fw-pf.c83
2 files changed, 89 insertions, 2 deletions
diff --git a/net/libdnet/Makefile b/net/libdnet/Makefile
index 63134d9f8b40..2004f32597ea 100644
--- a/net/libdnet/Makefile
+++ b/net/libdnet/Makefile
@@ -1,7 +1,7 @@
PORTNAME= libdnet
PORTVERSION= 1.13
DISTVERSIONPREFIX= v
-PORTREVISION?= 3
+PORTREVISION?= 4
CATEGORIES?= net
MAINTAINER?= onatan@gmail.com
@@ -11,7 +11,11 @@ WWW= https://github.com/5u623l20/libdnet/
LICENSE= BSD3CLAUSE
LICENSE_FILE= ${WRKSRC}/LICENSE
-USES?= autoreconf libtool
+LIB_DEPENDS= libpfctl.so:net/libpfctl
+
+USES?= autoreconf libtool localbase
+
+LDFLAGS+= -lpfctl
USE_GITHUB= yes
GH_ACCOUNT= 5u623l20
diff --git a/net/libdnet/files/patch-src_fw-pf.c b/net/libdnet/files/patch-src_fw-pf.c
new file mode 100644
index 000000000000..4e892f271f15
--- /dev/null
+++ b/net/libdnet/files/patch-src_fw-pf.c
@@ -0,0 +1,83 @@
+--- src/fw-pf.c.orig 2019-03-19 17:55:02 UTC
++++ src/fw-pf.c
+@@ -15,6 +15,7 @@
+ #include <net/if.h>
+ #include <netinet/in.h>
+ #include <net/pfvar.h>
++#include <libpfctl.h>
+
+ #include <assert.h>
+ #include <errno.h>
+@@ -115,7 +116,7 @@ static int
+ }
+
+ static int
+-pr_to_fr(const struct pf_rule *pr, struct fw_rule *fr)
++pr_to_fr(const struct pfctl_rule *pr, struct fw_rule *fr)
+ {
+ memset(fr, 0, sizeof(*fr));
+
+@@ -205,12 +206,14 @@ fw_add(fw_t *fw, const struct fw_rule *rule)
+ #ifdef HAVE_PF_CHANGE_GET_TICKET
+ {
+ struct fw_rule fr;
++ struct pfctl_rule pfrule;
+
+ if (ioctl(fw->fd, DIOCGETRULES, &pcr) < 0)
+ return (-1);
+ while ((int)--pcr.nr >= 0) {
+- if (ioctl(fw->fd, DIOCGETRULE, &pcr) == 0 &&
+- pr_to_fr(&pcr.rule, &fr) == 0) {
++ if (pfctl_get_rule(fw->fd, pcr.nr, pcr.ticket, pcr.anchor,
++ pcr.action, &pfrule, pcr.anchor_call) == 0 &&
++ pr_to_fr(&pfrule, &fr) == 0) {
+ if (_fw_cmp(rule, &fr) == 0) {
+ errno = EEXIST;
+ return (-1);
+@@ -244,13 +247,15 @@ fw_delete(fw_t *fw, const struct fw_rule *rule)
+ #ifdef HAVE_PF_CHANGE_GET_TICKET
+ {
+ struct fw_rule fr;
++ struct pfctl_rule pfrule;
+ int found = 0;
+
+ if (ioctl(fw->fd, DIOCGETRULES, &pcr) < 0)
+ return (-1);
+ while ((int)--pcr.nr >= 0) {
+- if (ioctl(fw->fd, DIOCGETRULE, &pcr) == 0 &&
+- pr_to_fr(&pcr.rule, &fr) == 0) {
++ if (pfctl_get_rule(fw->fd, pcr.nr, pcr.ticket, pcr.anchor,
++ pcr.action, &pfrule, pcr.anchor_call) == 0 &&
++ pr_to_fr(&pfrule, &fr) == 0) {
+ if (_fw_cmp(rule, &fr) == 0) {
+ found = 1;
+ break;
+@@ -282,6 +287,7 @@ fw_loop(fw_t *fw, fw_handler callback, void *arg)
+ fw_loop(fw_t *fw, fw_handler callback, void *arg)
+ {
+ struct pfioc_rule pr;
++ struct pfctl_rule pfrule;
+ struct fw_rule fr;
+ uint32_t n, max;
+ int ret = 0;
+@@ -292,8 +298,9 @@ fw_loop(fw_t *fw, fw_handler callback, void *arg)
+
+ for (n = 0, max = pr.nr; n < max; n++) {
+ pr.nr = n;
+-
+- if ((ret = ioctl(fw->fd, DIOCGETRULE, &pr)) < 0)
++
++ if ((ret = pfctl_get_rule(fw->fd, pr.nr, pr.ticket, pr.anchor,
++ pr.action, &pfrule, pr.anchor_call)) < 0)
+ break;
+ #ifdef PF_TABLE_NAME_SIZE
+ /* XXX - actually in r1.125, not 1.126 */
+@@ -301,7 +308,7 @@ fw_loop(fw_t *fw, fw_handler callback, void *arg)
+ pr.rule.dst.addr.type == PF_ADDR_TABLE)
+ continue;
+ #endif
+- if (pr_to_fr(&pr.rule, &fr) < 0)
++ if (pr_to_fr(&pfrule, &fr) < 0)
+ continue;
+ if ((ret = callback(&fr, arg)) != 0)
+ break;