[Devel] [PATCH RHEL7 COMMIT] ve/net: fix userspace if_tun.h compilation
Konstantin Khorenko
khorenko at virtuozzo.com
Thu Nov 12 01:26:28 PST 2015
JFYI: i've made
s/unsigned ifru_acctid;/unsigned int ifru_acctid;/
--
Best regards,
Konstantin Khorenko,
Virtuozzo Linux Kernel Team
On 11/12/2015 12:25 PM, Konstantin Khorenko wrote:
> The commit is pushed to "branch-rh7-3.10.0-229.7.2.vz7.9.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
> after rh7-3.10.0-229.7.2.vz7.9.9
> ------>
> commit 20d9d273d62b292e544575af5277c75d449cd76c
> Author: Vladimir Sementsov-Ogievskiy <vsementsov at virtuozzo.com>
> Date: Thu Nov 12 13:25:07 2015 +0400
>
> ve/net: fix userspace if_tun.h compilation
>
> The patch fixes b59e089eb2d : "ve/net: introduce TAP accounting"
>
> Currently if_tun.h uses IFNAMSIZ and it can't be compiled in userspace.
>
> This patch fixes it and also use more common approach of sending data
> to tun ioctl, without additional structure.
>
> https://jira.sw.ru/browse/PSBM-40629
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov at virtuozzo.com>
> Acked-by: Andrew Vagin <avagin at virtuozzo.com>
> ---
> drivers/net/tun.c | 16 ++++++----------
> include/uapi/linux/if.h | 2 ++
> include/uapi/linux/if_tun.h | 8 +-------
> 3 files changed, 9 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> index 779d73c..dd14140 100644
> --- a/drivers/net/tun.c
> +++ b/drivers/net/tun.c
> @@ -1921,17 +1921,12 @@ unlock:
>
> #ifdef CONFIG_VE_TUNTAP_ACCOUNTING
> /* setacctid_ioctl should be called under rtnl_lock */
> -static long setacctid_ioctl(struct file *file, void __user *argp)
> +static int tun_set_acctid(struct net *net, struct ifreq *ifr)
> {
> - struct tun_file *tfile = file->private_data;
> - struct tun_acctid info;
> struct net_device *dev;
> struct tun_struct *tun;
>
> - if (copy_from_user(&info, argp, sizeof(info)))
> - return -EFAULT;
> -
> - dev = __dev_get_by_name(tfile->net, info.ifname);
> + dev = __dev_get_by_name(net, ifr->ifr_name);
> if (dev == NULL)
> return -ENOENT;
>
> @@ -1943,7 +1938,7 @@ static long setacctid_ioctl(struct file *file, void __user *argp)
> if (tun->vestat) {
> venet_acct_put_stat(tun->vestat);
> }
> - tun->vestat = venet_acct_find_create_stat(info.acctid);
> + tun->vestat = venet_acct_find_create_stat(ifr->ifr_acctid);
> if (tun->vestat == NULL)
> return -ENOMEM;
>
> @@ -1965,7 +1960,8 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
> unsigned int ifindex;
> int ret;
>
> - if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
> + if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || cmd == TUNSETACCTID ||
> + _IOC_TYPE(cmd) == 0x89) {
> if (copy_from_user(&ifr, argp, ifreq_len))
> return -EFAULT;
> } else {
> @@ -1986,7 +1982,7 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
>
> #ifdef CONFIG_VE_TUNTAP_ACCOUNTING
> if (cmd == TUNSETACCTID) {
> - ret = setacctid_ioctl(file, argp);
> + ret = tun_set_acctid(tfile->net, &ifr);
> goto unlock;
> }
> #endif /* CONFIG_VE_TUNTAP_ACCOUNTING */
> diff --git a/include/uapi/linux/if.h b/include/uapi/linux/if.h
> index 1ec407b..49c472e 100644
> --- a/include/uapi/linux/if.h
> +++ b/include/uapi/linux/if.h
> @@ -194,6 +194,7 @@ struct ifreq {
> char ifru_newname[IFNAMSIZ];
> void __user * ifru_data;
> struct if_settings ifru_settings;
> + unsigned int ifru_acctid;
> } ifr_ifru;
> };
>
> @@ -214,6 +215,7 @@ struct ifreq {
> #define ifr_qlen ifr_ifru.ifru_ivalue /* Queue length */
> #define ifr_newname ifr_ifru.ifru_newname /* New name */
> #define ifr_settings ifr_ifru.ifru_settings /* Device/proto settings*/
> +#define ifr_acctid ifr_ifru.ifru_acctid /* New ve accounting identifier */
>
> /*
> * Structure used in SIOCGIFCONF request.
> diff --git a/include/uapi/linux/if_tun.h b/include/uapi/linux/if_tun.h
> index 81e791e..5952d4b 100644
> --- a/include/uapi/linux/if_tun.h
> +++ b/include/uapi/linux/if_tun.h
> @@ -60,7 +60,7 @@
> #define TUNGETFILTER _IOR('T', 219, struct sock_fprog)
>
> /* CONFIG_VE_TUNTAP_ACCOUNTING should be set */
> -#define TUNSETACCTID _IOW('T', 300, struct tun_acctid)
> +#define TUNSETACCTID _IOW('T', 300, struct ifreq)
>
> /* TUNSETIFF ifr flags */
> #define IFF_TUN 0x0001
> @@ -106,10 +106,4 @@ struct tun_filter {
> __u8 addr[0][ETH_ALEN];
> };
>
> -/* used as TUNSETACCTID ioctl parameter */
> -struct tun_acctid {
> - char ifname[IFNAMSIZ];
> - __u32 acctid;
> -};
> -
> #endif /* _UAPI__IF_TUN_H */
>
More information about the Devel
mailing list