netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH resent] tcp: ioctl type SIOCOUTQNSD returns amount of data not sent
@ 2011-03-04  8:48 Steffen Sledz
  2011-03-04  9:04 ` David Miller
  0 siblings, 1 reply; 13+ messages in thread
From: Steffen Sledz @ 2011-03-04  8:48 UTC (permalink / raw)
  To: netdev, linux-kernel
  Cc: David S. Miller, Alexey Kuznetsov, Pekka Savola (ipv6),
	James Morris, Hideaki YOSHIFUJI, Patrick McHardy,
	Mario Schuknecht, Steffen Sledz

From: Mario Schuknecht <m.schuknecht@dresearch.de>

In contrast to SIOCOUTQ which returns the amount of data sent
but not yet acknowledged plus data not yet sent this patch only
returns the data not sent.

For various methods of live streaming bitrate control it may
be helpful to know how much data are in the tcp outqueue are
not sent yet.

Signed-off-by: Mario Schuknecht <m.schuknecht@dresearch.de>
Signed-off-by: Steffen Sledz <sledz@dresearch.de>
---
 include/asm-generic/ioctls.h |    1 +
 include/linux/sockios.h      |    1 +
 net/ipv4/tcp.c               |    9 +++++++++
 3 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/include/asm-generic/ioctls.h b/include/asm-generic/ioctls.h
index 199975f..ef2be0b 100644
--- a/include/asm-generic/ioctls.h
+++ b/include/asm-generic/ioctls.h
@@ -74,6 +74,7 @@
 #define TCSETXW		0x5435
 #define TIOCSIG		_IOW('T', 0x36, int)  /* pty: generate signal */
 #define TIOCVHANGUP	0x5437
+#define TIOCOUTQNSD	0x5438
 
 #define FIONCLEX	0x5450
 #define FIOCLEX		0x5451
diff --git a/include/linux/sockios.h b/include/linux/sockios.h
index 241f179..4c5ca47 100644
--- a/include/linux/sockios.h
+++ b/include/linux/sockios.h
@@ -23,6 +23,7 @@
 /* Linux-specific socket ioctls */
 #define SIOCINQ		FIONREAD
 #define SIOCOUTQ	TIOCOUTQ
+#define SIOCOUTQNSD	TIOCOUTQNSD
 
 /* Routing table calls. */
 #define SIOCADDRT	0x890B		/* add routing table entry	*/
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index a17a5a7..b22d450 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -505,6 +505,15 @@ int tcp_ioctl(struct sock *sk, int cmd, unsigned long arg)
 		else
 			answ = tp->write_seq - tp->snd_una;
 		break;
+	case SIOCOUTQNSD:
+		if (sk->sk_state == TCP_LISTEN)
+			return -EINVAL;
+
+		if ((1 << sk->sk_state) & (TCPF_SYN_SENT | TCPF_SYN_RECV))
+			answ = 0;
+		else
+			answ = tp->write_seq - tp->snd_nxt;
+		break;
 	default:
 		return -ENOIOCTLCMD;
 	}
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2011-03-10 22:16 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-04  8:48 [PATCH resent] tcp: ioctl type SIOCOUTQNSD returns amount of data not sent Steffen Sledz
2011-03-04  9:04 ` David Miller
2011-03-04  9:51   ` Steffen Sledz
2011-03-04  9:57     ` Arnd Bergmann
2011-03-04 10:20       ` [PATCH v2] " Steffen Sledz
2011-03-04 12:26         ` Steffen Sledz
2011-03-04 12:39           ` Alan Cox
2011-03-06 19:59             ` [PATCH v3] " Steffen Sledz
2011-03-08 11:57               ` Steffen Sledz
2011-03-08 18:48                 ` David Miller
2011-03-09 22:09               ` David Miller
2011-03-10 22:12                 ` Hagen Paul Pfeifer
2011-03-10 22:16                   ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).