[PATCH net-next v2 4/8] net: qualcomm: rmnet: Restrict supported MAP checksum configurations

From: Subash Abhinov Kasiviswanathan

Date: Wed Oct 07 2026 - 20:58:00 EST


RmNet only supports three MAP data format configurations: MAPv1 (no
checksum offload), MAPv4 (v4 checksum offload) and MAPv5 (v5 checksum
offload). MAP command support is orthogonal and may be combined with any
of the three. Checksum offload versions are selected independently for
ingress and egress, but only one version may be enabled across the device.
Mixing the v4 and v5 checksum offload flags together, whether on the same
direction or across directions, is not a valid configuration. A direction
may leave checksum offload disabled.

Validate the requested data format in both rmnet_newlink() and
rmnet_changelink() and reject any combination that sets both the v4 and
v5 checksum offload flags at the same time, regardless of direction. This
is in preparation for the next patch where coalescing support needs to be
allowed with MAPv5 format only.

Co-developed-by: Sean Tranchetti <sean.tranchetti@xxxxxxxxxxxxxxxx>
Signed-off-by: Sean Tranchetti <sean.tranchetti@xxxxxxxxxxxxxxxx>
Signed-off-by: Subash Abhinov Kasiviswanathan <subash.a.kasiviswanathan@xxxxxxxxxxxxxxxx>
---
v2:
- Document the restrictions on invalid combinations of data format as
reported by Sashiko
v1: https://lore.kernel.org/all/20260930051345.857443-4-subash.a.kasiviswanathan@xxxxxxxxxxxxxxxx/

.../ethernet/qualcomm/rmnet/rmnet_config.c | 29 +++++++++++++++++++
1 file changed, 29 insertions(+)

diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c
index e5a6289b018a..b68f5561680f 100644
--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c
+++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c
@@ -26,6 +26,23 @@ static int rmnet_is_real_dev_registered(const struct net_device *real_dev)
return rcu_access_pointer(real_dev->rx_handler) == rmnet_rx_handler;
}

+/* Only three MAP configurations are supported: MAPv1 (no checksum
+ * offload), MAPv4 (v4 checksum offload) and MAPv5 (v5 checksum
+ * offload). MAP command support is orthogonal and permitted with any
+ * of the three. Checksum offload versions are selected independently
+ * for ingress and egress, but only one version may be enabled across
+ * the device. Mixing v4 and v5 checksum flags is not supported.
+ */
+static bool rmnet_config_data_format_valid(u32 data_format)
+{
+ u32 v4_mask = RMNET_FLAGS_INGRESS_MAP_CKSUMV4 |
+ RMNET_FLAGS_EGRESS_MAP_CKSUMV4;
+ u32 v5_mask = RMNET_FLAGS_INGRESS_MAP_CKSUMV5 |
+ RMNET_FLAGS_EGRESS_MAP_CKSUMV5;
+
+ return !(data_format & v4_mask) || !(data_format & v5_mask);
+}
+
/* Needs rtnl lock */
struct rmnet_port*
rmnet_get_port_rtnl(const struct net_device *real_dev)
@@ -151,6 +168,12 @@ static int rmnet_newlink(struct net_device *dev,
data_format |= flags->flags & flags->mask;
}

+ if (!rmnet_config_data_format_valid(data_format)) {
+ NL_SET_ERR_MSG_MOD(extack,
+ "unsupported MAP checksum flag combination");
+ return -EINVAL;
+ }
+
ep = kzalloc_obj(*ep);
if (!ep)
return -ENOMEM;
@@ -337,6 +360,12 @@ static int rmnet_changelink(struct net_device *dev, struct nlattr *tb[],
flags = nla_data(data[IFLA_RMNET_FLAGS]);
data_format = old_data_format & ~flags->mask;
data_format |= flags->flags & flags->mask;
+
+ if (!rmnet_config_data_format_valid(data_format)) {
+ NL_SET_ERR_MSG_MOD(extack,
+ "unsupported MAP checksum flag combination");
+ return -EINVAL;
+ }
}

if (data[IFLA_RMNET_MUX_ID]) {
--
2.34.1