Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.kernel > #67662

Bug#966459: linux: traffic class socket options (both IPv4/IPv6) inconsistent with docs/standards

Path csiph.com!news.mixmin.net!aioe.org!bofh.it!news.nic.it!robomod
From Ben Hutchings <ben@decadent.org.uk>
Newsgroups linux.debian.bugs.dist, linux.debian.kernel
Subject Bug#966459: linux: traffic class socket options (both IPv4/IPv6) inconsistent with docs/standards
Date Sun, 02 Aug 2020 20:00:01 +0200
Message-ID <Azqr7-vc-3@gated-at.bofh.it> (permalink)
References <AxCG6-6la-9@gated-at.bofh.it> <AxCG6-6la-9@gated-at.bofh.it>
X-Mailbox-Line From debian-bugs-dist-request@lists.debian.org Sun Aug 2 17:51:11 2020
Old-Return-Path <debbugs@buxtehude.debian.org>
X-Spam-Flag NO
X-Spam-Score -0.699
Reply-To Ben Hutchings <ben@decadent.org.uk>, 966459@bugs.debian.org
Resent-To debian-bugs-dist@lists.debian.org
Resent-Cc Debian Kernel Team <debian-kernel@lists.debian.org>
X-Debian-Pr-Message followup 966459
X-Debian-Pr-Package src:linux
X-Debian-Pr-Keywords upstream
X-Debian-Pr-Source linux
X-Spam-Bayes score:0.0000 Tokens: new, 41; hammy, 150; neutral, 160; spammy, 0. spammytokens: hammytokens:0.000-+--manpage, 0.000-+--H*F:D*decadent.org.uk, 0.000-+--H*RU:sk:shadbol, 0.000-+--H*r:sk:shadbol, 0.000-+--H*RU:88.96.1.126
Content-Type multipart/signed; micalg="pgp-sha512"; protocol="application/pgp-signature"; boundary="=-j2nqJ8CckHMlJHKjRxx/"
User-Agent Evolution 3.36.3-1
MIME-Version 1.0
X-Sa-Exim-Connect-IP 192.168.4.242
X-Sa-Exim-Mail-From ben@decadent.org.uk
X-Sa-Exim-Scanned No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false
X-Debian-Message from BTS
X-Mailing-List <debian-bugs-dist@lists.debian.org> archive/latest/1616655
List-ID <debian-bugs-dist.lists.debian.org>
List-URL <https://lists.debian.org/debian-bugs-dist/>
Approved robomod@news.nic.it
Lines 108
Organization linux.* mail to news gateway
Sender robomod@news.nic.it
X-Original-Cc netdev <netdev@vger.kernel.org>
X-Original-Date Sun, 02 Aug 2020 18:49:26 +0100
X-Original-Message-ID <e67190b7de22fff20fb4c5c084307e0b76001248.camel@decadent.org.uk>
X-Original-References <159596111771.2639.6929056987566441726.reportbug@tglase-nb.lan.tarent.de> <159596111771.2639.6929056987566441726.reportbug@tglase-nb.lan.tarent.de>
Xref csiph.com linux.debian.bugs.dist:1020182 linux.debian.kernel:67662

Cross-posted to 2 groups.

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

[The previous message is archived at <https://bugs.debian.org/966459>.]

On Tue, 2020-07-28 at 20:31 +0200, Thorsten Glaser wrote:
> Package: src:linux
> Version: 5.7.6-1
> Severity: normal
> Tags: upstream
> X-Debbugs-Cc: tg@mirbsd.de
> 
> I’m using setsockopt to set the traffic class on sending and receive
> it in control messages on receiving, for both IPv4 and IPv6.
> 
> The relevant documentation is the ip(7) manpage and, because the ipv6(7)
> manpage doesn’t contain it, RFC3542.

ip(7) also doesn't document IP_PKTOPIONS.

[...]
> Same in net/ipv4/ip_sockglue.c…
> 
>                         int tos = inet->rcv_tos;
>                         put_cmsg(&msg, SOL_IP, IP_TOS, sizeof(tos), &tos);
> … in one place, but…
> 
>         put_cmsg(msg, SOL_IP, IP_TOS, 1, &ip_hdr(skb)->tos);
> 
> … in ip_cmsg_recv_tos(), yielding inconsistent results for IPv4(!).

Those are two different APIs though: recvmsg() for datagram sockets, vs
getsockopt(... IP_PKTOPTIONS ...) for stream sockets.  They obviously
ought to be consistent, but mistakes happen.

[...]
> tl;dr: Receiving traffic class values from IP traffic is broken on
> big endian platforms.

Some user-space that uses getsockopt(... IP_PKTOPTIONS ...) for stream
sockets might be broken.

I searched for 'cmsg_type.*IP_TOS' on codesearch.debian.net, and found
only two instances where it was used in conjunction with IP_PKTOPTIONS.

libzorpll reads only the first byte (so is broken on big-endian):
https://sources.debian.org/src/libzorpll/7.0.1.0%7Ealpha1-1.1/src/io.cc/#L239

squid reads an int and then truncates it to a byte (so is fine):
https://sources.debian.org/src/squid/4.12-1/src/ip/QosConfig.cc/#L41

> I place the following suggestion for discussion, to achieve maximum
> portability: put 4 bytes into the CMSG for both IPv4 and IPv6, where
> the first and fourth byte are, identically, traffic class, second and
> third 0.
[...]

I see no point in changing the IPv6 behaviour: it seems to be
consistent with itself and with the standard, so only risks breaking
user-space that works today.

As for IPv4, changing the format of the IP_TOS field in the
IP_PKTOPIONS value looks like it would work for the two users found in
Debian.

But you should know that the highest priority for Linux API
compatibility is to avoid breaking currently working user-space.  That
means that ugly and inconsistent APIs won't get fixed if it causes a
regression for the programs people actually use.  If the API never
worked like it was supposed to on some architectures, that's not a
regression, and is lower priority.

Ben.

-- 
Ben Hutchings
It is easier to write an incorrect program
than to understand a correct one.

Back to linux.debian.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Bug#966459: linux: traffic class socket options (both IPv4/IPv6) inconsistent with docs/standards Thorsten Glaser <tg@mirbsd.de> - 2020-07-28 20:40 +0200
  Bug#966459: linux: traffic class socket options (both IPv4/IPv6) inconsistent with docs/standards Ben Hutchings <ben@decadent.org.uk> - 2020-08-02 20:00 +0200
    Bug#966459: linux: traffic class socket options (both IPv4/IPv6) inconsistent with docs/standards Thorsten Glaser <t.glaser@tarent.de> - 2020-08-02 21:50 +0200
      Bug#966459: linux: traffic class socket options (both IPv4/IPv6) inconsistent with docs/standards Ben Hutchings <ben@decadent.org.uk> - 2020-08-02 22:40 +0200
        Bug#966459: linux: traffic class socket options (both IPv4/IPv6) inconsistent with docs/standards Thorsten Glaser <t.glaser@tarent.de> - 2020-08-02 22:50 +0200
          Bug#966459: linux: traffic class socket options (both IPv4/IPv6) inconsistent with docs/standards Ben Hutchings <ben@decadent.org.uk> - 2020-08-03 05:40 +0200
            Bug#966459: linux: traffic class socket options (both IPv4/IPv6) inconsistent with docs/standards Thorsten Glaser <t.glaser@tarent.de> - 2020-08-03 19:10 +0200
              Bug#966459: linux: traffic class socket options (both IPv4/IPv6) inconsistent with docs/standards Thorsten Glaser <t.glaser@tarent.de> - 2020-08-04 21:10 +0200

csiph-web