From: Jacob Keller <jacob.e.keller@intel.com>
To: Eric Dumazet <edumazet@google.com>,
"David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: <netdev@vger.kernel.org>, <eric.dumazet@gmail.com>,
Simon Horman <horms@kernel.org>
Subject: Re: [PATCH net-next] net: annotate writes on dev->mtu from ndo_change_mtu()
Date: Mon, 6 May 2024 15:31:10 -0700 [thread overview]
Message-ID: <0bfded05-d4d1-4b60-a3fa-24a2ff6644b5@intel.com> (raw)
In-Reply-To: <20240506102812.3025432-1-edumazet@google.com>
On 5/6/2024 3:28 AM, Eric Dumazet wrote:
> Simon reported that ndo_change_mtu() methods were never
> updated to use WRITE_ONCE(dev->mtu, new_mtu) as hinted
> in commit 501a90c94510 ("inet: protect against too small
> mtu values.")
>
> We read dev->mtu without holding RTNL in many places,
> with READ_ONCE() annotations.
>
> It is time to take care of ndo_change_mtu() methods
> to use corresponding WRITE_ONCE()
>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Reported-by: Simon Horman <horms@kernel.org>
> Closes: https://lore.kernel.org/netdev/20240505144608.GB67882@kernel.org/
> ---
Many drivers, but it is fairly mechanical and straight forward. I
noticed one place where you also fixed up the code style, but otherwise
everything looks exactly like a mechanical transformation.
> diff --git a/drivers/net/ethernet/myricom/myri10ge/myri10ge.c b/drivers/net/ethernet/myricom/myri10ge/myri10ge.c
> index 7b7e1c5b00f4728cccfb693e2ab4e32b9613616e..b7d9657a7af3d168ea6fa6acd205d690fc79db06 100644
> --- a/drivers/net/ethernet/myricom/myri10ge/myri10ge.c
> +++ b/drivers/net/ethernet/myricom/myri10ge/myri10ge.c
> @@ -3036,11 +3036,11 @@ static int myri10ge_change_mtu(struct net_device *dev, int new_mtu)
> /* if we change the mtu on an active device, we must
> * reset the device so the firmware sees the change */
> myri10ge_close(dev);
> - dev->mtu = new_mtu;
> + WRITE_ONCE(dev->mtu, new_mtu);
> myri10ge_open(dev);
> - } else
> - dev->mtu = new_mtu;
> -
Looks like you also fix up the style with { } here. That is fine with me.
> + } else {
> + WRITE_ONCE(dev->mtu, new_mtu);
> + }
> return 0;
> }
>
The new style is correct, and I see no reason not to commit this now and
fix up the writes.
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
next prev parent reply other threads:[~2024-05-06 22:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-06 10:28 [PATCH net-next] net: annotate writes on dev->mtu from ndo_change_mtu() Eric Dumazet
2024-05-06 22:31 ` Jacob Keller [this message]
2024-05-07 10:05 ` Sabrina Dubroca
2024-05-07 20:07 ` Simon Horman
2024-05-07 22:31 ` Nelson, Shannon
2024-05-07 23:40 ` patchwork-bot+netdevbpf
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=0bfded05-d4d1-4b60-a3fa-24a2ff6644b5@intel.com \
--to=jacob.e.keller@intel.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=eric.dumazet@gmail.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).