diff --git a/sys/compat/netbsd32/netbsd32_ioctl.c b/sys/compat/netbsd32/netbsd32_ioctl.c index 1ff7bbf6153c..765705191e6a 100644 --- a/sys/compat/netbsd32/netbsd32_ioctl.c +++ b/sys/compat/netbsd32/netbsd32_ioctl.c @@ -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 -__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 #include @@ -899,6 +899,17 @@ netbsd32_ioctl(struct lwp *l, const struct netbsd32_ioctl_args *uap, register_t 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 --git a/sys/compat/netbsd32/netbsd32_ioctl.h b/sys/compat/netbsd32/netbsd32_ioctl.h index 7de671957948..a1862efe9055 100644 --- a/sys/compat/netbsd32/netbsd32_ioctl.h +++ b/sys/compat/netbsd32/netbsd32_ioctl.h @@ -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 */ #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 */ diff --git a/sys/net/if.c b/sys/net/if.c index 2ef17e70180f..dc69e5a3001c 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -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 -__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, void *data, struct lwp *l) 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 --git a/sys/net/if.h b/sys/net/if.h index 9345f5d8b067..324479e4ee11 100644 --- a/sys/net/if.h +++ b/sys/net/if.h @@ -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 ifaddr *, bool); 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 *);