Skip to content

Conversation

@timp87
Copy link
Contributor

@timp87 timp87 commented Jan 6, 2026

Fix missing header sys/socket.h:

configure:29217: checking for struct arpreq.arp_pa
.../net/if_arp.h: error: field has incomplete type 'struct sockaddr'

Fix ac_aggr.arp_pa test, replacing it with a test of a data member
that Squid code is actually using:

conftest.cpp:112:5: error: value of type 'struct sockaddr' is not
    contextually convertible to 'bool'

Discovered while porting Squid v7 to FreeBSD.

1. Fix missing header `sys/socket.h`

```
configure:29217: checking for struct arpreq.arp_pa
.../net/if_arp.h:89:18: error: field has incomplete type 'struct sockaddr'
```

2. Fix ac_aggr.arp_pa test
```
conftest.cpp:112:5: error: value of type 'struct sockaddr' is not contextually convertible to 'bool'
```
@squid-anubis squid-anubis added the M-failed-description https://github.com/measurement-factory/anubis#pull-request-labels label Jan 6, 2026
@squid-anubis

This comment was marked as resolved.

@timp87
Copy link
Contributor Author

timp87 commented Jan 6, 2026

  1. The EUI check uses #include <sys/socket.h> header placed under #if HAVE_SYS_SOCKET_H condition https://github.com/squid-cache/squid/blob/SQUID_7_3/configure.ac#L1003-L1005
    Full error
configure:29217: checking for struct arpreq.arp_pa
configure:29217: c++ -std=c++17 -c  -Wall -Wextra -Wno-unused-private-field -Wno-implicit-fallthrough -Wpointer-arith -Wwrite-strings -Wcomments -Wshadow -Wmissing-declarations -Woverloaded-virtual  -D_REENTRANT -DBOOL_DEFINED -isystem /u
sr/local/include conftest.cpp >&5
In file included from conftest.cpp:103:
/usr/include/net/if_arp.h:89:18: error: field has incomplete type 'struct sockaddr'
   89 |         struct  sockaddr arp_pa;                /* protocol address */
      |                          ^
/usr/include/net/if_arp.h:89:9: note: forward declaration of 'sockaddr'
   89 |         struct  sockaddr arp_pa;                /* protocol address */
      |                 ^
/usr/include/net/if_arp.h:90:18: error: field has incomplete type 'struct sockaddr'
   90 |         struct  sockaddr arp_ha;                /* hardware address */
      |                          ^
/usr/include/net/if_arp.h:89:9: note: forward declaration of 'sockaddr'
   89 |         struct  sockaddr arp_pa;                /* protocol address */
      |                 ^
2 errors generated.

The problem here is that HAVE_SYS_SOCKET_H is not defined yet at that point, so it's skipped and the check fails.
I'm not sure how to fix it better like remove #if HAVE_SYS_SOCKET_H condition and let the header be included unconditionally, or include this header into some AC_CHECK_HEADERS a bit above, or something else. So please guide me how you wanted me this to do. For now I just put separate simple AC_CHECK_HEADERS
BTW, there is big AC_CHECK_HEADERS https://github.com/squid-cache/squid/blob/SQUID_7_3/configure.ac#L1758C1-L1758C17 where HAVE_SYS_SOCKET_H will be set, but it's below the test

  1. Once I fixed previous error I get another:
configure:29224: checking for struct arpreq.arp_pa
configure:29224: c++ -std=c++17 -c  -Wall -Wextra -Wno-unused-private-field -Wno-implicit-fallthrough -Wpointer-arith -Wwrite-strings -Wcomments -Wshadow -Wmissing-declarations -Woverloaded-virtual  -D_REENTRANT -DBOOL_DEFINED -isystem /usr/local/include conftest.cpp >&5
conftest.cpp:112:5: error: value of type 'struct sockaddr' is not contextually convertible to 'bool'
  112 | if (ac_aggr.arp_pa)
      |     ^~~~~~~~~~~~~~
1 error generated.

So use particular member (sa_family) for the check.

@squid-anubis squid-anubis removed the M-failed-description https://github.com/measurement-factory/anubis#pull-request-labels label Jan 6, 2026
@rousskov rousskov changed the title Fix ./configure eui check Fix ./configure eui check on FreeBSD Jan 6, 2026
Copy link
Contributor

@rousskov rousskov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the fix and useful triage details.

