[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] linux-user: Add several IFTUN ioctls
From: |
Josh Kunz |
Subject: |
[PATCH] linux-user: Add several IFTUN ioctls |
Date: |
Fri, 10 Jul 2020 12:53:28 -0700 |
This change includes most widely-available if_tun ioctls that are
integer typed.
Tested by compiling all linux-user emulators. This patch has also been
used successfully to run several binaries that utilize these ioctls for
several months.
Linux Header:
https://github.com/torvalds/linux/blob/dcde237b9b0eb1d19306e6f48c0a4e058907619f/include/uapi/linux/if_tun.h#L31
Signed-off-by: Josh Kunz <jkz@google.com>
---
linux-user/ioctls.h | 20 ++++++++++++++++++++
linux-user/syscall.c | 1 +
linux-user/syscall_defs.h | 21 +++++++++++++++++++++
3 files changed, 42 insertions(+)
diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h
index 0713ae1311..9b4a67fe84 100644
--- a/linux-user/ioctls.h
+++ b/linux-user/ioctls.h
@@ -593,3 +593,23 @@
IOCTL(KCOV_DISABLE, 0, TYPE_NULL)
IOCTL(KCOV_INIT_TRACE, IOC_R, TYPE_ULONG)
#endif
+
+ IOCTL(TUNGETFEATURES , IOC_R , TYPE_INT)
+ IOCTL(TUNGETIFF , IOC_R , TYPE_INT)
+ IOCTL(TUNGETSNDBUF , IOC_R , TYPE_INT)
+ IOCTL(TUNGETVNETHDRSZ , IOC_R , TYPE_INT)
+ IOCTL(TUNGETVNETLE , IOC_R , TYPE_INT)
+ IOCTL(TUNSETDEBUG , IOC_W , TYPE_INT)
+ IOCTL(TUNSETGROUP , IOC_W , TYPE_INT)
+ IOCTL(TUNSETIFF , IOC_W , TYPE_INT)
+ IOCTL(TUNSETIFINDEX , IOC_W , TYPE_INT)
+ IOCTL(TUNSETLINK , IOC_W , TYPE_INT)
+ IOCTL(TUNSETNOCSUM , IOC_W , TYPE_INT)
+ IOCTL(TUNSETOFFLOAD , IOC_W , TYPE_INT)
+ IOCTL(TUNSETOWNER , IOC_W , TYPE_INT)
+ IOCTL(TUNSETPERSIST , IOC_W , TYPE_INT)
+ IOCTL(TUNSETQUEUE , IOC_W , TYPE_INT)
+ IOCTL(TUNSETSNDBUF , IOC_W , TYPE_INT)
+ IOCTL(TUNSETTXFILTER , IOC_W , TYPE_INT)
+ IOCTL(TUNSETVNETHDRSZ , IOC_W , TYPE_INT)
+ IOCTL(TUNSETVNETLE , IOC_W , TYPE_INT)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 98ea86ca81..4ad4b36a84 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -58,6 +58,7 @@
#include <linux/icmpv6.h>
#include <linux/errqueue.h>
#include <linux/random.h>
+#include <linux/if_tun.h>
#ifdef CONFIG_TIMERFD
#include <sys/timerfd.h>
#endif
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index 3c261cff0e..833ef68faf 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -859,6 +859,27 @@ struct target_rtc_pll_info {
#define TARGET_SIOCSIFPFLAGS 0x8934 /* set extended flags
*/
#define TARGET_SIOCGIFPFLAGS 0x8935 /* get extended flags
*/
+/* if_tun ioctls */
+#define TARGET_TUNGETFEATURES TARGET_IOR('T', 207, unsigned int)
+#define TARGET_TUNGETIFF TARGET_IOR('T', 210, unsigned int)
+#define TARGET_TUNGETSNDBUF TARGET_IOR('T', 211, int)
+#define TARGET_TUNGETVNETHDRSZ TARGET_IOR('T', 215, int)
+#define TARGET_TUNGETVNETLE TARGET_IOR('T', 221, int)
+#define TARGET_TUNSETDEBUG TARGET_IOW('T', 201, int)
+#define TARGET_TUNSETGROUP TARGET_IOW('T', 206, int)
+#define TARGET_TUNSETIFF TARGET_IOW('T', 202, int)
+#define TARGET_TUNSETIFINDEX TARGET_IOW('T', 218, unsigned int)
+#define TARGET_TUNSETLINK TARGET_IOW('T', 205, int)
+#define TARGET_TUNSETNOCSUM TARGET_IOW('T', 200, int)
+#define TARGET_TUNSETOFFLOAD TARGET_IOW('T', 208, unsigned int)
+#define TARGET_TUNSETOWNER TARGET_IOW('T', 204, int)
+#define TARGET_TUNSETPERSIST TARGET_IOW('T', 203, int)
+#define TARGET_TUNSETQUEUE TARGET_IOW('T', 217, int)
+#define TARGET_TUNSETSNDBUF TARGET_IOW('T', 212, int)
+#define TARGET_TUNSETTXFILTER TARGET_IOW('T', 209, unsigned int)
+#define TARGET_TUNSETVNETHDRSZ TARGET_IOW('T', 216, int)
+#define TARGET_TUNSETVNETLE TARGET_IOW('T', 220, int)
+
/* Bridging control calls */
#define TARGET_SIOCGIFBR 0x8940 /* Bridging support
*/
#define TARGET_SIOCSIFBR 0x8941 /* Set bridging options
*/
--
2.27.0.383.g050319c2ae-goog
- [PATCH] linux-user: Add several IFTUN ioctls,
Josh Kunz <=