Skip to content

Commit

Permalink
net: dccp: Add SIOCOUTQ IOCTL support (send buffer fill)
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
richi235 authored and davem330 committed Jul 23, 2020
1 parent 09a0d32 commit 749c08f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Documentation/networking/dccp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
==============
Expand Down
9 changes: 9 additions & 0 deletions net/dccp/proto.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 749c08f

Please sign in to comment.