Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tcp: ioctl type SIOCOUTQNSD returns amount of data not sent

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>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Mario Schuknecht and committed by
David S. Miller
2f4e1b39 ee3f1aaf

+12 -1
+3 -1
include/linux/sockios.h
··· 22 22 23 23 /* Linux-specific socket ioctls */ 24 24 #define SIOCINQ FIONREAD 25 - #define SIOCOUTQ TIOCOUTQ 25 + #define SIOCOUTQ TIOCOUTQ /* output queue size (not sent + not acked) */ 26 26 27 27 /* Routing table calls. */ 28 28 #define SIOCADDRT 0x890B /* add routing table entry */ ··· 82 82 #define SIOCSMIIREG 0x8949 /* Write MII PHY register. */ 83 83 84 84 #define SIOCWANDEV 0x894A /* get/set netdev parameters */ 85 + 86 + #define SIOCOUTQNSD 0x894B /* output queue size (not sent only) */ 85 87 86 88 /* ARP cache control calls. */ 87 89 /* 0x8950 - 0x8952 * obsolete calls, don't re-use */
+9
net/ipv4/tcp.c
··· 505 505 else 506 506 answ = tp->write_seq - tp->snd_una; 507 507 break; 508 + case SIOCOUTQNSD: 509 + if (sk->sk_state == TCP_LISTEN) 510 + return -EINVAL; 511 + 512 + if ((1 << sk->sk_state) & (TCPF_SYN_SENT | TCPF_SYN_RECV)) 513 + answ = 0; 514 + else 515 + answ = tp->write_seq - tp->snd_nxt; 516 + break; 508 517 default: 509 518 return -ENOIOCTLCMD; 510 519 }