From: Yu Watanabe Date: Thu, 9 Dec 2021 11:25:12 +0000 (+0900) Subject: network: dhcp: make IPServiceType= accept "none" to disable tos in the outgoing packet X-Git-Tag: v250-rc1~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b55093ce8884ee4fc72f28c6fd5e39897e921e21;p=thirdparty%2Fsystemd.git network: dhcp: make IPServiceType= accept "none" to disable tos in the outgoing packet Fixes #9874. --- diff --git a/man/systemd.network.xml b/man/systemd.network.xml index 6f152c9e141..f263c2c0b28 100644 --- a/man/systemd.network.xml +++ b/man/systemd.network.xml @@ -1550,8 +1550,11 @@ Table=1234 IPServiceType= - Takes string; CS6 or CS4. Used to set IP - service type to CS6 (network control) or CS4 (Realtime). Defaults to CS6. + Takes one of the special values none, CS6, or + CS4. When none no IP sevice type is set to the packet + sent from the DHCPv4 client. When CS6 (network control) or + CS4 (realtime), the corresponding service type will be set. Defaults to + CS6. diff --git a/src/network/networkd-dhcp4.c b/src/network/networkd-dhcp4.c index b8efb768589..81faf48448c 100644 --- a/src/network/networkd-dhcp4.c +++ b/src/network/networkd-dhcp4.c @@ -1704,17 +1704,24 @@ int config_parse_dhcp_ip_service_type( void *data, void *userdata) { + int *tos = data; + assert(filename); assert(lvalue); assert(rvalue); + assert(data); - if (streq(rvalue, "CS4")) - *((int *)data) = IPTOS_CLASS_CS4; + if (isempty(rvalue)) + *tos = -1; /* use sd_dhcp_client's default (currently, CS6). */ + else if (streq(rvalue, "none")) + *tos = 0; + else if (streq(rvalue, "CS4")) + *tos = IPTOS_CLASS_CS4; else if (streq(rvalue, "CS6")) - *((int *)data) = IPTOS_CLASS_CS6; + *tos = IPTOS_CLASS_CS6; else log_syntax(unit, LOG_WARNING, filename, line, 0, - "Failed to parse IPServiceType type '%s', ignoring.", rvalue); + "Failed to parse %s=, ignoring assignment: %s", lvalue, rvalue); return 0; }