Module Name: src
Committed By: seanb
Date: Tue Nov 25 15:04:37 UTC 2014
Modified Files:
src/sys/netinet: in_pcb.c in_pcb.h
src/sys/netinet6: in6_pcb.c
Log Message:
Clean up any dangling ifp references in (struct in6pcb *)->in6p_v4moptions
(v4 multicast options off v4 mapped v6 socket) on interface destruction. The
code to clean this up in a true v4 socket was moved to its own function
which is now also called in the corresponding place for v6 sockets on
interface destruction.
To generate a diff of this commit:
cvs rdiff -u -r1.153 -r1.154 src/sys/netinet/in_pcb.c
cvs rdiff -u -r1.54 -r1.55 src/sys/netinet/in_pcb.h
cvs rdiff -u -r1.132 -r1.133 src/sys/netinet6/in6_pcb.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/netinet/in_pcb.c
diff -u src/sys/netinet/in_pcb.c:1.153 src/sys/netinet/in_pcb.c:1.154
--- src/sys/netinet/in_pcb.c:1.153 Mon Nov 10 18:52:51 2014
+++ src/sys/netinet/in_pcb.c Tue Nov 25 15:04:37 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: in_pcb.c,v 1.153 2014/11/10 18:52:51 maxv Exp $ */
+/* $NetBSD: in_pcb.c,v 1.154 2014/11/25 15:04:37 seanb Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -93,7 +93,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in_pcb.c,v 1.153 2014/11/10 18:52:51 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in_pcb.c,v 1.154 2014/11/25 15:04:37 seanb Exp $");
#include "opt_inet.h"
#include "opt_ipsec.h"
@@ -698,40 +698,44 @@ in_pcbnotifyall(struct inpcbtable *table
}
void
+in_purgeifmcast(struct ip_moptions *imo, struct ifnet *ifp)
+{
+ int i, gap;
+
+ if (imo == NULL)
+ return;
+
+ /*
+ * Unselect the outgoing interface if it is being
+ * detached.
+ */
+ if (imo->imo_multicast_ifp == ifp)
+ imo->imo_multicast_ifp = NULL;
+
+ /*
+ * Drop multicast group membership if we joined
+ * through the interface being detached.
+ */
+ for (i = 0, gap = 0; i < imo->imo_num_memberships; i++) {
+ if (imo->imo_membership[i]->inm_ifp == ifp) {
+ in_delmulti(imo->imo_membership[i]);
+ gap++;
+ } else if (gap != 0)
+ imo->imo_membership[i - gap] = imo->imo_membership[i];
+ }
+ imo->imo_num_memberships -= gap;
+}
+
+void
in_pcbpurgeif0(struct inpcbtable *table, struct ifnet *ifp)
{
struct inpcb_hdr *inph, *ninph;
- struct ip_moptions *imo;
- int i, gap;
TAILQ_FOREACH_SAFE(inph, &table->inpt_queue, inph_queue, ninph) {
struct inpcb *inp = (struct inpcb *)inph;
if (inp->inp_af != AF_INET)
continue;
- imo = inp->inp_moptions;
- if (imo != NULL) {
- /*
- * Unselect the outgoing interface if it is being
- * detached.
- */
- if (imo->imo_multicast_ifp == ifp)
- imo->imo_multicast_ifp = NULL;
-
- /*
- * Drop multicast group membership if we joined
- * through the interface being detached.
- */
- for (i = 0, gap = 0; i < imo->imo_num_memberships;
- i++) {
- if (imo->imo_membership[i]->inm_ifp == ifp) {
- in_delmulti(imo->imo_membership[i]);
- gap++;
- } else if (gap != 0)
- imo->imo_membership[i - gap] =
- imo->imo_membership[i];
- }
- imo->imo_num_memberships -= gap;
- }
+ in_purgeifmcast(inp->inp_moptions, ifp);
}
}
Index: src/sys/netinet/in_pcb.h
diff -u src/sys/netinet/in_pcb.h:1.54 src/sys/netinet/in_pcb.h:1.55
--- src/sys/netinet/in_pcb.h:1.54 Tue Aug 5 05:24:26 2014
+++ src/sys/netinet/in_pcb.h Tue Nov 25 15:04:37 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: in_pcb.h,v 1.54 2014/08/05 05:24:26 rtr Exp $ */
+/* $NetBSD: in_pcb.h,v 1.55 2014/11/25 15:04:37 seanb Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -152,6 +152,7 @@ void in_pcbnotifyall(struct inpcbtable *
void (*)(struct inpcb *, int));
void in_pcbpurgeif0(struct inpcbtable *, struct ifnet *);
void in_pcbpurgeif(struct inpcbtable *, struct ifnet *);
+void in_purgeifmcast(struct ip_moptions *, struct ifnet *);
void in_pcbstate(struct inpcb *, int);
void in_rtchange(struct inpcb *, int);
void in_setpeeraddr(struct inpcb *, struct mbuf *);
Index: src/sys/netinet6/in6_pcb.c
diff -u src/sys/netinet6/in6_pcb.c:1.132 src/sys/netinet6/in6_pcb.c:1.133
--- src/sys/netinet6/in6_pcb.c:1.132 Fri Nov 14 17:34:23 2014
+++ src/sys/netinet6/in6_pcb.c Tue Nov 25 15:04:37 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: in6_pcb.c,v 1.132 2014/11/14 17:34:23 maxv Exp $ */
+/* $NetBSD: in6_pcb.c,v 1.133 2014/11/25 15:04:37 seanb Exp $ */
/* $KAME: in6_pcb.c,v 1.84 2001/02/08 18:02:08 itojun Exp $ */
/*
@@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in6_pcb.c,v 1.132 2014/11/14 17:34:23 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6_pcb.c,v 1.133 2014/11/25 15:04:37 seanb Exp $");
#include "opt_inet.h"
#include "opt_ipsec.h"
@@ -848,6 +848,7 @@ in6_pcbpurgeif0(struct inpcbtable *table
}
}
}
+ in_purgeifmcast(in6p->in6p_v4moptions, ifp);
}
}