mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-01 04:28:00 +02:00
dhpc: merge branch 'th/dhcp-request-broadcast'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/822
This commit is contained in:
commit
42938a7f52
15 changed files with 217 additions and 126 deletions
|
|
@ -1747,7 +1747,7 @@ new_default_connection(NMDevice *self)
|
|||
if (dev)
|
||||
uprop = udev_device_get_property_value(dev, "NM_AUTO_DEFAULT_LINK_LOCAL_ONLY");
|
||||
|
||||
if (nm_udev_utils_property_as_boolean(uprop)) {
|
||||
if (_nm_utils_ascii_str_to_bool(uprop, FALSE)) {
|
||||
setting = nm_setting_ip4_config_new();
|
||||
g_object_set(setting,
|
||||
NM_SETTING_IP_CONFIG_METHOD,
|
||||
|
|
|
|||
|
|
@ -9447,6 +9447,8 @@ dhcp4_start(NMDevice *self)
|
|||
GError * error = NULL;
|
||||
const NMPlatformLink * pllink;
|
||||
const char *const * reject_servers;
|
||||
gboolean request_broadcast;
|
||||
const char * str;
|
||||
|
||||
connection = nm_device_get_applied_connection(self);
|
||||
g_return_val_if_fail(connection, FALSE);
|
||||
|
|
@ -9460,10 +9462,22 @@ dhcp4_start(NMDevice *self)
|
|||
nm_dbus_object_clear_and_unexport(&priv->dhcp_data_4.config);
|
||||
priv->dhcp_data_4.config = nm_dhcp_config_new(AF_INET);
|
||||
|
||||
request_broadcast = FALSE;
|
||||
|
||||
pllink = nm_platform_link_get(nm_device_get_platform(self), nm_device_get_ip_ifindex(self));
|
||||
if (pllink) {
|
||||
hwaddr = nmp_link_address_get_as_bytes(&pllink->l_address);
|
||||
bcast_hwaddr = nmp_link_address_get_as_bytes(&pllink->l_broadcast);
|
||||
|
||||
str = nmp_object_link_udev_device_get_property_value(NMP_OBJECT_UP_CAST(pllink),
|
||||
"ID_NET_DHCP_BROADCAST");
|
||||
if (str && _nm_utils_ascii_str_to_bool(str, FALSE)) {
|
||||
/* Use the device property ID_NET_DHCP_BROADCAST setting, which may be set for interfaces
|
||||
* requiring that the DHCPOFFER message is being broadcast because they can't handle unicast
|
||||
* messages while not fully configured.
|
||||
*/
|
||||
request_broadcast = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
client_id = _prop_get_ipv4_dhcp_client_id(self, connection, hwaddr);
|
||||
|
|
@ -9472,28 +9486,29 @@ dhcp4_start(NMDevice *self)
|
|||
reject_servers = nm_setting_ip_config_get_dhcp_reject_servers(s_ip4, NULL);
|
||||
|
||||
g_warn_if_fail(priv->dhcp_data_4.client == NULL);
|
||||
priv->dhcp_data_4.client =
|
||||
nm_dhcp_manager_start_ip4(nm_dhcp_manager_get(),
|
||||
nm_netns_get_multi_idx(nm_device_get_netns(self)),
|
||||
nm_device_get_ip_iface(self),
|
||||
nm_device_get_ip_ifindex(self),
|
||||
hwaddr,
|
||||
bcast_hwaddr,
|
||||
nm_connection_get_uuid(connection),
|
||||
nm_device_get_route_table(self, AF_INET),
|
||||
nm_device_get_route_metric(self, AF_INET),
|
||||
nm_setting_ip_config_get_dhcp_send_hostname(s_ip4),
|
||||
nm_setting_ip_config_get_dhcp_hostname(s_ip4),
|
||||
nm_setting_ip4_config_get_dhcp_fqdn(NM_SETTING_IP4_CONFIG(s_ip4)),
|
||||
_prop_get_ipvx_dhcp_hostname_flags(self, AF_INET),
|
||||
_prop_get_connection_mud_url(self, s_con, &mud_url_free),
|
||||
client_id,
|
||||
_prop_get_ipvx_dhcp_timeout(self, AF_INET),
|
||||
priv->dhcp_anycast_address,
|
||||
NULL,
|
||||
vendor_class_identifier,
|
||||
reject_servers,
|
||||
&error);
|
||||
priv->dhcp_data_4.client = nm_dhcp_manager_start_ip4(
|
||||
nm_dhcp_manager_get(),
|
||||
nm_netns_get_multi_idx(nm_device_get_netns(self)),
|
||||
nm_device_get_ip_iface(self),
|
||||
nm_device_get_ip_ifindex(self),
|
||||
hwaddr,
|
||||
bcast_hwaddr,
|
||||
nm_connection_get_uuid(connection),
|
||||
nm_device_get_route_table(self, AF_INET),
|
||||
nm_device_get_route_metric(self, AF_INET),
|
||||
request_broadcast ? NM_DHCP_CLIENT_FLAGS_REQUEST_BROADCAST : NM_DHCP_CLIENT_FLAGS_NONE,
|
||||
nm_setting_ip_config_get_dhcp_send_hostname(s_ip4),
|
||||
nm_setting_ip_config_get_dhcp_hostname(s_ip4),
|
||||
nm_setting_ip4_config_get_dhcp_fqdn(NM_SETTING_IP4_CONFIG(s_ip4)),
|
||||
_prop_get_ipvx_dhcp_hostname_flags(self, AF_INET),
|
||||
_prop_get_connection_mud_url(self, s_con, &mud_url_free),
|
||||
client_id,
|
||||
_prop_get_ipvx_dhcp_timeout(self, AF_INET),
|
||||
priv->dhcp_anycast_address,
|
||||
NULL,
|
||||
vendor_class_identifier,
|
||||
reject_servers,
|
||||
&error);
|
||||
if (!priv->dhcp_data_4.client) {
|
||||
_LOGW(LOGD_DHCP4, "failure to start DHCP: %s", error->message);
|
||||
g_clear_error(&error);
|
||||
|
|
@ -9931,6 +9946,8 @@ dhcp6_start_with_link_ready(NMDevice *self, NMConnection *connection)
|
|||
nm_connection_get_uuid(connection),
|
||||
nm_device_get_route_table(self, AF_INET6),
|
||||
nm_device_get_route_metric(self, AF_INET6),
|
||||
(priv->dhcp6.mode == NM_NDISC_DHCP_LEVEL_OTHERCONF) ? NM_DHCP_CLIENT_FLAGS_INFO_ONLY
|
||||
: NM_DHCP_CLIENT_FLAGS_NONE,
|
||||
nm_setting_ip_config_get_dhcp_send_hostname(s_ip6),
|
||||
nm_setting_ip_config_get_dhcp_hostname(s_ip6),
|
||||
_prop_get_ipvx_dhcp_hostname_flags(self, AF_INET6),
|
||||
|
|
@ -9941,7 +9958,6 @@ dhcp6_start_with_link_ready(NMDevice *self, NMConnection *connection)
|
|||
iaid_explicit,
|
||||
_prop_get_ipvx_dhcp_timeout(self, AF_INET6),
|
||||
priv->dhcp_anycast_address,
|
||||
(priv->dhcp6.mode == NM_NDISC_DHCP_LEVEL_OTHERCONF) ? TRUE : FALSE,
|
||||
nm_setting_ip6_config_get_ip6_privacy(NM_SETTING_IP6_CONFIG(s_ip6)),
|
||||
priv->dhcp6.needed_prefixes,
|
||||
&error);
|
||||
|
|
@ -16154,7 +16170,8 @@ nm_device_spawn_iface_helper(NMDevice *self)
|
|||
|
||||
hostname = nm_dhcp_client_get_hostname(priv->dhcp_data_4.client);
|
||||
if (hostname) {
|
||||
if (nm_dhcp_client_get_use_fqdn(priv->dhcp_data_4.client))
|
||||
if (NM_FLAGS_HAS(nm_dhcp_client_get_client_flags(priv->dhcp_data_4.client),
|
||||
NM_DHCP_CLIENT_FLAGS_USE_FQDN))
|
||||
g_ptr_array_add(argv, g_strdup("--dhcp4-fqdn"));
|
||||
else
|
||||
g_ptr_array_add(argv, g_strdup("--dhcp4-hostname"));
|
||||
|
|
|
|||
|
|
@ -73,8 +73,7 @@ typedef struct _NMDhcpClientPrivate {
|
|||
guint32 iaid;
|
||||
NMDhcpState state;
|
||||
NMDhcpHostnameFlags hostname_flags;
|
||||
bool info_only : 1;
|
||||
bool use_fqdn : 1;
|
||||
NMDhcpClientFlags client_flags;
|
||||
bool iaid_explicit : 1;
|
||||
} NMDhcpClientPrivate;
|
||||
|
||||
|
|
@ -292,20 +291,12 @@ nm_dhcp_client_get_hostname_flags(NMDhcpClient *self)
|
|||
return NM_DHCP_CLIENT_GET_PRIVATE(self)->hostname_flags;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_dhcp_client_get_info_only(NMDhcpClient *self)
|
||||
NMDhcpClientFlags
|
||||
nm_dhcp_client_get_client_flags(NMDhcpClient *self)
|
||||
{
|
||||
g_return_val_if_fail(NM_IS_DHCP_CLIENT(self), FALSE);
|
||||
g_return_val_if_fail(NM_IS_DHCP_CLIENT(self), NM_DHCP_CLIENT_FLAGS_NONE);
|
||||
|
||||
return NM_DHCP_CLIENT_GET_PRIVATE(self)->info_only;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_dhcp_client_get_use_fqdn(NMDhcpClient *self)
|
||||
{
|
||||
g_return_val_if_fail(NM_IS_DHCP_CLIENT(self), FALSE);
|
||||
|
||||
return NM_DHCP_CLIENT_GET_PRIVATE(self)->use_fqdn;
|
||||
return NM_DHCP_CLIENT_GET_PRIVATE(self)->client_flags;
|
||||
}
|
||||
|
||||
const char *
|
||||
|
|
@ -930,12 +921,12 @@ nm_dhcp_client_handle_event(gpointer unused,
|
|||
priv->route_metric));
|
||||
} else {
|
||||
prefix = nm_dhcp_utils_ip6_prefix_from_options(str_options);
|
||||
ip_config = NM_IP_CONFIG_CAST(
|
||||
nm_dhcp_utils_ip6_config_from_options(nm_dhcp_client_get_multi_idx(self),
|
||||
priv->ifindex,
|
||||
priv->iface,
|
||||
str_options,
|
||||
priv->info_only));
|
||||
ip_config = NM_IP_CONFIG_CAST(nm_dhcp_utils_ip6_config_from_options(
|
||||
nm_dhcp_client_get_multi_idx(self),
|
||||
priv->ifindex,
|
||||
priv->iface,
|
||||
str_options,
|
||||
NM_FLAGS_HAS(priv->client_flags, NM_DHCP_CLIENT_FLAGS_INFO_ONLY)));
|
||||
}
|
||||
} else
|
||||
g_warn_if_reached();
|
||||
|
|
@ -1052,11 +1043,8 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps
|
|||
case PROP_FLAGS:
|
||||
/* construct-only */
|
||||
flags = g_value_get_uint(value);
|
||||
nm_assert(
|
||||
(flags & ~((guint)(NM_DHCP_CLIENT_FLAGS_INFO_ONLY | NM_DHCP_CLIENT_FLAGS_USE_FQDN)))
|
||||
== 0);
|
||||
priv->info_only = NM_FLAGS_HAS(flags, NM_DHCP_CLIENT_FLAGS_INFO_ONLY);
|
||||
priv->use_fqdn = NM_FLAGS_HAS(flags, NM_DHCP_CLIENT_FLAGS_USE_FQDN);
|
||||
nm_assert(!NM_FLAGS_ANY(flags, ~((guint) NM_DHCP_CLIENT_FLAGS_ALL)));
|
||||
priv->client_flags = flags;
|
||||
break;
|
||||
case PROP_MULTI_IDX:
|
||||
/* construct-only */
|
||||
|
|
@ -1153,6 +1141,26 @@ nm_dhcp_client_init(NMDhcpClient *self)
|
|||
priv->pid = -1;
|
||||
}
|
||||
|
||||
#if NM_MORE_ASSERTS
|
||||
static void
|
||||
constructed(GObject *object)
|
||||
{
|
||||
NMDhcpClient * self = NM_DHCP_CLIENT(object);
|
||||
NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE(self);
|
||||
|
||||
/* certain flags only make sense with certain address family. Assert
|
||||
* for that. */
|
||||
if (NM_IS_IPv4(priv->addr_family))
|
||||
nm_assert(!NM_FLAGS_ANY(priv->client_flags, NM_DHCP_CLIENT_FLAGS_INFO_ONLY));
|
||||
else {
|
||||
nm_assert(NM_FLAGS_HAS(priv->client_flags, NM_DHCP_CLIENT_FLAGS_USE_FQDN));
|
||||
nm_assert(!NM_FLAGS_ANY(priv->client_flags, NM_DHCP_CLIENT_FLAGS_REQUEST_BROADCAST));
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS(nm_dhcp_client_parent_class)->constructed(object);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
dispose(GObject *object)
|
||||
{
|
||||
|
|
@ -1191,6 +1199,9 @@ nm_dhcp_client_class_init(NMDhcpClientClass *client_class)
|
|||
|
||||
g_type_class_add_private(client_class, sizeof(NMDhcpClientPrivate));
|
||||
|
||||
#if NM_MORE_ASSERTS
|
||||
object_class->constructed = constructed;
|
||||
#endif
|
||||
object_class->dispose = dispose;
|
||||
object_class->get_property = get_property;
|
||||
object_class->set_property = set_property;
|
||||
|
|
|
|||
|
|
@ -68,9 +68,15 @@ typedef struct {
|
|||
CList dhcp_client_lst;
|
||||
} NMDhcpClient;
|
||||
|
||||
typedef enum {
|
||||
NM_DHCP_CLIENT_FLAGS_INFO_ONLY = (1LL << 0),
|
||||
NM_DHCP_CLIENT_FLAGS_USE_FQDN = (1LL << 1),
|
||||
typedef enum _nm_packed {
|
||||
NM_DHCP_CLIENT_FLAGS_NONE = 0,
|
||||
|
||||
NM_DHCP_CLIENT_FLAGS_INFO_ONLY = (1LL << 0),
|
||||
NM_DHCP_CLIENT_FLAGS_USE_FQDN = (1LL << 1),
|
||||
NM_DHCP_CLIENT_FLAGS_REQUEST_BROADCAST = (1LL << 2),
|
||||
|
||||
_NM_DHCP_CLIENT_FLAGS_LAST,
|
||||
NM_DHCP_CLIENT_FLAGS_ALL = ((_NM_DHCP_CLIENT_FLAGS_LAST - 1) << 1) - 1,
|
||||
} NMDhcpClientFlags;
|
||||
|
||||
typedef struct {
|
||||
|
|
@ -148,9 +154,7 @@ const char *const *nm_dhcp_client_get_reject_servers(NMDhcpClient *self);
|
|||
|
||||
NMDhcpHostnameFlags nm_dhcp_client_get_hostname_flags(NMDhcpClient *self);
|
||||
|
||||
gboolean nm_dhcp_client_get_info_only(NMDhcpClient *self);
|
||||
|
||||
gboolean nm_dhcp_client_get_use_fqdn(NMDhcpClient *self);
|
||||
NMDhcpClientFlags nm_dhcp_client_get_client_flags(NMDhcpClient *self);
|
||||
|
||||
GBytes *nm_dhcp_client_get_vendor_class_identifier(NMDhcpClient *self);
|
||||
|
||||
|
|
|
|||
|
|
@ -435,6 +435,12 @@ dhclient_start(NMDhcpClient *client,
|
|||
if (release)
|
||||
g_ptr_array_add(argv, (gpointer) "-r");
|
||||
|
||||
if (!release
|
||||
&& NM_FLAGS_HAS(nm_dhcp_client_get_client_flags(NM_DHCP_CLIENT(self)),
|
||||
NM_DHCP_CLIENT_FLAGS_REQUEST_BROADCAST)) {
|
||||
g_ptr_array_add(argv, (gpointer) "-B");
|
||||
}
|
||||
|
||||
if (addr_family == AF_INET6) {
|
||||
g_ptr_array_add(argv, (gpointer) "-6");
|
||||
|
||||
|
|
@ -520,19 +526,20 @@ ip4_start(NMDhcpClient *client,
|
|||
|
||||
client_id = nm_dhcp_client_get_client_id(client);
|
||||
|
||||
priv->conf_file = create_dhclient_config(self,
|
||||
AF_INET,
|
||||
nm_dhcp_client_get_iface(client),
|
||||
nm_dhcp_client_get_uuid(client),
|
||||
client_id,
|
||||
dhcp_anycast_addr,
|
||||
nm_dhcp_client_get_hostname(client),
|
||||
nm_dhcp_client_get_timeout(client),
|
||||
nm_dhcp_client_get_use_fqdn(client),
|
||||
nm_dhcp_client_get_hostname_flags(client),
|
||||
nm_dhcp_client_get_mud_url(client),
|
||||
nm_dhcp_client_get_reject_servers(client),
|
||||
&new_client_id);
|
||||
priv->conf_file = create_dhclient_config(
|
||||
self,
|
||||
AF_INET,
|
||||
nm_dhcp_client_get_iface(client),
|
||||
nm_dhcp_client_get_uuid(client),
|
||||
client_id,
|
||||
dhcp_anycast_addr,
|
||||
nm_dhcp_client_get_hostname(client),
|
||||
nm_dhcp_client_get_timeout(client),
|
||||
NM_FLAGS_HAS(nm_dhcp_client_get_client_flags(client), NM_DHCP_CLIENT_FLAGS_USE_FQDN),
|
||||
nm_dhcp_client_get_hostname_flags(client),
|
||||
nm_dhcp_client_get_mud_url(client),
|
||||
nm_dhcp_client_get_reject_servers(client),
|
||||
&new_client_id);
|
||||
if (!priv->conf_file) {
|
||||
nm_utils_error_set_literal(error,
|
||||
NM_UTILS_ERROR_UNKNOWN,
|
||||
|
|
@ -582,7 +589,10 @@ ip6_start(NMDhcpClient * client,
|
|||
}
|
||||
|
||||
return dhclient_start(client,
|
||||
nm_dhcp_client_get_info_only(NM_DHCP_CLIENT(self)) ? "-S" : "-N",
|
||||
NM_FLAGS_HAS(nm_dhcp_client_get_client_flags(NM_DHCP_CLIENT(self)),
|
||||
NM_DHCP_CLIENT_FLAGS_INFO_ONLY)
|
||||
? "-S"
|
||||
: "-N",
|
||||
FALSE,
|
||||
NULL,
|
||||
needed_prefixes,
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ ip4_start(NMDhcpClient *client,
|
|||
hostname = nm_dhcp_client_get_hostname(client);
|
||||
|
||||
if (hostname) {
|
||||
if (nm_dhcp_client_get_use_fqdn(client)) {
|
||||
if (NM_FLAGS_HAS(nm_dhcp_client_get_client_flags(client), NM_DHCP_CLIENT_FLAGS_USE_FQDN)) {
|
||||
g_ptr_array_add(argv, (gpointer) "-h");
|
||||
g_ptr_array_add(argv, (gpointer) hostname);
|
||||
g_ptr_array_add(argv, (gpointer) "-F");
|
||||
|
|
|
|||
|
|
@ -213,12 +213,11 @@ client_start(NMDhcpManager * self,
|
|||
guint32 iaid,
|
||||
gboolean iaid_explicit,
|
||||
guint32 timeout,
|
||||
NMDhcpClientFlags client_flags,
|
||||
const char * dhcp_anycast_addr,
|
||||
const char * hostname,
|
||||
gboolean hostname_use_fqdn,
|
||||
NMDhcpHostnameFlags hostname_flags,
|
||||
const char * mud_url,
|
||||
gboolean info_only,
|
||||
NMSettingIP6ConfigPrivacy privacy,
|
||||
const char * last_ip4_address,
|
||||
guint needed_prefixes,
|
||||
|
|
@ -241,6 +240,7 @@ client_start(NMDhcpManager * self,
|
|||
|| g_bytes_get_size(vendor_class_identifier) <= 255,
|
||||
NULL);
|
||||
g_return_val_if_fail(!error || !*error, NULL);
|
||||
nm_assert(!NM_FLAGS_ANY(client_flags, ~NM_DHCP_CLIENT_FLAGS_ALL));
|
||||
|
||||
if (addr_family == AF_INET) {
|
||||
if (!hwaddr || !bcast_hwaddr) {
|
||||
|
|
@ -263,12 +263,14 @@ client_start(NMDhcpManager * self,
|
|||
}
|
||||
|
||||
if (hostname) {
|
||||
if ((hostname_use_fqdn && !nm_sd_dns_name_is_valid(hostname))
|
||||
|| (!hostname_use_fqdn && !nm_sd_hostname_is_valid(hostname, FALSE))) {
|
||||
gboolean use_fqdn = NM_FLAGS_HAS(client_flags, NM_DHCP_CLIENT_FLAGS_USE_FQDN);
|
||||
|
||||
if ((use_fqdn && !nm_sd_dns_name_is_valid(hostname))
|
||||
|| (!use_fqdn && !nm_sd_hostname_is_valid(hostname, FALSE))) {
|
||||
nm_log_warn(LOGD_DHCP,
|
||||
"dhcp%c: %s '%s' is invalid, will be ignored",
|
||||
nm_utils_addr_family_to_char(addr_family),
|
||||
hostname_use_fqdn ? "FQDN" : "hostname",
|
||||
use_fqdn ? "FQDN" : "hostname",
|
||||
hostname);
|
||||
hostname = NULL;
|
||||
}
|
||||
|
|
@ -334,8 +336,7 @@ client_start(NMDhcpManager * self,
|
|||
NM_DHCP_CLIENT_REJECT_SERVERS,
|
||||
reject_servers,
|
||||
NM_DHCP_CLIENT_FLAGS,
|
||||
(guint)(0 | (hostname_use_fqdn ? NM_DHCP_CLIENT_FLAGS_USE_FQDN : 0)
|
||||
| (info_only ? NM_DHCP_CLIENT_FLAGS_INFO_ONLY : 0)),
|
||||
(guint) client_flags,
|
||||
NULL);
|
||||
nm_assert(client && c_list_is_empty(&client->dhcp_client_lst));
|
||||
c_list_link_tail(&priv->dhcp_client_lst_head, &client->dhcp_client_lst);
|
||||
|
|
@ -406,6 +407,7 @@ nm_dhcp_manager_start_ip4(NMDhcpManager * self,
|
|||
const char * uuid,
|
||||
guint32 route_table,
|
||||
guint32 route_metric,
|
||||
NMDhcpClientFlags client_flags,
|
||||
gboolean send_hostname,
|
||||
const char * dhcp_hostname,
|
||||
const char * dhcp_fqdn,
|
||||
|
|
@ -425,6 +427,10 @@ nm_dhcp_manager_start_ip4(NMDhcpManager * self,
|
|||
gboolean use_fqdn = FALSE;
|
||||
char * dot;
|
||||
|
||||
/* these flags are set automatically/prohibited, and not free to set to the caller. */
|
||||
nm_assert(!NM_FLAGS_ANY(client_flags,
|
||||
NM_DHCP_CLIENT_FLAGS_USE_FQDN | NM_DHCP_CLIENT_FLAGS_INFO_ONLY));
|
||||
|
||||
g_return_val_if_fail(NM_IS_DHCP_MANAGER(self), NULL);
|
||||
priv = NM_DHCP_MANAGER_GET_PRIVATE(self);
|
||||
|
||||
|
|
@ -451,34 +457,34 @@ nm_dhcp_manager_start_ip4(NMDhcpManager * self,
|
|||
}
|
||||
}
|
||||
|
||||
return client_start(self,
|
||||
AF_INET,
|
||||
multi_idx,
|
||||
iface,
|
||||
ifindex,
|
||||
hwaddr,
|
||||
bcast_hwaddr,
|
||||
uuid,
|
||||
route_table,
|
||||
route_metric,
|
||||
NULL,
|
||||
dhcp_client_id,
|
||||
FALSE,
|
||||
0,
|
||||
FALSE,
|
||||
timeout,
|
||||
dhcp_anycast_addr,
|
||||
hostname,
|
||||
use_fqdn,
|
||||
hostname_flags,
|
||||
mud_url,
|
||||
FALSE,
|
||||
0,
|
||||
last_ip_address,
|
||||
0,
|
||||
vendor_class_identifier,
|
||||
reject_servers,
|
||||
error);
|
||||
return client_start(
|
||||
self,
|
||||
AF_INET,
|
||||
multi_idx,
|
||||
iface,
|
||||
ifindex,
|
||||
hwaddr,
|
||||
bcast_hwaddr,
|
||||
uuid,
|
||||
route_table,
|
||||
route_metric,
|
||||
NULL,
|
||||
dhcp_client_id,
|
||||
FALSE,
|
||||
0,
|
||||
FALSE,
|
||||
timeout,
|
||||
client_flags | (use_fqdn ? NM_DHCP_CLIENT_FLAGS_USE_FQDN : NM_DHCP_CLIENT_FLAGS_NONE),
|
||||
dhcp_anycast_addr,
|
||||
hostname,
|
||||
hostname_flags,
|
||||
mud_url,
|
||||
0,
|
||||
last_ip_address,
|
||||
0,
|
||||
vendor_class_identifier,
|
||||
reject_servers,
|
||||
error);
|
||||
}
|
||||
|
||||
/* Caller owns a reference to the NMDhcpClient on return */
|
||||
|
|
@ -491,6 +497,7 @@ nm_dhcp_manager_start_ip6(NMDhcpManager * self,
|
|||
const char * uuid,
|
||||
guint32 route_table,
|
||||
guint32 route_metric,
|
||||
NMDhcpClientFlags client_flags,
|
||||
gboolean send_hostname,
|
||||
const char * dhcp_hostname,
|
||||
NMDhcpHostnameFlags hostname_flags,
|
||||
|
|
@ -501,7 +508,6 @@ nm_dhcp_manager_start_ip6(NMDhcpManager * self,
|
|||
gboolean iaid_explicit,
|
||||
guint32 timeout,
|
||||
const char * dhcp_anycast_addr,
|
||||
gboolean info_only,
|
||||
NMSettingIP6ConfigPrivacy privacy,
|
||||
guint needed_prefixes,
|
||||
GError ** error)
|
||||
|
|
@ -509,6 +515,9 @@ nm_dhcp_manager_start_ip6(NMDhcpManager * self,
|
|||
NMDhcpManagerPrivate *priv;
|
||||
const char * hostname = NULL;
|
||||
|
||||
/* this flag is set automatically, and not free to set to the caller. */
|
||||
nm_assert(!NM_FLAGS_ANY(client_flags, NM_DHCP_CLIENT_FLAGS_USE_FQDN));
|
||||
|
||||
g_return_val_if_fail(NM_IS_DHCP_MANAGER(self), NULL);
|
||||
priv = NM_DHCP_MANAGER_GET_PRIVATE(self);
|
||||
|
||||
|
|
@ -532,12 +541,11 @@ nm_dhcp_manager_start_ip6(NMDhcpManager * self,
|
|||
iaid,
|
||||
iaid_explicit,
|
||||
timeout,
|
||||
client_flags | NM_DHCP_CLIENT_FLAGS_USE_FQDN,
|
||||
dhcp_anycast_addr,
|
||||
hostname,
|
||||
TRUE,
|
||||
hostname_flags,
|
||||
mud_url,
|
||||
info_only,
|
||||
privacy,
|
||||
NULL,
|
||||
needed_prefixes,
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ NMDhcpClient *nm_dhcp_manager_start_ip4(NMDhcpManager * manager,
|
|||
const char * uuid,
|
||||
guint32 route_table,
|
||||
guint32 route_metric,
|
||||
NMDhcpClientFlags client_flags,
|
||||
gboolean send_hostname,
|
||||
const char * dhcp_hostname,
|
||||
const char * dhcp_fqdn,
|
||||
|
|
@ -62,6 +63,7 @@ NMDhcpClient *nm_dhcp_manager_start_ip6(NMDhcpManager * manager,
|
|||
const char * uuid,
|
||||
guint32 route_table,
|
||||
guint32 route_metric,
|
||||
NMDhcpClientFlags client_flags,
|
||||
gboolean send_hostname,
|
||||
const char * dhcp_hostname,
|
||||
NMDhcpHostnameFlags hostname_flags,
|
||||
|
|
@ -72,7 +74,6 @@ NMDhcpClient *nm_dhcp_manager_start_ip6(NMDhcpManager * manager,
|
|||
gboolean iaid_explicit,
|
||||
guint32 timeout,
|
||||
const char * dhcp_anycast_addr,
|
||||
gboolean info_only,
|
||||
NMSettingIP6ConfigPrivacy privacy,
|
||||
guint needed_prefixes,
|
||||
GError ** error);
|
||||
|
|
|
|||
|
|
@ -938,6 +938,10 @@ nettools_create(NMDhcpNettools *self, const char *dhcp_anycast_addr, GError **er
|
|||
n_dhcp4_client_config_set_transport(config, transport);
|
||||
n_dhcp4_client_config_set_mac(config, hwaddr_arr, hwaddr_len);
|
||||
n_dhcp4_client_config_set_broadcast_mac(config, bcast_hwaddr_arr, bcast_hwaddr_len);
|
||||
n_dhcp4_client_config_set_request_broadcast(
|
||||
config,
|
||||
NM_FLAGS_HAS(nm_dhcp_client_get_client_flags(NM_DHCP_CLIENT(self)),
|
||||
NM_DHCP_CLIENT_FLAGS_REQUEST_BROADCAST));
|
||||
r = n_dhcp4_client_config_set_client_id(config,
|
||||
client_id_arr,
|
||||
NM_MIN(client_id_len, 1 + _NM_SD_MAX_CLIENT_ID_LEN));
|
||||
|
|
@ -1110,7 +1114,7 @@ ip4_start(NMDhcpClient *client,
|
|||
}
|
||||
hostname = nm_dhcp_client_get_hostname(client);
|
||||
if (hostname) {
|
||||
if (nm_dhcp_client_get_use_fqdn(client)) {
|
||||
if (NM_FLAGS_HAS(nm_dhcp_client_get_client_flags(client), NM_DHCP_CLIENT_FLAGS_USE_FQDN)) {
|
||||
uint8_t buffer[255];
|
||||
NMDhcpHostnameFlags flags;
|
||||
size_t fqdn_len;
|
||||
|
|
|
|||
|
|
@ -632,6 +632,11 @@ ip4_start(NMDhcpClient *client,
|
|||
sd_dhcp_lease_get_address(lease, &last_addr);
|
||||
}
|
||||
|
||||
r = sd_dhcp_client_set_request_broadcast(sd_client,
|
||||
NM_FLAGS_HAS(nm_dhcp_client_get_client_flags(client),
|
||||
NM_DHCP_CLIENT_FLAGS_REQUEST_BROADCAST));
|
||||
nm_assert(r >= 0);
|
||||
|
||||
if (last_addr.s_addr) {
|
||||
r = sd_dhcp_client_set_request_address(sd_client, &last_addr);
|
||||
if (r < 0) {
|
||||
|
|
@ -844,14 +849,16 @@ bound6_handle(NMDhcpSystemd *self)
|
|||
|
||||
_LOGD("lease available");
|
||||
|
||||
ip6_config = lease_to_ip6_config(nm_dhcp_client_get_multi_idx(NM_DHCP_CLIENT(self)),
|
||||
iface,
|
||||
nm_dhcp_client_get_ifindex(NM_DHCP_CLIENT(self)),
|
||||
lease,
|
||||
nm_dhcp_client_get_info_only(NM_DHCP_CLIENT(self)),
|
||||
&options,
|
||||
ts,
|
||||
&error);
|
||||
ip6_config =
|
||||
lease_to_ip6_config(nm_dhcp_client_get_multi_idx(NM_DHCP_CLIENT(self)),
|
||||
iface,
|
||||
nm_dhcp_client_get_ifindex(NM_DHCP_CLIENT(self)),
|
||||
lease,
|
||||
NM_FLAGS_HAS(nm_dhcp_client_get_client_flags(NM_DHCP_CLIENT(self)),
|
||||
NM_DHCP_CLIENT_FLAGS_INFO_ONLY),
|
||||
&options,
|
||||
ts,
|
||||
&error);
|
||||
|
||||
if (!ip6_config) {
|
||||
_LOGW("%s", error->message);
|
||||
|
|
@ -938,7 +945,7 @@ ip6_start(NMDhcpClient * client,
|
|||
|
||||
_LOGT("dhcp-client6: set %p", sd_client);
|
||||
|
||||
if (nm_dhcp_client_get_info_only(client)) {
|
||||
if (NM_FLAGS_HAS(nm_dhcp_client_get_client_flags(client), NM_DHCP_CLIENT_FLAGS_INFO_ONLY)) {
|
||||
sd_dhcp6_client_set_address_request(sd_client, 0);
|
||||
if (needed_prefixes == 0)
|
||||
sd_dhcp6_client_set_information_request(sd_client, 1);
|
||||
|
|
|
|||
|
|
@ -668,6 +668,7 @@ main(int argc, char *argv[])
|
|||
global_opt.uuid,
|
||||
RT_TABLE_MAIN,
|
||||
global_opt.priority_v4,
|
||||
NM_DHCP_CLIENT_FLAGS_NONE,
|
||||
!!global_opt.dhcp4_hostname,
|
||||
global_opt.dhcp4_hostname,
|
||||
global_opt.dhcp4_fqdn,
|
||||
|
|
|
|||
|
|
@ -1441,8 +1441,11 @@ nm_platform_link_get_type_name(NMPlatform *self, int ifindex)
|
|||
return obj->link.kind ?: "unknown";
|
||||
}
|
||||
|
||||
static gboolean
|
||||
link_get_udev_property(NMPlatform *self, int ifindex, const char *name, const char **out_value)
|
||||
gboolean
|
||||
nm_platform_link_get_udev_property(NMPlatform * self,
|
||||
int ifindex,
|
||||
const char * name,
|
||||
const char **out_value)
|
||||
{
|
||||
struct udev_device *udevice = NULL;
|
||||
const char * uproperty;
|
||||
|
|
@ -1473,8 +1476,8 @@ nm_platform_link_get_unmanaged(NMPlatform *self, int ifindex, gboolean *unmanage
|
|||
{
|
||||
const char *value;
|
||||
|
||||
if (link_get_udev_property(self, ifindex, "NM_UNMANAGED", &value)) {
|
||||
NM_SET_OUT(unmanaged, nm_udev_utils_property_as_boolean(value));
|
||||
if (nm_platform_link_get_udev_property(self, ifindex, "NM_UNMANAGED", &value)) {
|
||||
NM_SET_OUT(unmanaged, _nm_utils_ascii_str_to_bool(value, FALSE));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -1633,8 +1636,7 @@ nm_platform_link_get_path(NMPlatform *self, int ifindex)
|
|||
{
|
||||
const char *value = NULL;
|
||||
|
||||
link_get_udev_property(self, ifindex, "ID_PATH", &value);
|
||||
|
||||
nm_platform_link_get_udev_property(self, ifindex, "ID_PATH", &value);
|
||||
return value;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1840,6 +1840,10 @@ nm_platform_link_change_flags(NMPlatform *self, int ifindex, unsigned value, gbo
|
|||
return nm_platform_link_change_flags_full(self, ifindex, value, set ? value : 0u);
|
||||
}
|
||||
|
||||
gboolean nm_platform_link_get_udev_property(NMPlatform * self,
|
||||
int ifindex,
|
||||
const char * name,
|
||||
const char **out_value);
|
||||
const char *nm_platform_link_get_udi(NMPlatform *self, int ifindex);
|
||||
const char *nm_platform_link_get_path(NMPlatform *self, int ifindex);
|
||||
|
||||
|
|
|
|||
|
|
@ -257,6 +257,24 @@ nm_sock_addr_union_to_string(const NMSockAddrUnion *sa, char *buf, gsize len)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
const char *
|
||||
nmp_object_link_udev_device_get_property_value(const NMPObject *obj, const char *key)
|
||||
{
|
||||
nm_assert(key);
|
||||
|
||||
if (!obj)
|
||||
return nm_assert_unreachable_val(NULL);
|
||||
|
||||
nm_assert(NMP_OBJECT_GET_TYPE(obj) == NMP_OBJECT_TYPE_LINK);
|
||||
|
||||
if (!obj->_link.udev.device)
|
||||
return NULL;
|
||||
|
||||
return udev_device_get_property_value(obj->_link.udev.device, key);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static const NMDedupMultiIdxTypeClass _dedup_multi_idx_type_class;
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -1067,6 +1067,10 @@ nmp_object_ip6_address_is_not_link_local(const NMPObject *obj)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
const char *nmp_object_link_udev_device_get_property_value(const NMPObject *obj, const char *key);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static inline gboolean
|
||||
nm_platform_dedup_multi_iter_next_obj(NMDedupMultiIter *ipconf_iter,
|
||||
const NMPObject **out_obj,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue