1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-06 16:59:03 +03:00

sd-dhcp: network - set TOS on outgoing packets

This should improve performance on busy wireless networks and the
like. Inspired by a similar change in dnsmasq.
This commit is contained in:
Tom Gundersen 2014-05-06 22:02:14 +02:00
parent 085cabf266
commit 85923f79e1
2 changed files with 6 additions and 1 deletions

View 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 dhcp_network_bind_udp_socket(be32_t address, uint16_t port)
{ {
int s; int s, tos = IPTOS_CLASS_CS6;
union sockaddr_union src = { union sockaddr_union src = {
.in.sin_family = AF_INET, .in.sin_family = AF_INET,
.in.sin_port = htobe16(port), .in.sin_port = htobe16(port),
@ -109,6 +109,9 @@ int dhcp_network_bind_udp_socket(be32_t address, uint16_t port)
if (s < 0) if (s < 0)
return -errno; return -errno;
if (setsockopt(s, IPPROTO_IP, IP_TOS, &tos, sizeof(tos)) < 0)
return -errno;
if (bind(s, &src.sa, sizeof(src.in)) < 0) { if (bind(s, &src.sa, sizeof(src.in)) < 0) {
safe_close(s); safe_close(s);
return -errno; return -errno;

View File

@ -116,6 +116,8 @@ void dhcp_packet_append_ip_headers(DHCPPacket *packet, be32_t source_addr,
packet->ip.ihl = DHCP_IP_SIZE / 4; packet->ip.ihl = DHCP_IP_SIZE / 4;
packet->ip.tot_len = htobe16(len); packet->ip.tot_len = htobe16(len);
packet->ip.tos = IPTOS_CLASS_CS6;
packet->ip.protocol = IPPROTO_UDP; packet->ip.protocol = IPPROTO_UDP;
packet->ip.saddr = source_addr; packet->ip.saddr = source_addr;
packet->ip.daddr = destination_addr; packet->ip.daddr = destination_addr;