Re: udp(7) and MSG_TRUNC

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 21 Jul 2004, David S. Miller wrote:

On Mon, 12 Jul 2004 22:34:34 +0000 (UTC)
Alexey Toptygin <alexeyt@freeshell.org> wrote:

But, in both 2.4 and 2.6 it doesn't seem to be honoring that.

It is honoring the man page section that you are quoting. On return from recvmsg() UDP will set MSG_TRUNC in the msg_flags if the users's buffer is smaller than the packet length.

The patch you have made reference to does something different,
if MSG_TRUNC is passed _IN_ to recvmsg() by the user, this
modifies what length will be returned.

Sorry, I was quoting the wrong man page. I wanted to quote recv(2) where it says:


    MSG_TRUNC
	Return  the  real  length of the packet, even when it was longer
	than the passed buffer. Only valid for packet sockets.

The patch linked from my email fixes that, but only for ipv4 udp (which is why I initially misquoted from udp(7) ).

In any event, that patch is useful and I'm going to apply it.

I didn't hear from anyone for a while, so I assumed the man page was wrong, and sent a patch for the recv(2) manpage to Andries Brouwer.
I might have to unsend that now :-)


Also, since this seems to be a fairly generic datagram socket thing, one might try to do it in sys_recvmsg or something (or at least similarly patch af_unix and raw ip). I can try to come up with something, if there is interest.

In any case, the previously linked patch is incomplete (ipv4/udp only), so I don't think it's ready for application.

Finally, would changing this have a non-trivial chance of breaking userspace code that was assuming the old behavior? Like, if a msghdr structure is used for multiple calls to recvmsg, and an earlier call sets MSG_TRUNC on output, and then a later call gets it back in on input?

			Alexey
-
: send the line "unsubscribe linux-net" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux