linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] mac80211: Supporting of IFLA_INFO_KIND rtnl attribute
@ 2014-12-07 10:20 Vadim Kochan
  2014-12-08  7:27 ` Johannes Berg
  0 siblings, 1 reply; 7+ messages in thread
From: Vadim Kochan @ 2014-12-07 10:20 UTC (permalink / raw)
  To: linville, johannes, linux-wireless; +Cc: Vadim Kochan

It allows to identify the wlan kind of device for
the user application, e.g.:

    # ip -d link

    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 promiscuity 0
    2: enp0s25: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT group default qlen 1000
        link/ether XX:XX:XX:XX:XX:XX brd ff:ff:ff:ff:ff:ff promiscuity 0
    3: wlp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
        link/ether XX:XX:XX:XX:XX:XX brd ff:ff:ff:ff:ff:ff promiscuity 0
        wlan

Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
---
 net/mac80211/iface.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index 653f5eb..e48372b 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -18,6 +18,7 @@
 #include <linux/rtnetlink.h>
 #include <net/mac80211.h>
 #include <net/ieee80211_radiotap.h>
+#include <net/rtnetlink.h>
 #include "ieee80211_i.h"
 #include "sta_info.h"
 #include "debugfs_netdev.h"
@@ -1624,6 +1625,10 @@ static void ieee80211_assign_perm_addr(struct ieee80211_local *local,
 	mutex_unlock(&local->iflist_mtx);
 }
 
+static struct rtnl_link_ops wireless_link_ops __read_mostly = {
+	.kind = "wlan",
+};
+
 int ieee80211_if_add(struct ieee80211_local *local, const char *name,
 		     struct wireless_dev **new_wdev, enum nl80211_iftype type,
 		     struct vif_params *params)
@@ -1684,6 +1689,8 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name,
 		memcpy(sdata->vif.addr, ndev->dev_addr, ETH_ALEN);
 		memcpy(sdata->name, ndev->name, IFNAMSIZ);
 
+		ndev->rtnl_link_ops = &wireless_link_ops;
+
 		sdata->dev = ndev;
 	}
 
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] mac80211: Supporting of IFLA_INFO_KIND rtnl attribute
  2014-12-07 10:20 [PATCH v2] mac80211: Supporting of IFLA_INFO_KIND rtnl attribute Vadim Kochan
@ 2014-12-08  7:27 ` Johannes Berg
  2014-12-08 10:07   ` Vadim Kochan
  0 siblings, 1 reply; 7+ messages in thread
From: Johannes Berg @ 2014-12-08  7:27 UTC (permalink / raw)
  To: Vadim Kochan; +Cc: linville, linux-wireless

On Sun, 2014-12-07 at 12:20 +0200, Vadim Kochan wrote:

> +++ b/net/mac80211/iface.c

> @@ -1624,6 +1625,10 @@ static void ieee80211_assign_perm_addr(struct ieee80211_local *local,
>  	mutex_unlock(&local->iflist_mtx);
>  }
>  
> +static struct rtnl_link_ops wireless_link_ops __read_mostly = {
> +	.kind = "wlan",
> +};

I think it would make sense to set it - if not already set - in the
netdev notifier in cfg80211.

johannes


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] mac80211: Supporting of IFLA_INFO_KIND rtnl attribute
  2014-12-08  7:27 ` Johannes Berg
@ 2014-12-08 10:07   ` Vadim Kochan
  2014-12-08 10:17     ` Johannes Berg
  0 siblings, 1 reply; 7+ messages in thread
From: Vadim Kochan @ 2014-12-08 10:07 UTC (permalink / raw)
  To: Johannes Berg; +Cc: John Linville, linux-wireless

You meant here ?

net/wireless/core.c : static int cfg80211_netdev_notifier_call(struct
notifier_block *nb,
                                          unsigned long state, void *ptr)
{

    ...
    switch (state) {
             case NETDEV_POST_INIT:
                     SET_NETDEV_DEVTYPE(dev, &wiphy_type);
                     break;
             case NETDEV_REGISTER:
                     ...
                     dev->rtnl_link_ops = &wireless_link_ops;
                     ...
    }
    ...
}

Regards,

On Mon, Dec 8, 2014 at 9:27 AM, Johannes Berg <johannes@sipsolutions.net> wrote:
> On Sun, 2014-12-07 at 12:20 +0200, Vadim Kochan wrote:
>
>> +++ b/net/mac80211/iface.c
>
>> @@ -1624,6 +1625,10 @@ static void ieee80211_assign_perm_addr(struct ieee80211_local *local,
>>       mutex_unlock(&local->iflist_mtx);
>>  }
>>
>> +static struct rtnl_link_ops wireless_link_ops __read_mostly = {
>> +     .kind = "wlan",
>> +};
>
> I think it would make sense to set it - if not already set - in the
> netdev notifier in cfg80211.
>
> johannes
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] mac80211: Supporting of IFLA_INFO_KIND rtnl attribute
  2014-12-08 10:07   ` Vadim Kochan
@ 2014-12-08 10:17     ` Johannes Berg
  2014-12-08 21:48       ` vadim4j
  0 siblings, 1 reply; 7+ messages in thread
From: Johannes Berg @ 2014-12-08 10:17 UTC (permalink / raw)
  To: Vadim Kochan; +Cc: John Linville, linux-wireless

On Mon, 2014-12-08 at 12:07 +0200, Vadim Kochan wrote:
> You meant here ?
> 
> net/wireless/core.c : static int cfg80211_netdev_notifier_call(struct
> notifier_block *nb,
>                                           unsigned long state, void *ptr)
> {
> 
>     ...
>     switch (state) {
>              case NETDEV_POST_INIT:
>                      SET_NETDEV_DEVTYPE(dev, &wiphy_type);
>                      break;
>              case NETDEV_REGISTER:
>                      ...
>                      dev->rtnl_link_ops = &wireless_link_ops;
>                      ...
>     }

Well it seems it could go more with the SET_NETDEV_TYPE()?

johannes


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] mac80211: Supporting of IFLA_INFO_KIND rtnl attribute
  2014-12-08 10:17     ` Johannes Berg
@ 2014-12-08 21:48       ` vadim4j
  2014-12-09  8:24         ` Johannes Berg
  0 siblings, 1 reply; 7+ messages in thread
From: vadim4j @ 2014-12-08 21:48 UTC (permalink / raw)
  To: Johannes Berg; +Cc: Vadim Kochan, John Linville, linux-wireless

On Mon, Dec 08, 2014 at 11:17:03AM +0100, Johannes Berg wrote:
> On Mon, 2014-12-08 at 12:07 +0200, Vadim Kochan wrote:
> > You meant here ?
> > 
> > net/wireless/core.c : static int cfg80211_netdev_notifier_call(struct
> > notifier_block *nb,
> >                                           unsigned long state, void *ptr)
> > {
> > 
> >     ...
> >     switch (state) {
> >              case NETDEV_POST_INIT:
> >                      SET_NETDEV_DEVTYPE(dev, &wiphy_type);
> >                      break;
> >              case NETDEV_REGISTER:
> >                      ...
> >                      dev->rtnl_link_ops = &wireless_link_ops;
> >                      ...
> >     }
> 
> Well it seems it could go more with the SET_NETDEV_TYPE()?
> 
> johannes
> 

What I worry about is this peace of code in net/core/dev.c : 

    int register_netdevice(struct net_device *dev)
    {
            ...

            if (!dev->rtnl_link_ops ||
                dev->rtnl_link_state == RTNL_LINK_INITIALIZED)
                    rtmsg_ifinfo(RTM_NEWLINK, dev, ~0U, GFP_KERNEL);
            ...
    }

which will skip sending RTM_NEWLINK message if it has rtnl_link_ops ...
Actually meanwhile I dont see any problems as my wifi works OK with
these changes, but I want to be sure in 100% that it does not break
anything ...

So I am under investigating this ... Maybe you can suggest ?

Thanks,

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] mac80211: Supporting of IFLA_INFO_KIND rtnl attribute
  2014-12-08 21:48       ` vadim4j
@ 2014-12-09  8:24         ` Johannes Berg
  2014-12-09 22:08           ` vadim4j
  0 siblings, 1 reply; 7+ messages in thread
From: Johannes Berg @ 2014-12-09  8:24 UTC (permalink / raw)
  To: vadim4j; +Cc: John Linville, linux-wireless

On Mon, 2014-12-08 at 23:48 +0200, vadim4j@gmail.com wrote:

> What I worry about is this peace of code in net/core/dev.c : 
> 
>     int register_netdevice(struct net_device *dev)
>     {
>             ...
> 
>             if (!dev->rtnl_link_ops ||
>                 dev->rtnl_link_state == RTNL_LINK_INITIALIZED)
>                     rtmsg_ifinfo(RTM_NEWLINK, dev, ~0U, GFP_KERNEL);
>             ...
>     }

rtnl_link_state should be RTNL_LINK_INITIALIZED though, unless somebody
set something else.

johannes


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] mac80211: Supporting of IFLA_INFO_KIND rtnl attribute
  2014-12-09  8:24         ` Johannes Berg
@ 2014-12-09 22:08           ` vadim4j
  0 siblings, 0 replies; 7+ messages in thread
From: vadim4j @ 2014-12-09 22:08 UTC (permalink / raw)
  To: Johannes Berg; +Cc: vadim4j, John Linville, linux-wireless

On Tue, Dec 09, 2014 at 09:24:18AM +0100, Johannes Berg wrote:
> On Mon, 2014-12-08 at 23:48 +0200, vadim4j@gmail.com wrote:
> 
> > What I worry about is this peace of code in net/core/dev.c : 
> > 
> >     int register_netdevice(struct net_device *dev)
> >     {
> >             ...
> > 
> >             if (!dev->rtnl_link_ops ||
> >                 dev->rtnl_link_state == RTNL_LINK_INITIALIZED)
> >                     rtmsg_ifinfo(RTM_NEWLINK, dev, ~0U, GFP_KERNEL);
> >             ...
> >     }
> 
> rtnl_link_state should be RTNL_LINK_INITIALIZED though, unless somebody
> set something else.
> 
> johannes
> 

OK I tested & checked by code that RTNL_LINK_INITIALIZED is set, and
RTM_NEWLINK message will be sent as it was before.

I will resend the patch.

Thanks,

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-12-09 22:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-07 10:20 [PATCH v2] mac80211: Supporting of IFLA_INFO_KIND rtnl attribute Vadim Kochan
2014-12-08  7:27 ` Johannes Berg
2014-12-08 10:07   ` Vadim Kochan
2014-12-08 10:17     ` Johannes Berg
2014-12-08 21:48       ` vadim4j
2014-12-09  8:24         ` Johannes Berg
2014-12-09 22:08           ` vadim4j

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).