* [PATCH] macvtap: add ioctl to modify vnet header size
@ 2010-04-29 13:51 Michael S. Tsirkin
2010-04-29 14:40 ` Arnd Bergmann
0 siblings, 1 reply; 6+ messages in thread
From: Michael S. Tsirkin @ 2010-04-29 13:51 UTC (permalink / raw)
To: David S. Miller, Arnd Bergmann, Sridhar Samudrala, Eric Dumazet,
Michael S. Tsirkin
This adds TUNSETVNETHDRSZ/TUNGETVNETHDRSZ support
to macvtap.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
This just mirrors the support in tun,
http://lkml.org/lkml/2010/3/17/221
so that we can make vhost mergeable buffers work with macvtap as well.
I plan to merge both patches through vhost tree together
with mergeable buffer support. Comments?
drivers/net/macvtap.c | 31 +++++++++++++++++++++++++++----
1 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
index d97e1fd..6451c4b 100644
--- a/drivers/net/macvtap.c
+++ b/drivers/net/macvtap.c
@@ -37,6 +37,7 @@
struct macvtap_queue {
struct sock sk;
struct socket sock;
+ int vnet_hdr_sz;
struct macvlan_dev *vlan;
struct file *file;
unsigned int flags;
@@ -280,6 +281,7 @@ static int macvtap_open(struct inode *inode, struct file *file)
sock_init_data(&q->sock, &q->sk);
q->sk.sk_write_space = macvtap_sock_write_space;
q->flags = IFF_VNET_HDR | IFF_NO_PI | IFF_TAP;
+ q->vnet_hdr_sz = sizeof(struct virtio_net_hdr);
err = macvtap_set_queue(dev, file, q);
if (err)
@@ -440,14 +442,14 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q,
int vnet_hdr_len = 0;
if (q->flags & IFF_VNET_HDR) {
- vnet_hdr_len = sizeof(vnet_hdr);
+ vnet_hdr_len = q->vnet_hdr_sz;
err = -EINVAL;
if ((len -= vnet_hdr_len) < 0)
goto err;
err = memcpy_fromiovecend((void *)&vnet_hdr, iv, 0,
- vnet_hdr_len);
+ sizeof(vnet_hdr));
if (err < 0)
goto err;
if ((vnet_hdr.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) &&
@@ -529,7 +531,7 @@ static ssize_t macvtap_put_user(struct macvtap_queue *q,
if (q->flags & IFF_VNET_HDR) {
struct virtio_net_hdr vnet_hdr;
- vnet_hdr_len = sizeof (vnet_hdr);
+ vnet_hdr_len = q->vnet_hdr_sz;
if ((len -= vnet_hdr_len) < 0)
return -EINVAL;
@@ -537,7 +539,7 @@ static ssize_t macvtap_put_user(struct macvtap_queue *q,
if (ret)
return ret;
- if (memcpy_toiovecend(iv, (void *)&vnet_hdr, 0, vnet_hdr_len))
+ if (memcpy_toiovecend(iv, (void *)&vnet_hdr, 0, sizeof(vnet_hdr)))
return -EFAULT;
}
@@ -622,6 +624,8 @@ static long macvtap_ioctl(struct file *file, unsigned int cmd,
struct ifreq __user *ifr = argp;
unsigned int __user *up = argp;
unsigned int u;
+ int __user *sp = argp;
+ int s;
int ret;
switch (cmd) {
@@ -667,6 +671,25 @@ static long macvtap_ioctl(struct file *file, unsigned int cmd,
q->sk.sk_sndbuf = u;
return 0;
+ case TUNGETVNETHDRSZ:
+ s = q->vnet_hdr_sz;
+ if (put_user(s, sp))
+ ret = -EFAULT;
+ break;
+
+ case TUNSETVNETHDRSZ:
+ if (get_user(s, sp)) {
+ ret = -EFAULT;
+ break;
+ }
+ if (s < (int)sizeof(struct virtio_net_hdr)) {
+ ret = -EINVAL;
+ break;
+ }
+
+ q->vnet_hdr_sz = s;
+ break;
+
case TUNSETOFFLOAD:
/* let the user check for future flags */
if (arg & ~(TUN_F_CSUM | TUN_F_TSO4 | TUN_F_TSO6 |
--
1.7.1.rc1.22.g3163
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] macvtap: add ioctl to modify vnet header size
2010-04-29 13:51 [PATCH] macvtap: add ioctl to modify vnet header size Michael S. Tsirkin
@ 2010-04-29 14:40 ` Arnd Bergmann
2010-05-03 6:32 ` David Miller
0 siblings, 1 reply; 6+ messages in thread
From: Arnd Bergmann @ 2010-04-29 14:40 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: David S. Miller, Sridhar Samudrala, Eric Dumazet, netdev,
linux-kernel, David Stevens
On Thursday 29 April 2010, Michael S. Tsirkin wrote:
> This adds TUNSETVNETHDRSZ/TUNGETVNETHDRSZ support
> to macvtap.
Looks good, thanks Michael!
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] macvtap: add ioctl to modify vnet header size
2010-04-29 14:40 ` Arnd Bergmann
@ 2010-05-03 6:32 ` David Miller
2010-05-03 6:34 ` David Miller
0 siblings, 1 reply; 6+ messages in thread
From: David Miller @ 2010-05-03 6:32 UTC (permalink / raw)
To: arnd; +Cc: mst, sri, eric.dumazet, netdev, linux-kernel, dlstevens
From: Arnd Bergmann <arnd@arndb.de>
Date: Thu, 29 Apr 2010 16:40:57 +0200
> On Thursday 29 April 2010, Michael S. Tsirkin wrote:
>> This adds TUNSETVNETHDRSZ/TUNGETVNETHDRSZ support
>> to macvtap.
>
> Looks good, thanks Michael!
>
>> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
>
> Acked-by: Arnd Bergmann <arnd@arndb.de>
Applied to net-next-2.6, thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] macvtap: add ioctl to modify vnet header size
2010-05-03 6:32 ` David Miller
@ 2010-05-03 6:34 ` David Miller
2010-05-03 7:55 ` Michael S. Tsirkin
0 siblings, 1 reply; 6+ messages in thread
From: David Miller @ 2010-05-03 6:34 UTC (permalink / raw)
To: arnd; +Cc: mst, sri, eric.dumazet, netdev, linux-kernel, dlstevens
From: David Miller <davem@davemloft.net>
Date: Sun, 02 May 2010 23:32:32 -0700 (PDT)
> From: Arnd Bergmann <arnd@arndb.de>
> Date: Thu, 29 Apr 2010 16:40:57 +0200
>
>> On Thursday 29 April 2010, Michael S. Tsirkin wrote:
>>> This adds TUNSETVNETHDRSZ/TUNGETVNETHDRSZ support
>>> to macvtap.
>>
>> Looks good, thanks Michael!
>>
>>> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
>>
>> Acked-by: Arnd Bergmann <arnd@arndb.de>
>
> Applied to net-next-2.6, thanks.
Nevermind, reverted:
drivers/net/macvtap.c: In function 'macvtap_ioctl':
drivers/net/macvtap.c:679:7: error: 'TUNGETVNETHDRSZ' undeclared (first use in this function)
drivers/net/macvtap.c:679:7: note: each undeclared identifier is reported only once for each function it appears in
drivers/net/macvtap.c:685:7: error: 'TUNSETVNETHDRSZ' undeclared (first use in this function)
What tree is this supposed to build under? Certinaly not net-2.6
or net-next-2.6
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] macvtap: add ioctl to modify vnet header size
2010-05-03 6:34 ` David Miller
@ 2010-05-03 7:55 ` Michael S. Tsirkin
2010-05-03 8:00 ` David Miller
0 siblings, 1 reply; 6+ messages in thread
From: Michael S. Tsirkin @ 2010-05-03 7:55 UTC (permalink / raw)
To: David Miller; +Cc: arnd, sri, eric.dumazet, netdev, linux-kernel, dlstevens
On Sun, May 02, 2010 at 11:34:39PM -0700, David Miller wrote:
> From: David Miller <davem@davemloft.net>
> Date: Sun, 02 May 2010 23:32:32 -0700 (PDT)
>
> > From: Arnd Bergmann <arnd@arndb.de>
> > Date: Thu, 29 Apr 2010 16:40:57 +0200
> >
> >> On Thursday 29 April 2010, Michael S. Tsirkin wrote:
> >>> This adds TUNSETVNETHDRSZ/TUNGETVNETHDRSZ support
> >>> to macvtap.
> >>
> >> Looks good, thanks Michael!
> >>
> >>> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> >>
> >> Acked-by: Arnd Bergmann <arnd@arndb.de>
> >
> > Applied to net-next-2.6, thanks.
>
> Nevermind, reverted:
>
> drivers/net/macvtap.c: In function 'macvtap_ioctl':
> drivers/net/macvtap.c:679:7: error: 'TUNGETVNETHDRSZ' undeclared (first use in this function)
> drivers/net/macvtap.c:679:7: note: each undeclared identifier is reported only once for each function it appears in
> drivers/net/macvtap.c:685:7: error: 'TUNSETVNETHDRSZ' undeclared (first use in this function)
>
> What tree is this supposed to build under? Certinaly not net-2.6
> or net-next-2.6
The reason is it needs to be applied on top of the patch that adds the
same header to tun that you acked. I put this in patch description:
> I plan to merge both patches through vhost tree together
> with mergeable buffer support. Comments?
In other words, this will be included in a pull request that I
intend to send out shortly.
--
MST
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] macvtap: add ioctl to modify vnet header size
2010-05-03 7:55 ` Michael S. Tsirkin
@ 2010-05-03 8:00 ` David Miller
0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2010-05-03 8:00 UTC (permalink / raw)
To: mst; +Cc: arnd, sri, eric.dumazet, netdev, linux-kernel, dlstevens
From: "Michael S. Tsirkin" <mst@redhat.com>
Date: Mon, 3 May 2010 10:55:11 +0300
> On Sun, May 02, 2010 at 11:34:39PM -0700, David Miller wrote:
>> What tree is this supposed to build under? Certinaly not net-2.6
>> or net-next-2.6
>
> The reason is it needs to be applied on top of the patch that adds the
> same header to tun that you acked. I put this in patch description:
>> I plan to merge both patches through vhost tree together
>> with mergeable buffer support. Comments?
> In other words, this will be included in a pull request that I
> intend to send out shortly.
works for me:
Acked-by: David S. Miller <davem@davemloft.net>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-05-03 8:00 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-29 13:51 [PATCH] macvtap: add ioctl to modify vnet header size Michael S. Tsirkin
2010-04-29 14:40 ` Arnd Bergmann
2010-05-03 6:32 ` David Miller
2010-05-03 6:34 ` David Miller
2010-05-03 7:55 ` Michael S. Tsirkin
2010-05-03 8:00 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).