dhcp4: make IPServiceType configurable

IPServiceType set to CS6 (network control) causes problems on some old
network setups that continue to interpret the field as IP TOS.

Make DHCP work on such networks by allowing this field to be set to
CS4 (Realtime) instead, as this maps to IPTOS_LOWDELAY.

Signed-off-by: Siddharth Chandrasekaran <csiddharth@vmware.com>
This commit is contained in:
Siddharth Chandrasekara
2019-09-26 11:39:46 +09:00
committed by Yu Watanabe
parent 55a1729fd0
commit afe42aef39
15 changed files with 79 additions and 13 deletions
+29
View File
@@ -4,6 +4,7 @@
***/
#include <ctype.h>
#include <netinet/ip.h>
#include "conf-parser.h"
#include "def.h"
@@ -14,6 +15,7 @@
#include "networkd-manager.h"
#include "networkd-network.h"
#include "networkd-speed-meter.h"
#include "networkd-dhcp4.h"
#include "string-table.h"
int manager_parse_config_file(Manager *m) {
@@ -180,3 +182,30 @@ int config_parse_duid_rawdata(
ret->raw_data_len = count;
return 0;
}
int config_parse_ip_service_type(
const char *unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
assert(filename);
assert(lvalue);
assert(rvalue);
if (streq(rvalue, "CS4"))
*((int *)data) = IPTOS_CLASS_CS4;
else if (streq(rvalue, "CS6"))
*((int *)data) = IPTOS_CLASS_CS6;
else
log_syntax(unit, LOG_WARNING, filename, line, 0,
"Failed to parse IPServiceType type '%s', ignoring.", rvalue);
return 0;
}
+1
View File
@@ -15,3 +15,4 @@ const struct ConfigPerfItem* networkd_gperf_lookup(const char *key, GPERF_LEN_TY
CONFIG_PARSER_PROTOTYPE(config_parse_duid_type);
CONFIG_PARSER_PROTOTYPE(config_parse_duid_rawdata);
CONFIG_PARSER_PROTOTYPE(config_parse_ip_service_type);
+6 -1
View File
@@ -1213,7 +1213,12 @@ int dhcp4_configure(Link *link) {
return log_link_error_errno(link, r, "DHCP4 CLIENT: Failed to set max attempts: %m");
}
return dhcp4_set_client_identifier(link);
if (link->network->ip_service_type > 0) {
r = sd_dhcp_client_set_service_type(link->dhcp_client, link->network->ip_service_type);
if (r < 0)
return log_link_error_errno(link, r, "DHCP4 CLIENT: Failed to set ip service type: %m");
}
return dhcp4_set_client_identifier(link);
}
int config_parse_dhcp_max_attempts(
+1
View File
@@ -167,6 +167,7 @@ DHCPv4.IAID, config_parse_iaid,
DHCPv4.ListenPort, config_parse_uint16, 0, offsetof(Network, dhcp_client_port)
DHCPv4.SendRelease, config_parse_bool, 0, offsetof(Network, dhcp_send_release)
DHCPv4.BlackList, config_parse_dhcp_black_listed_ip_address, 0, 0
DHCPv4.IPServiceType, config_parse_ip_service_type, 0, offsetof(Network, ip_service_type)
DHCPv6.UseDNS, config_parse_bool, 0, offsetof(Network, dhcp6_use_dns)
DHCPv6.UseNTP, config_parse_bool, 0, offsetof(Network, dhcp6_use_ntp)
DHCPv6.RapidCommit, config_parse_bool, 0, offsetof(Network, rapid_commit)
+1
View File
@@ -442,6 +442,7 @@ int network_load_one(Manager *manager, const char *filename) {
.keep_configuration = _KEEP_CONFIGURATION_INVALID,
.can_triple_sampling = -1,
.ip_service_type = -1,
};
r = config_parse_many(filename, NETWORK_DIRS, dropin_dirname,
+1
View File
@@ -104,6 +104,7 @@ struct Network {
DHCPUseDomains dhcp_use_domains;
Set *dhcp_black_listed_ip;
Set *dhcp_request_options;
int ip_service_type;
/* DHCPv6 Client support*/
bool dhcp6_use_dns;