diff mbox

[PATCHv2,1/2] cfg80211: add the new IBSS_STA event

Message ID 1355138182-11825-1-git-send-email-antonio@open-mesh.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Antonio Quartulli Dec. 10, 2012, 11:16 a.m. UTC
In IBSS mode it could be the case that a station being added
is not ready for starting higher level routines (e.g. key
exchange when IBSS/RSN is enabled). In particular, this can
happen when we are waiting for the AUTH response message.

This IBSS_STA event is triggered after the NEW_STA one and
only when the upper layer is allowed to assume that the new
peer is ready

Signed-off-by: Antonio Quartulli <antonio@open-mesh.com>
---

1/2 v2:
 * untouched
2/2 v2:
 * if userspace registered for auth frames, the new station is immediately
   authenticated and the new IBSS_STA event is triggered.

 include/net/cfg80211.h       |  8 ++++++++
 include/uapi/linux/nl80211.h |  2 ++
 net/wireless/mlme.c          |  9 +++++++++
 net/wireless/nl80211.c       | 33 +++++++++++++++++++++++++++++++++
 net/wireless/nl80211.h       |  3 +++
 5 files changed, 55 insertions(+)

Comments

Will Hawkins Dec. 11, 2012, 4:37 p.m. UTC | #1
Will this give IBSS something equivalent to the 802.11s
NL80211_CMD_NEW_PEER_CANDIDATE?

That's how I am reading it, but I just wanted to get some more context.
If this is what you are adding, it's great! Just exactly what I need.

Thanks for your work Antonio.

Will

On 12/10/2012 06:16 AM, Antonio Quartulli wrote:
> In IBSS mode it could be the case that a station being added
> is not ready for starting higher level routines (e.g. key
> exchange when IBSS/RSN is enabled). In particular, this can
> happen when we are waiting for the AUTH response message.
> 
> This IBSS_STA event is triggered after the NEW_STA one and
> only when the upper layer is allowed to assume that the new
> peer is ready
> 
> Signed-off-by: Antonio Quartulli <antonio@open-mesh.com>
> ---
> 
> 1/2 v2:
>  * untouched
> 2/2 v2:
>  * if userspace registered for auth frames, the new station is immediately
>    authenticated and the new IBSS_STA event is triggered.
> 
>  include/net/cfg80211.h       |  8 ++++++++
>  include/uapi/linux/nl80211.h |  2 ++
>  net/wireless/mlme.c          |  9 +++++++++
>  net/wireless/nl80211.c       | 33 +++++++++++++++++++++++++++++++++
>  net/wireless/nl80211.h       |  3 +++
>  5 files changed, 55 insertions(+)
> 
> diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
> index 8e6a6b7..3266c03 100644
> --- a/include/net/cfg80211.h
> +++ b/include/net/cfg80211.h
> @@ -3497,6 +3497,14 @@ void cfg80211_new_sta(struct net_device *dev, const u8 *mac_addr,
>  		      struct station_info *sinfo, gfp_t gfp);
>  
>  /**
> + * cfg80211_ibss_sta - notify userspace that the ibss station is ready
> + * @dev: the netdev
> + * @mac_addr: the station's address
> + * @gfp: allocation flags
> + */
> +void cfg80211_ibss_sta(struct net_device *dev, const u8 *mac_addr, gfp_t gfp);
> +
> +/**
>   * cfg80211_del_sta - notify userspace about deletion of a station
>   *
>   * @dev: the netdev
> diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
> index e3e19f8..7e0911e 100644
> --- a/include/uapi/linux/nl80211.h
> +++ b/include/uapi/linux/nl80211.h
> @@ -736,6 +736,8 @@ enum nl80211_commands {
>  
>  	NL80211_CMD_SET_MCAST_RATE,
>  
> +	NL80211_CMD_IBSS_STATION,
> +
>  	/* add new commands above here */
>  
>  	/* used to define NL80211_CMD_MAX below */
> diff --git a/net/wireless/mlme.c b/net/wireless/mlme.c
> index 5e8123e..f9493fc 100644
> --- a/net/wireless/mlme.c
> +++ b/net/wireless/mlme.c
> @@ -612,6 +612,15 @@ void cfg80211_new_sta(struct net_device *dev, const u8 *mac_addr,
>  }
>  EXPORT_SYMBOL(cfg80211_new_sta);
>  
> +void cfg80211_ibss_sta(struct net_device *dev, const u8 *mac_addr, gfp_t gfp)
> +{
> +	struct wiphy *wiphy = dev->ieee80211_ptr->wiphy;
> +	struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
> +
> +	nl80211_send_ibss_sta_event(rdev, dev, mac_addr, gfp);
> +}
> +EXPORT_SYMBOL(cfg80211_ibss_sta);
> +
>  void cfg80211_del_sta(struct net_device *dev, const u8 *mac_addr, gfp_t gfp)
>  {
>  	struct wiphy *wiphy = dev->ieee80211_ptr->wiphy;
> diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
> index f45706a..2d27911 100644
> --- a/net/wireless/nl80211.c
> +++ b/net/wireless/nl80211.c
> @@ -8564,6 +8564,39 @@ void nl80211_send_sta_event(struct cfg80211_registered_device *rdev,
>  				nl80211_mlme_mcgrp.id, gfp);
>  }
>  
> +void nl80211_send_ibss_sta_event(struct cfg80211_registered_device *rdev,
> +				 struct net_device *dev, const u8 *mac_addr,
> +				 gfp_t gfp)
> +{
> +	struct sk_buff *msg;
> +	void *hdr;
> +
> +	msg = nlmsg_new(NLMSG_GOODSIZE, gfp);
> +	if (!msg)
> +		return;
> +
> +	hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_IBSS_STATION);
> +	if (!hdr) {
> +		nlmsg_free(msg);
> +		return;
> +	}
> +
> +	if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) ||
> +	    nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, mac_addr))
> +		goto nla_put_failure;
> +
> +	genlmsg_end(msg, hdr);
> +
> +	genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0,
> +				nl80211_mlme_mcgrp.id, gfp);
> +	return;
> +
> + nla_put_failure:
> +	genlmsg_cancel(msg, hdr);
> +	nlmsg_free(msg);
> +}
> +
> +
>  void nl80211_send_sta_del_event(struct cfg80211_registered_device *rdev,
>  				struct net_device *dev, const u8 *mac_addr,
>  				gfp_t gfp)
> diff --git a/net/wireless/nl80211.h b/net/wireless/nl80211.h
> index 2acba84..429f5d6 100644
> --- a/net/wireless/nl80211.h
> +++ b/net/wireless/nl80211.h
> @@ -85,6 +85,9 @@ void nl80211_send_remain_on_channel_cancel(
>  void nl80211_send_sta_event(struct cfg80211_registered_device *rdev,
>  			    struct net_device *dev, const u8 *mac_addr,
>  			    struct station_info *sinfo, gfp_t gfp);
> +void nl80211_send_ibss_sta_event(struct cfg80211_registered_device *rdev,
> +				 struct net_device *dev, const u8 *mac_addr,
> +				 gfp_t gfp);
>  void nl80211_send_sta_del_event(struct cfg80211_registered_device *rdev,
>  				struct net_device *dev, const u8 *mac_addr,
>  				gfp_t gfp);
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Antonio Quartulli Dec. 11, 2012, 4:53 p.m. UTC | #2
Hi Will,

On Tue, Dec 11, 2012 at 11:37:44AM -0500, Will Hawkins wrote:
> Will this give IBSS something equivalent to the 802.11s
> NL80211_CMD_NEW_PEER_CANDIDATE?
> 

I'm not very familiar with the 802.11s code, but after having given a look,
they seem to be similar. The difference is that the IBSS_STA event is triggered
only after the new station has been AUTHENTICATED, while NNEW_PEER_CANDIDATE
seems to be triggered right after having "intercepted" a new peer.

So in IBSS, with this patchset, you will have these sequence:

0) detection of a new node
1) sta_info creation and NEW_STA is triggered (this event has not been removed)
2) sta gets authenticated
3) IBSS_STA triggered => sta is ready to be handled by userspace (e.g. wpa_s)

> That's how I am reading it, but I just wanted to get some more context.
> If this is what you are adding, it's great! Just exactly what I need.

I hope the explanation above is enough, otherwise feel free to ask more :-)

> 
> Thanks for your work Antonio.
> 


np, thank Open-Mesh for having given me the chance to work on this ;)

Cheers,

> Will
> 
> On 12/10/2012 06:16 AM, Antonio Quartulli wrote:
> > In IBSS mode it could be the case that a station being added
> > is not ready for starting higher level routines (e.g. key
> > exchange when IBSS/RSN is enabled). In particular, this can
> > happen when we are waiting for the AUTH response message.
> > 
> > This IBSS_STA event is triggered after the NEW_STA one and
> > only when the upper layer is allowed to assume that the new
> > peer is ready
> > 
> > Signed-off-by: Antonio Quartulli <antonio@open-mesh.com>
> > ---
> > 
> > 1/2 v2:
> >  * untouched
> > 2/2 v2:
> >  * if userspace registered for auth frames, the new station is immediately
> >    authenticated and the new IBSS_STA event is triggered.
> > 
> >  include/net/cfg80211.h       |  8 ++++++++
> >  include/uapi/linux/nl80211.h |  2 ++
> >  net/wireless/mlme.c          |  9 +++++++++
> >  net/wireless/nl80211.c       | 33 +++++++++++++++++++++++++++++++++
> >  net/wireless/nl80211.h       |  3 +++
> >  5 files changed, 55 insertions(+)
> > 
> > diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
> > index 8e6a6b7..3266c03 100644
> > --- a/include/net/cfg80211.h
> > +++ b/include/net/cfg80211.h
> > @@ -3497,6 +3497,14 @@ void cfg80211_new_sta(struct net_device *dev, const u8 *mac_addr,
> >  		      struct station_info *sinfo, gfp_t gfp);
> >  
> >  /**
> > + * cfg80211_ibss_sta - notify userspace that the ibss station is ready
> > + * @dev: the netdev
> > + * @mac_addr: the station's address
> > + * @gfp: allocation flags
> > + */
> > +void cfg80211_ibss_sta(struct net_device *dev, const u8 *mac_addr, gfp_t gfp);
> > +
> > +/**
> >   * cfg80211_del_sta - notify userspace about deletion of a station
> >   *
> >   * @dev: the netdev
> > diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
> > index e3e19f8..7e0911e 100644
> > --- a/include/uapi/linux/nl80211.h
> > +++ b/include/uapi/linux/nl80211.h
> > @@ -736,6 +736,8 @@ enum nl80211_commands {
> >  
> >  	NL80211_CMD_SET_MCAST_RATE,
> >  
> > +	NL80211_CMD_IBSS_STATION,
> > +
> >  	/* add new commands above here */
> >  
> >  	/* used to define NL80211_CMD_MAX below */
> > diff --git a/net/wireless/mlme.c b/net/wireless/mlme.c
> > index 5e8123e..f9493fc 100644
> > --- a/net/wireless/mlme.c
> > +++ b/net/wireless/mlme.c
> > @@ -612,6 +612,15 @@ void cfg80211_new_sta(struct net_device *dev, const u8 *mac_addr,
> >  }
> >  EXPORT_SYMBOL(cfg80211_new_sta);
> >  
> > +void cfg80211_ibss_sta(struct net_device *dev, const u8 *mac_addr, gfp_t gfp)
> > +{
> > +	struct wiphy *wiphy = dev->ieee80211_ptr->wiphy;
> > +	struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
> > +
> > +	nl80211_send_ibss_sta_event(rdev, dev, mac_addr, gfp);
> > +}
> > +EXPORT_SYMBOL(cfg80211_ibss_sta);
> > +
> >  void cfg80211_del_sta(struct net_device *dev, const u8 *mac_addr, gfp_t gfp)
> >  {
> >  	struct wiphy *wiphy = dev->ieee80211_ptr->wiphy;
> > diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
> > index f45706a..2d27911 100644
> > --- a/net/wireless/nl80211.c
> > +++ b/net/wireless/nl80211.c
> > @@ -8564,6 +8564,39 @@ void nl80211_send_sta_event(struct cfg80211_registered_device *rdev,
> >  				nl80211_mlme_mcgrp.id, gfp);
> >  }
> >  
> > +void nl80211_send_ibss_sta_event(struct cfg80211_registered_device *rdev,
> > +				 struct net_device *dev, const u8 *mac_addr,
> > +				 gfp_t gfp)
> > +{
> > +	struct sk_buff *msg;
> > +	void *hdr;
> > +
> > +	msg = nlmsg_new(NLMSG_GOODSIZE, gfp);
> > +	if (!msg)
> > +		return;
> > +
> > +	hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_IBSS_STATION);
> > +	if (!hdr) {
> > +		nlmsg_free(msg);
> > +		return;
> > +	}
> > +
> > +	if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) ||
> > +	    nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, mac_addr))
> > +		goto nla_put_failure;
> > +
> > +	genlmsg_end(msg, hdr);
> > +
> > +	genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0,
> > +				nl80211_mlme_mcgrp.id, gfp);
> > +	return;
> > +
> > + nla_put_failure:
> > +	genlmsg_cancel(msg, hdr);
> > +	nlmsg_free(msg);
> > +}
> > +
> > +
> >  void nl80211_send_sta_del_event(struct cfg80211_registered_device *rdev,
> >  				struct net_device *dev, const u8 *mac_addr,
> >  				gfp_t gfp)
> > diff --git a/net/wireless/nl80211.h b/net/wireless/nl80211.h
> > index 2acba84..429f5d6 100644
> > --- a/net/wireless/nl80211.h
> > +++ b/net/wireless/nl80211.h
> > @@ -85,6 +85,9 @@ void nl80211_send_remain_on_channel_cancel(
> >  void nl80211_send_sta_event(struct cfg80211_registered_device *rdev,
> >  			    struct net_device *dev, const u8 *mac_addr,
> >  			    struct station_info *sinfo, gfp_t gfp);
> > +void nl80211_send_ibss_sta_event(struct cfg80211_registered_device *rdev,
> > +				 struct net_device *dev, const u8 *mac_addr,
> > +				 gfp_t gfp);
> >  void nl80211_send_sta_del_event(struct cfg80211_registered_device *rdev,
> >  				struct net_device *dev, const u8 *mac_addr,
> >  				gfp_t gfp);
> >
diff mbox

Patch

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 8e6a6b7..3266c03 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -3497,6 +3497,14 @@  void cfg80211_new_sta(struct net_device *dev, const u8 *mac_addr,
 		      struct station_info *sinfo, gfp_t gfp);
 
 /**
+ * cfg80211_ibss_sta - notify userspace that the ibss station is ready
+ * @dev: the netdev
+ * @mac_addr: the station's address
+ * @gfp: allocation flags
+ */
+void cfg80211_ibss_sta(struct net_device *dev, const u8 *mac_addr, gfp_t gfp);
+
+/**
  * cfg80211_del_sta - notify userspace about deletion of a station
  *
  * @dev: the netdev
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index e3e19f8..7e0911e 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -736,6 +736,8 @@  enum nl80211_commands {
 
 	NL80211_CMD_SET_MCAST_RATE,
 
+	NL80211_CMD_IBSS_STATION,
+
 	/* add new commands above here */
 
 	/* used to define NL80211_CMD_MAX below */
diff --git a/net/wireless/mlme.c b/net/wireless/mlme.c
index 5e8123e..f9493fc 100644
--- a/net/wireless/mlme.c
+++ b/net/wireless/mlme.c
@@ -612,6 +612,15 @@  void cfg80211_new_sta(struct net_device *dev, const u8 *mac_addr,
 }
 EXPORT_SYMBOL(cfg80211_new_sta);
 
+void cfg80211_ibss_sta(struct net_device *dev, const u8 *mac_addr, gfp_t gfp)
+{
+	struct wiphy *wiphy = dev->ieee80211_ptr->wiphy;
+	struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
+
+	nl80211_send_ibss_sta_event(rdev, dev, mac_addr, gfp);
+}
+EXPORT_SYMBOL(cfg80211_ibss_sta);
+
 void cfg80211_del_sta(struct net_device *dev, const u8 *mac_addr, gfp_t gfp)
 {
 	struct wiphy *wiphy = dev->ieee80211_ptr->wiphy;
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index f45706a..2d27911 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -8564,6 +8564,39 @@  void nl80211_send_sta_event(struct cfg80211_registered_device *rdev,
 				nl80211_mlme_mcgrp.id, gfp);
 }
 
+void nl80211_send_ibss_sta_event(struct cfg80211_registered_device *rdev,
+				 struct net_device *dev, const u8 *mac_addr,
+				 gfp_t gfp)
+{
+	struct sk_buff *msg;
+	void *hdr;
+
+	msg = nlmsg_new(NLMSG_GOODSIZE, gfp);
+	if (!msg)
+		return;
+
+	hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_IBSS_STATION);
+	if (!hdr) {
+		nlmsg_free(msg);
+		return;
+	}
+
+	if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) ||
+	    nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, mac_addr))
+		goto nla_put_failure;
+
+	genlmsg_end(msg, hdr);
+
+	genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0,
+				nl80211_mlme_mcgrp.id, gfp);
+	return;
+
+ nla_put_failure:
+	genlmsg_cancel(msg, hdr);
+	nlmsg_free(msg);
+}
+
+
 void nl80211_send_sta_del_event(struct cfg80211_registered_device *rdev,
 				struct net_device *dev, const u8 *mac_addr,
 				gfp_t gfp)
diff --git a/net/wireless/nl80211.h b/net/wireless/nl80211.h
index 2acba84..429f5d6 100644
--- a/net/wireless/nl80211.h
+++ b/net/wireless/nl80211.h
@@ -85,6 +85,9 @@  void nl80211_send_remain_on_channel_cancel(
 void nl80211_send_sta_event(struct cfg80211_registered_device *rdev,
 			    struct net_device *dev, const u8 *mac_addr,
 			    struct station_info *sinfo, gfp_t gfp);
+void nl80211_send_ibss_sta_event(struct cfg80211_registered_device *rdev,
+				 struct net_device *dev, const u8 *mac_addr,
+				 gfp_t gfp);
 void nl80211_send_sta_del_event(struct cfg80211_registered_device *rdev,
 				struct net_device *dev, const u8 *mac_addr,
 				gfp_t gfp);