node: move roam-events to dedicated struct
authorDavid Bauer <mail@david-bauer.net>
Fri, 26 Nov 2021 00:36:43 +0000 (01:36 +0100)
committerDavid Bauer <mail@david-bauer.net>
Sun, 28 Nov 2021 12:47:53 +0000 (13:47 +0100)
Move the roam event counters to a dedicated struct.

Update the ubus output to represent this new organization.

Signed-off-by: David Bauer <mail@david-bauer.net>
local_node.c
node.c
remote.c
ubus.c
usteer.h

index 3a6b6314e02b2c4d35f0d807a8a08f0247f90d24..613dac31e4188d8a9a50e73bc668adb4bc90c3db 100644 (file)
@@ -163,7 +163,7 @@ usteer_local_node_assoc_update(struct sta_info *si, struct blob_attr *data)
                                        continue;
 
                                if (current_time - remote_si->last_connected < config.roam_process_timeout) {
-                                       rn->node.roam_source++;
+                                       rn->node.roam_events.source++;
                                        /* Don't abort looking for roam sources here.
                                         * The client might have roamed via another node
                                         * within the roam-timeout.
diff --git a/node.c b/node.c
index ee7d280e7e6262f8c7dc0c9e53850373be5b7717..8fd10696e4d98ca8920e048067f5492b6cc24763 100644 (file)
--- a/node.c
+++ b/node.c
@@ -60,8 +60,8 @@ usteer_node_higher_roamability(struct usteer_node *node, struct usteer_node *ref
 {
        uint64_t roamability_node, roamability_ref;
 
-       roamability_node = ((uint64_t)(node->roam_source + node->roam_destination)) * current_time / ((current_time - node->created) + 1);
-       roamability_ref = ((uint64_t)(ref->roam_source + ref->roam_destination)) * current_time / ((current_time - ref->created) + 1);
+       roamability_node = ((uint64_t)(node->roam_events.source + node->roam_events.target)) * current_time / ((current_time - node->created) + 1);
+       roamability_ref = ((uint64_t)(ref->roam_events.source + ref->roam_events.target)) * current_time / ((current_time - ref->created) + 1);
 
        if (roamability_node < roamability_ref)
                return ref;
index 282e39b3f290b3ea56abfda3ac81acaea53da24d..cb4f3ddc350d8b61e89fb2e6e6090a8a1f236ab8 100644 (file)
--- a/remote.c
+++ b/remote.c
@@ -193,7 +193,7 @@ interface_add_station(struct usteer_remote_node *node, struct blob_attr *data)
                                continue;
 
                        if (current_time - local_si->last_connected < config.roam_process_timeout) {
-                               node->node.roam_destination++;
+                               node->node.roam_events.target++;
                                break;
                        }
                }
diff --git a/ubus.c b/ubus.c
index 7b4ce10182f47c1a7b0b2eea82a6a4ae85623514..768c9cf03b022bc4e2c7e74f135bf7d3b461bfdb 100644 (file)
--- a/ubus.c
+++ b/ubus.c
@@ -274,7 +274,7 @@ usteer_ubus_set_config(struct ubus_context *ctx, struct ubus_object *obj,
 
 void usteer_dump_node(struct blob_buf *buf, struct usteer_node *node)
 {
-       void *c;
+       void *c, *roam_events;
 
        c = blobmsg_open_table(buf, usteer_node_name(node));
        blobmsg_printf(buf, "bssid", MAC_ADDR_FMT, MAC_ADDR_DATA(node->bssid));
@@ -283,8 +283,12 @@ void usteer_dump_node(struct blob_buf *buf, struct usteer_node *node)
        blobmsg_add_u32(buf, "noise", node->noise);
        blobmsg_add_u32(buf, "load", node->load);
        blobmsg_add_u32(buf, "max_assoc", node->max_assoc);
-       blobmsg_add_u32(buf, "roam_source", node->roam_source);
-       blobmsg_add_u32(buf, "roam_destination", node->roam_destination);
+
+       roam_events = blobmsg_open_table(buf, "roam_events");
+       blobmsg_add_u32(buf, "source", node->roam_events.source);
+       blobmsg_add_u32(buf, "target", node->roam_events.target);
+       blobmsg_close_table(buf, roam_events);
+
        if (node->rrm_nr)
                blobmsg_add_field(buf, BLOBMSG_TYPE_ARRAY, "rrm_nr",
                                  blobmsg_data(node->rrm_nr),
index 292bcc0636882eccd5a43e0697a761ef64f436d5..dd4ea0e7fbf2e44be96529fe6bafe670e9fa570a 100644 (file)
--- a/usteer.h
+++ b/usteer.h
@@ -88,8 +88,10 @@ struct usteer_node {
        int max_assoc;
        int load;
 
-       int roam_source;
-       int roam_destination;
+       struct {
+               int source;
+               int target;
+       } roam_events;
 
        uint64_t created;
 };