From nobody Fri Dec 19 14:37:03 2025 Received: from mail1.fiberby.net (mail1.fiberby.net [193.104.135.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 55A7131D37A; Wed, 5 Nov 2025 18:33:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.104.135.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762367586; cv=none; b=AupiR82iY84IoR0+NuE08D/hG1SvpNcrKppLtubxWJames/mciuXDaIRM6fwjqzfW12b/Q0vBixNlU0ucjFR3cmof1ddNaIpzUCGZBbOf+ZJpHoqg4Mvy8nDKDyidZR4GzBoy7IP97jp3k07qeQHxfJjzmgfbc6Bl+qTBfsbEtk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762367586; c=relaxed/simple; bh=He5ET711S02oLtc1y7hWh0ZqphfBwv5k6IK3wRuetZQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=X5Sqzu6GsbGFYcJSL9GG4p2JmSPjw05m90UdfQPl3LFGkvgSLivPyFOQ6Jk3bKv7KkuNbG6TaSfLw7U7tiWDZTkFpQLlLu6uMv2GPTOhBNB7OLHsL4PxrDDufU/rE6y7S2JVVF8gLlJhpebtjszi/fO6rilRuOnVDQkhw3ZouXU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fiberby.net; spf=pass smtp.mailfrom=fiberby.net; dkim=pass (2048-bit key) header.d=fiberby.net header.i=@fiberby.net header.b=fPnHcsKG; arc=none smtp.client-ip=193.104.135.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fiberby.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fiberby.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fiberby.net header.i=@fiberby.net header.b="fPnHcsKG" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fiberby.net; s=202008; t=1762367571; bh=He5ET711S02oLtc1y7hWh0ZqphfBwv5k6IK3wRuetZQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fPnHcsKGpgjl5LvoLcpe5btPLBZhSoeeFnjchYikr0K5rIMN7d/pzEdjIFRe/2WWU 09cP3yJRMBCy/mZ0M0um80Yvvyr9860M5aZdh/NdisCP8/zxBBPRmv5us1cF9211de wHg0Z3OUEB2xVd5wLPf0fE0nw4oFrFBy5ZoZ6RTn/BbBQa185kHYnKhXjaAERu6kin Mti+BO0dxh+z+WZcOC0UmrbIWmNtNhYZe1K5vkh3N+iE7h61fvtYZUBDZucOx13EZf RzbtiJdnYVqH9GKQ3DwRX3hq0sl/uS6pvCh8u5L02oluQy4L1pMmBeEHSLrHxuRINs J2XmG7OkAP4MA== Received: from x201s (193-104-135-243.ip4.fiberby.net [193.104.135.243]) by mail1.fiberby.net (Postfix) with ESMTPSA id EC7AB6010A; Wed, 5 Nov 2025 18:32:50 +0000 (UTC) Received: by x201s (Postfix, from userid 1000) id 17CD82050AD; Wed, 05 Nov 2025 18:32:25 +0000 (UTC) From: =?UTF-8?q?Asbj=C3=B8rn=20Sloth=20T=C3=B8nnesen?= To: "Jason A. Donenfeld" , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: =?UTF-8?q?Asbj=C3=B8rn=20Sloth=20T=C3=B8nnesen?= , Donald Hunter , Simon Horman , Jacob Keller , Andrew Lunn , wireguard@lists.zx2c4.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jordan Rife Subject: [PATCH net-next v3 01/11] wireguard: netlink: validate nested arrays in policy Date: Wed, 5 Nov 2025 18:32:10 +0000 Message-ID: <20251105183223.89913-2-ast@fiberby.net> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251105183223.89913-1-ast@fiberby.net> References: <20251105183223.89913-1-ast@fiberby.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Use NLA_POLICY_NESTED_ARRAY() to perform nested array validation in the policy validation step. The nested policy was already enforced through nla_parse_nested(), however extack wasn't passed previously. Signed-off-by: Asbj=C3=B8rn Sloth T=C3=B8nnesen --- drivers/net/wireguard/netlink.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireguard/netlink.c b/drivers/net/wireguard/netlin= k.c index 67f962eb8b46..e4416f23d427 100644 --- a/drivers/net/wireguard/netlink.c +++ b/drivers/net/wireguard/netlink.c @@ -18,6 +18,8 @@ #include =20 static struct genl_family genl_family; +static const struct nla_policy peer_policy[WGPEER_A_MAX + 1]; +static const struct nla_policy allowedip_policy[WGALLOWEDIP_A_MAX + 1]; =20 static const struct nla_policy device_policy[WGDEVICE_A_MAX + 1] =3D { [WGDEVICE_A_IFINDEX] =3D { .type =3D NLA_U32 }, @@ -27,7 +29,7 @@ static const struct nla_policy device_policy[WGDEVICE_A_M= AX + 1] =3D { [WGDEVICE_A_FLAGS] =3D NLA_POLICY_MASK(NLA_U32, __WGDEVICE_F_ALL), [WGDEVICE_A_LISTEN_PORT] =3D { .type =3D NLA_U16 }, [WGDEVICE_A_FWMARK] =3D { .type =3D NLA_U32 }, - [WGDEVICE_A_PEERS] =3D { .type =3D NLA_NESTED } + [WGDEVICE_A_PEERS] =3D NLA_POLICY_NESTED_ARRAY(peer_policy), }; =20 static const struct nla_policy peer_policy[WGPEER_A_MAX + 1] =3D { @@ -39,7 +41,7 @@ static const struct nla_policy peer_policy[WGPEER_A_MAX += 1] =3D { [WGPEER_A_LAST_HANDSHAKE_TIME] =3D NLA_POLICY_EXACT_LEN(sizeof(struct _= _kernel_timespec)), [WGPEER_A_RX_BYTES] =3D { .type =3D NLA_U64 }, [WGPEER_A_TX_BYTES] =3D { .type =3D NLA_U64 }, - [WGPEER_A_ALLOWEDIPS] =3D { .type =3D NLA_NESTED }, + [WGPEER_A_ALLOWEDIPS] =3D NLA_POLICY_NESTED_ARRAY(allowedip_policy), [WGPEER_A_PROTOCOL_VERSION] =3D { .type =3D NLA_U32 } }; =20 @@ -467,7 +469,7 @@ static int set_peer(struct wg_device *wg, struct nlattr= **attrs) =20 nla_for_each_nested(attr, attrs[WGPEER_A_ALLOWEDIPS], rem) { ret =3D nla_parse_nested(allowedip, WGALLOWEDIP_A_MAX, - attr, allowedip_policy, NULL); + attr, NULL, NULL); if (ret < 0) goto out; ret =3D set_allowedip(peer, allowedip); @@ -593,7 +595,7 @@ static int wg_set_device(struct sk_buff *skb, struct ge= nl_info *info) =20 nla_for_each_nested(attr, info->attrs[WGDEVICE_A_PEERS], rem) { ret =3D nla_parse_nested(peer, WGPEER_A_MAX, attr, - peer_policy, NULL); + NULL, NULL); if (ret < 0) goto out; ret =3D set_peer(wg, peer); --=20 2.51.0 From nobody Fri Dec 19 14:37:03 2025 Received: from mail1.fiberby.net (mail1.fiberby.net [193.104.135.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F16623148A7; Wed, 5 Nov 2025 18:33:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.104.135.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762367586; cv=none; b=t2P/a76M5JRhdRxrJqTOvDYFGETavYfUqIfkTFn0Zl97p2/nDl7+jW3y9n6VDbD+2gjdJeoarZwTWvlAp+0WEcDtg1BgN6qB7ZANFj0ecbPDudB9T1bH50czBv81bnpjMfrnHI9xLthqlxrAQZ3lRmHeV+0RduOlRXwU7o8jy08= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762367586; c=relaxed/simple; bh=V1qpp0ij75kE1ods7p/ksE4mY2gQykj4G8kFXbDQACs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MJ/NiO8oB8FeqERTDZPxvWGxaZxXaC53q7kN1Ee2lcYER0VLJa96McJPVjDeOhC9bLliKsn9B9k/oS2t9/eWfKiqW41/CljIA/XGvd9odcPosphd30n7KqjvQdr/aVmPWaw76CyXsthC/1JDpVlT17+pAh4rUG+WO5eWZc9xrIE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fiberby.net; spf=pass smtp.mailfrom=fiberby.net; dkim=pass (2048-bit key) header.d=fiberby.net header.i=@fiberby.net header.b=pRPVYGk3; arc=none smtp.client-ip=193.104.135.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fiberby.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fiberby.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fiberby.net header.i=@fiberby.net header.b="pRPVYGk3" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fiberby.net; s=202008; t=1762367571; bh=V1qpp0ij75kE1ods7p/ksE4mY2gQykj4G8kFXbDQACs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pRPVYGk3mjM00Wv4+0TgHbL8U+STKrYUw+dB884kcjD79IlpUQ52IzTYbKexFexil Ip8nyjq/g+bmYpO7xvio+EZRa2YfNSG9gV6U4sG87m4qs0YeKGjLODDzktkLXm0a6p MqujphqKWD8g/4mZWSI4PAODYWp1Wb6UgEWGZlZAsAmTQ5nYWB+ToagCBqwYpFjHVz 4e3GoYUNZp08d04sFdNHEqBxWdn/9DU2JeHzkxjQcbMQGcl43AIpqMXWs/tRu9z49N 16rSSGyZeoJah7r00Z6cl/NAUJLIZIpYsSJOibV6GIb6UVpBxfxcbOs8GQ6nbTahqL UV7FdOWU4HUZA== Received: from x201s (193-104-135-243.ip4.fiberby.net [193.104.135.243]) by mail1.fiberby.net (Postfix) with ESMTPSA id EBB9760109; Wed, 5 Nov 2025 18:32:50 +0000 (UTC) Received: by x201s (Postfix, from userid 1000) id 239852050B6; Wed, 05 Nov 2025 18:32:25 +0000 (UTC) From: =?UTF-8?q?Asbj=C3=B8rn=20Sloth=20T=C3=B8nnesen?= To: "Jason A. Donenfeld" , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: =?UTF-8?q?Asbj=C3=B8rn=20Sloth=20T=C3=B8nnesen?= , Donald Hunter , Simon Horman , Jacob Keller , Andrew Lunn , wireguard@lists.zx2c4.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jordan Rife Subject: [PATCH net-next v3 02/11] wireguard: netlink: use WG_KEY_LEN in policies Date: Wed, 5 Nov 2025 18:32:11 +0000 Message-ID: <20251105183223.89913-3-ast@fiberby.net> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251105183223.89913-1-ast@fiberby.net> References: <20251105183223.89913-1-ast@fiberby.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable When converting the netlink policies to YNL, then the constants used in the policy has to be visible to user-space. As NOISE_*_KEY_LEN isn't visible for userspace, then change the policy to use WG_KEY_LEN, as is also documented in the UAPI header: $ grep WG_KEY_LEN include/uapi/linux/wireguard.h * WGDEVICE_A_PRIVATE_KEY: NLA_EXACT_LEN, len WG_KEY_LEN * WGDEVICE_A_PUBLIC_KEY: NLA_EXACT_LEN, len WG_KEY_LEN * WGPEER_A_PUBLIC_KEY: NLA_EXACT_LEN, len WG_KEY_LEN * WGPEER_A_PRESHARED_KEY: NLA_EXACT_LEN, len WG_KEY_LEN [...] Add a couple of BUILD_BUG_ON() to ensure that they stay in sync. No behavioural changes intended. Signed-off-by: Asbj=C3=B8rn Sloth T=C3=B8nnesen --- drivers/net/wireguard/netlink.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireguard/netlink.c b/drivers/net/wireguard/netlin= k.c index e4416f23d427..db57a74d379b 100644 --- a/drivers/net/wireguard/netlink.c +++ b/drivers/net/wireguard/netlink.c @@ -24,8 +24,8 @@ static const struct nla_policy allowedip_policy[WGALLOWED= IP_A_MAX + 1]; static const struct nla_policy device_policy[WGDEVICE_A_MAX + 1] =3D { [WGDEVICE_A_IFINDEX] =3D { .type =3D NLA_U32 }, [WGDEVICE_A_IFNAME] =3D { .type =3D NLA_NUL_STRING, .len =3D IFNAMSIZ - = 1 }, - [WGDEVICE_A_PRIVATE_KEY] =3D NLA_POLICY_EXACT_LEN(NOISE_PUBLIC_KEY_LEN), - [WGDEVICE_A_PUBLIC_KEY] =3D NLA_POLICY_EXACT_LEN(NOISE_PUBLIC_KEY_LEN), + [WGDEVICE_A_PRIVATE_KEY] =3D NLA_POLICY_EXACT_LEN(WG_KEY_LEN), + [WGDEVICE_A_PUBLIC_KEY] =3D NLA_POLICY_EXACT_LEN(WG_KEY_LEN), [WGDEVICE_A_FLAGS] =3D NLA_POLICY_MASK(NLA_U32, __WGDEVICE_F_ALL), [WGDEVICE_A_LISTEN_PORT] =3D { .type =3D NLA_U16 }, [WGDEVICE_A_FWMARK] =3D { .type =3D NLA_U32 }, @@ -33,8 +33,8 @@ static const struct nla_policy device_policy[WGDEVICE_A_M= AX + 1] =3D { }; =20 static const struct nla_policy peer_policy[WGPEER_A_MAX + 1] =3D { - [WGPEER_A_PUBLIC_KEY] =3D NLA_POLICY_EXACT_LEN(NOISE_PUBLIC_KEY_LEN), - [WGPEER_A_PRESHARED_KEY] =3D NLA_POLICY_EXACT_LEN(NOISE_SYMMETRIC_KEY_L= EN), + [WGPEER_A_PUBLIC_KEY] =3D NLA_POLICY_EXACT_LEN(WG_KEY_LEN), + [WGPEER_A_PRESHARED_KEY] =3D NLA_POLICY_EXACT_LEN(WG_KEY_LEN), [WGPEER_A_FLAGS] =3D NLA_POLICY_MASK(NLA_U32, __WGPEER_F_ALL), [WGPEER_A_ENDPOINT] =3D NLA_POLICY_MIN_LEN(sizeof(struct sockaddr)), [WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL] =3D { .type =3D NLA_U16 }, @@ -644,6 +644,9 @@ static struct genl_family genl_family __ro_after_init = =3D { =20 int __init wg_genetlink_init(void) { + BUILD_BUG_ON(WG_KEY_LEN !=3D NOISE_PUBLIC_KEY_LEN); + BUILD_BUG_ON(WG_KEY_LEN !=3D NOISE_SYMMETRIC_KEY_LEN); + return genl_register_family(&genl_family); } =20 --=20 2.51.0 From nobody Fri Dec 19 14:37:03 2025 Received: from mail1.fiberby.net (mail1.fiberby.net [193.104.135.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D2D0461FFE; Wed, 5 Nov 2025 18:33:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.104.135.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762367583; cv=none; b=aRJ+biJuWbtmXyk9CfT0QDgjvO+E3hWlaTmO3sX3yfVdgv9LhJOEO3Aj/7u8MI1SBvGRkgmevplyzTnqF5eZo4H/EBhph0hakLL4IG6SfDQMKeL4ISXcI8haTdWboeR7BReuv7PiOgGjYeQgypcQVXEHUL4Cyy5/Q8kATR0ccL4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762367583; c=relaxed/simple; bh=eTnEqUfZ1QM8rQVdqe622sxSi3uLZoHR6Wimv93HDIk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RieVmul4WCq4ZRv+Pibo8eK3T2/wULUovmhOKk10r599bAoi3+qGtQaw3XbplQt6rGR5SuSWaC1PYocEDD9JgkaoLEQYLzvHESpF9K64Px/T2/7mxKS5yrcKKdmYQumiEz8XXqzI2BDYtLeMGnwegYr4XZAc87met3CPMcstz5s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fiberby.net; spf=pass smtp.mailfrom=fiberby.net; dkim=pass (2048-bit key) header.d=fiberby.net header.i=@fiberby.net header.b=r2XjgkIs; arc=none smtp.client-ip=193.104.135.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fiberby.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fiberby.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fiberby.net header.i=@fiberby.net header.b="r2XjgkIs" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fiberby.net; s=202008; t=1762367571; bh=eTnEqUfZ1QM8rQVdqe622sxSi3uLZoHR6Wimv93HDIk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r2XjgkIsRXR0hJuwsViDFkgEE3qS5lyXCAF7nE68uU3+Jy8fDHewh2wVEwqDrOOai vmLdTl5on9eWGq3e3FcBCbaUtnx6sKcJvV5Ik/J6q9LCWkz2myPIGGlaFZ2zrg6KzZ WixSsQV9yl//eNSR/aE14RMvrwsI2h839mHQUBhUKaLfQCLNz9tBR+xF1p5xRmmLgG nB0RK/XiPLTnf+da8GVqbJCfrt1GOfAS5Yx+y13CZULNeCPu6ZLGDJVFdoI42QqExW 7YRRLe8ddW3Q4ELo51oMFQBqngGLlQALqeATUPKNBS1Nkt9rBvmgkKoPo5VpxHPxfh ZEkhYxkzSYdYQ== Received: from x201s (193-104-135-243.ip4.fiberby.net [193.104.135.243]) by mail1.fiberby.net (Postfix) with ESMTPSA id F087C6010D; Wed, 5 Nov 2025 18:32:50 +0000 (UTC) Received: by x201s (Postfix, from userid 1000) id 2E41720517D; Wed, 05 Nov 2025 18:32:25 +0000 (UTC) From: =?UTF-8?q?Asbj=C3=B8rn=20Sloth=20T=C3=B8nnesen?= To: "Jason A. Donenfeld" , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: =?UTF-8?q?Asbj=C3=B8rn=20Sloth=20T=C3=B8nnesen?= , Donald Hunter , Simon Horman , Jacob Keller , Andrew Lunn , wireguard@lists.zx2c4.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jordan Rife Subject: [PATCH net-next v3 03/11] wireguard: netlink: enable strict genetlink validation Date: Wed, 5 Nov 2025 18:32:12 +0000 Message-ID: <20251105183223.89913-4-ast@fiberby.net> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251105183223.89913-1-ast@fiberby.net> References: <20251105183223.89913-1-ast@fiberby.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Wireguard is a modern enough genetlink family, that it doesn't need resv_start_op. It already had policies in place when it was first merged, it has also never used the reserved field, or other things toggled by resv_start_op. wireguard-tools have always used zero initialized memory, and have never touched the reserved field, neither have any other clients I have checked. Closed-source clients are much more likely to use the embeddedable library from wireguard-tools, than a DIY implementation using uninitialized memory. Signed-off-by: Asbj=C3=B8rn Sloth T=C3=B8nnesen --- drivers/net/wireguard/netlink.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/net/wireguard/netlink.c b/drivers/net/wireguard/netlin= k.c index db57a74d379b..682678d24a9f 100644 --- a/drivers/net/wireguard/netlink.c +++ b/drivers/net/wireguard/netlink.c @@ -633,7 +633,6 @@ static const struct genl_ops genl_ops[] =3D { static struct genl_family genl_family __ro_after_init =3D { .ops =3D genl_ops, .n_ops =3D ARRAY_SIZE(genl_ops), - .resv_start_op =3D WG_CMD_SET_DEVICE + 1, .name =3D WG_GENL_NAME, .version =3D WG_GENL_VERSION, .maxattr =3D WGDEVICE_A_MAX, --=20 2.51.0 From nobody Fri Dec 19 14:37:03 2025 Received: from mail1.fiberby.net (mail1.fiberby.net [193.104.135.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5C4CF2BEC41; Wed, 5 Nov 2025 18:33:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.104.135.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762367586; cv=none; b=Uasc1SRR6L8UzWTY2Wi3ANTVHads2Q9Lc3LrMDmQfSHJUJmJLPEWxQAuZHqGLVoaY8n251sYI2ou4FI/Zyov4a0JHLy8yyptBTZ0ZP2ZcQlUtFDE3yfVqhkpI8Ob4c7/el0VAHR8e5RGbHYpLS/PMi5NJnTTEh7V7X5k4ou1JCo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762367586; c=relaxed/simple; bh=l3U2HSflidkXFUo8sy7/2OmOL2mQo/1hJlvD8S3kW8g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qtL4QHU4jYlRgDE7lDW8/YWy5SKRvXlxuOcdFw+1/dmaHhrVdyGhBhEkXKUI2ILjN8+brW2qkqdvX0zoDPNKvzLdUpYfR2JM0BRfydn5H/WmyM1dQAzhpSxQgp+65mWoyYXwy//jKHI5JzLiBzYtfmTLn2rAdDRlUs+f9I51Mhw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fiberby.net; spf=pass smtp.mailfrom=fiberby.net; dkim=pass (2048-bit key) header.d=fiberby.net header.i=@fiberby.net header.b=k6CB1S1V; arc=none smtp.client-ip=193.104.135.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fiberby.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fiberby.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fiberby.net header.i=@fiberby.net header.b="k6CB1S1V" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fiberby.net; s=202008; t=1762367571; bh=l3U2HSflidkXFUo8sy7/2OmOL2mQo/1hJlvD8S3kW8g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k6CB1S1VyIYmlecKGx1hKC76WnP13VMRHQc1Z2L1u/dwl42V5XwWc/UNjS6GM5obc PW8E0NbQpkU4oIQaioSGGG6MnsZzqIC0Xl1960t8eul2J1klZu0iOdKdJj0lek6vnx fhpT/fNl4SC3wU41XeHbanWc5AqsnGA9v4gLWXgvksdutw5KzC8FkgM/l9Ip4FK6sl Y497tDwvxhfwxypYHPmZ6Vu/sCbISfsiC7Yz1uviZ4YY7PAivjEzxcx20EVz6QjGmP QCqLzRLltR1Q48+DVpqI4obZibZw3kDzxn8M1/3ypxDZRImSg2HJDpvT4xiIGtozeL KnnjNMD2ROdyg== Received: from x201s (193-104-135-243.ip4.fiberby.net [193.104.135.243]) by mail1.fiberby.net (Postfix) with ESMTPSA id 015CF6010E; Wed, 5 Nov 2025 18:32:50 +0000 (UTC) Received: by x201s (Postfix, from userid 1000) id 393562051DB; Wed, 05 Nov 2025 18:32:25 +0000 (UTC) From: =?UTF-8?q?Asbj=C3=B8rn=20Sloth=20T=C3=B8nnesen?= To: "Jason A. Donenfeld" , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: =?UTF-8?q?Asbj=C3=B8rn=20Sloth=20T=C3=B8nnesen?= , Donald Hunter , Simon Horman , Jacob Keller , Andrew Lunn , wireguard@lists.zx2c4.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jordan Rife Subject: [PATCH net-next v3 04/11] netlink: specs: add specification for wireguard Date: Wed, 5 Nov 2025 18:32:13 +0000 Message-ID: <20251105183223.89913-5-ast@fiberby.net> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251105183223.89913-1-ast@fiberby.net> References: <20251105183223.89913-1-ast@fiberby.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable This patch adds an near[1] complete YNL specification for wireguard, documenting the protocol in a machine-readable format, than the comment in wireguard.h, and eases usage from C and non-C programming languages alike. The generated C library will be featured in the next patch, so in this patch I will use the in-kernel python client for examples. This makes the documentation in the UAPI header redundant, and it is therefore removed. The in-line documentation in the spec, is based on the existing comment in wireguard.h, and once released then it will be available in the kernel documentation at: https://docs.kernel.org/netlink/specs/wireguard.html (until then run: make htmldocs) Generate wireguard.rst from this spec: $ make -C tools/net/ynl/generated/ wireguard.rst Query wireguard interface through pyynl: $ sudo ./tools/net/ynl/pyynl/cli.py --family wireguard \ --dump get-device \ --json '{"ifindex":3}' [{'fwmark': 0, 'ifindex': 3, 'ifname': 'wg-test', 'listen-port': 54318, 'peers': [{0: {'allowedips': [{0: {'cidr-mask': 0, 'family': 2, 'ipaddr': '0.0.0.0'}}, {0: {'cidr-mask': 0, 'family': 10, 'ipaddr': '::'}}], 'endpoint': b'[...]', 'last-handshake-time': {'nsec': 42, 'sec': 42}, 'persistent-keepalive-interval': 42, 'preshared-key': '[...]', 'protocol-version': 1, 'public-key': '[...]', 'rx-bytes': 42, 'tx-bytes': 42}}], 'private-key': '[...]', 'public-key': '[...]'}] Add another allowed IP prefix: $ sudo ./tools/net/ynl/pyynl/cli.py --family wireguard \ --do set-device --json '{"ifindex":3,"peers":[ {"public-key":"6a df b1 83 a4 ..","allowedips":[ {"cidr-mask":0,"family":10,"ipaddr":"::"}]}]}' [1] As can be seen above, the "endpoint" is only decoded as binary data, as it can't be described fully in YNL. It's a struct sockaddr_in or struct sockaddr_in6 depending on the attribute length. Signed-off-by: Asbj=C3=B8rn Sloth T=C3=B8nnesen --- Documentation/netlink/specs/wireguard.yaml | 301 +++++++++++++++++++++ MAINTAINERS | 1 + include/uapi/linux/wireguard.h | 129 --------- 3 files changed, 302 insertions(+), 129 deletions(-) create mode 100644 Documentation/netlink/specs/wireguard.yaml diff --git a/Documentation/netlink/specs/wireguard.yaml b/Documentation/net= link/specs/wireguard.yaml new file mode 100644 index 000000000000..7dcb2dec3d06 --- /dev/null +++ b/Documentation/netlink/specs/wireguard.yaml @@ -0,0 +1,301 @@ +# SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Cla= use) +--- +name: wireguard +protocol: genetlink-legacy + +doc: | + **Netlink protocol to control WireGuard network devices.** + + The below enums and macros are for interfacing with WireGuard, + using generic netlink, with family ``WG_GENL_NAME`` and version + ``WG_GENL_VERSION``. It defines two commands: get and set. + Note that while they share many common attributes, these two + commands actually accept a slightly different set of inputs and + outputs. These differences are noted under the individual attributes. +c-family-name: wg-genl-name +c-version-name: wg-genl-version +max-by-define: true + +definitions: + - + name-prefix: wg- + name: key-len + type: const + value: 32 + - + name: --kernel-timespec + type: struct + header: linux/time_types.h + members: + - + name: sec + type: u64 + doc: Number of seconds, since UNIX epoch. + - + name: nsec + type: u64 + doc: Number of nanoseconds, after the second began. + - + name: wgdevice-flags + name-prefix: wgdevice-f- + enum-name: wgdevice-flag + type: flags + entries: + - replace-peers + - + name: wgpeer-flags + name-prefix: wgpeer-f- + enum-name: wgpeer-flag + type: flags + entries: + - remove-me + - replace-allowedips + - update-only + - + name: wgallowedip-flags + name-prefix: wgallowedip-f- + enum-name: wgallowedip-flag + type: flags + entries: + - remove-me + +attribute-sets: + - + name: wgdevice + enum-name: wgdevice-attribute + name-prefix: wgdevice-a- + attr-cnt-name: --wgdevice-a-last + attributes: + - + name: unspec + type: unused + value: 0 + - + name: ifindex + type: u32 + - + name: ifname + type: string + checks: + max-len: 15 + - + name: private-key + type: binary + doc: Set to all zeros to remove. + display-hint: hex + checks: + exact-len: wg-key-len + - + name: public-key + type: binary + display-hint: hex + checks: + exact-len: wg-key-len + - + name: flags + type: u32 + doc: | + ``0`` or ``WGDEVICE_F_REPLACE_PEERS`` if all current peers + should be removed prior to adding the list below. + enum: wgdevice-flags + - + name: listen-port + type: u16 + doc: Set as ``0`` to choose randomly. + - + name: fwmark + type: u32 + doc: Set as ``0`` to disable. + - + name: peers + type: indexed-array + sub-type: nest + nested-attributes: wgpeer + doc: The index is set as ``0`` in ``DUMP``, and unused in ``DO``. + - + name: wgpeer + enum-name: wgpeer-attribute + name-prefix: wgpeer-a- + attr-cnt-name: --wgpeer-a-last + attributes: + - + name: unspec + type: unused + value: 0 + - + name: public-key + type: binary + display-hint: hex + checks: + exact-len: wg-key-len + - + name: preshared-key + type: binary + doc: Set as all zeros to remove. + display-hint: hex + checks: + exact-len: wg-key-len + - + name: flags + type: u32 + doc: | + ``0`` and/or ``WGPEER_F_REMOVE_ME`` if the specified peer should= not + exist at the end of the operation, rather than added/updated + and/or ``WGPEER_F_REPLACE_ALLOWEDIPS`` if all current allowed IPs + of this peer should be removed prior to adding the list below + and/or ``WGPEER_F_UPDATE_ONLY`` if the peer should only be set if + it already exists. + enum: wgpeer-flags + - + name: endpoint + type: binary + doc: struct sockaddr_in or struct sockaddr_in6 + checks: + min-len: 16 + - + name: persistent-keepalive-interval + type: u16 + doc: Set as ``0`` to disable. + - + name: last-handshake-time + type: binary + struct: --kernel-timespec + checks: + exact-len: 16 + - + name: rx-bytes + type: u64 + - + name: tx-bytes + type: u64 + - + name: allowedips + type: indexed-array + sub-type: nest + nested-attributes: wgallowedip + doc: The index is set as ``0`` in ``DUMP``, and unused in ``DO``. + - + name: protocol-version + type: u32 + doc: | + Should not be set or used at all by most users of this API, + as the most recent protocol will be used when this is unset. + Otherwise, must be set to ``1``. + - + name: wgallowedip + enum-name: wgallowedip-attribute + name-prefix: wgallowedip-a- + attr-cnt-name: --wgallowedip-a-last + attributes: + - + name: unspec + type: unused + value: 0 + - + name: family + type: u16 + doc: IP family, either ``AF_INET`` or ``AF_INET6``. + - + name: ipaddr + type: binary + doc: Either ``struct in_addr`` or ``struct in6_addr``. + display-hint: ipv4-or-v6 + checks: + min-len: 4 + - + name: cidr-mask + type: u8 + - + name: flags + type: u32 + doc: | + ``WGALLOWEDIP_F_REMOVE_ME`` if the specified IP should be + removed; otherwise, this IP will be added if it is not + already present. + enum: wgallowedip-flags + +operations: + enum-name: wg-cmd + name-prefix: wg-cmd- + list: + - + name: get-device + value: 0 + doc: | + Retrieve WireGuard device + ~~~~~~~~~~~~~~~~~~~~~~~~~ + + The command should be called with one but not both of: + + - ``WGDEVICE_A_IFINDEX`` + - ``WGDEVICE_A_IFNAME`` + + The kernel will then return several messages (``NLM_F_MULTI``). + It is possible that all of the allowed IPs of a single peer + will not fit within a single netlink message. In that case, the + same peer will be written in the following message, except it will + only contain ``WGPEER_A_PUBLIC_KEY`` and ``WGPEER_A_ALLOWEDIPS``. + This may occur several times in a row for the same peer. + It is then up to the receiver to coalesce adjacent peers. + Likewise, it is possible that all peers will not fit within a + single message. + So, subsequent peers will be sent in following messages, + except those will only contain ``WGDEVICE_A_IFNAME`` and + ``WGDEVICE_A_PEERS``. It is then up to the receiver to coalesce + these messages to form the complete list of peers. + + While this command does accept the other ``WGDEVICE_A_*`` + attributes, for compatibility reasons, but they are ignored + by this command, and should not be used in requests. + + Since this is an ``NLA_F_DUMP`` command, the final message will + always be ``NLMSG_DONE``, even if an error occurs. However, this + ``NLMSG_DONE`` message contains an integer error code. It is + either zero or a negative error code corresponding to the errno. + attribute-set: wgdevice + flags: [uns-admin-perm] + + dump: + pre: wireguard-nl-get-device-start + post: wireguard-nl-get-device-done + # request only uses ifindex | ifname, but keep .maxattr as is + request: &all-attrs + attributes: + - ifindex + - ifname + - private-key + - public-key + - flags + - listen-port + - fwmark + - peers + reply: *all-attrs + - + name: set-device + value: 1 + doc: | + Set WireGuard device + ~~~~~~~~~~~~~~~~~~~~ + + This command should be called with a wgdevice set, containing one + but not both of ``WGDEVICE_A_IFINDEX`` and ``WGDEVICE_A_IFNAME``. + + It is possible that the amount of configuration data exceeds that + of the maximum message length accepted by the kernel. + In that case, several messages should be sent one after another, + with each successive one filling in information not contained in + the prior. + Note that if ``WGDEVICE_F_REPLACE_PEERS`` is specified in the first + message, it probably should not be specified in fragments that come + after, so that the list of peers is only cleared the first time but + appended after. + Likewise for peers, if ``WGPEER_F_REPLACE_ALLOWEDIPS`` is specified + in the first message of a peer, it likely should not be specified + in subsequent fragments. + + If an error occurs, ``NLMSG_ERROR`` will reply containing an errno. + attribute-set: wgdevice + flags: [uns-admin-perm] + + do: + request: *all-attrs diff --git a/MAINTAINERS b/MAINTAINERS index bdf0a3a0dd36..35cd289899f7 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -27649,6 +27649,7 @@ M: Jason A. Donenfeld L: wireguard@lists.zx2c4.com L: netdev@vger.kernel.org S: Maintained +F: Documentation/netlink/specs/wireguard.yaml F: drivers/net/wireguard/ F: tools/testing/selftests/wireguard/ =20 diff --git a/include/uapi/linux/wireguard.h b/include/uapi/linux/wireguard.h index 8c26391196d5..dee4401e0b5d 100644 --- a/include/uapi/linux/wireguard.h +++ b/include/uapi/linux/wireguard.h @@ -1,135 +1,6 @@ /* SPDX-License-Identifier: (GPL-2.0 WITH Linux-syscall-note) OR MIT */ /* * Copyright (C) 2015-2019 Jason A. Donenfeld . All Right= s Reserved. - * - * Documentation - * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D - * - * The below enums and macros are for interfacing with WireGuard, using ge= neric - * netlink, with family WG_GENL_NAME and version WG_GENL_VERSION. It defin= es two - * methods: get and set. Note that while they share many common attributes, - * these two functions actually accept a slightly different set of inputs = and - * outputs. - * - * WG_CMD_GET_DEVICE - * ----------------- - * - * May only be called via NLM_F_REQUEST | NLM_F_DUMP. The command should c= ontain - * one but not both of: - * - * WGDEVICE_A_IFINDEX: NLA_U32 - * WGDEVICE_A_IFNAME: NLA_NUL_STRING, maxlen IFNAMSIZ - 1 - * - * The kernel will then return several messages (NLM_F_MULTI) containing t= he - * following tree of nested items: - * - * WGDEVICE_A_IFINDEX: NLA_U32 - * WGDEVICE_A_IFNAME: NLA_NUL_STRING, maxlen IFNAMSIZ - 1 - * WGDEVICE_A_PRIVATE_KEY: NLA_EXACT_LEN, len WG_KEY_LEN - * WGDEVICE_A_PUBLIC_KEY: NLA_EXACT_LEN, len WG_KEY_LEN - * WGDEVICE_A_LISTEN_PORT: NLA_U16 - * WGDEVICE_A_FWMARK: NLA_U32 - * WGDEVICE_A_PEERS: NLA_NESTED - * 0: NLA_NESTED - * WGPEER_A_PUBLIC_KEY: NLA_EXACT_LEN, len WG_KEY_LEN - * WGPEER_A_PRESHARED_KEY: NLA_EXACT_LEN, len WG_KEY_LEN - * WGPEER_A_ENDPOINT: NLA_MIN_LEN(struct sockaddr), struct sock= addr_in or struct sockaddr_in6 - * WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL: NLA_U16 - * WGPEER_A_LAST_HANDSHAKE_TIME: NLA_EXACT_LEN, struct __kernel= _timespec - * WGPEER_A_RX_BYTES: NLA_U64 - * WGPEER_A_TX_BYTES: NLA_U64 - * WGPEER_A_ALLOWEDIPS: NLA_NESTED - * 0: NLA_NESTED - * WGALLOWEDIP_A_FAMILY: NLA_U16 - * WGALLOWEDIP_A_IPADDR: NLA_MIN_LEN(struct in_addr), s= truct in_addr or struct in6_addr - * WGALLOWEDIP_A_CIDR_MASK: NLA_U8 - * 0: NLA_NESTED - * ... - * 0: NLA_NESTED - * ... - * ... - * WGPEER_A_PROTOCOL_VERSION: NLA_U32 - * 0: NLA_NESTED - * ... - * ... - * - * It is possible that all of the allowed IPs of a single peer will not - * fit within a single netlink message. In that case, the same peer will - * be written in the following message, except it will only contain - * WGPEER_A_PUBLIC_KEY and WGPEER_A_ALLOWEDIPS. This may occur several - * times in a row for the same peer. It is then up to the receiver to - * coalesce adjacent peers. Likewise, it is possible that all peers will - * not fit within a single message. So, subsequent peers will be sent - * in following messages, except those will only contain WGDEVICE_A_IFNAME - * and WGDEVICE_A_PEERS. It is then up to the receiver to coalesce these - * messages to form the complete list of peers. - * - * Since this is an NLA_F_DUMP command, the final message will always be - * NLMSG_DONE, even if an error occurs. However, this NLMSG_DONE message - * contains an integer error code. It is either zero or a negative error - * code corresponding to the errno. - * - * WG_CMD_SET_DEVICE - * ----------------- - * - * May only be called via NLM_F_REQUEST. The command should contain the - * following tree of nested items, containing one but not both of - * WGDEVICE_A_IFINDEX and WGDEVICE_A_IFNAME: - * - * WGDEVICE_A_IFINDEX: NLA_U32 - * WGDEVICE_A_IFNAME: NLA_NUL_STRING, maxlen IFNAMSIZ - 1 - * WGDEVICE_A_FLAGS: NLA_U32, 0 or WGDEVICE_F_REPLACE_PEERS if all curr= ent - * peers should be removed prior to adding the list b= elow. - * WGDEVICE_A_PRIVATE_KEY: len WG_KEY_LEN, all zeros to remove - * WGDEVICE_A_LISTEN_PORT: NLA_U16, 0 to choose randomly - * WGDEVICE_A_FWMARK: NLA_U32, 0 to disable - * WGDEVICE_A_PEERS: NLA_NESTED - * 0: NLA_NESTED - * WGPEER_A_PUBLIC_KEY: len WG_KEY_LEN - * WGPEER_A_FLAGS: NLA_U32, 0 and/or WGPEER_F_REMOVE_ME if the - * specified peer should not exist at the end o= f the - * operation, rather than added/updated and/or - * WGPEER_F_REPLACE_ALLOWEDIPS if all current a= llowed - * IPs of this peer should be removed prior to = adding - * the list below and/or WGPEER_F_UPDATE_ONLY i= f the - * peer should only be set if it already exists. - * WGPEER_A_PRESHARED_KEY: len WG_KEY_LEN, all zeros to remove - * WGPEER_A_ENDPOINT: struct sockaddr_in or struct sockaddr_in6 - * WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL: NLA_U16, 0 to disable - * WGPEER_A_ALLOWEDIPS: NLA_NESTED - * 0: NLA_NESTED - * WGALLOWEDIP_A_FAMILY: NLA_U16 - * WGALLOWEDIP_A_IPADDR: struct in_addr or struct in6_a= ddr - * WGALLOWEDIP_A_CIDR_MASK: NLA_U8 - * WGALLOWEDIP_A_FLAGS: NLA_U32, WGALLOWEDIP_F_REMOVE_M= E if - * the specified IP should be remo= ved; - * otherwise, this IP will be adde= d if - * it is not already present. - * 0: NLA_NESTED - * ... - * 0: NLA_NESTED - * ... - * ... - * WGPEER_A_PROTOCOL_VERSION: NLA_U32, should not be set or use= d at - * all by most users of this API, as= the - * most recent protocol will be used= when - * this is unset. Otherwise, must be= set - * to 1. - * 0: NLA_NESTED - * ... - * ... - * - * It is possible that the amount of configuration data exceeds that of - * the maximum message length accepted by the kernel. In that case, several - * messages should be sent one after another, with each successive one - * filling in information not contained in the prior. Note that if - * WGDEVICE_F_REPLACE_PEERS is specified in the first message, it probably - * should not be specified in fragments that come after, so that the list - * of peers is only cleared the first time but appended after. Likewise for - * peers, if WGPEER_F_REPLACE_ALLOWEDIPS is specified in the first message - * of a peer, it likely should not be specified in subsequent fragments. - * - * If an error occurs, NLMSG_ERROR will reply containing an errno. */ =20 #ifndef _WG_UAPI_WIREGUARD_H --=20 2.51.0 From nobody Fri Dec 19 14:37:03 2025 Received: from mail1.fiberby.net (mail1.fiberby.net [193.104.135.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 606F527F759; Wed, 5 Nov 2025 18:33:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.104.135.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762367582; cv=none; b=cwqgzhbk97mqM+Q00g+N8rqWy/bozbnhPieUZKoKGECdNpHStLaU6SSNWo50tHjDWHSbDOihHdClEb3qu2dHbAW+t/Z4pxQhCYOxBForLkYF8LA4caU8GACPT7ITN+ao84KRg3OdRWpP/hKqUCGwt+oRKq+QTytC4wNuhq48oO0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762367582; c=relaxed/simple; bh=a6iHhfPZ+WxXWgSSU0GzwY2TxKP9Vf9YncSXeUje4pE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=EkAfBr9hzjvnbSAh0sxvPXVK2PDjWyhhzE2x1PIMY9f50aJ8B4IEp9k/iV8Z21ukxY5IBNp7nQkd7fsNnpxcNYyXeNY6NWWfKLTX34VEqg3vRmMsuQC0w8I0ygTv98G6th5vRiG6PrBGkOyLVr797CCzgoOBNr2EePtQvzK9M5k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fiberby.net; spf=pass smtp.mailfrom=fiberby.net; dkim=pass (2048-bit key) header.d=fiberby.net header.i=@fiberby.net header.b=AEhUreaQ; arc=none smtp.client-ip=193.104.135.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fiberby.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fiberby.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fiberby.net header.i=@fiberby.net header.b="AEhUreaQ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fiberby.net; s=202008; t=1762367570; bh=a6iHhfPZ+WxXWgSSU0GzwY2TxKP9Vf9YncSXeUje4pE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AEhUreaQwpy8yIuXX1zs8HeJ9t5MaSR0ijDWe2PHn38IikZa2BEcF3QX5Xwq+I1Uw 7WZRAgLs58Ut/1xVDvw1WqUMTl4rfm3JEgsbdQW5qE3+Vga4WcIdEYbrRqXEUTeYoX 8tZxa6T6dLMkjd7mkdQL3jcHpRfQH01DYSTM6GEBpEr93IGh6GHlWyfnNpCL3+WTLG 6gr5/pA14q9CAS5excF+3IlydxIHhHaPynqkx1kLkIAQQ3Ft2ivfZrBH6n3r+CdVo7 242M2x3sPzMHIQeDDH/J3cgjH42ZUCQvFd+ufEQXfjO4ayscqPZM+/vD9icEEpfQdn mLm/TO9Au4hCw== Received: from x201s (193-104-135-243.ip4.fiberby.net [193.104.135.243]) by mail1.fiberby.net (Postfix) with ESMTPSA id 61D856000C; Wed, 5 Nov 2025 18:32:47 +0000 (UTC) Received: by x201s (Postfix, from userid 1000) id 429BD2052C6; Wed, 05 Nov 2025 18:32:25 +0000 (UTC) From: =?UTF-8?q?Asbj=C3=B8rn=20Sloth=20T=C3=B8nnesen?= To: "Jason A. Donenfeld" , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: =?UTF-8?q?Asbj=C3=B8rn=20Sloth=20T=C3=B8nnesen?= , Donald Hunter , Simon Horman , Jacob Keller , Andrew Lunn , wireguard@lists.zx2c4.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jordan Rife Subject: [PATCH net-next v3 05/11] uapi: wireguard: move enum wg_cmd Date: Wed, 5 Nov 2025 18:32:14 +0000 Message-ID: <20251105183223.89913-6-ast@fiberby.net> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251105183223.89913-1-ast@fiberby.net> References: <20251105183223.89913-1-ast@fiberby.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable This patch moves enum wg_cmd to the end of the file, where ynl-gen would like to generate it. This is an incremental step towards adopting an UAPI header generated by ynl-gen. This is split out to keep the patches readable. This is a trivial patch with no behavioural changes intended. Signed-off-by: Asbj=C3=B8rn Sloth T=C3=B8nnesen --- include/uapi/linux/wireguard.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/include/uapi/linux/wireguard.h b/include/uapi/linux/wireguard.h index dee4401e0b5d..3ebfffd61269 100644 --- a/include/uapi/linux/wireguard.h +++ b/include/uapi/linux/wireguard.h @@ -11,13 +11,6 @@ =20 #define WG_KEY_LEN 32 =20 -enum wg_cmd { - WG_CMD_GET_DEVICE, - WG_CMD_SET_DEVICE, - __WG_CMD_MAX -}; -#define WG_CMD_MAX (__WG_CMD_MAX - 1) - enum wgdevice_flag { WGDEVICE_F_REPLACE_PEERS =3D 1U << 0, __WGDEVICE_F_ALL =3D WGDEVICE_F_REPLACE_PEERS @@ -73,4 +66,12 @@ enum wgallowedip_attribute { }; #define WGALLOWEDIP_A_MAX (__WGALLOWEDIP_A_LAST - 1) =20 +enum wg_cmd { + WG_CMD_GET_DEVICE, + WG_CMD_SET_DEVICE, + + __WG_CMD_MAX +}; +#define WG_CMD_MAX (__WG_CMD_MAX - 1) + #endif /* _WG_UAPI_WIREGUARD_H */ --=20 2.51.0 From nobody Fri Dec 19 14:37:03 2025 Received: from mail1.fiberby.net (mail1.fiberby.net [193.104.135.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 45C642836AF; Wed, 5 Nov 2025 18:32:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.104.135.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762367581; cv=none; b=M45/7DubwCarLNX/VeR0FXSlxYuH5+IpjF3thjmfLgdzxLayL1bLDjuOSpXjkCUzsc5VqVqO+nnRLYnpq06xPdTYls8QIvIyc7QuAuMCZr7Iq05bplL86s6YfVcqxFE86CaGgvjRt4slcHOW7yC/TPwzO2g+FE3UxYztNWpwk7I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762367581; c=relaxed/simple; bh=YPqkNXL4NHX4RHOQWGnzf+GIF8t49H/f/uCLLW+fk58=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=eusxrt0/gI5mvaBXytGy4Jp5jdbFc41b4ZvghCEIeMdcQtRcKAyv6FL7GjZii2dJICrego0Y4vJO0IPwbPb72RFacWuQH/BWSnhiIBShWHE7VMwBGcWM9LGrX0kL6+0Bml+BK2GDVLSf8zLbT72keVshvQN0cdI9hSFFETok3v0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fiberby.net; spf=pass smtp.mailfrom=fiberby.net; dkim=pass (2048-bit key) header.d=fiberby.net header.i=@fiberby.net header.b=ou3sV+P9; arc=none smtp.client-ip=193.104.135.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fiberby.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fiberby.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fiberby.net header.i=@fiberby.net header.b="ou3sV+P9" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fiberby.net; s=202008; t=1762367570; bh=YPqkNXL4NHX4RHOQWGnzf+GIF8t49H/f/uCLLW+fk58=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ou3sV+P9ZLQE6Hoixp/XsfzkKhEldNeTXAHmCSdMU2Y+PGbvQ8kSbL/ymcSx5wvLB C4uNj8V+LANN/Cs6Y+jpOaMvevs9pRxu/SHOea6cdPyCVh2pDLJcWTE7PHgm8AuN4K e6P+xRsj4q2RjuC/AwzBc4zAu1NiDu5e9JrR4wq9TGNbO4cnz3RaSXpZpq3DkSWJKZ sAjZjVvhSyo3NPuG8oqk4YdNpXLIK9E2x53sN/xJNbsEKx31afuUEV8lvuJTLcxk7h o0Iw99jIw0v5+SD0Ogu+CpZHC/BsPoL3KZAhLAhux5PbRbIP3Qa9LP/fiXxjeT5bFk 9p6ZjQ2yzWYAQ== Received: from x201s (193-104-135-243.ip4.fiberby.net [193.104.135.243]) by mail1.fiberby.net (Postfix) with ESMTPSA id 63BED600BF; Wed, 5 Nov 2025 18:32:47 +0000 (UTC) Received: by x201s (Postfix, from userid 1000) id 4C03B2052FD; Wed, 05 Nov 2025 18:32:25 +0000 (UTC) From: =?UTF-8?q?Asbj=C3=B8rn=20Sloth=20T=C3=B8nnesen?= To: "Jason A. Donenfeld" , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: =?UTF-8?q?Asbj=C3=B8rn=20Sloth=20T=C3=B8nnesen?= , Donald Hunter , Simon Horman , Jacob Keller , Andrew Lunn , wireguard@lists.zx2c4.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jordan Rife Subject: [PATCH net-next v3 06/11] uapi: wireguard: move flag enums Date: Wed, 5 Nov 2025 18:32:15 +0000 Message-ID: <20251105183223.89913-7-ast@fiberby.net> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251105183223.89913-1-ast@fiberby.net> References: <20251105183223.89913-1-ast@fiberby.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Move the wg*_flag enums, so that they are defined above the attribute set enums, as ynl-gen would place them. This is an incremental step towards adopting an UAPI header generated by ynl-gen. This is split out to keep the patches readable. This is a trivial patch with no behavioural changes intended. Signed-off-by: Asbj=C3=B8rn Sloth T=C3=B8nnesen --- include/uapi/linux/wireguard.h | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/include/uapi/linux/wireguard.h b/include/uapi/linux/wireguard.h index 3ebfffd61269..a2815f4f2910 100644 --- a/include/uapi/linux/wireguard.h +++ b/include/uapi/linux/wireguard.h @@ -15,6 +15,20 @@ enum wgdevice_flag { WGDEVICE_F_REPLACE_PEERS =3D 1U << 0, __WGDEVICE_F_ALL =3D WGDEVICE_F_REPLACE_PEERS }; + +enum wgpeer_flag { + WGPEER_F_REMOVE_ME =3D 1U << 0, + WGPEER_F_REPLACE_ALLOWEDIPS =3D 1U << 1, + WGPEER_F_UPDATE_ONLY =3D 1U << 2, + __WGPEER_F_ALL =3D WGPEER_F_REMOVE_ME | WGPEER_F_REPLACE_ALLOWEDIPS | + WGPEER_F_UPDATE_ONLY +}; + +enum wgallowedip_flag { + WGALLOWEDIP_F_REMOVE_ME =3D 1U << 0, + __WGALLOWEDIP_F_ALL =3D WGALLOWEDIP_F_REMOVE_ME +}; + enum wgdevice_attribute { WGDEVICE_A_UNSPEC, WGDEVICE_A_IFINDEX, @@ -29,13 +43,6 @@ enum wgdevice_attribute { }; #define WGDEVICE_A_MAX (__WGDEVICE_A_LAST - 1) =20 -enum wgpeer_flag { - WGPEER_F_REMOVE_ME =3D 1U << 0, - WGPEER_F_REPLACE_ALLOWEDIPS =3D 1U << 1, - WGPEER_F_UPDATE_ONLY =3D 1U << 2, - __WGPEER_F_ALL =3D WGPEER_F_REMOVE_ME | WGPEER_F_REPLACE_ALLOWEDIPS | - WGPEER_F_UPDATE_ONLY -}; enum wgpeer_attribute { WGPEER_A_UNSPEC, WGPEER_A_PUBLIC_KEY, @@ -52,10 +59,6 @@ enum wgpeer_attribute { }; #define WGPEER_A_MAX (__WGPEER_A_LAST - 1) =20 -enum wgallowedip_flag { - WGALLOWEDIP_F_REMOVE_ME =3D 1U << 0, - __WGALLOWEDIP_F_ALL =3D WGALLOWEDIP_F_REMOVE_ME -}; enum wgallowedip_attribute { WGALLOWEDIP_A_UNSPEC, WGALLOWEDIP_A_FAMILY, --=20 2.51.0 From nobody Fri Dec 19 14:37:03 2025 Received: from mail1.fiberby.net (mail1.fiberby.net [193.104.135.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5C5562BEC44; Wed, 5 Nov 2025 18:33:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.104.135.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762367585; cv=none; b=Qw94LnlYmuSyCVPEcmj6FPPk42681QzEyosmCdDaSnGB8hEFRmwGS6qawMKcAEP9FFPMoQb6Tv7UZDmnDlvwu8UnPnbXL8V0f7WKvK0YLAWEnG2mkSotkpIaEoX+YzEg6ZwSaqmt+9vUr4QtfZpD6GW/vsdryWKOZ29HI2IdZ3g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762367585; c=relaxed/simple; bh=xY7lHq4ALfv0HJXzy0ZxMdbYjvTe3T0JRD2cTLBa4FI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=R+ZjkpHLZcIxDsJFmS95slzmBH8iGXurp3fXClCD6GI6WwpmvKkd9Y1ynkqnZIisSAEBs78k4W7E3rPU7xrqZV1J5T6SO6niKeTho9DDgVJ9ztC+944kb1DCpFg2380chtP1EkhtFR4NWFSRQGvuAkSov9LOo4aoGhVOZyxquxY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fiberby.net; spf=pass smtp.mailfrom=fiberby.net; dkim=pass (2048-bit key) header.d=fiberby.net header.i=@fiberby.net header.b=agtKH4iQ; arc=none smtp.client-ip=193.104.135.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fiberby.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fiberby.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fiberby.net header.i=@fiberby.net header.b="agtKH4iQ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fiberby.net; s=202008; t=1762367571; bh=xY7lHq4ALfv0HJXzy0ZxMdbYjvTe3T0JRD2cTLBa4FI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=agtKH4iQZRCg2gngb7jle8z20A+CMAjfRCDTtBt0xFzS31Ts2F7ko6Xq9WX+fOlaV T9ZiyloSvObP3EIH0g+C927RZnahEUjv0zndGVBXdnTLR8Q7i5ImvBvmQgLRTWYJ2C o9IDoFNJLfszDr0Sd7Bt8YAimg1nCdqOwor2iDJhIThNLhVczJURqtXoSDmXIhQDJG SA/mdQEKm5kIPrLEPeYQ255vc0M4s53DzWPpLOvXP1UNTe2JMJpRIN9i91upA5Gpt+ cc+ov2M2CnXVAupG0e8vSAoJlfGPoEKsvi5NS/S3nJraRF2QKAJvDLUTI3MdLgd/nn JTIwHOme2esnw== Received: from x201s (193-104-135-243.ip4.fiberby.net [193.104.135.243]) by mail1.fiberby.net (Postfix) with ESMTPSA id 0EE0960114; Wed, 5 Nov 2025 18:32:51 +0000 (UTC) Received: by x201s (Postfix, from userid 1000) id 55BB6205302; Wed, 05 Nov 2025 18:32:25 +0000 (UTC) From: =?UTF-8?q?Asbj=C3=B8rn=20Sloth=20T=C3=B8nnesen?= To: "Jason A. Donenfeld" , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: =?UTF-8?q?Asbj=C3=B8rn=20Sloth=20T=C3=B8nnesen?= , Donald Hunter , Simon Horman , Jacob Keller , Andrew Lunn , wireguard@lists.zx2c4.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jordan Rife Subject: [PATCH net-next v3 07/11] uapi: wireguard: generate header with ynl-gen Date: Wed, 5 Nov 2025 18:32:16 +0000 Message-ID: <20251105183223.89913-8-ast@fiberby.net> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251105183223.89913-1-ast@fiberby.net> References: <20251105183223.89913-1-ast@fiberby.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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, and ensures that it stays in sync. Changes in generated header: * Trivial include 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=C3=B8rn Sloth T=C3=B8nnesen --- drivers/net/wireguard/netlink.c | 6 +++--- include/uapi/linux/wireguard.h | 37 ++++++++++++++++----------------- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/drivers/net/wireguard/netlink.c b/drivers/net/wireguard/netlin= k.c index 682678d24a9f..f9bed135000f 100644 --- a/drivers/net/wireguard/netlink.c +++ b/drivers/net/wireguard/netlink.c @@ -26,7 +26,7 @@ static const struct nla_policy device_policy[WGDEVICE_A_M= AX + 1] =3D { [WGDEVICE_A_IFNAME] =3D { .type =3D NLA_NUL_STRING, .len =3D IFNAMSIZ - = 1 }, [WGDEVICE_A_PRIVATE_KEY] =3D NLA_POLICY_EXACT_LEN(WG_KEY_LEN), [WGDEVICE_A_PUBLIC_KEY] =3D NLA_POLICY_EXACT_LEN(WG_KEY_LEN), - [WGDEVICE_A_FLAGS] =3D NLA_POLICY_MASK(NLA_U32, __WGDEVICE_F_ALL), + [WGDEVICE_A_FLAGS] =3D NLA_POLICY_MASK(NLA_U32, 0x1), [WGDEVICE_A_LISTEN_PORT] =3D { .type =3D NLA_U16 }, [WGDEVICE_A_FWMARK] =3D { .type =3D NLA_U32 }, [WGDEVICE_A_PEERS] =3D NLA_POLICY_NESTED_ARRAY(peer_policy), @@ -35,7 +35,7 @@ static const struct nla_policy device_policy[WGDEVICE_A_M= AX + 1] =3D { static const struct nla_policy peer_policy[WGPEER_A_MAX + 1] =3D { [WGPEER_A_PUBLIC_KEY] =3D NLA_POLICY_EXACT_LEN(WG_KEY_LEN), [WGPEER_A_PRESHARED_KEY] =3D NLA_POLICY_EXACT_LEN(WG_KEY_LEN), - [WGPEER_A_FLAGS] =3D NLA_POLICY_MASK(NLA_U32, __WGPEER_F_ALL), + [WGPEER_A_FLAGS] =3D NLA_POLICY_MASK(NLA_U32, 0x7), [WGPEER_A_ENDPOINT] =3D NLA_POLICY_MIN_LEN(sizeof(struct sockaddr)), [WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL] =3D { .type =3D NLA_U16 }, [WGPEER_A_LAST_HANDSHAKE_TIME] =3D NLA_POLICY_EXACT_LEN(sizeof(struct _= _kernel_timespec)), @@ -49,7 +49,7 @@ static const struct nla_policy allowedip_policy[WGALLOWED= IP_A_MAX + 1] =3D { [WGALLOWEDIP_A_FAMILY] =3D { .type =3D NLA_U16 }, [WGALLOWEDIP_A_IPADDR] =3D NLA_POLICY_MIN_LEN(sizeof(struct in_addr)), [WGALLOWEDIP_A_CIDR_MASK] =3D { .type =3D NLA_U8 }, - [WGALLOWEDIP_A_FLAGS] =3D NLA_POLICY_MASK(NLA_U32, __WGALLOWEDIP_F_ALL), + [WGALLOWEDIP_A_FLAGS] =3D NLA_POLICY_MASK(NLA_U32, 0x1), }; =20 static struct wg_device *lookup_interface(struct nlattr **attrs, diff --git a/include/uapi/linux/wireguard.h b/include/uapi/linux/wireguard.h index a2815f4f2910..dc3924d0c552 100644 --- a/include/uapi/linux/wireguard.h +++ b/include/uapi/linux/wireguard.h @@ -1,32 +1,28 @@ -/* SPDX-License-Identifier: (GPL-2.0 WITH Linux-syscall-note) OR MIT */ -/* - * Copyright (C) 2015-2019 Jason A. Donenfeld . All Right= s Reserved. - */ +/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Cl= ause) */ +/* Do not edit directly, auto-generated from: */ +/* Documentation/netlink/specs/wireguard.yaml */ +/* YNL-GEN uapi header */ =20 -#ifndef _WG_UAPI_WIREGUARD_H -#define _WG_UAPI_WIREGUARD_H +#ifndef _UAPI_LINUX_WIREGUARD_H +#define _UAPI_LINUX_WIREGUARD_H =20 -#define WG_GENL_NAME "wireguard" -#define WG_GENL_VERSION 1 +#define WG_GENL_NAME "wireguard" +#define WG_GENL_VERSION 1 =20 -#define WG_KEY_LEN 32 +#define WG_KEY_LEN 32 =20 enum wgdevice_flag { - WGDEVICE_F_REPLACE_PEERS =3D 1U << 0, - __WGDEVICE_F_ALL =3D WGDEVICE_F_REPLACE_PEERS + WGDEVICE_F_REPLACE_PEERS =3D 1, }; =20 enum wgpeer_flag { - WGPEER_F_REMOVE_ME =3D 1U << 0, - WGPEER_F_REPLACE_ALLOWEDIPS =3D 1U << 1, - WGPEER_F_UPDATE_ONLY =3D 1U << 2, - __WGPEER_F_ALL =3D WGPEER_F_REMOVE_ME | WGPEER_F_REPLACE_ALLOWEDIPS | - WGPEER_F_UPDATE_ONLY + WGPEER_F_REMOVE_ME =3D 1, + WGPEER_F_REPLACE_ALLOWEDIPS =3D 2, + WGPEER_F_UPDATE_ONLY =3D 4, }; =20 enum wgallowedip_flag { - WGALLOWEDIP_F_REMOVE_ME =3D 1U << 0, - __WGALLOWEDIP_F_ALL =3D WGALLOWEDIP_F_REMOVE_ME + WGALLOWEDIP_F_REMOVE_ME =3D 1, }; =20 enum wgdevice_attribute { @@ -39,6 +35,7 @@ enum wgdevice_attribute { WGDEVICE_A_LISTEN_PORT, WGDEVICE_A_FWMARK, WGDEVICE_A_PEERS, + __WGDEVICE_A_LAST }; #define WGDEVICE_A_MAX (__WGDEVICE_A_LAST - 1) @@ -55,6 +52,7 @@ enum wgpeer_attribute { WGPEER_A_TX_BYTES, WGPEER_A_ALLOWEDIPS, WGPEER_A_PROTOCOL_VERSION, + __WGPEER_A_LAST }; #define WGPEER_A_MAX (__WGPEER_A_LAST - 1) @@ -65,6 +63,7 @@ enum wgallowedip_attribute { WGALLOWEDIP_A_IPADDR, WGALLOWEDIP_A_CIDR_MASK, WGALLOWEDIP_A_FLAGS, + __WGALLOWEDIP_A_LAST }; #define WGALLOWEDIP_A_MAX (__WGALLOWEDIP_A_LAST - 1) @@ -77,4 +76,4 @@ enum wg_cmd { }; #define WG_CMD_MAX (__WG_CMD_MAX - 1) =20 -#endif /* _WG_UAPI_WIREGUARD_H */ +#endif /* _UAPI_LINUX_WIREGUARD_H */ --=20 2.51.0 From nobody Fri Dec 19 14:37:03 2025 Received: from mail1.fiberby.net (mail1.fiberby.net [193.104.135.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F142B286408; Wed, 5 Nov 2025 18:33:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.104.135.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762367586; cv=none; b=C4CHy0STuCb8mDWFBELd+ANMOqhC+oKdKxtdIkabypWwmu5d7mFWrNUc24NHgD97Qsg9G7J6WPS1DJh0jjsassTcgysEwj8ZPmfqXj2ERHbY51nrQsoCW7prFU9PJnUyE+x9qgTfTRKloDSFeNEqLUypIKnweNyS+opeMdn0GTQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762367586; c=relaxed/simple; bh=oRBe7GgNH6oPmcSON579G3PLmxGPq156I++5dsMEZGE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BAyO9Vrq+dGdWigDkjWkZZZAUPq1kBU+QGr1LFMyG6H3Jwv3xUPCmDdyabQpA+rnXhYtj9mX3DsMwJ1ldREIWpbEPIP9nwv+aFL9tICl0Nf9GYDKQH0S3sqk8FP1pLuWjp7hXer1iuEDxv27y7An59dXPi5R9VERoT0kNAfyP0M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fiberby.net; spf=pass smtp.mailfrom=fiberby.net; dkim=pass (2048-bit key) header.d=fiberby.net header.i=@fiberby.net header.b=HWzQCovt; arc=none smtp.client-ip=193.104.135.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fiberby.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fiberby.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fiberby.net header.i=@fiberby.net header.b="HWzQCovt" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fiberby.net; s=202008; t=1762367571; bh=oRBe7GgNH6oPmcSON579G3PLmxGPq156I++5dsMEZGE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HWzQCovtoyXt78Pe9AxLIjJw+Tl7icPRVQ1bX20UA5rplLNPqhIpNTpibhUbA8sZ+ mx+Hd/HrY9JlLmvZmavOl8eQLd1J7IZQ6Fo+OEXXvVnGcOAANXRvEMZpHOff+CVQpo rtitdQVawGiS2AoVrend3z6VrRhL5wkyj5NkIGyaWdIBhKdtfN3p1t01IPtoU9iFAx yR4k83k+0ffnR8K5N3rEKZQMB9azhQN/doNThFrtxYgLOiTIdo6tL5KcyVm8UD3S/5 SAoTgG2bMpNQR5Unk4G7UOyFzLhzptPzhJcVU/31peE0tQJI/2YhHZAIXn/vIhpJzZ fVSZ8Yc+b2kdQ== Received: from x201s (193-104-135-243.ip4.fiberby.net [193.104.135.243]) by mail1.fiberby.net (Postfix) with ESMTPSA id 068456010F; Wed, 5 Nov 2025 18:32:51 +0000 (UTC) Received: by x201s (Postfix, from userid 1000) id 5F563205331; Wed, 05 Nov 2025 18:32:25 +0000 (UTC) From: =?UTF-8?q?Asbj=C3=B8rn=20Sloth=20T=C3=B8nnesen?= To: "Jason A. Donenfeld" , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: =?UTF-8?q?Asbj=C3=B8rn=20Sloth=20T=C3=B8nnesen?= , Donald Hunter , Simon Horman , Jacob Keller , Andrew Lunn , wireguard@lists.zx2c4.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jordan Rife Subject: [PATCH net-next v3 08/11] tools: ynl: add sample for wireguard Date: Wed, 5 Nov 2025 18:32:17 +0000 Message-ID: <20251105183223.89913-9-ast@fiberby.net> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251105183223.89913-1-ast@fiberby.net> References: <20251105183223.89913-1-ast@fiberby.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Add a sample application for wireguard, using the generated C library, The main benefit of this is to exercise the generated library, which might be useful for future selftests. In order to support usage with a pre-YNL wireguard.h in /usr/include, then the former guard is added to Makefile.deps as well. Example: $ make -C tools/net/ynl/lib $ make -C tools/net/ynl/generated $ make -C tools/net/ynl/samples wireguard $ ./tools/net/ynl/samples/wireguard usage: ./tools/net/ynl/samples/wireguard $ sudo ./tools/net/ynl/samples/wireguard wg-test Interface 3: wg-test Peer 6adfb183a4a2c94a2f92dab5ade762a4788[...]: Data: rx: 42 / tx: 42 bytes Allowed IPs: 0.0.0.0/0 ::/0 Signed-off-by: Asbj=C3=B8rn Sloth T=C3=B8nnesen --- MAINTAINERS | 1 + tools/net/ynl/Makefile.deps | 2 + tools/net/ynl/samples/.gitignore | 1 + tools/net/ynl/samples/wireguard.c | 104 ++++++++++++++++++++++++++++++ 4 files changed, 108 insertions(+) create mode 100644 tools/net/ynl/samples/wireguard.c diff --git a/MAINTAINERS b/MAINTAINERS index 35cd289899f7..1c9c21ff2c97 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -27651,6 +27651,7 @@ L: netdev@vger.kernel.org S: Maintained F: Documentation/netlink/specs/wireguard.yaml F: drivers/net/wireguard/ +F: tools/net/ynl/samples/wireguard.c F: tools/testing/selftests/wireguard/ =20 WISTRON LAPTOP BUTTON DRIVER diff --git a/tools/net/ynl/Makefile.deps b/tools/net/ynl/Makefile.deps index 865fd2e8519e..a9a5348b31a3 100644 --- a/tools/net/ynl/Makefile.deps +++ b/tools/net/ynl/Makefile.deps @@ -48,3 +48,5 @@ CFLAGS_tc:=3D $(call get_hdr_inc,__LINUX_RTNETLINK_H,rtne= tlink.h) \ $(call get_hdr_inc,_TC_SKBEDIT_H,tc_act/tc_skbedit.h) \ $(call get_hdr_inc,_TC_TUNNEL_KEY_H,tc_act/tc_tunnel_key.h) CFLAGS_tcp_metrics:=3D$(call get_hdr_inc,_LINUX_TCP_METRICS_H,tcp_metrics.= h) +CFLAGS_wireguard:=3D$(call get_hdr_inc,_LINUX_WIREGUARD_H,wireguard.h) \ + -D _WG_UAPI_WIREGUARD_H # alternate pre-YNL guard diff --git a/tools/net/ynl/samples/.gitignore b/tools/net/ynl/samples/.giti= gnore index 7f5fca7682d7..09c61e4c18cd 100644 --- a/tools/net/ynl/samples/.gitignore +++ b/tools/net/ynl/samples/.gitignore @@ -7,3 +7,4 @@ rt-addr rt-link rt-route tc +wireguard diff --git a/tools/net/ynl/samples/wireguard.c b/tools/net/ynl/samples/wire= guard.c new file mode 100644 index 000000000000..43f3551eb101 --- /dev/null +++ b/tools/net/ynl/samples/wireguard.c @@ -0,0 +1,104 @@ +// SPDX-License-Identifier: GPL-2.0 +#include +#include +#include +#include +#include + +#include "wireguard-user.h" + +static void print_allowed_ip(const struct wireguard_wgallowedip *aip) +{ + char addr_out[INET6_ADDRSTRLEN]; + + if (!inet_ntop(aip->family, aip->ipaddr, addr_out, sizeof(addr_out))) { + addr_out[0] =3D '?'; + addr_out[1] =3D '\0'; + } + printf("\t\t\t%s/%u\n", addr_out, aip->cidr_mask); +} + +/* Only printing public key in this demo. For better key formatting, + * use the constant-time implementation as found in wireguard-tools. + */ +static void print_peer_header(const struct wireguard_wgpeer *peer) +{ + unsigned int i; + uint8_t *key =3D peer->public_key; + unsigned int len =3D peer->_len.public_key; + + if (len !=3D 32) + return; + printf("\tPeer "); + for (i =3D 0; i < len; i++) + printf("%02x", key[i]); + printf(":\n"); +} + +static void print_peer(const struct wireguard_wgpeer *peer) +{ + unsigned int i; + + print_peer_header(peer); + printf("\t\tData: rx: %llu / tx: %llu bytes\n", + peer->rx_bytes, peer->tx_bytes); + printf("\t\tAllowed IPs:\n"); + for (i =3D 0; i < peer->_count.allowedips; i++) + print_allowed_ip(&peer->allowedips[i]); +} + +static void build_request(struct wireguard_get_device_req *req, char *arg) +{ + char *endptr; + int ifindex; + + ifindex =3D strtol(arg, &endptr, 0); + if (endptr !=3D arg + strlen(arg) || errno !=3D 0) + ifindex =3D 0; + if (ifindex > 0) + wireguard_get_device_req_set_ifindex(req, ifindex); + else + wireguard_get_device_req_set_ifname(req, arg); +} + +int main(int argc, char **argv) +{ + struct wireguard_get_device_list *devs; + struct wireguard_get_device_req *req; + struct ynl_sock *ys; + + if (argc < 2) { + fprintf(stderr, "usage: %s \n", argv[0]); + return 1; + } + + req =3D wireguard_get_device_req_alloc(); + build_request(req, argv[1]); + + ys =3D ynl_sock_create(&ynl_wireguard_family, NULL); + if (!ys) + return 2; + + devs =3D wireguard_get_device_dump(ys, req); + if (!devs) + goto err_close; + + ynl_dump_foreach(devs, d) { + unsigned int i; + + printf("Interface %d: %s\n", d->ifindex, d->ifname); + for (i =3D 0; i < d->_count.peers; i++) + print_peer(&d->peers[i]); + } + wireguard_get_device_list_free(devs); + wireguard_get_device_req_free(req); + ynl_sock_destroy(ys); + + return 0; + +err_close: + fprintf(stderr, "YNL (%d): %s\n", ys->err.code, ys->err.msg); + wireguard_get_device_req_free(req); + ynl_sock_destroy(ys); + return 3; +} --=20 2.51.0 From nobody Fri Dec 19 14:37:03 2025 Received: from mail1.fiberby.net (mail1.fiberby.net [193.104.135.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2997C31D371; Wed, 5 Nov 2025 18:33:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.104.135.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762367586; cv=none; b=QqGFEA07esOlILsn/L+PbV86IaOTbevpP7HjNKZR3iMIm9pvInQ/jEiFndqX7wRePhAh8oedDbM9RVXbveH7W4zEtO/eofYiyCechh2s2rFTZRp8S3HDkI8ZqLpN39T2MyMaDR5tlIgOydCiZbSN6RwbtVjTOlG2/fdleXM+Dt0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762367586; c=relaxed/simple; bh=YP/7Az468O3K9xv25TYnGVQmzRYsWPioltt1rTnsRhQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=r6+uYF89g6a5J7obbqSyIXPV2c6d00deOKBu/HuZ4oPTMkYmxUhRX0st/BUWbPb84nh91uFYDYyJxZ10vRy7p30qdySnmVf2wVJrN+usdGR50S95nfhFS2QMwOPOx4Mn0k4P1wsRp6tjeQdW584hpoMzJovVGorOz3bhTrxRH8w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fiberby.net; spf=pass smtp.mailfrom=fiberby.net; dkim=pass (2048-bit key) header.d=fiberby.net header.i=@fiberby.net header.b=p/j5nRwW; arc=none smtp.client-ip=193.104.135.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fiberby.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fiberby.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fiberby.net header.i=@fiberby.net header.b="p/j5nRwW" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fiberby.net; s=202008; t=1762367571; bh=YP/7Az468O3K9xv25TYnGVQmzRYsWPioltt1rTnsRhQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p/j5nRwW8wg+AoZ3gV6Wm0zWg8FqBHTyPcV5fku/rtnGh/fpBw5D4H8KpMXje0RvC M+CT8x3WF/fiLQj2xV6gXI6ZS9pi4dBiqWfvAVhGahRVkpG4mKC0F+oBo//wlSAkK1 dIO0t03dQq1ezzZbqzptO9brpO9xl0l9QNWEdN3OIUWAhc1v+Dq/EVrti5Lfv8aB6B D/GSu7XA0Ylj74YeN/5GzznIvEl9aSSxgaTJ8JRAqeYnn8NpB8U0MLYOM6MHkoLAVR eLEXw4u1WBN4uNH77HRc0kO3j6oKuyyFKUuZd28AmH8vxWfkhSpF8D/2fnY49JCmSY BGe+fPfMVTukQ== Received: from x201s (193-104-135-243.ip4.fiberby.net [193.104.135.243]) by mail1.fiberby.net (Postfix) with ESMTPSA id 13A2260115; Wed, 5 Nov 2025 18:32:51 +0000 (UTC) Received: by x201s (Postfix, from userid 1000) id 68A00205462; Wed, 05 Nov 2025 18:32:25 +0000 (UTC) From: =?UTF-8?q?Asbj=C3=B8rn=20Sloth=20T=C3=B8nnesen?= To: "Jason A. Donenfeld" , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: =?UTF-8?q?Asbj=C3=B8rn=20Sloth=20T=C3=B8nnesen?= , Donald Hunter , Simon Horman , Jacob Keller , Andrew Lunn , wireguard@lists.zx2c4.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jordan Rife Subject: [PATCH net-next v3 09/11] wireguard: netlink: convert to split ops Date: Wed, 5 Nov 2025 18:32:18 +0000 Message-ID: <20251105183223.89913-10-ast@fiberby.net> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251105183223.89913-1-ast@fiberby.net> References: <20251105183223.89913-1-ast@fiberby.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable This patch converts wireguard from using 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, which might not be 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=C3=B8rn Sloth T=C3=B8nnesen --- drivers/net/wireguard/netlink.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireguard/netlink.c b/drivers/net/wireguard/netlin= k.c index f9bed135000f..7fecc25bd781 100644 --- a/drivers/net/wireguard/netlink.c +++ b/drivers/net/wireguard/netlink.c @@ -616,28 +616,30 @@ static int wg_set_device(struct sk_buff *skb, struct = genl_info *info) return ret; } =20 -static const struct genl_ops genl_ops[] =3D { +static const struct genl_split_ops wireguard_nl_ops[] =3D { { .cmd =3D WG_CMD_GET_DEVICE, .start =3D wg_get_device_start, .dumpit =3D wg_get_device_dump, .done =3D wg_get_device_done, - .flags =3D GENL_UNS_ADMIN_PERM + .policy =3D device_policy, + .maxattr =3D WGDEVICE_A_PEERS, + .flags =3D GENL_UNS_ADMIN_PERM | GENL_CMD_CAP_DUMP, }, { .cmd =3D WG_CMD_SET_DEVICE, .doit =3D wg_set_device, - .flags =3D GENL_UNS_ADMIN_PERM + .policy =3D device_policy, + .maxattr =3D WGDEVICE_A_PEERS, + .flags =3D GENL_UNS_ADMIN_PERM | GENL_CMD_CAP_DO, } }; =20 static struct genl_family genl_family __ro_after_init =3D { - .ops =3D genl_ops, - .n_ops =3D ARRAY_SIZE(genl_ops), + .split_ops =3D wireguard_nl_ops, + .n_split_ops =3D ARRAY_SIZE(wireguard_nl_ops), .name =3D WG_GENL_NAME, .version =3D WG_GENL_VERSION, - .maxattr =3D WGDEVICE_A_MAX, .module =3D THIS_MODULE, - .policy =3D device_policy, .netnsok =3D true }; =20 --=20 2.51.0 From nobody Fri Dec 19 14:37:03 2025 Received: from mail1.fiberby.net (mail1.fiberby.net [193.104.135.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 607FA2836B5; Wed, 5 Nov 2025 18:33:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.104.135.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762367583; cv=none; b=rAPNgcHy6sOi692mYApskEPg0dzfDlTjdo0Yd6XM3bEarSFLMPcZlKAqerQy5uEyVx3uXW8u8Q0atobksJdVmHdGZQilOpV7o7yo5ma7x2KlcOAwHKe65SOBdm+GHEw7H3Qwdbwf7h2i1Pdxc5oiQdCrcQEDIV0OF961KkK5Dsk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762367583; c=relaxed/simple; bh=Qg64MJjBEEWYMlr4/omGhrF4j5gB4P52bN2CbFfv5NU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=K5xhY6h7l30iSO0FKqjCCicRbjInlXlHDIMsM14PiHezrSSGyC6zqS0+Lkv6bvWuyT82DWPIa3TOGTRTF4aGz1WhgZvUX0840C/EMv+p0IoRl4ktnns/b5Ex77lNv7L03uKA1/hQSz+ihlAD2ynI4+MLaf/t0ciYcCXiMTFAbks= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fiberby.net; spf=pass smtp.mailfrom=fiberby.net; dkim=pass (2048-bit key) header.d=fiberby.net header.i=@fiberby.net header.b=nExIVRxd; arc=none smtp.client-ip=193.104.135.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fiberby.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fiberby.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fiberby.net header.i=@fiberby.net header.b="nExIVRxd" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fiberby.net; s=202008; t=1762367570; bh=Qg64MJjBEEWYMlr4/omGhrF4j5gB4P52bN2CbFfv5NU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nExIVRxdjxTAXq7k3nlsv1UoAHhpVSe6K7I2q9HPbFmxmYxjtfZhMluJL5mxc371y 5CQwEvtW7jC0AXZqIp3YRXriNFq16Fm7su1RRWBQjJXDdA4Fbac0i9wy31HJGD5eQ5 xQLREzDasUnXpJOTdJIgdJOd9iFjkyS4LTzxDX/Met//cKQbRzW6mSZLFwSeqRKtId yMD5hLGeFXymED9raQZOoiJZ0ND5DcJ8V5GI4j8t5CcVDBZZjjVasB8iXz0CkE7mAe manKpmqEh/eMGowTHKS90bbKtmmlVEt32LrZ4PevmHF3NCiDatUMFj48cTd8+tWNDA Ls7VvxyhoGkHA== Received: from x201s (193-104-135-243.ip4.fiberby.net [193.104.135.243]) by mail1.fiberby.net (Postfix) with ESMTPSA id C984460103; Wed, 5 Nov 2025 18:32:47 +0000 (UTC) Received: by x201s (Postfix, from userid 1000) id 725B420551B; Wed, 05 Nov 2025 18:32:25 +0000 (UTC) From: =?UTF-8?q?Asbj=C3=B8rn=20Sloth=20T=C3=B8nnesen?= To: "Jason A. Donenfeld" , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: =?UTF-8?q?Asbj=C3=B8rn=20Sloth=20T=C3=B8nnesen?= , Donald Hunter , Simon Horman , Jacob Keller , Andrew Lunn , wireguard@lists.zx2c4.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jordan Rife Subject: [PATCH net-next v3 10/11] wireguard: netlink: rename netlink handlers Date: Wed, 5 Nov 2025 18:32:19 +0000 Message-ID: <20251105183223.89913-11-ast@fiberby.net> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251105183223.89913-1-ast@fiberby.net> References: <20251105183223.89913-1-ast@fiberby.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Rename netlink handlers to use the naming expected by ynl-gen. This is an incremental step towards adopting netlink command definitions generated by ynl-gen. This is a trivial patch with no behavioural changes intended. Signed-off-by: Asbj=C3=B8rn Sloth T=C3=B8nnesen --- drivers/net/wireguard/netlink.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireguard/netlink.c b/drivers/net/wireguard/netlin= k.c index 7fecc25bd781..ff1549fe55e2 100644 --- a/drivers/net/wireguard/netlink.c +++ b/drivers/net/wireguard/netlink.c @@ -199,7 +199,7 @@ get_peer(struct wg_peer *peer, struct sk_buff *skb, str= uct dump_ctx *ctx) return -EMSGSIZE; } =20 -static int wg_get_device_start(struct netlink_callback *cb) +static int wireguard_nl_get_device_start(struct netlink_callback *cb) { struct wg_device *wg; =20 @@ -210,7 +210,8 @@ static int wg_get_device_start(struct netlink_callback = *cb) return 0; } =20 -static int wg_get_device_dump(struct sk_buff *skb, struct netlink_callback= *cb) +static int wireguard_nl_get_device_dumpit(struct sk_buff *skb, + struct netlink_callback *cb) { struct wg_peer *peer, *next_peer_cursor; struct dump_ctx *ctx =3D DUMP_CTX(cb); @@ -304,7 +305,7 @@ static int wg_get_device_dump(struct sk_buff *skb, stru= ct netlink_callback *cb) */ } =20 -static int wg_get_device_done(struct netlink_callback *cb) +static int wireguard_nl_get_device_done(struct netlink_callback *cb) { struct dump_ctx *ctx =3D DUMP_CTX(cb); =20 @@ -502,7 +503,8 @@ static int set_peer(struct wg_device *wg, struct nlattr= **attrs) return ret; } =20 -static int wg_set_device(struct sk_buff *skb, struct genl_info *info) +static int wireguard_nl_set_device_doit(struct sk_buff *skb, + struct genl_info *info) { struct wg_device *wg =3D lookup_interface(info->attrs, skb); u32 flags =3D 0; @@ -619,15 +621,15 @@ static int wg_set_device(struct sk_buff *skb, struct = genl_info *info) static const struct genl_split_ops wireguard_nl_ops[] =3D { { .cmd =3D WG_CMD_GET_DEVICE, - .start =3D wg_get_device_start, - .dumpit =3D wg_get_device_dump, - .done =3D wg_get_device_done, + .start =3D wireguard_nl_get_device_start, + .dumpit =3D wireguard_nl_get_device_dumpit, + .done =3D wireguard_nl_get_device_done, .policy =3D device_policy, .maxattr =3D WGDEVICE_A_PEERS, .flags =3D GENL_UNS_ADMIN_PERM | GENL_CMD_CAP_DUMP, }, { .cmd =3D WG_CMD_SET_DEVICE, - .doit =3D wg_set_device, + .doit =3D wireguard_nl_set_device_doit, .policy =3D device_policy, .maxattr =3D WGDEVICE_A_PEERS, .flags =3D GENL_UNS_ADMIN_PERM | GENL_CMD_CAP_DO, --=20 2.51.0 From nobody Fri Dec 19 14:37:03 2025 Received: from mail1.fiberby.net (mail1.fiberby.net [193.104.135.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6078D27FB3E; Wed, 5 Nov 2025 18:32:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.104.135.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762367582; cv=none; b=Exg52OoBicLQ+7jzuJuf5S1px3egSYrtCg6WQpdD+eFhyJCCnX0nSen/qLPhlpbypHb6o2q7t0qFeIIo5xuvRZyX7OJRK3qSPH8xrsj8KQLKuSaGSNRROlj8Ifw+ccHxkqs64w2qpByd005BFK9BzFL/pELUqufMO90G2xWdJbo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762367582; c=relaxed/simple; bh=+E6POiYbR00/Qa9rgRxaRGOxtUb5aoVC9OS9qJhBE8g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KYSxn5CQOW6rUr1i/aF/Y8YXFpm9ZHLgcTh2wpyLluDJvKhPj0C8KH83BrB8pqMYD+sX+y4tdKLIZYczo/hBDcycA3AfJbYDo1UXmKhc1tPicYPTn0S7ToPPctkezEw4lAsaOhP2ZU8kk5R8JhM/AbV8THxD3o8To28hyp5+fs0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fiberby.net; spf=pass smtp.mailfrom=fiberby.net; dkim=pass (2048-bit key) header.d=fiberby.net header.i=@fiberby.net header.b=VOCEE7lH; arc=none smtp.client-ip=193.104.135.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fiberby.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fiberby.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fiberby.net header.i=@fiberby.net header.b="VOCEE7lH" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fiberby.net; s=202008; t=1762367570; bh=+E6POiYbR00/Qa9rgRxaRGOxtUb5aoVC9OS9qJhBE8g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VOCEE7lHWziAGOvSz0vusDnOKuu3aLTLpkXPEfvLcmV2vIb+rgw1hF0ZTTXszMfv3 qSN0mVEUmAtXg+ePWU0Pr4x7yWhqDf+83mIe7GF70V+1yF8t32W4lRWvoGl+imqa0O BJ9FlVCNei1mx6N0A/oPRp2HOaF9fq83OXexKRfErGTwxV62E+2V5RHgYNyIOQuZwt pswxX03Me5SUX+t+GyR12PKaOHzGDEOH1ahs/mbdJ4u1KE4duRWRfDxA1mB32ZBRpl BUlSkHkCMiSrXzNSLx1YqvKoXJj0nWH/o6l6FDFQTG7BzvQARjcEo3ozWkVohHEEsI Y1KcombHHdSPw== Received: from x201s (193-104-135-243.ip4.fiberby.net [193.104.135.243]) by mail1.fiberby.net (Postfix) with ESMTPSA id 7975D600C1; Wed, 5 Nov 2025 18:32:47 +0000 (UTC) Received: by x201s (Postfix, from userid 1000) id 7C1652055B3; Wed, 05 Nov 2025 18:32:25 +0000 (UTC) From: =?UTF-8?q?Asbj=C3=B8rn=20Sloth=20T=C3=B8nnesen?= To: "Jason A. Donenfeld" , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: =?UTF-8?q?Asbj=C3=B8rn=20Sloth=20T=C3=B8nnesen?= , Donald Hunter , Simon Horman , Jacob Keller , Andrew Lunn , wireguard@lists.zx2c4.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jordan Rife Subject: [PATCH net-next v3 11/11] wireguard: netlink: generate netlink code Date: Wed, 5 Nov 2025 18:32:20 +0000 Message-ID: <20251105183223.89913-12-ast@fiberby.net> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251105183223.89913-1-ast@fiberby.net> References: <20251105183223.89913-1-ast@fiberby.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable This patch adopts netlink policy and command definitions as generated by ynl-gen, thus completing the conversion to YNL. Given that the old and new policy is functionally identical, and just moved to a new file, then it serves to verify that the policy in the spec in identical to the previous policy code. The new files are covered by drivers/net/wireguard/ pattern in MAINTAINERS. No behavioural changes intended. Signed-off-by: Asbj=C3=B8rn Sloth T=C3=B8nnesen --- drivers/net/wireguard/Makefile | 1 + drivers/net/wireguard/netlink.c | 64 +++--------------------- drivers/net/wireguard/netlink_gen.c | 77 +++++++++++++++++++++++++++++ drivers/net/wireguard/netlink_gen.h | 29 +++++++++++ 4 files changed, 114 insertions(+), 57 deletions(-) create mode 100644 drivers/net/wireguard/netlink_gen.c create mode 100644 drivers/net/wireguard/netlink_gen.h diff --git a/drivers/net/wireguard/Makefile b/drivers/net/wireguard/Makefile index dbe1f8514efc..ae4b479cddbd 100644 --- a/drivers/net/wireguard/Makefile +++ b/drivers/net/wireguard/Makefile @@ -14,4 +14,5 @@ wireguard-y +=3D allowedips.o wireguard-y +=3D ratelimiter.o wireguard-y +=3D cookie.o wireguard-y +=3D netlink.o +wireguard-y +=3D netlink_gen.o obj-$(CONFIG_WIREGUARD) :=3D wireguard.o diff --git a/drivers/net/wireguard/netlink.c b/drivers/net/wireguard/netlin= k.c index ff1549fe55e2..6a7e522e3a78 100644 --- a/drivers/net/wireguard/netlink.c +++ b/drivers/net/wireguard/netlink.c @@ -9,6 +9,7 @@ #include "socket.h" #include "queueing.h" #include "messages.h" +#include "netlink_gen.h" =20 #include =20 @@ -18,39 +19,6 @@ #include =20 static struct genl_family genl_family; -static const struct nla_policy peer_policy[WGPEER_A_MAX + 1]; -static const struct nla_policy allowedip_policy[WGALLOWEDIP_A_MAX + 1]; - -static const struct nla_policy device_policy[WGDEVICE_A_MAX + 1] =3D { - [WGDEVICE_A_IFINDEX] =3D { .type =3D NLA_U32 }, - [WGDEVICE_A_IFNAME] =3D { .type =3D NLA_NUL_STRING, .len =3D IFNAMSIZ - = 1 }, - [WGDEVICE_A_PRIVATE_KEY] =3D NLA_POLICY_EXACT_LEN(WG_KEY_LEN), - [WGDEVICE_A_PUBLIC_KEY] =3D NLA_POLICY_EXACT_LEN(WG_KEY_LEN), - [WGDEVICE_A_FLAGS] =3D NLA_POLICY_MASK(NLA_U32, 0x1), - [WGDEVICE_A_LISTEN_PORT] =3D { .type =3D NLA_U16 }, - [WGDEVICE_A_FWMARK] =3D { .type =3D NLA_U32 }, - [WGDEVICE_A_PEERS] =3D NLA_POLICY_NESTED_ARRAY(peer_policy), -}; - -static const struct nla_policy peer_policy[WGPEER_A_MAX + 1] =3D { - [WGPEER_A_PUBLIC_KEY] =3D NLA_POLICY_EXACT_LEN(WG_KEY_LEN), - [WGPEER_A_PRESHARED_KEY] =3D NLA_POLICY_EXACT_LEN(WG_KEY_LEN), - [WGPEER_A_FLAGS] =3D NLA_POLICY_MASK(NLA_U32, 0x7), - [WGPEER_A_ENDPOINT] =3D NLA_POLICY_MIN_LEN(sizeof(struct sockaddr)), - [WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL] =3D { .type =3D NLA_U16 }, - [WGPEER_A_LAST_HANDSHAKE_TIME] =3D NLA_POLICY_EXACT_LEN(sizeof(struct _= _kernel_timespec)), - [WGPEER_A_RX_BYTES] =3D { .type =3D NLA_U64 }, - [WGPEER_A_TX_BYTES] =3D { .type =3D NLA_U64 }, - [WGPEER_A_ALLOWEDIPS] =3D NLA_POLICY_NESTED_ARRAY(allowedip_policy), - [WGPEER_A_PROTOCOL_VERSION] =3D { .type =3D NLA_U32 } -}; - -static const struct nla_policy allowedip_policy[WGALLOWEDIP_A_MAX + 1] =3D= { - [WGALLOWEDIP_A_FAMILY] =3D { .type =3D NLA_U16 }, - [WGALLOWEDIP_A_IPADDR] =3D NLA_POLICY_MIN_LEN(sizeof(struct in_addr)), - [WGALLOWEDIP_A_CIDR_MASK] =3D { .type =3D NLA_U8 }, - [WGALLOWEDIP_A_FLAGS] =3D NLA_POLICY_MASK(NLA_U32, 0x1), -}; =20 static struct wg_device *lookup_interface(struct nlattr **attrs, struct sk_buff *skb) @@ -199,7 +167,7 @@ get_peer(struct wg_peer *peer, struct sk_buff *skb, str= uct dump_ctx *ctx) return -EMSGSIZE; } =20 -static int wireguard_nl_get_device_start(struct netlink_callback *cb) +int wireguard_nl_get_device_start(struct netlink_callback *cb) { struct wg_device *wg; =20 @@ -210,8 +178,8 @@ static int wireguard_nl_get_device_start(struct netlink= _callback *cb) return 0; } =20 -static int wireguard_nl_get_device_dumpit(struct sk_buff *skb, - struct netlink_callback *cb) +int wireguard_nl_get_device_dumpit(struct sk_buff *skb, + struct netlink_callback *cb) { struct wg_peer *peer, *next_peer_cursor; struct dump_ctx *ctx =3D DUMP_CTX(cb); @@ -305,7 +273,7 @@ static int wireguard_nl_get_device_dumpit(struct sk_buf= f *skb, */ } =20 -static int wireguard_nl_get_device_done(struct netlink_callback *cb) +int wireguard_nl_get_device_done(struct netlink_callback *cb) { struct dump_ctx *ctx =3D DUMP_CTX(cb); =20 @@ -503,8 +471,8 @@ static int set_peer(struct wg_device *wg, struct nlattr= **attrs) return ret; } =20 -static int wireguard_nl_set_device_doit(struct sk_buff *skb, - struct genl_info *info) +int wireguard_nl_set_device_doit(struct sk_buff *skb, + struct genl_info *info) { struct wg_device *wg =3D lookup_interface(info->attrs, skb); u32 flags =3D 0; @@ -618,24 +586,6 @@ static int wireguard_nl_set_device_doit(struct sk_buff= *skb, return ret; } =20 -static const struct genl_split_ops wireguard_nl_ops[] =3D { - { - .cmd =3D WG_CMD_GET_DEVICE, - .start =3D wireguard_nl_get_device_start, - .dumpit =3D wireguard_nl_get_device_dumpit, - .done =3D wireguard_nl_get_device_done, - .policy =3D device_policy, - .maxattr =3D WGDEVICE_A_PEERS, - .flags =3D GENL_UNS_ADMIN_PERM | GENL_CMD_CAP_DUMP, - }, { - .cmd =3D WG_CMD_SET_DEVICE, - .doit =3D wireguard_nl_set_device_doit, - .policy =3D device_policy, - .maxattr =3D WGDEVICE_A_PEERS, - .flags =3D GENL_UNS_ADMIN_PERM | GENL_CMD_CAP_DO, - } -}; - static struct genl_family genl_family __ro_after_init =3D { .split_ops =3D wireguard_nl_ops, .n_split_ops =3D ARRAY_SIZE(wireguard_nl_ops), diff --git a/drivers/net/wireguard/netlink_gen.c b/drivers/net/wireguard/ne= tlink_gen.c new file mode 100644 index 000000000000..f95fa133778f --- /dev/null +++ b/drivers/net/wireguard/netlink_gen.c @@ -0,0 +1,77 @@ +// SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Cl= ause) +/* Do not edit directly, auto-generated from: */ +/* Documentation/netlink/specs/wireguard.yaml */ +/* YNL-GEN kernel source */ + +#include +#include + +#include "netlink_gen.h" + +#include +#include + +/* Common nested types */ +const struct nla_policy wireguard_wgallowedip_nl_policy[WGALLOWEDIP_A_FLAG= S + 1] =3D { + [WGALLOWEDIP_A_FAMILY] =3D { .type =3D NLA_U16, }, + [WGALLOWEDIP_A_IPADDR] =3D NLA_POLICY_MIN_LEN(4), + [WGALLOWEDIP_A_CIDR_MASK] =3D { .type =3D NLA_U8, }, + [WGALLOWEDIP_A_FLAGS] =3D NLA_POLICY_MASK(NLA_U32, 0x1), +}; + +const struct nla_policy wireguard_wgpeer_nl_policy[WGPEER_A_PROTOCOL_VERSI= ON + 1] =3D { + [WGPEER_A_PUBLIC_KEY] =3D NLA_POLICY_EXACT_LEN(WG_KEY_LEN), + [WGPEER_A_PRESHARED_KEY] =3D NLA_POLICY_EXACT_LEN(WG_KEY_LEN), + [WGPEER_A_FLAGS] =3D NLA_POLICY_MASK(NLA_U32, 0x7), + [WGPEER_A_ENDPOINT] =3D NLA_POLICY_MIN_LEN(16), + [WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL] =3D { .type =3D NLA_U16, }, + [WGPEER_A_LAST_HANDSHAKE_TIME] =3D NLA_POLICY_EXACT_LEN(16), + [WGPEER_A_RX_BYTES] =3D { .type =3D NLA_U64, }, + [WGPEER_A_TX_BYTES] =3D { .type =3D NLA_U64, }, + [WGPEER_A_ALLOWEDIPS] =3D NLA_POLICY_NESTED_ARRAY(wireguard_wgallowedip_n= l_policy), + [WGPEER_A_PROTOCOL_VERSION] =3D { .type =3D NLA_U32, }, +}; + +/* WG_CMD_GET_DEVICE - dump */ +static const struct nla_policy wireguard_get_device_nl_policy[WGDEVICE_A_P= EERS + 1] =3D { + [WGDEVICE_A_IFINDEX] =3D { .type =3D NLA_U32, }, + [WGDEVICE_A_IFNAME] =3D { .type =3D NLA_NUL_STRING, .len =3D 15, }, + [WGDEVICE_A_PRIVATE_KEY] =3D NLA_POLICY_EXACT_LEN(WG_KEY_LEN), + [WGDEVICE_A_PUBLIC_KEY] =3D NLA_POLICY_EXACT_LEN(WG_KEY_LEN), + [WGDEVICE_A_FLAGS] =3D NLA_POLICY_MASK(NLA_U32, 0x1), + [WGDEVICE_A_LISTEN_PORT] =3D { .type =3D NLA_U16, }, + [WGDEVICE_A_FWMARK] =3D { .type =3D NLA_U32, }, + [WGDEVICE_A_PEERS] =3D NLA_POLICY_NESTED_ARRAY(wireguard_wgpeer_nl_policy= ), +}; + +/* WG_CMD_SET_DEVICE - do */ +static const struct nla_policy wireguard_set_device_nl_policy[WGDEVICE_A_P= EERS + 1] =3D { + [WGDEVICE_A_IFINDEX] =3D { .type =3D NLA_U32, }, + [WGDEVICE_A_IFNAME] =3D { .type =3D NLA_NUL_STRING, .len =3D 15, }, + [WGDEVICE_A_PRIVATE_KEY] =3D NLA_POLICY_EXACT_LEN(WG_KEY_LEN), + [WGDEVICE_A_PUBLIC_KEY] =3D NLA_POLICY_EXACT_LEN(WG_KEY_LEN), + [WGDEVICE_A_FLAGS] =3D NLA_POLICY_MASK(NLA_U32, 0x1), + [WGDEVICE_A_LISTEN_PORT] =3D { .type =3D NLA_U16, }, + [WGDEVICE_A_FWMARK] =3D { .type =3D NLA_U32, }, + [WGDEVICE_A_PEERS] =3D NLA_POLICY_NESTED_ARRAY(wireguard_wgpeer_nl_policy= ), +}; + +/* Ops table for wireguard */ +const struct genl_split_ops wireguard_nl_ops[2] =3D { + { + .cmd =3D WG_CMD_GET_DEVICE, + .start =3D wireguard_nl_get_device_start, + .dumpit =3D wireguard_nl_get_device_dumpit, + .done =3D wireguard_nl_get_device_done, + .policy =3D wireguard_get_device_nl_policy, + .maxattr =3D WGDEVICE_A_PEERS, + .flags =3D GENL_UNS_ADMIN_PERM | GENL_CMD_CAP_DUMP, + }, + { + .cmd =3D WG_CMD_SET_DEVICE, + .doit =3D wireguard_nl_set_device_doit, + .policy =3D wireguard_set_device_nl_policy, + .maxattr =3D WGDEVICE_A_PEERS, + .flags =3D GENL_UNS_ADMIN_PERM | GENL_CMD_CAP_DO, + }, +}; diff --git a/drivers/net/wireguard/netlink_gen.h b/drivers/net/wireguard/ne= tlink_gen.h new file mode 100644 index 000000000000..e635b1f5f0df --- /dev/null +++ b/drivers/net/wireguard/netlink_gen.h @@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Cl= ause) */ +/* Do not edit directly, auto-generated from: */ +/* Documentation/netlink/specs/wireguard.yaml */ +/* YNL-GEN kernel header */ + +#ifndef _LINUX_WIREGUARD_GEN_H +#define _LINUX_WIREGUARD_GEN_H + +#include +#include + +#include +#include + +/* Common nested types */ +extern const struct nla_policy wireguard_wgallowedip_nl_policy[WGALLOWEDIP= _A_FLAGS + 1]; +extern const struct nla_policy wireguard_wgpeer_nl_policy[WGPEER_A_PROTOCO= L_VERSION + 1]; + +/* Ops table for wireguard */ +extern const struct genl_split_ops wireguard_nl_ops[2]; + +int wireguard_nl_get_device_start(struct netlink_callback *cb); +int wireguard_nl_get_device_done(struct netlink_callback *cb); + +int wireguard_nl_get_device_dumpit(struct sk_buff *skb, + struct netlink_callback *cb); +int wireguard_nl_set_device_doit(struct sk_buff *skb, struct genl_info *in= fo); + +#endif /* _LINUX_WIREGUARD_GEN_H */ --=20 2.51.0