summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1995-12-11 13:24:58 +0000
committerpeter <peter@FreeBSD.org>1995-12-11 13:24:58 +0000
commit286d95551f8211bbe15b8be12c6eaf9325c1232f (patch)
tree63e57ac213a78a36778e0a60e506d9af6f437fbf
parent7a7fb14fa9b36f5a77f0861c85e6bb995aa6b757 (diff)
downloadFreeBSD-src-286d95551f8211bbe15b8be12c6eaf9325c1232f.zip
FreeBSD-src-286d95551f8211bbe15b8be12c6eaf9325c1232f.tar.gz
Make FIONREAD return the actual that a read() would return, not just the
amount of data in the first mbuf. Obtained from: Bob Smart <smart@mel.dit.csiro.au> (for NetBSD & SunOS)
-rw-r--r--sys/net/if_tun.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c
index 675995f..a9db860 100644
--- a/sys/net/if_tun.c
+++ b/sys/net/if_tun.c
@@ -431,9 +431,11 @@ tunioctl(dev, cmd, data, flag, p)
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
+ 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;
OpenPOWER on IntegriCloud