From: Mario Schuknecht <m.schuknecht@dresearch.de>
To: linux-kernel@vger.kernel.org
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>,
linux-net@vger.kernel.org,
Mario Schuknecht <m.schuknecht@dresearch.de>
Subject: [PATCH] tcp: ioctl type SIOCOUTQNSD returns amount of data not sent
Date: Tue, 5 Oct 2010 11:32:34 +0200 [thread overview]
Message-ID: <1286271154-18600-1-git-send-email-m.schuknecht@dresearch.de> (raw)
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>
---
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
#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 1664a05..c2d52e8 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
next reply other threads:[~2010-10-05 9:51 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-05 9:32 Mario Schuknecht [this message]
2011-02-23 12:14 ` Steffen Sledz
2011-03-04 11:49 ` Alan Cox
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1286271154-18600-1-git-send-email-m.schuknecht@dresearch.de \
--to=m.schuknecht@dresearch.de \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-net@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®