Bug 286539 - net-mgmt/nfdump: port doesn't build on 14.3-STABLE
Summary: net-mgmt/nfdump: port doesn't build on 14.3-STABLE
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Kurt Jaeger
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-05-03 06:47 UTC by Marek Zarychta
Modified: 2025-05-09 17:13 UTC (History)
4 users (show)

See Also:
bugzilla: maintainer-feedback? (pi)


Attachments
Proposed patch for src/nfpcapd/nfpcapd.c to be placed in the files subdirectory of the port (216 bytes, patch)
2025-05-03 16:52 UTC, Trond Endrestøl
no flags Details | Diff
alternative patch (1.25 KB, patch)
2025-05-03 19:32 UTC, Kurt Jaeger
no flags Details | Diff
Patch for src/nfpcapd/nfpcapd.c enabling sys/types.h (293 bytes, patch)
2025-05-07 07:08 UTC, Trond Endrestøl
no flags Details | Diff
Patch for src/nfpcapd/packet_bpf.c enabling sys/types.h (250 bytes, patch)
2025-05-07 07:08 UTC, Trond Endrestøl
no flags Details | Diff
Patch for src/nfpcapd/pcaproc.h enabling sys/types.h (233 bytes, patch)
2025-05-07 07:09 UTC, Trond Endrestøl
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Marek Zarychta 2025-05-03 06:47:40 UTC
This port is not ready for FreeBSD 14.3 yet. I am pasting below the excerpt from poudriere build log:

In file included from nfpcapd.c:44:
/usr/include/netinet/in_systm.h:53:9: error: unknown type name 'u_int16_t'
   53 | typedef u_int16_t n_short;              /* short as received from the net */
      |         ^
/usr/include/netinet/in_systm.h:54:9: error: unknown type name 'u_int32_t'
   54 | typedef u_int32_t n_long;               /* long as received from the net */
      |         ^
/usr/include/netinet/in_systm.h:56:9: error: unknown type name 'u_int32_t'
   56 | typedef u_int32_t n_time;               /* ms since 00:00 UTC, byte rev */
      |         ^
3 errors generated.
--- nfpcapd-packet_bpf.o ---
In file included from packet_bpf.c:40:
/usr/include/net/bpf.h:50:9: error: unknown type name 'int32_t'; did you mean '__int32_t'?
   50 | typedef int32_t   bpf_int32;
      |         ^
/usr/include/sys/_types.h:47:15: note: '__int32_t' declared here
   47 | typedef int                     __int32_t;
      |                                 ^
In file included from packet_bpf.c:40:
/usr/include/net/bpf.h:51:9: error: unknown type name 'u_int32_t'; did you mean '__int32_t'?
   51 | typedef u_int32_t bpf_u_int32;
      |         ^
/usr/include/sys/_types.h:47:15: note: '__int32_t' declared here
   47 | typedef int                     __int32_t;
      |                                 ^
In file included from packet_bpf.c:40:
/usr/include/net/bpf.h:52:9: error: unknown type name 'int64_t'; did you mean '__int64_t'?
   52 | typedef int64_t   bpf_int64;
      |         ^
/usr/include/sys/_types.h:50:16: note: '__int64_t' declared here
   50 | typedef long                    __int64_t;
      |                                 ^
In file included from packet_bpf.c:40:
/usr/include/net/bpf.h:53:9: error: unknown type name 'u_int64_t'; did you mean '__int64_t'?
   53 | typedef u_int64_t bpf_u_int64;
      |         ^
/usr/include/sys/_types.h:50:16: note: '__int64_t' declared here
   50 | typedef long                    __int64_t;
      |                                 ^
In file included from packet_bpf.c:40:
/usr/include/net/bpf.h:71:2: error: unknown type name 'u_int'
   71 |         u_int bf_len;
      |         ^
/usr/include/net/bpf.h:79:2: error: unknown type name 'u_int'
   79 |         u_int bs_recv;          /* number of packets received */
      |         ^
/usr/include/net/bpf.h:80:2: error: unknown type name 'u_int'
   80 |         u_int bs_drop;          /* number of packets dropped */
      |         ^
/usr/include/net/bpf.h:95:2: error: unknown type name 'u_short'; did you mean 'short'?
   95 |         u_short bv_major;
      |         ^
/usr/include/net/bpf.h:96:2: error: unknown type name 'u_short'; did you mean 'short'?
   96 |         u_short bv_minor;
      |         ^
/usr/include/net/bpf.h:120:2: error: unknown type name 'size_t'; did you mean '__size_t'?
  120 |         size_t   bz_buflen;     /* Size of zero-copy buffers. */
      |         ^
/usr/include/sys/_types.h:91:20: note: '__size_t' declared here
   91 | typedef __uint64_t      __size_t;       /* sizeof() */
      |                         ^
In file included from packet_bpf.c:40:
/usr/include/net/bpf.h:206:2: error: unknown type name 'u_short'; did you mean 'short'?
  206 |         u_short         bh_hdrlen;      /* length of bpf header (this struct
      |         ^
/usr/include/net/bpf.h:211:17: error: field has incomplete type 'struct timeval'
  211 |         struct timeval  bh_tstamp;      /* time stamp */
      |                         ^
/usr/include/net/bpf.h:211:9: note: forward declaration of 'struct timeval'
  211 |         struct timeval  bh_tstamp;      /* time stamp */
      |                ^
/usr/include/net/bpf.h:214:2: error: unknown type name 'u_short'; did you mean 'short'?
  214 |         u_short         bh_hdrlen;      /* length of bpf header (this struct
      |         ^
/usr/include/net/bpf.h:234:11: error: unknown type name 'u_int'
  234 |         volatile u_int  bzh_kernel_gen; /* Kernel generation number. */
      |                  ^
/usr/include/net/bpf.h:235:11: error: unknown type name 'u_int'
  235 |         volatile u_int  bzh_kernel_len; /* Length of data in the buffer. */
      |                  ^
/usr/include/net/bpf.h:236:11: error: unknown type name 'u_int'
  236 |         volatile u_int  bzh_user_gen;   /* User generation number. */
      |                  ^
/usr/include/net/bpf.h:237:2: error: unknown type name 'u_int'
  237 |         u_int _bzh_pad[5];
      |         ^
/usr/include/net/bpf.h:364:2: error: unknown type name 'u_short'; did you mean 'short'?
  364 |         u_short         code;
      |         ^
/usr/include/net/bpf.h:365:2: error: unknown type name 'u_char'; did you mean 'char'?
  365 |         u_char          jt;
      |         ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
--- nfpcapd-nfpcapd.o ---
*** [nfpcapd-nfpcapd.o] Error code 1

make[2]: stopped in /wrkdirs/usr/ports/net-mgmt/nfdump/work/nfdump-1.7.4/src/nfpcapd
--- nfpcapd-packet_bpf.o ---
*** [nfpcapd-packet_bpf.o] Error code 1

make[2]: stopped in /wrkdirs/usr/ports/net-mgmt/nfdump/work/nfdump-1.7.4/src/nfpcapd
2 errors

make[2]: stopped in /wrkdirs/usr/ports/net-mgmt/nfdump/work/nfdump-1.7.4/src/nfpcapd

make[1]: stopped in /wrkdirs/usr/ports/net-mgmt/nfdump/work/nfdump-1.7.4

make: stopped in /wrkdirs/usr/ports/net-mgmt/nfdump/work/nfdump-1.7.4
===> Compilation failed unexpectedly.
Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to
the maintainer.
*** Error code 1
Comment 1 Trond Endrestøl 2025-05-03 16:52:08 UTC
Created attachment 260122 [details]
Proposed patch for src/nfpcapd/nfpcapd.c to be placed in the files subdirectory of the port

