mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-04 01:20:35 +01:00
dhcp: support FQDN flags in the dhclient backend
Make the dhclient backend honor the ipv4.dhcp-fqdn-flags setting.
This commit is contained in:
parent
292d3f2b57
commit
316ff68bfa
12 changed files with 169 additions and 28 deletions
|
|
@ -716,6 +716,10 @@ ipv6.ip6-privacy=0
|
|||
<term><varname>ipv4.dhcp-iaid</varname></term>
|
||||
<listitem><para>If left unspecified, it defaults to "ifname".</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><varname>ipv4.dhcp-hostname-flags</varname></term>
|
||||
<listitem><para>If left unspecified, the value 3 (fqdn-encoded,fqdn-serv-update) is used.</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><varname>ipv4.dhcp-timeout</varname></term>
|
||||
<listitem><para>If left unspecified, the default value for
|
||||
|
|
@ -744,6 +748,10 @@ ipv6.ip6-privacy=0
|
|||
<term><varname>ipv6.dhcp-iaid</varname></term>
|
||||
<listitem><para>If left unspecified, it defaults to "ifname".</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><varname>ipv6.dhcp-hostname-flags</varname></term>
|
||||
<listitem><para>If left unspecified, the value 1 (fqdn-serv-update) is used.</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><varname>ipv6.dhcp-timeout</varname></term>
|
||||
<listitem><para>If left unspecified, the default value for
|
||||
|
|
|
|||
|
|
@ -55,6 +55,5 @@ NM_IAID_IS_SPECIAL (const char *str)
|
|||
NM_IAID_IFNAME,
|
||||
NM_IAID_STABLE);
|
||||
}
|
||||
/*****************************************************************************/
|
||||
|
||||
#endif /* __NM_COMMON_MACROS_H__ */
|
||||
|
|
|
|||
|
|
@ -8092,6 +8092,53 @@ out_good:
|
|||
return iaid;
|
||||
}
|
||||
|
||||
static NMDhcpHostnameFlags
|
||||
get_dhcp_hostname_flags (NMDevice *self, int addr_family)
|
||||
{
|
||||
NMConnection *connection;
|
||||
NMSettingIPConfig *s_ip;
|
||||
NMDhcpHostnameFlags flags;
|
||||
gs_free_error GError *error = NULL;
|
||||
|
||||
g_return_val_if_fail (NM_IS_DEVICE (self), NM_DHCP_HOSTNAME_FLAG_NONE);
|
||||
|
||||
connection = nm_device_get_applied_connection (self);
|
||||
s_ip = nm_connection_get_setting_ip_config (connection, addr_family);
|
||||
g_return_val_if_fail (s_ip, NM_DHCP_HOSTNAME_FLAG_NONE);
|
||||
|
||||
if (!nm_setting_ip_config_get_dhcp_send_hostname (s_ip))
|
||||
return NM_DHCP_HOSTNAME_FLAG_NONE;
|
||||
|
||||
flags = nm_setting_ip_config_get_dhcp_hostname_flags (s_ip);
|
||||
if (flags != NM_DHCP_HOSTNAME_FLAG_NONE)
|
||||
return flags;
|
||||
|
||||
flags = nm_config_data_get_connection_default_int64 (NM_CONFIG_GET_DATA,
|
||||
addr_family == AF_INET
|
||||
? NM_CON_DEFAULT ("ipv4.dhcp-hostname-flags")
|
||||
: NM_CON_DEFAULT ("ipv6.dhcp-hostname-flags"),
|
||||
self,
|
||||
0, NM_DHCP_HOSTNAME_FLAG_FQDN_CLEAR_FLAGS,
|
||||
0);
|
||||
|
||||
if (!_nm_utils_validate_dhcp_hostname_flags (flags, addr_family, &error)) {
|
||||
_LOGW (LOGD_DEVICE, "invalid global default value 0x%x for ipv%d.%s: %s",
|
||||
(guint) flags,
|
||||
addr_family == AF_INET ? 4 : 6,
|
||||
NM_SETTING_IP_CONFIG_DHCP_HOSTNAME_FLAGS,
|
||||
error->message);
|
||||
flags = NM_DHCP_HOSTNAME_FLAG_NONE;
|
||||
}
|
||||
|
||||
if (flags != NM_DHCP_HOSTNAME_FLAG_NONE)
|
||||
return flags;
|
||||
|
||||
if (addr_family == AF_INET)
|
||||
return NM_DHCP_HOSTNAME_FLAGS_FQDN_DEFAULT_IP4;
|
||||
else
|
||||
return NM_DHCP_HOSTNAME_FLAGS_FQDN_DEFAULT_IP6;
|
||||
}
|
||||
|
||||
static GBytes *
|
||||
dhcp4_get_client_id (NMDevice *self,
|
||||
NMConnection *connection,
|
||||
|
|
@ -8265,12 +8312,12 @@ dhcp4_start (NMDevice *self)
|
|||
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)),
|
||||
get_dhcp_hostname_flags (self, AF_INET),
|
||||
client_id,
|
||||
get_dhcp_timeout (self, AF_INET),
|
||||
priv->dhcp_anycast_address,
|
||||
NULL,
|
||||
&error);
|
||||
|
||||
if (!priv->dhcp4.client) {
|
||||
_LOGW (LOGD_DHCP4, "failure to start DHCP: %s", error->message);
|
||||
g_clear_error (&error);
|
||||
|
|
@ -9078,6 +9125,7 @@ dhcp6_start_with_link_ready (NMDevice *self, NMConnection *connection)
|
|||
nm_device_get_route_metric (self, AF_INET6),
|
||||
nm_setting_ip_config_get_dhcp_send_hostname (s_ip6),
|
||||
nm_setting_ip_config_get_dhcp_hostname (s_ip6),
|
||||
get_dhcp_hostname_flags (self, AF_INET6),
|
||||
duid,
|
||||
enforce_duid,
|
||||
iaid,
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMDhcpClient,
|
|||
PROP_IAID,
|
||||
PROP_IAID_EXPLICIT,
|
||||
PROP_HOSTNAME,
|
||||
PROP_HOSTNAME_FLAGS,
|
||||
);
|
||||
|
||||
typedef struct _NMDhcpClientPrivate {
|
||||
|
|
@ -69,6 +70,7 @@ typedef struct _NMDhcpClientPrivate {
|
|||
guint32 timeout;
|
||||
guint32 iaid;
|
||||
NMDhcpState state;
|
||||
NMDhcpHostnameFlags hostname_flags;
|
||||
bool info_only:1;
|
||||
bool use_fqdn:1;
|
||||
bool iaid_explicit:1;
|
||||
|
|
@ -286,6 +288,14 @@ nm_dhcp_client_get_hostname (NMDhcpClient *self)
|
|||
return NM_DHCP_CLIENT_GET_PRIVATE (self)->hostname;
|
||||
}
|
||||
|
||||
NMDhcpHostnameFlags
|
||||
nm_dhcp_client_get_hostname_flags (NMDhcpClient *self)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_DHCP_CLIENT (self), NM_DHCP_HOSTNAME_FLAG_NONE);
|
||||
|
||||
return NM_DHCP_CLIENT_GET_PRIVATE (self)->hostname_flags;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_dhcp_client_get_info_only (NMDhcpClient *self)
|
||||
{
|
||||
|
|
@ -1035,6 +1045,10 @@ set_property (GObject *object, guint prop_id,
|
|||
/* construct-only */
|
||||
priv->hostname = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_HOSTNAME_FLAGS:
|
||||
/* construct-only */
|
||||
priv->hostname_flags = g_value_get_uint (value);
|
||||
break;
|
||||
case PROP_ROUTE_TABLE:
|
||||
priv->route_table = g_value_get_uint (value);
|
||||
break;
|
||||
|
|
@ -1168,6 +1182,12 @@ nm_dhcp_client_class_init (NMDhcpClientClass *client_class)
|
|||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
obj_properties[PROP_HOSTNAME_FLAGS] =
|
||||
g_param_spec_uint (NM_DHCP_CLIENT_HOSTNAME_FLAGS, "", "",
|
||||
0, G_MAXUINT32, NM_DHCP_HOSTNAME_FLAG_NONE,
|
||||
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
obj_properties[PROP_ROUTE_TABLE] =
|
||||
g_param_spec_uint (NM_DHCP_CLIENT_ROUTE_TABLE, "", "",
|
||||
0, G_MAXUINT32, RT_TABLE_MAIN,
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@
|
|||
#define NM_DHCP_CLIENT_UUID "uuid"
|
||||
#define NM_DHCP_CLIENT_IAID "iaid"
|
||||
#define NM_DHCP_CLIENT_IAID_EXPLICIT "iaid-explicit"
|
||||
#define NM_DHCP_CLIENT_HOSTNAME_FLAGS "hostname-flags"
|
||||
|
||||
#define NM_DHCP_CLIENT_SIGNAL_STATE_CHANGED "state-changed"
|
||||
#define NM_DHCP_CLIENT_SIGNAL_PREFIX_DELEGATED "prefix-delegated"
|
||||
|
|
@ -140,6 +141,8 @@ GBytes *nm_dhcp_client_get_client_id (NMDhcpClient *self);
|
|||
|
||||
const char *nm_dhcp_client_get_hostname (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);
|
||||
|
|
|
|||
|
|
@ -93,21 +93,11 @@ grab_request_options (GPtrArray *store, const char* line)
|
|||
}
|
||||
|
||||
static void
|
||||
add_hostname4 (GString *str, const char *hostname, gboolean use_fqdn)
|
||||
{
|
||||
if (hostname) {
|
||||
if (use_fqdn) {
|
||||
g_string_append_printf (str, FQDN_FORMAT "\n", hostname);
|
||||
g_string_append (str,
|
||||
"send fqdn.encoded on;\n"
|
||||
"send fqdn.server-update on;\n");
|
||||
} else
|
||||
g_string_append_printf (str, HOSTNAME4_FORMAT "\n", hostname);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
add_ip4_config (GString *str, GBytes *client_id, const char *hostname, gboolean use_fqdn)
|
||||
add_ip4_config (GString *str,
|
||||
GBytes *client_id,
|
||||
const char *hostname,
|
||||
gboolean use_fqdn,
|
||||
NMDhcpHostnameFlags hostname_flags)
|
||||
{
|
||||
if (client_id) {
|
||||
const char *p;
|
||||
|
|
@ -143,7 +133,27 @@ add_ip4_config (GString *str, GBytes *client_id, const char *hostname, gboolean
|
|||
g_string_append (str, "; # added by NetworkManager\n");
|
||||
}
|
||||
|
||||
add_hostname4 (str, hostname, use_fqdn);
|
||||
if (hostname) {
|
||||
if (use_fqdn) {
|
||||
g_string_append_printf (str, FQDN_FORMAT "\n", hostname);
|
||||
|
||||
g_string_append_printf (str, FQDN_TAG_PREFIX "encoded %s;\n",
|
||||
(hostname_flags & NM_DHCP_HOSTNAME_FLAG_FQDN_ENCODED)
|
||||
? "on"
|
||||
: "off");
|
||||
|
||||
g_string_append_printf (str, FQDN_TAG_PREFIX "server-update %s;\n",
|
||||
(hostname_flags & NM_DHCP_HOSTNAME_FLAG_FQDN_SERV_UPDATE)
|
||||
? "on"
|
||||
: "off");
|
||||
|
||||
g_string_append_printf (str, FQDN_TAG_PREFIX "no-client-update %s;\n",
|
||||
(hostname_flags & NM_DHCP_HOSTNAME_FLAG_FQDN_NO_UPDATE)
|
||||
? "on"
|
||||
: "off");
|
||||
} else
|
||||
g_string_append_printf (str, HOSTNAME4_FORMAT "\n", hostname);
|
||||
}
|
||||
|
||||
g_string_append_c (str, '\n');
|
||||
|
||||
|
|
@ -159,12 +169,16 @@ add_ip4_config (GString *str, GBytes *client_id, const char *hostname, gboolean
|
|||
}
|
||||
|
||||
static void
|
||||
add_hostname6 (GString *str, const char *hostname)
|
||||
add_hostname6 (GString *str,
|
||||
const char *hostname,
|
||||
NMDhcpHostnameFlags hostname_flags)
|
||||
{
|
||||
if (hostname) {
|
||||
g_string_append_printf (str, FQDN_FORMAT "\n", hostname);
|
||||
g_string_append (str,
|
||||
"send fqdn.server-update on;\n");
|
||||
if (hostname_flags & NM_DHCP_HOSTNAME_FLAG_FQDN_SERV_UPDATE)
|
||||
g_string_append (str, FQDN_TAG_PREFIX "server-update on;\n");
|
||||
if (hostname_flags & NM_DHCP_HOSTNAME_FLAG_FQDN_NO_UPDATE)
|
||||
g_string_append (str, FQDN_TAG_PREFIX "no-client-update on;\n");
|
||||
g_string_append_c (str, '\n');
|
||||
}
|
||||
}
|
||||
|
|
@ -271,6 +285,7 @@ nm_dhcp_dhclient_create_config (const char *interface,
|
|||
const char *hostname,
|
||||
guint32 timeout,
|
||||
gboolean use_fqdn,
|
||||
NMDhcpHostnameFlags hostname_flags,
|
||||
const char *orig_path,
|
||||
const char *orig_contents,
|
||||
GBytes **out_new_client_id)
|
||||
|
|
@ -437,7 +452,7 @@ nm_dhcp_dhclient_create_config (const char *interface,
|
|||
}
|
||||
|
||||
if (addr_family == AF_INET) {
|
||||
add_ip4_config (new_contents, client_id, hostname, use_fqdn);
|
||||
add_ip4_config (new_contents, client_id, hostname, use_fqdn, hostname_flags);
|
||||
add_request (reqs, "rfc3442-classless-static-routes");
|
||||
add_request (reqs, "ms-classless-static-routes");
|
||||
add_request (reqs, "static-routes");
|
||||
|
|
@ -445,7 +460,7 @@ nm_dhcp_dhclient_create_config (const char *interface,
|
|||
add_request (reqs, "ntp-servers");
|
||||
add_request (reqs, "root-path");
|
||||
} else {
|
||||
add_hostname6 (new_contents, hostname);
|
||||
add_hostname6 (new_contents, hostname, hostname_flags);
|
||||
add_request (reqs, "dhcp6.name-servers");
|
||||
add_request (reqs, "dhcp6.domain-search");
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ char *nm_dhcp_dhclient_create_config (const char *interface,
|
|||
const char *hostname,
|
||||
guint32 timeout,
|
||||
gboolean use_fqdn,
|
||||
NMDhcpHostnameFlags hostname_flags,
|
||||
const char *orig_path,
|
||||
const char *orig_contents,
|
||||
GBytes **out_new_client_id);
|
||||
|
|
|
|||
|
|
@ -146,6 +146,7 @@ merge_dhclient_config (NMDhcpDhclient *self,
|
|||
const char *hostname,
|
||||
guint32 timeout,
|
||||
gboolean use_fqdn,
|
||||
NMDhcpHostnameFlags hostname_flags,
|
||||
const char *orig_path,
|
||||
GBytes **out_new_client_id,
|
||||
GError **error)
|
||||
|
|
@ -174,6 +175,7 @@ merge_dhclient_config (NMDhcpDhclient *self,
|
|||
hostname,
|
||||
timeout,
|
||||
use_fqdn,
|
||||
hostname_flags,
|
||||
orig_path,
|
||||
orig,
|
||||
out_new_client_id);
|
||||
|
|
@ -265,6 +267,7 @@ create_dhclient_config (NMDhcpDhclient *self,
|
|||
const char *hostname,
|
||||
guint32 timeout,
|
||||
gboolean use_fqdn,
|
||||
NMDhcpHostnameFlags hostname_flags,
|
||||
GBytes **out_new_client_id)
|
||||
{
|
||||
gs_free char *orig = NULL;
|
||||
|
|
@ -292,6 +295,7 @@ create_dhclient_config (NMDhcpDhclient *self,
|
|||
hostname,
|
||||
timeout,
|
||||
use_fqdn,
|
||||
hostname_flags,
|
||||
orig,
|
||||
out_new_client_id,
|
||||
&error)) {
|
||||
|
|
@ -491,6 +495,7 @@ ip4_start (NMDhcpClient *client,
|
|||
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),
|
||||
&new_client_id);
|
||||
if (!priv->conf_file) {
|
||||
nm_utils_error_set_literal (error,
|
||||
|
|
@ -534,6 +539,7 @@ ip6_start (NMDhcpClient *client,
|
|||
nm_dhcp_client_get_hostname (client),
|
||||
nm_dhcp_client_get_timeout (client),
|
||||
TRUE,
|
||||
nm_dhcp_client_get_hostname_flags (client),
|
||||
NULL);
|
||||
if (!priv->conf_file) {
|
||||
nm_utils_error_set_literal (error,
|
||||
|
|
|
|||
|
|
@ -219,6 +219,7 @@ client_start (NMDhcpManager *self,
|
|||
const char *dhcp_anycast_addr,
|
||||
const char *hostname,
|
||||
gboolean hostname_use_fqdn,
|
||||
NMDhcpHostnameFlags hostname_flags,
|
||||
gboolean info_only,
|
||||
NMSettingIP6ConfigPrivacy privacy,
|
||||
const char *last_ip4_address,
|
||||
|
|
@ -305,6 +306,7 @@ client_start (NMDhcpManager *self,
|
|||
NM_DHCP_CLIENT_ROUTE_TABLE, (guint) route_table,
|
||||
NM_DHCP_CLIENT_ROUTE_METRIC, (guint) route_metric,
|
||||
NM_DHCP_CLIENT_TIMEOUT, (guint) timeout,
|
||||
NM_DHCP_CLIENT_HOSTNAME_FLAGS, (guint) hostname_flags,
|
||||
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)
|
||||
|
|
@ -379,6 +381,7 @@ nm_dhcp_manager_start_ip4 (NMDhcpManager *self,
|
|||
gboolean send_hostname,
|
||||
const char *dhcp_hostname,
|
||||
const char *dhcp_fqdn,
|
||||
NMDhcpHostnameFlags hostname_flags,
|
||||
GBytes *dhcp_client_id,
|
||||
guint32 timeout,
|
||||
const char *dhcp_anycast_addr,
|
||||
|
|
@ -436,6 +439,7 @@ nm_dhcp_manager_start_ip4 (NMDhcpManager *self,
|
|||
dhcp_anycast_addr,
|
||||
hostname,
|
||||
use_fqdn,
|
||||
hostname_flags,
|
||||
FALSE,
|
||||
0,
|
||||
last_ip_address,
|
||||
|
|
@ -457,6 +461,7 @@ nm_dhcp_manager_start_ip6 (NMDhcpManager *self,
|
|||
guint32 route_metric,
|
||||
gboolean send_hostname,
|
||||
const char *dhcp_hostname,
|
||||
NMDhcpHostnameFlags hostname_flags,
|
||||
GBytes *duid,
|
||||
gboolean enforce_duid,
|
||||
guint32 iaid,
|
||||
|
|
@ -497,6 +502,7 @@ nm_dhcp_manager_start_ip6 (NMDhcpManager *self,
|
|||
dhcp_anycast_addr,
|
||||
hostname,
|
||||
TRUE,
|
||||
hostname_flags,
|
||||
info_only,
|
||||
privacy,
|
||||
NULL,
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ NMDhcpClient * nm_dhcp_manager_start_ip4 (NMDhcpManager *manager,
|
|||
gboolean send_hostname,
|
||||
const char *dhcp_hostname,
|
||||
const char *dhcp_fqdn,
|
||||
NMDhcpHostnameFlags hostname_flags,
|
||||
GBytes *dhcp_client_id,
|
||||
guint32 timeout,
|
||||
const char *dhcp_anycast_addr,
|
||||
|
|
@ -60,6 +61,7 @@ NMDhcpClient * nm_dhcp_manager_start_ip6 (NMDhcpManager *manager,
|
|||
guint32 route_metric,
|
||||
gboolean send_hostname,
|
||||
const char *dhcp_hostname,
|
||||
NMDhcpHostnameFlags hostname_flags,
|
||||
GBytes *duid,
|
||||
gboolean enforce_duid,
|
||||
guint32 iaid,
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ test_config (const char *orig,
|
|||
const char *hostname,
|
||||
guint32 timeout,
|
||||
gboolean use_fqdn,
|
||||
NMDhcpHostnameFlags hostname_flags,
|
||||
const char *dhcp_client_id,
|
||||
GBytes *expected_new_client_id,
|
||||
const char *iface,
|
||||
|
|
@ -50,6 +51,7 @@ test_config (const char *orig,
|
|||
hostname,
|
||||
timeout,
|
||||
use_fqdn,
|
||||
hostname_flags,
|
||||
"/path/to/dhclient.conf",
|
||||
orig,
|
||||
&new_client_id);
|
||||
|
|
@ -94,7 +96,11 @@ static const char *orig_missing_expected = \
|
|||
static void
|
||||
test_orig_missing (void)
|
||||
{
|
||||
test_config (NULL, orig_missing_expected, AF_INET, NULL, 0, FALSE, NULL, NULL, "eth0", NULL);
|
||||
test_config (NULL,
|
||||
orig_missing_expected,
|
||||
AF_INET, NULL, 0, FALSE,
|
||||
NM_DHCP_HOSTNAME_FLAG_NONE,
|
||||
NULL, NULL, "eth0", NULL);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
@ -125,6 +131,7 @@ test_override_client_id (void)
|
|||
{
|
||||
test_config (override_client_id_orig, override_client_id_expected,
|
||||
AF_INET, NULL, 0, FALSE,
|
||||
NM_DHCP_HOSTNAME_FLAG_NONE,
|
||||
"11:22:33:44:55:66",
|
||||
NULL,
|
||||
"eth0",
|
||||
|
|
@ -155,6 +162,7 @@ test_quote_client_id (void)
|
|||
{
|
||||
test_config (NULL, quote_client_id_expected,
|
||||
AF_INET, NULL, 0, FALSE,
|
||||
NM_DHCP_HOSTNAME_FLAG_NONE,
|
||||
"abcd",
|
||||
NULL,
|
||||
"eth0",
|
||||
|
|
@ -185,6 +193,7 @@ test_quote_client_id_2 (void)
|
|||
{
|
||||
test_config (NULL, quote_client_id_expected_2,
|
||||
AF_INET, NULL, 0, FALSE,
|
||||
NM_DHCP_HOSTNAME_FLAG_NONE,
|
||||
"a\\bc",
|
||||
NULL,
|
||||
"eth0",
|
||||
|
|
@ -215,6 +224,7 @@ test_hex_zero_client_id (void)
|
|||
{
|
||||
test_config (NULL, hex_zero_client_id_expected,
|
||||
AF_INET, NULL, 0, FALSE,
|
||||
NM_DHCP_HOSTNAME_FLAG_NONE,
|
||||
"00:11:22:33",
|
||||
NULL,
|
||||
"eth0",
|
||||
|
|
@ -245,6 +255,7 @@ test_ascii_client_id (void)
|
|||
{
|
||||
test_config (NULL, ascii_client_id_expected,
|
||||
AF_INET, NULL, 0, FALSE,
|
||||
NM_DHCP_HOSTNAME_FLAG_NONE,
|
||||
"qb:cd:ef:12:34:56",
|
||||
NULL,
|
||||
"eth0",
|
||||
|
|
@ -275,6 +286,7 @@ test_hex_single_client_id (void)
|
|||
{
|
||||
test_config (NULL, hex_single_client_id_expected,
|
||||
AF_INET, NULL, 0, FALSE,
|
||||
NM_DHCP_HOSTNAME_FLAG_NONE,
|
||||
"ab:cd:e:12:34:56",
|
||||
NULL,
|
||||
"eth0",
|
||||
|
|
@ -313,6 +325,7 @@ test_existing_hex_client_id (void)
|
|||
new_client_id = g_bytes_new (bytes, sizeof (bytes));
|
||||
test_config (existing_hex_client_id_orig, existing_hex_client_id_expected,
|
||||
AF_INET, NULL, 0, FALSE,
|
||||
NM_DHCP_HOSTNAME_FLAG_NONE,
|
||||
NULL,
|
||||
new_client_id,
|
||||
"eth0",
|
||||
|
|
@ -350,6 +363,7 @@ test_existing_escaped_client_id (void)
|
|||
new_client_id = g_bytes_new ("$test\xfe", 6);
|
||||
test_config (existing_escaped_client_id_orig, existing_escaped_client_id_expected,
|
||||
AF_INET, NULL, 0, FALSE,
|
||||
NM_DHCP_HOSTNAME_FLAG_NONE,
|
||||
NULL,
|
||||
new_client_id,
|
||||
"eth0",
|
||||
|
|
@ -391,6 +405,7 @@ test_existing_ascii_client_id (void)
|
|||
new_client_id = g_bytes_new (buf, sizeof (buf));
|
||||
test_config (existing_ascii_client_id_orig, existing_ascii_client_id_expected,
|
||||
AF_INET, NULL, 0, FALSE,
|
||||
NM_DHCP_HOSTNAME_FLAG_NONE,
|
||||
NULL,
|
||||
new_client_id,
|
||||
"eth0",
|
||||
|
|
@ -403,7 +418,8 @@ static const char *fqdn_expected = \
|
|||
"\n"
|
||||
"send fqdn.fqdn \"foo.bar.com\"; # added by NetworkManager\n"
|
||||
"send fqdn.encoded on;\n"
|
||||
"send fqdn.server-update on;\n"
|
||||
"send fqdn.server-update off;\n"
|
||||
"send fqdn.no-client-update on;\n"
|
||||
"\n"
|
||||
"option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;\n"
|
||||
"option ms-classless-static-routes code 249 = array of unsigned integer 8;\n"
|
||||
|
|
@ -421,7 +437,10 @@ test_fqdn (void)
|
|||
{
|
||||
test_config (NULL, fqdn_expected,
|
||||
AF_INET, "foo.bar.com", 0,
|
||||
TRUE, NULL,
|
||||
TRUE,
|
||||
NM_DHCP_HOSTNAME_FLAG_FQDN_ENCODED
|
||||
| NM_DHCP_HOSTNAME_FLAG_FQDN_NO_UPDATE,
|
||||
NULL,
|
||||
NULL,
|
||||
"eth0",
|
||||
NULL);
|
||||
|
|
@ -438,8 +457,9 @@ static const char *fqdn_options_override_expected = \
|
|||
"# Merged from /path/to/dhclient.conf\n"
|
||||
"\n"
|
||||
"send fqdn.fqdn \"example2.com\"; # added by NetworkManager\n"
|
||||
"send fqdn.encoded on;\n"
|
||||
"send fqdn.encoded off;\n"
|
||||
"send fqdn.server-update on;\n"
|
||||
"send fqdn.no-client-update off;\n"
|
||||
"\n"
|
||||
"option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;\n"
|
||||
"option ms-classless-static-routes code 249 = array of unsigned integer 8;\n"
|
||||
|
|
@ -462,6 +482,7 @@ test_fqdn_options_override (void)
|
|||
test_config (fqdn_options_override_orig,
|
||||
fqdn_options_override_expected,
|
||||
AF_INET, "example2.com", 0,
|
||||
NM_DHCP_HOSTNAME_FLAG_FQDN_SERV_UPDATE,
|
||||
TRUE, NULL,
|
||||
NULL,
|
||||
"eth0",
|
||||
|
|
@ -496,6 +517,7 @@ test_override_hostname (void)
|
|||
{
|
||||
test_config (override_hostname_orig, override_hostname_expected,
|
||||
AF_INET, "blahblah", 0, FALSE,
|
||||
NM_DHCP_HOSTNAME_FLAG_NONE,
|
||||
NULL,
|
||||
NULL,
|
||||
"eth0",
|
||||
|
|
@ -524,6 +546,7 @@ test_override_hostname6 (void)
|
|||
{
|
||||
test_config (override_hostname6_orig, override_hostname6_expected,
|
||||
AF_INET6, "blahblah.local", 0, TRUE,
|
||||
NM_DHCP_HOSTNAME_FLAG_FQDN_SERV_UPDATE,
|
||||
NULL,
|
||||
NULL,
|
||||
"eth0",
|
||||
|
|
@ -536,7 +559,7 @@ static const char *nonfqdn_hostname6_expected = \
|
|||
"# Created by NetworkManager\n"
|
||||
"\n"
|
||||
"send fqdn.fqdn \"blahblah\"; # added by NetworkManager\n"
|
||||
"send fqdn.server-update on;\n"
|
||||
"send fqdn.no-client-update on;\n"
|
||||
"\n"
|
||||
"also request dhcp6.name-servers;\n"
|
||||
"also request dhcp6.domain-search;\n"
|
||||
|
|
@ -549,6 +572,7 @@ test_nonfqdn_hostname6 (void)
|
|||
/* Non-FQDN hostname can now be used with dhclient */
|
||||
test_config (NULL, nonfqdn_hostname6_expected,
|
||||
AF_INET6, "blahblah", 0, TRUE,
|
||||
NM_DHCP_HOSTNAME_FLAG_FQDN_NO_UPDATE,
|
||||
NULL,
|
||||
NULL,
|
||||
"eth0",
|
||||
|
|
@ -585,6 +609,7 @@ test_existing_alsoreq (void)
|
|||
{
|
||||
test_config (existing_alsoreq_orig, existing_alsoreq_expected,
|
||||
AF_INET, NULL, 0, FALSE,
|
||||
NM_DHCP_HOSTNAME_FLAG_NONE,
|
||||
NULL,
|
||||
NULL,
|
||||
"eth0",
|
||||
|
|
@ -624,6 +649,7 @@ test_existing_req (void)
|
|||
{
|
||||
test_config (existing_req_orig, existing_req_expected,
|
||||
AF_INET, NULL, 0, FALSE,
|
||||
NM_DHCP_HOSTNAME_FLAG_NONE,
|
||||
NULL,
|
||||
NULL,
|
||||
"eth0",
|
||||
|
|
@ -664,6 +690,7 @@ test_existing_multiline_alsoreq (void)
|
|||
{
|
||||
test_config (existing_multiline_alsoreq_orig, existing_multiline_alsoreq_expected,
|
||||
AF_INET, NULL, 0, FALSE,
|
||||
NM_DHCP_HOSTNAME_FLAG_NONE,
|
||||
NULL,
|
||||
NULL,
|
||||
"eth0",
|
||||
|
|
@ -903,6 +930,7 @@ test_interface1 (void)
|
|||
{
|
||||
test_config (interface1_orig, interface1_expected,
|
||||
AF_INET, NULL, 0, FALSE,
|
||||
NM_DHCP_HOSTNAME_FLAG_NONE,
|
||||
NULL,
|
||||
NULL,
|
||||
"eth0",
|
||||
|
|
@ -949,6 +977,7 @@ test_interface2 (void)
|
|||
{
|
||||
test_config (interface2_orig, interface2_expected,
|
||||
AF_INET, NULL, 0, FALSE,
|
||||
NM_DHCP_HOSTNAME_FLAG_NONE,
|
||||
NULL,
|
||||
NULL,
|
||||
"eth1",
|
||||
|
|
@ -1060,6 +1089,7 @@ test_structured (void)
|
|||
new_client_id = g_bytes_new (bytes, sizeof (bytes) - 1);
|
||||
test_config (orig, expected,
|
||||
AF_INET, NULL, 0, FALSE,
|
||||
NM_DHCP_HOSTNAME_FLAG_NONE,
|
||||
NULL,
|
||||
new_client_id,
|
||||
"eth0",
|
||||
|
|
@ -1115,6 +1145,7 @@ test_config_req_intf (void)
|
|||
|
||||
test_config (orig, expected,
|
||||
AF_INET, NULL, 0, FALSE,
|
||||
NM_DHCP_HOSTNAME_FLAG_NONE,
|
||||
NULL,
|
||||
NULL,
|
||||
"eth0",
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
#include "ndisc/nm-ndisc.h"
|
||||
#include "ndisc/nm-lndp-ndisc.h"
|
||||
#include "nm-utils.h"
|
||||
#include "nm-core-internal.h"
|
||||
#include "nm-setting-ip6-config.h"
|
||||
#include "systemd/nm-sd.h"
|
||||
|
||||
|
|
@ -520,6 +521,7 @@ main (int argc, char *argv[])
|
|||
!!global_opt.dhcp4_hostname,
|
||||
global_opt.dhcp4_hostname,
|
||||
global_opt.dhcp4_fqdn,
|
||||
NM_DHCP_HOSTNAME_FLAGS_FQDN_DEFAULT_IP4,
|
||||
client_id,
|
||||
NM_DHCP_TIMEOUT_DEFAULT,
|
||||
NULL,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue