linux-user: Add several IFTUN ioctls
PATCH 1/1 linux-user: Add several IFTUN ioctls
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
--- linux-user/ioctls.h | 20 ++++++++++++++++++++ linux-user/syscall.c | 1 + linux-user/syscall_defs.h | 21 +++++++++++++++++++++ 3 files changed, 42 insertions(+)
linux-user/ioctls.h +20 -0
@@ -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 )
linux-user/syscall.c +1 -0
@@ -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
linux-user/syscall_defs.h +21 -0
@@ -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 */
Signature · 1 line
2.27.0.383.g050319c2ae-goog
Le 10/07/2020 à 21:53, Josh Kunz a écrit :
Quoted 80 lines
This change includes most widely-available
if_tunioctls 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#L31Signed-off-by Josh Kunz <[email protected]>--- linux-user/ioctls.h | 20 ++++++++++++++++++++ linux-user/syscall.c | 1 + linux-user/syscall_defs.h | 21 +++++++++++++++++++++ 3 files changed, 42 insertions(+)linux-user/ioctls.h +20
-0@@ -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 )linux-user/syscall.c +1
-0@@ -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 linux-user/syscall_defs.h +14
-0@@ -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)
linux-user/syscall_defs.h struct target_rtc_pll_info { · line 885
Quoted 10 lines
linux-user/syscall_defs.h +7
-0+#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 */
Laurent Vivier
AppliedLe 10/07/2020 à 21:53, Josh Kunz a écrit :
Quoted 80 lines
This change includes most widely-available
if_tunioctls 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#L31Signed-off-by Josh Kunz <[email protected]>--- linux-user/ioctls.h | 20 ++++++++++++++++++++ linux-user/syscall.c | 1 + linux-user/syscall_defs.h | 21 +++++++++++++++++++++ 3 files changed, 42 insertions(+)linux-user/ioctls.h +20
-0@@ -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 )linux-user/syscall.c +1
-0@@ -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 linux-user/syscall_defs.h +14
-0@@ -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)
linux-user/syscall_defs.h struct target_rtc_pll_info { · line 885
Quoted 10 lines
linux-user/syscall_defs.h +7
-0+#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 */
Applied to my linux-user-for-5.1 branch.
Thanks,
Laurent
Le 13/07/2020 à 21:28, Laurent Vivier a écrit :
Quoted 46 lines
Le 10/07/2020 à 21:53, Josh Kunz a écrit :
Quoted 45 lines
This change includes most widely-available
if_tunioctls 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#L31Signed-off-by Josh Kunz <[email protected]>--- linux-user/ioctls.h | 20 ++++++++++++++++++++ linux-user/syscall.c | 1 + linux-user/syscall_defs.h | 21 +++++++++++++++++++++ 3 files changed, 42 insertions(+)linux-user/ioctls.h +20
-0@@ -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 )
...
Quoted 3 lines
Quoted 1 line
Applied to my linux-user-for-5.1 branch.
This patch fails ioctls03 LTP tests on some archs (s390x for instance), TUNGETFEATURES returns unknown features.
Your patch is not correct, definitions should use MK_PTR(...) rather than TYPE_INT (and some of them are not based on int but on more complex structures). Your patch only works with guest with same endianness and word size.
I remove it from the queue.
Thanks,
Laurent