Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 28 Feb 1998 13:05:40 PST
From:      Bill Fenner <fenner@parc.xerox.com>
To:        Adel Abushaev <adel@ksu.ru>
Cc:        freebsd-bugs@FreeBSD.ORG
Subject:   Re: Possible ioctl() implementation mistake 
Message-ID:  <98Feb28.130552pst.177476@crevenia.parc.xerox.com>
In-Reply-To: Your message of "Sat, 28 Feb 98 09:50:28 PST." <199802281750.UAA07054@alpha.ksu.ru> 

next in thread | previous in thread | raw e-mail | index | archive | help
This is an old BSD bug.  It's also present in IRIX 6.2, OSF1 3.2, SunOS
4.1.3_U1, and NeXTStep 3.3 .

The problem is that the 16-byte sockaddr is stored in the receive
buffer too, for recvfrom() to return.  FIONREAD returns the amount of
data in the receive buffer, without worrying about whether it's really
data or control info.  For example, if I setsockopt(...,IP_RECVDSTADDR,...),
server's output becomes

ioctl: 544
recv: 512
ioctl: 0

since both the source and the destination are on the socket buffer queue.

There are a couple possible fixes:
1. Walk the socket buffer, adding up the lengths of MT_HEADER, MT_DATA
or MT_OOBDATA mbufs.  This is easy but it's a shame to convert an O(1)
function to an O(N) one.
2. Redefine sb_cc to be the data-only length (which appears to be the
intent in any case) and make sure that the sockbuf handling functions
manage it properly.  This may or may not be easy, depending on how much
other pieces of the system know about sockbuf internals.

  Bill

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?98Feb28.130552pst.177476>