Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/netinet Apply psz/psref to remaining IFADDR_READER_FOREACH
details: https://anonhg.NetBSD.org/src/rev/b69996cba121
branches: trunk
changeset: 347532:b69996cba121
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Thu Sep 01 04:27:00 2016 +0000
description:
Apply psz/psref to remaining IFADDR_READER_FOREACH
Pointed out by ryo@
diffstat:
sys/netinet/in.c | 39 +++++++++++++++++++++++++++++++++++----
1 files changed, 35 insertions(+), 4 deletions(-)
diffs (133 lines):
diff -r 346f52170502 -r b69996cba121 sys/netinet/in.c
--- a/sys/netinet/in.c Wed Aug 31 17:31:22 2016 +0000
+++ b/sys/netinet/in.c Thu Sep 01 04:27:00 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: in.c,v 1.178 2016/08/01 03:15:30 ozaki-r Exp $ */
+/* $NetBSD: in.c,v 1.179 2016/09/01 04:27:00 ozaki-r Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.178 2016/08/01 03:15:30 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.179 2016/09/01 04:27:00 ozaki-r Exp $");
#include "arp.h"
@@ -944,7 +944,7 @@
struct in_ifaddr *ia;
struct in_addr mask, candidate, match;
struct sockaddr_in *sin;
- int cmp;
+ int cmp, s;
memset(&mask, 0, sizeof(mask));
memset(&match, 0, sizeof(match)); /* XXX gcc */
@@ -975,6 +975,7 @@
}
}
+ s = pserialize_read_enter();
IFADDR_READER_FOREACH(ifa, ifp) {
if (ifa->ifa_addr->sa_family != AF_INET)
continue;
@@ -985,8 +986,10 @@
if (candidate.s_addr == match.s_addr)
break;
}
- if (ifa == NULL)
+ if (ifa == NULL) {
+ pserialize_read_exit(s);
return EADDRNOTAVAIL;
+ }
ia = (struct in_ifaddr *)ifa;
if (cmd == SIOCGLIFADDR) {
@@ -1003,6 +1006,7 @@
in_mask2len(&ia->ia_sockmask.sin_addr);
iflr->flags = 0; /*XXX*/
+ pserialize_read_exit(s);
return 0;
} else {
@@ -1021,6 +1025,7 @@
}
memcpy(&ifra.ifra_dstaddr, &ia->ia_sockmask,
ia->ia_sockmask.sin_len);
+ pserialize_read_exit(s);
return in_control(so, SIOCDIFADDR, &ifra, ifp);
}
@@ -1342,6 +1347,7 @@
{
struct ifaddr *ifa;
struct in_ifaddr *ia;
+ int s, bound;
/* Ensure it's sane to run DAD */
if (ifp->if_link_state == LINK_STATE_DOWN)
@@ -1349,9 +1355,16 @@
if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING))
return;
+ bound = curlwp_bind();
+ s = pserialize_read_enter();
IFADDR_READER_FOREACH(ifa, ifp) {
+ struct psref psref;
+
if (ifa->ifa_addr->sa_family != AF_INET)
continue;
+ ifa_acquire(ifa, &psref);
+ pserialize_read_exit(s);
+
ia = (struct in_ifaddr *)ifa;
/* If detached then mark as tentative */
@@ -1368,7 +1381,12 @@
ia->ia4_flags &= ~IN_IFF_DUPLICATED;
ia->ia_dad_start(ifa);
}
+
+ s = pserialize_read_enter();
+ ifa_release(ifa, &psref);
}
+ pserialize_read_exit(s);
+ curlwp_bindx(bound);
}
void
@@ -1387,10 +1405,18 @@
{
struct ifaddr *ifa;
struct in_ifaddr *ia;
+ int s, bound;
+ bound = curlwp_bind();
+ s = pserialize_read_enter();
IFADDR_READER_FOREACH(ifa, ifp) {
+ struct psref psref;
+
if (ifa->ifa_addr->sa_family != AF_INET)
continue;
+ ifa_acquire(ifa, &psref);
+ pserialize_read_exit(s);
+
ia = (struct in_ifaddr *)ifa;
/* Stop DAD processing */
@@ -1406,7 +1432,12 @@
~(IN_IFF_TENTATIVE | IN_IFF_DUPLICATED);
rt_newaddrmsg(RTM_NEWADDR, ifa, 0, NULL);
}
+
+ s = pserialize_read_enter();
+ ifa_release(ifa, &psref);
}
+ pserialize_read_exit(s);
+ curlwp_bindx(bound);
}
void
Home |
Main Index |
Thread Index |
Old Index