LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
Search this Thread
Old 07-04-2013, 07:53 AM   #1
pendrive
Member
 
Registered: Mar 2011
Posts: 51

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

Code:
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
Code:
uname -r
3.10.0-031000-generic
kernel version in a much simpler program.

Code:
//essential
#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){
		printf("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");
		    error=1;
		    break;
		  }
		
		  if(ioctl(fd, TUNSETIFF, (void *)&ifr) < 0 ) {
		    printf("first error\n");
		    error=1;
		    close(fd);
		    break;
		  }	
	}
	if(error==1)
		return -1;
	return 0;
}
int main(int argc, char *argv[])
{
	
	int* fdsx;
	if(tun_alloc_mq("testmqtun0",20,fdsx)<0)
	{
		perror("tun");
		exit(1);
	}
	return 0;
}
and it turns out this is limited to 8 too. here is the output:

Code:
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
pendrive
Member
 
Registered: Mar 2011
Posts: 51

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...
 
  


Reply

Tags
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


All times are GMT -5. The time now is 06:11 AM.

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