Also this renames sd_dhcp_client_set_service_type() to _set_ip_service_type().
void *state_userdata;
sd_dhcp_lease *lease;
usec_t start_delay;
- int ip_service_type;
+ uint8_t ip_service_type;
int socket_priority;
- bool socket_priority_set;
bool ipv6_acquired;
bool bootp;
bool send_release;
&client->bcast_addr,
client->arp_type,
client->port,
- client->socket_priority_set,
+ /* so_priority_set= */ true,
client->socket_priority);
if (fd < 0)
return fd;
#include "network-common.h"
#include "random-util.h"
#include "set.h"
+#include "socket-util.h"
#include "string-table.h"
#include "string-util.h"
#include "time-util.h"
return 0;
}
-int sd_dhcp_client_set_service_type(sd_dhcp_client *client, int type) {
+int sd_dhcp_client_set_ip_service_type(sd_dhcp_client *client, uint8_t type) {
assert_return(client, -EINVAL);
assert_return(!sd_dhcp_client_is_running(client), -EBUSY);
assert_return(client, -EINVAL);
assert_return(!sd_dhcp_client_is_running(client), -EBUSY);
- client->socket_priority_set = true;
client->socket_priority = socket_priority;
return 0;
.port = DHCP_PORT_CLIENT,
.server_port = DHCP_PORT_SERVER,
.max_discover_attempts = UINT64_MAX,
- .ip_service_type = -1,
+ .ip_service_type = IPTOS_CLASS_CS6, /* Defaults to CS6 (Internetwork Control). */
+ .socket_priority = tos_to_priority(IPTOS_CLASS_CS6),
};
FOREACH_ELEMENT(opt, default_req_opts) {
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <linux/if_arp.h>
+#include <linux/pkt_sched.h>
#include <linux/rtnetlink.h>
#include <netinet/in.h>
#include <netinet/ip.h>
}
if (link->network->dhcp_ip_service_type >= 0) {
- r = sd_dhcp_client_set_service_type(link->dhcp_client, link->network->dhcp_ip_service_type);
+ assert(link->network->dhcp_ip_service_type <= UINT8_MAX);
+ r = sd_dhcp_client_set_ip_service_type(link->dhcp_client, link->network->dhcp_ip_service_type);
if (r < 0)
return log_link_debug_errno(link, r, "DHCPv4 CLIENT: Failed to set IP service type: %m");
}
- if (link->network->dhcp_socket_priority_set) {
+ if (link->network->dhcp_socket_priority >= 0) {
r = sd_dhcp_client_set_socket_priority(link->dhcp_client, link->network->dhcp_socket_priority);
if (r < 0)
return log_link_debug_errno(link, r, "DHCPv4 CLIENT: Failed to set socket priority: %m");
void *data,
void *userdata) {
- Network *network = ASSERT_PTR(data);
- int a, r;
+ int r, a, *priority = ASSERT_PTR(data);
assert(lvalue);
assert(rvalue);
if (isempty(rvalue)) {
- network->dhcp_socket_priority_set = false;
+ *priority = -1;
return 0;
}
"Failed to parse socket priority, ignoring: %s", rvalue);
return 0;
}
+ if (a < 0 || a > TC_PRIO_MAX) {
+ log_syntax(unit, LOG_WARNING, filename, line, 0,
+ "Invalid socket priority, must be in 0…%i, ignoring: %i", TC_PRIO_MAX, a);
+ return 0;
+ }
- network->dhcp_socket_priority_set = true;
- network->dhcp_socket_priority = a;
-
+ *priority = a;
return 0;
}
DHCPv4.DenyList, config_parse_in_addr_prefixes, AF_INET, offsetof(Network, dhcp_deny_listed_ip)
DHCPv4.AllowList, config_parse_in_addr_prefixes, AF_INET, offsetof(Network, dhcp_allow_listed_ip)
DHCPv4.IPServiceType, config_parse_dhcp_ip_service_type, 0, offsetof(Network, dhcp_ip_service_type)
-DHCPv4.SocketPriority, config_parse_dhcp_socket_priority, 0, 0
+DHCPv4.SocketPriority, config_parse_dhcp_socket_priority, 0, offsetof(Network, dhcp_socket_priority)
DHCPv4.SendOption, config_parse_dhcp_option_tlv, 0, offsetof(Network, dhcp_extra_options)
DHCPv4.SendVendorOption, config_parse_dhcp_option_tlv, 0, offsetof(Network, dhcp_vendor_options)
DHCPv4.RouteMTUBytes, config_parse_mtu, AF_INET, offsetof(Network, dhcp_route_mtu)
.dhcp_client_identifier = _DHCP_CLIENT_ID_INVALID,
.dhcp_route_table = RT_TABLE_MAIN,
.dhcp_ip_service_type = -1,
+ .dhcp_socket_priority = -1,
.dhcp_broadcast = -1,
.dhcp_ipv6_only_mode = -1,
.dhcp_6rd_prefix_route_type = RTN_UNREACHABLE,
int dhcp_critical;
int dhcp_ip_service_type;
int dhcp_socket_priority;
- bool dhcp_socket_priority_set;
bool dhcp_anonymize;
bool dhcp_send_hostname;
bool dhcp_send_hostname_set;
int sd_dhcp_client_get_lease(
sd_dhcp_client *client,
sd_dhcp_lease **ret);
-int sd_dhcp_client_set_service_type(
+int sd_dhcp_client_set_ip_service_type(
sd_dhcp_client *client,
- int type);
+ uint8_t type);
int sd_dhcp_client_set_socket_priority(
sd_dhcp_client *client,
int socket_priority);