-/* $OpenBSD: igmp.c,v 1.77 2021/12/15 15:58:01 bluhm Exp $ */
+/* $OpenBSD: igmp.c,v 1.78 2022/03/28 16:31:26 bluhm Exp $ */
/* $NetBSD: igmp.c,v 1.15 1996/02/13 23:41:25 christos Exp $ */
/*
}
void
-igmp_joingroup(struct in_multi *inm)
+igmp_joingroup(struct in_multi *inm, struct ifnet *ifp)
{
- struct ifnet* ifp;
int i;
- ifp = if_get(inm->inm_ifidx);
-
inm->inm_state = IGMP_IDLE_MEMBER;
if (!IN_LOCAL_GROUP(inm->inm_addr.s_addr) &&
- ifp && (ifp->if_flags & IFF_LOOPBACK) == 0) {
+ (ifp->if_flags & IFF_LOOPBACK) == 0) {
i = rti_fill(inm);
igmp_sendpkt(ifp, inm, i, 0);
inm->inm_state = IGMP_DELAYING_MEMBER;
igmp_timers_are_running = 1;
} else
inm->inm_timer = 0;
-
- if_put(ifp);
}
void
-igmp_leavegroup(struct in_multi *inm)
+igmp_leavegroup(struct in_multi *inm, struct ifnet *ifp)
{
- struct ifnet* ifp;
-
- ifp = if_get(inm->inm_ifidx);
-
switch (inm->inm_state) {
case IGMP_DELAYING_MEMBER:
case IGMP_IDLE_MEMBER:
if (!IN_LOCAL_GROUP(inm->inm_addr.s_addr) &&
- ifp && (ifp->if_flags & IFF_LOOPBACK) == 0)
+ (ifp->if_flags & IFF_LOOPBACK) == 0)
if (inm->inm_rti->rti_type != IGMP_v1_ROUTER)
igmp_sendpkt(ifp, inm,
IGMP_HOST_LEAVE_MESSAGE,
case IGMP_SLEEPING_MEMBER:
break;
}
- if_put(ifp);
}
void
-/* $OpenBSD: igmp_var.h,v 1.14 2020/08/17 16:25:34 gnezdo Exp $ */
+/* $OpenBSD: igmp_var.h,v 1.15 2022/03/28 16:31:26 bluhm Exp $ */
/* $NetBSD: igmp_var.h,v 1.9 1996/02/13 23:41:31 christos Exp $ */
/*
void igmp_init(void);
int igmp_input(struct mbuf **, int *, int, int);
-void igmp_joingroup(struct in_multi *);
-void igmp_leavegroup(struct in_multi *);
+void igmp_joingroup(struct in_multi *, struct ifnet *);
+void igmp_leavegroup(struct in_multi *, struct ifnet *);
void igmp_fasttimo(void);
void igmp_slowtimo(void);
int igmp_sysctl(int *, u_int, void *, size_t *, void *, size_t);
-/* $OpenBSD: in.c,v 1.172 2022/03/04 21:09:03 bluhm Exp $ */
+/* $OpenBSD: in.c,v 1.173 2022/03/28 16:31:26 bluhm Exp $ */
/* $NetBSD: in.c,v 1.26 1996/02/13 23:41:39 christos Exp $ */
/*
/*
* Let IGMP know that we have joined a new IP multicast group.
*/
- igmp_joingroup(inm);
+ igmp_joingroup(inm, ifp);
}
return (inm);
NET_ASSERT_LOCKED();
- if (--inm->inm_refcnt == 0) {
+ if (--inm->inm_refcnt != 0)
+ return;
+
+ ifp = if_get(inm->inm_ifidx);
+ if (ifp != NULL) {
/*
* No remaining claims to this record; let IGMP know that
* we are leaving the multicast group.
*/
- igmp_leavegroup(inm);
- ifp = if_get(inm->inm_ifidx);
+ igmp_leavegroup(inm, ifp);
/*
* Notify the network driver to update its multicast
* reception filter.
*/
- if (ifp != NULL) {
- memset(&ifr, 0, sizeof(ifr));
- satosin(&ifr.ifr_addr)->sin_len =
- sizeof(struct sockaddr_in);
- satosin(&ifr.ifr_addr)->sin_family = AF_INET;
- satosin(&ifr.ifr_addr)->sin_addr = inm->inm_addr;
- KERNEL_LOCK();
- (*ifp->if_ioctl)(ifp, SIOCDELMULTI, (caddr_t)&ifr);
- KERNEL_UNLOCK();
-
- TAILQ_REMOVE(&ifp->if_maddrlist, &inm->inm_ifma,
- ifma_list);
- }
- if_put(ifp);
-
- free(inm, M_IPMADDR, sizeof(*inm));
+ memset(&ifr, 0, sizeof(ifr));
+ satosin(&ifr.ifr_addr)->sin_len = sizeof(struct sockaddr_in);
+ satosin(&ifr.ifr_addr)->sin_family = AF_INET;
+ satosin(&ifr.ifr_addr)->sin_addr = inm->inm_addr;
+ KERNEL_LOCK();
+ (*ifp->if_ioctl)(ifp, SIOCDELMULTI, (caddr_t)&ifr);
+ KERNEL_UNLOCK();
+
+ TAILQ_REMOVE(&ifp->if_maddrlist, &inm->inm_ifma, ifma_list);
}
+ if_put(ifp);
+
+ free(inm, M_IPMADDR, sizeof(*inm));
}
/*