From 863f61726257ab73848e820ea94984b6f3b3a0db Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sat, 3 Nov 2018 07:06:30 -0600 Subject: [PATCH] net/igmp and net/mld: Fix problem when both IGMP and MLD are enabled. The cannot share the same group list in the network devices structure. --- include/nuttx/net/igmp.h | 2 +- include/nuttx/net/netdev.h | 14 +++++++++++--- net/igmp/igmp_group.c | 6 +++--- net/igmp/igmp_initialize.c | 2 +- net/igmp/igmp_input.c | 2 +- net/igmp/igmp_poll.c | 2 +- net/igmp/igmp_send.c | 2 +- net/mld/mld_group.c | 6 +++--- net/mld/mld_initialize.c | 2 +- net/mld/mld_poll.c | 2 +- net/mld/mld_query.c | 2 +- 11 files changed, 25 insertions(+), 17 deletions(-) diff --git a/include/nuttx/net/igmp.h b/include/nuttx/net/igmp.h index 0efc3b9ba6..5d03f2f072 100644 --- a/include/nuttx/net/igmp.h +++ b/include/nuttx/net/igmp.h @@ -140,7 +140,7 @@ struct igmp_iphdr_s /* Router Alert IP header option */ - uint16_t ra[2]; + uint16_t ra[2]; /* RFC 2113 */ /* IGMPv2 header: * diff --git a/include/nuttx/net/netdev.h b/include/nuttx/net/netdev.h index faa665f860..ebd7417f08 100644 --- a/include/nuttx/net/netdev.h +++ b/include/nuttx/net/netdev.h @@ -344,10 +344,18 @@ struct net_driver_s uint16_t d_sndlen; -#ifdef CONFIG_NET_MCASTGROUP - /* IGMP/MLD group list */ + /* Multicast group support */ - sq_queue_t grplist; +#ifdef CONFIG_NET_IGMP + /* IGMP group list */ + + sq_queue_t d_igmp_grplist; +#endif + +#ifdef CONFIG_NET_MCASTGROUP + /* MLD group list */ + + sq_queue_t d_mld_grplist; #endif #ifdef CONFIG_NETDEV_STATISTICS diff --git a/net/igmp/igmp_group.c b/net/igmp/igmp_group.c index 95e1ef2542..cb240b6c97 100644 --- a/net/igmp/igmp_group.c +++ b/net/igmp/igmp_group.c @@ -143,7 +143,7 @@ FAR struct igmp_group_s *igmp_grpalloc(FAR struct net_driver_s *dev, /* Add the group structure to the list in the device structure */ - sq_addfirst((FAR sq_entry_t *)group, &dev->grplist); + sq_addfirst((FAR sq_entry_t *)group, &dev->d_igmp_grplist); net_unlock(); } @@ -166,7 +166,7 @@ FAR struct igmp_group_s *igmp_grpfind(FAR struct net_driver_s *dev, grpinfo("Searching for addr %08x\n", (int)*addr); net_lock(); - for (group = (FAR struct igmp_group_s *)dev->grplist.head; + for (group = (FAR struct igmp_group_s *)dev->d_igmp_grplist.head; group; group = group->next) { @@ -225,7 +225,7 @@ void igmp_grpfree(FAR struct net_driver_s *dev, FAR struct igmp_group_s *group) /* Remove the group structure from the group list in the device structure */ - sq_rem((FAR sq_entry_t *)group, &dev->grplist); + sq_rem((FAR sq_entry_t *)group, &dev->d_igmp_grplist); /* Destroy the wait semaphore */ diff --git a/net/igmp/igmp_initialize.c b/net/igmp/igmp_initialize.c index 246771f6ca..97a69781f3 100644 --- a/net/igmp/igmp_initialize.c +++ b/net/igmp/igmp_initialize.c @@ -94,7 +94,7 @@ void igmp_initialize(void) void igmp_devinit(struct net_driver_s *dev) { ninfo("IGMP initializing dev %p\n", dev); - DEBUGASSERT(dev->grplist.head == NULL); + DEBUGASSERT(dev->d_igmp_grplist.head == NULL); /* Add the all systems address to the group */ diff --git a/net/igmp/igmp_input.c b/net/igmp/igmp_input.c index b0995d0bea..789b806925 100644 --- a/net/igmp/igmp_input.c +++ b/net/igmp/igmp_input.c @@ -196,7 +196,7 @@ void igmp_input(struct net_driver_s *dev) } IGMP_STATINCR(g_netstats.igmp.query_received); - for (member = (FAR struct igmp_group_s *)dev->grplist.head; + for (member = (FAR struct igmp_group_s *)dev->d_igmp_grplist.head; member; member = member->next) { diff --git a/net/igmp/igmp_poll.c b/net/igmp/igmp_poll.c index 49801a088e..c9d0a32fe4 100644 --- a/net/igmp/igmp_poll.c +++ b/net/igmp/igmp_poll.c @@ -152,7 +152,7 @@ void igmp_poll(FAR struct net_driver_s *dev) /* Check each member of the group */ - for (group = (FAR struct igmp_group_s *)dev->grplist.head; + for (group = (FAR struct igmp_group_s *)dev->d_igmp_grplist.head; group; group = group->next) { diff --git a/net/igmp/igmp_send.c b/net/igmp/igmp_send.c index fd0d90c14e..8230f1e3f9 100644 --- a/net/igmp/igmp_send.c +++ b/net/igmp/igmp_send.c @@ -129,7 +129,7 @@ void igmp_send(FAR struct net_driver_s *dev, FAR struct igmp_group_s *group, dev->d_sndlen = IGMP_HDRLEN; - /* Add the router alert option */ + /* Add the router alert option (RFC 2113) */ IGMPBUF->ra[0] = HTONS(IPOPT_RA >> 16); IGMPBUF->ra[1] = HTONS(IPOPT_RA & 0xffff); diff --git a/net/mld/mld_group.c b/net/mld/mld_group.c index 513debdba6..8583cc7ed5 100644 --- a/net/mld/mld_group.c +++ b/net/mld/mld_group.c @@ -138,7 +138,7 @@ FAR struct mld_group_s *mld_grpalloc(FAR struct net_driver_s *dev, /* Add the group structure to the list in the device structure */ - sq_addfirst((FAR sq_entry_t *)group, &dev->grplist); + sq_addfirst((FAR sq_entry_t *)group, &dev->d_mld_grplist); net_unlock(); } @@ -161,7 +161,7 @@ FAR struct mld_group_s *mld_grpfind(FAR struct net_driver_s *dev, grpinfo("Searching for addr %08x\n", (int)*addr); net_lock(); - for (group = (FAR struct mld_group_s *)dev->grplist.head; + for (group = (FAR struct mld_group_s *)dev->d_mld_grplist.head; group; group = group->next) { @@ -227,7 +227,7 @@ void mld_grpfree(FAR struct net_driver_s *dev, FAR struct mld_group_s *group) /* Remove the group structure from the group list in the device structure */ - sq_rem((FAR sq_entry_t *)group, &dev->grplist); + sq_rem((FAR sq_entry_t *)group, &dev->d_mld_grplist); /* Destroy the wait semaphore */ diff --git a/net/mld/mld_initialize.c b/net/mld/mld_initialize.c index e1514cded0..a224054ade 100644 --- a/net/mld/mld_initialize.c +++ b/net/mld/mld_initialize.c @@ -77,7 +77,7 @@ void mld_initialize(void) void mld_devinit(struct net_driver_s *dev) { ninfo("MLD initializing dev %p\n", dev); - DEBUGASSERT(dev->grplist.head == NULL); + DEBUGASSERT(dev->d_mld_grplist.head == NULL); /* Add the all nodes address to the group */ diff --git a/net/mld/mld_poll.c b/net/mld/mld_poll.c index 63c49b0c9c..50be5d2fec 100644 --- a/net/mld/mld_poll.c +++ b/net/mld/mld_poll.c @@ -156,7 +156,7 @@ void mld_poll(FAR struct net_driver_s *dev) /* Check each member of the group */ - for (group = (FAR struct mld_group_s *)dev->grplist.head; + for (group = (FAR struct mld_group_s *)dev->d_mld_grplist.head; group; group = group->next) { diff --git a/net/mld/mld_query.c b/net/mld/mld_query.c index 753d69adfd..9c0a96de94 100644 --- a/net/mld/mld_query.c +++ b/net/mld/mld_query.c @@ -133,7 +133,7 @@ int mld_query(FAR struct net_driver_s *dev, ninfo("General multicast query\n"); MLD_STATINCR(g_netstats.mld.gmq_query_received); - for (member = (FAR struct mld_group_s *)dev->grplist.head; + for (member = (FAR struct mld_group_s *)dev->d_mld_grplist.head; member; member = member->next) {