Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Fix and make consistent of usages of psz/psref in ifconf...
details: https://anonhg.NetBSD.org/src/rev/f410d3aaa06e
branches: trunk
changeset: 357709:f410d3aaa06e
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Wed Nov 22 10:19:14 2017 +0000
description:
Fix and make consistent of usages of psz/psref in ifconf variants
diffstat:
sys/compat/common/uipc_syscalls_40.c | 29 +++++++++++++++++------------
sys/compat/linux/common/linux_socket.c | 9 +++++----
sys/compat/linux32/common/linux32_socket.c | 9 +++++----
sys/net/if.c | 14 ++++++++++----
4 files changed, 37 insertions(+), 24 deletions(-)
diffs (253 lines):
diff -r 56a4cbe9593c -r f410d3aaa06e sys/compat/common/uipc_syscalls_40.c
--- a/sys/compat/common/uipc_syscalls_40.c Wed Nov 22 08:28:56 2017 +0000
+++ b/sys/compat/common/uipc_syscalls_40.c Wed Nov 22 10:19:14 2017 +0000
@@ -1,9 +1,9 @@
-/* $NetBSD: uipc_syscalls_40.c,v 1.13 2017/03/14 09:03:08 ozaki-r Exp $ */
+/* $NetBSD: uipc_syscalls_40.c,v 1.14 2017/11/22 10:19:14 ozaki-r Exp $ */
/* written by Pavel Cahyna, 2006. Public domain. */
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls_40.c,v 1.13 2017/03/14 09:03:08 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls_40.c,v 1.14 2017/11/22 10:19:14 ozaki-r Exp $");
/*
* System call interface to the socket abstraction.
@@ -53,6 +53,7 @@
struct ifaddr *ifa;
if_acquire(ifp, &psref);
+ pserialize_read_exit(s);
(void)strncpy(ifr.ifr_name, ifp->if_xname,
sizeof(ifr.ifr_name));
@@ -69,9 +70,10 @@
ifrp++;
}
space -= sizeof(ifr);
- continue;
+ goto next;
}
+ s = pserialize_read_enter();
IFADDR_READER_FOREACH(ifa, ifp) {
struct sockaddr *sa = ifa->ifa_addr;
struct psref psref_ifa;
@@ -85,11 +87,8 @@
/*
* If it does not fit, we don't bother with it
*/
- if (sa->sa_len > sizeof(*osa)) {
- s = pserialize_read_enter();
- ifa_release(ifa, &psref_ifa);
- continue;
- }
+ if (sa->sa_len > sizeof(*osa))
+ goto next_ifa;
memcpy(&ifr.ifr_addr, sa, sa->sa_len);
osa->sa_family = sa->sa_family;
if (space >= sz) {
@@ -119,13 +118,20 @@
(char *)&ifrp->ifr_addr);
}
}
+ if (error != 0) {
+ ifa_release(ifa, &psref_ifa);
+ goto release_exit;
+ }
+ space -= sz;
+
+ next_ifa:
s = pserialize_read_enter();
ifa_release(ifa, &psref_ifa);
- if (error != 0)
- goto release_exit;
- space -= sz;
}
+ pserialize_read_exit(s);
+ next:
+ s = pserialize_read_enter();
if_release(ifp, &psref);
}
pserialize_read_exit(s);
@@ -138,7 +144,6 @@
return (0);
release_exit:
- pserialize_read_exit(s);
if_release(ifp, &psref);
curlwp_bindx(bound);
return error;
diff -r 56a4cbe9593c -r f410d3aaa06e sys/compat/linux/common/linux_socket.c
--- a/sys/compat/linux/common/linux_socket.c Wed Nov 22 08:28:56 2017 +0000
+++ b/sys/compat/linux/common/linux_socket.c Wed Nov 22 10:19:14 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_socket.c,v 1.138 2017/03/14 09:03:08 ozaki-r Exp $ */
+/* $NetBSD: linux_socket.c,v 1.139 2017/11/22 10:19:14 ozaki-r Exp $ */
/*-
* Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.138 2017/03/14 09:03:08 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.139 2017/11/22 10:19:14 ozaki-r Exp $");
#if defined(_KERNEL_OPT)
#include "opt_inet.h"
@@ -1144,6 +1144,7 @@
IFNET_READER_FOREACH(ifp) {
struct ifaddr *ifa;
if_acquire(ifp, &psref);
+ pserialize_read_exit(s);
(void)strncpy(ifr.ifr_name, ifp->if_xname,
sizeof(ifr.ifr_name));
@@ -1152,6 +1153,7 @@
goto release_exit;
}
+ s = pserialize_read_enter();
IFADDR_READER_FOREACH(ifa, ifp) {
struct psref psref_ifa;
ifa_acquire(ifa, &psref_ifa);
@@ -1167,7 +1169,6 @@
if (space >= sz) {
error = copyout(&ifr, ifrp, sz);
if (error != 0) {
- s = pserialize_read_enter();
ifa_release(ifa, &psref_ifa);
goto release_exit;
}
@@ -1179,6 +1180,7 @@
ifa_release(ifa, &psref_ifa);
}
+ s = pserialize_read_enter();
if_release(ifp, &psref);
}
pserialize_read_exit(s);
@@ -1192,7 +1194,6 @@
return copyout(&ifc, data, sizeof(ifc));
release_exit:
- pserialize_read_exit(s);
if_release(ifp, &psref);
curlwp_bindx(bound);
return error;
diff -r 56a4cbe9593c -r f410d3aaa06e sys/compat/linux32/common/linux32_socket.c
--- a/sys/compat/linux32/common/linux32_socket.c Wed Nov 22 08:28:56 2017 +0000
+++ b/sys/compat/linux32/common/linux32_socket.c Wed Nov 22 10:19:14 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux32_socket.c,v 1.27 2017/03/14 09:03:08 ozaki-r Exp $ */
+/* $NetBSD: linux32_socket.c,v 1.28 2017/11/22 10:19:14 ozaki-r Exp $ */
/*-
* Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved.
@@ -33,7 +33,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux32_socket.c,v 1.27 2017/03/14 09:03:08 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux32_socket.c,v 1.28 2017/11/22 10:19:14 ozaki-r Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -442,6 +442,7 @@
IFNET_READER_FOREACH(ifp) {
struct ifaddr *ifa;
if_acquire(ifp, &psref);
+ pserialize_read_exit(s);
(void)strncpy(ifr.ifr_name, ifp->if_xname,
sizeof(ifr.ifr_name));
@@ -450,6 +451,7 @@
goto release_exit;
}
+ s = pserialize_read_enter();
IFADDR_READER_FOREACH(ifa, ifp) {
struct psref psref_ifa;
ifa_acquire(ifa, &psref_ifa);
@@ -465,7 +467,6 @@
if (space >= sz) {
error = copyout(&ifr, ifrp, sz);
if (error != 0) {
- s = pserialize_read_enter();
ifa_release(ifa, &psref_ifa);
goto release_exit;
}
@@ -477,6 +478,7 @@
ifa_release(ifa, &psref_ifa);
}
+ s = pserialize_read_enter();
if_release(ifp, &psref);
}
pserialize_read_exit(s);
@@ -490,7 +492,6 @@
return copyout(&ifc, data, sizeof(ifc));
release_exit:
- pserialize_read_exit(s);
if_release(ifp, &psref);
curlwp_bindx(bound);
return error;
diff -r 56a4cbe9593c -r f410d3aaa06e sys/net/if.c
--- a/sys/net/if.c Wed Nov 22 08:28:56 2017 +0000
+++ b/sys/net/if.c Wed Nov 22 10:19:14 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if.c,v 1.399 2017/11/22 03:03:18 ozaki-r Exp $ */
+/* $NetBSD: if.c,v 1.400 2017/11/22 10:19:14 ozaki-r Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.399 2017/11/22 03:03:18 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.400 2017/11/22 10:19:14 ozaki-r Exp $");
#if defined(_KERNEL_OPT)
#include "opt_inet.h"
@@ -3169,7 +3169,7 @@
memset(&ifr.ifr_addr, 0, sizeof(ifr.ifr_addr));
if (!docopy) {
space += sz;
- continue;
+ goto next;
}
if (space >= sz) {
error = copyout(&ifr, ifrp, sz);
@@ -3180,6 +3180,7 @@
}
}
+ s = pserialize_read_enter();
IFADDR_READER_FOREACH(ifa, ifp) {
struct sockaddr *sa = ifa->ifa_addr;
/* all sockaddrs must fit in sockaddr_storage */
@@ -3190,14 +3191,19 @@
continue;
}
memcpy(&ifr.ifr_space, sa, sa->sa_len);
+ pserialize_read_exit(s);
+
if (space >= sz) {
error = copyout(&ifr, ifrp, sz);
if (error != 0)
goto release_exit;
ifrp++; space -= sz;
}
+ s = pserialize_read_enter();
}
-
+ pserialize_read_exit(s);
+
+ next:
s = pserialize_read_enter();
psref_release(&psref, &ifp->if_psref, ifnet_psref_class);
}
Home |
Main Index |
Thread Index |
Old Index