Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Networking
User Name
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.


  Search this Thread
Old 07-04-2013, 07:53 AM   #1
Registered: Mar 2011
Posts: 51
Blog Entries: 1

Rep: Reputation: 2
Question problem in getting more than 8 queue file descriptor from a tun device

hi all,
After I heared that after kernel 3.8 linux added multi queue ability to tun tap device with flag IFF_MULTI_QUEUE, I upgraded my kernel to 3.10 and have its header in /usr/src
then I altered my c code to have a thread to open a new queue file descriptor each time neaded.
but the thread could just open 8 queue (with my earlier than 3.8 kernel, it could not open queue at all) and after that I get this "Arguments too long" error from ioctl in

ioctl(fd, TUNSETIFF, (void *)&ifr)
then I wrote another program to test how much queue fd can be opend in my ubuntu 12.10 linux box with this
uname -r
kernel version in a much simpler program.

#include <net/if.h>
#include <linux/if_tun.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/socket.h> 
#include <sys/select.h>
#include <sys/time.h>
#include <errno.h>
#include <stdarg.h>

#include <netdb.h>

#define IFF_MULTI_QUEUE 0x0100
int tun_alloc_mq(char *dev, int queues, int *fds)
	struct ifreq ifr;
	int fd, err=-1, i;
	char *clonedev = "/dev/net/tun";

	if (!dev){
		return -1;

	memset(&ifr, 0, sizeof(ifr));
	ifr.ifr_flags = IFF_TAP | IFF_NO_PI | IFF_MULTI_QUEUE;
	strcpy(ifr.ifr_name, dev);
	int error=0;

	for (i = 0; i < queues; i++) {
		printf("loop %d\n",i);
		if( (fd = open(clonedev , O_RDWR)) < 0 ) {
		    perror("Opening /dev/net/tun");
		  if(ioctl(fd, TUNSETIFF, (void *)&ifr) < 0 ) {
		    printf("first error\n");
		return -1;
	return 0;
int main(int argc, char *argv[])
	int* fdsx;
	return 0;
and it turns out this is limited to 8 too. here is the output:

loop 0
loop 1
loop 2
loop 3
loop 4
loop 5
loop 6
loop 7
loop 8
first error
tun: Argument list too long
I tested it on another linux box and it had the same output.
So is there a limit to opening more than 8 queue from a tun device in kernel?
if so, how to fix that?
please help me with that
Old 07-05-2013, 07:27 AM   #2
Registered: Mar 2011
Posts: 51
Blog Entries: 1

Original Poster
Rep: Reputation: 2
there have not been any thoughts yet?
please if you could at least test this code in your machines and let me know about the results, it would be great for me...


queue, tuntap

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting File Descriptor for a USB device to pass to ioctl command linuxsy Linux - Kernel 0 08-07-2012 04:45 AM
Problem with ioctl function when openning TUN/TAP device on Linux. shmilt24 Linux - Newbie 2 09-10-2010 02:14 AM
usb device descriptor read / 64, error -71 problem edomingox Linux - Hardware 2 04-05-2010 06:51 AM
File descriptor problem huyangyang Linux - Newbie 6 11-10-2009 07:36 PM
vnuml tun device /dev/net/tun not found. asalford Linux - Networking 1 01-30-2007 10:11 PM > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 03:06 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration