Subject: Bug in if_tun.c
To: None <netbsd-bugs@NetBSD.ORG>
From: Bob Smart <smart@mel.dit.csiro.au>
List: netbsd-bugs
Date: 12/11/1995 10:56:45
The FIONREAD ioctl is wrong for the tunnel driver. It only returns
the first link of the mbuf chain whereas the read will return the
lot. I admit that I haven't tested this under netbsd. This patch
applies to the SunOS 4.1.x version of if_tun.c. It should be
easy to apply the equivalent patch to the netbsd version. I presume
netbsd is the repository of BSD correctness these days.
Bob Smart
*** OLD/andrew/sunos/if_tun.c Fri Dec 8 18:31:12 1995
--- if_tun.c Sun Dec 10 13:14:20 1995
***************
*** 13,18 ****
--- 13,21 ----
*
* $Header: if_tun.c,v 1.13 88/07/11 08:28:51 jpo Exp $
*
+ * Revision 1.14 95/12/10 rks
+ * fix for FIONREAD ioctl
+ *
* $Log: if_tun.c,v $
* Revision 1.13 88/07/11 08:28:51 jpo
* Some tidying up
***************
*** 422,429 ****
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);
break;
--- 425,435 ----
case FIONREAD:
s = splimp ();
! if (tp->tun_if.if_snd.ifq_head) {
! struct mbuf *mb = tp->tun_if.if_snd.ifq_head;
! for( *(int *)data = 0; mb != 0; mb = mb->m_next)
! *(int *)data += mb->m_len;
! }
else *(int *)data = 0;
splx (s);
break;