linux-kernel.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

* Re: [PATCH resent] tcp: ioctl type SIOCOUTQNSD returns amount of data not sent
  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
  0 siblings, 1 reply; 13+ messages in thread
From: David Miller @ 2011-03-04  9:04 UTC (permalink / raw)
  To: sledz
  Cc: netdev, linux-kernel, kuznet, pekkas, jmorris, yoshfuji, kaber,
	m.schuknecht

From: Steffen Sledz <sledz@dresearch.de>
Date: Fri,  4 Mar 2011 09:48:17 +0100

> 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

Hitting only asm-generic/ioctls.h is insufficient, many architectures do
not make use of this file and the build will fail for them with your patch
applied.

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

* Re: [PATCH resent] tcp: ioctl type SIOCOUTQNSD returns amount of data not sent
  2011-03-04  9:04 ` David Miller
@ 2011-03-04  9:51   ` Steffen Sledz
  2011-03-04  9:57     ` Arnd Bergmann
  0 siblings, 1 reply; 13+ messages in thread
From: Steffen Sledz @ 2011-03-04  9:51 UTC (permalink / raw)
  To: David Miller
  Cc: netdev, linux-kernel, kuznet, pekkas, jmorris, yoshfuji, kaber,
	m.schuknecht

Am 04.03.2011 10:04, schrieb David Miller:
> From: Steffen Sledz <sledz@dresearch.de>
> Date: Fri,  4 Mar 2011 09:48:17 +0100
> 
>> 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
> 
> Hitting only asm-generic/ioctls.h is insufficient, many architectures do
> not make use of this file and the build will fail for them with your patch
> applied.

That's not fully clear to me.

We made the define similar to the existing TIOCOUTQ. What other files should be hit?

Steffen Sledz

-- 
DResearch Fahrzeugelektronik GmbH
Otto-Schmirgal-Str. 3, 10319 Berlin, Germany
Tel: +49 30 515932-237 mailto:sledz@DResearch.de
Fax: +49 30 515932-299
Geschäftsführer: Dr. Michael Weber, Werner Mögle;
Amtsgericht Berlin Charlottenburg; HRB 130120 B;
Ust.-IDNr. DE273952058


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

* Re: [PATCH resent] tcp: ioctl type SIOCOUTQNSD returns amount of data not sent
  2011-03-04  9:51   ` Steffen Sledz
@ 2011-03-04  9:57     ` Arnd Bergmann
  2011-03-04 10:20       ` [PATCH v2] " Steffen Sledz
  0 siblings, 1 reply; 13+ messages in thread
From: Arnd Bergmann @ 2011-03-04  9:57 UTC (permalink / raw)
  To: Steffen Sledz
  Cc: David Miller, netdev, linux-kernel, kuznet, pekkas, jmorris,
	yoshfuji, kaber, m.schuknecht

On Friday 04 March 2011 10:51:29 Steffen Sledz wrote:
> Am 04.03.2011 10:04, schrieb David Miller:

> > Hitting only asm-generic/ioctls.h is insufficient, many architectures do
> > not make use of this file and the build will fail for them with your patch
> > applied.
> 
> That's not fully clear to me.
> 
> We made the define similar to the existing TIOCOUTQ. What other files should be hit?
> 

These ones:

$ git grep TIOCOUTQ arch/*/include/
arch/alpha/include/asm/ioctls.h:#define TIOCOUTQ        _IOR('t', 115, int)     /* output queue size */
arch/mips/include/asm/ioctls.h:#define TIOCOUTQ 0x7472          /* output queue size */
arch/parisc/include/asm/ioctls.h:#define TIOCOUTQ       0x5411
arch/powerpc/include/asm/ioctls.h:#define TIOCOUTQ        _IOR('t', 115, int)     /* output queue size */
arch/sh/include/asm/ioctls.h:#define TIOCOUTQ        _IOR('t', 115, int)     /* output queue size */
arch/sparc/include/asm/ioctls.h:#define TIOCOUTQ        _IOR('t', 115, int)
arch/xtensa/include/asm/ioctls.h:#define TIOCOUTQ        _IOR('t', 115, int)     /* output queue size */

	Arnd

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

* [PATCH v2] tcp: ioctl type SIOCOUTQNSD returns amount of data not sent
  2011-03-04  9:57     ` Arnd Bergmann
@ 2011-03-04 10:20       ` Steffen Sledz
  2011-03-04 12:26         ` Steffen Sledz
  0 siblings, 1 reply; 13+ messages in thread
From: Steffen Sledz @ 2011-03-04 10:20 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>
---
 arch/alpha/include/asm/ioctls.h   |    3 ++-
 arch/mips/include/asm/ioctls.h    |    3 ++-
 arch/parisc/include/asm/ioctls.h  |    3 ++-
 arch/powerpc/include/asm/ioctls.h |    3 ++-
 arch/sh/include/asm/ioctls.h      |    3 ++-
 arch/sparc/include/asm/ioctls.h   |    3 ++-
 arch/xtensa/include/asm/ioctls.h  |    3 ++-
 include/asm-generic/ioctls.h      |    3 ++-
 include/linux/sockios.h           |    1 +
 net/ipv4/tcp.c                    |    9 +++++++++
 10 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/arch/alpha/include/asm/ioctls.h b/arch/alpha/include/asm/ioctls.h
index 80e1cee..5ceb2de 100644
--- a/arch/alpha/include/asm/ioctls.h
+++ b/arch/alpha/include/asm/ioctls.h
@@ -35,12 +35,13 @@
 #define TIOCGWINSZ	_IOR('t', 104, struct winsize)
 #define	TIOCSTART	_IO('t', 110)		/* start output, like ^Q */
 #define	TIOCSTOP	_IO('t', 111)		/* stop output, like ^S */
-#define TIOCOUTQ        _IOR('t', 115, int)     /* output queue size */
+#define TIOCOUTQ        _IOR('t', 115, int)     /* output queue size (not send + not acked) */
 
 #define TIOCGLTC	_IOR('t', 116, struct ltchars)
 #define TIOCSLTC	_IOW('t', 117, struct ltchars)
 #define TIOCSPGRP	_IOW('t', 118, int)
 #define TIOCGPGRP	_IOR('t', 119, int)
+#define TIOCOUTQNSD     _IOR('t', 120, int)     /* output queue size (not send only) */
 
 #define TIOCEXCL	0x540C
 #define TIOCNXCL	0x540D
diff --git a/arch/mips/include/asm/ioctls.h b/arch/mips/include/asm/ioctls.h
index 92403c3..dd8d8c5 100644
--- a/arch/mips/include/asm/ioctls.h
+++ b/arch/mips/include/asm/ioctls.h
@@ -27,7 +27,8 @@
 
 #define TIOCEXCL	0x740d		/* set exclusive use of tty */
 #define TIOCNXCL	0x740e		/* reset exclusive use of tty */
-#define TIOCOUTQ	0x7472		/* output queue size */
+#define TIOCOUTQ	0x7472		/* output queue size (not send + not acked) */
+#define TIOCOUTQNSD	0x7473		/* output queue size (not send only) */
 #define TIOCSTI		0x5472		/* simulate terminal input */
 #define TIOCMGET	0x741d		/* get all modem bits */
 #define TIOCMBIS	0x741b		/* bis modem bits */
diff --git a/arch/parisc/include/asm/ioctls.h b/arch/parisc/include/asm/ioctls.h
index 054ec06..1cf1681 100644
--- a/arch/parisc/include/asm/ioctls.h
+++ b/arch/parisc/include/asm/ioctls.h
@@ -21,7 +21,7 @@
 #define TIOCSCTTY	0x540E
 #define TIOCGPGRP	_IOR('T', 30, int)
 #define TIOCSPGRP	_IOW('T', 29, int)
-#define TIOCOUTQ	0x5411
+#define TIOCOUTQ	0x5411 /* output queue size (not send + not acked) */
 #define TIOCSTI		0x5412
 #define TIOCGWINSZ	0x5413
 #define TIOCSWINSZ	0x5414
@@ -55,6 +55,7 @@
 #define TIOCGDEV	_IOR('T',0x32, int)  /* Get primary device node of /dev/console */
 #define TIOCSIG		_IOW('T',0x36, int)  /* Generate signal on Pty slave */
 #define TIOCVHANGUP	0x5437
+#define TIOCOUTQNSD	0x5438 /* output queue size (not send only) */
 
 #define FIONCLEX	0x5450  /* these numbers need to be adjusted. */
 #define FIOCLEX		0x5451
diff --git a/arch/powerpc/include/asm/ioctls.h b/arch/powerpc/include/asm/ioctls.h
index e9b7887..ae1b21e 100644
--- a/arch/powerpc/include/asm/ioctls.h
+++ b/arch/powerpc/include/asm/ioctls.h
@@ -35,12 +35,13 @@
 #define TIOCGWINSZ	_IOR('t', 104, struct winsize)
 #define	TIOCSTART	_IO('t', 110)		/* start output, like ^Q */
 #define	TIOCSTOP	_IO('t', 111)		/* stop output, like ^S */
-#define TIOCOUTQ        _IOR('t', 115, int)     /* output queue size */
+#define TIOCOUTQ        _IOR('t', 115, int)     /* output queue size (not send + not acked) */
 
 #define TIOCGLTC	_IOR('t', 116, struct ltchars)
 #define TIOCSLTC	_IOW('t', 117, struct ltchars)
 #define TIOCSPGRP	_IOW('t', 118, int)
 #define TIOCGPGRP	_IOR('t', 119, int)
+#define TIOCOUTQNSD     _IOR('t', 120, int)     /* output queue size (not send only) */
 
 #define TIOCEXCL	0x540C
 #define TIOCNXCL	0x540D
diff --git a/arch/sh/include/asm/ioctls.h b/arch/sh/include/asm/ioctls.h
index a6769f3..f0bd75a 100644
--- a/arch/sh/include/asm/ioctls.h
+++ b/arch/sh/include/asm/ioctls.h
@@ -29,7 +29,8 @@
 #define TIOCGWINSZ	0x80087468	/* _IOR('t', 104, struct winsize) */
 #define	TIOCSTART	_IO('t', 110)		/* start output, like ^Q */
 #define	TIOCSTOP	_IO('t', 111)		/* stop output, like ^S */
-#define TIOCOUTQ        _IOR('t', 115, int)     /* output queue size */
+#define TIOCOUTQ        _IOR('t', 115, int)     /* output queue size (not send + not acked) */
+#define TIOCOUTQNSD     _IOR('t', 116, int)     /* output queue size (not send only) */
 
 #define TIOCSPGRP	_IOW('t', 118, int)
 #define TIOCGPGRP	_IOR('t', 119, int)
diff --git a/arch/sparc/include/asm/ioctls.h b/arch/sparc/include/asm/ioctls.h
index 28d0c8b..184acc3 100644
--- a/arch/sparc/include/asm/ioctls.h
+++ b/arch/sparc/include/asm/ioctls.h
@@ -60,7 +60,7 @@
 #define TIOCPKT		_IOW('t', 112, int)
 #define TIOCNOTTY	_IO('t', 113)
 #define TIOCSTI		_IOW('t', 114, char)
-#define TIOCOUTQ	_IOR('t', 115, int)
+#define TIOCOUTQ	_IOR('t', 115, int) /* output queue size (not send + not acked) */
 #define __TIOCGLTC        _IOR('t', 116, struct ltchars) /* SunOS Specific */
 #define __TIOCSLTC        _IOW('t', 117, struct ltchars) /* SunOS Specific */
 /* 118 is the non-posix setpgrp tty ioctl */
@@ -83,6 +83,7 @@
 #define TIOCGPTN	_IOR('t', 134, unsigned int) /* Get Pty Number */
 #define TIOCSPTLCK	_IOW('t', 135, int) /* Lock/unlock PTY */
 #define TIOCSIG		_IOW('t', 136, int) /* Generate signal on Pty slave */
+#define TIOCOUTQNSD	_IOW('t', 137, int) /* output queue size (not send only) */
 
 /* Little f */
 #define FIOCLEX		_IO('f', 1)
diff --git a/arch/xtensa/include/asm/ioctls.h b/arch/xtensa/include/asm/ioctls.h
index fd1d136..5222d8c 100644
--- a/arch/xtensa/include/asm/ioctls.h
+++ b/arch/xtensa/include/asm/ioctls.h
@@ -41,7 +41,8 @@
 #define TIOCGWINSZ	_IOR('t', 104, struct winsize)
 #define	TIOCSTART	_IO('t', 110)		/* start output, like ^Q */
 #define	TIOCSTOP	_IO('t', 111)		/* stop output, like ^S */
-#define TIOCOUTQ        _IOR('t', 115, int)     /* output queue size */
+#define TIOCOUTQ        _IOR('t', 115, int)     /* output queue size (not send + not acked) */
+#define TIOCOUTQNSD     _IOR('t', 116, int)     /* output queue size (not send only) */
 
 #define TIOCSPGRP	_IOW('t', 118, int)
 #define TIOCGPGRP	_IOR('t', 119, int)
diff --git a/include/asm-generic/ioctls.h b/include/asm-generic/ioctls.h
index 199975f..231e492 100644
--- a/include/asm-generic/ioctls.h
+++ b/include/asm-generic/ioctls.h
@@ -32,7 +32,7 @@
 #define TIOCSCTTY	0x540E
 #define TIOCGPGRP	0x540F
 #define TIOCSPGRP	0x5410
-#define TIOCOUTQ	0x5411
+#define TIOCOUTQ	0x5411 /* output queue size (not send + not acked) */
 #define TIOCSTI		0x5412
 #define TIOCGWINSZ	0x5413
 #define TIOCSWINSZ	0x5414
@@ -74,6 +74,7 @@
 #define TCSETXW		0x5435
 #define TIOCSIG		_IOW('T', 0x36, int)  /* pty: generate signal */
 #define TIOCVHANGUP	0x5437
+#define TIOCOUTQNSD	0x5438 /* output queue size (not send only) */
 
 #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

* Re: [PATCH v2] tcp: ioctl type SIOCOUTQNSD returns amount of data not sent
  2011-03-04 10:20       ` [PATCH v2] " Steffen Sledz
