Andrey, please review.
--
Best regards,
Konstantin Khorenko,
Virtuozzo Linux Kernel Team
On 11/11/2015 01:00 PM, Vladimir Sementsov-Ogievskiy wrote:
Patch b59e089eb2d : "ve/net: introduce TAP accounting" uses IFNAMSIZ
in if_tun.h 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.
#PSBM-40629:fixed
Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
---
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..b0c8933 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 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 */
_______________________________________________
Devel mailing list
[email protected]
https://lists.openvz.org/mailman/listinfo/devel