Commit 0924074a authored by Sven Eckelmann's avatar Sven Eckelmann Committed by Martin Weinelt

gluon-mesh-batman-adv: Only use local TT to count non-wifi clients (#1676)

The amount of local wifi clients is currently counted by two different
ways:

* asking the kernel wifi layer for the number of of clients on 2.4GHz and
  5GHz band
* asking batman-adv for the number of non-timed out entries in the local
  translation table with WiFi flag

The number of wifi24+wifi5 and the number of TT wifi client counts are
reported via respondd to various consumers. The ffrgb meshviewer is
displaying these values as:

* 2,4 GHz: wifi24
* 5 GHz: wifi5
* other: (TT local wifi+non-wifi clients) - (wifi24 + wifi5)

But the local translation table is holding entries much longer than the
wifi layer. It can therefore easily happen that a wifi client disappears in
the kernel wifi layer and batman-adv still has the entry stored in the
local TT.

The ffrgb meshviewer would then show this count in the category "other".
This often results in confusions because "other" is usually for ethernet
clients. And nodes with a frequently disappearing larger group of clients
(near bus stations or larger intersections) often show most clients under
the group "other" even when this devices doesn't have a LAN ethernet port.

It is better for presentation to calculate the number of total wifi clients
by summing up wifi24 + wifi5. And getting the number of total clients (non
wifi + wifi) by adding the result of the previous calculation to the sum of
non-wifi client in the local batman-adv translation table.

Fixes: 89a9d813 ("gluon-mesh-batman-adv-core: Announce client count by frequency")
Reported-by: 's avatarPascal Wettin <p.wettin@gmx.de>
(cherry picked from commit b850fff7e4f4b938c512d81de31bfae872fa42e4)
parent eed810aa
......@@ -76,8 +76,7 @@ struct gw_netlink_opts {
};
struct clients_netlink_opts {
size_t total;
size_t wifi;
size_t non_wifi;
struct batadv_nlquery_opts query_opts;
};
......@@ -553,26 +552,24 @@ static int parse_clients_list_netlink_cb(struct nl_msg *msg, void *arg)
flags = nla_get_u32(attrs[BATADV_ATTR_TT_FLAGS]);
if (flags & BATADV_TT_CLIENT_NOPURGE)
if (flags & (BATADV_TT_CLIENT_NOPURGE | BATADV_TT_CLIENT_WIFI))
return NL_OK;
lastseen = nla_get_u32(attrs[BATADV_ATTR_LAST_SEEN_MSECS]);
if (lastseen > MAX_INACTIVITY)
return NL_OK;
if (flags & BATADV_TT_CLIENT_WIFI)
opts->wifi++;
opts->total++;
opts->non_wifi++;
return NL_OK;
}
static struct json_object * get_clients(void) {
size_t wifi24 = 0, wifi5 = 0;
size_t total;
size_t wifi;
struct clients_netlink_opts opts = {
.total = 0,
.wifi = 0,
.non_wifi = 0,
.query_opts = {
.err = 0,
},
......@@ -583,10 +580,12 @@ static struct json_object * get_clients(void) {
&opts.query_opts);
count_stations(&wifi24, &wifi5);
wifi = wifi24 + wifi5;
total = wifi + opts.non_wifi;
struct json_object *ret = json_object_new_object();
json_object_object_add(ret, "total", json_object_new_int(opts.total));
json_object_object_add(ret, "wifi", json_object_new_int(opts.wifi));
json_object_object_add(ret, "total", json_object_new_int(total));
json_object_object_add(ret, "wifi", json_object_new_int(wifi));
json_object_object_add(ret, "wifi24", json_object_new_int(wifi24));
json_object_object_add(ret, "wifi5", json_object_new_int(wifi5));
return ret;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment