From f9334ec6963d7f5e4a58760143648986a0b06ef0 Mon Sep 17 00:00:00 2001
From: Maxim Menshikov <maxim.menshikov@iopsys.eu>
Date: Sat, 16 Sep 2023 14:06:45 +0100
Subject: [PATCH] More correct place to invoke QoS-related node synchronization

---
 src/cntlr.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/src/cntlr.c b/src/cntlr.c
index 16c4f808..1c568403 100644
--- a/src/cntlr.c
+++ b/src/cntlr.c
@@ -456,6 +456,12 @@ struct node *cntlr_add_node(struct controller *c, uint8_t *almac)
 		cntlr_sync_dyn_controller_config(c, almac);
 #endif
 
+#if (EASYMESH_VERSION > 2)
+	if (c->cfg.qos.enabled) {
+		cntlr_qos_sync_node(c, n->alid);
+	}
+#endif
+
 	return n;
 }
 
@@ -1530,10 +1536,6 @@ static void cntlr_query_nodes(atimer_t *t)
 			send_cmdu(c, cmdu);
 			cmdu_free(cmdu);
 		}
-
-#if (EASYMESH_VERSION > 2)
-		cntlr_qos_sync_node(c, n->alid);
-#endif
 	}
 
 	timer_set(&c->query_nodes, 60 * 1000);
@@ -1618,6 +1620,18 @@ bool cntlr_check_config_diff(struct controller *c, uint8_t diff)
 			p->is_policy_diff = false;
 		}
 	}
+#if (EASYMESH_VERSION > 2)
+	if ((diff & CONFIG_DIFF_QOS) && c->cfg.qos.enabled) {
+		struct node *n = NULL;
+
+		trace("qos config changed\n");
+
+		/* send the policy config cmdu to the marked agent */
+		list_for_each_entry(n, &c->nodelist, list) {
+			cntlr_qos_sync_node(c, n->alid);
+		}
+	}
+#endif
 
 	return reloaded;
 }
-- 
GitLab