Implement SIOCIFGCLONERS for netbsd32, so ifconfig -C works.
This commit is contained in:
parent
2754f5946a
commit
c5617ba863
@ -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 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
|
||||
|
@ -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 */
|
||||
|
||||
|
25
sys/net/if.c
25
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 <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, 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)
|
||||
|
@ -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 *);
|
||||
|
Loading…
Reference in New Issue
Block a user