]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
ntp: set DSCP for IPv6
authorMike Ryan <msr@hsilop.net>
Wed, 16 Nov 2022 14:13:09 +0000 (09:13 -0500)
committerMiroslav Lichvar <mlichvar@redhat.com>
Wed, 16 Nov 2022 16:15:11 +0000 (17:15 +0100)
Chrony's dscp setting currently applies to IPv4 only. This patch sets
the necessary option for IPv6 as well.

ntp_io.c
sys_linux.c

index 86e3f26c43fb65f71848a70a43154466f1ea2c1d..ade3a0ef51a3d9acb4c1d9e83e8e10d94cdd045a 100644 (file)
--- a/ntp_io.c
+++ b/ntp_io.c
@@ -126,8 +126,14 @@ open_socket(int family, int local_port, int client_only, IPSockAddr *remote_addr
   dscp = CNF_GetNtpDscp();
   if (dscp > 0 && dscp < 64) {
 #ifdef IP_TOS
-    if (!SCK_SetIntOption(sock_fd, IPPROTO_IP, IP_TOS, dscp << 2))
-      ;
+    if (family == IPADDR_INET4)
+      if (!SCK_SetIntOption(sock_fd, IPPROTO_IP, IP_TOS, dscp << 2))
+        ;
+#endif
+#if defined(FEAT_IPV6) && defined(IPV6_TCLASS)
+    if (family == IPADDR_INET6)
+      if (!SCK_SetIntOption(sock_fd, IPPROTO_IPV6, IPV6_TCLASS, dscp << 2))
+        ;
 #endif
   }
 
index f2baab1fc13c1855dd57ae124baa20621dffc61a..8e647e33d9f14ae0be84d0e0f1920d1d4c64afd9 100644 (file)
@@ -633,6 +633,9 @@ SYS_Linux_EnableSystemCallFilter(int level, SYS_ProcessContext context)
     { SOL_IP, IP_PKTINFO }, { SOL_IP, IP_FREEBIND }, { SOL_IP, IP_TOS },
 #ifdef FEAT_IPV6
     { SOL_IPV6, IPV6_V6ONLY }, { SOL_IPV6, IPV6_RECVPKTINFO },
+#ifdef IPV6_TCLASS
+    { SOL_IPV6, IPV6_TCLASS },
+#endif
 #endif
 #ifdef SO_BINDTODEVICE
     { SOL_SOCKET, SO_BINDTODEVICE },