chiark / gitweb /
sd-dhcp: network - set TOS on outgoing packets
[elogind.git] / src / libsystemd-network / dhcp-network.c
index 722f1b18b3af52705b282e340fb110d964fc6213..2a63f1850eaaf8d167db39b6716d3b47d0435c71 100644 (file)
@@ -98,7 +98,7 @@ int dhcp_network_bind_raw_socket(int index, union sockaddr_union *link, uint32_t
 
 int dhcp_network_bind_udp_socket(be32_t address, uint16_t port)
 {
-        int s;
+        int s, tos = IPTOS_CLASS_CS6;
         union sockaddr_union src = {
                 .in.sin_family = AF_INET,
                 .in.sin_port = htobe16(port),
@@ -109,6 +109,9 @@ int dhcp_network_bind_udp_socket(be32_t address, uint16_t port)
         if (s < 0)
                 return -errno;
 
+        if (setsockopt(s, IPPROTO_IP, IP_TOS, &tos, sizeof(tos)) < 0)
+                return -errno;
+
         if (bind(s, &src.sa, sizeof(src.in)) < 0) {
                 safe_close(s);
                 return -errno;