diff options
author | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2018-01-23 17:05:45 +0100 |
---|---|---|
committer | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2018-01-23 17:05:45 +0100 |
commit | d6cf996151307d083c30e4ecde0f1d7449b19253 (patch) | |
tree | 2c005e24fb82c7f83d34f99e68c452110dbb6176 /sysdep/unix | |
parent | 63472779ad4ecdecbcfedf2d2bb40abc2f8c84b0 (diff) |
IO: Fix socket priority
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 to Vincent Bernat for the patch.
Diffstat (limited to 'sysdep/unix')
-rw-r--r-- | sysdep/unix/io.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/sysdep/unix/io.c b/sysdep/unix/io.c index 6d6a0990..53a37a50 100644 --- a/sysdep/unix/io.c +++ b/sysdep/unix/io.c @@ -1238,10 +1238,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) @@ -1292,6 +1288,11 @@ sk_setup(sock *s) return -1; } + /* Must be after sk_set_tos4() as setting ToS on Linux also mangles priority */ + if (s->priority >= 0) + if (sk_set_priority(s, s->priority) < 0) + return -1; + return 0; } |