]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
wireguard: netlink: convert to split ops
authorAsbjørn Sloth Tønnesen <ast@fiberby.net>
Wed, 26 Nov 2025 17:35:35 +0000 (17:35 +0000)
committerJason A. Donenfeld <Jason@zx2c4.com>
Mon, 1 Dec 2025 02:25:09 +0000 (03:25 +0100)
This patch converts WireGuard from using the legacy struct genl_ops
to struct genl_split_ops, by applying the same transformation as
genl_cmd_full_to_split() would otherwise do at runtime.

WGDEVICE_A_MAX is swapped for WGDEVICE_A_PEERS, while they are
currently equivalent, then .maxattr should be the maximum attribute
that a given command supports, and not change along with WGDEVICE_A_MAX.

This is an incremental step towards adopting netlink policy code
generated by ynl-gen, ensuring that the code and spec is aligned.

This is a trivial patch with no behavioural changes intended.

Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
drivers/net/wireguard/netlink.c

index 682678d24a9f6ef327b56c6f4b1841077e1471b9..e7efe5f8465dca3403c7be7b44e60c3b6453b143 100644 (file)
@@ -616,28 +616,30 @@ out_nodev:
        return ret;
 }
 
-static const struct genl_ops genl_ops[] = {
+static const struct genl_split_ops wireguard_nl_ops[] = {
        {
                .cmd = WG_CMD_GET_DEVICE,
                .start = wg_get_device_start,
                .dumpit = wg_get_device_dump,
                .done = wg_get_device_done,
-               .flags = GENL_UNS_ADMIN_PERM
+               .policy = device_policy,
+               .maxattr = WGDEVICE_A_PEERS,
+               .flags = GENL_UNS_ADMIN_PERM | GENL_CMD_CAP_DUMP,
        }, {
                .cmd = WG_CMD_SET_DEVICE,
                .doit = wg_set_device,
-               .flags = GENL_UNS_ADMIN_PERM
+               .policy = device_policy,
+               .maxattr = WGDEVICE_A_PEERS,
+               .flags = GENL_UNS_ADMIN_PERM | GENL_CMD_CAP_DO,
        }
 };
 
 static struct genl_family genl_family __ro_after_init = {
-       .ops = genl_ops,
-       .n_ops = ARRAY_SIZE(genl_ops),
+       .split_ops = wireguard_nl_ops,
+       .n_split_ops = ARRAY_SIZE(wireguard_nl_ops),
        .name = WG_GENL_NAME,
        .version = WG_GENL_VERSION,
-       .maxattr = WGDEVICE_A_MAX,
        .module = THIS_MODULE,
-       .policy = device_policy,
        .netnsok = true
 };