Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 23 Dec 1996 13:59:06 GMT
From:      hans@brandinnovators.com (Hans Zuidam)
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   kern/2271: FIONREAD in if_tun.c wrong
Message-ID:  <199612231359.NAA01354@truk.brandinnovators.com>
Resent-Message-ID: <199612231320.FAA03658@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>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:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199612231359.NAA01354>