Patchwork [PATCHv2] tap: set IFF_ONE_QUEUE per default

login
register
mail settings
Submitter Peter Lieven
Date Feb. 15, 2013, 9:32 a.m.
Message ID <511E00AF.5070901@dlhnet.de>
Download mbox | patch
Permalink /patch/220692/
State New
Headers show

Comments

Peter Lieven - Feb. 15, 2013, 9:32 a.m.
historically the kernel queues packets two times. once
at the device and second in qdisc. this is believed to cause
interface stalls if one of these queues overruns.

setting IFF_ONE_QUEUE is the default in kernels >= 3.8. the
flag is ignored since then. see kernel commit
5d097109257c03a71845729f8db6b5770c4bbedc

v2:
  - do only set the flag on linux as it breaks macvtap
  - define IFF_ONE_QUEUE in tap-linux.h

Signed-off-by: Peter Lieven <pl@kamp.de>
---
  net/tap-linux.c |    4 ++++
  net/tap-linux.h |    1 +
  2 files changed, 5 insertions(+)
Stefan Hajnoczi - Feb. 15, 2013, 1:32 p.m.
On Fri, Feb 15, 2013 at 10:32:31AM +0100, Peter Lieven wrote:
> historically the kernel queues packets two times. once
> at the device and second in qdisc. this is believed to cause
> interface stalls if one of these queues overruns.
> 
> setting IFF_ONE_QUEUE is the default in kernels >= 3.8. the
> flag is ignored since then. see kernel commit
> 5d097109257c03a71845729f8db6b5770c4bbedc
> 
> v2:
>  - do only set the flag on linux as it breaks macvtap
>  - define IFF_ONE_QUEUE in tap-linux.h
> 
> Signed-off-by: Peter Lieven <pl@kamp.de>
> ---
>  net/tap-linux.c |    4 ++++
>  net/tap-linux.h |    1 +
>  2 files changed, 5 insertions(+)
> 
> diff --git a/net/tap-linux.c b/net/tap-linux.c
> index a953189..d49f2fd 100644
> --- a/net/tap-linux.c
> +++ b/net/tap-linux.c
> @@ -51,6 +51,10 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr,
>      memset(&ifr, 0, sizeof(ifr));
>      ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
> 
> +#ifdef __linux__
> +    ifr.ifr_flags |= IFF_ONE_QUEUE;
> +#endif

tap-linux.c  <--- notice the filename

Perhaps the solution is to try with IFF_ONE_QUEUE.  If the result is
-EINVAL, try without.

Stefan
Peter Lieven - Feb. 15, 2013, 2:27 p.m.
Am 15.02.2013 um 14:32 schrieb Stefan Hajnoczi <stefanha@gmail.com>:

> On Fri, Feb 15, 2013 at 10:32:31AM +0100, Peter Lieven wrote:
>> historically the kernel queues packets two times. once
>> at the device and second in qdisc. this is believed to cause
>> interface stalls if one of these queues overruns.
>> 
>> setting IFF_ONE_QUEUE is the default in kernels >= 3.8. the
>> flag is ignored since then. see kernel commit
>> 5d097109257c03a71845729f8db6b5770c4bbedc
>> 
>> v2:
>> - do only set the flag on linux as it breaks macvtap
>> - define IFF_ONE_QUEUE in tap-linux.h
>> 
>> Signed-off-by: Peter Lieven <pl@kamp.de>
>> ---
>> net/tap-linux.c |    4 ++++
>> net/tap-linux.h |    1 +
>> 2 files changed, 5 insertions(+)
>> 
>> diff --git a/net/tap-linux.c b/net/tap-linux.c
>> index a953189..d49f2fd 100644
>> --- a/net/tap-linux.c
>> +++ b/net/tap-linux.c
>> @@ -51,6 +51,10 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr,
>>     memset(&ifr, 0, sizeof(ifr));
>>     ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
>> 
>> +#ifdef __linux__
>> +    ifr.ifr_flags |= IFF_ONE_QUEUE;
>> +#endif
> 
> tap-linux.c  <--- notice the filename

i know. is qemu really using it on MACs?

Peter

> 
> Perhaps the solution is to try with IFF_ONE_QUEUE.  If the result is
> -EINVAL, try without.
> 
> Stefan
Christian Borntraeger - Feb. 15, 2013, 2:30 p.m.
On 15/02/13 15:27, Peter Lieven wrote:
> 
> Am 15.02.2013 um 14:32 schrieb Stefan Hajnoczi <stefanha@gmail.com>:
> 
>> On Fri, Feb 15, 2013 at 10:32:31AM +0100, Peter Lieven wrote:
>>> historically the kernel queues packets two times. once
>>> at the device and second in qdisc. this is believed to cause
>>> interface stalls if one of these queues overruns.
>>>
>>> setting IFF_ONE_QUEUE is the default in kernels >= 3.8. the
>>> flag is ignored since then. see kernel commit
>>> 5d097109257c03a71845729f8db6b5770c4bbedc
>>>
>>> v2:
>>> - do only set the flag on linux as it breaks macvtap
>>> - define IFF_ONE_QUEUE in tap-linux.h
>>>
>>> Signed-off-by: Peter Lieven <pl@kamp.de>
>>> ---
>>> net/tap-linux.c |    4 ++++
>>> net/tap-linux.h |    1 +
>>> 2 files changed, 5 insertions(+)
>>>
>>> diff --git a/net/tap-linux.c b/net/tap-linux.c
>>> index a953189..d49f2fd 100644
>>> --- a/net/tap-linux.c
>>> +++ b/net/tap-linux.c
>>> @@ -51,6 +51,10 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr,
>>>     memset(&ifr, 0, sizeof(ifr));
>>>     ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
>>>
>>> +#ifdef __linux__
>>> +    ifr.ifr_flags |= IFF_ONE_QUEUE;
>>> +#endif
>>
>> tap-linux.c  <--- notice the filename
> 
> i know. is qemu really using it on MACs?
> 

