Hi,
we found a problem with NDK when changing IP address if there's an open UDP socket. In particular the stack hangs in a call to SockCleanPcb(SOCKPROT_UDP…), in SPIpNet() inside netsrv.c
To change IP address we follow this procedure:
/* get the current static IP entry */
CfgGetEntry(0, CFGTAG_IPNET, PHY_MAC_INTERFACE_INDEX, 1, &hCfgIpAddr);
/* remove the current static IP entry */
CfgRemoveEntry(0, hCfgIpAddr);
// Add the address to interface 1
CfgAddEntry(0, CFGTAG_IPNET, PHY_MAC_INTERFACE_INDEX, 0, sizeof(CI_IPNET), (UINT8 *) &NA, 0);
We fixed the problem adding the changes below in red to SPIpNet():
// Else if this is a "remove", remove the entry
else if( Op == CFGOP_REMOVE )
{
// If no network, return "pass"
if( !pi->hBind )
return(0);
// Remove the network MOVED AFTER the calls to SockCleanPcb()
//NtRemoveNetwork( pi->hBind );
//pi->hBind = 0;
/* BUG FIX SDSCM00014560
* When an IP address is modified we need to close the sockets of all existing
* applications. */
{
SockCleanPcb (SOCKPROT_TCP, pi->IPAddr);
SockCleanPcb (SOCKPROT_UDP, pi->IPAddr);
SockCleanPcb (SOCKPROT_RAW, pi->IPAddr);
}
NtRemoveNetwork( pi->hBind );
pi->hBind = 0;
// Notify NetCtrl
NC_IPUpdate( pi->IPAddr, Item, 0 );
}
QUESTION: does it make sense to you? Can you please confirm that this fix is correct?
Best regards
Massimo