[Openvpn-devel,net,v2,1/2] ovpn: add missing rtnl_link_ops->get_size callback

Message ID bd44d25247e13a6f0c7d72a17db03cbf17b351e6.1785330764.git.ralf@mandelbit.com
State Accepted
Headers
Series [Openvpn-devel,net,v2,1/2] ovpn: add missing rtnl_link_ops->get_size callback |

Commit Message

Ralf Lici July 29, 2026, 1:41 p.m. UTC
  ovpn_fill_info emits IFLA_OVPN_MODE inside IFLA_INFO_DATA, but
ovpn_link_ops does not provide a get_size callback. Consequently,
rtnetlink's size estimate for ovpn link messages does not include the
nested mode attribute.

Available skb tailroom may hide this mismatch. When the remaining space
is insufficient, however, ovpn_fill_info returns -EMSGSIZE and message
construction fails.

Add the callback and account for IFLA_OVPN_MODE.

Fixes: c2d950c4672a ("ovpn: add basic interface creation/destruction/management routines")
Signed-off-by: Ralf Lici <ralf@mandelbit.com>
---
Changes since v1 https://lore.kernel.org/openvpn-devel/20260603145007.603632-1-ralf@mandelbit.com/
- Clarify in the commit message that the incorrect size estimate causes
  a failure when skb tailroom is insufficient.
- Add the selftest as patch 2/2.

 drivers/net/ovpn/main.c | 7 +++++++
 1 file changed, 7 insertions(+)
  

Comments

Antonio Quartulli July 29, 2026, 2:11 p.m. UTC | #1
From: Antonio Quartulli <antonio@openvpn.net>


On Wed, 29 Jul 2026 15:41:30 +0200, Ralf Lici wrote:
> ovpn_fill_info emits IFLA_OVPN_MODE inside IFLA_INFO_DATA, but
> ovpn_link_ops does not provide a get_size callback. Consequently,
> rtnetlink's size estimate for ovpn link messages does not include the
> nested mode attribute.
> 
> Available skb tailroom may hide this mismatch. When the remaining space
> is insufficient, however, ovpn_fill_info returns -EMSGSIZE and message
> construction fails.
> 
> [...]

Applied, thanks!

[1/2] ovpn: add missing rtnl_link_ops->get_size callback
      commit: 6e9f539e4f01153651dd77609b5ccadd44b74df8
[2/2] selftests: ovpn: add rtnl link mode check
      commit: f4a57dae061c8542dc29de1a72168a0048d29283

Best regards,
  

Patch

diff --git a/drivers/net/ovpn/main.c b/drivers/net/ovpn/main.c
index 9993c1dfe471..9d9a0ff690d6 100644
--- a/drivers/net/ovpn/main.c
+++ b/drivers/net/ovpn/main.c
@@ -210,6 +210,12 @@  static int ovpn_newlink(struct net_device *dev,
 	return register_netdevice(dev);
 }
 
+static size_t ovpn_get_size(const struct net_device *dev)
+{
+	/* IFLA_OVPN_MODE */
+	return nla_total_size(sizeof(u8));
+}
+
 static int ovpn_fill_info(struct sk_buff *skb, const struct net_device *dev)
 {
 	struct ovpn_priv *ovpn = netdev_priv(dev);
@@ -228,6 +234,7 @@  static struct rtnl_link_ops ovpn_link_ops = {
 	.policy = ovpn_policy,
 	.maxtype = IFLA_OVPN_MAX,
 	.newlink = ovpn_newlink,
+	.get_size = ovpn_get_size,
 	.fill_info = ovpn_fill_info,
 };