sd-dhcp-client: set TOS and socket priority by default

Also this renames sd_dhcp_client_set_service_type() to _set_ip_service_type().
This commit is contained in:
Yu Watanabe
2026-05-17 01:34:44 +09:00
parent e7c550895a
commit ff32569f2a
8 changed files with 22 additions and 18 deletions
@@ -78,9 +78,8 @@ struct sd_dhcp_client {
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;
+1 -1
View File
@@ -93,7 +93,7 @@ static int client_send_raw(
&client->bcast_addr,
client->arp_type,
client->port,
client->socket_priority_set,
/* so_priority_set= */ true,
client->socket_priority);
if (fd < 0)
return fd;
+4 -3
View File
@@ -22,6 +22,7 @@
#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"
@@ -515,7 +516,7 @@ int sd_dhcp_client_get_lease(sd_dhcp_client *client, sd_dhcp_lease **ret) {
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);
@@ -528,7 +529,6 @@ int sd_dhcp_client_set_socket_priority(sd_dhcp_client *client, int socket_priori
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;
@@ -1425,7 +1425,8 @@ int sd_dhcp_client_new(sd_dhcp_client **ret) {
.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) {