net: ipv6: Allow joining to existing multicast address

If the multicast address already exists, then do not give
error but try to join it.

Change-Id: I32ffa6b3bf0798011d684a1a21e87e389f1f0380
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
Jukka Rissanen 2017-02-10 09:45:32 +02:00
commit 82267e7bd4
2 changed files with 19 additions and 3 deletions

View file

@ -648,6 +648,20 @@ static inline void net_if_ipv6_maddr_join(struct net_if_mcast_addr *addr)
addr->is_joined = true; addr->is_joined = true;
} }
/**
* @brief Check if given multicast address is joined or not.
*
* @param addr IPv6 multicast address
*
* @return True if address is joined, False otherwise.
*/
static inline bool net_if_ipv6_maddr_is_joined(struct net_if_mcast_addr *addr)
{
NET_ASSERT(addr);
return addr->is_joined;
}
/** /**
* @brief Mark a given multicast address to be left. * @brief Mark a given multicast address to be left.
* *

View file

@ -2288,13 +2288,15 @@ int net_ipv6_mld_join(struct net_if *iface, const struct in6_addr *addr)
int ret; int ret;
maddr = net_if_ipv6_maddr_lookup(addr, &iface); maddr = net_if_ipv6_maddr_lookup(addr, &iface);
if (maddr) { if (maddr && net_if_ipv6_maddr_is_joined(maddr)) {
return -EALREADY; return -EALREADY;
} }
maddr = net_if_ipv6_maddr_add(iface, addr);
if (!maddr) { if (!maddr) {
return -ENOMEM; maddr = net_if_ipv6_maddr_add(iface, addr);
if (!maddr) {
return -ENOMEM;
}
} }
ret = send_mldv2(iface, addr, NET_IPV6_MLDv2_MODE_IS_EXCLUDE); ret = send_mldv2(iface, addr, NET_IPV6_MLDv2_MODE_IS_EXCLUDE);