Skip to main content
Sign in
Snippets Groups Projects
Commit 929bcfa4 authored by Jakob Olsson's avatar Jakob Olsson
Browse files

mapcontroller: trigger autoconfig renew regardless if detected by SIGHUP

parent 381b1363
No related branches found
No related tags found
No related merge requests found
Pipeline #36627 failed
...@@ -1429,52 +1429,11 @@ static void cntlr_query_nodes(struct uloop_timeout *t) ...@@ -1429,52 +1429,11 @@ static void cntlr_query_nodes(struct uloop_timeout *t)
uloop_timeout_set(&c->query_nodes, 60 * 1000); uloop_timeout_set(&c->query_nodes, 60 * 1000);
} }
uint8_t cntlr_resync_config(struct controller *c)
{
uint8_t diff;
struct node_policy *np;
diff = cntlr_config_reload(&c->cfg);
list_for_each_entry(np, &c->cfg.nodelist, list) {
struct node *n;
n = find_node_by_mac(c, np->agent_id);
if (n)
n->np = np;
}
return diff;
}
#define RADIO_MAX 8 #define RADIO_MAX 8
static void cntlr_signal_periodic_run(struct uloop_timeout *t) bool cntlr_check_config_diff(struct controller *c, uint8_t diff)
{ {
struct controller *c = container_of(t, struct controller, signal_handler); bool reloaded = false;
sigset_t waiting_mask;
sigpending(&waiting_mask);
if (sigismember(&waiting_mask, SIGINT)) {
dbg("|%s:%d| Received SIGINT, terminating\n", __func__, __LINE__);
signal(SIGINT, SIG_IGN);
cntlr_terminate(c);
}
if (sigismember(&waiting_mask, SIGTERM)) {
dbg("|%s:%d| Received SIGSTP, terminating\n", __func__, __LINE__);
signal(SIGTERM, SIG_IGN);
cntlr_terminate(c);
}
if (sigismember(&waiting_mask, SIGHUP)) {
uint8_t diff;
dbg("|%s:%d| Received SIGHUP, reload config\n", __func__, __LINE__);
signal(SIGHUP, SIG_IGN);
diff = cntlr_resync_config(c);
if (diff & CONFIG_DIFF_CREDENTIALS || diff & CONFIG_DIFF_VLAN) { if (diff & CONFIG_DIFF_CREDENTIALS || diff & CONFIG_DIFF_VLAN) {
struct cmdu_buff *cmdu; struct cmdu_buff *cmdu;
uint8_t origin[6] = {0x01, 0x80, 0xc2, 0x00, 0x00, 0x13}; uint8_t origin[6] = {0x01, 0x80, 0xc2, 0x00, 0x00, 0x13};
...@@ -1484,6 +1443,7 @@ static void cntlr_signal_periodic_run(struct uloop_timeout *t) ...@@ -1484,6 +1443,7 @@ static void cntlr_signal_periodic_run(struct uloop_timeout *t)
if (cmdu) { if (cmdu) {
send_cmdu(c, cmdu); send_cmdu(c, cmdu);
cmdu_free(cmdu); cmdu_free(cmdu);
reloaded = true;
} }
} else if (diff & (CONFIG_DIFF_AGENT_POLICY | CONFIG_DIFF_AGENT_POLICY_CNT)) { } else if (diff & (CONFIG_DIFF_AGENT_POLICY | CONFIG_DIFF_AGENT_POLICY_CNT)) {
struct node_policy *p; struct node_policy *p;
...@@ -1496,7 +1456,8 @@ static void cntlr_signal_periodic_run(struct uloop_timeout *t) ...@@ -1496,7 +1456,8 @@ static void cntlr_signal_periodic_run(struct uloop_timeout *t)
* Also few information i.e. exclude stalist, * Also few information i.e. exclude stalist,
* rcpi/util threshold is sent along with * rcpi/util threshold is sent along with
* 17.2.11 & 17.2.12 tlv. * 17.2.11 & 17.2.12 tlv.
* So for now, dummy radio id & bss id is being used for this purpose. * So for now, dummy radio id & bss id is being used for this
* purpose.
* ((later on radio id & bss id info for specific agent * ((later on radio id & bss id info for specific agent
* will be stored using in Topology Response CMDU.)) * will be stored using in Topology Response CMDU.))
*/ */
...@@ -1528,6 +1489,7 @@ static void cntlr_signal_periodic_run(struct uloop_timeout *t) ...@@ -1528,6 +1489,7 @@ static void cntlr_signal_periodic_run(struct uloop_timeout *t)
if (cmdu) { if (cmdu) {
send_cmdu(c, cmdu); send_cmdu(c, cmdu);
cmdu_free(cmdu); cmdu_free(cmdu);
reloaded = true;
} }
} }
...@@ -1535,6 +1497,54 @@ static void cntlr_signal_periodic_run(struct uloop_timeout *t) ...@@ -1535,6 +1497,54 @@ static void cntlr_signal_periodic_run(struct uloop_timeout *t)
list_for_each_entry(p, &c->cfg.nodelist, list) list_for_each_entry(p, &c->cfg.nodelist, list)
p->is_policy_diff = false; p->is_policy_diff = false;
} }
return reloaded;
}
bool cntlr_resync_config(struct controller *c, bool reload)
{
uint8_t diff;
struct node_policy *np;
diff = cntlr_config_reload(&c->cfg);
if (reload)
cntlr_check_config_diff(c, diff);
list_for_each_entry(np, &c->cfg.nodelist, list) {
struct node *n;
n = find_node_by_mac(c, np->agent_id);
if (n)
n->np = np;
}
return !!diff;
}
static void cntlr_signal_periodic_run(struct uloop_timeout *t)
{
struct controller *c = container_of(t, struct controller, signal_handler);
sigset_t waiting_mask;
sigpending(&waiting_mask);
if (sigismember(&waiting_mask, SIGINT)) {
dbg("|%s:%d| Received SIGINT, terminating\n", __func__, __LINE__);
signal(SIGINT, SIG_IGN);
cntlr_terminate(c);
}
if (sigismember(&waiting_mask, SIGTERM)) {
dbg("|%s:%d| Received SIGSTP, terminating\n", __func__, __LINE__);
signal(SIGTERM, SIG_IGN);
cntlr_terminate(c);
}
if (sigismember(&waiting_mask, SIGHUP)) {
dbg("|%s:%d| Received SIGHUP, reload config\n", __func__, __LINE__);
signal(SIGHUP, SIG_IGN);
cntlr_resync_config(c, true);
} }
uloop_timeout_set(&c->signal_handler, 1 * 1000); uloop_timeout_set(&c->signal_handler, 1 * 1000);
...@@ -2123,7 +2133,7 @@ int start_controller(void) ...@@ -2123,7 +2133,7 @@ int start_controller(void)
alloc_node_init(c, np->agent_id); alloc_node_init(c, np->agent_id);
} }
} }
cntlr_resync_config(c); cntlr_resync_config(c, false);
if (!c->cfg.enabled) if (!c->cfg.enabled)
goto out_exit; goto out_exit;
... ...
......
...@@ -406,7 +406,7 @@ struct sta *cntlr_find_sta(struct controller *c, uint8_t *mac); ...@@ -406,7 +406,7 @@ struct sta *cntlr_find_sta(struct controller *c, uint8_t *mac);
struct bcnreq *cntlr_find_bcnreq(struct controller *c, uint8_t *sta, uint8_t *alid); struct bcnreq *cntlr_find_bcnreq(struct controller *c, uint8_t *sta, uint8_t *alid);
struct netif_iface *cntlr_get_fbss_by_mac(struct controller *c, struct node *n, struct netif_iface *cntlr_get_fbss_by_mac(struct controller *c, struct node *n,
uint8_t *mac); uint8_t *mac);
uint8_t cntlr_resync_config(struct controller *c); bool cntlr_resync_config(struct controller *c, bool reload);
void free_bcn_metrics(struct controller *c, struct sta *s); void free_bcn_metrics(struct controller *c, struct sta *s);
void free_usta_metrics(struct controller *c, struct sta *s); void free_usta_metrics(struct controller *c, struct sta *s);
#endif /* CNTLR_H */ #endif /* CNTLR_H */
...@@ -465,7 +465,7 @@ struct node *cntlr_add_agent(struct controller *c, uint8_t *hwaddr) ...@@ -465,7 +465,7 @@ struct node *cntlr_add_agent(struct controller *c, uint8_t *hwaddr)
cntlr_config_add_agent(&c->cfg, mac_str); cntlr_config_add_agent(&c->cfg, mac_str);
cntlr_resync_config(c); cntlr_resync_config(c, true);
return n; return n;
} }
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment