Skip to content

Commit e0a1e91

Browse files
rluboskartben
authored andcommitted
net: ip: igmp: Ensure IGMP APIs work with offloaded interfaces
IGMP APIs are commonly used across the codebase to configure IPv4 multicast addresses on network interfaces. Sending IGMP reports however works only for native interfaces as it uses low-level APIs. Therefore, in order to make the APIs at least semi-functional for offloaded interfaces as well (i.e. allow to configure multicast address on the interface), return early in case interface is offloaded. Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
1 parent 4d01228 commit e0a1e91

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

subsys/net/ip/igmp.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ int net_ipv4_igmp_join(struct net_if *iface, const struct in_addr *addr,
584584
const struct igmp_param *param)
585585
{
586586
struct net_if_mcast_addr *maddr;
587-
int ret;
587+
int ret = 0;
588588

589589
#if defined(CONFIG_NET_IPV4_IGMPV3)
590590
if (param != NULL) {
@@ -622,6 +622,10 @@ int net_ipv4_igmp_join(struct net_if *iface, const struct in_addr *addr,
622622

623623
net_if_ipv4_maddr_join(iface, maddr);
624624

625+
if (net_if_is_offloaded(iface)) {
626+
goto out;
627+
}
628+
625629
#if defined(CONFIG_NET_IPV4_IGMPV3)
626630
ret = igmpv3_send_generic(iface, maddr);
627631
#else
@@ -640,6 +644,7 @@ int net_ipv4_igmp_join(struct net_if *iface, const struct in_addr *addr,
640644
}
641645
#endif
642646

647+
out:
643648
net_if_mcast_monitor(iface, &maddr->address, true);
644649

645650
net_mgmt_event_notify_with_info(NET_EVENT_IPV4_MCAST_JOIN, iface, &maddr->address.in_addr,
@@ -651,13 +656,17 @@ int net_ipv4_igmp_join(struct net_if *iface, const struct in_addr *addr,
651656
int net_ipv4_igmp_leave(struct net_if *iface, const struct in_addr *addr)
652657
{
653658
struct net_if_mcast_addr *maddr;
654-
int ret;
659+
int ret = 0;
655660

656661
maddr = net_if_ipv4_maddr_lookup(addr, &iface);
657662
if (!maddr) {
658663
return -ENOENT;
659664
}
660665

666+
if (net_if_is_offloaded(iface)) {
667+
goto out;
668+
}
669+
661670
#if defined(CONFIG_NET_IPV4_IGMPV3)
662671
maddr->record_type = IGMPV3_CHANGE_TO_INCLUDE_MODE;
663672
maddr->sources_len = 0;
@@ -670,6 +679,7 @@ int net_ipv4_igmp_leave(struct net_if *iface, const struct in_addr *addr)
670679
return ret;
671680
}
672681

682+
out:
673683
if (!net_if_ipv4_maddr_rm(iface, addr)) {
674684
return -EINVAL;
675685
}

0 commit comments

Comments
 (0)