Skip to content

Commit 73af07d

Browse files
Asbjørn Sloth Tønnesenzx2c4
authored andcommitted
wireguard: netlink: convert to split ops
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>
1 parent 9755f9d commit 73af07d

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

drivers/net/wireguard/netlink.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -616,28 +616,30 @@ static int wg_set_device(struct sk_buff *skb, struct genl_info *info)
616616
return ret;
617617
}
618618

619-
static const struct genl_ops genl_ops[] = {
619+
static const struct genl_split_ops wireguard_nl_ops[] = {
620620
{
621621
.cmd = WG_CMD_GET_DEVICE,
622622
.start = wg_get_device_start,
623623
.dumpit = wg_get_device_dump,
624624
.done = wg_get_device_done,
625-
.flags = GENL_UNS_ADMIN_PERM
625+
.policy = device_policy,
626+
.maxattr = WGDEVICE_A_PEERS,
627+
.flags = GENL_UNS_ADMIN_PERM | GENL_CMD_CAP_DUMP,
626628
}, {
627629
.cmd = WG_CMD_SET_DEVICE,
628630
.doit = wg_set_device,
629-
.flags = GENL_UNS_ADMIN_PERM
631+
.policy = device_policy,
632+
.maxattr = WGDEVICE_A_PEERS,
633+
.flags = GENL_UNS_ADMIN_PERM | GENL_CMD_CAP_DO,
630634
}
631635
};
632636

633637
static struct genl_family genl_family __ro_after_init = {
634-
.ops = genl_ops,
635-
.n_ops = ARRAY_SIZE(genl_ops),
638+
.split_ops = wireguard_nl_ops,
639+
.n_split_ops = ARRAY_SIZE(wireguard_nl_ops),
636640
.name = WG_GENL_NAME,
637641
.version = WG_GENL_VERSION,
638-
.maxattr = WGDEVICE_A_MAX,
639642
.module = THIS_MODULE,
640-
.policy = device_policy,
641643
.netnsok = true
642644
};
643645

0 commit comments

Comments
 (0)