@ 2011-03-04 12:26         ` Steffen Sledz
  2011-03-04 12:39           ` Alan Cox
  0 siblings, 1 reply; 13+ messages in thread
From: Steffen Sledz @ 2011-03-04 12:26 UTC (permalink / raw)
  To: Alan Cox
  Cc: netdev, linux-kernel, David S. Miller, Alexey Kuznetsov,
	Pekka Savola (ipv6),
	James Morris, Hideaki YOSHIFUJI, Patrick McHardy,
	Mario Schuknecht, Steffen Sledz

Am 04.03.2011 12:49, schrieb Alan Cox:
> ...
>>> Signed-off-by: Mario Schuknecht <m.schuknecht@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 a321665..b87115b 100644
>>> --- a/include/asm-generic/ioctls.h
>>> +++ b/include/asm-generic/ioctls.h
>>> @@ -72,6 +72,7 @@
>>>  #define TCSETXF		0x5434
>>>  #define TCSETXW		0x5435
>>>  #define TIOCSIG		_IOW('T', 0x36, int)  /* pty: generate signal */
>>> +#define TIOCOUTQNSD	0x5437
>
> These are tty not socket ioctl codes. For various historical reasons some
> of them got sort of emulated by the socket layer in Unix and thus in
> Linux.
>
> If you plan to add one to Linux then please post the accompanying *tty
> layer* patches and reasoning, otherwise if it is socket only please stick
> to the socket ioctl.

So we should define the new SIOCOUTQNSD in sockios.h only and not similiar to SIOCOUTQ using TIOCOUTQ. Right?

Steffen

-- 
DResearch Fahrzeugelektronik GmbH
Otto-Schmirgal-Str. 3, 10319 Berlin, Germany
Tel: +49 30 515932-237 mailto:sledz@DResearch.de
Fax: +49 30 515932-299
Geschäftsführer: Dr. Michael Weber, Werner Mögle;
Amtsgericht Berlin Charlottenburg; HRB 130120 B;
Ust.-IDNr. DE273952058


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

* Re: [PATCH v2] tcp: ioctl type SIOCOUTQNSD returns amount of data not sent
  2011-03-04 12:26         ` Steffen Sledz
@ 2011-03-04 12:39           ` Alan Cox
  2011-03-06 19:59             ` [PATCH v3] " Steffen Sledz
  0 siblings, 1 reply; 13+ messages in thread
From: Alan Cox @ 2011-03-04 12:39 UTC (permalink / raw)
  To: Steffen Sledz
  Cc: netdev, linux-kernel, David S. Miller, Alexey Kuznetsov,
	Pekka Savola (ipv6),
	James Morris, Hideaki YOSHIFUJI, Patrick McHardy,
	Mario Schuknecht

> > If you plan to add one to Linux then please post the accompanying *tty
> > layer* patches and reasoning, otherwise if it is socket only please stick
> > to the socket ioctl.
> 
> So we should define the new SIOCOUTQNSD in sockios.h only and not similiar to SIOCOUTQ using TIOCOUTQ. Right?

Right

Alan

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

* [PATCH v3] tcp: ioctl type SIOCOUTQNSD returns amount of data not sent
  2011-03-04 12:39           ` Alan Cox
@ 2011-03-06 19:59             ` Steffen Sledz
  2011-03-08 11:57               ` Steffen Sledz
  2011-03-09 22:09               ` David Miller
  0 siblings, 2 replies; 13+ messages in thread
From: Steffen Sledz @ 2011-03-06 19:59 UTC (permalink / raw)
  To: netdev, linux-kernel
  Cc: Alan Cox, 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/linux/sockios.h |    4 +++-
 net/ipv4/tcp.c          |    9 +++++++++
 2 files changed, 12 insertions(+), 1 deletions(-)

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;
 	}
-- 
1.7.1


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

* Re: [PATCH v3] tcp: ioctl type SIOCOUTQNSD returns amount of data not sent
  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
  1 sibling, 1 reply; 13+ messages in thread
From: Steffen Sledz @ 2011-03-08 11:57 UTC (permalink / raw)
  To: netdev, Alan Cox
  Cc: linux-kernel, David S. Miller, Alexey Kuznetsov,
	Pekka Savola (ipv6),
	James Morris, Hideaki YOSHIFUJI, Patrick McHardy,
	Mario Schuknecht

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

-- 
DResearch Fahrzeugelektronik GmbH
Otto-Schmirgal-Str. 3, 10319 Berlin, Germany
Tel: +49 30 515932-237 mailto:sledz@DResearch.de
Fax: +49 30 515932-299
Geschäftsführer: Dr. Michael Weber, Werner Mögle;
Amtsgericht Berlin Charlottenburg; HRB 130120 B;
Ust.-IDNr. DE273952058


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

* Re: [PATCH v3] tcp: ioctl type SIOCOUTQNSD returns amount of data not sent
  2011-03-08 11:57               ` Steffen Sledz
@ 2011-03-08 18:48                 ` David Miller
  0 siblings, 0 replies; 13+ messages in thread
From: David Miller @ 2011-03-08 18:48 UTC (permalink / raw)
  To: sledz
  Cc: netdev, alan, linux-kernel, kuznet, pekkas, jmorris, yoshfuji,
	kaber, m.schuknecht

From: Steffen Sledz <sledz@dresearch.de>
Date: Tue, 08 Mar 2011 12:57:22 +0100

> Anything else to do?

Be patient.

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

* Re: [PATCH v3] tcp: ioctl type SIOCOUTQNSD returns amount of data not sent
  2011-03-06 19:59             ` [PATCH v3] " Steffen Sledz
  2011-03-08 11:57               ` Steffen Sledz
@ 2011-03-09 22:09               ` David Miller
  2011-03-10 22:12                 ` Hagen Paul Pfeifer
  1 sibling, 1 reply; 13+ messages in thread
From: David Miller @ 2011-03-09 22:09 UTC (permalink / raw)
  To: sledz
  Cc: netdev, linux-kernel, alan, kuznet, pekkas, jmorris, yoshfuji,
	kaber, m.schuknecht

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.

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

* Re: [PATCH v3] tcp: ioctl type SIOCOUTQNSD returns amount of data not sent
  2011-03-09 22:09               ` David Miller
@ 2011-03-10 22:12                 ` Hagen Paul Pfeifer
  2011-03-10 22:16                   ` David Miller
  0 siblings, 1 reply; 13+ messages in thread
From: Hagen Paul Pfeifer @ 2011-03-10 22:12 UTC (permalink / raw)
  To: David Miller
  Cc: sledz, netdev, linux-kernel, alan, kuznet, pekkas, jmorris,
	yoshfuji, kaber, m.schuknecht

* 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

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

* Re: [PATCH v3] tcp: ioctl type SIOCOUTQNSD returns amount of data not sent
  2011-03-10 22:12                 ` Hagen Paul Pfeifer
@ 2011-03-10 22:16                   ` David Miller
  0 siblings, 0 replies; 13+ messages in thread
From: David Miller @ 2011-03-10 22:16 UTC (permalink / raw)
  To: hagen
  Cc: sledz, netdev, linux-kernel, alan, kuznet, pekkas, jmorris,
	yoshfuji, kaber, m.schuknecht

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.

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

end of thread, other threads:[~2011-03-10 22:15 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).