From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202602 header.b=SZgOxZYs; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id E94FF5A004E for ; Mon, 23 Feb 2026 06:33:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202602; t=1771824822; bh=xrq2hOehF4pBfdZGhe87NWRjJVaM+0nD9fmXCKKJpsI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=SZgOxZYs2UpZcfuXKV3ERpR/Kf42t8IvUXOCI6PXerf3yWZH5xI0Xk1g/AVYdhRm5 JvC+64ZsqMBsqi/9E15oDybTYF+JTFATwDLguXOaDQMqyd76FUQ9r5iVmPQCK6mslA KQxsHOuZAsHEJKgGadtOfLu8ouoZhUmZyOAk3Ct/qMW4aCuNltlviHo9BsjKfxkCbw q/QLml3IAkxRr924t4T4JDBPiQiouimRmxujjfATxLOyQ0ZM6x33OZzJIS1sGH0vW2 +TL6OT+8zIsPfKlGLgAKTvb6bdD4EnbNkMMna5wUkzPcS8wHPf6Et0ddGBI23wm42s n9S/1j/512vEw== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4fK8fG674qz4w2D; Mon, 23 Feb 2026 16:33:42 +1100 (AEDT) Date: Mon, 23 Feb 2026 16:33:32 +1100 From: David Gibson To: Peter Foley Subject: Re: [PATCH] Add missing includes to headers Message-ID: References: <20260219184454.1501389-1-pefoley@google.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="Ukql9ilyfYzi3O/4" Content-Disposition: inline In-Reply-To: <20260219184454.1501389-1-pefoley@google.com> Message-ID-Hash: CNEQWTUNUZVUY6RHJPETTBLXPRAK5C4Z X-Message-ID-Hash: CNEQWTUNUZVUY6RHJPETTBLXPRAK5C4Z X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --Ukql9ilyfYzi3O/4 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Feb 19, 2026 at 01:44:54PM -0500, Peter Foley wrote: > Support build systems like bazel that check that headers are > self-contained. >=20 > Signed-off-by: Peter Foley There are kind of two schools of thoughts on headers. One is that every header should #include anything it relies on. The other is that headers should #include nothing, and .c files should includde everything they need in the right order. The advantages of the second approach are that it makes it easier to keep #includes in .c files minimal, and makes circular dependencies more obvious and easier to dientanble. We've kinda sorta been using approach two in passt, but not entirely, and honestly, it's not really working. So I'm happy to convert to the former approach. However, if we're adding #includes in the headers so they're self contained, then we should be able to also *remove* a bunch of #includes from .c files (and other .h files) which were previously only there to satisfy the indirect dependencies. > --- > flow.h | 6 ++++++ > flow_table.h | 1 + > icmp_flow.h | 2 ++ > inany.h | 5 +++++ > ip.h | 2 ++ > linux_dep.h | 3 +++ > pif.h | 4 ++++ > seccomp.sh | 5 +++++ > siphash.h | 3 +++ > tap.h | 5 +++++ > tcp_conn.h | 4 ++++ > tcp_internal.h | 5 +++++ > udp_internal.h | 3 +++ > util.c | 1 + > 14 files changed, 49 insertions(+) >=20 > diff --git a/flow.h b/flow.h > index d636358..897c9ea 100644 > --- a/flow.h > +++ b/flow.h > @@ -7,6 +7,12 @@ > #ifndef FLOW_H > #define FLOW_H > =20 > +#include > +#include > + > +#include "inany.h" > +#include "util.h" > + > #define FLOW_TIMER_INTERVAL 1000 /* ms */ > =20 > /** > diff --git a/flow_table.h b/flow_table.h > index 73de13b..8fb7b5c 100644 > --- a/flow_table.h > +++ b/flow_table.h > @@ -7,6 +7,7 @@ > #ifndef FLOW_TABLE_H > #define FLOW_TABLE_H > =20 > +#include "pif.h" > #include "tcp_conn.h" > #include "icmp_flow.h" > #include "udp_flow.h" > diff --git a/icmp_flow.h b/icmp_flow.h > index fb93801..3af98be 100644 > --- a/icmp_flow.h > +++ b/icmp_flow.h > @@ -7,6 +7,8 @@ > #ifndef ICMP_FLOW_H > #define ICMP_FLOW_H > =20 > +#include "flow.h" > + > /** > * struct icmp_ping_flow - Descriptor for a flow of ping requests/replies > * @f: Generic flow information > diff --git a/inany.h b/inany.h > index b02c289..c7de094 100644 > --- a/inany.h > +++ b/inany.h > @@ -9,6 +9,11 @@ > #ifndef INANY_H > #define INANY_H > =20 > +#include > + > +#include "ip.h" > +#include "siphash.h" > + > struct siphash_state; > =20 > /** union inany_addr - Represents either an IPv4 or IPv6 address > diff --git a/ip.h b/ip.h > index a8043c2..3be2d4e 100644 > --- a/ip.h > +++ b/ip.h > @@ -9,6 +9,8 @@ > #include > #include > =20 > +#include "util.h" > + > #define IN4_IS_ADDR_UNSPECIFIED(a) \ > (((struct in_addr *)(a))->s_addr =3D=3D htonl_constant(INADDR_ANY)) > #define IN4_IS_ADDR_BROADCAST(a) \ > diff --git a/linux_dep.h b/linux_dep.h > index 89e590c..3f8184b 100644 > --- a/linux_dep.h > +++ b/linux_dep.h > @@ -7,6 +7,9 @@ > #ifndef LINUX_DEP_H > #define LINUX_DEP_H > =20 > +#include > +#include > + > /* struct tcp_info_linux - Information from Linux TCP_INFO getsockopt() > * > * Largely derived from include/linux/tcp.h in the Linux kernel > diff --git a/pif.h b/pif.h > index 0f7f667..7c755bd 100644 > --- a/pif.h > +++ b/pif.h > @@ -7,6 +7,10 @@ > #ifndef PIF_H > #define PIF_H > =20 > +#include > + > +#include "epoll_type.h" > + > union inany_addr; > union sockaddr_inany; > =20 > diff --git a/seccomp.sh b/seccomp.sh > index 60ebe84..5347586 100755 > --- a/seccomp.sh > +++ b/seccomp.sh > @@ -34,6 +34,11 @@ AUDIT_ARCH=3D"AUDIT_ARCH_$(echo ${ARCH} | tr '[a-z]' '= [A-Z]' \ > =20 > HEADER=3D"/* This file was automatically generated by $(basename ${0}) */ > =20 > +#include > +#include > +#include > +#include > + > #ifndef AUDIT_ARCH_PPC64LE > #define AUDIT_ARCH_PPC64LE (AUDIT_ARCH_PPC64 | __AUDIT_ARCH_LE) > #endif" > diff --git a/siphash.h b/siphash.h > index e760236..bbddcac 100644 > --- a/siphash.h > +++ b/siphash.h > @@ -44,6 +44,9 @@ > #ifndef SIPHASH_H > #define SIPHASH_H > =20 > +#include > +#include > + > /** > * struct siphash_state - Internal state of siphash calculation > */ > diff --git a/tap.h b/tap.h > index cc780d1..07ca096 100644 > --- a/tap.h > +++ b/tap.h > @@ -6,6 +6,11 @@ > #ifndef TAP_H > #define TAP_H > =20 > +#include > +#include > + > +#include "passt.h" > + > /** L2_MAX_LEN_PASTA - Maximum frame length for pasta mode (with L2 head= er) > * > * The kernel tuntap device imposes a maximum frame size of 65535 includ= ing > diff --git a/tcp_conn.h b/tcp_conn.h > index 21cea10..d4d0139 100644 > --- a/tcp_conn.h > +++ b/tcp_conn.h > @@ -9,6 +9,10 @@ > #ifndef TCP_CONN_H > #define TCP_CONN_H > =20 > +#include > + > +#include "flow.h" > + > /** > * struct tcp_tap_conn - Descriptor for a TCP connection (not spliced) > * @f: Generic flow information > diff --git a/tcp_internal.h b/tcp_internal.h > index 518913b..591e58c 100644 > --- a/tcp_internal.h > +++ b/tcp_internal.h > @@ -6,6 +6,11 @@ > #ifndef TCP_INTERNAL_H > #define TCP_INTERNAL_H > =20 > +#include > +#include > + > +#include "util.h" > + > #define MAX_WS 8 > #define MAX_WINDOW (1 << (16 + (MAX_WS))) > =20 > diff --git a/udp_internal.h b/udp_internal.h > index 0a8fe49..64e4577 100644 > --- a/udp_internal.h > +++ b/udp_internal.h > @@ -6,6 +6,9 @@ > #ifndef UDP_INTERNAL_H > #define UDP_INTERNAL_H > =20 > +#include > +#include > + > #include "tap.h" /* needed by udp_meta_t */ > =20 > /** > diff --git a/util.c b/util.c > index a48f727..db27431 100644 > --- a/util.c > +++ b/util.c > @@ -25,6 +25,7 @@ > #include > #include > #include > +#include > #include > =20 > #include "linux_dep.h" > --=20 > 2.53.0.371.g1d285c8824-goog >=20 --=20 David Gibson (he or they) | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you, not the other way | around. http://www.ozlabs.org/~dgibson --Ukql9ilyfYzi3O/4 Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmmb5pcACgkQzQJF27ox 2Gd6mw/+IPTAeLoEl7pIcaC2mQwqMe6q66sHKdsZGxdCnxuOQ4cdSVcsGoc7Vu7a Wl/mjqRmHJ+72EUKLQKlRmC5WpjdXZLRbJKuZJuAPiyUQRKZOqKJeWycFO8pCVHy mSd8cKDLnJg3cZmi0ZN3Jhdyvlb8B4EjOlItOaZKIl1E8UiDsWHZvjLmwrcUT1mm gE0iMRl9/KqGS5SyxBsD5GX5dOH6AFR67Ntn+7QmuvFTDyl0FnXPPvbnkc1tZk1/ X2PMF9iUHtHIFsPdB3GUfCIKvmBN95lQ3F9odnswzxKKBdEdt7r2Iuordt/icU9J BiR5g3RFDaEZkBKwWGu5YvJmKnZoPynrq7Bzl/jerNdUsstFIAUZwEcMh41G3pfc viibnylMLG5hQpu1z2oT4xPUd2KAWb/NfikO9woENotUEo8pgTQye0QlI64fmTxT CduDDUMfR1l43FzxnDMRJEkl6OfchnZfZCz70z9wVeLjyqGt7qv3JT7cp7JXYYWM LbR6KaYE8bHEAE5S9sk8AT6TGj6oteEkdInGRhM251cUj5JrnNFpW0bsAqWXY8iu PqJ2AoL31VBHepkvm45PflWCa6RYqtcnWvWniAJKhZvf7oXc2tdzUPQZ6RIfGzb3 4vl77I51qd5JQoelrQzS54x20uXySmaYApY7z4RYlIxaXHSBVVs= =0Sfv -----END PGP SIGNATURE----- --Ukql9ilyfYzi3O/4--