Pairing fails when IPv6 enabled in SoftAP intf

Issue: udp_sendto() Fails for multicast IPV6 packet when interface is switched from SoftAP to STA mode.
When SoftAP start is called,  add_ethernet_interface() will be called internally to add interface details into  netif_list.
When switching from SoftAP to STA mode,  add_ethernet_interface() will be called again to append the interace details into netif_list.
When udp_sendto() is called, ip6_route() will return interface as NULL since it consider device as single interface.
Fix: SoftAP mode Stop, call remove_ethernet_interface() to remove the interface from the netif_list.
pull/12312/head
Arun S 2020-01-17 16:33:34 +05:30
parent fd22997b60
commit 18285e1fc1
5 changed files with 67 additions and 0 deletions

View File

@ -465,6 +465,41 @@ nsapi_error_t LWIP::add_ethernet_interface(EMAC &emac, bool default_if, OnboardN
#endif //LWIP_ETHERNET
}
nsapi_error_t LWIP::remove_ethernet_interface(OnboardNetworkStack::Interface **interface_out)
{
#if LWIP_ETHERNET
if ((interface_out != NULL) && (*interface_out != NULL)) {
Interface *lwip = static_cast<Interface *>(*interface_out);
Interface *node = lwip->list;
if (lwip->list != NULL) {
if (lwip->list == lwip) {
lwip->list = lwip->list->next;
netif_remove(&node->netif);
*interface_out = NULL;
delete node;
} else {
while (node->next != NULL && node->next != lwip) {
node = node->next;
}
if (node->next != NULL && node->next == lwip) {
Interface *remove = node->next;
node->next = node->next->next;
netif_remove(&remove->netif);
*interface_out = NULL;
delete remove;
}
}
}
}
return NSAPI_ERROR_OK;
#else
return NSAPI_ERROR_UNSUPPORTED;
#endif //LWIP_ETHERNET
}
nsapi_error_t LWIP::add_l3ip_interface(L3IP &l3ip, bool default_if, OnboardNetworkStack::Interface **interface_out)
{

View File

@ -281,6 +281,14 @@ public:
* @param[out] interface_out pointer to stack interface object controlling the L3IP
* @return NSAPI_ERROR_OK on success, or error code
*/
virtual nsapi_error_t remove_ethernet_interface(OnboardNetworkStack::Interface **interface_out);
/** Remove a network interface from IP stack
*
* Removes PPP objects,network interface from stack list, and shutdown device driver.
* @param[out] interface_out pointer to stack interface object controlling the PPP
* @return NSAPI_ERROR_OK on success, or error code
*/
virtual nsapi_error_t remove_l3ip_interface(OnboardNetworkStack::Interface **interface_out);
/** Remove a network interface from IP stack

View File

@ -181,6 +181,11 @@ public:
return NSAPI_ERROR_UNSUPPORTED;
};
virtual nsapi_error_t remove_ethernet_interface(Interface **interface_out)
{
return NSAPI_ERROR_OK;
};
virtual nsapi_error_t remove_l3ip_interface(Interface **interface_out)
{
return NSAPI_ERROR_OK;

View File

@ -355,6 +355,15 @@ nsapi_error_t WhdSTAInterface::disconnect()
}
whd_emac_wifi_link_state_changed(_whd_emac.ifp, WHD_FALSE);
// remove the interface added in connect
if (_interface) {
nsapi_error_t err = _stack.remove_ethernet_interface(&_interface);
if (err != NSAPI_ERROR_OK) {
return err;
}
_iface_shared.iface_sta = NULL;
}
res = whd_wifi_deregister_event_handler(_whd_emac.ifp, sta_link_update_entry);
if (res != WHD_SUCCESS) {
return whd_toerror(res);

View File

@ -201,6 +201,16 @@ int WhdSoftAPInterface::stop(void)
if (res != WHD_SUCCESS) {
return whd_toerror(res);
}
// remove the interface added in start
if (_interface) {
nsapi_error_t err = _stack.remove_ethernet_interface(&_interface);
if (err != NSAPI_ERROR_OK) {
return err;
}
_iface_shared.iface_softap = NULL;
}
return NSAPI_ERROR_OK;
}