Try this crude patch.
Comment 2 Marek Zarychta 2025-05-03 16:55:23 UTC
(In reply to Trond Endrestøl from comment #1)
Thanks. I also considered this solution, but why didn't we need it for stable/14 in the past, nor for main aka CURRENT?

Perhaps I will be able to test it later.
Comment 3 Trond Endrestøl 2025-05-03 19:10:16 UTC
(In reply to Marek Zarychta from comment #2)
Same here. My builder is bogged down rebuilding packages for stable/14 after moving from stable/13 today.
Comment 4 Marek Zarychta 2025-05-03 19:25:59 UTC
It looks to me that -std=gnu89 is overridden by -std=gnu17 and it is probably the culprit.

cc -DHAVE_CONFIG_H -I. -I../..  -I.. -I../include -I../libnffile -I../inline  -I../collector -I../netflow  -DUSE_BPFSOCKET   -DHAVEPCAPAPPEND -DHAVEZLIB -Wno-error=incompatible-function-pointer-types -I/usr/local/include -D_BSD_SOURCE -D_DEFAULT_SOURCE -O2 -pipe -O2 -pipe -fno-strict-aliasing -march=nocona  -D_BSD_SOURCE -D_DEFAULT_SOURCE -fstack-protector-strong -std=gnu89  -std=gnu17 -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wmissing-noreturn -DNSEL -pthread -MT nfpcapd-flowdump.o -MD -MP -MF .deps/nfpcapd-flowdump.Tpo -c -o nfpcapd-flowdump.o `test -f 'flowdump.c' || echo './'`flowdump.c
Comment 5 Kurt Jaeger freebsd_committer freebsd_triage 2025-05-03 19:32:14 UTC
Created attachment 260123 [details]
alternative patch

This builds on 150 142 143 135 134, so ?
Comment 6 Dimitry Andric freebsd_committer freebsd_triage 2025-05-03 20:21:13 UTC
This was almost certainly broken with base b48ad95e67f2881977a767e040b906e20dd33844 ("netinet: Make ip.h self-contained") by @markj.

I'm unsure if there are any particular follow-up commits that need to be MFCd to work around this.
Comment 7 Dimitry Andric freebsd_committer freebsd_triage 2025-05-03 20:24:09 UTC
(In reply to Dimitry Andric from comment #6)
FWIW I tried recent snapshots:
- https://artifact.ci.freebsd.org/snapshot/stable-14/81fc9469313bc92138d73906622390d5bca5e444/ (2025-04-24T02:57) works
- https://artifact.ci.freebsd.org/snapshot/stable-14/b48ad95e67f2881977a767e040b906e20dd33844/ (2025-04-24T14:08) fails

$ git log --oneline 81fc9469313b..b48ad95e67f2
b48ad95e67f2 netinet: Make ip.h self-contained
1065a7ebdeb8 posixshm: Fix range locking in shm_write()
fb405ecd9f52 copy_file_range: Fix overlap checking
21ea2ef51cbe vm_object: Make a comment more clear
1b7e2cc10854 ktr: Make debug.ktr.verbose available whenever KTR is configured
Comment 8 Mark Johnston freebsd_committer freebsd_triage 2025-05-03 20:40:45 UTC
Ugh.  This port fails to build on main too.  It has an autoconf check which tries to figure out if sys/types.h needs to be explicitly included (search for FIX_INCLUDE).  The test uses in.h, so now determines that an explicit sys/types.h isn't needed, but some other headers still need it.

I will probably fix this by simply fixing those headers too.  That FIX_INCLUDE hack is misguided though, as sys/types.h should be included directly by at least nfpcapd.c: it uses uint32_t etc..
Comment 9 commit-hook freebsd_committer freebsd_triage 2025-05-03 20:49:41 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=75d173a84836d14b12a0f747ffed7d37766dd274

commit 75d173a84836d14b12a0f747ffed7d37766dd274
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2025-05-03 20:44:13 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2025-05-03 20:44:45 +0000

    netinet: Make in_systm.h self-contained

    PR:             286539
    MFC after:      3 days

 sys/netinet/in_systm.h                 | 2 ++
 tools/build/test-includes/badfiles.inc | 1 -
 2 files changed, 2 insertions(+), 1 deletion(-)
Comment 10 commit-hook freebsd_committer freebsd_triage 2025-05-03 20:49:42 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=981af1192cfa5ecd7bee9fe47386ed9d45397828

commit 981af1192cfa5ecd7bee9fe47386ed9d45397828
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2025-05-03 20:43:42 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2025-05-03 20:44:45 +0000

    bpf: Make bpf.h self-contained

    PR:             286539
    MFC after:      3 days

 sys/net/bpf.h                          | 1 +
 tools/build/test-includes/badfiles.inc | 1 -
 2 files changed, 1 insertion(+), 1 deletion(-)
Comment 11 commit-hook freebsd_committer freebsd_triage 2025-05-06 14:16:48 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=48881a2680ab42ea1b06d1c9685df9d295991d16

commit 48881a2680ab42ea1b06d1c9685df9d295991d16
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2025-05-03 20:43:42 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2025-05-06 14:15:38 +0000

    bpf: Make bpf.h self-contained

    PR:             286539
    MFC after:      3 days

    (cherry picked from commit 981af1192cfa5ecd7bee9fe47386ed9d45397828)

 sys/net/bpf.h                          | 1 +
 tools/build/test-includes/badfiles.inc | 1 -
 2 files changed, 1 insertion(+), 1 deletion(-)
Comment 12 commit-hook freebsd_committer freebsd_triage 2025-05-06 14:16:52 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=02dde7c43fe76a5dcdc170de1c2740a31629e106

commit 02dde7c43fe76a5dcdc170de1c2740a31629e106
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2025-05-03 20:44:13 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2025-05-06 14:15:38 +0000

    netinet: Make in_systm.h self-contained

    PR:             286539
    MFC after:      3 days

    (cherry picked from commit 75d173a84836d14b12a0f747ffed7d37766dd274)

 sys/netinet/in_systm.h                 | 2 ++
 tools/build/test-includes/badfiles.inc | 1 -
 2 files changed, 2 insertions(+), 1 deletion(-)
Comment 13 Trond Endrestøl 2025-05-06 14:39:44 UTC
Comment on attachment 260122 [details]
Proposed patch for src/nfpcapd/nfpcapd.c to be placed in the files subdirectory of the port

The problem is due to a missing inclusion of sys/types.h. I wish (system) header files would serve themselves by including the necessary header files. For systems not yet updated to the latest commits for this PR, adding CFLAGS+=-DFIX_INCLUDE to the port's Makefile does the trick.
Comment 14 Mark Johnston freebsd_committer freebsd_triage 2025-05-06 14:53:26 UTC
I've proposed the patches for inclusion in releng/14.3.

(In reply to Trond Endrestøl from comment #13)
We're slowly fixing system header files.  The FIX_INCLUDE hack is wrong though: nfpcapd.c /itself/ needs sys/types.h, and shouldn't be relying on other headers implicitly pulling it in.  If those headers change such that they no longer include sys/types.h, nfpcapd.c will be broken.  This kind of fragility is the main reason BSD system headers historically were not self-contained, AFAIK.

I would suggest patching nfdump to unconditionally include sys/types.h.
Comment 15 Marek Zarychta 2025-05-06 15:43:06 UTC
(In reply to Mark Johnston from comment #14)
Thank you for fixing it in an expedited way! 

I am not using this software, but I have it in my poudriere builds for a forgotten reason. It's old code, using gnu89 standard din port's makefile for some reason (it looks like it's being overridden by gnu17 though), but it's an important tool since we have only 3 programs of this kind in ports.
Comment 16 Kurt Jaeger freebsd_committer freebsd_triage 2025-05-06 18:18:12 UTC
markj, thanks for the patches for base. How long should we keep this PR open ? The updates will be in the REL and HEAD, but will still take quite a while until one can assume everything's in place ?
Comment 17 Trond Endrestøl 2025-05-07 07:08:00 UTC
Created attachment 260231 [details]
Patch for src/nfpcapd/nfpcapd.c enabling sys/types.h
Comment 18 Trond Endrestøl 2025-05-07 07:08:40 UTC
Created attachment 260232 [details]
Patch for src/nfpcapd/packet_bpf.c enabling sys/types.h
Comment 19 Trond Endrestøl 2025-05-07 07:09:12 UTC
Created attachment 260233 [details]
Patch for src/nfpcapd/pcaproc.h enabling sys/types.h
Comment 20 Marek Zarychta 2025-05-07 07:55:41 UTC
This port now builds fine for me now. I think we need to upstream the change in include files instead of adding patches which are really useless now, after markj@ made those files self-contained. I preapered port update submitted in the report for bug 286633.
Comment 21 commit-hook freebsd_committer freebsd_triage 2025-05-07 12:10:02 UTC
A commit in branch releng/14.3 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=f30669ba9725c37ea4336b4236a2f117276848a1

commit f30669ba9725c37ea4336b4236a2f117276848a1
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2025-05-03 20:43:42 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2025-05-07 12:05:08 +0000

    bpf: Make bpf.h self-contained

    PR:             286539
    MFC after:      3 days
    Approved by:    re (cperciva)

    (cherry picked from commit 981af1192cfa5ecd7bee9fe47386ed9d45397828)
    (cherry picked from commit 48881a2680ab42ea1b06d1c9685df9d295991d16)

 sys/net/bpf.h                          | 1 +
 tools/build/test-includes/badfiles.inc | 1 -
 2 files changed, 1 insertion(+), 1 deletion(-)
Comment 22 commit-hook freebsd_committer freebsd_triage 2025-05-07 12:10:03 UTC
A commit in branch releng/14.3 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=399bc0c1823c4643abbe3089bc6ed2f3ddf7bef7

commit 399bc0c1823c4643abbe3089bc6ed2f3ddf7bef7
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2025-05-03 20:44:13 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2025-05-07 12:04:59 +0000

    netinet: Make in_systm.h self-contained

    PR:             286539
    MFC after:      3 days
    Approved by:    re (cperciva)

    (cherry picked from commit 75d173a84836d14b12a0f747ffed7d37766dd274)
    (cherry picked from commit 02dde7c43fe76a5dcdc170de1c2740a31629e106)

 sys/netinet/in_systm.h                 | 2 ++
 tools/build/test-includes/badfiles.inc | 1 -
 2 files changed, 2 insertions(+), 1 deletion(-)
Comment 23 Mark Johnston freebsd_committer freebsd_triage 2025-05-07 12:18:26 UTC
(In reply to Kurt Jaeger from comment #16)
I have no plans to do anything further for this PR.  AFAIK the port build failure is now resolved on main, stable/14 and 14.3, so this PR can probably be closed.

I think the port should further be patched to remove FIX_INCLUDE and unconditionally include sys/types.h, but it's not a high priority.
Comment 24 Marek Zarychta 2025-05-07 12:53:02 UTC
I don't know if it will proceed any further, but I created this issue: https://github.com/phaag/nfdump/issues/620
Comment 25 Marek Zarychta 2025-05-09 11:45:46 UTC
The upstream fixed early FreeBSD 14.3 build problems 
https://github.com/phaag/nfdump/commit/a7feab45400d96757e86ac01a20c37f2055974fc
Comment 26 Marek Zarychta 2025-05-09 14:33:10 UTC
With this double fix, should we still keep this PR open ?
Comment 27 Trond Endrestøl 2025-05-09 17:08:37 UTC
(In reply to Marek Zarychta from comment #26)
I think it's safe to mark this one as fixed.