Source-Changes-HG archive

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

[src/trunk]: src/sys/compat/netbsd32 Restore netbsd32 compat code for new NPF...



details:   https://anonhg.NetBSD.org/src/rev/3fc1239f69d6
branches:  trunk
changeset: 837260:3fc1239f69d6
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Sun Nov 25 17:58:29 2018 +0000

description:
Restore netbsd32 compat code for new NPF ABI.

diffstat:

 sys/compat/netbsd32/netbsd32.h       |   9 +++-
 sys/compat/netbsd32/netbsd32_conv.h  |  32 +++++++++++++-
 sys/compat/netbsd32/netbsd32_ioctl.c |  83 +++++++++++++++++++++++++++++++++--
 sys/compat/netbsd32/netbsd32_ioctl.h |  25 ++++++++++-
 4 files changed, 140 insertions(+), 9 deletions(-)

diffs (272 lines):

diff -r a830e3dadb89 -r 3fc1239f69d6 sys/compat/netbsd32/netbsd32.h
--- a/sys/compat/netbsd32/netbsd32.h    Sun Nov 25 16:21:04 2018 +0000
+++ b/sys/compat/netbsd32/netbsd32.h    Sun Nov 25 17:58:29 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32.h,v 1.119 2018/08/11 03:41:06 mrg Exp $       */
+/*     $NetBSD: netbsd32.h,v 1.120 2018/11/25 17:58:29 mlelstv Exp $   */
 
 /*
  * Copyright (c) 1998, 2001, 2008, 2015 Matthew R. Green
@@ -912,6 +912,13 @@
        netbsd32_size_t pref_len;
 };
 
+/* <nv.h> */
+typedef struct {
+       netbsd32_pointer_t buf;
+       netbsd32_size_t    len;
+       int                flags;
+} netbsd32_nvlist_ref_t;
+
 /* from <ufs/lfs/lfs.h> */
 typedef netbsd32_pointer_t netbsd32_block_infop_t;  /* XXX broken */
 
diff -r a830e3dadb89 -r 3fc1239f69d6 sys/compat/netbsd32/netbsd32_conv.h
--- a/sys/compat/netbsd32/netbsd32_conv.h       Sun Nov 25 16:21:04 2018 +0000
+++ b/sys/compat/netbsd32/netbsd32_conv.h       Sun Nov 25 17:58:29 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32_conv.h,v 1.35 2018/05/10 02:36:07 christos Exp $      */
+/*     $NetBSD: netbsd32_conv.h,v 1.36 2018/11/25 17:58:29 mlelstv Exp $       */
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -48,6 +48,8 @@
 
 #include <prop/plistref.h>
 
+#include <nv.h>
+
 #include <compat/netbsd32/netbsd32.h>
 
 /* converters for structures that we need */
@@ -796,6 +798,34 @@
            sizeof(struct netbsd32_plistref));
 }
 
+static __inline int
+netbsd32_copyin_nvlist_ref_t(netbsd32_pointer_t n32p, nvlist_ref_t *p)
+{
+       netbsd32_nvlist_ref_t n32nv;
+       int error;
+
+       error = copyin(NETBSD32PTR64(n32p), &n32nv,
+           sizeof(netbsd32_nvlist_ref_t));
+       if (error)
+               return error;
+       p->buf = NETBSD32PTR64(n32nv.buf);
+       p->len = n32nv.len;
+       p->flags = n32nv.flags;
+       return 0;
+}
+
+static __inline int
+netbsd32_copyout_nvlist_ref_t(netbsd32_pointer_t n32p, nvlist_ref_t *p)
+{
+       netbsd32_nvlist_ref_t n32nv;
+
+       NETBSD32PTR32(n32nv.buf, p->buf);
+       n32nv.len = p->len;
+       n32nv.flags = p->flags;
+       return copyout(&n32nv, NETBSD32PTR64(n32p),
+           sizeof(netbsd32_nvlist_ref_t));
+}
+
 static __inline void
 netbsd32_to_mq_attr(const struct netbsd32_mq_attr *a32,
     struct mq_attr *attr)
diff -r a830e3dadb89 -r 3fc1239f69d6 sys/compat/netbsd32/netbsd32_ioctl.c
--- a/sys/compat/netbsd32/netbsd32_ioctl.c      Sun Nov 25 16:21:04 2018 +0000
+++ b/sys/compat/netbsd32/netbsd32_ioctl.c      Sun Nov 25 17:58:29 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32_ioctl.c,v 1.99 2018/10/12 05:06:05 rin Exp $  */
+/*     $NetBSD: netbsd32_ioctl.c,v 1.100 2018/11/25 17:58:29 mlelstv 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.99 2018/10/12 05:06:05 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_ioctl.c,v 1.100 2018/11/25 17:58:29 mlelstv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ntp.h"
@@ -287,20 +287,27 @@
 }
 
 static inline void
+netbsd32_to_nvlist_ref_t(netbsd32_nvlist_ref_t *s32p, nvlist_ref_t *p, u_long cmd)
+{
+
+       p->buf = NETBSD32PTR64(s32p->buf);
+       p->len = s32p->len;
+       p->flags = s32p->flags;
+}
+
+static inline void
 netbsd32_to_u_long(netbsd32_u_long *s32p, u_long *p, u_long cmd)
 {
 
        *p = (u_long)*s32p;
 }
 
-#ifdef notdef
 static inline void
 netbsd32_to_voidp(netbsd32_voidp *s32p, voidp *p, u_long cmd)
 {
 
        *p = (void *)NETBSD32PTR64(*s32p);
 }
-#endif
 
 static inline void
 netbsd32_to_wdog_conf(struct netbsd32_wdog_conf *s32p, struct wdog_conf *p, u_long cmd)
@@ -311,6 +318,28 @@
 }
 
 static inline void
+netbsd32_to_npf_ioctl_table(
+    const struct netbsd32_npf_ioctl_table *s32p,
+    struct npf_ioctl_table *p,
+    u_long cmd)
+{
+
+       p->nct_cmd = s32p->nct_cmd;
+       p->nct_name = NETBSD32PTR64(s32p->nct_name);
+       switch (s32p->nct_cmd) {
+       case NPF_CMD_TABLE_LOOKUP:
+       case NPF_CMD_TABLE_ADD:
+       case NPF_CMD_TABLE_REMOVE:
+               p->nct_data.ent = s32p->nct_data.ent;
+               break;
+       case NPF_CMD_TABLE_LIST:
+               p->nct_data.buf.buf = NETBSD32PTR64(s32p->nct_data.buf.buf);
+               p->nct_data.buf.len = s32p->nct_data.buf.len;
+               break;
+       }
+}
+
+static inline void
 netbsd32_to_bpf_program(struct netbsd32_bpf_program *s32p, struct bpf_program *p, u_long cmd)
 {
 
@@ -740,6 +769,15 @@
 }
 
 static inline void
+netbsd32_from_nvlist_ref_t(nvlist_ref_t *p, netbsd32_nvlist_ref_t *s32p, u_long cmd)
+{
+
+       NETBSD32PTR32(s32p->buf, p->buf);
+       s32p->len = p->len;
+       s32p->flags = p->flags;
+}
+
+static inline void
 netbsd32_from_wdog_conf(struct wdog_conf *p, struct netbsd32_wdog_conf *s32p, u_long cmd)
 {
 
@@ -857,14 +895,12 @@
        *s32p = (netbsd32_u_long)*p;
 }
 
-#ifdef notdef
 static inline void
 netbsd32_from_voidp(voidp *p, netbsd32_voidp *s32p, u_long cmd)
 {
 
        NETBSD32PTR32(*s32p, *p);
 }
-#endif
 
 static inline void
 netbsd32_from_clockctl_settimeofday(
@@ -935,6 +971,28 @@
 }
 
 static inline void
+netbsd32_from_npf_ioctl_table(
+    const struct npf_ioctl_table *p,
+    struct netbsd32_npf_ioctl_table *s32p,
+    u_long cmd)
+{
+
+       s32p->nct_cmd = p->nct_cmd;
+       NETBSD32PTR32(s32p->nct_name, p->nct_name);
+       switch (p->nct_cmd) {
+       case NPF_CMD_TABLE_LOOKUP:
+       case NPF_CMD_TABLE_ADD:
+       case NPF_CMD_TABLE_REMOVE:
+               s32p->nct_data.ent = p->nct_data.ent;
+               break;
+       case NPF_CMD_TABLE_LIST:
+               NETBSD32PTR32(s32p->nct_data.buf.buf, p->nct_data.buf.buf);
+               s32p->nct_data.buf.len = p->nct_data.buf.len;
+               break;
+       }
+}
+
+static inline void
 netbsd32_from_devlistargs(
     const struct devlistargs *p,
     struct netbsd32_devlistargs *s32p,
@@ -1422,6 +1480,19 @@
        case KIOCGVALUE32:
                IOCTL_STRUCT_CONV_TO(KIOCGVALUE, ksyms_gvalue);
 
+        case IOC_NPF_LOAD32:
+                IOCTL_CONV_TO(IOC_NPF_LOAD, nvlist_ref_t);
+        case IOC_NPF_TABLE32:
+                IOCTL_STRUCT_CONV_TO(IOC_NPF_TABLE, npf_ioctl_table);
+        case IOC_NPF_STATS32:
+                IOCTL_CONV_TO(IOC_NPF_STATS, voidp);
+        case IOC_NPF_SAVE32:
+                IOCTL_CONV_TO(IOC_NPF_SAVE, nvlist_ref_t);
+        case IOC_NPF_RULE32:
+                IOCTL_CONV_TO(IOC_NPF_RULE, nvlist_ref_t);
+        case IOC_NPF_CONN_LOOKUP32:
+                IOCTL_CONV_TO(IOC_NPF_CONN_LOOKUP, nvlist_ref_t);
+
        case DRVRESCANBUS32:
                IOCTL_STRUCT_CONV_TO(DRVRESCANBUS, devrescanargs);
        case DRVLISTDEV32:
diff -r a830e3dadb89 -r 3fc1239f69d6 sys/compat/netbsd32/netbsd32_ioctl.h
--- a/sys/compat/netbsd32/netbsd32_ioctl.h      Sun Nov 25 16:21:04 2018 +0000
+++ b/sys/compat/netbsd32/netbsd32_ioctl.h      Sun Nov 25 17:58:29 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32_ioctl.h,v 1.65 2018/10/11 15:23:22 christos Exp $     */
+/*     $NetBSD: netbsd32_ioctl.h,v 1.66 2018/11/25 17:58:29 mlelstv Exp $      */
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -561,6 +561,29 @@
 #define        KIOCGSYMBOL32   _IOWR('l', 5, struct netbsd32_ksyms_gsymbol)
 #endif /* KIOCGSYMBOL */
 
