diff mbox

[v3] net, wireless: overwrite default_ethtool_ops

Message ID 20130111091909.GA2347@redhat.com
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Stanislaw Gruszka Jan. 11, 2013, 9:19 a.m. UTC
Since:

commit 2c60db037034d27f8c636403355d52872da92f81
Author: Eric Dumazet <edumazet@google.com>
Date:   Sun Sep 16 09:17:26 2012 +0000

    net: provide a default dev->ethtool_ops

wireless core does not correctly assign ethtool_ops.

After alloc_netdev*() call, some cfg80211 drivers provide they own
ethtool_ops, but some do not. For them, wireless core provide generic
cfg80211_ethtool_ops, which is assigned in NETDEV_REGISTER notify call:

        if (!dev->ethtool_ops)
                dev->ethtool_ops = &cfg80211_ethtool_ops;

But after Eric's commit, dev->ethtool_ops is no longer NULL (on cfg80211
drivers without custom ethtool_ops), but points to &default_ethtool_ops.

In order to fix the problem, provide function which will overwrite
default_ethtool_ops and use it by wireless core.

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
---
v1 -> v2: change order of default_ethtool_ops initialization to avoid
the problem. Change the subject accordingly.

v2 -> v3: provide function to overwrite default_ethtool_ops, describe
problem a bit more detailed in the changelog

 include/linux/netdevice.h |    3 +++
 net/core/dev.c            |    8 ++++++++
 net/wireless/core.c       |    3 +--
 3 files changed, 12 insertions(+), 2 deletions(-)

Comments

Johannes Berg Jan. 11, 2013, 10:51 a.m. UTC | #1
On Fri, 2013-01-11 at 10:19 +0100, Stanislaw Gruszka wrote:
> Since:
> 
> commit 2c60db037034d27f8c636403355d52872da92f81
> Author: Eric Dumazet <edumazet@google.com>
> Date:   Sun Sep 16 09:17:26 2012 +0000
> 
>     net: provide a default dev->ethtool_ops
> 
> wireless core does not correctly assign ethtool_ops.
> 
> After alloc_netdev*() call, some cfg80211 drivers provide they own
> ethtool_ops, but some do not. For them, wireless core provide generic
> cfg80211_ethtool_ops, which is assigned in NETDEV_REGISTER notify call:
> 
>         if (!dev->ethtool_ops)
>                 dev->ethtool_ops = &cfg80211_ethtool_ops;
> 
> But after Eric's commit, dev->ethtool_ops is no longer NULL (on cfg80211
> drivers without custom ethtool_ops), but points to &default_ethtool_ops.
> 
> In order to fix the problem, provide function which will overwrite
> default_ethtool_ops and use it by wireless core.
> 
> Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>

Acked-by: Johannes Berg <johannes@sipsolutions.net>

This will work nicely, clearly I didn't understand davem's suggestion :)

johannes

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Ben Hutchings Jan. 11, 2013, 8 p.m. UTC | #2
On Fri, 2013-01-11 at 10:19 +0100, Stanislaw Gruszka wrote:
> Since:
> 
> commit 2c60db037034d27f8c636403355d52872da92f81
> Author: Eric Dumazet <edumazet@google.com>
> Date:   Sun Sep 16 09:17:26 2012 +0000
> 
>     net: provide a default dev->ethtool_ops
> 
> wireless core does not correctly assign ethtool_ops.
> 
> After alloc_netdev*() call, some cfg80211 drivers provide they own
> ethtool_ops, but some do not. For them, wireless core provide generic
> cfg80211_ethtool_ops, which is assigned in NETDEV_REGISTER notify call:
> 
>         if (!dev->ethtool_ops)
>                 dev->ethtool_ops = &cfg80211_ethtool_ops;
> 
> But after Eric's commit, dev->ethtool_ops is no longer NULL (on cfg80211
> drivers without custom ethtool_ops), but points to &default_ethtool_ops.
> 
> In order to fix the problem, provide function which will overwrite
> default_ethtool_ops and use it by wireless core.
> 
> Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
[...]

Acked-by: Ben Hutchings <bhutchings@solarflare.com>
David Miller Jan. 11, 2013, 11:59 p.m. UTC | #3
From: Ben Hutchings <bhutchings@solarflare.com>
Date: Fri, 11 Jan 2013 20:00:32 +0000

> On Fri, 2013-01-11 at 10:19 +0100, Stanislaw Gruszka wrote:
>> Since:
>> 
>> commit 2c60db037034d27f8c636403355d52872da92f81
>> Author: Eric Dumazet <edumazet@google.com>
>> Date:   Sun Sep 16 09:17:26 2012 +0000
>> 
>>     net: provide a default dev->ethtool_ops
>> 
>> wireless core does not correctly assign ethtool_ops.
>> 
>> After alloc_netdev*() call, some cfg80211 drivers provide they own
>> ethtool_ops, but some do not. For them, wireless core provide generic
>> cfg80211_ethtool_ops, which is assigned in NETDEV_REGISTER notify call:
>> 
>>         if (!dev->ethtool_ops)
>>                 dev->ethtool_ops = &cfg80211_ethtool_ops;
>> 
>> But after Eric's commit, dev->ethtool_ops is no longer NULL (on cfg80211
>> drivers without custom ethtool_ops), but points to &default_ethtool_ops.
>> 
>> In order to fix the problem, provide function which will overwrite
>> default_ethtool_ops and use it by wireless core.
>> 
>> Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
> [...]
> 
> Acked-by: Ben Hutchings <bhutchings@solarflare.com>

Applied.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Luis R. Rodriguez Jan. 21, 2013, 8:52 p.m. UTC | #4
On Fri, Jan 11, 2013 at 3:59 PM, David Miller <davem@davemloft.net> wrote:
> From: Ben Hutchings <bhutchings@solarflare.com>
> Date: Fri, 11 Jan 2013 20:00:32 +0000
>
>> On Fri, 2013-01-11 at 10:19 +0100, Stanislaw Gruszka wrote:
>>> Since:
>>>
>>> commit 2c60db037034d27f8c636403355d52872da92f81
>>> Author: Eric Dumazet <edumazet@google.com>
>>> Date:   Sun Sep 16 09:17:26 2012 +0000
>>>
>>>     net: provide a default dev->ethtool_ops
>>>
>>> wireless core does not correctly assign ethtool_ops.
>>>
>>> After alloc_netdev*() call, some cfg80211 drivers provide they own
>>> ethtool_ops, but some do not. For them, wireless core provide generic
>>> cfg80211_ethtool_ops, which is assigned in NETDEV_REGISTER notify call:
>>>
>>>         if (!dev->ethtool_ops)
>>>                 dev->ethtool_ops = &cfg80211_ethtool_ops;
>>>
>>> But after Eric's commit, dev->ethtool_ops is no longer NULL (on cfg80211
>>> drivers without custom ethtool_ops), but points to &default_ethtool_ops.
>>>
>>> In order to fix the problem, provide function which will overwrite
>>> default_ethtool_ops and use it by wireless core.
>>>
>>> Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
>> [...]
>>
>> Acked-by: Ben Hutchings <bhutchings@solarflare.com>
>
> Applied.

Stanislaw, I see Eric's patch went in on v3.7-rc1 as such I suspect
this needs to be submitted as a stable fix for v3.7.5. Its already on
v3.8-rc4.

mcgrof@frijol ~/linux-stable (git::linux-3.7.y)$ git describe
--contains 2c60db037034d27f8c636403355d52872da92f81
v3.7-rc1~145^2~142

  Luis
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller Jan. 21, 2013, 9:04 p.m. UTC | #5
It's queued up for -stable already as is clearly seen at:

http://patchwork.ozlabs.org/user/bundle/2566/?state=*
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Stanislaw Gruszka Jan. 22, 2013, 10:56 a.m. UTC | #6
On Mon, Jan 21, 2013 at 04:04:04PM -0500, David Miller wrote:
> 
> It's queued up for -stable already as is clearly seen at:
> 
> http://patchwork.ozlabs.org/user/bundle/2566/?state=*

Hmm, this link does not work for me (need user/password).

Anyway, I marked cc -stable in v2 patch, but forgot that in v3.
Committed patch does not include the mark, so I'll post patch
to stable just in case.

Thanks
Stanislaw 
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller Jan. 22, 2013, 7:06 p.m. UTC | #7
From: Stanislaw Gruszka <sgruszka@redhat.com>
Date: Tue, 22 Jan 2013 11:56:19 +0100

> On Mon, Jan 21, 2013 at 04:04:04PM -0500, David Miller wrote:
>> 
>> It's queued up for -stable already as is clearly seen at:
>> 
>> http://patchwork.ozlabs.org/user/bundle/2566/?state=*
> 
> Hmm, this link does not work for me (need user/password).

You just need to make a patchwork login, it's visible to any
registered user.

> Anyway, I marked cc -stable in v2 patch, but forgot that in v3.
> Committed patch does not include the mark, so I'll post patch
> to stable just in case.

Do NOT DO THIS, I do the submissions myself, by hand.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index c599e47..9ef07d0 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -60,6 +60,9 @@  struct wireless_dev;
 #define SET_ETHTOOL_OPS(netdev,ops) \
 	( (netdev)->ethtool_ops = (ops) )
 
+extern void netdev_set_default_ethtool_ops(struct net_device *dev,
+					   const struct ethtool_ops *ops);
+
 /* hardware address assignment types */
 #define NET_ADDR_PERM		0	/* address is permanent (default) */
 #define NET_ADDR_RANDOM		1	/* address is generated randomly */
diff --git a/net/core/dev.c b/net/core/dev.c
index 515473e..f64e439 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -6121,6 +6121,14 @@  struct netdev_queue *dev_ingress_queue_create(struct net_device *dev)
 
 static const struct ethtool_ops default_ethtool_ops;
 
+void netdev_set_default_ethtool_ops(struct net_device *dev,
+				    const struct ethtool_ops *ops)
+{
+	if (dev->ethtool_ops == &default_ethtool_ops)
+		dev->ethtool_ops = ops;
+}
+EXPORT_SYMBOL_GPL(netdev_set_default_ethtool_ops);
+
 /**
  *	alloc_netdev_mqs - allocate network device
  *	@sizeof_priv:	size of private data to allocate space for
diff --git a/net/wireless/core.c b/net/wireless/core.c
index 747dd93..7cbd3bf 100644
--- a/net/wireless/core.c
+++ b/net/wireless/core.c
@@ -858,8 +858,7 @@  static int cfg80211_netdev_notifier_call(struct notifier_block *nb,
 		/* allow mac80211 to determine the timeout */
 		wdev->ps_timeout = -1;
 
-		if (!dev->ethtool_ops)
-			dev->ethtool_ops = &cfg80211_ethtool_ops;
+		netdev_set_default_ethtool_ops(dev, &cfg80211_ethtool_ops);
 
 		if ((wdev->iftype == NL80211_IFTYPE_STATION ||
 		     wdev->iftype == NL80211_IFTYPE_P2P_CLIENT ||