Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Apply pserialize to some iterations of IP address lists
details: https://anonhg.NetBSD.org/src/rev/6530d85d1c4f
branches: trunk
changeset: 816719:6530d85d1c4f
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Wed Jul 20 07:37:51 2016 +0000
description:
Apply pserialize to some iterations of IP address lists
diffstat:
sys/compat/svr4/svr4_sockio.c | 6 ++++--
sys/dev/qbus/if_dmc.c | 9 ++++++---
sys/dist/pf/net/pf_if.c | 9 +++++++--
sys/net/agr/if_agr.c | 8 ++++++--
sys/netinet6/in6.c | 18 ++++++++++++++----
sys/netinet6/in6_ifattach.c | 6 ++++--
sys/netinet6/mld6.c | 8 ++++++--
sys/netinet6/nd6_rtr.c | 8 ++++++--
sys/netipsec/key.c | 23 +++++++++++++++++------
9 files changed, 70 insertions(+), 25 deletions(-)
diffs (truncated from 410 to 300 lines):
diff -r 3bd503d00747 -r 6530d85d1c4f sys/compat/svr4/svr4_sockio.c
--- a/sys/compat/svr4/svr4_sockio.c Wed Jul 20 03:38:09 2016 +0000
+++ b/sys/compat/svr4/svr4_sockio.c Wed Jul 20 07:37:51 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: svr4_sockio.c,v 1.38 2016/07/07 09:32:02 ozaki-r Exp $ */
+/* $NetBSD: svr4_sockio.c,v 1.39 2016/07/20 07:37:51 ozaki-r Exp $ */
/*-
* Copyright (c) 1995, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: svr4_sockio.c,v 1.38 2016/07/07 09:32:02 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: svr4_sockio.c,v 1.39 2016/07/20 07:37:51 ozaki-r Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@@ -87,10 +87,12 @@
{
struct ifaddr *ifa;
int ifnum = 0;
+ int s = pserialize_read_enter();
IFADDR_READER_FOREACH(ifa, ifp)
ifnum++;
+ pserialize_read_exit(s);
return MAX(1, ifnum);
}
diff -r 3bd503d00747 -r 6530d85d1c4f sys/dev/qbus/if_dmc.c
--- a/sys/dev/qbus/if_dmc.c Wed Jul 20 03:38:09 2016 +0000
+++ b/sys/dev/qbus/if_dmc.c Wed Jul 20 07:37:51 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_dmc.c,v 1.25 2016/07/07 09:32:02 ozaki-r Exp $ */
+/* $NetBSD: if_dmc.c,v 1.26 2016/07/20 07:37:51 ozaki-r Exp $ */
/*
* Copyright (c) 1982, 1986 Regents of the University of California.
* All rights reserved.
@@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_dmc.c,v 1.25 2016/07/07 09:32:02 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_dmc.c,v 1.26 2016/07/20 07:37:51 ozaki-r Exp $");
#undef DMCDEBUG /* for base table dump on fatal error */
@@ -313,9 +313,12 @@
* Check to see that an address has been set
* (both local and destination for an address family).
*/
- IFADDR_READER_FOREACH(ifa, ifp)
+ s = pserialize_read_enter();
+ IFADDR_READER_FOREACH(ifa, ifp) {
if (ifa->ifa_addr->sa_family && ifa->ifa_dstaddr->sa_family)
break;
+ }
+ pserialize_read_exit(s);
if (ifa == NULL)
return 0;
diff -r 3bd503d00747 -r 6530d85d1c4f sys/dist/pf/net/pf_if.c
--- a/sys/dist/pf/net/pf_if.c Wed Jul 20 03:38:09 2016 +0000
+++ b/sys/dist/pf/net/pf_if.c Wed Jul 20 07:37:51 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pf_if.c,v 1.30 2016/07/07 09:32:02 ozaki-r Exp $ */
+/* $NetBSD: pf_if.c,v 1.31 2016/07/20 07:37:51 ozaki-r Exp $ */
/* $OpenBSD: pf_if.c,v 1.47 2007/07/13 09:17:48 markus Exp $ */
/*
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pf_if.c,v 1.30 2016/07/07 09:32:02 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pf_if.c,v 1.31 2016/07/20 07:37:51 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -556,9 +556,13 @@
struct ifaddr *ia;
int got4 = 0, got6 = 0;
int net2, af;
+ int s;
if (ifp == NULL)
return;
+
+ /* Depends on pfi_address_add doesn't sleep */
+ s = pserialize_read_enter();
IFADDR_READER_FOREACH(ia, ifp) {
af = ia->ifa_addr->sa_family;
if (af != AF_INET && af != AF_INET6)
@@ -603,6 +607,7 @@
else
pfi_address_add(ia->ifa_addr, af, net2);
}
+ pserialize_read_exit(s);
}
void
diff -r 3bd503d00747 -r 6530d85d1c4f sys/net/agr/if_agr.c
--- a/sys/net/agr/if_agr.c Wed Jul 20 03:38:09 2016 +0000
+++ b/sys/net/agr/if_agr.c Wed Jul 20 07:37:51 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_agr.c,v 1.37 2016/07/07 09:32:02 ozaki-r Exp $ */
+/* $NetBSD: if_agr.c,v 1.38 2016/07/20 07:37:51 ozaki-r Exp $ */
/*-
* Copyright (c)2005 YAMAMOTO Takashi,
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_agr.c,v 1.37 2016/07/07 09:32:02 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_agr.c,v 1.38 2016/07/20 07:37:51 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -567,6 +567,7 @@
struct agr_softc *sc = ifp->if_softc;
struct agr_port *port = NULL;
int error = 0;
+ int s;
if (ifp_port->if_ioctl == NULL) {
error = EOPNOTSUPP;
@@ -591,12 +592,15 @@
}
port->port_flags = AGRPORT_LARVAL;
+ s = pserialize_read_enter();
IFADDR_READER_FOREACH(ifa, ifp_port) {
if (ifa->ifa_addr->sa_family != AF_LINK) {
+ pserialize_read_exit(s);
error = EBUSY;
goto out;
}
}
+ pserialize_read_exit(s);
if (sc->sc_nports == 0) {
switch (ifp_port->if_type) {
diff -r 3bd503d00747 -r 6530d85d1c4f sys/netinet6/in6.c
--- a/sys/netinet6/in6.c Wed Jul 20 03:38:09 2016 +0000
+++ b/sys/netinet6/in6.c Wed Jul 20 07:37:51 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: in6.c,v 1.209 2016/07/15 07:40:09 ozaki-r Exp $ */
+/* $NetBSD: in6.c,v 1.210 2016/07/20 07:37:51 ozaki-r Exp $ */
/* $KAME: in6.c,v 1.198 2001/07/18 09:12:38 itojun Exp $ */
/*
@@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.209 2016/07/15 07:40:09 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.210 2016/07/20 07:37:51 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -1832,15 +1832,20 @@
in6_localaddr(const struct in6_addr *in6)
{
struct in6_ifaddr *ia;
+ int s;
if (IN6_IS_ADDR_LOOPBACK(in6) || IN6_IS_ADDR_LINKLOCAL(in6))
return 1;
+ s = pserialize_read_enter();
IN6_ADDRLIST_READER_FOREACH(ia) {
if (IN6_ARE_MASKED_ADDR_EQUAL(in6, &ia->ia_addr.sin6_addr,
- &ia->ia_prefixmask.sin6_addr))
+ &ia->ia_prefixmask.sin6_addr)) {
+ pserialize_read_exit(s);
return 1;
+ }
}
+ pserialize_read_exit(s);
return 0;
}
@@ -1849,18 +1854,23 @@
in6_is_addr_deprecated(struct sockaddr_in6 *sa6)
{
struct in6_ifaddr *ia;
+ int s;
+ s = pserialize_read_enter();
IN6_ADDRLIST_READER_FOREACH(ia) {
if (IN6_ARE_ADDR_EQUAL(&ia->ia_addr.sin6_addr,
&sa6->sin6_addr) &&
#ifdef SCOPEDROUTING
ia->ia_addr.sin6_scope_id == sa6->sin6_scope_id &&
#endif
- (ia->ia6_flags & IN6_IFF_DEPRECATED) != 0)
+ (ia->ia6_flags & IN6_IFF_DEPRECATED) != 0) {
+ pserialize_read_exit(s);
return 1; /* true */
+ }
/* XXX: do we still have to go thru the rest of the list? */
}
+ pserialize_read_exit(s);
return 0; /* false */
}
diff -r 3bd503d00747 -r 6530d85d1c4f sys/netinet6/in6_ifattach.c
--- a/sys/netinet6/in6_ifattach.c Wed Jul 20 03:38:09 2016 +0000
+++ b/sys/netinet6/in6_ifattach.c Wed Jul 20 07:37:51 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: in6_ifattach.c,v 1.101 2016/07/07 09:32:03 ozaki-r Exp $ */
+/* $NetBSD: in6_ifattach.c,v 1.102 2016/07/20 07:37:51 ozaki-r Exp $ */
/* $KAME: in6_ifattach.c,v 1.124 2001/07/18 08:32:51 jinmei Exp $ */
/*
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in6_ifattach.c,v 1.101 2016/07/07 09:32:03 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6_ifattach.c,v 1.102 2016/07/20 07:37:51 ozaki-r Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -244,6 +244,7 @@
badid = 1;
else {
struct in6_ifaddr *ia;
+ int s = pserialize_read_enter();
IN6_ADDRLIST_READER_FOREACH(ia) {
if (!memcmp(&ia->ia_addr.sin6_addr.s6_addr[8],
@@ -252,6 +253,7 @@
break;
}
}
+ pserialize_read_exit(s);
}
/*
diff -r 3bd503d00747 -r 6530d85d1c4f sys/netinet6/mld6.c
--- a/sys/netinet6/mld6.c Wed Jul 20 03:38:09 2016 +0000
+++ b/sys/netinet6/mld6.c Wed Jul 20 07:37:51 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mld6.c,v 1.72 2016/07/08 04:33:30 ozaki-r Exp $ */
+/* $NetBSD: mld6.c,v 1.73 2016/07/20 07:37:51 ozaki-r Exp $ */
/* $KAME: mld6.c,v 1.25 2001/01/16 14:14:18 itojun Exp $ */
/*
@@ -102,7 +102,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mld6.c,v 1.72 2016/07/08 04:33:30 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mld6.c,v 1.73 2016/07/20 07:37:51 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -723,6 +723,8 @@
mld_stoptimer(in6m);
if (--in6m->in6m_refcount == 0) {
+ int _s;
+
/*
* No remaining claims to this record; let MLD6 know
* that we are leaving the multicast group.
@@ -742,6 +744,7 @@
* Delete all references of this multicasting group from
* the membership arrays
*/
+ _s = pserialize_read_enter();
IN6_ADDRLIST_READER_FOREACH(ia) {
struct in6_multi_mship *imm;
LIST_FOREACH(imm, &ia->ia6_memberships, i6mm_chain) {
@@ -749,6 +752,7 @@
imm->i6mm_maddr = NULL;
}
}
+ pserialize_read_exit(_s);
/*
* Notify the network driver to update its multicast
diff -r 3bd503d00747 -r 6530d85d1c4f sys/netinet6/nd6_rtr.c
--- a/sys/netinet6/nd6_rtr.c Wed Jul 20 03:38:09 2016 +0000
+++ b/sys/netinet6/nd6_rtr.c Wed Jul 20 07:37:51 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nd6_rtr.c,v 1.116 2016/07/15 07:40:09 ozaki-r Exp $ */
+/* $NetBSD: nd6_rtr.c,v 1.117 2016/07/20 07:37:51 ozaki-r Exp $ */
/* $KAME: nd6_rtr.c,v 1.95 2001/02/07 08:09:47 itojun Exp $ */
/*
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
Home |
Main Index |
Thread Index |
Old Index