All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Medialy <medialy@gmail.com>
Cc: netfilter@vger.kernel.org
Subject: Re: Why "No buffer space available"?
Date: Wed, 30 Dec 2009 13:10:24 +0100	[thread overview]
Message-ID: <4B3B4330.4050304@netfilter.org> (raw)
In-Reply-To: <cc73a9220912281849qf25a81evdb6082197d037917@mail.gmail.com>

Medialy wrote:
> Hi,
> I have written a program to log the nat behavior. the program works
> well when traffic is low. But when the traffic reaches 1Gb, program
> always error.
> According to the previous discussions about this problem, I even set
> the recv buffer size to 50MB and the error still exists.

Increasing the buffer size would not solve the problem, that will only 
delay the ENOBUFS error. There are several reasons why you may hit ENOBUFS:

a) your program is too slow to handle the Netlink messages that you 
receive from the kernel at a given rate. This is easier to trigger if 
the handling that you perform on every message takes too long.
b) the queue size is too small, but this does not seem to be your case.

ENOBUFS basically means that the kernel has to drop Netlink messages 
because your user-space program cannot back-off.

> For every callback, format the data and then put it into the queue
> directly.  The formating of data causes less then 1 second for 0.65
> million records.
> Errors always occurs  when there are less than 10 log records.

I don't understand what you mean here above.

BTW, if you use a recent Linux kernel (>=2.6.30) you can set these two 
socket options not to get ENOBUFS error and to try to improve ctnetlink 
reliability.

int on = 1;

setsockopt(nfct_fd(h), SOL_NETLINK,
            NETLINK_BROADCAST_SEND_ERROR, &on, sizeof(int));

setsockopt(nfct_fd(h), SOL_NETLINK,
            NETLINK_NO_ENOBUFS, &on, sizeof(int));

  reply	other threads:[~2009-12-30 12:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cc73a9220912281846h6a337b76ud7d9d1f61371f21e@mail.gmail.com>
2009-12-29  2:49 ` Why "No buffer space available"? Medialy
2009-12-30 12:10   ` Pablo Neira Ayuso [this message]
     [not found]     ` <c29e3bea0912301743k7f7bda48o17ce78d4521a7585@mail.gmail.com>
2009-12-31 11:31       ` Pablo Neira Ayuso

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4B3B4330.4050304@netfilter.org \
    --to=pablo@netfilter.org \
    --cc=medialy@gmail.com \
    --cc=netfilter@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.