diff options
author | Thomas Haller <thaller@redhat.com> | 2016-11-30 15:09:41 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2016-11-30 15:40:26 +0100 |
commit | 55ea6e6b6cd805f441b410971c9dd7575e783ef4 (patch) | |
tree | 674fa1461f678f54aa8750c72ffcaaf69945f559 /lib/nl.c | |
parent | 6f9620721200d171d6a317573b3c1c00141f036b (diff) | |
download | libnl-55ea6e6b6cd805f441b410971c9dd7575e783ef4.tar.gz |
lib: use MSG_PEEK by default for nl_recvmsgs()
The MSG_PEEK API of recvmsg() should be avoid because it requires an additional
syscall. But worse is to choose a too small buffer size and failing to receive
the message.
A user who is aware of the issue can avoid MSG_PEEK by either
nl_socket_disable_msg_peek()/nl_socket_enable_msg_peek() or by setting
a buffer size via nl_socket_set_msg_buf_size().
By default however we now use MSG_PEEK. This is more important since commit
90c6ebec9bd7a where the link dump request can be rather large.
Signed-off-by: Thomas Haller <thaller@redhat.com>
Diffstat (limited to 'lib/nl.c')
-rw-r--r-- | lib/nl.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -672,7 +672,8 @@ int nl_recv(struct nl_sock *sk, struct sockaddr_nl *nla, if (!buf || !nla) return -NLE_INVAL; - if (sk->s_flags & NL_MSG_PEEK) + if ( (sk->s_flags & NL_MSG_PEEK) + || (!(sk->s_flags & NL_MSG_PEEK_EXPLICIT) && sk->s_bufsize == 0)) flags |= MSG_PEEK | MSG_TRUNC; if (page_size == 0) @@ -736,7 +737,7 @@ retry: void *tmp; /* respond with error to an incomplete message */ - if (!(sk->s_flags & NL_MSG_PEEK)) { + if (flags == 0) { retval = -NLE_MSG_TRUNC; goto abort; } |