Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Clean up any dangling ifp references in (struct in6pcb *...
details: https://anonhg.NetBSD.org/src/rev/4f0894085a0b
branches: trunk
changeset: 804141:4f0894085a0b
user: seanb <seanb%NetBSD.org@localhost>
date: Tue Nov 25 15:04:37 2014 +0000
description:
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.
diffstat:
sys/netinet/in_pcb.c | 60 ++++++++++++++++++++++++++-----------------------
sys/netinet/in_pcb.h | 3 +-
sys/netinet6/in6_pcb.c | 5 ++-
3 files changed, 37 insertions(+), 31 deletions(-)
diffs (132 lines):
diff -r bb7e69979625 -r 4f0894085a0b sys/netinet/in_pcb.c
--- a/sys/netinet/in_pcb.c Tue Nov 25 14:30:05 2014 +0000
+++ b/sys/netinet/in_pcb.c Tue Nov 25 15:04:37 2014 +0000
@@ -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 @@
}
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);
}
}
diff -r bb7e69979625 -r 4f0894085a0b sys/netinet/in_pcb.h
--- a/sys/netinet/in_pcb.h Tue Nov 25 14:30:05 2014 +0000
+++ b/sys/netinet/in_pcb.h Tue Nov 25 15:04:37 2014 +0000
@@ -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 (*)(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 *);
diff -r bb7e69979625 -r 4f0894085a0b sys/netinet6/in6_pcb.c
--- a/sys/netinet6/in6_pcb.c Tue Nov 25 14:30:05 2014 +0000
+++ b/sys/netinet6/in6_pcb.c Tue Nov 25 15:04:37 2014 +0000
@@ -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 @@
}
}
}
+ in_purgeifmcast(in6p->in6p_v4moptions, ifp);
}
}
Home |
Main Index |
Thread Index |
Old Index