It has nothing todo with Apple products. Its about a linux kernel driver that provides
a tap like interface that can be attached to an network interface with MAC-address 
filtering.

http://virt.kernelnewbies.org/MacVTap

Christian
Peter Lieven - Feb. 18, 2013, 12:39 p.m.
On 15.02.2013 14:32, Stefan Hajnoczi wrote:
> On Fri, Feb 15, 2013 at 10:32:31AM +0100, Peter Lieven wrote:
>> historically the kernel queues packets two times. once
>> at the device and second in qdisc. this is believed to cause
>> interface stalls if one of these queues overruns.
>>
>> setting IFF_ONE_QUEUE is the default in kernels >= 3.8. the
>> flag is ignored since then. see kernel commit
>> 5d097109257c03a71845729f8db6b5770c4bbedc
>>
>> v2:
>>   - do only set the flag on linux as it breaks macvtap
>>   - define IFF_ONE_QUEUE in tap-linux.h
>>
>> Signed-off-by: Peter Lieven <pl@kamp.de>
>> ---
>>   net/tap-linux.c |    4 ++++
>>   net/tap-linux.h |    1 +
>>   2 files changed, 5 insertions(+)
>>
>> diff --git a/net/tap-linux.c b/net/tap-linux.c
>> index a953189..d49f2fd 100644
>> --- a/net/tap-linux.c
>> +++ b/net/tap-linux.c
>> @@ -51,6 +51,10 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr,
>>       memset(&ifr, 0, sizeof(ifr));
>>       ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
>>
>> +#ifdef __linux__
>> +    ifr.ifr_flags |= IFF_ONE_QUEUE;
>> +#endif
>
> tap-linux.c  <--- notice the filename
>
> Perhaps the solution is to try with IFF_ONE_QUEUE.  If the result is
> -EINVAL, try without.

Is IFF_ONE_QUEUE queryable with ioctl(fd, TUNGETFEATURES, &features) ?

Peter

>
> Stefan
>
Peter Lieven - Feb. 25, 2013, 8:13 a.m.
On 18.02.2013 13:39, Peter Lieven wrote:
> On 15.02.2013 14:32, Stefan Hajnoczi wrote:
>> On Fri, Feb 15, 2013 at 10:32:31AM +0100, Peter Lieven wrote:
>>> historically the kernel queues packets two times. once
>>> at the device and second in qdisc. this is believed to cause
>>> interface stalls if one of these queues overruns.
>>>
>>> setting IFF_ONE_QUEUE is the default in kernels >= 3.8. the
>>> flag is ignored since then. see kernel commit
>>> 5d097109257c03a71845729f8db6b5770c4bbedc
>>>
>>> v2:
>>>   - do only set the flag on linux as it breaks macvtap
>>>   - define IFF_ONE_QUEUE in tap-linux.h
>>>
>>> Signed-off-by: Peter Lieven <pl@kamp.de>
>>> ---
>>>   net/tap-linux.c |    4 ++++
>>>   net/tap-linux.h |    1 +
>>>   2 files changed, 5 insertions(+)
>>>
>>> diff --git a/net/tap-linux.c b/net/tap-linux.c
>>> index a953189..d49f2fd 100644
>>> --- a/net/tap-linux.c
>>> +++ b/net/tap-linux.c
>>> @@ -51,6 +51,10 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr,
>>>       memset(&ifr, 0, sizeof(ifr));
>>>       ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
>>>
>>> +#ifdef __linux__
>>> +    ifr.ifr_flags |= IFF_ONE_QUEUE;
>>> +#endif
>>
>> tap-linux.c  <--- notice the filename
>>
>> Perhaps the solution is to try with IFF_ONE_QUEUE.  If the result is
>> -EINVAL, try without.
>
> Is IFF_ONE_QUEUE queryable with ioctl(fd, TUNGETFEATURES, &features) ?
>
> Peter

Anyone?

Thanks,
Peter
Christian Borntraeger - Feb. 25, 2013, 8:17 a.m.
On 25/02/13 09:13, Peter Lieven wrote:

>>
>> Is IFF_ONE_QUEUE queryable with ioctl(fd, TUNGETFEATURES, &features) ?

Yes, that should work. The default tun/tap driver returns it, macvtap not.

Patch

diff --git a/net/tap-linux.c b/net/tap-linux.c
index a953189..d49f2fd 100644
--- a/net/tap-linux.c
+++ b/net/tap-linux.c
@@ -51,6 +51,10 @@  int tap_open(char *ifname, int ifname_size, int *vnet_hdr,
      memset(&ifr, 0, sizeof(ifr));
      ifr.ifr_flags = IFF_TAP | IFF_NO_PI;

+#ifdef __linux__
+    ifr.ifr_flags |= IFF_ONE_QUEUE;
+#endif
+
      if (*vnet_hdr) {
          unsigned int features;

diff --git a/net/tap-linux.h b/net/tap-linux.h
index 65087e1..13002fd 100644
--- a/net/tap-linux.h
+++ b/net/tap-linux.h
@@ -36,6 +36,7 @@ 
  /* TUNSETIFF ifr flags */
  #define IFF_TAP		0x0002
  #define IFF_NO_PI	0x1000
+#define IFF_ONE_QUEUE	0x2000
  #define IFF_VNET_HDR	0x4000
  #define IFF_MULTI_QUEUE 0x0100
  #define IFF_ATTACH_QUEUE 0x0200