linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Oliver Neukum <oneukum@suse.com>
Cc: Hayes Wang <hayeswang@realtek.com>,
	USB list <linux-usb@vger.kernel.org>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: Re: handling MAC set by user space in reset_resume() of r8152
Date: Wed, 27 Jul 2022 20:34:33 +0200	[thread overview]
Message-ID: <YuGFOU7oKlAGZjTa@lunn.ch> (raw)
In-Reply-To: <2397d98d-e373-1740-eb5f-8fe795a0352a@suse.com>

On Wed, Jul 27, 2022 at 01:39:43PM +0200, Oliver Neukum wrote:
> Hi,
> 
> looking at the driver it looks to me like the address
> provided to ndo_set_mac_address() is thrown away after use.
> That looks problematic to me, because reset_resume()
> should redo the operation.
> What do you think?
> 
> 	Regards
> 		Oliver

> From 19fc972a5cc98197bc81a7c56dd5d68e3fdfc36b Mon Sep 17 00:00:00 2001
> From: Oliver Neukum <oneukum@suse.com>
> Date: Wed, 27 Jul 2022 13:29:42 +0200
> Subject: [PATCH] r8152: restore external MAC in reset_resume
> 
> If user space has set the MAC of the interface,
> reset_resume() must restore that setting rather
> than redetermine the MAC like if te interface
> is probed regularly.
> 
> Signed-off-by: Oliver Neukum <oneukum@suse.com>
> ---
>  drivers/net/usb/r8152.c | 34 +++++++++++++++++++++++++---------
>  1 file changed, 25 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
> index 0f6efaabaa32..5cf74b984655 100644
> --- a/drivers/net/usb/r8152.c
> +++ b/drivers/net/usb/r8152.c
> @@ -923,6 +923,7 @@ struct r8152 {
>  	atomic_t rx_count;
>  
>  	bool eee_en;
> +	bool external_mac;
>  	int intr_interval;
>  	u32 saved_wolopts;
>  	u32 msg_enable;
> @@ -933,6 +934,8 @@ struct r8152 {
>  	u32 rx_copybreak;
>  	u32 rx_pending;
>  	u32 fc_pause_on, fc_pause_off;
> +	/* for reset_resume */
> +	struct sockaddr saved_addr;
>  
>  	unsigned int pipe_in, pipe_out, pipe_intr, pipe_ctrl_in, pipe_ctrl_out;
>  
> @@ -1574,6 +1577,7 @@ static int __rtl8152_set_mac_address(struct net_device *netdev, void *p,
>  	mutex_lock(&tp->control);
>  
>  	eth_hw_addr_set(netdev, addr->sa_data);
> +	memcpy(&tp->saved_addr, addr, sizeof(tp->saved_addr));

Do you need a copy in tp? I would expect the MAC address stored in
netdev by eth_hw_addr_set() is still there after the resume?

       Andrew

  reply	other threads:[~2022-07-27 19:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-27 11:39 handling MAC set by user space in reset_resume() of r8152 Oliver Neukum
2022-07-27 18:34 ` Andrew Lunn [this message]
2022-07-28  8:40   ` Hayes Wang
2022-07-28  8:54     ` Oliver Neukum
2022-07-28  9:41       ` Hayes Wang

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=YuGFOU7oKlAGZjTa@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=hayeswang@realtek.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=oneukum@suse.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).