Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 34250 - Problem with FD_SETSIZE using netcat
Summary: Problem with FD_SETSIZE using netcat
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: x86 All
: High trivial (vote)
Assignee: SpanKY
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-11-24 03:44 UTC by Frederic Mangeant
Modified: 2003-11-26 06:08 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
Change FD_SETSIZE from 16 to 1024 (netcat.diff,691 bytes, patch)
2003-11-26 06:08 UTC, Frederic Mangeant
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Frederic Mangeant 2003-11-24 03:44:28 UTC
Problem with FD_SETSIZE using netcat
Comment 1 Frederic Mangeant 2003-11-24 03:51:37 UTC
Hi

here's what can be found in netcat.c (release 110-r4):

/* have to do this *before* including types.h. xxx: Linux still has it wrong */
#ifdef FD_SETSIZE               /* should be in types.h, butcha never know. */
#undef FD_SETSIZE               /* if we ever need more than 16 active */
#endif                          /* fd's, something is horribly wrong! */
#define FD_SETSIZE 16           /* <-- this'll give us a long anyways, wtf */
#include <sys/types.h>          /* *now* do it.  Sigh, this is broken */

As FD_SETSIZE does'nt seem to be included in /usr/include/sys/types.h (linux-headers 2.4.19-r1), FD_SETSIZE=16.

Later in the netcat's code, we have :

if (fd > FD_SETSIZE) {
    holler ("Preposterous fd value %d", fd);
    return (1);
}

So netcat does'nt work if more than 16 files are opened. I'm using netcat within cacti, a rrdtool frontend. As a lot of files are opened, I got :

nc -vv xxx.xxx.xxx.xxx 50000 -w 5, output:
Preposterous fd value 71
 sent 0, rcvd 0

I've tweaked FD_SETSIZE=16 to FD_SETSIZE=1024, and now it works as expected :

nc -vv xxx.xxx.xxx.xxx 50000 -w 5, output: xxxxxxxxxxx
 sent 0, rcvd 17

Could you add this as a patch to the ebuild ?

Thanks in advance.

Regards,

Fr
Comment 2 Frederic Mangeant 2003-11-24 03:51:37 UTC
Hi

here's what can be found in netcat.c (release 110-r4):

/* have to do this *before* including types.h. xxx: Linux still has it wrong */
#ifdef FD_SETSIZE               /* should be in types.h, butcha never know. */
#undef FD_SETSIZE               /* if we ever need more than 16 active */
#endif                          /* fd's, something is horribly wrong! */
#define FD_SETSIZE 16           /* <-- this'll give us a long anyways, wtf */
#include <sys/types.h>          /* *now* do it.  Sigh, this is broken */

As FD_SETSIZE does'nt seem to be included in /usr/include/sys/types.h (linux-headers 2.4.19-r1), FD_SETSIZE=16.

Later in the netcat's code, we have :

if (fd > FD_SETSIZE) {
    holler ("Preposterous fd value %d", fd);
    return (1);
}

So netcat does'nt work if more than 16 files are opened. I'm using netcat within cacti, a rrdtool frontend. As a lot of files are opened, I got :

nc -vv xxx.xxx.xxx.xxx 50000 -w 5, output:
Preposterous fd value 71
 sent 0, rcvd 0

I've tweaked FD_SETSIZE=16 to FD_SETSIZE=1024, and now it works as expected :

nc -vv xxx.xxx.xxx.xxx 50000 -w 5, output: xxxxxxxxxxx
 sent 0, rcvd 17

Could you add this as a patch to the ebuild ?

Thanks in advance.

Regards,

Frédéric Mangeant


Comment 3 SpanKY gentoo-dev 2003-11-24 09:49:00 UTC
added this to -r4:
sed -i 's:#define FD_SETSIZE 16:#define FD_SETSIZE 1024:' netcat.c
Comment 4 Frederic Mangeant 2003-11-26 06:08:00 UTC
Created attachment 21312 [details, diff]
Change FD_SETSIZE from 16 to 1024