Netdev List
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Roy Marples <roy@marples.name>
Cc: netdev@vger.kernel.org
Subject: Re: recv(2), MSG_TRUNK and kernels older than 2.6.22
Date: Tue, 20 Jul 2010 10:54:59 +0200	[thread overview]
Message-ID: <1279616099.2498.9.camel@edumazet-laptop> (raw)
In-Reply-To: <4C455DC3.1050304@marples.name>

Le mardi 20 juillet 2010 à 09:26 +0100, Roy Marples a écrit :
> Hi
> 
> I would like to support all possible kernels I can and previously used a 
> fixed buffer of size 256 to read from netlink sockets. This is now 
> proving too small for some 64-bit kernels so I would like to use recv(2) 
> with MSG_TRUNK to wor out the size. However, the man page says that this 
> only works for 2.6.22 kernels or newer.
> 
> My question is, what is the behaviour of recv on older kernels where 
> MSG_TRUNC is not supported? I would rather not use some arbitary size if 
> at all possible.
> 

Is it for the dhcpcd problem we talk about few week ago, disturbed by
new 64bit stats ?

Why do you want to have a fixed size of 256 bytes ?

Using 8192 bytes on stack would avoid MSG_TRUNK mess.

static int
get_netlink(int fd, int flags,
    int (*callback)(struct nlmsghdr *))
{
        char buffer[8192];
        ssize_t bytes;
        struct nlmsghdr *nlm;
        int r = -1;

        for (;;) {
                bytes = recv(fd, buffer, sizeof(buffer), flags);
                if (bytes == -1) {
                        if (errno == EAGAIN) {
                                r = 0;
                                goto eexit;
                        }
                        if (errno == EINTR)
                                continue;
                        goto eexit;
                }





  reply	other threads:[~2010-07-20  8:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-20  8:26 recv(2), MSG_TRUNK and kernels older than 2.6.22 Roy Marples
2010-07-20  8:54 ` Eric Dumazet [this message]
2010-07-20  9:08   ` Roy Marples
2010-07-20  9:24     ` Eric Dumazet
2010-07-20 10:02       ` Eric Dumazet
2010-07-20 10:04         ` Roy Marples

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=1279616099.2498.9.camel@edumazet-laptop \
    --to=eric.dumazet@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=roy@marples.name \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox