[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <29155dac-97c4-4213-8db5-194d9109050e@fiberby.net>
Date: Tue, 18 Nov 2025 17:16:12 +0000
From: Asbjørn Sloth Tønnesen <ast@...erby.net>
To: "Jason A. Donenfeld" <Jason@...c4.com>
Cc: "David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>, Donald Hunter <donald.hunter@...il.com>,
Simon Horman <horms@...nel.org>, Jacob Keller <jacob.e.keller@...el.com>,
Andrew Lunn <andrew+netdev@...n.ch>, wireguard@...ts.zx2c4.com,
netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
Jordan Rife <jordan@...fe.io>
Subject: Re: [PATCH net-next v3 08/11] tools: ynl: add sample for wireguard
On 11/18/25 3:20 PM, Jason A. Donenfeld wrote:
> On Wed, Nov 05, 2025 at 06:32:17PM +0000, Asbjørn Sloth Tønnesen wrote:
>> +CFLAGS_wireguard:=$(call get_hdr_inc,_LINUX_WIREGUARD_H,wireguard.h) \
>> + -D _WG_UAPI_WIREGUARD_H # alternate pre-YNL guard
>
> I don't totally grok what's going on here. As I understand it, this
> makefile creates `wireguard-user.h` in the generated/ include path,
> which has all the various netlink wrapper declarations. And then this
> also references, somehow, include/uapi/linux/wireguard.h, for the constants.
> For some reason, you're then defining _WG_UAPI_WIREGUARD_H here, so that
> wireguard.h from /usr/include doesn't clash. But also, why would it?
> Isn't this just a matter of placing $(src)/include/uapi earlier in the
> include file path?
The aim is to use the generated in-tree header, while avoiding making a
copy, and avoiding the system header.
As an example then in tools/net/ynl/generated/Makefile:
%-user.o: %-user.c %-user.h
@echo -e "\tCC $@"
@$(COMPILE.c) $(CFLAGS_$*) -o $@ $<
Where for the "wireguard-user.o" target, then "$(CFLAGS_$*)" expands to
"$CFLAGS_wireguard".
CFLAGS_wireguard has two parts the normal one similar to the other families,
and a transitional extra guard.
The header guard in the old UAPI header is "_WG_UAPI_WIREGUARD_H".
The header guard in the new UAPI header in-tree is "_UAPI_LINUX_WIREGUARD_H".
The header guard in the new UAPI header in-system is "_LINUX_WIREGUARD_H".
Linux uapi headers are installed using scripts/headers_install.sh, which
transforms the headers slightly, one of these transformations is to alter
the header guard, stripping the _UAPI in the beginning of the guard.
So "get_hdr_inc=-D$(1) -include $(UAPI_PATH)/linux/$(2)" does:
1) Defines the in-system guard
2) Includes the in-tree header
The purpose of defining the in-system guard is disable the include in
the code, as it's header guard is already defined.
I added the extra transitional define of the old UAPI guard, so that
it also works on systems with the old header installed in /usr.
This extra line can be removed in a few releases, when we don't care
about compiling these tools on a system with the old header installed.
Powered by blists - more mailing lists