Module Name:    src
Committed By:   christos
Date:           Fri Jan 11 19:01:36 UTC 2013

Modified Files:
        src/sys/compat/linux/common: linux_socket.c linux_sockio.h
        src/sys/compat/linux32/common: linux32_socket.c linux32_sockio.h

Log Message:
Use copyin/copyout and linux-specific ifreq structures (they are the same
as the netbsd ones, but this disconnects them)


To generate a diff of this commit:
cvs rdiff -u -r1.114 -r1.115 src/sys/compat/linux/common/linux_socket.c
cvs rdiff -u -r1.18 -r1.19 src/sys/compat/linux/common/linux_sockio.h
cvs rdiff -u -r1.16 -r1.17 src/sys/compat/linux32/common/linux32_socket.c
cvs rdiff -u -r1.3 -r1.4 src/sys/compat/linux32/common/linux32_sockio.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/compat/linux/common/linux_socket.c
diff -u src/sys/compat/linux/common/linux_socket.c:1.114 src/sys/compat/linux/common/linux_socket.c:1.115
--- src/sys/compat/linux/common/linux_socket.c:1.114	Wed Jun 20 11:03:18 2012
+++ src/sys/compat/linux/common/linux_socket.c	Fri Jan 11 14:01:36 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_socket.c,v 1.114 2012/06/20 15:03:18 christos Exp $	*/
+/*	$NetBSD: linux_socket.c,v 1.115 2013/01/11 19:01:36 christos 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.114 2012/06/20 15:03:18 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.115 2013/01/11 19:01:36 christos Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -1083,7 +1083,7 @@ int
 linux_getifconf(struct lwp *l, register_t *retval, void *data)
 {
 	struct linux_ifreq ifr, *ifrp;
-	struct ifconf *ifc = data;
+	struct linux_ifconf ifc;
 	struct ifnet *ifp;
 	struct ifaddr *ifa;
 	struct sockaddr *sa;
@@ -1091,11 +1091,15 @@ linux_getifconf(struct lwp *l, register_
 	int space, error = 0;
 	const int sz = (int)sizeof(ifr);
 
-	ifrp = (struct linux_ifreq *)ifc->ifc_req;
+	error = copyin(data, &ifc, sizeof(ifc));
+	if (error)
+		return error;
+
+	ifrp = ifc.ifc_req;
 	if (ifrp == NULL)
 		space = 0;
 	else
-		space = ifc->ifc_len;
+		space = ifc.ifc_len;
 
 	IFNET_FOREACH(ifp) {
 		(void)strncpy(ifr.ifr_name, ifp->if_xname,
@@ -1123,11 +1127,11 @@ linux_getifconf(struct lwp *l, register_
 	}
 
 	if (ifrp != NULL)
-		ifc->ifc_len -= space;
+		ifc.ifc_len -= space;
 	else
-		ifc->ifc_len = -space;
+		ifc.ifc_len = -space;
 
-	return 0;
+	return copyout(&ifc, data, sizeof(ifc));
 }
 
 int

Index: src/sys/compat/linux/common/linux_sockio.h
diff -u src/sys/compat/linux/common/linux_sockio.h:1.18 src/sys/compat/linux/common/linux_sockio.h:1.19
--- src/sys/compat/linux/common/linux_sockio.h:1.18	Sat Nov 28 17:11:42 2009
+++ src/sys/compat/linux/common/linux_sockio.h	Fri Jan 11 14:01:36 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_sockio.h,v 1.18 2009/11/28 22:11:42 dsl Exp $	*/
+/*	$NetBSD: linux_sockio.h,v 1.19 2013/01/11 19:01:36 christos Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
@@ -76,4 +76,15 @@ struct linux_ifreq {
 #define ifr_map		ifr_ifru.ifru_map	/* device map           */
 };
 
+struct linux_ifconf {
+        int ifc_len;
+	union {
+		char *ifcu_buf;
+		struct linux_ifreq *ifcu_req;
+	} ifc_ifcu;
+};
+
+#define ifc_buf ifc_ifcu.ifcu_buf
+#define ifc_req ifc_ifcu.ifcu_req
+
 #endif /* !_LINUX_SOCKIO_H */

Index: src/sys/compat/linux32/common/linux32_socket.c
diff -u src/sys/compat/linux32/common/linux32_socket.c:1.16 src/sys/compat/linux32/common/linux32_socket.c:1.17
--- src/sys/compat/linux32/common/linux32_socket.c:1.16	Thu Mar 15 12:17:48 2012
+++ src/sys/compat/linux32/common/linux32_socket.c	Fri Jan 11 14:01:36 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux32_socket.c,v 1.16 2012/03/15 16:17:48 bouyer Exp $ */
+/*	$NetBSD: linux32_socket.c,v 1.17 2013/01/11 19:01:36 christos 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.16 2012/03/15 16:17:48 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux32_socket.c,v 1.17 2013/01/11 19:01:36 christos Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -414,7 +414,7 @@ int
 linux32_getifconf(struct lwp *l, register_t *retval, void *data)
 {
 	struct linux32_ifreq ifr, *ifrp;
-	struct netbsd32_ifconf *ifc = data;
+	struct linux32_ifconf ifc;
 	struct ifnet *ifp;
 	struct ifaddr *ifa;
 	struct sockaddr *sa;
@@ -422,11 +422,15 @@ linux32_getifconf(struct lwp *l, registe
 	int space, error = 0;
 	const int sz = (int)sizeof(ifr);
 
-	ifrp = (struct linux32_ifreq *)NETBSD32PTR64(ifc->ifc_req);
+	error = copyin(data, &ifc, sizeof(ifc));
+	if (error)
+		return error;
+
+	ifrp = NETBSD32PTR64(ifc.ifc_req);
 	if (ifrp == NULL)
 		space = 0;
 	else
-		space = ifc->ifc_len;
+		space = ifc.ifc_len;
 
 	IFNET_FOREACH(ifp) {
 		(void)strncpy(ifr.ifr_name, ifp->if_xname,
@@ -454,11 +458,11 @@ linux32_getifconf(struct lwp *l, registe
 	}
 
 	if (ifrp != NULL)
-		ifc->ifc_len -= space;
+		ifc.ifc_len -= space;
 	else
-		ifc->ifc_len = -space;
+		ifc.ifc_len = -space;
 
-	return 0;
+	return copyout(&ifc, data, sizeof(ifc));
 }
 
 int

Index: src/sys/compat/linux32/common/linux32_sockio.h
diff -u src/sys/compat/linux32/common/linux32_sockio.h:1.3 src/sys/compat/linux32/common/linux32_sockio.h:1.4
--- src/sys/compat/linux32/common/linux32_sockio.h:1.3	Fri Nov 13 16:45:03 2009
+++ src/sys/compat/linux32/common/linux32_sockio.h	Fri Jan 11 14:01:36 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: linux32_sockio.h,v 1.3 2009/11/13 21:45:03 joerg Exp $ */
+/* $NetBSD: linux32_sockio.h,v 1.4 2013/01/11 19:01:36 christos Exp $ */
 
 /*
  * Copyright (c) 2008 Nicolas Joly
@@ -56,4 +56,15 @@ struct linux32_ifreq {
 #define ifr_map		ifr_ifru.ifru_map	/* device map           */
 };
 
+struct linux32_ifconf {
+        int ifc_len;
+	union {
+		netbsd32_caddr_t ifcu_buf;      
+		netbsd32_ifreq_tp_t ifcu_req;   
+	} ifc_ifcu;
+};
+
+#define ifc_buf ifc_ifcu.ifcu_buf
+#define ifc_req ifc_ifcu.ifcu_req
+
 #endif /* !_LINUX32_SOCKIO_H */

Reply via email to