Modify the BRDGGIFS and BRDGRTS cmds to be more COMPAT_NETBSD32 friendly.
(XXX whitespace)
This commit is contained in:
parent
b420830aee
commit
ef434b48cb
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: if_bridge.c,v 1.98 2015/04/16 08:54:15 ozaki-r Exp $ */
|
/* $NetBSD: if_bridge.c,v 1.99 2015/06/01 06:14:43 matt Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2001 Wasabi Systems, Inc.
|
* Copyright 2001 Wasabi Systems, Inc.
|
||||||
|
@ -80,7 +80,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.98 2015/04/16 08:54:15 ozaki-r Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.99 2015/06/01 06:14:43 matt Exp $");
|
||||||
|
|
||||||
#ifdef _KERNEL_OPT
|
#ifdef _KERNEL_OPT
|
||||||
#include "opt_bridge_ipf.h"
|
#include "opt_bridge_ipf.h"
|
||||||
|
@ -143,6 +143,10 @@ __KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.98 2015/04/16 08:54:15 ozaki-r Exp $
|
||||||
#include <netinet/ip_carp.h>
|
#include <netinet/ip_carp.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
__CTASSERT(sizeof(struct ifbifconf) == sizeof(struct ifbaconf));
|
||||||
|
__CTASSERT(offsetof(struct ifbifconf, ifbic_len) == offsetof(struct ifbaconf, ifbac_len));
|
||||||
|
__CTASSERT(offsetof(struct ifbifconf, ifbic_buf) == offsetof(struct ifbaconf, ifbac_buf));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Maximum number of addresses to cache.
|
* Maximum number of addresses to cache.
|
||||||
*/
|
*/
|
||||||
|
@ -306,6 +310,8 @@ struct bridge_control {
|
||||||
#define BC_F_COPYIN 0x01 /* copy arguments in */
|
#define BC_F_COPYIN 0x01 /* copy arguments in */
|
||||||
#define BC_F_COPYOUT 0x02 /* copy arguments out */
|
#define BC_F_COPYOUT 0x02 /* copy arguments out */
|
||||||
#define BC_F_SUSER 0x04 /* do super-user check */
|
#define BC_F_SUSER 0x04 /* do super-user check */
|
||||||
|
#define BC_F_XLATEIN 0x08 /* xlate arguments in */
|
||||||
|
#define BC_F_XLATEOUT 0x10 /* xlate arguments out */
|
||||||
|
|
||||||
static const struct bridge_control bridge_control_table[] = {
|
static const struct bridge_control bridge_control_table[] = {
|
||||||
[BRDGADD] = {bridge_ioctl_add, sizeof(struct ifbreq), BC_F_COPYIN|BC_F_SUSER},
|
[BRDGADD] = {bridge_ioctl_add, sizeof(struct ifbreq), BC_F_COPYIN|BC_F_SUSER},
|
||||||
|
@ -317,8 +323,8 @@ static const struct bridge_control bridge_control_table[] = {
|
||||||
[BRDGSCACHE] = {bridge_ioctl_scache, sizeof(struct ifbrparam), BC_F_COPYIN|BC_F_SUSER},
|
[BRDGSCACHE] = {bridge_ioctl_scache, sizeof(struct ifbrparam), BC_F_COPYIN|BC_F_SUSER},
|
||||||
[BRDGGCACHE] = {bridge_ioctl_gcache, sizeof(struct ifbrparam), BC_F_COPYOUT},
|
[BRDGGCACHE] = {bridge_ioctl_gcache, sizeof(struct ifbrparam), BC_F_COPYOUT},
|
||||||
|
|
||||||
[BRDGGIFS] = {bridge_ioctl_gifs, sizeof(struct ifbifconf), BC_F_COPYIN|BC_F_COPYOUT},
|
[OBRDGGIFS] = {bridge_ioctl_gifs, sizeof(struct ifbifconf), BC_F_COPYIN|BC_F_COPYOUT},
|
||||||
[BRDGRTS] = {bridge_ioctl_rts, sizeof(struct ifbaconf), BC_F_COPYIN|BC_F_COPYOUT},
|
[OBRDGRTS] = {bridge_ioctl_rts, sizeof(struct ifbaconf), BC_F_COPYIN|BC_F_COPYOUT},
|
||||||
|
|
||||||
[BRDGSADDR] = {bridge_ioctl_saddr, sizeof(struct ifbareq), BC_F_COPYIN|BC_F_SUSER},
|
[BRDGSADDR] = {bridge_ioctl_saddr, sizeof(struct ifbareq), BC_F_COPYIN|BC_F_SUSER},
|
||||||
|
|
||||||
|
@ -348,7 +354,10 @@ static const struct bridge_control bridge_control_table[] = {
|
||||||
[BRDGGFILT] = {bridge_ioctl_gfilt, sizeof(struct ifbrparam), BC_F_COPYOUT},
|
[BRDGGFILT] = {bridge_ioctl_gfilt, sizeof(struct ifbrparam), BC_F_COPYOUT},
|
||||||
[BRDGSFILT] = {bridge_ioctl_sfilt, sizeof(struct ifbrparam), BC_F_COPYIN|BC_F_SUSER},
|
[BRDGSFILT] = {bridge_ioctl_sfilt, sizeof(struct ifbrparam), BC_F_COPYIN|BC_F_SUSER},
|
||||||
#endif /* BRIDGE_IPF */
|
#endif /* BRIDGE_IPF */
|
||||||
|
[BRDGGIFS] = {bridge_ioctl_gifs, sizeof(struct ifbifconf), BC_F_XLATEIN|BC_F_XLATEOUT},
|
||||||
|
[BRDGRTS] = {bridge_ioctl_rts, sizeof(struct ifbaconf), BC_F_XLATEIN|BC_F_XLATEOUT},
|
||||||
};
|
};
|
||||||
|
|
||||||
static const int bridge_control_table_size = __arraycount(bridge_control_table);
|
static const int bridge_control_table_size = __arraycount(bridge_control_table);
|
||||||
|
|
||||||
static LIST_HEAD(, bridge_softc) bridge_list;
|
static LIST_HEAD(, bridge_softc) bridge_list;
|
||||||
|
@ -621,13 +630,12 @@ bridge_ioctl(struct ifnet *ifp, u_long cmd, void *data)
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case SIOCGDRVSPEC:
|
case SIOCGDRVSPEC:
|
||||||
case SIOCSDRVSPEC:
|
case SIOCSDRVSPEC:
|
||||||
if (ifd->ifd_cmd >= bridge_control_table_size) {
|
if (ifd->ifd_cmd >= bridge_control_table_size
|
||||||
|
|| (bc = &bridge_control_table[ifd->ifd_cmd]) == NULL) {
|
||||||
error = EINVAL;
|
error = EINVAL;
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
bc = &bridge_control_table[ifd->ifd_cmd];
|
|
||||||
|
|
||||||
/* We only care about BC_F_SUSER at this point. */
|
/* We only care about BC_F_SUSER at this point. */
|
||||||
if ((bc->bc_flags & BC_F_SUSER) == 0)
|
if ((bc->bc_flags & BC_F_SUSER) == 0)
|
||||||
break;
|
break;
|
||||||
|
@ -651,20 +659,21 @@ bridge_ioctl(struct ifnet *ifp, u_long cmd, void *data)
|
||||||
case SIOCSDRVSPEC:
|
case SIOCSDRVSPEC:
|
||||||
KASSERT(bc != NULL);
|
KASSERT(bc != NULL);
|
||||||
if (cmd == SIOCGDRVSPEC &&
|
if (cmd == SIOCGDRVSPEC &&
|
||||||
(bc->bc_flags & BC_F_COPYOUT) == 0) {
|
(bc->bc_flags & (BC_F_COPYOUT|BC_F_XLATEOUT)) == 0) {
|
||||||
error = EINVAL;
|
error = EINVAL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (cmd == SIOCSDRVSPEC &&
|
else if (cmd == SIOCSDRVSPEC &&
|
||||||
(bc->bc_flags & BC_F_COPYOUT) != 0) {
|
(bc->bc_flags & (BC_F_COPYOUT|BC_F_XLATEOUT)) != 0) {
|
||||||
error = EINVAL;
|
error = EINVAL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* BC_F_SUSER is checked above, before splnet(). */
|
/* BC_F_SUSER is checked above, before splnet(). */
|
||||||
|
|
||||||
if (ifd->ifd_len != bc->bc_argsize ||
|
if ((bc->bc_flags & (BC_F_XLATEIN|BC_F_XLATEOUT)) == 0
|
||||||
ifd->ifd_len > sizeof(args)) {
|
&& (ifd->ifd_len != bc->bc_argsize
|
||||||
|
|| ifd->ifd_len > sizeof(args))) {
|
||||||
error = EINVAL;
|
error = EINVAL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -674,15 +683,21 @@ bridge_ioctl(struct ifnet *ifp, u_long cmd, void *data)
|
||||||
error = copyin(ifd->ifd_data, &args, ifd->ifd_len);
|
error = copyin(ifd->ifd_data, &args, ifd->ifd_len);
|
||||||
if (error)
|
if (error)
|
||||||
break;
|
break;
|
||||||
|
} else if (bc->bc_flags & BC_F_XLATEIN) {
|
||||||
|
args.ifbifconf.ifbic_len = ifd->ifd_len;
|
||||||
|
args.ifbifconf.ifbic_buf = ifd->ifd_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
error = (*bc->bc_func)(sc, &args);
|
error = (*bc->bc_func)(sc, &args);
|
||||||
if (error)
|
if (error)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (bc->bc_flags & BC_F_COPYOUT)
|
if (bc->bc_flags & BC_F_COPYOUT) {
|
||||||
error = copyout(&args, ifd->ifd_data, ifd->ifd_len);
|
error = copyout(&args, ifd->ifd_data, ifd->ifd_len);
|
||||||
|
} else if (bc->bc_flags & BC_F_XLATEOUT) {
|
||||||
|
ifd->ifd_len = args.ifbifconf.ifbic_len;
|
||||||
|
ifd->ifd_data = args.ifbifconf.ifbic_buf;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SIOCSIFFLAGS:
|
case SIOCSIFFLAGS:
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: if_bridgevar.h,v 1.23 2015/01/16 10:36:14 ozaki-r Exp $ */
|
/* $NetBSD: if_bridgevar.h,v 1.24 2015/06/01 06:14:43 matt Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2001 Wasabi Systems, Inc.
|
* Copyright 2001 Wasabi Systems, Inc.
|
||||||
|
@ -90,8 +90,8 @@
|
||||||
#define BRDGSIFFLGS 3 /* set member if flags (ifbreq) */
|
#define BRDGSIFFLGS 3 /* set member if flags (ifbreq) */
|
||||||
#define BRDGSCACHE 4 /* set cache size (ifbrparam) */
|
#define BRDGSCACHE 4 /* set cache size (ifbrparam) */
|
||||||
#define BRDGGCACHE 5 /* get cache size (ifbrparam) */
|
#define BRDGGCACHE 5 /* get cache size (ifbrparam) */
|
||||||
#define BRDGGIFS 6 /* get member list (ifbifconf) */
|
#define OBRDGGIFS 6 /* get member list (ifbifconf) */
|
||||||
#define BRDGRTS 7 /* get address list (ifbaconf) */
|
#define OBRDGRTS 7 /* get address list (ifbaconf) */
|
||||||
#define BRDGSADDR 8 /* set static address (ifbareq) */
|
#define BRDGSADDR 8 /* set static address (ifbareq) */
|
||||||
#define BRDGSTO 9 /* set cache timeout (ifbrparam) */
|
#define BRDGSTO 9 /* set cache timeout (ifbrparam) */
|
||||||
#define BRDGGTO 10 /* get cache timeout (ifbrparam) */
|
#define BRDGGTO 10 /* get cache timeout (ifbrparam) */
|
||||||
|
@ -111,6 +111,9 @@
|
||||||
#define BRDGGFILT 23 /* get filter flags (ifbrparam) */
|
#define BRDGGFILT 23 /* get filter flags (ifbrparam) */
|
||||||
#define BRDGSFILT 24 /* set filter flags (ifbrparam) */
|
#define BRDGSFILT 24 /* set filter flags (ifbrparam) */
|
||||||
|
|
||||||
|
#define BRDGGIFS 25 /* get member list */
|
||||||
|
#define BRDGRTS 26 /* get address list */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Generic bridge control request.
|
* Generic bridge control request.
|
||||||
*/
|
*/
|
||||||
|
@ -163,8 +166,7 @@ struct ifbifconf {
|
||||||
*/
|
*/
|
||||||
struct ifbareq {
|
struct ifbareq {
|
||||||
char ifba_ifsname[IFNAMSIZ]; /* member if name */
|
char ifba_ifsname[IFNAMSIZ]; /* member if name */
|
||||||
/*XXX: time_t */
|
time_t ifba_expire; /* address expire time */
|
||||||
long ifba_expire; /* address expire time */
|
|
||||||
uint8_t ifba_flags; /* address flags */
|
uint8_t ifba_flags; /* address flags */
|
||||||
uint8_t ifba_dst[ETHER_ADDR_LEN];/* destination address */
|
uint8_t ifba_dst[ETHER_ADDR_LEN];/* destination address */
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue