Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/net Use psz/psref to hold ifa
details: https://anonhg.NetBSD.org/src/rev/01607f38d4c7
branches: trunk
changeset: 349842:01607f38d4c7
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Mon Dec 26 07:25:00 2016 +0000
description:
Use psz/psref to hold ifa
diffstat:
sys/net/link_proto.c | 33 +++++++++++++++++++++------------
1 files changed, 21 insertions(+), 12 deletions(-)
diffs (95 lines):
diff -r f935d5522a65 -r 01607f38d4c7 sys/net/link_proto.c
--- a/sys/net/link_proto.c Mon Dec 26 03:24:11 2016 +0000
+++ b/sys/net/link_proto.c Mon Dec 26 07:25:00 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: link_proto.c,v 1.32 2016/11/19 14:44:00 njoly Exp $ */
+/* $NetBSD: link_proto.c,v 1.33 2016/12/26 07:25:00 ozaki-r Exp $ */
/*-
* Copyright (c) 1982, 1986, 1993
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: link_proto.c,v 1.32 2016/11/19 14:44:00 njoly Exp $");
+__KERNEL_RCSID(0, "$NetBSD: link_proto.c,v 1.33 2016/12/26 07:25:00 ozaki-r Exp $");
#include <sys/param.h>
#include <sys/socket.h>
@@ -141,6 +141,7 @@
} u;
struct ifaddr *ifa;
const struct sockaddr_dl *asdl, *nsdl;
+ struct psref psref;
switch (cmd) {
case SIOCALIFADDR:
@@ -168,15 +169,19 @@
error = 0;
- s = splnet();
-
+ s = pserialize_read_enter();
IFADDR_READER_FOREACH(ifa, ifp) {
- if (sockaddr_cmp(&u.sa, ifa->ifa_addr) == 0)
+ if (sockaddr_cmp(&u.sa, ifa->ifa_addr) == 0) {
+ ifa_acquire(ifa, &psref);
break;
+ }
}
+ pserialize_read_exit(s);
switch (cmd) {
case SIOCGLIFADDR:
+ ifa_release(ifa, &psref);
+ s = pserialize_read_enter();
if ((iflr->flags & IFLR_PREFIX) == 0) {
IFADDR_READER_FOREACH(ifa, ifp) {
if (ifa->ifa_addr->sa_family == AF_LINK)
@@ -184,6 +189,7 @@
}
}
if (ifa == NULL) {
+ pserialize_read_exit(s);
error = EADDRNOTAVAIL;
break;
}
@@ -198,6 +204,8 @@
sockaddr_copy(sstosa(&iflr->addr), sizeof(iflr->addr),
ifa->ifa_addr);
+ pserialize_read_exit(s);
+ ifa = NULL;
break;
case SIOCDLIFADDR:
@@ -212,12 +220,13 @@
}
break;
case SIOCALIFADDR:
- if (ifa != NULL)
- ;
- else if ((ifa = if_dl_create(ifp, &nsdl)) == NULL) {
- error = ENOMEM;
- break;
- } else {
+ if (ifa == NULL) {
+ ifa = if_dl_create(ifp, &nsdl);
+ if (ifa == NULL) {
+ error = ENOMEM;
+ break;
+ }
+ ifa_acquire(ifa, &psref);
sockaddr_copy(ifa->ifa_addr,
ifa->ifa_addr->sa_len, &u.sa);
ifa_insert(ifp, ifa);
@@ -234,7 +243,7 @@
}
break;
}
- splx(s);
+ ifa_release(ifa, &psref);
if (error != ENETRESET)
return error;
else if ((ifp->if_flags & IFF_RUNNING) != 0 &&
Home |
Main Index |
Thread Index |
Old Index