mirror of
https://github.com/Telecominfraproject/wlan-ap.git
synced 2025-10-31 18:38:10 +00:00
wifi-2649: Fix SM memory leak
memory leaks while reading apc state/config. Change read method for apc state/config Signed-off-by: Chaitanya Godavarthi <chaitanya.kiran@netexperience.com>
This commit is contained in:
committed by
Rick Sommerville
parent
ef68964976
commit
b122f99bc1
@@ -26,5 +26,7 @@ extern void radio_maverick(void *arg);
|
|||||||
|
|
||||||
int nl80211_channel_get(char *name, unsigned int *chan);
|
int nl80211_channel_get(char *name, unsigned int *chan);
|
||||||
void set_config_apply_timeout(ovsdb_update_monitor_t *mon);
|
void set_config_apply_timeout(ovsdb_update_monitor_t *mon);
|
||||||
|
bool apc_read_conf(struct schema_APC_Config *apcconf);
|
||||||
|
bool apc_read_state(struct schema_APC_State *apcst);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ ovsdb_table_t table_Wifi_Inet_Config;
|
|||||||
ovsdb_table_t table_Node_Config;
|
ovsdb_table_t table_Node_Config;
|
||||||
|
|
||||||
unsigned int radproxy_apc = 0;
|
unsigned int radproxy_apc = 0;
|
||||||
extern json_t* ovsdb_table_where(ovsdb_table_t *table, void *record);
|
|
||||||
|
|
||||||
static struct uci_package *wireless;
|
static struct uci_package *wireless;
|
||||||
struct uci_context *uci;
|
struct uci_context *uci;
|
||||||
@@ -809,32 +808,105 @@ static const struct blobmsg_policy apc_policy[__APC_ATTR_MAX] = {
|
|||||||
|
|
||||||
struct schema_APC_Config apc_conf;
|
struct schema_APC_Config apc_conf;
|
||||||
|
|
||||||
void apc_state_set(struct blob_attr *msg)
|
|
||||||
{
|
|
||||||
struct blob_attr *tb[__APC_ATTR_MAX] = { };
|
|
||||||
struct schema_APC_Config apc_conf;
|
|
||||||
struct schema_APC_State apc_state;
|
|
||||||
json_t *where;
|
|
||||||
|
|
||||||
/* Check if apc conf is disabled, if disabled the update state
|
bool apc_read_conf(struct schema_APC_Config *apcconf)
|
||||||
* with NC mode and return, this is to avoid the apc ubus
|
{
|
||||||
* notifications which come after the APC is disabled */
|
json_t *jrows;
|
||||||
where = ovsdb_table_where(&table_APC_Config, &apc_conf);
|
int cnt = 0;
|
||||||
if (false == ovsdb_table_select_one_where(&table_APC_Config,
|
int i = 0;
|
||||||
where, &apc_conf)) {
|
pjs_errmsg_t perr;
|
||||||
LOG(ERR, "%s: APC_State read failed", __func__);
|
|
||||||
apc_conf.enabled = true;
|
jrows = ovsdb_sync_select_where(SCHEMA_TABLE(APC_Config), NULL);
|
||||||
|
if(!jrows)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
cnt = json_array_size(jrows);
|
||||||
|
if(!cnt)
|
||||||
|
{
|
||||||
|
json_decref(jrows);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (apc_conf.enabled == false) {
|
for (i = 0; i < cnt; i++)
|
||||||
|
{
|
||||||
|
if(!schema_APC_Config_from_json(apcconf, json_array_get(jrows, i),
|
||||||
|
false, perr))
|
||||||
|
{
|
||||||
|
LOGE("Unable to parse APC Config column: %s", perr);
|
||||||
|
json_decref(jrows);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
json_decref(jrows);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool apc_read_state(struct schema_APC_State *apcst)
|
||||||
|
{
|
||||||
|
json_t *jrows;
|
||||||
|
int cnt = 0;
|
||||||
|
int i = 0;
|
||||||
|
pjs_errmsg_t perr;
|
||||||
|
|
||||||
|
jrows = ovsdb_sync_select_where(SCHEMA_TABLE(APC_State), NULL);
|
||||||
|
if(!jrows)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
cnt = json_array_size(jrows);
|
||||||
|
if(!cnt)
|
||||||
|
{
|
||||||
|
json_decref(jrows);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < cnt; i++)
|
||||||
|
{
|
||||||
|
if(!schema_APC_State_from_json(apcst, json_array_get(jrows, i),
|
||||||
|
false, perr))
|
||||||
|
{
|
||||||
|
LOGE("Unable to parse APC State column: %s", perr);
|
||||||
|
json_decref(jrows);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
json_decref(jrows);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check if apc conf is disabled, if disabled the update state
|
||||||
|
* with NC mode and return, this is to avoid the apc ubus
|
||||||
|
* notifications which come after the APC is disabled */
|
||||||
|
bool apc_conf_en()
|
||||||
|
{
|
||||||
|
struct schema_APC_Config apcconf;
|
||||||
|
struct schema_APC_State apc_state;
|
||||||
|
|
||||||
|
if(apc_read_conf(&apcconf) == false)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (apcconf.enabled == false) {
|
||||||
SCHEMA_SET_STR(apc_state.mode, "NC");
|
SCHEMA_SET_STR(apc_state.mode, "NC");
|
||||||
SCHEMA_SET_STR(apc_state.dr_addr, "0.0.0.0");
|
SCHEMA_SET_STR(apc_state.dr_addr, "0.0.0.0");
|
||||||
SCHEMA_SET_STR(apc_state.bdr_addr, "0.0.0.0");
|
SCHEMA_SET_STR(apc_state.bdr_addr, "0.0.0.0");
|
||||||
SCHEMA_SET_INT(apc_state.enabled, false);
|
SCHEMA_SET_INT(apc_state.enabled, false);
|
||||||
if (!ovsdb_table_update(&table_APC_State, &apc_state))
|
if (!ovsdb_table_update(&table_APC_State, &apc_state))
|
||||||
LOG(ERR, "APC_state: failed to update");
|
LOG(ERR, "APC_state: failed to update");
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void apc_state_set(struct blob_attr *msg)
|
||||||
|
{
|
||||||
|
struct blob_attr *tb[__APC_ATTR_MAX] = { };
|
||||||
|
struct schema_APC_State apc_state;
|
||||||
|
|
||||||
|
if(apc_conf_en() == false)
|
||||||
|
return;
|
||||||
|
|
||||||
blobmsg_parse(apc_policy, __APC_ATTR_MAX, tb,
|
blobmsg_parse(apc_policy, __APC_ATTR_MAX, tb,
|
||||||
blob_data(msg), blob_len(msg));
|
blob_data(msg), blob_len(msg));
|
||||||
@@ -879,13 +951,10 @@ static int conn_since = 0;
|
|||||||
static void apc_enable(bool flag) {
|
static void apc_enable(bool flag) {
|
||||||
|
|
||||||
struct schema_APC_State apc_state;
|
struct schema_APC_State apc_state;
|
||||||
json_t *where;
|
|
||||||
|
|
||||||
LOGI("APC %s: %s APC", __func__, flag?"enable":"disable");
|
LOGI("APC %s: %s APC", __func__, flag?"enable":"disable");
|
||||||
if (flag == false) {
|
if (flag == false) {
|
||||||
where = ovsdb_table_where(&table_APC_State, &apc_state);
|
if(apc_read_state(&apc_state) == false) {
|
||||||
if (false == ovsdb_table_select_one_where(&table_APC_State,
|
|
||||||
where, &apc_state)) {
|
|
||||||
LOG(ERR, "%s: APC_State read failed", __func__);
|
LOG(ERR, "%s: APC_State read failed", __func__);
|
||||||
apc_state.enabled = true;
|
apc_state.enabled = true;
|
||||||
}
|
}
|
||||||
@@ -918,18 +987,14 @@ apc_cld_mon_cb(struct schema_Manager *mgr)
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
conn_since = 0;
|
conn_since = 0;
|
||||||
struct schema_APC_State apc_state;
|
struct schema_APC_State apc_state;
|
||||||
json_t *where;
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
int link = 1;
|
int link = 1;
|
||||||
|
|
||||||
where = ovsdb_table_where(&table_APC_State, &apc_state);
|
if(apc_read_state(&apc_state) == false) {
|
||||||
if (false == ovsdb_table_select_one_where(&table_APC_State,
|
|
||||||
where, &apc_state)) {
|
|
||||||
LOG(ERR, "%s: APC_State read failed", __func__);
|
LOG(ERR, "%s: APC_State read failed", __func__);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*Checks if wan ethernet port is down and disables apc*/
|
/*Checks if wan ethernet port is down and disables apc*/
|
||||||
ret = system("/bin/check_wan_link.sh");
|
ret = system("/bin/check_wan_link.sh");
|
||||||
if (WIFEXITED(ret)) {
|
if (WIFEXITED(ret)) {
|
||||||
|
|||||||
@@ -222,14 +222,6 @@ static bool radius_proxy_config_set(struct schema_Radius_Proxy_Config *conf)
|
|||||||
char server_name[256] = {};
|
char server_name[256] = {};
|
||||||
char acct_server_name[256] = {};
|
char acct_server_name[256] = {};
|
||||||
char tls_name[256] = {};
|
char tls_name[256] = {};
|
||||||
struct schema_APC_State apc_conf;
|
|
||||||
|
|
||||||
json_t *where = ovsdb_table_where(&table_APC_State, &apc_conf);
|
|
||||||
if (false == ovsdb_table_select_one_where(&table_APC_State,
|
|
||||||
where, &apc_conf)) {
|
|
||||||
LOG(INFO, "APC_State read failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Configure options block */
|
/* Configure options block */
|
||||||
blob_buf_init(&uci_buf, 0);
|
blob_buf_init(&uci_buf, 0);
|
||||||
|
|||||||
@@ -329,7 +329,6 @@ static struct vif_crypto {
|
|||||||
};
|
};
|
||||||
|
|
||||||
extern ovsdb_table_t table_APC_State;
|
extern ovsdb_table_t table_APC_State;
|
||||||
extern json_t* ovsdb_table_where(ovsdb_table_t *table, void *record);
|
|
||||||
extern unsigned int radproxy_apc;
|
extern unsigned int radproxy_apc;
|
||||||
|
|
||||||
/* Custom options table */
|
/* Custom options table */
|
||||||
@@ -417,12 +416,12 @@ static int vif_config_security_set(struct blob_buf *b,
|
|||||||
|
|
||||||
if (vif_config_custom_opt_get_proxy(vconf)) { /* Radius Proxy Enabled */
|
if (vif_config_custom_opt_get_proxy(vconf)) { /* Radius Proxy Enabled */
|
||||||
LOGN("%s: Apply Proxy Security Settings", vconf->if_name);
|
LOGN("%s: Apply Proxy Security Settings", vconf->if_name);
|
||||||
json_t *where = ovsdb_table_where(&table_APC_State, &apc_conf);
|
if(apc_read_state(&apc_conf) == false)
|
||||||
if (false == ovsdb_table_select_one_where(&table_APC_State,
|
{
|
||||||
where, &apc_conf)) {
|
LOGI("APC_State read failed");
|
||||||
LOG(INFO, "APC_State read failed");
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strncmp(apc_conf.mode, "DR", 2)) {
|
if (!strncmp(apc_conf.mode, "DR", 2)) {
|
||||||
auth_server = local_server;
|
auth_server = local_server;
|
||||||
acct_server = local_server;
|
acct_server = local_server;
|
||||||
@@ -1065,8 +1064,7 @@ void vif_check_radius_proxy()
|
|||||||
int n = 0;
|
int n = 0;
|
||||||
void *buf = NULL;
|
void *buf = NULL;
|
||||||
|
|
||||||
json_t *where = ovsdb_table_where(&table_APC_State, &apc_conf);
|
if(apc_read_state(&apc_conf) == false)
|
||||||
if (false == ovsdb_table_select_one_where(&table_APC_State, where, &apc_conf))
|
|
||||||
{
|
{
|
||||||
LOGI("APC_State read failed");
|
LOGI("APC_State read failed");
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user