diff mbox

[v3] tcp: ioctl type SIOCOUTQNSD returns amount of data not sent

Message ID 1299441595-18455-1-git-send-email-sledz@dresearch.de
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Steffen Sledz March 6, 2011, 7:59 p.m. UTC
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/linux/sockios.h |    4 +++-
 net/ipv4/tcp.c          |    9 +++++++++
 2 files changed, 12 insertions(+), 1 deletions(-)

Comments

Steffen Sledz March 8, 2011, 11:57 a.m. UTC | #1
Am 06.03.2011 20:59, schrieb 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/linux/sockios.h |    4 +++-
>  net/ipv4/tcp.c          |    9 +++++++++
>  2 files changed, 12 insertions(+), 1 deletions(-)

This is the patch version modified according to the comments from Alan Cox.

Anything else to do?

Steffen
David Miller March 8, 2011, 6:48 p.m. UTC | #2
From: Steffen Sledz <sledz@dresearch.de>
Date: Tue, 08 Mar 2011 12:57:22 +0100

> Anything else to do?

Be patient.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller March 9, 2011, 10:09 p.m. UTC | #3
From: Steffen Sledz <sledz@dresearch.de>
Date: Sun,  6 Mar 2011 20:59:55 +0100

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

Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Hagen Paul Pfeifer March 10, 2011, 10:12 p.m. UTC | #4
* David Miller | 2011-03-09 14:09:51 [-0800]:

>From: Steffen Sledz <sledz@dresearch.de>
>Date: Sun,  6 Mar 2011 20:59:55 +0100
>
>> 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>
>
>Applied, thanks.

A little bit late - but why not using struct tcp_info for that? The
information is already provided via getsockopt(TCP_INFO).

Hagen
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller March 10, 2011, 10:16 p.m. UTC | #5
From: Hagen Paul Pfeifer <hagen@jauu.net>
Date: Thu, 10 Mar 2011 23:12:05 +0100

> * David Miller | 2011-03-09 14:09:51 [-0800]:
> 
>>From: Steffen Sledz <sledz@dresearch.de>
>>Date: Sun,  6 Mar 2011 20:59:55 +0100
>>
>>> 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>
>>
>>Applied, thanks.
> 
> A little bit late - but why not using struct tcp_info for that? The
> information is already provided via getsockopt(TCP_INFO).

It's pretty heavy handed to copy that entire TCP_INFO struct into
userspace during every I/O sequence the application makes.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/include/linux/sockios.h b/include/linux/sockios.h
index 241f179..7997a50 100644
--- a/include/linux/sockios.h
+++ b/include/linux/sockios.h
@@ -22,7 +22,7 @@ 
 
 /* Linux-specific socket ioctls */
 #define SIOCINQ		FIONREAD
-#define SIOCOUTQ	TIOCOUTQ
+#define SIOCOUTQ	TIOCOUTQ        /* output queue size (not sent + not acked) */
 
 /* Routing table calls. */
 #define SIOCADDRT	0x890B		/* add routing table entry	*/
@@ -83,6 +83,8 @@ 
 
 #define SIOCWANDEV	0x894A		/* get/set netdev parameters	*/
 
+#define SIOCOUTQNSD	0x894B		/* output queue size (not sent only) */
+
 /* ARP cache control calls. */
 		    /*  0x8950 - 0x8952  * obsolete calls, don't re-use */
 #define SIOCDARP	0x8953		/* delete ARP 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;
 	}