🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
8 messages
8 total messages Started by Subash Abhinov Kasiviswanathan Tue, 17 Nov 2026 06:07
[PATCH net v5 0/5] net: qualcomm: rmnet: Update MTU handling during format changes
#17640
Author: Subash Abhinov Kasiviswanathan
Date: Tue, 17 Nov 2026 06:07
58 lines
14045 bytes
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
[PATCH net v5 2/5] net: qualcomm: rmnet: Size the first device from the requested data format
#17641
Author: Subash Abhinov Kasiviswanathan
Date: Tue, 17 Nov 2026 06:07
179 lines
18204 bytes
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
[PATCH net v5 5/5] net: qualcomm: rmnet: Resize endpoints with dev_set_mtu() and restore on failure
#17642
Author: Subash Abhinov Kasiviswanathan
Date: Tue, 17 Nov 2026 06:07
90 lines
14572 bytes
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
Re: [PATCH net v5 2/5] net: qualcomm: rmnet: Size the first device from the requested data format
#20089
Author: netdev-bot+sashiko
Date: Sat, 21 Nov 2026 07:04
54 lines
10066 bytes
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
Re: [PATCH net v5 5/5] net: qualcomm: rmnet: Resize endpoints with dev_set_mtu() and restore on failure
#20090
Author: netdev-bot+sashiko
Date: Sat, 21 Nov 2026 07:04
165 lines
13820 bytes
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
RE: [PATCH net v5 5/5] net: qualcomm: rmnet: Resize endpoints with dev_set_mtu() and restore on failure
#20149
Author: subash.a.kasiviswanathan
Date: Sat, 21 Nov 2026 15:51
208 lines
22456 bytes
> -----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". 
Re: [PATCH net v5 5/5] net: qualcomm: rmnet: Resize endpoints with dev_set_mtu() and restore on failure
#21079
Author: Simon Horman
Date: Mon, 23 Nov 2026 14:33
191 lines
15475 bytes
On Sat, Nov 21, 2026 at 08:51:04AM -0700, subash.a.kasiviswanathan@oss.qualcomm.com wrote:
> > -----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". 

I assume that the motivation for taking this approach is that both avoiding
the need for rollback and performing a full rollback is somewhere between
difficult and impossible.

If so, I think the trade-off made in this patch is reasonable.
Re: [PATCH net v5 5/5] net: qualcomm: rmnet: Resize endpoints with dev_set_mtu() and restore on failure
#21081
Author: Simon Horman
Date: Mon, 23 Nov 2026 14:35
136 lines
12637 bytes
On Mon, Nov 16, 2026 at 10:07:38PM -0800, Subash Abhinov Kasiviswanathan wrote:
> 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;
>  }

The preferred idiom in Networking code is to:
1. Keep the happy path in the main unconditional path of execution.
2. Use goto for unwind on error

I think that can be achieved here with this incremental change
(compile tested only!).

diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c
index dce436e4c630..6b147ef5211e 100644
--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c
+++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c
@@ -433,12 +433,12 @@ 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 rmnet_endpoint *fail_ep;
 	struct hlist_node *tmp_ep;
 	struct rmnet_endpoint *ep;
 	unsigned long bkt_ep;
 	int new_mtu;
-	int err = 0;
+	int err;
 
 	new_mtu = rmnet_vnd_target_mtu(real_dev, data_format);
 	if (new_mtu < 0)
@@ -452,13 +452,13 @@ int rmnet_vnd_update_dev_mtu(struct rmnet_port *port,
 		err = dev_set_mtu(ep->egress_dev, new_mtu);
 		if (err) {
 			fail_ep = ep;
-			break;
+			goto restore_mtu;
 		}
 	}
 
-	if (!err)
-		return 0;
+	return 0;
 
+restore_mtu:
 	/* Restore the endpoints which were already resized. Failures here
 	 * are ignored since the original error is the one to report.
 	 */

-- 
pw-bot: changes-requested
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads