All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@vyatta.com>
To: Jiri Pirko <jiri@resnulli.us>
Cc: netdev@vger.kernel.org, davem@davemloft.net, edumazet@google.com,
	bhutchings@solarflare.com, sassmann@redhat.com, kaber@trash.net,
	richard@nod.at
Subject: Re: [patch net-next 1/7] rtnl: use dev_set_mac_address() instead of plain ndo_
Date: Tue, 1 Jan 2013 10:33:06 -0800	[thread overview]
Message-ID: <20130101103306.78e26e89@nehalam.linuxnetplumber.net> (raw)
In-Reply-To: <1357047019-1037-2-git-send-email-jiri@resnulli.us>

On Tue,  1 Jan 2013 14:30:13 +0100
Jiri Pirko <jiri@resnulli.us> wrote:

> Benefit from existence of dev_set_mac_address() and remove duplicate
> code.
> 
> Signed-off-by: Jiri Pirko <jiri@resnulli.us>
> ---
>  net/core/rtnetlink.c | 20 ++------------------
>  1 file changed, 2 insertions(+), 18 deletions(-)
> 
> diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
> index 2ef7a56..78d05a9 100644
> --- a/net/core/rtnetlink.c
> +++ b/net/core/rtnetlink.c
> @@ -1310,7 +1310,6 @@ static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm,
>  		      struct nlattr **tb, char *ifname, int modified)
>  {
>  	const struct net_device_ops *ops = dev->netdev_ops;
> -	int send_addr_notify = 0;
>  	int err;
>  
>  	if (tb[IFLA_NET_NS_PID] || tb[IFLA_NET_NS_FD]) {
> @@ -1363,16 +1362,6 @@ static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm,
>  		struct sockaddr *sa;
>  		int len;
>  
> -		if (!ops->ndo_set_mac_address) {
> -			err = -EOPNOTSUPP;
> -			goto errout;
> -		}
> -
> -		if (!netif_device_present(dev)) {
> -			err = -ENODEV;
> -			goto errout;
> -		}
> -
>  		len = sizeof(sa_family_t) + dev->addr_len;
>  		sa = kmalloc(len, GFP_KERNEL);
>  		if (!sa) {
> @@ -1382,13 +1371,11 @@ static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm,
>  		sa->sa_family = dev->type;
>  		memcpy(sa->sa_data, nla_data(tb[IFLA_ADDRESS]),
>  		       dev->addr_len);
> -		err = ops->ndo_set_mac_address(dev, sa);
> +		err = dev_set_mac_address(dev, sa);
>  		kfree(sa);
>  		if (err)
>  			goto errout;
> -		send_addr_notify = 1;
>  		modified = 1;
> -		add_device_randomness(dev->dev_addr, dev->addr_len);
>  	}
>  
>  	if (tb[IFLA_MTU]) {
> @@ -1425,7 +1412,7 @@ static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm,
>  
>  	if (tb[IFLA_BROADCAST]) {
>  		nla_memcpy(dev->broadcast, tb[IFLA_BROADCAST], dev->addr_len);
> -		send_addr_notify = 1;
> +		call_netdevice_notifiers(NETDEV_CHANGEADDR, dev);
>  	}
>  
>  	if (ifm->ifi_flags || ifm->ifi_change) {
> @@ -1546,9 +1533,6 @@ errout:
>  		net_warn_ratelimited("A link change request failed with some changes committed already. Interface %s may have been left with an inconsistent configuration, please check.\n",
>  				     dev->name);
>  
> -	if (send_addr_notify)
> -		call_netdevice_notifiers(NETDEV_CHANGEADDR, dev);
> -
>  	return err;
>  }
>  

This will cause call_netdevice_notifiers to be called twice if both IFLA_BROADCAST and IFLA_ADDRESS
are changed in one request. Not sure if that would break anything?

  reply	other threads:[~2013-01-01 18:34 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-01 13:30 [patch net-next 0/7] fix dev->addr_assign_type setting and related code Jiri Pirko
2013-01-01 13:30 ` [patch net-next 1/7] rtnl: use dev_set_mac_address() instead of plain ndo_ Jiri Pirko
2013-01-01 18:33   ` Stephen Hemminger [this message]
2013-01-01 19:00     ` Jiri Pirko
2013-01-01 13:30 ` [patch net-next 2/7] net: call add_device_randomness() only after successful mac change Jiri Pirko
2013-01-01 13:30 ` [patch net-next 3/7] net: set dev->addr_assign_type correctly Jiri Pirko
2013-01-01 13:30 ` [patch net-next 4/7] net: add address assign type "SET" Jiri Pirko
2013-01-01 13:30 ` [patch net-next 5/7] net: remove unnecessary NET_ADDR_RANDOM "bitclean" Jiri Pirko
2013-01-10  2:55   ` Antonio Quartulli
2013-01-01 13:30 ` [patch net-next 6/7] um: net: use eth_hw_addr_random() to generate random mac Jiri Pirko
2013-01-01 13:30 ` [patch net-next 7/7] ll_temac: fix mac address setting Jiri Pirko
2013-01-04  6:43 ` [patch net-next 0/7] fix dev->addr_assign_type setting and related code David Miller

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=20130101103306.78e26e89@nehalam.linuxnetplumber.net \
    --to=shemminger@vyatta.com \
    --cc=bhutchings@solarflare.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jiri@resnulli.us \
    --cc=kaber@trash.net \
    --cc=netdev@vger.kernel.org \
    --cc=richard@nod.at \
    --cc=sassmann@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 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.