Try to ignore the usual value restrictions of sockopt SO_RCVBUF when running

as root (with CAP_NET_ADMIN) by using SO_RCVBUFFORCE if possible.
pull/7/head
Oliver Hartkopp 2010-01-15 19:15:08 +00:00
parent 3c019ea611
commit 9327499121
1 changed files with 22 additions and 15 deletions

View File

@ -355,7 +355,7 @@ int main(int argc, char **argv)
if (silent == SILENT_INI) {
if (log) {
fprintf(stderr, "\nDisabled standard output while logging.");
fprintf(stderr, "Disabled standard output while logging.\n");
silent = SILENT_ON; /* disable output on stdout */
} else
silent = SILENT_OFF; /* default output */
@ -482,6 +482,12 @@ int main(int argc, char **argv)
int curr_rcvbuf_size;
socklen_t curr_rcvbuf_size_len = sizeof(curr_rcvbuf_size);
/* try SO_RCVBUFFORCE first, if we run with CAP_NET_ADMIN */
if (setsockopt(s[i], SOL_SOCKET, SO_RCVBUFFORCE,
&rcvbuf_size, sizeof(rcvbuf_size)) < 0) {
#ifdef DEBUG
printf("SO_RCVBUFFORCE failed so try SO_RCVBUF ...\n");
#endif
if (setsockopt(s[i], SOL_SOCKET, SO_RCVBUF,
&rcvbuf_size, sizeof(rcvbuf_size)) < 0) {
perror("setsockopt SO_RCVBUF");
@ -500,6 +506,7 @@ int main(int argc, char **argv)
fprintf(stderr, "The socket receive buffer size was "
"adjusted due to /proc/sys/net/core/rmem_max.\n");
}
}
if (timestamp || log || logfrmt) {