diff mbox

mesh: Report mesh peer AID to kernel

Message ID 1467277404-2760-1-git-send-email-masashi.honma@gmail.com
State Superseded
Headers show

Commit Message

Masashi Honma June 30, 2016, 9:03 a.m. UTC
Previously, mesh peer AID is not reported to kernel when local mesh
STA is created without iw command. The mesh peer AID is needed by mesh
peer power management functionality to identify a AID in a TIM
element.

This patch reports mesh peer AID to kernel.

Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
---
 src/ap/sta_info.h            | 1 +
 src/drivers/driver.h         | 1 +
 src/drivers/driver_nl80211.c | 7 +++++++
 src/drivers/nl80211_copy.h   | 5 +++++
 wpa_supplicant/mesh_mpm.c    | 9 +++++++--
 5 files changed, 21 insertions(+), 2 deletions(-)

Comments

Johannes Berg June 30, 2016, 9:37 a.m. UTC | #1
On Thu, 2016-06-30 at 18:03 +0900, Masashi Honma wrote:
> Previously, mesh peer AID is not reported to kernel when local mesh
> STA is created without iw command.

How does "iw" come into play here?

joahnnes
Bob Copeland June 30, 2016, 11 a.m. UTC | #2
On Thu, Jun 30, 2016 at 06:03:24PM +0900, Masashi Honma wrote:
> Previously, mesh peer AID is not reported to kernel when local mesh
> STA is created without iw command. The mesh peer AID is needed by mesh
> peer power management functionality to identify a AID in a TIM
> element.
> 
> This patch reports mesh peer AID to kernel.

The naming used in the patch is pretty confusing: we have "aid" already
and now "mesh_aid".  Which is which?  [Answer: aid is the association id
of the peer in our TIM (sta->aid in the kernel), while mesh_aid is our
association id in the peer's TIM (sta->mesh->aid).]

When it came to naming sta->mesh->aid I kind of punted and described
it in the comment struct, but if we're going to call it:

> +		    nla_put_u16(msg, NL80211_ATTR_MESH_PEER_AID,
> +				params->mesh_aid))

Then we might as well use "peer_aid" everywhere by analogy to peer linkid
since both are generated on the peer.
Masashi Honma June 30, 2016, 11:07 a.m. UTC | #3
On 2016年06月30日 18:37, Johannes Berg wrote:
> How does "iw" come into play here?

We can create mesh network by iw command without wpa_supplicant.
Like "sudo iw dev mesh0 mesh join mesh_id".
Then, sta->mesh->aid is set in mesh_process_plink_frame() correclty.
But sta->mesh->aid is not set when creating mesh by wpa_supplicant.
So new interface is needed for wpa_supplicant.
Masashi Honma June 30, 2016, 11:10 a.m. UTC | #4
On 2016年06月30日 20:00, Bob Copeland wrote:
> The naming used in the patch is pretty confusing: we have "aid" already
> and now "mesh_aid".  Which is which?  [Answer: aid is the association id
> of the peer in our TIM (sta->aid in the kernel), while mesh_aid is our
> association id in the peer's TIM (sta->mesh->aid).]
>
> When it came to naming sta->mesh->aid I kind of punted and described
> it in the comment struct, but if we're going to call it:
>
>> +		    nla_put_u16(msg, NL80211_ATTR_MESH_PEER_AID,
>> +				params->mesh_aid))
> Then we might as well use "peer_aid" everywhere by analogy to peer linkid
> since both are generated on the peer.
>

Yes, mesh_aid is received from peer confirm frame.
I will modify it to peer_aid.
Johannes Berg June 30, 2016, 11:47 a.m. UTC | #5
On Thu, 2016-06-30 at 20:07 +0900, Masashi Honma wrote:
> On 2016年06月30日 18:37, Johannes Berg wrote:
> > How does "iw" come into play here?
> 
> We can create mesh network by iw command without wpa_supplicant.
> Like "sudo iw dev mesh0 mesh join mesh_id".
> Then, sta->mesh->aid is set in mesh_process_plink_frame() correclty.
> But sta->mesh->aid is not set when creating mesh by wpa_supplicant.
> So new interface is needed for wpa_supplicant.

Huh, ok, but that's not the real difference - the real difference is
who is doing the MPM, I guess? Please rephrase that appropriately, the
tool "iw" has no real impact on the difference.

johannes
Masashi Honma June 30, 2016, 11:59 a.m. UTC | #6
On 2016年06月30日 20:47, Johannes Berg wrote:
> Huh, ok, but that's not the real difference - the real difference is
> who is doing the MPM, I guess? Please rephrase that appropriately, the
> tool "iw" has no real impact on the difference.

Now I understand your concern.
I will use the phrases "user space MPM" and "kernel MPM".
diff mbox

Patch

diff --git a/src/ap/sta_info.h b/src/ap/sta_info.h
index 5d4d0c8..8b2a550 100644
--- a/src/ap/sta_info.h
+++ b/src/ap/sta_info.h
@@ -80,6 +80,7 @@  struct sta_info {
 	enum mesh_plink_state plink_state;
 	u16 peer_lid;
 	u16 my_lid;
+	u16 mesh_aid;
 	u16 mpm_close_reason;
 	int mpm_retries;
 	u8 my_nonce[WPA_NONCE_LEN];
diff --git a/src/drivers/driver.h b/src/drivers/driver.h
index edb6978..a08857c 100644
--- a/src/drivers/driver.h
+++ b/src/drivers/driver.h
@@ -1423,6 +1423,7 @@  struct hostapd_sta_add_params {
 	u32 flags_mask; /* unset bits in flags */
 #ifdef CONFIG_MESH
 	enum mesh_plink_state plink_state;
+	u16 mesh_aid;
 #endif /* CONFIG_MESH */
 	int set; /* Set STA parameters instead of add */
 	u8 qosinfo;
diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index e7a818a..7f45f55 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -4032,6 +4032,13 @@  static int wpa_driver_nl80211_sta_add(void *priv,
 			if (!(params->flags & WPA_STA_ASSOCIATED))
 				upd.mask |= BIT(NL80211_STA_FLAG_ASSOCIATED);
 		}
+#ifdef CONFIG_MESH
+	} else {
+		if (params->plink_state == PLINK_ESTAB && params->mesh_aid &&
+		    nla_put_u16(msg, NL80211_ATTR_MESH_PEER_AID,
+				params->mesh_aid))
+			goto fail;
+#endif /* CONFIG_MESH */
 	}
 
 	wpa_printf(MSG_DEBUG, "  * flags set=0x%x mask=0x%x",
diff --git a/src/drivers/nl80211_copy.h b/src/drivers/nl80211_copy.h
index 53c8278..f8c454e 100644
--- a/src/drivers/nl80211_copy.h
+++ b/src/drivers/nl80211_copy.h
@@ -1829,6 +1829,9 @@  enum nl80211_commands {
  *	%NL80211_ATTR_EXT_CAPA_MASK, to specify the extended capabilities per
  *	interface type.
  *
+ * @NL80211_ATTR_MESH_PEER_AID: Association ID for the mesh peer (u16). This is
+ *	used to pull the stored data for mesh peer in power save state.
+ *
  * @NUM_NL80211_ATTR: total number of nl80211_attrs available
  * @NL80211_ATTR_MAX: highest attribute number currently defined
  * @__NL80211_ATTR_AFTER_LAST: internal use
@@ -2213,6 +2216,8 @@  enum nl80211_attrs {
 
 	NL80211_ATTR_IFTYPE_EXT_CAPA,
 
+	NL80211_ATTR_MESH_PEER_AID,
+
 	/* add attributes here, update the policy in nl80211.c */
 
 	__NL80211_ATTR_AFTER_LAST,
diff --git a/wpa_supplicant/mesh_mpm.c b/wpa_supplicant/mesh_mpm.c
index 8f327d8..eb8659f 100644
--- a/wpa_supplicant/mesh_mpm.c
+++ b/wpa_supplicant/mesh_mpm.c
@@ -195,6 +195,7 @@  static void mesh_mpm_init_link(struct wpa_supplicant *wpa_s,
 
 	sta->my_lid = llid;
 	sta->peer_lid = 0;
+	sta->mesh_aid = 0;
 
 	/*
 	 * We do not use wpa_mesh_set_plink_state() here because there is no
@@ -394,6 +395,7 @@  void wpa_mesh_set_plink_state(struct wpa_supplicant *wpa_s,
 	os_memset(&params, 0, sizeof(params));
 	params.addr = sta->addr;
 	params.plink_state = state;
+	params.mesh_aid = sta->mesh_aid;
 	params.set = 1;
 
 	ret = wpa_drv_sta_add(wpa_s, &params);
@@ -700,6 +702,7 @@  static struct sta_info * mesh_mpm_add_peer(struct wpa_supplicant *wpa_s,
 	params.addr = addr;
 	params.plink_state = sta->plink_state;
 	params.aid = sta->aid;
+	params.mesh_aid = sta->mesh_aid;
 	params.listen_interval = 100;
 	params.ht_capabilities = sta->ht_capabilities;
 	params.vht_capabilities = sta->vht_capabilities;
@@ -1032,7 +1035,7 @@  void mesh_mpm_action_rx(struct wpa_supplicant *wpa_s,
 	struct hostapd_data *hapd = wpa_s->ifmsh->bss[0];
 	struct mesh_conf *mconf = wpa_s->ifmsh->mconf;
 	struct sta_info *sta;
-	u16 plid = 0, llid = 0;
+	u16 plid = 0, llid = 0, aid = 0;
 	enum plink_event event;
 	struct ieee802_11_elems elems;
 	struct mesh_peer_mgmt_ie peer_mgmt_ie;
@@ -1069,7 +1072,8 @@  void mesh_mpm_action_rx(struct wpa_supplicant *wpa_s,
 		ie_len -= 2;
 	}
 	if (action_field == PLINK_CONFIRM) {
-		wpa_printf(MSG_DEBUG, "MPM: AID 0x%x", WPA_GET_LE16(ies));
+		aid = WPA_GET_LE16(ies);
+		wpa_printf(MSG_DEBUG, "MPM: AID 0x%x", aid);
 		ies += 2;	/* aid */
 		ie_len -= 2;
 	}
@@ -1181,6 +1185,7 @@  void mesh_mpm_action_rx(struct wpa_supplicant *wpa_s,
 		} else {
 			if (!sta->peer_lid)
 				sta->peer_lid = plid;
+			sta->mesh_aid = aid;
 			event = CNF_ACPT;
 		}
 		break;