From: Simon Horman <horms@kernel.org>
To: Subash Abhinov Kasiviswanathan
<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
Date: Mon, 23 Nov 2026 14:35:38 +0000 [thread overview]
Message-ID: <20261123143538.GD31322@horms.kernel.org> (raw)
In-Reply-To: <20261117060737.2764327-6-subash.a.kasiviswanathan@oss.qualcomm.com>
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
prev parent reply other threads:[~2026-11-23 14:35 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
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-23 14:41 ` Simon Horman
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
2026-11-23 14:33 ` Simon Horman
2026-11-23 14:35 ` Simon Horman [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261123143538.GD31322@horms.kernel.org \
--to=horms@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sean.tranchetti@oss.qualcomm.com \
--cc=subash.a.kasiviswanathan@oss.qualcomm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.