From: Thomas Pedersen <thomas@cozybit.com>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: linux-wirelss <linux-wireless@vger.kernel.org>,
me@bobcopeland.com, open80211s <devel@lists.open80211s.org>
Subject: [RFC 01/12] mac80211: track and share mesh BSSes among interfaces
Date: Thu, 2 May 2013 19:33:51 -0700 [thread overview]
Message-ID: <1367548442-8229-2-git-send-email-thomas@cozybit.com> (raw)
In-Reply-To: <1367548442-8229-1-git-send-email-thomas@cozybit.com>
From: Bob Copeland <me@bobcopeland.com>
Add a new global list of mesh BSSes for this host. Each struct
mesh_local_bss contains parameters specific to a mesh instance,
as well as a list of interfaces participating in the MBSS. This
will enable lookup of other interfaces on the host participating
in the same mesh.
Signed-off-by: Bob Copeland <bob@cozybit.com>
---
net/mac80211/ieee80211_i.h | 33 +++++++++
net/mac80211/mesh.c | 172 ++++++++++++++++++++++++++++++++++++++++++++
net/mac80211/mesh.h | 4 ++
3 files changed, 209 insertions(+)
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 44be28c..da7fbd4 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -285,6 +285,35 @@ struct mesh_stats {
__u32 dropped_frames_congestion;/* Not forwarded due to congestion */
};
+/**
+ * mesh_local_bss - a mesh BSS running on this host
+ *
+ * @mesh_id: the mesh id
+ * @mesh_id_len: size of mesh id in bytes
+ * @sync_method: which synchronization method to use
+ * @path_sel_proto: which path selection protocol to use
+ * @path_metric: which metric to use
+ * @is_secure: true if the mesh is secure
+ * @can_share: true if this bss can be shared (user-configurable per-if)
+ * @net: network namespace devices in this mbss belong to
+ * @list: listptr for siblings in mesh_bss_list
+ * @if_list: interfaces sharing this bss
+ */
+struct mesh_local_bss {
+ u8 mesh_id[IEEE80211_MAX_SSID_LEN];
+ u8 mesh_id_len;
+ u8 sync_method;
+ u8 path_sel_proto;
+ u8 path_metric;
+ bool is_secure;
+
+ bool can_share;
+ struct net *net;
+
+ struct list_head list;
+ struct list_head if_list;
+};
+
#define PREQ_Q_F_START 0x1
#define PREQ_Q_F_REFRESH 0x2
struct mesh_preq_queue {
@@ -600,6 +629,10 @@ struct ieee80211_if_mesh {
int ps_peers_light_sleep;
int ps_peers_deep_sleep;
struct ps_data ps;
+
+ /* mbss sharing */
+ struct mesh_local_bss *mesh_bss;
+ struct list_head if_list;
};
#ifdef CONFIG_MAC80211_MESH
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index 6952760..5ea4812 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -16,6 +16,10 @@
static int mesh_allocated;
static struct kmem_cache *rm_cache;
+/* mesh_bss_mtx protects updates; internal iface list uses RCU */
+static DEFINE_MUTEX(mesh_bss_mtx);
+static LIST_HEAD(mesh_bss_list);
+
bool mesh_action_is_path_sel(struct ieee80211_mgmt *mgmt)
{
return (mgmt->u.action.u.mesh_action.action_code ==
@@ -49,6 +53,154 @@ static void ieee80211_mesh_housekeeping_timer(unsigned long data)
ieee80211_queue_work(&local->hw, &sdata->work);
}
+static inline bool
+mesh_bss_matches(struct ieee80211_sub_if_data *sdata,
+ struct mesh_setup *setup,
+ struct mesh_local_bss *mbss)
+{
+ return mbss->can_share &&
+ mbss->mesh_id_len == setup->mesh_id_len &&
+ memcmp(mbss->mesh_id, setup->mesh_id, mbss->mesh_id_len) == 0 &&
+ mbss->path_sel_proto == setup->path_sel_proto &&
+ mbss->path_metric == setup->path_metric &&
+ mbss->sync_method == setup->sync_method &&
+ mbss->is_secure == setup->is_secure &&
+ net_eq(wiphy_net(sdata->wdev.wiphy), mbss->net);
+}
+
+static struct mesh_local_bss * __must_check
+mesh_bss_find(struct ieee80211_sub_if_data *sdata, struct mesh_setup *setup)
+{
+ struct mesh_local_bss *mbss;
+
+ if (WARN_ON(!setup->mesh_id_len))
+ return NULL;
+
+ lockdep_assert_held(&mesh_bss_mtx);
+
+ list_for_each_entry(mbss, &mesh_bss_list, list)
+ if (mesh_bss_matches(sdata, setup, mbss))
+ return mbss;
+
+ return NULL;
+}
+
+static struct mesh_local_bss * __must_check
+mesh_bss_create(struct ieee80211_sub_if_data *sdata, struct mesh_setup *setup)
+{
+ struct mesh_local_bss *mbss;
+
+ lockdep_assert_held(&mesh_bss_mtx);
+
+ if (WARN_ON(setup->mesh_id_len > IEEE80211_MAX_SSID_LEN))
+ return NULL;
+
+ mbss = kzalloc(sizeof(*mbss), GFP_KERNEL);
+ if (!mbss)
+ return NULL;
+
+ INIT_LIST_HEAD(&mbss->if_list);
+
+ mbss->mesh_id_len = setup->mesh_id_len;
+ memcpy(mbss->mesh_id, setup->mesh_id, setup->mesh_id_len);
+ mbss->can_share = false;
+ mbss->path_metric = setup->path_metric;
+ mbss->path_sel_proto = setup->path_sel_proto;
+ mbss->sync_method = setup->sync_method;
+ mbss->is_secure = setup->is_secure;
+ mbss->net = wiphy_net(sdata->wdev.wiphy);
+ return mbss;
+}
+
+static void mesh_bss_remove(struct ieee80211_sub_if_data *sdata)
+{
+ struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
+ struct mesh_local_bss *mbss = ifmsh->mesh_bss;
+
+ if (!mbss)
+ return;
+
+ mutex_lock(&mesh_bss_mtx);
+ list_del_rcu(&ifmsh->if_list);
+ synchronize_rcu();
+ ifmsh->mesh_bss = NULL;
+
+ /* free when no more devs have this mbss */
+ if (list_empty(&mbss->if_list)) {
+ list_del(&mbss->list);
+ kfree(mbss);
+ }
+ mutex_unlock(&mesh_bss_mtx);
+}
+
+static
+int mesh_bss_add(struct ieee80211_sub_if_data *sdata,
+ struct mesh_setup *setup)
+{
+ struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
+ struct mesh_local_bss *mbss;
+ int ret;
+
+ if (WARN_ON(!setup->mesh_id_len))
+ return -EINVAL;
+
+ mutex_lock(&mesh_bss_mtx);
+ mbss = mesh_bss_find(sdata, setup);
+ if (!mbss) {
+ mbss = mesh_bss_create(sdata, setup);
+ if (!mbss) {
+ ret = -ENOMEM;
+ goto out_fail;
+ }
+ list_add(&mbss->list, &mesh_bss_list);
+ }
+
+ ifmsh->mesh_bss = mbss;
+ list_add_rcu(&ifmsh->if_list, &mbss->if_list);
+ ret = 0;
+
+ out_fail:
+ mutex_unlock(&mesh_bss_mtx);
+ return ret;
+}
+
+/**
+ * mesh_bss_find_if - return the interface in the local mbss matching addr
+ *
+ * @mbss: mesh bss on this host
+ * @addr: address to find in the interface list
+ *
+ * Returns an interface in mbss matching addr, or NULL if none found.
+ */
+struct ieee80211_sub_if_data *
+mesh_bss_find_if(struct mesh_local_bss *mbss, const u8 *addr)
+{
+ struct ieee80211_sub_if_data *sdata;
+
+ rcu_read_lock();
+ list_for_each_entry_rcu(sdata, &mbss->if_list, u.mesh.if_list) {
+ if (ether_addr_equal(addr, sdata->vif.addr)) {
+ rcu_read_unlock();
+ return sdata;
+ }
+ }
+ rcu_read_unlock();
+ return NULL;
+}
+
+/**
+ * mesh_bss_matches_addr - check if the specified addr is in the local mbss
+ *
+ * @mbss: mesh bss on this host
+ * @addr: address to find in the interface list
+ *
+ * Returns true if the addr is used by an interface in the mbss.
+ */
+bool mesh_bss_matches_addr(struct mesh_local_bss *mbss, const u8 *addr)
+{
+ return mesh_bss_find_if(mbss, addr) != NULL;
+}
+
/**
* mesh_matches_local - check if the config of a mesh point matches ours
*
@@ -733,6 +885,9 @@ void ieee80211_mbss_info_change_notify(struct ieee80211_sub_if_data *sdata,
int ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata)
{
+ struct mesh_setup setup = {};
+ int ret;
+
struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
struct ieee80211_local *local = sdata->local;
u32 changed = BSS_CHANGED_BEACON |
@@ -769,6 +924,19 @@ int ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata)
return -ENOMEM;
}
+ setup.mesh_id_len = ifmsh->mesh_id_len;
+ setup.mesh_id = ifmsh->mesh_id;
+ setup.path_sel_proto = ifmsh->mesh_pp_id;
+ setup.sync_method = ifmsh->mesh_pm_id;
+ setup.path_metric = ifmsh->mesh_cc_id;
+ setup.is_secure = ifmsh->security & IEEE80211_MESH_SEC_SECURED;
+
+ ret = mesh_bss_add(sdata, &setup);
+ if (ret) {
+ ieee80211_stop_mesh(sdata);
+ return ret;
+ }
+
ieee80211_bss_info_change_notify(sdata, changed);
netif_carrier_on(sdata->dev);
@@ -818,6 +986,10 @@ void ieee80211_stop_mesh(struct ieee80211_sub_if_data *sdata)
local->fif_other_bss--;
atomic_dec(&local->iff_allmultis);
ieee80211_configure_filter(local);
+
+ netif_tx_stop_all_queues(sdata->dev);
+
+ mesh_bss_remove(sdata);
}
static void
diff --git a/net/mac80211/mesh.h b/net/mac80211/mesh.h
index da15877..f23b58f 100644
--- a/net/mac80211/mesh.h
+++ b/net/mac80211/mesh.h
@@ -361,6 +361,10 @@ void ieee80211_mesh_notify_scan_completed(struct ieee80211_local *local);
void mesh_path_flush_by_iface(struct ieee80211_sub_if_data *sdata);
void mesh_sync_adjust_tbtt(struct ieee80211_sub_if_data *sdata);
void ieee80211s_stop(void);
+struct ieee80211_sub_if_data *
+mesh_bss_find_if(struct mesh_local_bss *mbss, const u8 *addr);
+bool mesh_bss_matches_addr(struct mesh_local_bss *mbss, const u8 *addr);
+#define mbss(sdata) (sdata->u.mesh.mesh_bss)
#else
static inline void
ieee80211_mesh_notify_scan_completed(struct ieee80211_local *local) {}
--
1.7.10.4
next prev parent reply other threads:[~2013-05-03 2:36 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-03 2:33 [RFC 00/12] MBSS sharing across multiple interfaces Thomas Pedersen
2013-05-03 2:33 ` Thomas Pedersen [this message]
2013-05-07 13:37 ` [RFC 01/12] mac80211: track and share mesh BSSes among interfaces Johannes Berg
2013-05-07 14:08 ` Bob Copeland
2013-05-07 14:22 ` Johannes Berg
2013-05-07 15:55 ` Bob Copeland
2013-05-03 2:33 ` [RFC 02/12] mac80211: mesh: add function to tx on all other mbss ifaces Thomas Pedersen
2013-05-03 2:33 ` [RFC 03/12] mac80211: use all MBSS interfaces for path selection Thomas Pedersen
2013-05-07 13:40 ` Johannes Berg
2013-05-07 14:11 ` Bob Copeland
2013-05-03 2:33 ` [RFC 04/12] mac80211: assign outgoing interface with nexthop Thomas Pedersen
2013-05-03 2:33 ` [RFC 05/12] mac80211: forward frames on correct mbss-shared interface Thomas Pedersen
2013-05-03 2:33 ` [RFC 06/12] mac80211: notify bridge when leaving mesh Thomas Pedersen
2013-05-07 13:42 ` Johannes Berg
2013-05-22 1:09 ` Thomas Pedersen
2013-05-24 20:32 ` Johannes Berg
2013-05-28 17:01 ` Thomas Pedersen
2013-05-29 16:11 ` Thomas Pedersen
2013-05-03 2:33 ` [RFC 07/12] mac80211: make RMC per-mbss Thomas Pedersen
2013-05-03 2:33 ` [RFC 08/12] mac80211: forward group frames on mbss-shared interfaces Thomas Pedersen
2013-05-03 2:33 ` [RFC 09/12] mac80211: add shared-mbss transmit path Thomas Pedersen
2013-05-03 2:34 ` [RFC 10/12] mac08211: add shared-mbss receive path handling Thomas Pedersen
2013-05-03 2:34 ` [RFC 11/12] {nl,mac}80211: specify MBSS sharing on/off Thomas Pedersen
2013-05-03 2:34 ` [RFC 12/12] {nl,mac}80211: allow mpath dump to span local MBSS Thomas Pedersen
2013-05-03 13:25 ` [RFC 00/12] MBSS sharing across multiple interfaces Chaoxing Lin
[not found] ` <CAEFj987wqVTmN1eCCfqm2M16p5j8JtOn5AcKE0fETmsn+FyENg@mail.gmail.com>
2013-05-03 14:07 ` Chaoxing Lin
2013-05-03 14:35 ` Bob Copeland
[not found] ` <CAEFj986Avr_C5Hm4uRs0oP2ZRa-jnn6eRCJH71jkehcCuQ7iGQ@mail.gmail.com>
2013-05-03 15:41 ` Bob Copeland
2013-05-07 13:44 ` Johannes Berg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1367548442-8229-2-git-send-email-thomas@cozybit.com \
--to=thomas@cozybit.com \
--cc=devel@lists.open80211s.org \
--cc=johannes@sipsolutions.net \
--cc=linux-wireless@vger.kernel.org \
--cc=me@bobcopeland.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.