+#include <net/npf/npf.h>
+
+typedef struct netbsd32_npf_ioctl_buf {
+       netbsd32_voidp          buf;
+       netbsd32_size_t         len;
+} netbsd32_npf_ioctl_buf_t;
+
+typedef struct netbsd32_npf_ioctl_table {
+        int                    nct_cmd;  
+        netbsd32_charp         nct_name;
+        union {
+               npf_ioctl_ent_t ent;
+               netbsd32_npf_ioctl_buf_t buf;
+        } nct_data;
+} netbsd32_npf_ioctl_table_t;
+
+#define IOC_NPF_LOAD32         _IOWR('N', 102, netbsd32_nvlist_ref_t)
+#define IOC_NPF_TABLE32                _IOW('N', 103, struct netbsd32_npf_ioctl_table)
+#define IOC_NPF_STATS32                _IOW('N', 104, netbsd32_voidp)
+#define IOC_NPF_SAVE32         _IOR('N', 105, netbsd32_nvlist_ref_t)
+#define IOC_NPF_RULE32         _IOWR('N', 107, netbsd32_nvlist_ref_t)
+#define IOC_NPF_CONN_LOOKUP32  _IOWR('N', 108, netbsd32_nvlist_ref_t)
+
 /* From sys/drvctlio.h */
 struct netbsd32_devlistargs {
        char                    l_devname[16];



Home | Main Index | Thread Index | Old Index