[Click] Little hack to improve performance in userlevel fromdevice.cc element in BSD (Mac OS X)

Bubnov Dmitriy buba at luna-78.com
Mon Nov 22 19:15:16 EST 2010


Hi all,

I am using Click on Mac OS X in userlevel mode, and have found a poor prfomance in FromDevice element for that mode.

The problem is in missing actual call to ioctl with BIOCIMMEDIATE on pcap file descriptor at runtime, and without that ioctl pcap_fd left in buffered mode.

Here is a patched section of elements/userlevel/fromdevice.cc. First line is line 260 in original file:



//# if defined(BIOCIMMEDIATE) && !defined(__sun) // pcap/bpf ioctl, not in DLPI/bufmod
	{
	    int r, yes = 1;
	    if ((r = ioctl(pcap_fd, /*BIOCIMMEDIATE*/_IOW('B',112, u_int), &yes)) == -1)
		return errh->error("%s: BIOCIMMEDIATE: %s", ifname, strerror(errno));
	    /*else if (r != 0)
		  errh->warning("%s: BIOCIMMEDIATE returns %d", ifname, r);*/
	    errh->warning("%s: BIOCIMMEDIATE returns %d", ifname, r);
	}
//# endif



To force put pcap_fd in unbuffered mode, I commented out "#if defined" directives and insert a "_IOW('B',112, u_int)" instead of "BIOCIMMEDIATE" in "ioctl" to avoid include files conflicts.

It is just quick hack, not a solution! 
Hope that will be helpful for somebody.

--
Regards,
Dmitriy Bubnov


More information about the click mailing list