netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v5] net: dccp: Add SIOCOUTQ IOCTL support (send buffer fill)
@ 2020-07-20 16:06 Richard Sailer
  2020-07-23  0:01 ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Sailer @ 2020-07-20 16:06 UTC (permalink / raw)
  To: gerrit, davem, dccp; +Cc: netdev

This adds support for the SIOCOUTQ IOCTL to get the send buffer fill
of a DCCP socket, like UDP and TCP sockets already have.

Regarding the used data field: DCCP uses per packet sequence numbers,
not per byte, so sequence numbers can't be used like in TCP. sk_wmem_queued
is not used by DCCP and always 0, even in test on highly congested paths.
Therefore this uses sk_wmem_alloc like in UDP.

Signed-off-by: Richard Sailer <richard_siegfried@systemli.org>
---
v5: More infos into dccp.rst, +empty line after declarations
---
 Documentation/networking/dccp.rst | 3 +++
 net/dccp/proto.c                  | 9 +++++++++
 2 files changed, 12 insertions(+)

diff --git a/Documentation/networking/dccp.rst b/Documentation/networking/dccp.rst
index dde16be044562..91e5c33ba3ff5 100644
--- a/Documentation/networking/dccp.rst
+++ b/Documentation/networking/dccp.rst
@@ -192,6 +192,9 @@ FIONREAD
 	Works as in udp(7): returns in the ``int`` argument pointer the size of
 	the next pending datagram in bytes, or 0 when no datagram is pending.
 
+SIOCOUTQ
+	Returns the number of unsent data bytes in the socket send queue as ``int``
+	into the buffer specified by the argument pointer.
 
 Other tunables
 ==============
diff --git a/net/dccp/proto.c b/net/dccp/proto.c
index fd92d3fe321f0..9e453611107f1 100644
--- a/net/dccp/proto.c
+++ b/net/dccp/proto.c
@@ -375,6 +375,15 @@ int dccp_ioctl(struct sock *sk, int cmd, unsigned long arg)
 		goto out;
 
 	switch (cmd) {
+	case SIOCOUTQ: {
+		int amount = sk_wmem_alloc_get(sk);
+		/* Using sk_wmem_alloc here because sk_wmem_queued is not used by DCCP and
+		 * always 0, comparably to UDP.
+		 */
+
+		rc = put_user(amount, (int __user *)arg);
+	}
+		break;
 	case SIOCINQ: {
 		struct sk_buff *skb;
 		unsigned long amount = 0;
-- 
2.27.0


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

* Re: [PATCH net-next v5] net: dccp: Add SIOCOUTQ IOCTL support (send buffer fill)
  2020-07-20 16:06 [PATCH net-next v5] net: dccp: Add SIOCOUTQ IOCTL support (send buffer fill) Richard Sailer
@ 2020-07-23  0:01 ` David Miller
  2020-07-23 10:28   ` Richard Sailer
  0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2020-07-23  0:01 UTC (permalink / raw)
  To: richard_siegfried; +Cc: gerrit, dccp, netdev

From: Richard Sailer <richard_siegfried@systemli.org>
Date: Mon, 20 Jul 2020 18:06:14 +0200

> This adds support for the SIOCOUTQ IOCTL to get the send buffer fill
> of a DCCP socket, like UDP and TCP sockets already have.
> 
> Regarding the used data field: DCCP uses per packet sequence numbers,
> not per byte, so sequence numbers can't be used like in TCP. sk_wmem_queued
> is not used by DCCP and always 0, even in test on highly congested paths.
> Therefore this uses sk_wmem_alloc like in UDP.
> 
> Signed-off-by: Richard Sailer <richard_siegfried@systemli.org>
> ---
> v5: More infos into dccp.rst, +empty line after declarations

Applied, but I wonder if you'll also need something like tcp's SIOCOUTQNSD?

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

* Re: [PATCH net-next v5] net: dccp: Add SIOCOUTQ IOCTL support (send buffer fill)
  2020-07-23  0:01 ` David Miller
@ 2020-07-23 10:28   ` Richard Sailer
  0 siblings, 0 replies; 3+ messages in thread
From: Richard Sailer @ 2020-07-23 10:28 UTC (permalink / raw)
  To: David Miller; +Cc: gerrit, dccp, netdev


[-- Attachment #1.1: Type: text/plain, Size: 787 bytes --]


> 
> Applied, but I wonder if you'll also need something like tcp's SIOCOUTQNSD?
> 
A good question. SIOCOUTQNSD is not mentioned in man 7 tcp and I didn't
know and consider it. Now that I looked it up (bytes of unsent packets
in send buffer) maybe this patch's ioctl should be renamed SIOCOUTQNSD,
since it returns the byte count of unsent packets.

I'm undecided here, this is also the only of these ioctl's that makes
sense for DCCP since DCCP does not keep sent but un-acked packets so
SIOCOUTQ does not exist for DCCP. Or SIOCOUTQ and SIOCOUTQNSD are the
same for DCCP, that's a viewpoint question. And it's anyhow correctly
documented in dccp.rst, it's about unsent packets.

So I'm undecided here, should I resend my patch renamed to SIOCOUTQNSD?

-- Richard


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

end of thread, other threads:[~2020-07-23 10:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-20 16:06 [PATCH net-next v5] net: dccp: Add SIOCOUTQ IOCTL support (send buffer fill) Richard Sailer
2020-07-23  0:01 ` David Miller
2020-07-23 10:28   ` Richard Sailer

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