mirror of
https://github.com/apache/nuttx.git
synced 2026-05-21 04:52:02 +08:00
mld: free all mld group when netdev unregister
otherwise, if the mld timers are not cancelled, an illegal address will be accessed after timeout. to avoid this scenario, when the network card is unregistered, all MLD timers must be attempted to be synchronously cancelled. Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
This commit is contained in:
committed by
Alan C. Assis
parent
c2a4899941
commit
a0bd741387
@@ -330,6 +330,16 @@ FAR struct mld_group_s *mld_grpallocfind(FAR struct net_driver_s *dev,
|
||||
void mld_grpfree(FAR struct net_driver_s *dev,
|
||||
FAR struct mld_group_s *group);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: mld_grpfree_all
|
||||
*
|
||||
* Description:
|
||||
* Release all previously allocated groups for a device.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void mld_grpfree_all(FAR struct net_driver_s *dev);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: mld_new_pollcycle
|
||||
*
|
||||
|
||||
@@ -285,4 +285,29 @@ void mld_new_pollcycle(FAR struct net_driver_s *dev)
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: mld_grpfree_all
|
||||
*
|
||||
* Description:
|
||||
* Release all previously allocated groups for a device.
|
||||
*
|
||||
* Assumptions:
|
||||
* The network is locked.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void mld_grpfree_all(FAR struct net_driver_s *dev)
|
||||
{
|
||||
FAR struct mld_group_s *group =
|
||||
(FAR struct mld_group_s *)dev->d_mld.grplist.head;
|
||||
FAR struct mld_group_s *next;
|
||||
|
||||
while (group != NULL)
|
||||
{
|
||||
next = group->next;
|
||||
mld_grpfree(dev, group);
|
||||
group = next;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* CONFIG_NET_MLD */
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include <net/ethernet.h>
|
||||
#include <nuttx/net/netdev.h>
|
||||
|
||||
#include "mld/mld.h"
|
||||
#include "utils/utils.h"
|
||||
#include "netdev/netdev.h"
|
||||
|
||||
@@ -150,6 +151,16 @@ int netdev_unregister(FAR struct net_driver_s *dev)
|
||||
#ifdef CONFIG_NETDEV_IFINDEX
|
||||
free_ifindex(dev->d_ifindex);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_MLD
|
||||
if ((dev->d_flags & IFF_MULTICAST) != 0)
|
||||
{
|
||||
/* MLD is only supported on multicast capable devices */
|
||||
|
||||
mld_grpfree_all(dev);
|
||||
}
|
||||
#endif
|
||||
|
||||
net_unlock();
|
||||
|
||||
#if CONFIG_NETDEV_STATISTICS_LOG_PERIOD > 0
|
||||
|
||||
Reference in New Issue
Block a user