History

nl80211/mac80211: mesh: add mesh path change count to mpath info

Expose path change count to destination in mpath info

Julan Hsu committed 7 years ago

Commit 540bbcb1 parent cc241636 files · +20 −4Browse files

Unified · Split

6 files
  1. include/net/cfg80211.h +4 −1
  2. include/uapi/linux/nl80211.h +3 −1
  3. net/mac80211/cfg.c +3 −1
  4. net/mac80211/mesh.h +2 −0
  5. net/mac80211/mesh_hwmp.c +4 −0
  6. net/wireless/nl80211.c +4 −1
include/net/cfg80211.h+4−1
@@ -1439,7 +1439,8 @@ enum mpath_info_flags { · 1438 unmodified lines
14391439 MPATH_INFO_DISCOVERY_TIMEOUT = BIT(4),
14401440 MPATH_INFO_DISCOVERY_RETRIES = BIT(5),
14411441 MPATH_INFO_FLAGS = BIT(6),
1442− MPATH_INFO_HOP_COUNT = BIT(7)
1442+ MPATH_INFO_HOP_COUNT = BIT(7),
1443+ MPATH_INFO_PATH_CHANGE = BIT(8),
14431444 };
14441445
14451446 /**
@@ -1460,6 +1461,7 @@ enum mpath_info_flags { · 14 unmodified lines
14601461 * changes, i.e. when a station is added or removed, so that
14611462 * userspace can tell whether it got a consistent snapshot.
14621463 * @hop_count: hops to destination
1464+ * @path_change_count: total number of path changes to destination
14631465 */
14641466 struct mpath_info {
14651467 u32 filled;
@@ -1471,6 +1473,7 @@ struct mpath_info { · 5 unmodified lines
14711473 u8 discovery_retries;
14721474 u8 flags;
14731475 u8 hop_count;
1476+ u32 path_change_count;
14741477
14751478 int generation;
14761479 };
include/uapi/linux/nl80211.h+3−1
@@ -3288,8 +3288,9 @@ enum nl80211_mpath_flags { · 3287 unmodified lines
32883288 * @NL80211_MPATH_INFO_DISCOVERY_TIMEOUT: total path discovery timeout, in msec
32893289 * @NL80211_MPATH_INFO_DISCOVERY_RETRIES: mesh path discovery retries
32903290 * @NL80211_MPATH_INFO_HOP_COUNT: hop count to destination
3291+ * @NL80211_MPATH_INFO_PATH_CHANGE: total number of path changes to destination
32913292 * @NL80211_MPATH_INFO_MAX: highest mesh path information attribute number
3292− * currently defind
3293+ * currently defined
32933294 * @__NL80211_MPATH_INFO_AFTER_LAST: internal use
32943295 */
32953296 enum nl80211_mpath_info {
@@ -3302,6 +3303,7 @@ enum nl80211_mpath_info { · 6 unmodified lines
33023303 NL80211_MPATH_INFO_DISCOVERY_TIMEOUT,
33033304 NL80211_MPATH_INFO_DISCOVERY_RETRIES,
33043305 NL80211_MPATH_INFO_HOP_COUNT,
3306+ NL80211_MPATH_INFO_PATH_CHANGE,
33053307
33063308 /* keep last */
33073309 __NL80211_MPATH_INFO_AFTER_LAST,
net/mac80211/cfg.c+3−1
@@ -1746,7 +1746,8 @@ static void mpath_set_pinfo(struct mesh_path *mpath, u8 *next_hop, · 1745 unmodified lines
17461746 MPATH_INFO_DISCOVERY_TIMEOUT |
17471747 MPATH_INFO_DISCOVERY_RETRIES |
17481748 MPATH_INFO_FLAGS |
1749− MPATH_INFO_HOP_COUNT;
1749+ MPATH_INFO_HOP_COUNT |
1750+ MPATH_INFO_PATH_CHANGE;
17501751
17511752 pinfo->frame_qlen = mpath->frame_queue.qlen;
17521753 pinfo->sn = mpath->sn;
@@ -1767,6 +1768,7 @@ static void mpath_set_pinfo(struct mesh_path *mpath, u8 *next_hop, · 14 unmodified lines
17671768 if (mpath->flags & MESH_PATH_RESOLVED)
17681769 pinfo->flags |= NL80211_MPATH_FLAG_RESOLVED;
17691770 pinfo->hop_count = mpath->hop_count;
1771+ pinfo->path_change_count = mpath->path_change_count;
17701772 }
17711773
17721774 static int ieee80211_get_mpath(struct wiphy *wiphy, struct net_device *dev,
net/mac80211/mesh.h+2−0
@@ -94,6 +94,7 @@ enum mesh_deferred_task_flags { · 93 unmodified lines
9494 * @last_preq_to_root: Timestamp of last PREQ sent to root
9595 * @is_root: the destination station of this path is a root node
9696 * @is_gate: the destination station of this path is a mesh gate
97+ * @path_change_count: the number of path changes to destination
9798 *
9899 *
99100 * The dst address is unique in the mesh path table. Since the mesh_path is
@@ -124,6 +125,7 @@ struct mesh_path { · 24 unmodified lines
124125 unsigned long last_preq_to_root;
125126 bool is_root;
126127 bool is_gate;
128+ u32 path_change_count;
127129 };
128130
129131 /**
net/mac80211/mesh_hwmp.c+4−0
@@ -479,6 +479,8 @@ static u32 hwmp_route_info_get(struct ieee80211_sub_if_data *sdata, · 478 unmodified lines
479479 }
480480
481481 if (fresh_info) {
482+ if (rcu_access_pointer(mpath->next_hop) != sta)
483+ mpath->path_change_count++;
482484 mesh_path_assign_nexthop(mpath, sta);
483485 mpath->flags |= MESH_PATH_SN_VALID;
484486 mpath->metric = new_metric;
@@ -523,6 +525,8 @@ static u32 hwmp_route_info_get(struct ieee80211_sub_if_data *sdata, · 38 unmodified lines
523525 }
524526
525527 if (fresh_info) {
528+ if (rcu_access_pointer(mpath->next_hop) != sta)
529+ mpath->path_change_count++;
526530 mesh_path_assign_nexthop(mpath, sta);
527531 mpath->metric = last_hop_metric;
528532 mpath->exp_time = time_after(mpath->exp_time, exp_time)
net/wireless/nl80211.c+4−1
@@ -5830,7 +5830,10 @@ static int nl80211_send_mpath(struct sk_buff *msg, u32 portid, u32 seq, · 5829 unmodified lines
58305830 pinfo->discovery_retries)) ||
58315831 ((pinfo->filled & MPATH_INFO_HOP_COUNT) &&
58325832 nla_put_u8(msg, NL80211_MPATH_INFO_HOP_COUNT,
5833− pinfo->hop_count)))
5833+ pinfo->hop_count)) ||
5834+ ((pinfo->filled & MPATH_INFO_PATH_CHANGE) &&
5835+ nla_put_u32(msg, NL80211_MPATH_INFO_PATH_CHANGE,
5836+ pinfo->path_change_count)))
58345837 goto nla_put_failure;
58355838
58365839 nla_nest_end(msg, pinfoattr);