Skip to content

Commit 88cedad

Browse files
Asbjørn Sloth Tønnesenzx2c4
authored andcommitted
wireguard: uapi: generate header with ynl-gen
Use ynl-gen to generate the UAPI header for WireGuard. The cosmetic changes in this patch confirms that the spec is aligned with the implementation. By using the generated version, it ensures that they stay in sync. Changes in the generated header: * Trivial header guard rename. * Trivial white space changes. * Trivial comment changes. * Precompute bitflags in ynl-gen (see [1]). * Drop __*_F_ALL constants (see [1]). [1] https://lore.kernel.org/r/20251014123201.6ecfd146@kernel.org/ No behavioural changes intended. Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
1 parent 8d97487 commit 88cedad

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

drivers/net/wireguard/netlink.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ static const struct nla_policy device_policy[WGDEVICE_A_MAX + 1] = {
2626
[WGDEVICE_A_IFNAME] = { .type = NLA_NUL_STRING, .len = IFNAMSIZ - 1 },
2727
[WGDEVICE_A_PRIVATE_KEY] = NLA_POLICY_EXACT_LEN(WG_KEY_LEN),
2828
[WGDEVICE_A_PUBLIC_KEY] = NLA_POLICY_EXACT_LEN(WG_KEY_LEN),
29-
[WGDEVICE_A_FLAGS] = NLA_POLICY_MASK(NLA_U32, __WGDEVICE_F_ALL),
29+
[WGDEVICE_A_FLAGS] = NLA_POLICY_MASK(NLA_U32, 0x1),
3030
[WGDEVICE_A_LISTEN_PORT] = { .type = NLA_U16 },
3131
[WGDEVICE_A_FWMARK] = { .type = NLA_U32 },
3232
[WGDEVICE_A_PEERS] = NLA_POLICY_NESTED_ARRAY(peer_policy),
@@ -35,7 +35,7 @@ static const struct nla_policy device_policy[WGDEVICE_A_MAX + 1] = {
3535
static const struct nla_policy peer_policy[WGPEER_A_MAX + 1] = {
3636
[WGPEER_A_PUBLIC_KEY] = NLA_POLICY_EXACT_LEN(WG_KEY_LEN),
3737
[WGPEER_A_PRESHARED_KEY] = NLA_POLICY_EXACT_LEN(WG_KEY_LEN),
38-
[WGPEER_A_FLAGS] = NLA_POLICY_MASK(NLA_U32, __WGPEER_F_ALL),
38+
[WGPEER_A_FLAGS] = NLA_POLICY_MASK(NLA_U32, 0x7),
3939
[WGPEER_A_ENDPOINT] = NLA_POLICY_MIN_LEN(sizeof(struct sockaddr)),
4040
[WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL] = { .type = NLA_U16 },
4141
[WGPEER_A_LAST_HANDSHAKE_TIME] = NLA_POLICY_EXACT_LEN(sizeof(struct __kernel_timespec)),
@@ -49,7 +49,7 @@ static const struct nla_policy allowedip_policy[WGALLOWEDIP_A_MAX + 1] = {
4949
[WGALLOWEDIP_A_FAMILY] = { .type = NLA_U16 },
5050
[WGALLOWEDIP_A_IPADDR] = NLA_POLICY_MIN_LEN(sizeof(struct in_addr)),
5151
[WGALLOWEDIP_A_CIDR_MASK] = { .type = NLA_U8 },
52-
[WGALLOWEDIP_A_FLAGS] = NLA_POLICY_MASK(NLA_U32, __WGALLOWEDIP_F_ALL),
52+
[WGALLOWEDIP_A_FLAGS] = NLA_POLICY_MASK(NLA_U32, 0x1),
5353
};
5454

5555
static struct wg_device *lookup_interface(struct nlattr **attrs,

include/uapi/linux/wireguard.h

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,29 @@
1-
/* SPDX-License-Identifier: (GPL-2.0 WITH Linux-syscall-note) OR MIT */
2-
/*
3-
* Copyright (C) 2015-2019 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
4-
*/
1+
/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */
2+
/* Do not edit directly, auto-generated from: */
3+
/* Documentation/netlink/specs/wireguard.yaml */
4+
/* YNL-GEN uapi header */
5+
/* To regenerate run: tools/net/ynl/ynl-regen.sh */
56

6-
#ifndef _WG_UAPI_WIREGUARD_H
7-
#define _WG_UAPI_WIREGUARD_H
7+
#ifndef _UAPI_LINUX_WIREGUARD_H
8+
#define _UAPI_LINUX_WIREGUARD_H
89

9-
#define WG_GENL_NAME "wireguard"
10-
#define WG_GENL_VERSION 1
10+
#define WG_GENL_NAME "wireguard"
11+
#define WG_GENL_VERSION 1
1112

12-
#define WG_KEY_LEN 32
13+
#define WG_KEY_LEN 32
1314

1415
enum wgdevice_flag {
15-
WGDEVICE_F_REPLACE_PEERS = 1U << 0,
16-
__WGDEVICE_F_ALL = WGDEVICE_F_REPLACE_PEERS
16+
WGDEVICE_F_REPLACE_PEERS = 1,
1717
};
1818

1919
enum wgpeer_flag {
20-
WGPEER_F_REMOVE_ME = 1U << 0,
21-
WGPEER_F_REPLACE_ALLOWEDIPS = 1U << 1,
22-
WGPEER_F_UPDATE_ONLY = 1U << 2,
23-
__WGPEER_F_ALL = WGPEER_F_REMOVE_ME | WGPEER_F_REPLACE_ALLOWEDIPS |
24-
WGPEER_F_UPDATE_ONLY
20+
WGPEER_F_REMOVE_ME = 1,
21+
WGPEER_F_REPLACE_ALLOWEDIPS = 2,
22+
WGPEER_F_UPDATE_ONLY = 4,
2523
};
2624

2725
enum wgallowedip_flag {
28-
WGALLOWEDIP_F_REMOVE_ME = 1U << 0,
29-
__WGALLOWEDIP_F_ALL = WGALLOWEDIP_F_REMOVE_ME
26+
WGALLOWEDIP_F_REMOVE_ME = 1,
3027
};
3128

3229
enum wgdevice_attribute {
@@ -39,6 +36,7 @@ enum wgdevice_attribute {
3936
WGDEVICE_A_LISTEN_PORT,
4037
WGDEVICE_A_FWMARK,
4138
WGDEVICE_A_PEERS,
39+
4240
__WGDEVICE_A_LAST
4341
};
4442
#define WGDEVICE_A_MAX (__WGDEVICE_A_LAST - 1)
@@ -55,6 +53,7 @@ enum wgpeer_attribute {
5553
WGPEER_A_TX_BYTES,
5654
WGPEER_A_ALLOWEDIPS,
5755
WGPEER_A_PROTOCOL_VERSION,
56+
5857
__WGPEER_A_LAST
5958
};
6059
#define WGPEER_A_MAX (__WGPEER_A_LAST - 1)
@@ -65,6 +64,7 @@ enum wgallowedip_attribute {
6564
WGALLOWEDIP_A_IPADDR,
6665
WGALLOWEDIP_A_CIDR_MASK,
6766
WGALLOWEDIP_A_FLAGS,
67+
6868
__WGALLOWEDIP_A_LAST
6969
};
7070
#define WGALLOWEDIP_A_MAX (__WGALLOWEDIP_A_LAST - 1)
@@ -77,4 +77,4 @@ enum wg_cmd {
7777
};
7878
#define WG_CMD_MAX (__WG_CMD_MAX - 1)
7979

80-
#endif /* _WG_UAPI_WIREGUARD_H */
80+
#endif /* _UAPI_LINUX_WIREGUARD_H */

0 commit comments

Comments
 (0)