Skip to content

Commit 515d544

Browse files
jmberg-intelzx2c4
authored andcommitted
netlink: consistently use NLA_POLICY_EXACT_LEN()
Change places that open-code NLA_POLICY_EXACT_LEN() to use the macro instead, giving us flexibility in how we handle the details of the macro. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Acked-by: Matthieu Baerts <matthieu.baerts@tessares.net> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
1 parent 1a41e32 commit 515d544

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/netlink.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,21 @@ static struct genl_family genl_family;
2020
static const struct nla_policy device_policy[WGDEVICE_A_MAX + 1] = {
2121
[WGDEVICE_A_IFINDEX] = { .type = NLA_U32 },
2222
[WGDEVICE_A_IFNAME] = { .type = NLA_NUL_STRING, .len = IFNAMSIZ - 1 },
23-
[WGDEVICE_A_PRIVATE_KEY] = { .type = NLA_EXACT_LEN, .len = NOISE_PUBLIC_KEY_LEN },
24-
[WGDEVICE_A_PUBLIC_KEY] = { .type = NLA_EXACT_LEN, .len = NOISE_PUBLIC_KEY_LEN },
23+
[WGDEVICE_A_PRIVATE_KEY] = NLA_POLICY_EXACT_LEN(NOISE_PUBLIC_KEY_LEN),
24+
[WGDEVICE_A_PUBLIC_KEY] = NLA_POLICY_EXACT_LEN(NOISE_PUBLIC_KEY_LEN),
2525
[WGDEVICE_A_FLAGS] = { .type = NLA_U32 },
2626
[WGDEVICE_A_LISTEN_PORT] = { .type = NLA_U16 },
2727
[WGDEVICE_A_FWMARK] = { .type = NLA_U32 },
2828
[WGDEVICE_A_PEERS] = { .type = NLA_NESTED }
2929
};
3030

3131
static const struct nla_policy peer_policy[WGPEER_A_MAX + 1] = {
32-
[WGPEER_A_PUBLIC_KEY] = { .type = NLA_EXACT_LEN, .len = NOISE_PUBLIC_KEY_LEN },
33-
[WGPEER_A_PRESHARED_KEY] = { .type = NLA_EXACT_LEN, .len = NOISE_SYMMETRIC_KEY_LEN },
32+
[WGPEER_A_PUBLIC_KEY] = NLA_POLICY_EXACT_LEN(NOISE_PUBLIC_KEY_LEN),
33+
[WGPEER_A_PRESHARED_KEY] = NLA_POLICY_EXACT_LEN(NOISE_SYMMETRIC_KEY_LEN),
3434
[WGPEER_A_FLAGS] = { .type = NLA_U32 },
3535
[WGPEER_A_ENDPOINT] = { .type = NLA_MIN_LEN, .len = sizeof(struct sockaddr) },
3636
[WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL] = { .type = NLA_U16 },
37-
[WGPEER_A_LAST_HANDSHAKE_TIME] = { .type = NLA_EXACT_LEN, .len = sizeof(struct __kernel_timespec) },
37+
[WGPEER_A_LAST_HANDSHAKE_TIME] = NLA_POLICY_EXACT_LEN(sizeof(struct __kernel_timespec)),
3838
[WGPEER_A_RX_BYTES] = { .type = NLA_U64 },
3939
[WGPEER_A_TX_BYTES] = { .type = NLA_U64 },
4040
[WGPEER_A_ALLOWEDIPS] = { .type = NLA_NESTED },

0 commit comments

Comments
 (0)