summaryrefslogtreecommitdiffstats
path: root/sys/netinet
diff options
context:
space:
mode:
authordlg <dlg@openbsd.org>2015-09-10 13:19:25 +0000
committerdlg <dlg@openbsd.org>2015-09-10 13:19:25 +0000
commit1830f73ecda5bf430bf09f045264c8a9fc128b8d (patch)
treeba1e5f21de4af86f69eb5f703e19a0549adf1a1b /sys/netinet
parentRemove INT32 define and just use int, from Martijn van Duren and Michael (diff)
downloadwireguard-openbsd-1830f73ecda5bf430bf09f045264c8a9fc128b8d.tar.xz
wireguard-openbsd-1830f73ecda5bf430bf09f045264c8a9fc128b8d.zip
move the guts of igmp_input into a igmp_input_if function and call
it with the reference from if_get held so we can if_put it easly after the guts have run. ok claudio@
Diffstat (limited to 'sys/netinet')
-rw-r--r--sys/netinet/igmp.c36
1 files changed, 23 insertions, 13 deletions
diff --git a/sys/netinet/igmp.c b/sys/netinet/igmp.c
index c25b3f7a1ba..0101349372f 100644
--- a/sys/netinet/igmp.c
+++ b/sys/netinet/igmp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: igmp.c,v 1.50 2015/08/28 00:03:54 deraadt Exp $ */
+/* $OpenBSD: igmp.c,v 1.51 2015/09/10 13:19:25 dlg Exp $ */
/* $NetBSD: igmp.c,v 1.15 1996/02/13 23:41:25 christos Exp $ */
/*
@@ -107,6 +107,7 @@ void igmp_checktimer(struct ifnet *);
void igmp_sendpkt(struct in_multi *, int, in_addr_t);
int rti_fill(struct in_multi *);
struct router_info * rti_find(struct ifnet *);
+void igmp_input_if(struct ifnet *, struct mbuf *, int);
void
igmp_init(void)
@@ -183,7 +184,7 @@ rti_find(struct ifnet *ifp)
M_MRTABLE, M_NOWAIT);
if (rti == NULL)
return (NULL);
- rti->rti_ifp = ifp;
+ rti->rti_ifp = if_ref(ifp);
rti->rti_type = IGMP_v2_ROUTER;
rti->rti_next = rti_head;
rti_head = rti;
@@ -197,6 +198,7 @@ rti_delete(struct ifnet *ifp)
for (rti = rti_head; rti != 0; rti = rti->rti_next) {
if (rti->rti_ifp == ifp) {
+ if_put(ifp);
*prti = rti->rti_next;
free(rti, M_MRTABLE, sizeof(*rti));
break;
@@ -210,15 +212,6 @@ igmp_input(struct mbuf *m, ...)
{
int iphlen;
struct ifnet *ifp;
- struct ip *ip = mtod(m, struct ip *);
- struct igmp *igmp;
- int igmplen;
- int minlen;
- struct ifmaddr *ifma;
- struct in_multi *inm;
- struct router_info *rti;
- struct in_ifaddr *ia;
- int timer;
va_list ap;
va_start(ap, m);
@@ -227,13 +220,30 @@ igmp_input(struct mbuf *m, ...)
++igmpstat.igps_rcv_total;
- igmplen = ntohs(ip->ip_len) - iphlen;
-
ifp = if_get(m->m_pkthdr.ph_ifidx);
if (ifp == NULL) {
m_freem(m);
return;
}
+
+ igmp_input_if(ifp, m, iphlen);
+ if_put(ifp);
+}
+
+void
+igmp_input_if(struct ifnet *ifp, struct mbuf *m, int iphlen)
+{
+ struct ip *ip = mtod(m, struct ip *);
+ struct igmp *igmp;
+ int igmplen;
+ int minlen;
+ struct ifmaddr *ifma;
+ struct in_multi *inm;
+ struct router_info *rti;
+ struct in_ifaddr *ia;
+ int timer;
+
+ igmplen = ntohs(ip->ip_len) - iphlen;
/*
* Validate lengths