]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
IO: Fix socket priority
authorOndrej Zajicek (work) <santiago@crfreenet.org>
Tue, 23 Jan 2018 16:05:45 +0000 (17:05 +0100)
committerOndrej Zajicek (work) <santiago@crfreenet.org>
Tue, 23 Jan 2018 16:05:45 +0000 (17:05 +0100)
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.

sysdep/unix/io.c

index 6d6a09902cbd261646964dafa57953362db8c219..53a37a501b284ca774710f1c2d0c1e0e8eb5cf32 100644 (file)
@@ -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;
 }