[PATCH] Unix IO: Set socket priority after setting family specific options
From: Vincent Bernat <vincent@bernat.im> On Linux, setting the ToS will also set the priority and the range of accepted values is quite limited (masked by 0x1e). Therefore, 0xc0 is translated to a priority of 0, not something we want, overriding the "7" priority which was set previously explicitely. To avoid that, just move setting priority later in the code. --- sysdep/unix/io.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sysdep/unix/io.c b/sysdep/unix/io.c index 8773f4c41e86..1c81acbf4518 100644 --- a/sysdep/unix/io.c +++ b/sysdep/unix/io.c @@ -1226,10 +1226,6 @@ sk_setup(sock *s) #endif } - if (s->priority >= 0) - if (sk_set_priority(s, s->priority) < 0) - return -1; - if (sk_is_ipv4(s)) { if (s->flags & SKF_LADDR_RX) @@ -1280,6 +1276,10 @@ sk_setup(sock *s) return -1; } + if (s->priority >= 0) + if (sk_set_priority(s, s->priority) < 0) + return -1; + return 0; } -- 2.15.1
On Mon, Jan 22, 2018 at 10:52:05AM +0100, Vincent Bernat wrote:
From: Vincent Bernat <vincent@bernat.im>
On Linux, setting the ToS will also set the priority and the range of accepted values is quite limited (masked by 0x1e). Therefore, 0xc0 is translated to a priority of 0, not something we want, overriding the "7" priority which was set previously explicitely. To avoid that, just move setting priority later in the code.
Thanks, merged. Seems like the Linux behavior is brain-damaged two times at once. First, it implicitly sets one socket option as a side effect of setting another socket option, even if the first socket option was set explicitly. Second, it uses obsolete interpretation of ToS values for that. -- Elen sila lumenn' omentielvo Ondrej 'Santiago' Zajicek (email: santiago@crfreenet.org) OpenPGP encrypted e-mails preferred (KeyID 0x11DEADC3, wwwkeys.pgp.net) "To err is human -- to blame it on a computer is even more so."
participants (2)
-
Ondrej Zajicek -
Vincent Bernat