Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Implement SIOCIFGCLONERS for netbsd32, so ifconfig -C wo...



details:   https://anonhg.NetBSD.org/src/rev/f1a53df00b62
branches:  trunk
changeset: 808455:f1a53df00b62
user:      martin <martin%NetBSD.org@localhost>
date:      Mon May 18 06:38:59 2015 +0000

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

diffstat:

 sys/compat/netbsd32/netbsd32_ioctl.c |  15 +++++++++++++--
 sys/compat/netbsd32/netbsd32_ioctl.h |  10 +++++++++-
 sys/net/if.c                         |  25 ++++++++++++++-----------
 sys/net/if.h                         |   3 ++-
 4 files changed, 38 insertions(+), 15 deletions(-)

diffs (155 lines):

diff -r d9e85217fd97 -r f1a53df00b62 sys/compat/netbsd32/netbsd32_ioctl.c
--- a/sys/compat/netbsd32/netbsd32_ioctl.c      Mon May 18 06:27:04 2015 +0000
+++ b/sys/compat/netbsd32/netbsd32_ioctl.c      Mon May 18 06:38:59 2015 +0000
@@ -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 @@
        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
diff -r d9e85217fd97 -r f1a53df00b62 sys/compat/netbsd32/netbsd32_ioctl.h
--- a/sys/compat/netbsd32/netbsd32_ioctl.h      Mon May 18 06:27:04 2015 +0000
+++ b/sys/compat/netbsd32/netbsd32_ioctl.h      Mon May 18 06:38:59 2015 +0000
@@ -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 @@
        } 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 @@
 #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 */
 
diff -r d9e85217fd97 -r f1a53df00b62 sys/net/if.c
--- a/sys/net/if.c      Mon May 18 06:27:04 2015 +0000
+++ b/sys/net/if.c      Mon May 18 06:38:59 2015 +0000
@@ -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 @@
 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 @@
 /*
  * 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 @@
                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)
diff -r d9e85217fd97 -r f1a53df00b62 sys/net/if.h
--- a/sys/net/if.h      Mon May 18 06:27:04 2015 +0000
+++ b/sys/net/if.h      Mon May 18 06:38:59 2015 +0000
@@ -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_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 *);



Home | Main Index | Thread Index | Old Index