* [PATCH net v5 0/5] net: qualcomm: rmnet: Update MTU handling during format changes
@ 2026-11-17 6:07 Subash Abhinov Kasiviswanathan
2026-11-17 6:07 ` [PATCH net v5 1/5] net: qualcomm: rmnet: Account for V5 checksum header in headroom Subash Abhinov Kasiviswanathan
` (4 more replies)
0 siblings, 5 replies; 10+ messages in thread
From: Subash Abhinov Kasiviswanathan @ 2026-11-17 6:07 UTC (permalink / raw)
To: sean.tranchetti, andrew+netdev, davem, edumazet, kuba, pabeni
Cc: netdev, linux-kernel, Subash Abhinov Kasiviswanathan
This patch series addresses the code review comments raised by Sashiko
as part of the rmnet coalescing series. Changes were tested on QEMU only
and not on real hardware.
rmnet derives the MTU of its devices from the real device MTU minus the
headroom needed by the egress data format. Several problems exist in how
this is handled when the data format is set or changed, which can leave
a rmnet device with an MTU larger than the real device can carry, fail
creation of the first device, or leave a failed request half applied.
Patch 1 accounts for the V5 egress checksum header in the headroom, so
devices using V5 checksum offload no longer get an MTU that is too
large.
Patch 2 applies IFLA_RMNET_FLAGS before sizing the first device in
rmnet newlink, so the MTU matches the data format which is actually
used.
Patch 3 fixes the unsigned underflow when the real device MTU is below
the headroom and clamps the computed MTU to RMNET_MAX_PACKET_SIZE so
that a jumbo real device no longer makes the creation of the first
device fail.
Patch 4 computes the new data format locally and publishes the format
and any mux id change only after the MTUs have been updated, so the
data path never sees a format whose headers do not fit the MTUs. rmnet
newlink now also resizes existing devices and the real error is returned
instead of -1.
Patch 5 resizes endpoints with dev_set_mtu() so that MTU notifiers and
link notifications run, and restores the endpoints already resized when
a later one fails.
v5: v4 fixed all of these in a single patch. It was too large to review
comfortably, so this version splits it into a five patch series. The
resulting code is identical to v4 and there are no functional changes.
v4: https://lore.kernel.org/all/20261108075727.2031331-1-subash.a.kasiviswanathan@oss.qualcomm.com/
v3: https://lore.kernel.org/all/20261009084351.317632-2-subash.a.kasiviswanathan@oss.qualcomm.com/
v2: https://lore.kernel.org/all/20261008005543.2630828-2-subash.a.kasiviswanathan@oss.qualcomm.com/
Assisted-by: LLM
Subash Abhinov Kasiviswanathan (5):
net: qualcomm: rmnet: Account for V5 checksum header in headroom
net: qualcomm: rmnet: Size the first device from the requested data
format
net: qualcomm: rmnet: Fix MTU underflow and clamp to the maximum
packet size
net: qualcomm: rmnet: Publish data format and mux_id only after the
MTU update
net: qualcomm: rmnet: Resize endpoints with dev_set_mtu() and restore
on failure
.../ethernet/qualcomm/rmnet/rmnet_config.c | 77 +++++++-----
.../ethernet/qualcomm/rmnet/rmnet_config.h | 1 +
.../net/ethernet/qualcomm/rmnet/rmnet_vnd.c | 110 +++++++++++++-----
.../net/ethernet/qualcomm/rmnet/rmnet_vnd.h | 4 +-
4 files changed, 133 insertions(+), 59 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH net v5 1/5] net: qualcomm: rmnet: Account for V5 checksum header in headroom
2026-11-17 6:07 [PATCH net v5 0/5] net: qualcomm: rmnet: Update MTU handling during format changes Subash Abhinov Kasiviswanathan
@ 2026-11-17 6:07 ` Subash Abhinov Kasiviswanathan
2026-11-17 6:07 ` [PATCH net v5 2/5] net: qualcomm: rmnet: Size the first device from the requested data format Subash Abhinov Kasiviswanathan
` (3 subsequent siblings)
4 siblings, 0 replies; 10+ messages in thread
From: Subash Abhinov Kasiviswanathan @ 2026-11-17 6:07 UTC (permalink / raw)
To: sean.tranchetti, andrew+netdev, davem, edumazet, kuba, pabeni
Cc: netdev, linux-kernel, Subash Abhinov Kasiviswanathan
rmnet_vnd_headroom() only reserves space for the V4 egress checksum
header. A device using V5 checksum offload therefore gets an MTU which
is too large for the real device once the V5 header is added on egress.
Include the V5 checksum header in the headroom calculation when the V5
egress checksum flag is set.
Fixes: b6e5d27e32ef ("net: ethernet: rmnet: Add support for MAPv5 egress packets")
Co-developed-by: Sean Tranchetti <sean.tranchetti@oss.qualcomm.com>
Signed-off-by: Sean Tranchetti <sean.tranchetti@oss.qualcomm.com>
Signed-off-by: Subash Abhinov Kasiviswanathan <subash.a.kasiviswanathan@oss.qualcomm.com>
---
drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c
index 5f921cddf82b..fd10aa418be7 100644
--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c
+++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c
@@ -74,6 +74,8 @@ static int rmnet_vnd_headroom(struct rmnet_port *port)
if (port->data_format & RMNET_FLAGS_EGRESS_MAP_CKSUMV4)
headroom += sizeof(struct rmnet_map_ul_csum_header);
+ else if (port->data_format & RMNET_FLAGS_EGRESS_MAP_CKSUMV5)
+ headroom += sizeof(struct rmnet_map_v5_csum_header);
return headroom;
}
--
2.34.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH net v5 2/5] net: qualcomm: rmnet: Size the first device from the requested data format
2026-11-17 6:07 [PATCH net v5 0/5] net: qualcomm: rmnet: Update MTU handling during format changes Subash Abhinov Kasiviswanathan
2026-11-17 6:07 ` [PATCH net v5 1/5] net: qualcomm: rmnet: Account for V5 checksum header in headroom Subash Abhinov Kasiviswanathan
@ 2026-11-17 6:07 ` Subash Abhinov Kasiviswanathan
2026-11-21 7:04 ` netdev-bot+sashiko
2026-11-17 6:07 ` [PATCH net v5 3/5] net: qualcomm: rmnet: Fix MTU underflow and clamp to the maximum packet size Subash Abhinov Kasiviswanathan
` (2 subsequent siblings)
4 siblings, 1 reply; 10+ messages in thread
From: Subash Abhinov Kasiviswanathan @ 2026-11-17 6:07 UTC (permalink / raw)
To: sean.tranchetti, andrew+netdev, davem, edumazet, kuba, pabeni
Cc: netdev, linux-kernel, Subash Abhinov Kasiviswanathan
rmnet_newlink() sizes the first rmnet device from the data format
currently stored in the port, before the requested IFLA_RMNET_FLAGS
have been applied. The MTU therefore does not match the egress header
overhead of the format which ends up being used.
Apply IFLA_RMNET_FLAGS first and pass the resulting data format to
rmnet_vnd_newlink(), so that the headroom is calculated from the format
being configured.
Fixes: b7f5eb6ba21b ("net: qualcomm: rmnet: Update rmnet device MTU based on real device")
Co-developed-by: Sean Tranchetti <sean.tranchetti@oss.qualcomm.com>
Signed-off-by: Sean Tranchetti <sean.tranchetti@oss.qualcomm.com>
Signed-off-by: Subash Abhinov Kasiviswanathan <subash.a.kasiviswanathan@oss.qualcomm.com>
---
.../ethernet/qualcomm/rmnet/rmnet_config.c | 19 +++++-----
.../net/ethernet/qualcomm/rmnet/rmnet_vnd.c | 38 ++++++++++++-------
.../net/ethernet/qualcomm/rmnet/rmnet_vnd.h | 2 +-
3 files changed, 35 insertions(+), 24 deletions(-)
diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c
index 61b04c6c0390..40544b75e602 100644
--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c
+++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c
@@ -143,6 +143,14 @@ static int rmnet_newlink(struct net_device *dev,
return -ENODEV;
}
+ if (data[IFLA_RMNET_FLAGS]) {
+ struct ifla_rmnet_flags *flags;
+
+ flags = nla_data(data[IFLA_RMNET_FLAGS]);
+ data_format &= ~flags->mask;
+ data_format |= flags->flags & flags->mask;
+ }
+
ep = kzalloc_obj(*ep);
if (!ep)
return -ENOMEM;
@@ -154,7 +162,8 @@ static int rmnet_newlink(struct net_device *dev,
goto err0;
port = rmnet_get_port_rtnl(real_dev);
- err = rmnet_vnd_newlink(mux_id, dev, port, real_dev, ep, extack);
+ err = rmnet_vnd_newlink(mux_id, dev, port, real_dev, ep, extack,
+ data_format);
if (err)
goto err1;
@@ -167,14 +176,6 @@ static int rmnet_newlink(struct net_device *dev,
hlist_add_head_rcu(&ep->hlnode, &port->muxed_ep[mux_id]);
- if (data[IFLA_RMNET_FLAGS]) {
- struct ifla_rmnet_flags *flags;
-
- flags = nla_data(data[IFLA_RMNET_FLAGS]);
- data_format &= ~flags->mask;
- data_format |= flags->flags & flags->mask;
- }
-
netdev_dbg(dev, "data format [0x%08X]\n", data_format);
WRITE_ONCE(port->data_format, data_format);
diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c
index fd10aa418be7..984c66bee863 100644
--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c
+++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c
@@ -66,29 +66,27 @@ static netdev_tx_t rmnet_vnd_start_xmit(struct sk_buff *skb,
return NETDEV_TX_OK;
}
-static int rmnet_vnd_headroom(struct rmnet_port *port)
+static int rmnet_vnd_headroom(u32 data_format)
{
u32 headroom;
headroom = sizeof(struct rmnet_map_header);
- if (port->data_format & RMNET_FLAGS_EGRESS_MAP_CKSUMV4)
+ if (data_format & RMNET_FLAGS_EGRESS_MAP_CKSUMV4)
headroom += sizeof(struct rmnet_map_ul_csum_header);
- else if (port->data_format & RMNET_FLAGS_EGRESS_MAP_CKSUMV5)
+ else if (data_format & RMNET_FLAGS_EGRESS_MAP_CKSUMV5)
headroom += sizeof(struct rmnet_map_v5_csum_header);
return headroom;
}
-static int rmnet_vnd_change_mtu(struct net_device *rmnet_dev, int new_mtu)
+static int rmnet_vnd_change_mtu_with_format(struct net_device *rmnet_dev,
+ int new_mtu, u32 data_format)
{
struct rmnet_priv *priv = netdev_priv(rmnet_dev);
- struct rmnet_port *port;
u32 headroom;
- port = rmnet_get_port_rtnl(priv->real_dev);
-
- headroom = rmnet_vnd_headroom(port);
+ headroom = rmnet_vnd_headroom(data_format);
if (new_mtu < 0 || new_mtu > RMNET_MAX_PACKET_SIZE ||
new_mtu > (priv->real_dev->mtu - headroom))
@@ -98,6 +96,17 @@ static int rmnet_vnd_change_mtu(struct net_device *rmnet_dev, int new_mtu)
return 0;
}
+static int rmnet_vnd_change_mtu(struct net_device *rmnet_dev, int new_mtu)
+{
+ struct rmnet_priv *priv = netdev_priv(rmnet_dev);
+ struct rmnet_port *port;
+
+ port = rmnet_get_port_rtnl(priv->real_dev);
+
+ return rmnet_vnd_change_mtu_with_format(rmnet_dev, new_mtu,
+ READ_ONCE(port->data_format));
+}
+
static int rmnet_vnd_get_iflink(const struct net_device *dev)
{
struct rmnet_priv *priv = netdev_priv(dev);
@@ -310,8 +319,7 @@ int rmnet_vnd_newlink(u8 id, struct net_device *rmnet_dev,
struct rmnet_port *port,
struct net_device *real_dev,
struct rmnet_endpoint *ep,
- struct netlink_ext_ack *extack)
-
+ struct netlink_ext_ack *extack, u32 data_format)
{
struct rmnet_priv *priv = netdev_priv(rmnet_dev);
u32 headroom;
@@ -328,9 +336,11 @@ int rmnet_vnd_newlink(u8 id, struct net_device *rmnet_dev,
priv->real_dev = real_dev;
- headroom = rmnet_vnd_headroom(port);
+ headroom = rmnet_vnd_headroom(data_format);
- if (rmnet_vnd_change_mtu(rmnet_dev, real_dev->mtu - headroom)) {
+ if (rmnet_vnd_change_mtu_with_format(rmnet_dev,
+ real_dev->mtu - headroom,
+ data_format)) {
NL_SET_ERR_MSG_MOD(extack, "Invalid MTU on real dev");
return -EINVAL;
}
@@ -387,7 +397,7 @@ int rmnet_vnd_validate_real_dev_mtu(struct net_device *real_dev)
port = rmnet_get_port_rtnl(real_dev);
- headroom = rmnet_vnd_headroom(port);
+ headroom = rmnet_vnd_headroom(READ_ONCE(port->data_format));
hash_for_each_safe(port->muxed_ep, bkt_ep, tmp_ep, ep, hlnode) {
if (ep->egress_dev->mtu > (real_dev->mtu - headroom))
@@ -405,7 +415,7 @@ int rmnet_vnd_update_dev_mtu(struct rmnet_port *port,
unsigned long bkt_ep;
u32 headroom;
- headroom = rmnet_vnd_headroom(port);
+ headroom = rmnet_vnd_headroom(READ_ONCE(port->data_format));
hash_for_each_safe(port->muxed_ep, bkt_ep, tmp_ep, ep, hlnode) {
if (ep->egress_dev->mtu <= (real_dev->mtu - headroom))
diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.h b/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.h
index c2b2baf86894..5d54c24f5c8c 100644
--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.h
+++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.h
@@ -12,7 +12,7 @@ int rmnet_vnd_newlink(u8 id, struct net_device *rmnet_dev,
struct rmnet_port *port,
struct net_device *real_dev,
struct rmnet_endpoint *ep,
- struct netlink_ext_ack *extack);
+ struct netlink_ext_ack *extack, u32 data_format);
int rmnet_vnd_dellink(u8 id, struct rmnet_port *port,
struct rmnet_endpoint *ep);
void rmnet_vnd_rx_fixup(struct sk_buff *skb, struct net_device *dev);
--
2.34.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH net v5 3/5] net: qualcomm: rmnet: Fix MTU underflow and clamp to the maximum packet size
2026-11-17 6:07 [PATCH net v5 0/5] net: qualcomm: rmnet: Update MTU handling during format changes Subash Abhinov Kasiviswanathan
2026-11-17 6:07 ` [PATCH net v5 1/5] net: qualcomm: rmnet: Account for V5 checksum header in headroom Subash Abhinov Kasiviswanathan
2026-11-17 6:07 ` [PATCH net v5 2/5] net: qualcomm: rmnet: Size the first device from the requested data format Subash Abhinov Kasiviswanathan
@ 2026-11-17 6:07 ` Subash Abhinov Kasiviswanathan
2026-11-21 7:04 ` netdev-bot+sashiko
2026-11-17 6:07 ` [PATCH net v5 4/5] net: qualcomm: rmnet: Publish data format and mux_id only after the MTU update Subash Abhinov Kasiviswanathan
2026-11-17 6:07 ` [PATCH net v5 5/5] net: qualcomm: rmnet: Resize endpoints with dev_set_mtu() and restore on failure Subash Abhinov Kasiviswanathan
4 siblings, 1 reply; 10+ messages in thread
From: Subash Abhinov Kasiviswanathan @ 2026-11-17 6:07 UTC (permalink / raw)
To: sean.tranchetti, andrew+netdev, davem, edumazet, kuba, pabeni
Cc: netdev, linux-kernel, Subash Abhinov Kasiviswanathan
The MTU helpers subtract the egress headroom from the real device MTU
using unsigned arithmetic. A real device MTU smaller than the headroom
underflows and results in a huge target MTU instead of an error.
Additionally, a real device with a jumbo MTU makes the creation of the
first rmnet device fail since the unclamped value exceeds
RMNET_MAX_PACKET_SIZE, while resizing an existing device clamps it.
Add a helper which computes the largest MTU usable on top of the real
device for a data format, rejects real device MTUs below the headroom
before doing any arithmetic and clamps the result to
RMNET_MAX_PACKET_SIZE. Use it for both new and existing devices and add
the same underflow check to the other helpers.
Fixes: b7f5eb6ba21b ("net: qualcomm: rmnet: Update rmnet device MTU based on real device")
Co-developed-by: Sean Tranchetti <sean.tranchetti@oss.qualcomm.com>
Signed-off-by: Sean Tranchetti <sean.tranchetti@oss.qualcomm.com>
Signed-off-by: Subash Abhinov Kasiviswanathan <subash.a.kasiviswanathan@oss.qualcomm.com>
---
.../net/ethernet/qualcomm/rmnet/rmnet_vnd.c | 58 +++++++++++++------
1 file changed, 41 insertions(+), 17 deletions(-)
diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c
index 984c66bee863..2f3fefe58bce 100644
--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c
+++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c
@@ -80,6 +80,20 @@ static int rmnet_vnd_headroom(u32 data_format)
return headroom;
}
+/* Largest MTU an rmnet device can use on top of real_dev for the given data
+ * format, or -EINVAL if real_dev cannot even fit the headers.
+ */
+static int rmnet_vnd_target_mtu(struct net_device *real_dev, u32 data_format)
+{
+ u32 headroom;
+
+ headroom = rmnet_vnd_headroom(data_format);
+ if (real_dev->mtu < headroom)
+ return -EINVAL;
+
+ return min_t(int, real_dev->mtu - headroom, RMNET_MAX_PACKET_SIZE);
+}
+
static int rmnet_vnd_change_mtu_with_format(struct net_device *rmnet_dev,
int new_mtu, u32 data_format)
{
@@ -88,7 +102,8 @@ static int rmnet_vnd_change_mtu_with_format(struct net_device *rmnet_dev,
headroom = rmnet_vnd_headroom(data_format);
- if (new_mtu < 0 || new_mtu > RMNET_MAX_PACKET_SIZE ||
+ if (priv->real_dev->mtu < headroom ||
+ new_mtu < 0 || new_mtu > RMNET_MAX_PACKET_SIZE ||
new_mtu > (priv->real_dev->mtu - headroom))
return -EINVAL;
@@ -322,7 +337,7 @@ int rmnet_vnd_newlink(u8 id, struct net_device *rmnet_dev,
struct netlink_ext_ack *extack, u32 data_format)
{
struct rmnet_priv *priv = netdev_priv(rmnet_dev);
- u32 headroom;
+ int new_mtu;
int rc;
if (rmnet_get_endpoint(port, id)) {
@@ -336,11 +351,9 @@ int rmnet_vnd_newlink(u8 id, struct net_device *rmnet_dev,
priv->real_dev = real_dev;
- headroom = rmnet_vnd_headroom(data_format);
-
- if (rmnet_vnd_change_mtu_with_format(rmnet_dev,
- real_dev->mtu - headroom,
- data_format)) {
+ new_mtu = rmnet_vnd_target_mtu(real_dev, data_format);
+ if (new_mtu < 0 ||
+ rmnet_vnd_change_mtu_with_format(rmnet_dev, new_mtu, data_format)) {
NL_SET_ERR_MSG_MOD(extack, "Invalid MTU on real dev");
return -EINVAL;
}
@@ -387,17 +400,17 @@ int rmnet_vnd_do_flow_control(struct net_device *rmnet_dev, int enable)
return 0;
}
-int rmnet_vnd_validate_real_dev_mtu(struct net_device *real_dev)
+static int rmnet_vnd_validate_mtu(struct rmnet_port *port,
+ struct net_device *real_dev, u32 data_format)
{
struct hlist_node *tmp_ep;
struct rmnet_endpoint *ep;
- struct rmnet_port *port;
unsigned long bkt_ep;
u32 headroom;
- port = rmnet_get_port_rtnl(real_dev);
-
- headroom = rmnet_vnd_headroom(READ_ONCE(port->data_format));
+ headroom = rmnet_vnd_headroom(data_format);
+ if (real_dev->mtu < headroom)
+ return -EINVAL;
hash_for_each_safe(port->muxed_ep, bkt_ep, tmp_ep, ep, hlnode) {
if (ep->egress_dev->mtu > (real_dev->mtu - headroom))
@@ -407,22 +420,33 @@ int rmnet_vnd_validate_real_dev_mtu(struct net_device *real_dev)
return 0;
}
+int rmnet_vnd_validate_real_dev_mtu(struct net_device *real_dev)
+{
+ struct rmnet_port *port;
+
+ port = rmnet_get_port_rtnl(real_dev);
+
+ return rmnet_vnd_validate_mtu(port, real_dev,
+ READ_ONCE(port->data_format));
+}
+
int rmnet_vnd_update_dev_mtu(struct rmnet_port *port,
struct net_device *real_dev)
{
struct hlist_node *tmp_ep;
struct rmnet_endpoint *ep;
unsigned long bkt_ep;
- u32 headroom;
+ int new_mtu;
- headroom = rmnet_vnd_headroom(READ_ONCE(port->data_format));
+ new_mtu = rmnet_vnd_target_mtu(real_dev, READ_ONCE(port->data_format));
+ if (new_mtu < 0)
+ return new_mtu;
hash_for_each_safe(port->muxed_ep, bkt_ep, tmp_ep, ep, hlnode) {
- if (ep->egress_dev->mtu <= (real_dev->mtu - headroom))
+ if (ep->egress_dev->mtu <= new_mtu)
continue;
- if (rmnet_vnd_change_mtu(ep->egress_dev,
- real_dev->mtu - headroom))
+ if (rmnet_vnd_change_mtu(ep->egress_dev, new_mtu))
return -1;
}
--
2.34.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH net v5 4/5] net: qualcomm: rmnet: Publish data format and mux_id only after the MTU update
2026-11-17 6:07 [PATCH net v5 0/5] net: qualcomm: rmnet: Update MTU handling during format changes Subash Abhinov Kasiviswanathan
` (2 preceding siblings ...)
2026-11-17 6:07 ` [PATCH net v5 3/5] net: qualcomm: rmnet: Fix MTU underflow and clamp to the maximum packet size Subash Abhinov Kasiviswanathan
@ 2026-11-17 6:07 ` Subash Abhinov Kasiviswanathan
2026-11-17 6:07 ` [PATCH net v5 5/5] net: qualcomm: rmnet: Resize endpoints with dev_set_mtu() and restore on failure Subash Abhinov Kasiviswanathan
4 siblings, 0 replies; 10+ messages in thread
From: Subash Abhinov Kasiviswanathan @ 2026-11-17 6:07 UTC (permalink / raw)
To: sean.tranchetti, andrew+netdev, davem, edumazet, kuba, pabeni
Cc: netdev, linux-kernel, Subash Abhinov Kasiviswanathan
rmnet_changelink() publishes the new shared data format before
resizing the endpoints and reverts it if the resize fails, so the
datapath can briefly observe a format whose headers do not fit the
MTUs. A mux_id change requested in the same call is also applied before
the resize, so it is kept even though the call returned an error.
rmnet_newlink() never resized the existing devices at all, so a flags
change which increases the egress headroom left them with an MTU that
is too large for the real device.
Compute the new data format locally and pass it to
rmnet_vnd_update_dev_mtu(). In both rmnet_changelink() and
rmnet_newlink(), publish the format only after all MTUs have been
updated so that no revert is needed. rmnet_changelink() also moves the
endpoint to the new mux_id last, once the checks and the MTU update have
succeeded, so that a failed request leaves no partial change behind.
Return the error from the failing MTU change instead of -1.
Fixes: b7f5eb6ba21b ("net: qualcomm: rmnet: Update rmnet device MTU based on real device")
Co-developed-by: Sean Tranchetti <sean.tranchetti@oss.qualcomm.com>
Signed-off-by: Sean Tranchetti <sean.tranchetti@oss.qualcomm.com>
Signed-off-by: Subash Abhinov Kasiviswanathan <subash.a.kasiviswanathan@oss.qualcomm.com>
---
.../ethernet/qualcomm/rmnet/rmnet_config.c | 58 ++++++++++++-------
.../net/ethernet/qualcomm/rmnet/rmnet_vnd.c | 10 ++--
.../net/ethernet/qualcomm/rmnet/rmnet_vnd.h | 2 +-
3 files changed, 44 insertions(+), 26 deletions(-)
diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c
index 40544b75e602..9e66f3804de4 100644
--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c
+++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c
@@ -171,6 +171,13 @@ static int rmnet_newlink(struct net_device *dev,
if (err < 0)
goto err2;
+ /* Update existing MTUs before publishing the shared data format. */
+ err = rmnet_vnd_update_dev_mtu(port, real_dev, data_format);
+ if (err) {
+ NL_SET_ERR_MSG_MOD(extack, "Failed to update MTU of rmnet devices");
+ goto err3;
+ }
+
port->rmnet_mode = mode;
port->rmnet_dev = dev;
@@ -181,6 +188,8 @@ static int rmnet_newlink(struct net_device *dev,
return 0;
+err3:
+ netdev_upper_dev_unlink(real_dev, dev);
err2:
unregister_netdevice(dev);
rmnet_vnd_dellink(mux_id, port, ep);
@@ -302,9 +311,14 @@ static int rmnet_changelink(struct net_device *dev, struct nlattr *tb[],
struct netlink_ext_ack *extack)
{
struct rmnet_priv *priv = netdev_priv(dev);
+ struct rmnet_endpoint *ep = NULL;
+ struct ifla_rmnet_flags *flags;
struct net_device *real_dev;
struct rmnet_port *port;
+ u32 old_data_format;
+ u32 data_format;
u16 mux_id;
+ int err;
if (!dev)
return -ENODEV;
@@ -321,12 +335,17 @@ static int rmnet_changelink(struct net_device *dev, struct nlattr *tb[],
port = rmnet_get_port_rtnl(real_dev);
+ if (data[IFLA_RMNET_FLAGS]) {
+ old_data_format = READ_ONCE(port->data_format);
+ flags = nla_data(data[IFLA_RMNET_FLAGS]);
+ data_format = old_data_format & ~flags->mask;
+ data_format |= flags->flags & flags->mask;
+ }
+
if (data[IFLA_RMNET_MUX_ID]) {
mux_id = nla_get_u16(data[IFLA_RMNET_MUX_ID]);
if (mux_id != priv->mux_id) {
- struct rmnet_endpoint *ep;
-
ep = rmnet_get_endpoint(port, priv->mux_id);
if (!ep)
return -ENODEV;
@@ -336,32 +355,29 @@ static int rmnet_changelink(struct net_device *dev, struct nlattr *tb[],
"MUX ID already exists");
return -EINVAL;
}
-
- hlist_del_init_rcu(&ep->hlnode);
- WRITE_ONCE(ep->mux_id, mux_id);
- hlist_add_head_rcu(&ep->hlnode,
- &port->muxed_ep[mux_id]);
-
- WRITE_ONCE(priv->mux_id, mux_id);
}
}
if (data[IFLA_RMNET_FLAGS]) {
- struct ifla_rmnet_flags *flags;
- u32 old_data_format;
- u32 data_format;
+ err = rmnet_vnd_update_dev_mtu(port, real_dev, data_format);
+ if (err) {
+ NL_SET_ERR_MSG_MOD(extack,
+ "Failed to update MTU of rmnet devices");
+ return err;
+ }
- old_data_format = port->data_format;
- flags = nla_data(data[IFLA_RMNET_FLAGS]);
- data_format = old_data_format & ~flags->mask;
- data_format |= flags->flags & flags->mask;
WRITE_ONCE(port->data_format, data_format);
+ }
- if (rmnet_vnd_update_dev_mtu(port, real_dev)) {
- WRITE_ONCE(port->data_format, old_data_format);
- NL_SET_ERR_MSG_MOD(extack, "Invalid MTU on real dev");
- return -EINVAL;
- }
+ /* Nothing below can fail, so move the endpoint only after all the
+ * checks and the MTU update have succeeded.
+ */
+ if (ep) {
+ hlist_del_init_rcu(&ep->hlnode);
+ WRITE_ONCE(ep->mux_id, mux_id);
+ hlist_add_head_rcu(&ep->hlnode, &port->muxed_ep[mux_id]);
+
+ WRITE_ONCE(priv->mux_id, mux_id);
}
return 0;
diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c
index 2f3fefe58bce..8bf87c5ecb43 100644
--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c
+++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c
@@ -431,14 +431,15 @@ int rmnet_vnd_validate_real_dev_mtu(struct net_device *real_dev)
}
int rmnet_vnd_update_dev_mtu(struct rmnet_port *port,
- struct net_device *real_dev)
+ struct net_device *real_dev, u32 data_format)
{
struct hlist_node *tmp_ep;
struct rmnet_endpoint *ep;
unsigned long bkt_ep;
int new_mtu;
+ int err;
- new_mtu = rmnet_vnd_target_mtu(real_dev, READ_ONCE(port->data_format));
+ new_mtu = rmnet_vnd_target_mtu(real_dev, data_format);
if (new_mtu < 0)
return new_mtu;
@@ -446,8 +447,9 @@ int rmnet_vnd_update_dev_mtu(struct rmnet_port *port,
if (ep->egress_dev->mtu <= new_mtu)
continue;
- if (rmnet_vnd_change_mtu(ep->egress_dev, new_mtu))
- return -1;
+ err = rmnet_vnd_change_mtu(ep->egress_dev, new_mtu);
+ if (err)
+ return err;
}
return 0;
diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.h b/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.h
index 5d54c24f5c8c..901ef36900ac 100644
--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.h
+++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.h
@@ -21,5 +21,5 @@ void rmnet_vnd_tx_fixup(struct sk_buff *skb, struct net_device *dev);
void rmnet_vnd_setup(struct net_device *dev);
int rmnet_vnd_validate_real_dev_mtu(struct net_device *real_dev);
int rmnet_vnd_update_dev_mtu(struct rmnet_port *port,
- struct net_device *real_dev);
+ struct net_device *real_dev, u32 data_format);
#endif /* _RMNET_VND_H_ */
--
2.34.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH net v5 5/5] net: qualcomm: rmnet: Resize endpoints with dev_set_mtu() and restore on failure
2026-11-17 6:07 [PATCH net v5 0/5] net: qualcomm: rmnet: Update MTU handling during format changes Subash Abhinov Kasiviswanathan
` (3 preceding siblings ...)
2026-11-17 6:07 ` [PATCH net v5 4/5] net: qualcomm: rmnet: Publish data format and mux_id only after the MTU update Subash Abhinov Kasiviswanathan
@ 2026-11-17 6:07 ` Subash Abhinov Kasiviswanathan
2026-11-21 7:04 ` netdev-bot+sashiko
4 siblings, 1 reply; 10+ messages in thread
From: Subash Abhinov Kasiviswanathan @ 2026-11-17 6:07 UTC (permalink / raw)
To: sean.tranchetti, andrew+netdev, davem, edumazet, kuba, pabeni
Cc: netdev, linux-kernel, Subash Abhinov Kasiviswanathan
When the real device MTU or the data format requires a smaller MTU,
existing endpoints are shrunk by writing dev->mtu directly. No MTU
notifiers run and userspace gets no link notification.
Resize the endpoints with dev_set_mtu() so that the normal notifiers
and link notifications are delivered. If resizing an endpoint fails,
restore the endpoints which were already resized, ignoring any errors
from the restore, so that a failed request does not leave some of them
shrunk. The data format is not yet published while the endpoints are
resized, so the restore is validated against the format the endpoints
were sized for. The error from the failing dev_set_mtu() call is
returned to the caller.
Fixes: b7f5eb6ba21b ("net: qualcomm: rmnet: Update rmnet device MTU based on real device")
Co-developed-by: Sean Tranchetti <sean.tranchetti@oss.qualcomm.com>
Signed-off-by: Sean Tranchetti <sean.tranchetti@oss.qualcomm.com>
Signed-off-by: Subash Abhinov Kasiviswanathan <subash.a.kasiviswanathan@oss.qualcomm.com>
---
.../ethernet/qualcomm/rmnet/rmnet_config.h | 1 +
.../net/ethernet/qualcomm/rmnet/rmnet_vnd.c | 30 +++++++++++++++----
2 files changed, 25 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.h b/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.h
index 5adda0323dda..47b8db3206b9 100644
--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.h
+++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.h
@@ -19,6 +19,7 @@ struct rmnet_endpoint {
struct net_device *egress_dev;
struct hlist_node hlnode;
struct rcu_head rcu;
+ int saved_mtu;
};
struct rmnet_egress_agg_params {
diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c
index 8bf87c5ecb43..dce436e4c630 100644
--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c
+++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c
@@ -433,24 +433,42 @@ int rmnet_vnd_validate_real_dev_mtu(struct net_device *real_dev)
int rmnet_vnd_update_dev_mtu(struct rmnet_port *port,
struct net_device *real_dev, u32 data_format)
{
+ struct rmnet_endpoint *fail_ep = NULL;
struct hlist_node *tmp_ep;
struct rmnet_endpoint *ep;
unsigned long bkt_ep;
int new_mtu;
- int err;
+ int err = 0;
new_mtu = rmnet_vnd_target_mtu(real_dev, data_format);
if (new_mtu < 0)
return new_mtu;
hash_for_each_safe(port->muxed_ep, bkt_ep, tmp_ep, ep, hlnode) {
- if (ep->egress_dev->mtu <= new_mtu)
+ ep->saved_mtu = ep->egress_dev->mtu;
+ if (ep->saved_mtu <= new_mtu)
continue;
- err = rmnet_vnd_change_mtu(ep->egress_dev, new_mtu);
- if (err)
- return err;
+ err = dev_set_mtu(ep->egress_dev, new_mtu);
+ if (err) {
+ fail_ep = ep;
+ break;
+ }
}
- return 0;
+ if (!err)
+ return 0;
+
+ /* Restore the endpoints which were already resized. Failures here
+ * are ignored since the original error is the one to report.
+ */
+ hash_for_each_safe(port->muxed_ep, bkt_ep, tmp_ep, ep, hlnode) {
+ if (ep == fail_ep)
+ break;
+
+ if (ep->egress_dev->mtu != ep->saved_mtu)
+ dev_set_mtu(ep->egress_dev, ep->saved_mtu);
+ }
+
+ return err;
}
--
2.34.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH net v5 2/5] net: qualcomm: rmnet: Size the first device from the requested data format
2026-11-17 6:07 ` [PATCH net v5 2/5] net: qualcomm: rmnet: Size the first device from the requested data format Subash Abhinov Kasiviswanathan
@ 2026-11-21 7:04 ` netdev-bot+sashiko
0 siblings, 0 replies; 10+ messages in thread
From: netdev-bot+sashiko @ 2026-11-21 7:04 UTC (permalink / raw)
To: subash.a.kasiviswanathan
Cc: sean.tranchetti, andrew+netdev, davem, edumazet, kuba, pabeni,
netdev, linux-kernel
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The commit message understates what the patch changes.
--
net: qualcomm: rmnet: Size the first device from the requested data format
This commit moves the IFLA_RMNET_FLAGS merge in rmnet_newlink() so it
runs before rmnet_vnd_newlink(), and passes the resulting data format
down. The new device's MTU is then computed from the egress headroom of
the requested format, not from the format already stored in the port.
> net: qualcomm: rmnet: Size the first device from the requested data format
>
> rmnet_newlink() sizes the first rmnet device from the data format
> currently stored in the port, before the requested IFLA_RMNET_FLAGS
> have been applied. The MTU therefore does not match the egress header
> overhead of the format which ends up being used.
[Severity: Low]
This isn't a bug, but is the "first device" wording narrower than what
the patch does?
The reordering in rmnet_newlink() in
drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c is not limited to the
case where port->nr_rmnet_devs == 0. Every newlink now merges
IFLA_RMNET_FLAGS into the local data_format first, then sizes its device
from it:
err = rmnet_vnd_newlink(mux_id, dev, port, real_dev, ep, extack,
data_format);
Before this patch, a second or later device on the same real_dev got its
initial MTU from the port-wide format left by the previous newlink.
After this patch, that device is sized from its own requested flags. If
no flags are given, it is sized from RMNET_FLAGS_INGRESS_DEAGGREGATION
alone. Its default MTU can therefore differ by the size of the checksum
header (no checksum vs CKSUMV4/V5).
The message also doesn't say that port->data_format is a single setting
for the whole port, and that every newlink overwrites it.
Could the subject and body say that every device created through
rmnet_newlink() is affected, not only the first one?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261117060737.2764327-1-subash.a.kasiviswanathan%40oss.qualcomm.com
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH net v5 3/5] net: qualcomm: rmnet: Fix MTU underflow and clamp to the maximum packet size
2026-11-17 6:07 ` [PATCH net v5 3/5] net: qualcomm: rmnet: Fix MTU underflow and clamp to the maximum packet size Subash Abhinov Kasiviswanathan
@ 2026-11-21 7:04 ` netdev-bot+sashiko
0 siblings, 0 replies; 10+ messages in thread
From: netdev-bot+sashiko @ 2026-11-21 7:04 UTC (permalink / raw)
To: subash.a.kasiviswanathan
Cc: sean.tranchetti, andrew+netdev, davem, edumazet, kuba, pabeni,
netdev, linux-kernel
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The commit message gets the pre-patch behaviour wrong in three
places.
Pre-existing issues:
- [Medium] At this patch, rmnet_vnd_newlink() sizes only the new device's
MTU, using that request's data_format.
--
net: qualcomm: rmnet: Fix MTU underflow and clamp to the maximum packet size
This commit adds rmnet_vnd_target_mtu(). The helper rejects real device
MTUs below the egress headroom and clamps the result to
RMNET_MAX_PACKET_SIZE. It is used for new and existing rmnet devices, and
the same underflow check is added to the other MTU helpers in
rmnet_vnd.c.
> The MTU helpers subtract the egress headroom from the real device MTU
> using unsigned arithmetic. A real device MTU smaller than the headroom
> underflows and results in a huge target MTU instead of an error.
[Severity: Low]
Does this hold for the rmnet_vnd_newlink() path?
Before this patch, rmnet_vnd_newlink() passed the wrapped u32 value as
the int new_mtu parameter of rmnet_vnd_change_mtu_with_format():
if (rmnet_vnd_change_mtu_with_format(rmnet_dev,
real_dev->mtu - headroom,
data_format)) {
As an int, the wrapped value is negative, so the existing "new_mtu < 0"
check already returned -EINVAL.
The underflow seems to have mattered in other places:
- the ndo_change_mtu bound in rmnet_vnd_change_mtu_with_format(). On a
tiny real device it accepted any MTU up to RMNET_MAX_PACKET_SIZE.
- rmnet_vnd_validate_real_dev_mtu(). It let the real device MTU drop
below the headroom.
- rmnet_vnd_update_dev_mtu(). It accepted a data format whose headroom
is larger than the real device MTU.
> Additionally, a real device with a jumbo MTU makes the creation of the
> first rmnet device fail since the unclamped value exceeds
> RMNET_MAX_PACKET_SIZE, while resizing an existing device clamps it.
Is "first" accurate here? Every rmnet_vnd_newlink() call seems to fail
while real_dev->mtu - headroom is above RMNET_MAX_PACKET_SIZE.
That includes a second device created after the real device MTU was
raised. The NETDEV_CHANGEMTU validation only rejects a shrink, so the
raise is allowed.
As for "clamps it", rmnet_vnd_update_dev_mtu() had no clamp before this
patch:
hash_for_each_safe(port->muxed_ep, bkt_ep, tmp_ep, ep, hlnode) {
if (ep->egress_dev->mtu <= (real_dev->mtu - headroom))
continue;
On a jumbo real device this condition is always true, so the function
does nothing. The patch doesn't change that. Existing MTUs are already at
most RMNET_MAX_PACKET_SIZE, so the loop still takes the continue.
This patch has a Fixes: tag. Could the commit message say more precisely
which paths were affected?
> diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c
> index 984c66bee863a..2f3fefe58bce3 100644
> --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c
> +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c
[ ... ]
> @@ -336,11 +351,9 @@ int rmnet_vnd_newlink(u8 id, struct net_device *rmnet_dev,
>
> priv->real_dev = real_dev;
>
> - headroom = rmnet_vnd_headroom(data_format);
> -
> - if (rmnet_vnd_change_mtu_with_format(rmnet_dev,
> - real_dev->mtu - headroom,
> - data_format)) {
> + new_mtu = rmnet_vnd_target_mtu(real_dev, data_format);
> + if (new_mtu < 0 ||
> + rmnet_vnd_change_mtu_with_format(rmnet_dev, new_mtu, data_format)) {
> NL_SET_ERR_MSG_MOD(extack, "Invalid MTU on real dev");
> return -EINVAL;
> }
[Severity: Medium]
This is a pre-existing issue, not one introduced by this patch.
Only the new device is sized here, using the data_format from this
request. rmnet_newlink() then overwrites the format for the whole port
and does not recheck the existing endpoints:
drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c:rmnet_newlink() {
...
hlist_add_head_rcu(&ep->hlnode, &port->muxed_ep[mux_id]);
netdev_dbg(dev, "data format [0x%08X]\n", data_format);
WRITE_ONCE(port->data_format, data_format);
...
}
Can existing endpoints then send frames larger than the real device
MTU? For example, on a real device with MTU 1500:
- rmnet0 is created with the default format (headroom 4, MTU 1496).
- rmnet1 is then created with RMNET_FLAGS_EGRESS_MAP_CKSUMV4 set
(headroom 8).
After that, rmnet0 frames get the larger header, so a full-size rmnet0
frame comes out at 1504 bytes.
rmnet_changelink() covers this case. It calls rmnet_vnd_update_dev_mtu()
and restores old_data_format on failure. The newlink path does neither.
A later commit in the series, "net: qualcomm: rmnet: Publish data format
and mux_id only after the MTU update", appears to fix this. It calls
rmnet_vnd_update_dev_mtu(port, real_dev, data_format) from
rmnet_newlink() before publishing the format, and unwinds on failure.
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261117060737.2764327-1-subash.a.kasiviswanathan%40oss.qualcomm.com
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH net v5 5/5] net: qualcomm: rmnet: Resize endpoints with dev_set_mtu() and restore on failure
2026-11-17 6:07 ` [PATCH net v5 5/5] net: qualcomm: rmnet: Resize endpoints with dev_set_mtu() and restore on failure Subash Abhinov Kasiviswanathan
@ 2026-11-21 7:04 ` netdev-bot+sashiko
2026-11-21 15:51 ` subash.a.kasiviswanathan
0 siblings, 1 reply; 10+ messages in thread
From: netdev-bot+sashiko @ 2026-11-21 7:04 UTC (permalink / raw)
To: subash.a.kasiviswanathan
Cc: sean.tranchetti, andrew+netdev, davem, edumazet, kuba, pabeni,
netdev, linux-kernel
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 1
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] rmnet_vnd_update_dev_mtu()
(drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c:447-473) now shrinks…
- [Low] The commit message opens with "When the real device MTU or the
data format requires a smaller MTU, existing endpoints are shrunk by…
--
net: qualcomm: rmnet: Resize endpoints with dev_set_mtu() and restore on failure
This commit changes rmnet_vnd_update_dev_mtu() so it shrinks existing
endpoints with dev_set_mtu() instead of calling the ndo directly. As a
result, MTU notifiers and link notifications are now delivered. If resizing
an endpoint fails, the endpoints already resized are put back to their
saved MTU, and the original error is returned.
> When the real device MTU or the data format requires a smaller MTU,
> existing endpoints are shrunk by writing dev->mtu directly. No MTU
> notifiers run and userspace gets no link notification.
[Severity: Low]
Is the part about the real device MTU accurate?
rmnet_vnd_update_dev_mtu() has only two callers, rmnet_newlink() and
rmnet_changelink(). The changelink call only happens when IFLA_RMNET_FLAGS
is present, which means a data format change.
When the real device MTU changes, rmnet_config_notify_cb() only validates
the new value and vetoes it if needed:
drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c:rmnet_config_notify_cb() {
...
case NETDEV_CHANGEMTU:
if (rmnet_vnd_validate_real_dev_mtu(real_dev))
return NOTIFY_BAD;
...
}
So endpoints are never shrunk on that path, either before or after this
patch.
Could the commit message be limited to the data format case? As written,
it suggests this fix also covers the real device MTU path.
> diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c
> index 8bf87c5ecb43b..dce436e4c6305 100644
> --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c
> +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c
> @@ -433,24 +433,42 @@ int rmnet_vnd_validate_real_dev_mtu(struct net_device *real_dev)
[ ... ]
> hash_for_each_safe(port->muxed_ep, bkt_ep, tmp_ep, ep, hlnode) {
> - if (ep->egress_dev->mtu <= new_mtu)
> + ep->saved_mtu = ep->egress_dev->mtu;
> + if (ep->saved_mtu <= new_mtu)
> continue;
>
> - err = rmnet_vnd_change_mtu(ep->egress_dev, new_mtu);
> - if (err)
> - return err;
> + err = dev_set_mtu(ep->egress_dev, new_mtu);
> + if (err) {
> + fail_ep = ep;
> + break;
> + }
> }
>
> - return 0;
> + if (!err)
> + return 0;
> +
> + /* Restore the endpoints which were already resized. Failures here
> + * are ignored since the original error is the one to report.
> + */
> + hash_for_each_safe(port->muxed_ep, bkt_ep, tmp_ep, ep, hlnode) {
> + if (ep == fail_ep)
> + break;
> +
> + if (ep->egress_dev->mtu != ep->saved_mtu)
> + dev_set_mtu(ep->egress_dev, ep->saved_mtu);
[Severity: Medium]
Does this restore undo everything the earlier dev_set_mtu() calls did?
Now that the shrink goes through dev_set_mtu(), netif_set_mtu_ext() runs
the NETDEV_PRECHANGEMTU and NETDEV_CHANGEMTU notifier chains for each
endpoint.
A PRECHANGEMTU notifier can now veto the shrink. For example,
team_device_event() does this:
drivers/net/team/team_core.c:team_device_event() {
...
case NETDEV_PRECHANGEMTU:
/* Forbid to change mtu of underlaying device */
if (!port->team->port_mtu_change_allowed)
return NOTIFY_BAD;
...
}
Before this patch, the direct rmnet_vnd_change_mtu() call could not fail
here, because new_mtu < ep mtu <= real_dev->mtu - old headroom. So a
newlink or changelink with IFLA_RMNET_FLAGS that used to succeed can now
return an error.
If the veto happens on a later endpoint, the CHANGEMTU notifiers have
already run on the earlier ones. If the temporary new_mtu was below
IPV6_MIN_MTU, addrconf_notify() tore down IPv6 on those endpoints:
net/ipv6/addrconf.c:addrconf_notify() {
...
case NETDEV_CHANGEMTU:
/* if MTU under IPV6_MIN_MTU stop IPv6 on this interface. */
if (dev->mtu < IPV6_MIN_MTU) {
addrconf_ifdown(dev, dev != net->loopback_dev);
break;
}
...
}
In the same way, inetdev_event() falls through to inetdev_destroy() when
the MTU is below the IPv4 minimum.
Restoring saved_mtu only creates a new, empty inet6_dev or in_device. The
configured addresses, routes and per-device sysctls are still lost, even
though the request returned an error.
For example, take a real_dev MTU of 1284 with no checksum offload (4 bytes
of headroom). Endpoint A has a lower mux_id, has IPv6 configured and is at
1280. Endpoint B has a higher mux_id, is a team port and is also at 1280. A
changelink that sets CKSUMV5 (8 bytes of headroom) gives new_mtu = 1276:
dev_set_mtu(A, 1276) -> addrconf_ifdown(A, true)
dev_set_mtu(B, 1276) -> vetoed by team_device_event(), -EPERM
dev_set_mtu(A, 1280) -> A comes back with no IPv6 addresses
Userspace also gets a shrink-then-grow pair of RTM_NEWLINK events for A,
for a request that failed.
The commit message says a failed request "does not leave some of them
shrunk". That holds for the MTU values but not for the L3 state.
Is this partial rollback intended? If so, should the commit message
mention the new veto failures and the lost L3 state on endpoints that were
already resized?
> + }
> +
> + return err;
> }
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261117060737.2764327-1-subash.a.kasiviswanathan%40oss.qualcomm.com
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: [PATCH net v5 5/5] net: qualcomm: rmnet: Resize endpoints with dev_set_mtu() and restore on failure
2026-11-21 7:04 ` netdev-bot+sashiko
@ 2026-11-21 15:51 ` subash.a.kasiviswanathan
0 siblings, 0 replies; 10+ messages in thread
From: subash.a.kasiviswanathan @ 2026-11-21 15:51 UTC (permalink / raw)
To: netdev-bot+sashiko
Cc: sean.tranchetti, andrew+netdev, davem, edumazet, kuba, pabeni,
netdev, linux-kernel
> -----Original Message-----
> From: netdev-bot+sashiko@kernel.org <netdev-bot+sashiko@kernel.org>
> Sent: Saturday, November 21, 2026 12:04 AM
> To: subash.a.kasiviswanathan@oss.qualcomm.com
> Cc: sean.tranchetti@oss.qualcomm.com; andrew+netdev@lunn.ch;
> davem@davemloft.net; edumazet@kernel.org; kuba@kernel.org;
> pabeni@redhat.com; netdev@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: Re: [PATCH net v5 5/5] net: qualcomm: rmnet: Resize endpoints with
> dev_set_mtu() and restore on failure
>
> Thank you for your contribution! Sashiko AI review found 2 potential
> issue(s) to consider.
>
> Critical: 0 · High: 0 · Medium: 1 · Low: 1
>
> If you believe none of the issues are legitimate, please reply to each
> issue of Medium severity or higher and explain why the AI is wrong.
> If any of them are legitimate and you plan to respin, please let patchwork
> know by including "pw-bot: cr" as a separate line at the end of your reply
> (one such reply per series is enough).
>
> - [Medium] rmnet_vnd_update_dev_mtu()
> (drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c:447-473) now
> shrinks…
> - [Low] The commit message opens with "When the real device MTU or the
> data format requires a smaller MTU, existing endpoints are shrunk by…
>
> --
>
> net: qualcomm: rmnet: Resize endpoints with dev_set_mtu() and restore on
> failure
>
> This commit changes rmnet_vnd_update_dev_mtu() so it shrinks existing
> endpoints with dev_set_mtu() instead of calling the ndo directly. As a
> result, MTU notifiers and link notifications are now delivered. If resizing
> an endpoint fails, the endpoints already resized are put back to their
> saved MTU, and the original error is returned.
>
> > When the real device MTU or the data format requires a smaller MTU,
> > existing endpoints are shrunk by writing dev->mtu directly. No MTU
> > notifiers run and userspace gets no link notification.
>
> [Severity: Low]
> Is the part about the real device MTU accurate?
>
> rmnet_vnd_update_dev_mtu() has only two callers, rmnet_newlink() and
> rmnet_changelink(). The changelink call only happens when
> IFLA_RMNET_FLAGS
> is present, which means a data format change.
>
> When the real device MTU changes, rmnet_config_notify_cb() only validates
> the new value and vetoes it if needed:
>
> drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c:rmnet_config_notify_
> cb() {
> ...
> case NETDEV_CHANGEMTU:
> if (rmnet_vnd_validate_real_dev_mtu(real_dev))
> return NOTIFY_BAD;
> ...
> }
>
> So endpoints are never shrunk on that path, either before or after this
> patch.
>
> Could the commit message be limited to the data format case? As written,
> it suggests this fix also covers the real device MTU path.
>
> > diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c
> b/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c
> > index 8bf87c5ecb43b..dce436e4c6305 100644
> > --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c
> > +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c
> > @@ -433,24 +433,42 @@ int rmnet_vnd_validate_real_dev_mtu(struct
> net_device *real_dev)
>
> [ ... ]
>
> > hash_for_each_safe(port->muxed_ep, bkt_ep, tmp_ep, ep, hlnode) {
> > - if (ep->egress_dev->mtu <= new_mtu)
> > + ep->saved_mtu = ep->egress_dev->mtu;
> > + if (ep->saved_mtu <= new_mtu)
> > continue;
> >
> > - err = rmnet_vnd_change_mtu(ep->egress_dev, new_mtu);
> > - if (err)
> > - return err;
> > + err = dev_set_mtu(ep->egress_dev, new_mtu);
> > + if (err) {
> > + fail_ep = ep;
> > + break;
> > + }
> > }
> >
> > - return 0;
> > + if (!err)
> > + return 0;
> > +
> > + /* Restore the endpoints which were already resized. Failures here
> > + * are ignored since the original error is the one to report.
> > + */
> > + hash_for_each_safe(port->muxed_ep, bkt_ep, tmp_ep, ep, hlnode) {
> > + if (ep == fail_ep)
> > + break;
> > +
> > + if (ep->egress_dev->mtu != ep->saved_mtu)
> > + dev_set_mtu(ep->egress_dev, ep->saved_mtu);
>
> [Severity: Medium]
> Does this restore undo everything the earlier dev_set_mtu() calls did?
>
> Now that the shrink goes through dev_set_mtu(), netif_set_mtu_ext() runs
> the NETDEV_PRECHANGEMTU and NETDEV_CHANGEMTU notifier chains for
> each
> endpoint.
>
> A PRECHANGEMTU notifier can now veto the shrink. For example,
> team_device_event() does this:
>
> drivers/net/team/team_core.c:team_device_event() {
> ...
> case NETDEV_PRECHANGEMTU:
> /* Forbid to change mtu of underlaying device */
> if (!port->team->port_mtu_change_allowed)
> return NOTIFY_BAD;
> ...
> }
>
> Before this patch, the direct rmnet_vnd_change_mtu() call could not fail
> here, because new_mtu < ep mtu <= real_dev->mtu - old headroom. So a
> newlink or changelink with IFLA_RMNET_FLAGS that used to succeed can now
> return an error.
>
> If the veto happens on a later endpoint, the CHANGEMTU notifiers have
> already run on the earlier ones. If the temporary new_mtu was below
> IPV6_MIN_MTU, addrconf_notify() tore down IPv6 on those endpoints:
>
> net/ipv6/addrconf.c:addrconf_notify() {
> ...
> case NETDEV_CHANGEMTU:
> /* if MTU under IPV6_MIN_MTU stop IPv6 on this interface.
> */
> if (dev->mtu < IPV6_MIN_MTU) {
> addrconf_ifdown(dev, dev != net->loopback_dev);
> break;
> }
> ...
> }
>
> In the same way, inetdev_event() falls through to inetdev_destroy() when
> the MTU is below the IPv4 minimum.
>
> Restoring saved_mtu only creates a new, empty inet6_dev or in_device. The
> configured addresses, routes and per-device sysctls are still lost, even
> though the request returned an error.
>
> For example, take a real_dev MTU of 1284 with no checksum offload (4 bytes
> of headroom). Endpoint A has a lower mux_id, has IPv6 configured and is at
> 1280. Endpoint B has a higher mux_id, is a team port and is also at 1280. A
> changelink that sets CKSUMV5 (8 bytes of headroom) gives new_mtu = 1276:
>
> dev_set_mtu(A, 1276) -> addrconf_ifdown(A, true)
> dev_set_mtu(B, 1276) -> vetoed by team_device_event(), -EPERM
> dev_set_mtu(A, 1280) -> A comes back with no IPv6 addresses
>
> Userspace also gets a shrink-then-grow pair of RTM_NEWLINK events for A,
> for a request that failed.
>
> The commit message says a failed request "does not leave some of them
> shrunk". That holds for the MTU values but not for the L3 state.
>
> Is this partial rollback intended? If so, should the commit message
> mention the new veto failures and the lost L3 state on endpoints that were
> already resized?
>
> > + }
> > +
> > + return err;
> > }
>
Yes, partial rollback is expected here. The comment above the rollback logic already mentions that - "Failures here
are ignored".
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2026-11-21 15:51 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-17 6:07 [PATCH net v5 0/5] net: qualcomm: rmnet: Update MTU handling during format changes Subash Abhinov Kasiviswanathan
2026-11-17 6:07 ` [PATCH net v5 1/5] net: qualcomm: rmnet: Account for V5 checksum header in headroom Subash Abhinov Kasiviswanathan
2026-11-17 6:07 ` [PATCH net v5 2/5] net: qualcomm: rmnet: Size the first device from the requested data format Subash Abhinov Kasiviswanathan
2026-11-21 7:04 ` netdev-bot+sashiko
2026-11-17 6:07 ` [PATCH net v5 3/5] net: qualcomm: rmnet: Fix MTU underflow and clamp to the maximum packet size Subash Abhinov Kasiviswanathan
2026-11-21 7:04 ` netdev-bot+sashiko
2026-11-17 6:07 ` [PATCH net v5 4/5] net: qualcomm: rmnet: Publish data format and mux_id only after the MTU update Subash Abhinov Kasiviswanathan
2026-11-17 6:07 ` [PATCH net v5 5/5] net: qualcomm: rmnet: Resize endpoints with dev_set_mtu() and restore on failure Subash Abhinov Kasiviswanathan
2026-11-21 7:04 ` netdev-bot+sashiko
2026-11-21 15:51 ` subash.a.kasiviswanathan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®