#endif
]])
AC_CHECK_MEMBER([struct arpreq.arp_pa],[],[
AC_CHECK_HEADERS(sys/socket.h)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem here is that HAVE_SYS_SOCKET_H is not defined yet at that point, so it's skipped and the check fails.

I'm not sure how to fix it better like remove #if HAVE_SYS_SOCKET_H condition and let the header be included unconditionally, or include this header into some AC_CHECK_HEADERS a bit above, or something else. So please guide me how you wanted me this to do

I think what you did is the right solution for this PR -- it matches how similar code solves similar problems. There may be a better, more comprehensive solution, but I would place that outside this small/focused PR scope.

This comment answers a question without requesting any changes.

Copy link
Contributor

@yadij yadij Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO the checks here should be including our compat/types.h and compat/socket.h instead of the system headers. But that will still need this change first (along with other headers tested). So I am putting that on my TODO list for later, no need to do it here.

Copy link
Contributor

@rousskov rousskov Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO the checks here should be including our compat/types.h and compat/socket.h

I am against using compat/ sources in ./configure checks because that would imply that compat/ sources cannot reliably use ./configure results. However, there is now a better place for that discussion. Let's continue this conversation there.

Squid never uses arpreq.arp_pa.sa_family. Squid uses arpreq.arp_ha.sa_family, among other arpreq.arp_ha members.
@yadij yadij added S-could-use-an-approval An approval may speed this PR merger (but is not required) backport-to-v7 maintainer has approved these changes for v7 backporting labels Jan 7, 2026
@yadij yadij changed the title Fix ./configure eui check on FreeBSD EUI: Fix feature detection on FreeBSD Jan 7, 2026
@yadij yadij changed the title EUI: Fix feature detection on FreeBSD EUI: Fix feature detection Jan 7, 2026
#endif
]])
AC_CHECK_MEMBER([struct arpreq.arp_pa],[],[
AC_CHECK_HEADERS(sys/socket.h)
Copy link
Contributor

@rousskov rousskov Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO the checks here should be including our compat/types.h and compat/socket.h

I am against using compat/ sources in ./configure checks because that would imply that compat/ sources cannot reliably use ./configure results. However, there is now a better place for that discussion. Let's continue this conversation there.

@rousskov rousskov added the M-cleared-for-merge https://github.com/measurement-factory/anubis#pull-request-labels label Jan 7, 2026
@rousskov rousskov changed the title EUI: Fix feature detection Fix ./configure EUI check Jan 7, 2026
@rousskov
Copy link
Contributor

rousskov commented Jan 7, 2026

I adjusted the title to make it specific to ./configure again (and to avoid introducing EUI prefix).

Copy link
Contributor

@kinkie kinkie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's get this fixed for now, and we can improve later

@rousskov rousskov removed the S-could-use-an-approval An approval may speed this PR merger (but is not required) label Jan 7, 2026
squid-anubis pushed a commit that referenced this pull request Jan 7, 2026
Fix missing header `sys/socket.h`:

    configure:29217: checking for struct arpreq.arp_pa
    .../net/if_arp.h: error: field has incomplete type 'struct sockaddr'

Fix `ac_aggr.arp_pa` test, replacing it with a test of a data member
that Squid code is actually using:

    conftest.cpp:112:5: error: value of type 'struct sockaddr' is not
        contextually convertible to 'bool'

Discovered while porting Squid v7 to FreeBSD.
@squid-anubis squid-anubis added the M-waiting-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels label Jan 7, 2026
@squid-anubis squid-anubis added M-merged https://github.com/measurement-factory/anubis#pull-request-labels and removed M-waiting-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels M-cleared-for-merge https://github.com/measurement-factory/anubis#pull-request-labels labels Jan 8, 2026
squidadm pushed a commit to squidadm/squid that referenced this pull request Jan 8, 2026
Fix missing header `sys/socket.h`:

    configure:29217: checking for struct arpreq.arp_pa
    .../net/if_arp.h: error: field has incomplete type 'struct sockaddr'

Fix `ac_aggr.arp_pa` test, replacing it with a test of a data member
that Squid code is actually using:

    conftest.cpp:112:5: error: value of type 'struct sockaddr' is not
        contextually convertible to 'bool'

Discovered while porting Squid v7 to FreeBSD.
@squidadm squidadm removed the backport-to-v7 maintainer has approved these changes for v7 backporting label Jan 8, 2026
@squidadm
Copy link
Collaborator

squidadm commented Jan 8, 2026

queued for backport to v7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

M-merged https://github.com/measurement-factory/anubis#pull-request-labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants