All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick McHardy <kaber@trash.net>
To: Julius Volz <juliusv@google.com>
Cc: netdev@vger.kernel.org, Vince Busam <vbusam@google.com>,
	Thomas Graf <tgraf@suug.ch>
Subject: Re: Sending big Netlink messages to userspace
Date: Tue, 24 Jun 2008 19:00:28 +0200	[thread overview]
Message-ID: <4861282C.4000208@trash.net> (raw)
In-Reply-To: <f4845fc0806240938h36d275ect109fd5f5414cba37@mail.gmail.com>

Julius Volz wrote:
> Hi,
> 
> While adding a Netlink interface to IPVS, I've been wondering how to
> properly send very big messages to userspace and found these posts:
> 
> http://lists.openwall.net/netdev/2007/03/06/214
> http://lists.openwall.net/netdev/2007/03/07/2
> 
> Herbert writes in the second one, "Dumps should be done using 4K
> (NLMSG_GOODSIZE) skb's, where is the problem?" How is that meant?
> Should one manually split up dumps into several NLMSG_GOODSIZE
> messages or is there some mechanism for that?

Thats done automatically through netlink_dump_start().
You send one skb per dump callback invocation. The final
call returns a zero sized skb to indicate the end of the
dump.

> I need to send arbitrarily long lists to userspace and I'm already
> choosing a big enough size for nlmsg_new(), so I get no put failures
> while constructing the message. However, when receiving the data in
> userspace (with libnl), the receive callback is never called. An
> strace shows that MSG_TRUNC is set in the oversized message, so the
> data is never fully received.

You probably need to increase the receive buffer size in libnl.

> I just call nl_recvmsgs_default(sock) once (which does not return an
> error). Am I handling libnl incorrectly or do I need to do this
> differently on the kernel side?

It depends on what kind of attributes you're sending. In case
of top-level attributes you should only dump objects until
you reach NLMSG_GOODSIZE and continue during the next dump
callback invocation. Sending arbitary amounts of nested
data is more tricky, or might even be impossible currently.

  reply	other threads:[~2008-06-24 17:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-24 16:38 Sending big Netlink messages to userspace Julius Volz
2008-06-24 17:00 ` Patrick McHardy [this message]
2008-06-24 18:18   ` Julius Volz
2008-06-25 10:44   ` Thomas Graf
2008-06-25 18:56     ` Julius Volz
2008-06-26 10:01       ` Thomas Graf
2008-06-25 22:51     ` David Miller
2008-06-26  0:41       ` Patrick McHardy
2008-06-26 15:39         ` Julius Volz

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=4861282C.4000208@trash.net \
    --to=kaber@trash.net \
    --cc=juliusv@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=tgraf@suug.ch \
    --cc=vbusam@google.com \
    /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.