From owner-freebsd-bugs Mon Dec 23 05:20:05 1996 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.4/8.8.4) id FAA03664 for bugs-outgoing; Mon, 23 Dec 1996 05:20:05 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.8.4/8.8.4) id FAA03658; Mon, 23 Dec 1996 05:20:03 -0800 (PST) Resent-Date: Mon, 23 Dec 1996 05:20:03 -0800 (PST) Resent-Message-Id: <199612231320.FAA03658@freefall.freebsd.org> Resent-From: gnats (GNATS Management) Resent-To: freebsd-bugs Resent-Reply-To: FreeBSD-gnats@freefall.FreeBSD.org, hans@brandinnovators.com Received: from news.IAEhv.nl (root@news.IAEhv.nl [194.151.64.4]) by freefall.freebsd.org (8.8.4/8.8.4) with SMTP id FAA03299 for ; Mon, 23 Dec 1996 05:11:51 -0800 (PST) Received: from truk.brandinnovators.com (uucp@localhost) by news.IAEhv.nl (8.6.13/1.63) with IAEhv.nl; pid 9731 on Mon, 23 Dec 1996 14:04:20 +0100; id OAA09731 efrom: hans@truk.brandinnovators.com; eto: FreeBSD-gnats-submit@freebsd.org Received: by truk.brandinnovators.com (8.7.5/BI96070101) for <> id NAA01354; Mon, 23 Dec 1996 13:59:06 GMT Message-Id: <199612231359.NAA01354@truk.brandinnovators.com> Date: Mon, 23 Dec 1996 13:59:06 GMT From: hans@brandinnovators.com (Hans Zuidam) Reply-To: hans@brandinnovators.com To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.2 Subject: kern/2271: FIONREAD in if_tun.c wrong Sender: owner-bugs@freebsd.org X-Loop: FreeBSD.org Precedence: bulk >Number: 2271 >Category: kern >Synopsis: FIONREAD on tunnel device returns incorrect value. >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Dec 23 05:20:01 PST 1996 >Last-Modified: >Originator: Hans Zuidam >Organization: Brand Innovators B.V. >Release: FreeBSD 2.1.5-RELEASE i386 >Environment: tunnel device configured >Description: When doing a FIONREAD ioctl on the tunnel device, it returns the value of m_len, while it should return the value of m_pkthdr.len (if M_PKTHDR is set.) >How-To-Repeat: Using a propriatary TCP/IP stack it was discovered that large TCP packets would not be read correctly. The FIONREAD would report that there were 40 bytes in the packet, while there were actually many more. Note: none of the programs supplied with FreeBSD that use the tunnel device, use FIONREAD. All request as much as possible from a read. >Fix: Workaround by doing MAXINT reads (or something similar...) on a /dev/tun. Below is a patch which is believed to be correct. *** sys.org/net/if_tun.c Fri Dec 20 15:20:00 1996 --- sys/net/if_tun.c Mon Dec 23 09:51:22 1996 *************** *** 418,425 **** break; case FIONREAD: s = splimp(); ! if (tp->tun_if.if_snd.ifq_head) ! *(int *)data = tp->tun_if.if_snd.ifq_head->m_len; else *(int *)data = 0; splx(s); --- 418,429 ---- break; case FIONREAD: s = splimp(); ! if (tp->tun_if.if_snd.ifq_head) { ! if (tp->tun_if.if_snd.ifq_head->m_flags & M_PKTHDR) ! *(int *)data = tp->tun_if.if_snd.ifq_head->m_pkthdr.len; ! else ! *(int *)data = tp->tun_if.if_snd.ifq_head->m_len; ! } else *(int *)data = 0; splx(s); >Audit-Trail: >Unformatted: