net: if: Leave all IPv4 mcast groups when interface goes down
In a similar way as its done for IPv6. This allows to rejoin the group once the interface is up again. Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit is contained in:
parent
4da1a75a6c
commit
e718c8c2dc
1 changed files with 22 additions and 0 deletions
|
@ -14,6 +14,7 @@ LOG_MODULE_REGISTER(net_if, CONFIG_NET_IF_LOG_LEVEL);
|
||||||
#include <syscall_handler.h>
|
#include <syscall_handler.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <net/igmp.h>
|
||||||
#include <net/net_core.h>
|
#include <net/net_core.h>
|
||||||
#include <net/net_pkt.h>
|
#include <net/net_pkt.h>
|
||||||
#include <net/net_if.h>
|
#include <net/net_if.h>
|
||||||
|
@ -3791,7 +3792,27 @@ static void iface_ipv4_init(int if_count)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void leave_ipv4_mcast_all(struct net_if *iface)
|
||||||
|
{
|
||||||
|
struct net_if_ipv4 *ipv4 = iface->config.ip.ipv4;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (!ipv4) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < NET_IF_MAX_IPV4_MADDR; i++) {
|
||||||
|
if (!ipv4->mcast[i].is_used ||
|
||||||
|
!ipv4->mcast[i].is_joined) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
net_ipv4_igmp_leave(iface, &ipv4->mcast[i].address.in_addr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
#define leave_ipv4_mcast_all(...)
|
||||||
#define iface_ipv4_init(...)
|
#define iface_ipv4_init(...)
|
||||||
|
|
||||||
struct net_if_mcast_addr *net_if_ipv4_maddr_lookup(const struct in_addr *addr,
|
struct net_if_mcast_addr *net_if_ipv4_maddr_lookup(const struct in_addr *addr,
|
||||||
|
@ -4065,6 +4086,7 @@ int net_if_down(struct net_if *iface)
|
||||||
k_mutex_lock(&lock, K_FOREVER);
|
k_mutex_lock(&lock, K_FOREVER);
|
||||||
|
|
||||||
leave_mcast_all(iface);
|
leave_mcast_all(iface);
|
||||||
|
leave_ipv4_mcast_all(iface);
|
||||||
|
|
||||||
if (net_if_is_ip_offloaded(iface)) {
|
if (net_if_is_ip_offloaded(iface)) {
|
||||||
goto done;
|
goto done;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue