All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cfg80211: allow vendor commands to be sent to nan interface
@ 2016-10-19  4:47 Luca Coelho
  2016-10-20 12:40 ` Arend Van Spriel
  0 siblings, 1 reply; 6+ messages in thread
From: Luca Coelho @ 2016-10-19  4:47 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, Andrei Otcheretianski, Luca Coelho

From: Andrei Otcheretianski <andrei.otcheretianski@intel.com>

Allow vendor commands that require WIPHY_VENDOR_CMD_NEED_RUNNING flag, to
be sent to NAN interface.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
---
 net/wireless/nl80211.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index e48b9c3..fcf5b4f 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -11258,7 +11258,8 @@ static int nl80211_vendor_cmd(struct sk_buff *skb, struct genl_info *info)
 				if (wdev->netdev &&
 				    !netif_running(wdev->netdev))
 					return -ENETDOWN;
-				if (!wdev->netdev && !wdev->p2p_started)
+				if (!wdev->netdev && !wdev->p2p_started &&
+				    !wdev->nan_started)
 					return -ENETDOWN;
 			}
 
-- 
2.9.3

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

* Re: [PATCH] cfg80211: allow vendor commands to be sent to nan interface
  2016-10-19  4:47 [PATCH] cfg80211: allow vendor commands to be sent to nan interface Luca Coelho
@ 2016-10-20 12:40 ` Arend Van Spriel
  2016-10-20 12:42   ` Johannes Berg
  0 siblings, 1 reply; 6+ messages in thread
From: Arend Van Spriel @ 2016-10-20 12:40 UTC (permalink / raw)
  To: Luca Coelho, johannes; +Cc: linux-wireless, Andrei Otcheretianski, Luca Coelho

On 19-10-2016 6:47, Luca Coelho wrote:
> From: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
> 
> Allow vendor commands that require WIPHY_VENDOR_CMD_NEED_RUNNING flag, to
> be sent to NAN interface.
> 
> Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
> Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
> ---
>  net/wireless/nl80211.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
> index e48b9c3..fcf5b4f 100644
> --- a/net/wireless/nl80211.c
> +++ b/net/wireless/nl80211.c
> @@ -11258,7 +11258,8 @@ static int nl80211_vendor_cmd(struct sk_buff *skb, struct genl_info *info)
>  				if (wdev->netdev &&
>  				    !netif_running(wdev->netdev))
>  					return -ENETDOWN;
> -				if (!wdev->netdev && !wdev->p2p_started)
> +				if (!wdev->netdev && !wdev->p2p_started &&
> +				    !wdev->nan_started)
>  					return -ENETDOWN;

Seeing this patch flying by, my itch became unbearable so I cooked up
the patch below. Please consider this an RFC and let me know your thoughts.

Regards,
Arend
---
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 2bbbcc3..0010e5a 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -3781,8 +3781,8 @@ static inline struct wiphy *wiphy_new(const struct
cfg80211_ops *ops,
  * @beacon_interval: beacon interval used on this device for transmitting
  *	beacons, 0 when not valid
  * @address: The address for this device, valid only if @netdev is %NULL
- * @p2p_started: true if this is a P2P Device that has been started
- * @nan_started: true if this is a NAN interface that has been started
+ * @is_running: true if this is a non-netdev device that has been
started, eg.
+ *	like the P2P Device.
  * @cac_started: true if DFS channel availability check has been started
  * @cac_start_time: timestamp (jiffies) when the dfs state was entered.
  * @cac_time_ms: CAC time in ms
@@ -3814,7 +3814,7 @@ struct wireless_dev {

 	struct mutex mtx;

-	bool use_4addr, p2p_started, nan_started;
+	bool use_4addr, is_running;

 	u8 address[ETH_ALEN] __aligned(sizeof(u16));

@@ -3871,6 +3871,13 @@ static inline u8 *wdev_address(struct
wireless_dev *wdev)
 	return wdev->address;
 }

+static inline bool wdev_is_running(struct wireless_dev *wdev)
+{
+	if (wdev->netdev)
+		return netif_running(wdev->netdev);
+	return wdev->is_running;
+}
+
 /**
  * wdev_priv - return wiphy priv from wireless_dev
  *
diff --git a/net/wireless/core.c b/net/wireless/core.c
index f433f15..088ba44 100644
--- a/net/wireless/core.c
+++ b/net/wireless/core.c
@@ -210,11 +210,11 @@ void cfg80211_stop_p2p_device(struct
cfg80211_registered_device *rdev,
 	if (WARN_ON(wdev->iftype != NL80211_IFTYPE_P2P_DEVICE))
 		return;

-	if (!wdev->p2p_started)
+	if (!wdev_is_running(wdev))
 		return;

 	rdev_stop_p2p_device(rdev, wdev);
-	wdev->p2p_started = false;
+	wdev->is_running = false;

 	rdev->opencount--;

@@ -233,11 +233,11 @@ void cfg80211_stop_nan(struct
cfg80211_registered_device *rdev,
 	if (WARN_ON(wdev->iftype != NL80211_IFTYPE_NAN))
 		return;

-	if (!wdev->nan_started)
+	if (!wdev_is_running(wdev))
 		return;

 	rdev_stop_nan(rdev, wdev);
-	wdev->nan_started = false;
+	wdev->is_running = false;

 	rdev->opencount--;
 }
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index fcf5b4f..e37801e 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -10528,7 +10528,7 @@ static int nl80211_start_p2p_device(struct
sk_buff *skb, struct genl_info *info)
 	if (wdev->iftype != NL80211_IFTYPE_P2P_DEVICE)
 		return -EOPNOTSUPP;

-	if (wdev->p2p_started)
+	if (wdev_is_running(wdev))
 		return 0;

 	if (rfkill_blocked(rdev->rfkill))
@@ -10538,7 +10538,7 @@ static int nl80211_start_p2p_device(struct
sk_buff *skb, struct genl_info *info)
 	if (err)
 		return err;

-	wdev->p2p_started = true;
+	wdev->is_running = true;
 	rdev->opencount++;

 	return 0;
@@ -10570,7 +10570,7 @@ static int nl80211_start_nan(struct sk_buff
*skb, struct genl_info *info)
 	if (wdev->iftype != NL80211_IFTYPE_NAN)
 		return -EOPNOTSUPP;

-	if (wdev->nan_started)
+	if (!wdev_is_running(wdev))
 		return -EEXIST;

 	if (rfkill_blocked(rdev->rfkill))
@@ -10593,7 +10593,7 @@ static int nl80211_start_nan(struct sk_buff
*skb, struct genl_info *info)
 	if (err)
 		return err;

-	wdev->nan_started = true;
+	wdev->is_running = true;
 	rdev->opencount++;

 	return 0;
@@ -10678,7 +10678,7 @@ static int nl80211_nan_add_func(struct sk_buff *skb,
 	if (wdev->iftype != NL80211_IFTYPE_NAN)
 		return -EOPNOTSUPP;

-	if (!wdev->nan_started)
+	if (!wdev_is_running(wdev))
 		return -ENOTCONN;

 	if (!info->attrs[NL80211_ATTR_NAN_FUNC])
@@ -10915,7 +10915,7 @@ static int nl80211_nan_del_func(struct sk_buff *skb,
 	if (wdev->iftype != NL80211_IFTYPE_NAN)
 		return -EOPNOTSUPP;

-	if (!wdev->nan_started)
+	if (!wdev_is_running(wdev))
 		return -ENOTCONN;

 	if (!info->attrs[NL80211_ATTR_COOKIE])
@@ -10943,7 +10943,7 @@ static int nl80211_nan_change_config(struct
sk_buff *skb,
 	if (wdev->iftype != NL80211_IFTYPE_NAN)
 		return -EOPNOTSUPP;

-	if (!wdev->nan_started)
+	if (!wdev_is_running(wdev))
 		return -ENOTCONN;

 	if (info->attrs[NL80211_ATTR_NAN_MASTER_PREF]) {
@@ -11255,11 +11255,7 @@ static int nl80211_vendor_cmd(struct sk_buff
*skb, struct genl_info *info)
 				return -EINVAL;

 			if (vcmd->flags & WIPHY_VENDOR_CMD_NEED_RUNNING) {
-				if (wdev->netdev &&
-				    !netif_running(wdev->netdev))
-					return -ENETDOWN;
-				if (!wdev->netdev && !wdev->p2p_started &&
-				    !wdev->nan_started)
+				if (!wdev_is_running(wdev))
 					return -ENETDOWN;
 			}

@@ -11422,10 +11418,7 @@ static int nl80211_vendor_cmd_dump(struct
sk_buff *skb,
 			return -EINVAL;

 		if (vcmd->flags & WIPHY_VENDOR_CMD_NEED_RUNNING) {
-			if (wdev->netdev &&
-			    !netif_running(wdev->netdev))
-				return -ENETDOWN;
-			if (!wdev->netdev && !wdev->p2p_started)
+			if (!wdev_is_running(wdev))
 				return -ENETDOWN;
 		}
 	}
@@ -11796,29 +11789,14 @@ static int nl80211_pre_doit(const struct
genl_ops *ops, struct sk_buff *skb,
 			info->user_ptr[1] = wdev;
 		}

-		if (dev) {
-			if (ops->internal_flags & NL80211_FLAG_CHECK_NETDEV_UP &&
-			    !netif_running(dev)) {
-				if (rtnl)
-					rtnl_unlock();
-				return -ENETDOWN;
-			}
-
-			dev_hold(dev);
-		} else if (ops->internal_flags & NL80211_FLAG_CHECK_NETDEV_UP) {
-			if (wdev->iftype == NL80211_IFTYPE_P2P_DEVICE &&
-			    !wdev->p2p_started) {
-				if (rtnl)
-					rtnl_unlock();
-				return -ENETDOWN;
-			}
-			if (wdev->iftype == NL80211_IFTYPE_NAN &&
-			    !wdev->nan_started) {
-				if (rtnl)
-					rtnl_unlock();
-				return -ENETDOWN;
-			}
+		if (ops->internal_flags & NL80211_FLAG_CHECK_NETDEV_UP &&
+		    !wdev_is_running(wdev)) {
+			if (rtnl)
+				rtnl_unlock();
+			return -ENETDOWN;
 		}
+		if (dev)
+			dev_hold(dev);

 		info->user_ptr[0] = rdev;
 	}

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

* Re: [PATCH] cfg80211: allow vendor commands to be sent to nan interface
  2016-10-20 12:40 ` Arend Van Spriel
@ 2016-10-20 12:42   ` Johannes Berg
  2016-10-20 12:44     ` Arend Van Spriel
  0 siblings, 1 reply; 6+ messages in thread
From: Johannes Berg @ 2016-10-20 12:42 UTC (permalink / raw)
  To: Arend Van Spriel, Luca Coelho
  Cc: linux-wireless, Andrei Otcheretianski, Luca Coelho


> Seeing this patch flying by, my itch became unbearable so I cooked up
> the patch below. Please consider this an RFC and let me know your
> thoughts.

Hah, I had this itch before, but didn't do anything about it yet :)

I like it though, care to submit it properly?

johannes

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

* Re: [PATCH] cfg80211: allow vendor commands to be sent to nan interface
  2016-10-20 12:42   ` Johannes Berg
@ 2016-10-20 12:44     ` Arend Van Spriel
  2016-10-20 12:45       ` Johannes Berg
  0 siblings, 1 reply; 6+ messages in thread
From: Arend Van Spriel @ 2016-10-20 12:44 UTC (permalink / raw)
  To: Johannes Berg, Luca Coelho
  Cc: linux-wireless, Andrei Otcheretianski, Luca Coelho



On 20-10-2016 14:42, Johannes Berg wrote:
> 
>> Seeing this patch flying by, my itch became unbearable so I cooked up
>> the patch below. Please consider this an RFC and let me know your
>> thoughts.
> 
> Hah, I had this itch before, but didn't do anything about it yet :)
> 
> I like it though, care to submit it properly?

Sure. On top of this patch or will you deal with those conflicts?

Regards,
Arend

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

* Re: [PATCH] cfg80211: allow vendor commands to be sent to nan interface
  2016-10-20 12:44     ` Arend Van Spriel
@ 2016-10-20 12:45       ` Johannes Berg
  2016-10-21  7:50         ` Arend Van Spriel
  0 siblings, 1 reply; 6+ messages in thread
From: Johannes Berg @ 2016-10-20 12:45 UTC (permalink / raw)
  To: Arend Van Spriel, Luca Coelho
  Cc: linux-wireless, Andrei Otcheretianski, Luca Coelho

On Thu, 2016-10-20 at 14:44 +0200, Arend Van Spriel wrote:
> 
> Sure. On top of this patch or will you deal with those conflicts?
> 

I already applied this, so on top please (i.e. just resend what you
just had, with a commit message?)

johannes

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

* Re: [PATCH] cfg80211: allow vendor commands to be sent to nan interface
  2016-10-20 12:45       ` Johannes Berg
@ 2016-10-21  7:50         ` Arend Van Spriel
  0 siblings, 0 replies; 6+ messages in thread
From: Arend Van Spriel @ 2016-10-21  7:50 UTC (permalink / raw)
  To: Johannes Berg, Luca Coelho
  Cc: linux-wireless, Andrei Otcheretianski, Luca Coelho



On 20-10-2016 14:45, Johannes Berg wrote:
> On Thu, 2016-10-20 at 14:44 +0200, Arend Van Spriel wrote:
>>  
>> Sure. On top of this patch or will you deal with those conflicts?
>>
> 
> I already applied this, so on top please (i.e. just resend what you
> just had, with a commit message?)

Yup. Did not check/realize/whatever. I send it out yesterday [1].

Regards,
Arend

[1] https://patchwork.kernel.org/patch/9387467/

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

end of thread, other threads:[~2016-10-21  7:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-19  4:47 [PATCH] cfg80211: allow vendor commands to be sent to nan interface Luca Coelho
2016-10-20 12:40 ` Arend Van Spriel
2016-10-20 12:42   ` Johannes Berg
2016-10-20 12:44     ` Arend Van Spriel
2016-10-20 12:45       ` Johannes Berg
2016-10-21  7:50         ` Arend Van Spriel

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.