From 8c52afb6ca2108153d020e5fc214ad8df7e9ebc7 Mon Sep 17 00:00:00 2001 From: Dirk Ziegelmeier Date: Sat, 1 Oct 2016 17:28:36 +0200 Subject: [PATCH] igmp: Optimize code by always skipping the first entry in the linked groups list - it is always the "allsystems" entry --- src/core/ipv4/igmp.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/core/ipv4/igmp.c b/src/core/ipv4/igmp.c index ab20b883..45388aa7 100644 --- a/src/core/ipv4/igmp.c +++ b/src/core/ipv4/igmp.c @@ -195,10 +195,13 @@ igmp_report_groups(struct netif *netif) LWIP_DEBUGF(IGMP_DEBUG, ("igmp_report_groups: sending IGMP reports on if %p\n", (void*)netif)); + /* Skip the first group in the list, it is always the allsystems group added in igmp_start() */ + if(group != NULL) { + group = group->next; + } + while (group != NULL) { - if (!(ip4_addr_cmp(&(group->group_address), &allsystems))) { - igmp_delaying_member(group, IGMP_JOIN_DELAYING_MEMBER_TMR); - } + igmp_delaying_member(group, IGMP_JOIN_DELAYING_MEMBER_TMR); group = group->next; } } @@ -368,11 +371,15 @@ igmp_input(struct pbuf *p, struct netif *inp, const ip4_addr_t *dest) } groupref = netif_igmp_data(inp); + + /* Do not send messages on the all systems group address! */ + /* Skip the first group in the list, it is always the allsystems group added in igmp_start() */ + if(group != NULL) { + group = group->next; + } + while (groupref) { - /* Do not send messages on the all systems group address! */ - if (!(ip4_addr_cmp(&(groupref->group_address), &allsystems))) { - igmp_delaying_member(groupref, igmp->igmp_maxresp); - } + igmp_delaying_member(groupref, igmp->igmp_maxresp); groupref = groupref->next; } } else {