Skip to content

Commit 2785af1

Browse files
rediska01Denys Tretiakovgsathish86
authored
DTMESH-591: Fix steering issue in OneWifi when we don't send ADD to ovsdb (rdkcentral#722)
* Fix steering issue in OneWifi when we don't send ADD to ovsdb * Update wifi_ctrl_queue_handlers.c * Update wifi_ctrl_queue_handlers.c * Update wifi_ctrl_queue_handlers.c * Fix comment for wifi_ctrl_queue_handlers.c --------- Co-authored-by: Denys Tretiakov <[email protected]> Co-authored-by: Sathish Kumar Gnanasekaran <[email protected]>
1 parent 024b29a commit 2785af1

1 file changed

Lines changed: 147 additions & 65 deletions

File tree

source/core/wifi_ctrl_queue_handlers.c

Lines changed: 147 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1763,99 +1763,177 @@ int add_client_diff_assoclist(hash_map_t **diff_map, char *mac, assoc_dev_data_
17631763
}
17641764

17651765

1766+
int process_device_removal(rdk_wifi_vap_info_t *rdk_vap_info,
1767+
mac_addr_str_t mac_str,
1768+
assoc_dev_data_t *removed_dev,
1769+
wifi_mgr_t *p_wifi_mgr,
1770+
ULONG *new_count,
1771+
ULONG old_count)
1772+
{
1773+
removed_dev->client_state = client_state_disconnected;
1774+
if (add_client_diff_assoclist(&rdk_vap_info->associated_devices_diff_map, mac_str, removed_dev) == RETURN_ERR) {
1775+
wifi_util_error_print(WIFI_CTRL,"%s:%d Failed to update diff assoclist for vap %d mac_str : %s\n", __func__, __LINE__, rdk_vap_info->vap_index, mac_str);
1776+
free(removed_dev);
1777+
return RETURN_ERR;
1778+
}
1779+
p_wifi_mgr->ctrl.webconfig_state |= ctrl_webconfig_state_associated_clients_cfg_rsp_pending;
1780+
removed_dev->dev_stats.cli_Active = false;
1781+
lm_notify_disassoc(removed_dev, rdk_vap_info->vap_index);
1782+
free(removed_dev);
1783+
if (old_count > 0) {
1784+
*new_count = old_count - 1;
1785+
}
1786+
if (((isVapPrivate(rdk_vap_info->vap_index)) || (isVapXhs(rdk_vap_info->vap_index)))){
1787+
if (notify_associated_entries(&p_wifi_mgr->ctrl, rdk_vap_info->vap_index, *new_count, old_count) != RETURN_OK) {
1788+
wifi_util_error_print(WIFI_CTRL,"%s:%d Unable to send notification for associated entries\n", __func__, __LINE__);
1789+
}
1790+
}
1791+
return RETURN_OK;
1792+
}
1793+
17661794
void process_disassoc_device_event(void *data)
17671795
{
1768-
rdk_wifi_vap_info_t *rdk_vap_info = NULL;
1769-
assoc_dev_data_t *assoc_dev_data = NULL, *temp_assoc_dev_data = NULL;
1770-
mac_address_t disassoc_mac = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
1771-
mac_address_t zero_mac = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
1772-
wifi_mgr_t *p_wifi_mgr = get_wifimgr_obj();
1773-
ULONG old_count = 0, new_count = 0;
1774-
mac_addr_str_t mac_str;
1775-
1796+
static const mac_address_t BROADCAST_MAC = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
1797+
static const mac_address_t ZERO_MAC = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
1798+
17761799
if (data == NULL) {
17771800
return;
17781801
}
17791802

1780-
assoc_dev_data_t *assoc_data = (assoc_dev_data_t *) data;
1781-
1782-
rdk_vap_info = get_wifidb_rdk_vap_info(assoc_data->ap_index);
1803+
assoc_dev_data_t *assoc_data = (assoc_dev_data_t *)data;
1804+
rdk_wifi_vap_info_t *rdk_vap_info = get_wifidb_rdk_vap_info(assoc_data->ap_index);
1805+
17831806
if (rdk_vap_info == NULL) {
17841807
return;
17851808
}
17861809

1787-
memset(mac_str, 0, sizeof(mac_str));
1810+
wifi_mgr_t *p_wifi_mgr = get_wifimgr_obj();
1811+
mac_addr_str_t mac_str;
17881812
to_mac_str(assoc_data->dev_stats.cli_MACAddress, mac_str);
1813+
bool remove_all = (memcmp(assoc_data->dev_stats.cli_MACAddress,
1814+
BROADCAST_MAC, sizeof(mac_address_t)) == 0) ||
1815+
(memcmp(assoc_data->dev_stats.cli_MACAddress,
1816+
ZERO_MAC, sizeof(mac_address_t)) == 0);
17891817

1790-
if ((memcmp(assoc_data->dev_stats.cli_MACAddress, disassoc_mac, sizeof(mac_address_t)) == 0) ||
1791-
(memcmp(assoc_data->dev_stats.cli_MACAddress, zero_mac, sizeof(mac_address_t)) == 0)) {
1792-
pthread_mutex_lock(rdk_vap_info->associated_devices_lock);
1793-
if (rdk_vap_info->associated_devices_map != NULL) {
1794-
assoc_dev_data = hash_map_get_first(rdk_vap_info->associated_devices_map);
1795-
while (assoc_dev_data != NULL) {
1796-
memset(mac_str, 0, sizeof(mac_str));
1797-
to_mac_str(assoc_dev_data->dev_stats.cli_MACAddress, mac_str);
1798-
assoc_dev_data = hash_map_get_next(rdk_vap_info->associated_devices_map, assoc_dev_data);
1799-
temp_assoc_dev_data = hash_map_remove(rdk_vap_info->associated_devices_map, mac_str);
1800-
//Adding to the associated_devices_diff_map
1801-
1802-
if (temp_assoc_dev_data != NULL) {
1803-
temp_assoc_dev_data->client_state = client_state_disconnected;
1804-
if (add_client_diff_assoclist(&rdk_vap_info->associated_devices_diff_map, mac_str, temp_assoc_dev_data) == RETURN_ERR) {
1805-
wifi_util_error_print(WIFI_CTRL,"%s:%d Failed to update diff assoclist for vap %d mac_str : %s\n", __func__, __LINE__, rdk_vap_info->vap_index, mac_str);
1806-
free(temp_assoc_dev_data);
1807-
pthread_mutex_unlock(rdk_vap_info->associated_devices_lock);
1808-
return;
1809-
}
1810-
p_wifi_mgr->ctrl.webconfig_state |= ctrl_webconfig_state_associated_clients_cfg_rsp_pending;
1811-
temp_assoc_dev_data->dev_stats.cli_Active = false;
1812-
lm_notify_disassoc(temp_assoc_dev_data, rdk_vap_info->vap_index);
1813-
free(temp_assoc_dev_data);
1818+
pthread_mutex_lock(rdk_vap_info->associated_devices_lock);
1819+
1820+
if (rdk_vap_info->associated_devices_map == NULL) {
1821+
pthread_mutex_unlock(rdk_vap_info->associated_devices_lock);
1822+
return;
1823+
}
1824+
1825+
ULONG old_count = hash_map_count(rdk_vap_info->associated_devices_map);
1826+
ULONG new_count = old_count;
1827+
1828+
if (remove_all) {
1829+
assoc_dev_data_t *assoc_dev_data =
1830+
hash_map_get_first(rdk_vap_info->associated_devices_map);
1831+
1832+
while (assoc_dev_data != NULL) {
1833+
mac_addr_str_t temp_mac_str;
1834+
to_mac_str(assoc_dev_data->dev_stats.cli_MACAddress, temp_mac_str);
1835+
1836+
assoc_dev_data = hash_map_get_next(rdk_vap_info->associated_devices_map,
1837+
assoc_dev_data);
1838+
1839+
assoc_dev_data_t *temp = hash_map_remove(rdk_vap_info->associated_devices_map,
1840+
temp_mac_str);
1841+
if (temp != NULL) {
1842+
if (process_device_removal(rdk_vap_info, temp_mac_str, temp,
1843+
p_wifi_mgr, &new_count, old_count) == RETURN_ERR) {
1844+
pthread_mutex_unlock(rdk_vap_info->associated_devices_lock);
1845+
return;
18141846
}
18151847
}
18161848
}
1817-
pthread_mutex_unlock(rdk_vap_info->associated_devices_lock);
1818-
1819-
new_count = 0;
1820-
if (((isVapPrivate(rdk_vap_info->vap_index)) || (isVapXhs(rdk_vap_info->vap_index)))){
1821-
if (notify_associated_entries(&p_wifi_mgr->ctrl, rdk_vap_info->vap_index, new_count, old_count) != RETURN_OK) {
1822-
wifi_util_error_print(WIFI_CTRL,"%s:%d Unable to send notification for associated entries\n", __func__, __LINE__);
1849+
1850+
new_count = 0;
1851+
1852+
wifi_util_info_print(WIFI_CTRL,
1853+
"%s:%d Disassoc event for mac: %s - removed all assoclist entries\n",
1854+
__func__, __LINE__, mac_str);
1855+
} else {
1856+
assoc_dev_data_t *temp = hash_map_remove(rdk_vap_info->associated_devices_map,
1857+
mac_str);
1858+
if (temp != NULL) {
1859+
if (process_device_removal(rdk_vap_info, mac_str, temp,
1860+
p_wifi_mgr, &new_count, old_count) == RETURN_ERR) {
1861+
pthread_mutex_unlock(rdk_vap_info->associated_devices_lock);
1862+
return;
18231863
}
1864+
1865+
wifi_util_info_print(WIFI_CTRL,
1866+
"%s:%d Disassoc event for mac: %s - removed entry from hashmap\n",
1867+
__func__, __LINE__, mac_str);
1868+
}
1869+
}
1870+
1871+
if (new_count != old_count &&
1872+
(isVapPrivate(rdk_vap_info->vap_index) ||
1873+
isVapXhs(rdk_vap_info->vap_index))) {
1874+
if (notify_associated_entries(&p_wifi_mgr->ctrl, rdk_vap_info->vap_index,
1875+
new_count, old_count) != RETURN_OK) {
1876+
wifi_util_error_print(WIFI_CTRL,
1877+
"%s:%d Unable to send notification for associated entries\n",
1878+
__func__, __LINE__);
18241879
}
1825-
wifi_util_info_print(WIFI_CTRL,"%s:%d Disassoc event for mac: %s remove all assoclist entries\n", __func__, __LINE__, mac_str);
1880+
}
18261881

1882+
pthread_mutex_unlock(rdk_vap_info->associated_devices_lock);
1883+
}
1884+
1885+
void check_and_remove_mac_on_other_vaps(rdk_wifi_vap_info_t *current_vap_info,
1886+
assoc_dev_data_t *assoc_data)
1887+
{
1888+
if (assoc_data == NULL) {
18271889
return;
18281890
}
18291891

1830-
pthread_mutex_lock(rdk_vap_info->associated_devices_lock);
1831-
if (rdk_vap_info->associated_devices_map != NULL) {
1832-
old_count = hash_map_count(rdk_vap_info->associated_devices_map);
1892+
wifi_mgr_t *p_wifi_mgr = get_wifimgr_obj();
1893+
mac_addr_str_t mac_str;
1894+
to_mac_str(assoc_data->dev_stats.cli_MACAddress, mac_str);
1895+
1896+
unsigned int num_radios = getNumberRadios();
1897+
1898+
for (unsigned int vap_idx = 0; vap_idx < num_radios; vap_idx++) {
1899+
// Skip the VAP where device is currently associated
1900+
if ((int)vap_idx == assoc_data->ap_index) {
1901+
continue;
1902+
}
18331903

1834-
temp_assoc_dev_data = hash_map_remove(rdk_vap_info->associated_devices_map, mac_str);
1835-
if (temp_assoc_dev_data != NULL) {
1836-
temp_assoc_dev_data->client_state = client_state_disconnected;
1837-
if (add_client_diff_assoclist(&rdk_vap_info->associated_devices_diff_map, mac_str, temp_assoc_dev_data) == RETURN_ERR) {
1838-
wifi_util_error_print(WIFI_CTRL,"%s:%d Failed to update diff assoclist for vap %d mac_str : %s\n", __func__, __LINE__, rdk_vap_info->vap_index, mac_str);
1839-
free(temp_assoc_dev_data);
1840-
pthread_mutex_unlock(rdk_vap_info->associated_devices_lock);
1841-
return;
1842-
}
1843-
p_wifi_mgr->ctrl.webconfig_state |= ctrl_webconfig_state_associated_clients_cfg_rsp_pending;
1844-
temp_assoc_dev_data->dev_stats.cli_Active = false;
1845-
lm_notify_disassoc(temp_assoc_dev_data, rdk_vap_info->vap_index);
1846-
free(temp_assoc_dev_data);
1904+
rdk_wifi_vap_info_t *rdk_vap_info = get_wifidb_rdk_vap_info(vap_idx);
1905+
if (rdk_vap_info == NULL) {
1906+
continue;
18471907
}
18481908

1849-
new_count = old_count - 1;
1850-
if (((isVapPrivate(rdk_vap_info->vap_index)) || (isVapXhs(rdk_vap_info->vap_index)))){
1851-
if (notify_associated_entries(&p_wifi_mgr->ctrl, rdk_vap_info->vap_index, new_count, old_count) != RETURN_OK) {
1852-
wifi_util_error_print(WIFI_CTRL,"%s:%d Unable to send notification for associated entries\n", __func__, __LINE__);
1909+
pthread_mutex_lock(rdk_vap_info->associated_devices_lock);
1910+
1911+
if (rdk_vap_info->associated_devices_map == NULL) {
1912+
pthread_mutex_unlock(rdk_vap_info->associated_devices_lock);
1913+
continue;
1914+
}
1915+
1916+
ULONG old_count = hash_map_count(rdk_vap_info->associated_devices_map);
1917+
1918+
assoc_dev_data_t *removed_dev =
1919+
hash_map_remove(rdk_vap_info->associated_devices_map, mac_str);
1920+
1921+
if (removed_dev != NULL) {
1922+
ULONG new_count = old_count;
1923+
1924+
if (process_device_removal(rdk_vap_info, mac_str, removed_dev,
1925+
p_wifi_mgr, &new_count, old_count) == RETURN_ERR) {
1926+
pthread_mutex_unlock(rdk_vap_info->associated_devices_lock);
1927+
return;
18531928
}
1929+
1930+
wifi_util_info_print(WIFI_CTRL,
1931+
"%s:%d Removed MAC %s from VAP %d (roaming to VAP %d)\n",
1932+
__func__, __LINE__, mac_str, vap_idx, assoc_data->ap_index);
18541933
}
1855-
wifi_util_info_print(WIFI_CTRL,"%s:%d Disassoc event for mac : %s, Removed the entry from hashmap\n", __func__, __LINE__, mac_str);
18561934

1935+
pthread_mutex_unlock(rdk_vap_info->associated_devices_lock);
18571936
}
1858-
pthread_mutex_unlock(rdk_vap_info->associated_devices_lock);
18591937
}
18601938

18611939
void process_assoc_device_event(void *data)
@@ -1896,6 +1974,10 @@ void process_assoc_device_event(void *data)
18961974
memset(mac_str, 0, sizeof(mac_str));
18971975
to_mac_str(assoc_data->dev_stats.cli_MACAddress, mac_str);
18981976
str_tolower(mac_str);
1977+
1978+
//check and remove mac_str from other vaps if device is steering
1979+
check_and_remove_mac_on_other_vaps(rdk_vap_info, assoc_data);
1980+
18991981
tmp_assoc_dev_data = hash_map_get(rdk_vap_info->associated_devices_map, mac_str);
19001982
if (tmp_assoc_dev_data == NULL) {
19011983
old_count = hash_map_count(rdk_vap_info->associated_devices_map);

0 commit comments

Comments
 (0)