pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

suricata: fix net if capabilities handling, bmake successfull



Module Name:	pkgsrc-wip
Committed By:	kami <kisskamizeg%gmail.com@localhost>
Pushed By:	kami
Date:		Mon Sep 22 22:11:59 2025 +0200
Changeset:	78c6cb284d79026d151fae84bc803eab2fe03b73

Modified Files:
	suricata/Makefile
	suricata/TODO
	suricata/distinfo
Added Files:
	suricata/patches/patch-src_util-ioctl.c

Log Message:
suricata: fix net if capabilities handling, bmake successfull

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=78c6cb284d79026d151fae84bc803eab2fe03b73

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 suricata/Makefile                       |  2 +
 suricata/TODO                           | 14 +++--
 suricata/distinfo                       |  1 +
 suricata/patches/patch-src_util-ioctl.c | 93 +++++++++++++++++++++++++++++++++
 4 files changed, 106 insertions(+), 4 deletions(-)

diffs:
diff --git a/suricata/Makefile b/suricata/Makefile
index 6725c457c2..0b1dc71dc1 100644
--- a/suricata/Makefile
+++ b/suricata/Makefile
@@ -21,6 +21,8 @@ USE_TOOLS+=		pkg-config
 
 USE_LANGUAGES=		c c++
 
+LIBS.NetBSD+= -lm
+
 .include "../../mk/bsd.prefs.mk"
 
 #.include "options.mk"
diff --git a/suricata/TODO b/suricata/TODO
index 39eda7eca0..00e6afd328 100644
--- a/suricata/TODO
+++ b/suricata/TODO
@@ -5,10 +5,16 @@
 - pkgconfig overrides for rust/vendor/libz-sys not enabled yet
   - probably needs patches
 
-* configure
+* Configure
 - libunwind and dev header not found
 - check not found includes, features that exists on NetBSD
   and add support
-  
-* Compile
-- Lots of compile errors :/
+
+* Build
+- revise creation and use of cpu sets
+
+* Tests
+- run tests, evaluate and fix them
+- run executables, fix errors
+
+* Install
diff --git a/suricata/distinfo b/suricata/distinfo
index 3e081668e0..a166e40724 100644
--- a/suricata/distinfo
+++ b/suricata/distinfo
@@ -8,3 +8,4 @@ SHA1 (patch-src_threads.h) = bd3764e1ac575d2b2c7b6b88ea2dbd93c3c5a4cb
 SHA1 (patch-src_tm-threads.c) = cf2e747c3c26f72844184baf8dbdbf1aa9407665
 SHA1 (patch-src_util-affinity.h) = a5ede16436ae6b1d28615726bf8afa4a94159694
 SHA1 (patch-src_util-byte.h) = 2f4dd27b60eccc55a684d513765346bdbd120552
+SHA1 (patch-src_util-ioctl.c) = 00b8a07ebeea7e386fc5a24b79bbca0d3bf0494c
diff --git a/suricata/patches/patch-src_util-ioctl.c b/suricata/patches/patch-src_util-ioctl.c
new file mode 100644
index 0000000000..d805430be5
--- /dev/null
+++ b/suricata/patches/patch-src_util-ioctl.c
@@ -0,0 +1,93 @@
+$NetBSD$
+
+--- src/util-ioctl.c.orig	2025-09-22 18:04:28.981310802 +0000
++++ src/util-ioctl.c
+@@ -196,6 +196,8 @@ int SetIfaceFlags(const char *ifname, in
+ #ifdef OS_FREEBSD
+     ifr.ifr_flags = flags & 0xffff;
+     ifr.ifr_flagshigh = flags >> 16;
++#elif defined __NetBSD__
++    ifr.ifr_flags = flags & IFCAP_MASK;
+ #else
+     ifr.ifr_flags = (uint16_t)flags;
+ #endif
+@@ -214,8 +216,13 @@ int SetIfaceFlags(const char *ifname, in
+ #ifdef SIOCGIFCAP
+ int GetIfaceCaps(const char *ifname)
+ {
+-    struct ifreq ifr;
+-
++#ifdef __NetBSD__
++  struct ifcapreq ifr;
++  #define ifr_name ifcr_name
++#else
++  struct ifreq ifr;
++#endif
++  
+     int fd = socket(AF_INET, SOCK_DGRAM, 0);
+     if (fd < 0) {
+         return -1;
+@@ -231,14 +238,22 @@ int GetIfaceCaps(const char *ifname)
+     }
+ 
+     close(fd);
++#ifdef __NetBSD__
++    return ifr.ifcr_capabilities & IFCAP_MASK;
++#else
+     return ifr.ifr_curcap;
++#endif
+ }
+ #endif
+ #ifdef SIOCSIFCAP
+ int SetIfaceCaps(const char *ifname, int caps)
+ {
+-    struct ifreq ifr;
+-
++#ifdef __NetBSD__
++  struct ifcapreq ifr;
++#else
++  struct ifreq ifr;
++#endif
++  
+     int fd = socket(AF_INET, SOCK_DGRAM, 0);
+     if (fd < 0) {
+         return -1;
+@@ -246,8 +261,12 @@ int SetIfaceCaps(const char *ifname, int
+ 
+     memset(&ifr, 0, sizeof(ifr));
+     strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
++#ifdef __NetBSD__
++    ifr.ifcr_capabilities = caps & IFCAP_MASK;
++#else
+     ifr.ifr_reqcap = caps;
+-
++#endif
++    
+     if (ioctl(fd, SIOCSIFCAP, &ifr) == -1) {
+         SCLogError("%s: unable to set caps: %s", ifname, strerror(errno));
+         close(fd);
+@@ -524,6 +543,11 @@ static int GetIfaceOffloadingBSD(const c
+     }
+     SCLogDebug("if_caps %X", if_caps);
+ 
++#ifdef __NetBSD__
++#define IFCAP_RXCSUM (IFCAP_CSUM_IPv4_Rx | IFCAP_CSUM_TCPv4_Rx | IFCAP_CSUM_UDPv4_Rx | \
++		      IFCAP_CSUM_TCPv6_Rx | IFCAP_CSUM_UDPv6_Rx)
++#define IFCAP_TSO (IFCAP_TSOv4 | IFCAP_TSOv6)
++#endif
+     if (if_caps & IFCAP_RXCSUM) {
+         SCLogWarning("%s: RXCSUM activated can lead to capture problems. Run: ifconfig %s -rxcsum",
+                 ifname, ifname);
+@@ -568,6 +592,12 @@ static int DisableIfaceOffloadingBSD(Liv
+         SCLogPerf("%s: disabling rxcsum offloading", ifname);
+         set_caps &= ~IFCAP_RXCSUM;
+     }
++
++#ifdef __NetBSD__
++#define IFCAP_TXCSUM (IFCAP_CSUM_IPv4_Tx | IFCAP_CSUM_TCPv4_Tx | IFCAP_CSUM_UDPv4_Tx | \
++		      IFCAP_CSUM_TCPv6_Tx | IFCAP_CSUM_UDPv6_Tx)
++#endif
++
+     if (if_caps & IFCAP_TXCSUM) {
+         SCLogPerf("%s: disabling txcsum offloading", ifname);
+         set_caps &= ~IFCAP_TXCSUM;


Home | Main Index | Thread Index | Old Index