Module Name:    src
Committed By:   martin
Date:           Mon May 18 06:38:59 UTC 2015

Modified Files:
        src/sys/compat/netbsd32: netbsd32_ioctl.c netbsd32_ioctl.h
        src/sys/net: if.c if.h

Log Message:
Implement SIOCIFGCLONERS for netbsd32, so ifconfig -C works.


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/sys/compat/netbsd32/netbsd32_ioctl.c
cvs rdiff -u -r1.44 -r1.45 src/sys/compat/netbsd32/netbsd32_ioctl.h
cvs rdiff -u -r1.314 -r1.315 src/sys/net/if.c
cvs rdiff -u -r1.189 -r1.190 src/sys/net/if.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/netbsd32/netbsd32_ioctl.c
diff -u src/sys/compat/netbsd32/netbsd32_ioctl.c:1.69 src/sys/compat/netbsd32/netbsd32_ioctl.c:1.70
--- src/sys/compat/netbsd32/netbsd32_ioctl.c:1.69	Fri Jan 24 12:16:10 2014
+++ src/sys/compat/netbsd32/netbsd32_ioctl.c	Mon May 18 06:38:59 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_ioctl.c,v 1.69 2014/01/24 12:16:10 bouyer Exp $	*/
+/*	$NetBSD: netbsd32_ioctl.c,v 1.70 2015/05/18 06:38:59 martin Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_ioctl.c,v 1.69 2014/01/24 12:16:10 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_ioctl.c,v 1.70 2015/05/18 06:38:59 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -899,6 +899,17 @@ netbsd32_ioctl(struct lwp *l, const stru
 	case ATAIOCCOMMAND32:
 		IOCTL_STRUCT_CONV_TO(ATAIOCCOMMAND, atareq);
 
+	case SIOCIFGCLONERS32:
+		{
+			struct netbsd32_if_clonereq *req =
+			    (struct netbsd32_if_clonereq *)data32;
+			char *buf = NETBSD32PTR64(req->ifcr_buffer);
+
+			error = if_clone_list(req->ifcr_count,
+			    buf, &req->ifcr_total);
+			break;
+		}
+
 /*
  * only a few ifreq syscalls need conversion and those are
  * all driver specific... XXX

Index: src/sys/compat/netbsd32/netbsd32_ioctl.h
diff -u src/sys/compat/netbsd32/netbsd32_ioctl.h:1.44 src/sys/compat/netbsd32/netbsd32_ioctl.h:1.45
--- src/sys/compat/netbsd32/netbsd32_ioctl.h:1.44	Fri Jan 24 10:41:07 2014
+++ src/sys/compat/netbsd32/netbsd32_ioctl.h	Mon May 18 06:38:59 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_ioctl.h,v 1.44 2014/01/24 10:41:07 manu Exp $	*/
+/*	$NetBSD: netbsd32_ioctl.h,v 1.45 2015/05/18 06:38:59 martin Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -314,6 +314,12 @@ struct netbsd32_if_addrprefreq {
 	} ifap_addr;
 };
 
+struct netbsd32_if_clonereq {
+	int	ifcr_total;
+	int	ifcr_count;
+	netbsd32_charp ifcr_buffer;
+};
+
 /* from <dev/pci/if_devar.h> */
 #define	SIOCGADDRROM32		_IOW('i', 240, struct netbsd32_ifreq)	/* get 128 bytes of ROM */
 #define	SIOCGCHIPID32		_IOWR('i', 241, struct netbsd32_ifreq)	/* get chipid */
