From: Willy Tarreau <w@1wt.eu>
To: Henneberg - Systemdesign <lists@henneberg-systemdesign.com>
Cc: netdev@vger.kernel.org
Subject: Re: TIOCOUTQ implementation for sockets vs. tty
Date: Wed, 10 Mar 2021 19:29:35 +0100 [thread overview]
Message-ID: <20210310182935.GC17851@1wt.eu> (raw)
In-Reply-To: <87ft12ri0t.fsf@henneberg-systemdesign.com>
Hi,
On Wed, Mar 10, 2021 at 07:16:34PM +0100, Henneberg - Systemdesign wrote:
> Hi,
>
> I have a question regarding the implementation of ioctl TIOCOUTQ for
> various sockets compared to the tty implementation.
>
> For several sockets, e. g. AF_BLUETOOTH it is done like this
>
> af_bluetooth.c:
> case TIOCOUTQ:
> if (sk->sk_state == BT_LISTEN)
> return -EINVAL;
>
> amount = sk->sk_sndbuf - sk_wmem_alloc_get(sk);
> if (amount < 0)
> amount = 0;
> err = put_user(amount, (int __user *)arg);
> break;
>
> so the ioctl returns the available space in the send queue if I
> understand the code correctly (this is also what I observed from tests).
>
> The tty does this:
>
> n_tty.c:
> case TIOCOUTQ:
> return put_user(tty_chars_in_buffer(tty), (int __user *) arg);
>
> so it returns the used space in the send queue. This is also what I
> would expect from the manpage description.
>
> Is this mismatch intentional?
At least both man pages (tty_ioctl and tcp(7)) mention that TIOCOUTQ
should return the number of byte in queue.
What I suspect for sockets is that sk_sndbuf grows with allocations
and that sk_wmem_alloc_get() in fact returns the number of unused
allocations thus the difference would be the amount queued. But I
could be wrong and I would tend to read the code the same way as you
did.
Willy
next prev parent reply other threads:[~2021-03-10 18:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-10 18:16 TIOCOUTQ implementation for sockets vs. tty Henneberg - Systemdesign
2021-03-10 18:29 ` Willy Tarreau [this message]
2021-03-10 20:15 ` Henneberg - Systemdesign
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=20210310182935.GC17851@1wt.eu \
--to=w@1wt.eu \
--cc=lists@henneberg-systemdesign.com \
--cc=netdev@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;
as well as URLs for NNTP newsgroup(s).