[chrony-dev] [PATCH v2] Set DSCP for IPv6.

[ Thread Index | Date Index | More chrony.tuxfamily.org/chrony-dev Archives ]


Chrony's dscp setting currently applies to IPv4 only. This patch sets
the necessary option for IPv6 as well.
---
 ntp_io.c    | 10 ++++++++--
 sys_linux.c |  3 +++
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/ntp_io.c b/ntp_io.c
index 86e3f26..ade3a0e 100644
--- 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
   }
 
diff --git a/sys_linux.c b/sys_linux.c
index f2baab1..8e647e3 100644
--- a/sys_linux.c
+++ b/sys_linux.c
@@ -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 },
-- 
2.38.1


-- 
To unsubscribe email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "unsubscribe" in the subject.
For help email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "help" in the subject.
Trouble?  Email listmaster@xxxxxxxxxxxxxxxxxxxx.


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/