@@ -375,6 +381,8 @@ struct netbsd32_if_addrprefreq {
 #define	SIOCSIFMEDIA32	_IOWR('i', 53, struct netbsd32_ifreq)	/* set net media */
 #define	OSIOCSIFMEDIA32	_IOWR('i', 53, struct netbsd32_oifreq)	/* set net media */
 
+#define	SIOCIFGCLONERS32 _IOWR('i', 120, struct netbsd32_if_clonereq) /* get cloners */
+
 #define	SIOCSIFMTU32	 _IOW('i', 127, struct netbsd32_ifreq)	/* set ifnet mtu */
 #define	OSIOCSIFMTU32	 _IOW('i', 127, struct netbsd32_oifreq)	/* set ifnet mtu */
 

Index: src/sys/net/if.c
diff -u src/sys/net/if.c:1.314 src/sys/net/if.c:1.315
--- src/sys/net/if.c:1.314	Wed Apr 22 20:49:44 2015
+++ src/sys/net/if.c	Mon May 18 06:38:59 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.c,v 1.314 2015/04/22 20:49:44 roy Exp $	*/
+/*	$NetBSD: if.c,v 1.315 2015/05/18 06:38:59 martin 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.314 2015/04/22 20:49:44 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.315 2015/05/18 06:38:59 martin Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -177,7 +177,6 @@ int	ifqmaxlen = IFQ_MAXLEN;
 static int	if_rt_walktree(struct rtentry *, void *);
 
 static struct if_clone *if_clone_lookup(const char *, int *);
-static int	if_clone_list(struct if_clonereq *);
 
 static LIST_HEAD(, if_clone) if_cloners = LIST_HEAD_INITIALIZER(if_cloners);
 static int if_cloners_count;
@@ -1117,24 +1116,24 @@ if_clone_detach(struct if_clone *ifc)
 /*
  * Provide list of interface cloners to userspace.
  */
-static int
-if_clone_list(struct if_clonereq *ifcr)
+int
+if_clone_list(int buf_count, char *buffer, int *total)
 {
 	char outbuf[IFNAMSIZ], *dst;
 	struct if_clone *ifc;
 	int count, error = 0;
 
-	ifcr->ifcr_total = if_cloners_count;
-	if ((dst = ifcr->ifcr_buffer) == NULL) {
+	*total = if_cloners_count;
+	if ((dst = buffer) == NULL) {
 		/* Just asking how many there are. */
 		return 0;
 	}
 
-	if (ifcr->ifcr_count < 0)
+	if (buf_count < 0)
 		return EINVAL;
 
-	count = (if_cloners_count < ifcr->ifcr_count) ?
-	    if_cloners_count : ifcr->ifcr_count;
+	count = (if_cloners_count < buf_count) ?
+	    if_cloners_count : buf_count;
 
 	for (ifc = LIST_FIRST(&if_cloners); ifc != NULL && count != 0;
 	     ifc = LIST_NEXT(ifc, ifc_list), count--, dst += IFNAMSIZ) {
@@ -2005,7 +2004,11 @@ doifioctl(struct socket *so, u_long cmd,
 		return r;
 
 	case SIOCIFGCLONERS:
-		return if_clone_list((struct if_clonereq *)data);
+		{
+			struct if_clonereq *req = (struct if_clonereq *)data;
+			return if_clone_list(req->ifcr_count, req->ifcr_buffer,
+			    &req->ifcr_total);
+		}
 	}
 
 	if (ifp == NULL)

Index: src/sys/net/if.h
diff -u src/sys/net/if.h:1.189 src/sys/net/if.h:1.190
--- src/sys/net/if.h:1.189	Sat May  2 14:41:32 2015
+++ src/sys/net/if.h	Mon May 18 06:38:59 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.h,v 1.189 2015/05/02 14:41:32 roy Exp $	*/
+/*	$NetBSD: if.h,v 1.190 2015/05/18 06:38:59 martin Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -884,6 +884,7 @@ int	if_addr_init(ifnet_t *, struct ifadd
 int	if_do_dad(struct ifnet *);
 int	if_mcast_op(ifnet_t *, const unsigned long, const struct sockaddr *);
 int	if_flags_set(struct ifnet *, const short);
+int	if_clone_list(int, char *, int *);
 
 void ifa_insert(struct ifnet *, struct ifaddr *);
 void ifa_remove(struct ifnet *, struct ifaddr *);

Reply via email to