diff mbox series

[SRU,N,4/4] UBUNTU: SAUCE: fan: support vxlan strict length validation

Message ID 20240501124023.683940-5-andrea.righi@canonical.com
State New
Headers show
Series re-enable Ubuntu FAN in the Noble kernel | expand

Commit Message

Andrea Righi May 1, 2024, 12:35 p.m. UTC
BugLink: https://bugs.launchpad.net/bugs/2064508

Make IFLA_VXLAN_FAN_MAP compatible with the strict length check
validation enforced by vxlan_policy for attribute types >=
IFLA_VXLAN_LOCALBYPASS.

This allows to support new vxlan attribute types with kernels >= 6.8,
without breaking the existent user-space tools relying on Ubuntu FAN.

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
---
 drivers/net/vxlan/vxlan_core.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
diff mbox series

Patch

diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c
index f16a4679e5ee..d43d2221ebf0 100644
--- a/drivers/net/vxlan/vxlan_core.c
+++ b/drivers/net/vxlan/vxlan_core.c
@@ -3530,6 +3530,22 @@  static void vxlan_raw_setup(struct net_device *dev)
 	dev->netdev_ops = &vxlan_netdev_raw_ops;
 }
 
+/* Validate Ubuntu FAN payload.
+ *
+ * This is required to bypass the strict length validation enforced for the
+ * attribute types >= IFLA_VXLAN_LOCALBYPASS in vxlan_policy.
+ *
+ * In this way we can continue to use the same allocated ID for
+ * IFLA_VXLAN_FAN_MAP, without breaking the existing user-space and also
+ * future kernel ABIs that may add new attribute types to vxlan_policy.
+ */
+static int fan_map_validate_entry(const struct nlattr *attr,
+				  struct netlink_ext_ack *extack)
+{
+	/* Accept any payload for Ubuntu FAN */
+	return 0;
+}
+
 static const struct nla_policy vxlan_policy[IFLA_VXLAN_MAX + 1] = {
 	[IFLA_VXLAN_UNSPEC]     = { .strict_start_type = IFLA_VXLAN_LOCALBYPASS },
 	[IFLA_VXLAN_ID]		= { .type = NLA_U32 },
@@ -3564,6 +3580,9 @@  static const struct nla_policy vxlan_policy[IFLA_VXLAN_MAX + 1] = {
 	[IFLA_VXLAN_VNIFILTER]	= { .type = NLA_U8 },
 	[IFLA_VXLAN_LOCALBYPASS]	= NLA_POLICY_MAX(NLA_U8, 1),
 	[IFLA_VXLAN_LABEL_POLICY]       = NLA_POLICY_MAX(NLA_U32, VXLAN_LABEL_MAX),
+	[IFLA_VXLAN_FAN_MAP]		= NLA_POLICY_VALIDATE_FN(NLA_BINARY,
+						fan_map_validate_entry,
+						sizeof(struct ifla_fan_map) * 256),
 };
 
 static int vxlan_validate(struct nlattr *tb[], struct nlattr *data[],