* Possible bug in netlink_recvmsg()
@ 2007-04-13 18:08 David Howells
2007-04-13 21:11 ` David Miller
0 siblings, 1 reply; 3+ messages in thread
From: David Howells @ 2007-04-13 18:08 UTC (permalink / raw)
To: netdev
As I understand it, according to the recvmsg() manual page, if the packet
being returned is larger than the buffer provided, and the protocol does not
support piecemeal reception of data, then:
(1) the buffer should be filled,
(2) MSG_TRUNC should be set in msg_flags, and
(3) the length of the full packet, including the discarded bit should be
returned.
AF_NETLINK sockets, however, do not do (3). See this bit in netlink_recvmsg():
copied = skb->len;
if (len < copied) {
msg->msg_flags |= MSG_TRUNC;
copied = len;
}
Or is this only true if the caller of recvmsg() passes MSG_TRUNC in?
David
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: Possible bug in netlink_recvmsg()
2007-04-13 18:08 Possible bug in netlink_recvmsg() David Howells
@ 2007-04-13 21:11 ` David Miller
2007-04-19 16:07 ` David Howells
0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2007-04-13 21:11 UTC (permalink / raw)
To: dhowells; +Cc: netdev
From: David Howells <dhowells@redhat.com>
Date: Fri, 13 Apr 2007 19:08:31 +0100
> AF_NETLINK sockets, however, do not do (3). See this bit in netlink_recvmsg():
>
> copied = skb->len;
> if (len < copied) {
> msg->msg_flags |= MSG_TRUNC;
> copied = len;
> }
>
> Or is this only true if the caller of recvmsg() passes MSG_TRUNC in?
See this fix in my net-2.6.22 tree:
commit ad495d7b6cfcd1bc2eaf06c42699be0bb5d84234
Author: David S. Miller <davem@sunset.davemloft.net>
Date: Tue Mar 6 17:02:35 2007 -0800
[NETLINK]: Mirror UDP MSG_TRUNC semantics.
If the user passes MSG_TRUNC in via msg_flags, return
the full packet size not the truncated size.
Idea from Herbert Xu and Thomas Graf.
Signed-off-by: David S. Miller <davem@davemloft.net>
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index e73d8f5..b31a732 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -1242,6 +1242,9 @@ static int netlink_recvmsg(struct kiocb *kiocb, struct socket *sock,
scm_recv(sock, msg, siocb->scm, flags);
+ if (flags & MSG_TRUNC)
+ copied = skb->len;
+
out:
netlink_rcv_wake(sk);
return err ? : copied;
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: Possible bug in netlink_recvmsg()
2007-04-13 21:11 ` David Miller
@ 2007-04-19 16:07 ` David Howells
0 siblings, 0 replies; 3+ messages in thread
From: David Howells @ 2007-04-19 16:07 UTC (permalink / raw)
To: David Miller; +Cc: netdev
David Miller <davem@davemloft.net> wrote:
> See this fix in my net-2.6.22 tree:
>
> commit ad495d7b6cfcd1bc2eaf06c42699be0bb5d84234
> Author: David S. Miller <davem@sunset.davemloft.net>
> Date: Tue Mar 6 17:02:35 2007 -0800
Ummm... That seems to conflict with something in your net-2.6 tree. Which one
should I use?
David
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-04-19 16:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-13 18:08 Possible bug in netlink_recvmsg() David Howells
2007-04-13 21:11 ` David Miller
2007-04-19 16:07 ` David Howells
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).