linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iw:  Use ifname if available, print new/del/stop events.
@ 2015-06-10 22:17 greearb
  2015-06-17  9:14 ` Johannes Berg
  0 siblings, 1 reply; 4+ messages in thread
From: greearb @ 2015-06-10 22:17 UTC (permalink / raw)
  To: linux-wireless; +Cc: johannes, Ben Greear

From: Ben Greear <greearb@candelatech.com>

If the kernel sends the IFNAME in the netlink message, then
use it to save the call to map ifindex to name (and
potentially fix races, especially when kernel is
busy deleting an interface.

Signed-off-by: Ben Greear <greearb@candelatech.com>
---
 event.c | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/event.c b/event.c
index 929854b..b87a076 100644
--- a/event.c
+++ b/event.c
@@ -317,15 +317,22 @@ static int print_event(struct nl_msg *msg, void *arg)
 	nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
 		  genlmsg_attrlen(gnlh, 0), NULL);
 
-	if (tb[NL80211_ATTR_IFINDEX] && tb[NL80211_ATTR_WIPHY]) {
+	ifname[0] = 0;
+	if (tb[NL80211_ATTR_IFNAME]) {
+		memset(ifname, 0, sizeof(ifname));
+		strncpy(ifname, nla_data(tb[NL80211_ATTR_IFNAME]), IFNAMSIZ);
+	}
+	else if (tb[NL80211_ATTR_IFINDEX]) {
 		if_indextoname(nla_get_u32(tb[NL80211_ATTR_IFINDEX]), ifname);
+	}
+
+	if (ifname[0] && tb[NL80211_ATTR_WIPHY]) {
 		printf("%s (phy #%d): ", ifname, nla_get_u32(tb[NL80211_ATTR_WIPHY]));
 	} else if (tb[NL80211_ATTR_WDEV] && tb[NL80211_ATTR_WIPHY]) {
 		printf("wdev 0x%llx (phy #%d): ",
 			(unsigned long long)nla_get_u64(tb[NL80211_ATTR_WDEV]),
 			nla_get_u32(tb[NL80211_ATTR_WIPHY]));
-	} else if (tb[NL80211_ATTR_IFINDEX]) {
-		if_indextoname(nla_get_u32(tb[NL80211_ATTR_IFINDEX]), ifname);
+	} else if (ifname[0]) {
 		printf("%s: ", ifname);
 	} else if (tb[NL80211_ATTR_WDEV]) {
 		printf("wdev 0x%llx: ", (unsigned long long)nla_get_u64(tb[NL80211_ATTR_WDEV]));
@@ -599,6 +606,15 @@ static int print_event(struct nl_msg *msg, void *arg)
 		}
 		printf("\n");
 		break;
+	case NL80211_CMD_STOP_AP:
+		printf("stop AP\n");
+		break;
+	case NL80211_CMD_NEW_INTERFACE:
+		printf("new interface\n");
+		break;
+	case NL80211_CMD_DEL_INTERFACE:
+		printf("delete interface\n");
+		break;
 	default:
 		printf("unknown event %d (%s)\n",
 		       gnlh->cmd, command_name(gnlh->cmd));
-- 
1.9.3


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

* Re: [PATCH] iw:  Use ifname if available, print new/del/stop events.
  2015-06-10 22:17 [PATCH] iw: Use ifname if available, print new/del/stop events greearb
@ 2015-06-17  9:14 ` Johannes Berg
  2015-06-17 13:45   ` Ben Greear
  0 siblings, 1 reply; 4+ messages in thread
From: Johannes Berg @ 2015-06-17  9:14 UTC (permalink / raw)
  To: greearb; +Cc: linux-wireless

On Wed, 2015-06-10 at 18:17 -0400, greearb@candelatech.com wrote:
> From: Ben Greear <greearb@candelatech.com>
> 
> If the kernel sends the IFNAME in the netlink message, then
> use it to save the call to map ifindex to name (and
> potentially fix races, especially when kernel is
> busy deleting an interface.

Please split the "print new/del/stop events" part into a separate patch
- I can apply that now.

johannes


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

* Re: [PATCH] iw:  Use ifname if available, print new/del/stop events.
  2015-06-17  9:14 ` Johannes Berg
@ 2015-06-17 13:45   ` Ben Greear
  2015-07-17  8:55     ` Johannes Berg
  0 siblings, 1 reply; 4+ messages in thread
From: Ben Greear @ 2015-06-17 13:45 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless



On 06/17/2015 02:14 AM, Johannes Berg wrote:
> On Wed, 2015-06-10 at 18:17 -0400, greearb@candelatech.com wrote:
>> From: Ben Greear <greearb@candelatech.com>
>>
>> If the kernel sends the IFNAME in the netlink message, then
>> use it to save the call to map ifindex to name (and
>> potentially fix races, especially when kernel is
>> busy deleting an interface.
>
> Please split the "print new/del/stop events" part into a separate patch
> - I can apply that now.

Some existing events (interface-delete, I think) already have the ifname, by the way..so the iw patch
is useful without any kernel changes.

Thanks,
Ben

-- 
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc  http://www.candelatech.com

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

* Re: [PATCH] iw:  Use ifname if available, print new/del/stop events.
  2015-06-17 13:45   ` Ben Greear
@ 2015-07-17  8:55     ` Johannes Berg
  0 siblings, 0 replies; 4+ messages in thread
From: Johannes Berg @ 2015-07-17  8:55 UTC (permalink / raw)
  To: Ben Greear; +Cc: linux-wireless

On Wed, 2015-06-17 at 06:45 -0700, Ben Greear wrote:
> 
> On 06/17/2015 02:14 AM, Johannes Berg wrote:
> > On Wed, 2015-06-10 at 18:17 -0400, greearb@candelatech.com wrote:
> > > From: Ben Greear <greearb@candelatech.com>
> > > 
> > > If the kernel sends the IFNAME in the netlink message, then
> > > use it to save the call to map ifindex to name (and
> > > potentially fix races, especially when kernel is
> > > busy deleting an interface.
> > 
> > Please split the "print new/del/stop events" part into a separate 
> > patch
> > - I can apply that now.
> 
> Some existing events (interface-delete, I think) already have the 
> ifname, by the way..so the iw patch
> is useful without any kernel changes.
> 

Fair enough. Still, splitting the patch would make sense I think.

johannes

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

end of thread, other threads:[~2015-07-17  8:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-10 22:17 [PATCH] iw: Use ifname if available, print new/del/stop events greearb
2015-06-17  9:14 ` Johannes Berg
2015-06-17 13:45   ` Ben Greear
2015-07-17  8:55     ` Johannes Berg

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