Message ID | 20200710195328.587462-1-jkz@google.com |
---|---|
State | New |
Headers | show |
Series | linux-user: Add several IFTUN ioctls | expand |
Le 10/07/2020 à 21:53, Josh Kunz a écrit : > 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 */ > Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Le 10/07/2020 à 21:53, Josh Kunz a écrit : > 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 */ > Applied to my linux-user-for-5.1 branch. Thanks, Laurent
Le 13/07/2020 à 21:28, Laurent Vivier a écrit : > Le 10/07/2020 à 21:53, Josh Kunz a écrit : >> 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) ... >> > > 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
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 */
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(+)