Commit 68f12b4e authored by Dan Winship's avatar Dan Winship

settings: make connections always have s_ip4 and s_ip6

Make sure that all connections returned from NMSettings or created via
AddAndActivateConnection have an NMSettingIP4Config and an
NMSettingIP6Config, with non-NULL methods, and get rid of
now-unnecessary checks for those.

Also move the slaves-can't-have-IP-config checks into the
platform-independent code as well. This also gets rid of spurious
"ignoring IP4/IP6 configuration" warnings in ifcfg-rh when reading a
slave ifcfg file.

Partly based on a patch from Pavel.

https://bugzilla.gnome.org/show_bug.cgi?id=708875
parent 5bcdfd39
......@@ -298,10 +298,10 @@ nm_utils_get_shared_wifi_permission (NMConnection *connection)
const char *method = NULL;
s_ip4 = nm_connection_get_setting_ip4_config (connection);
if (s_ip4)
method = nm_setting_ip4_config_get_method (s_ip4);
method = nm_setting_ip4_config_get_method (s_ip4);
g_assert (method);
if (g_strcmp0 (method, NM_SETTING_IP4_CONFIG_METHOD_SHARED) != 0)
if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_SHARED) != 0)
return NULL; /* Not shared */
s_wifi = nm_connection_get_setting_wireless (connection);
......@@ -576,6 +576,72 @@ get_new_connection_name (const GSList *existing,
return cname;
}
void
nm_utils_normalize_connection (NMConnection *connection,
gboolean default_enable_ipv6)
{
NMSettingConnection *s_con = nm_connection_get_setting_connection (connection);
const char *default_ip4_method = NM_SETTING_IP4_CONFIG_METHOD_AUTO;
const char *default_ip6_method =
default_enable_ipv6 ? NM_SETTING_IP6_CONFIG_METHOD_AUTO : NM_SETTING_IP6_CONFIG_METHOD_IGNORE;
NMSettingIP4Config *s_ip4;
NMSettingIP6Config *s_ip6;
NMSetting *setting;
const char *method;
s_ip4 = nm_connection_get_setting_ip4_config (connection);
s_ip6 = nm_connection_get_setting_ip6_config (connection);
/* Slave connections don't have IP configuration. */
if (nm_setting_connection_get_master (s_con)) {
default_ip4_method = NM_SETTING_IP4_CONFIG_METHOD_DISABLED;
default_ip6_method = NM_SETTING_IP6_CONFIG_METHOD_IGNORE;
if (s_ip4) {
method = nm_setting_ip4_config_get_method (s_ip4);
if (g_strcmp0 (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED) != 0) {
nm_log_warn (LOGD_SETTINGS, "ignoring IP4 config on slave '%s'",
nm_connection_get_id (connection));
nm_connection_remove_setting (connection, NM_TYPE_SETTING_IP4_CONFIG);
s_ip4 = NULL;
}
}
if (s_ip6) {
method = nm_setting_ip6_config_get_method (s_ip6);
if (g_strcmp0 (method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE) != 0) {
nm_log_warn (LOGD_SETTINGS, "ignoring IP6 config on slave '%s'",
nm_connection_get_id (connection));
nm_connection_remove_setting (connection, NM_TYPE_SETTING_IP6_CONFIG);
s_ip6 = NULL;
}
}
}
/* Ensure all connections have IP4 and IP6 settings objects. If no
* IP6 setting was specified, then assume that means IP6 config is allowed
* to fail. But if no IP4 setting was specified, assume the caller was just
* being lazy.
*/
if (!s_ip4) {
setting = nm_setting_ip4_config_new ();
nm_connection_add_setting (connection, setting);
g_object_set (setting,
NM_SETTING_IP4_CONFIG_METHOD, default_ip4_method,
NULL);
}
if (!s_ip6) {
setting = nm_setting_ip6_config_new ();
nm_connection_add_setting (connection, setting);
g_object_set (setting,
NM_SETTING_IP6_CONFIG_METHOD, default_ip6_method,
NM_SETTING_IP6_CONFIG_MAY_FAIL, TRUE,
NULL);
}
}
void
nm_utils_complete_generic (NMConnection *connection,
const char *ctype,
......@@ -585,9 +651,6 @@ nm_utils_complete_generic (NMConnection *connection,
gboolean default_enable_ipv6)
{
NMSettingConnection *s_con;
NMSettingIP4Config *s_ip4;
NMSettingIP6Config *s_ip6;
const char *method;
char *id, *uuid;
s_con = nm_connection_get_setting_connection (connection);
......@@ -610,31 +673,8 @@ nm_utils_complete_generic (NMConnection *connection,
g_free (id);
}
/* Add an 'auto' IPv4 connection if present */
s_ip4 = nm_connection_get_setting_ip4_config (connection);
if (!s_ip4) {
s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new ();
nm_connection_add_setting (connection, NM_SETTING (s_ip4));
}
method = nm_setting_ip4_config_get_method (s_ip4);
if (!method) {
g_object_set (G_OBJECT (s_ip4),
NM_SETTING_IP4_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO,
NULL);
}
/* Add an 'auto' IPv6 setting if allowed and not preset */
s_ip6 = nm_connection_get_setting_ip6_config (connection);
if (!s_ip6 && default_enable_ipv6) {
s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new ();
nm_connection_add_setting (connection, NM_SETTING (s_ip6));
}
if (s_ip6 && !nm_setting_ip6_config_get_method (s_ip6)) {
g_object_set (G_OBJECT (s_ip6),
NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO,
NM_SETTING_IP6_CONFIG_MAY_FAIL, TRUE,
NULL);
}
/* Normalize */
nm_utils_normalize_connection (connection, default_enable_ipv6);
}
char *
......
......@@ -82,6 +82,9 @@ gboolean nm_utils_get_proc_sys_net_value_with_bounds (const char *path,
gint32 valid_min,
gint32 valid_max);
void nm_utils_normalize_connection (NMConnection *connection,
gboolean default_enable_ipv6);
void nm_utils_complete_generic (NMConnection *connection,
const char *ctype,
const GSList *existing,
......
......@@ -1316,11 +1316,9 @@ can_auto_connect (NMDevice *dev,
/* Use the connection if it's a shared connection */
s_ip4 = nm_connection_get_setting_ip4_config (connection);
if (s_ip4) {
method = nm_setting_ip4_config_get_method (s_ip4);
if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_SHARED))
return TRUE;
}
method = nm_setting_ip4_config_get_method (s_ip4);
if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_SHARED))
return TRUE;
for (ap_iter = priv->ap_list; ap_iter; ap_iter = g_slist_next (ap_iter)) {
NMAccessPoint *ap = NM_AP (ap_iter->data);
......@@ -1500,10 +1498,8 @@ scanning_allowed (NMDeviceWifi *self)
/* Don't scan when a shared connection is active; it makes drivers mad */
connection = nm_act_request_get_connection (req);
s_ip4 = nm_connection_get_setting_ip4_config (connection);
if (s_ip4)
ip4_method = nm_setting_ip4_config_get_method (s_ip4);
if (s_ip4 && !strcmp (ip4_method, NM_SETTING_IP4_CONFIG_METHOD_SHARED))
ip4_method = nm_setting_ip4_config_get_method (s_ip4);
if (!strcmp (ip4_method, NM_SETTING_IP4_CONFIG_METHOD_SHARED))
return FALSE;
/* Don't scan when the connection is locked to a specifc AP, since
......@@ -3140,8 +3136,7 @@ act_stage4_ip4_config_timeout (NMDevice *dev, NMDeviceStateReason *reason)
g_assert (connection);
s_ip4 = nm_connection_get_setting_ip4_config (connection);
if (s_ip4)
may_fail = nm_setting_ip4_config_get_may_fail (s_ip4);
may_fail = nm_setting_ip4_config_get_may_fail (s_ip4);
ret = handle_ip_config_timeout (NM_DEVICE_WIFI (dev), connection, may_fail, &chain_up, reason);
if (chain_up)
......@@ -3162,8 +3157,7 @@ act_stage4_ip6_config_timeout (NMDevice *dev, NMDeviceStateReason *reason)
g_assert (connection);
s_ip6 = nm_connection_get_setting_ip6_config (connection);
if (s_ip6)
may_fail = nm_setting_ip6_config_get_may_fail (s_ip6);
may_fail = nm_setting_ip6_config_get_may_fail (s_ip6);
ret = handle_ip_config_timeout (NM_DEVICE_WIFI (dev), connection, may_fail, &chain_up, reason);
if (chain_up)
......
......@@ -1012,25 +1012,21 @@ nm_device_release_one_slave (NMDevice *dev, NMDevice *slave, gboolean failed)
static gboolean
connection_is_static (NMConnection *connection)
{
NMSettingIP4Config *ip4;
NMSettingIP6Config *ip6;
NMSettingIP4Config *s_ip4;
NMSettingIP6Config *s_ip6;
const char *method;
ip4 = nm_connection_get_setting_ip4_config (connection);
if (ip4) {
method = nm_setting_ip4_config_get_method (ip4);
if ( g_strcmp0 (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL) != 0
&& g_strcmp0 (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED) != 0)
s_ip4 = nm_connection_get_setting_ip4_config (connection);
method = nm_setting_ip4_config_get_method (s_ip4);
if ( strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL) != 0
&& strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED) != 0)
return FALSE;
}
ip6 = nm_connection_get_setting_ip6_config (connection);
if (ip6) {
method = nm_setting_ip6_config_get_method (ip6);
if ( g_strcmp0 (method, NM_SETTING_IP6_CONFIG_METHOD_MANUAL) != 0
&& g_strcmp0 (method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE) != 0)
return FALSE;
}
s_ip6 = nm_connection_get_setting_ip6_config (connection);
method = nm_setting_ip6_config_get_method (s_ip6);
if ( strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_MANUAL) != 0
&& strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE) != 0)
return FALSE;
return TRUE;
}
......@@ -1931,11 +1927,11 @@ nm_device_ip_config_should_fail (NMDevice *self, gboolean ip6)
/* Fail the connection if the failed IP method is required to complete */
if (ip6) {
s_ip6 = nm_connection_get_setting_ip6_config (connection);
if (s_ip6 && !nm_setting_ip6_config_get_may_fail (s_ip6))
if (!nm_setting_ip6_config_get_may_fail (s_ip6))
return TRUE;
} else {
s_ip4 = nm_connection_get_setting_ip4_config (connection);
if (s_ip4 && !nm_setting_ip4_config_get_may_fail (s_ip4))
if (!nm_setting_ip4_config_get_may_fail (s_ip4))
return TRUE;
}
......@@ -2188,10 +2184,8 @@ nm_device_handle_autoip4_event (NMDevice *self,
/* Ignore if the connection isn't an AutoIP connection */
s_ip4 = nm_connection_get_setting_ip4_config (connection);
if (s_ip4)
method = nm_setting_ip4_config_get_method (s_ip4);
if (g_strcmp0 (method, NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL) != 0)
method = nm_setting_ip4_config_get_method (s_ip4);
if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL) != 0)
return;
iface = nm_device_get_iface (self);
......@@ -2705,10 +2699,8 @@ ip4_requires_slaves (NMConnection *connection)
const char *method = NM_SETTING_IP4_CONFIG_METHOD_AUTO;
s_ip4 = nm_connection_get_setting_ip4_config (connection);
if (s_ip4)
method = nm_setting_ip4_config_get_method (s_ip4);
return g_strcmp0 (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO) == 0;
method = nm_setting_ip4_config_get_method (s_ip4);
return strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO) == 0;
}
static NMActStageReturn
......@@ -2729,19 +2721,10 @@ act_stage3_ip4_config_start (NMDevice *self,
connection = nm_device_get_connection (self);
g_assert (connection);
/* If we did not receive IP4 configuration information, default to DHCP.
* Slaves, on the other hand, never have any IP configuration themselves,
* since the master handles all of that.
*/
s_ip4 = nm_connection_get_setting_ip4_config (connection);
if (priv->master) /* eg, device is a slave */
method = NM_SETTING_IP4_CONFIG_METHOD_DISABLED;
else if (s_ip4)
method = nm_setting_ip4_config_get_method (s_ip4);
else
method = NM_SETTING_IP4_CONFIG_METHOD_AUTO;
method = nm_setting_ip4_config_get_method (s_ip4);
if ( g_strcmp0 (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL) != 0
if ( strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL) != 0
&& nm_device_is_master (self)
&& nm_device_is_unavailable_because_of_carrier (self)) {
nm_log_info (LOGD_IP4 | LOGD_DEVICE,
......@@ -3249,16 +3232,15 @@ ip6_requires_slaves (NMConnection *connection)
const char *method = NM_SETTING_IP6_CONFIG_METHOD_AUTO;
s_ip6 = nm_connection_get_setting_ip6_config (connection);
if (s_ip6)
method = nm_setting_ip6_config_get_method (s_ip6);
method = nm_setting_ip6_config_get_method (s_ip6);
/* SLAAC, DHCP, and Link-Local depend on connectivity (and thus slaves)
* to complete addressing. SLAAC and DHCP obviously need a peer to
* provide a prefix, while Link-Local must perform DAD on the local link.
*/
return g_strcmp0 (method, NM_SETTING_IP6_CONFIG_METHOD_AUTO) == 0
|| g_strcmp0 (method, NM_SETTING_IP6_CONFIG_METHOD_DHCP) == 0
|| g_strcmp0 (method, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL) == 0;
return strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_AUTO) == 0
|| strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_DHCP) == 0
|| strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL) == 0;
}
static NMActStageReturn
......@@ -3285,19 +3267,10 @@ act_stage3_ip6_config_start (NMDevice *self,
connection = nm_device_get_connection (self);
g_assert (connection);
/* If we did not receive IP6 configuration information, default to AUTO.
* Slaves, on the other hand, never have any IP configuration themselves,
* since the master handles all of that.
*/
s_ip6 = nm_connection_get_setting_ip6_config (connection);
if (priv->master) /* eg, device is a slave */
method = NM_SETTING_IP6_CONFIG_METHOD_IGNORE;
else if (s_ip6)
method = nm_setting_ip6_config_get_method (s_ip6);
else
method = NM_SETTING_IP6_CONFIG_METHOD_AUTO;
method = nm_setting_ip6_config_get_method (s_ip6);
if ( g_strcmp0 (method, NM_SETTING_IP6_CONFIG_METHOD_MANUAL) != 0
if ( strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_MANUAL) != 0
&& nm_device_is_master (self)
&& nm_device_is_unavailable_because_of_carrier (self)) {
nm_log_info (LOGD_IP6 | LOGD_DEVICE,
......@@ -3370,7 +3343,7 @@ act_stage3_ip6_config_start (NMDevice *self,
conf_use_tempaddr = ip6_use_tempaddr ();
if (conf_use_tempaddr >= 0)
ip6_privacy = conf_use_tempaddr;
else if (s_ip6)
else
ip6_privacy = nm_setting_ip6_config_get_ip6_privacy (s_ip6);
ip6_privacy = CLAMP (ip6_privacy, NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN, NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR);
......@@ -3917,10 +3890,9 @@ nm_device_activate_ip4_config_commit (gpointer user_data)
/* Start IPv4 sharing if we need it */
s_ip4 = nm_connection_get_setting_ip4_config (connection);
if (s_ip4)
method = nm_setting_ip4_config_get_method (s_ip4);
method = nm_setting_ip4_config_get_method (s_ip4);
if (g_strcmp0 (method, NM_SETTING_IP4_CONFIG_METHOD_SHARED) == 0) {
if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_SHARED) == 0) {
if (!start_sharing (self, priv->ip4_config)) {
nm_log_warn (LOGD_SHARING, "Activation (%s) Stage 5 of 5 (IPv4 Commit) start sharing failed.", iface);
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_SHARED_START_FAILED);
......@@ -5041,10 +5013,8 @@ dispose (GObject *object)
* to check that.
*/
s_ip4 = nm_connection_get_setting_ip4_config (connection);
if (s_ip4)
method = nm_setting_ip4_config_get_method (s_ip4);
if ( !method
|| !strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO)
method = nm_setting_ip4_config_get_method (s_ip4);
if ( !strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO)
|| !strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL)
|| !strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED))
deconfigure = FALSE;
......@@ -6444,7 +6414,7 @@ ip4_match_config (NMDevice *self, NMConnection *connection)
FALSE);
g_object_unref (dhcp_mgr);
method = s_ip4 ? nm_setting_ip4_config_get_method (s_ip4) : NM_SETTING_IP4_CONFIG_METHOD_AUTO;
method = nm_setting_ip4_config_get_method (s_ip4);
if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO)) {
gboolean found = FALSE;
......@@ -6485,16 +6455,14 @@ ip4_match_config (NMDevice *self, NMConnection *connection)
/* Everything below for static addressing */
/* Find all IP4 addresses of this connection on the device */
if (s_ip4) {
num = nm_setting_ip4_config_get_num_addresses (s_ip4);
for (i = 0; i < num; i++) {
NMIP4Address *addr = nm_setting_ip4_config_get_address (s_ip4, i);
if (!nm_platform_ip4_address_exists (nm_device_get_ip_ifindex (self),
nm_ip4_address_get_address (addr),
nm_ip4_address_get_prefix (addr)))
return FALSE;
}
num = nm_setting_ip4_config_get_num_addresses (s_ip4);
for (i = 0; i < num; i++) {
NMIP4Address *addr = nm_setting_ip4_config_get_address (s_ip4, i);
if (!nm_platform_ip4_address_exists (nm_device_get_ip_ifindex (self),
nm_ip4_address_get_address (addr),
nm_ip4_address_get_prefix (addr)))
return FALSE;
}
/* Success; all the connection's static IP addresses are assigned to the device */
......
......@@ -70,35 +70,33 @@ add_hostname (GString *str, const char *format, const char *hostname)
static void
add_ip4_config (GString *str, NMSettingIP4Config *s_ip4, const char *hostname)
{
if (s_ip4) {
const char *tmp;
tmp = nm_setting_ip4_config_get_dhcp_client_id (s_ip4);
if (tmp) {
gboolean is_octets = TRUE;
int i = 0;
while (tmp[i]) {
if ((i % 3) != 2 && !g_ascii_isxdigit (tmp[i])) {
is_octets = FALSE;
break;
}
if ((i % 3) == 2 && tmp[i] != ':') {
is_octets = FALSE;
break;
}
i++;
}
const char *tmp;
/* If the client ID is just hex digits and : then don't use quotes,
* because dhclient expects either a quoted ASCII string, or a byte
* array formated as hex octets separated by :
*/
if (is_octets)
g_string_append_printf (str, CLIENTID_FORMAT_OCTETS "\n", tmp);
else
g_string_append_printf (str, CLIENTID_FORMAT "\n", tmp);
tmp = nm_setting_ip4_config_get_dhcp_client_id (s_ip4);
if (tmp) {
gboolean is_octets = TRUE;
int i = 0;
while (tmp[i]) {
if ((i % 3) != 2 && !g_ascii_isxdigit (tmp[i])) {
is_octets = FALSE;
break;
}
if ((i % 3) == 2 && tmp[i] != ':') {
is_octets = FALSE;
break;
}
i++;
}
/* If the client ID is just hex digits and : then don't use quotes,
* because dhclient expects either a quoted ASCII string, or a byte
* array formated as hex octets separated by :
*/
if (is_octets)
g_string_append_printf (str, CLIENTID_FORMAT_OCTETS "\n", tmp);
else
g_string_append_printf (str, CLIENTID_FORMAT "\n", tmp);
}
add_hostname (str, HOSTNAME4_FORMAT "\n", hostname);
......@@ -159,8 +157,7 @@ nm_dhcp_dhclient_create_config (const char *interface,
/* Override config file "dhcp-client-id" and use one from the
* connection.
*/
if ( s_ip4
&& nm_setting_ip4_config_get_dhcp_client_id (s_ip4)
if ( nm_setting_ip4_config_get_dhcp_client_id (s_ip4)
&& !strncmp (p, CLIENTID_TAG, strlen (CLIENTID_TAG)))
continue;
......
......@@ -519,28 +519,21 @@ nm_dhcp_manager_start_ip4 (NMDHCPManager *self,
guint8 *dhcp_anycast_addr)
{
NMDHCPManagerPrivate *priv;
const char *hostname = NULL;
gboolean send_hostname = TRUE;
const char *hostname, *method;
gboolean send_hostname;
g_return_val_if_fail (self, NULL);
g_return_val_if_fail (NM_IS_DHCP_MANAGER (self), NULL);
priv = NM_DHCP_MANAGER_GET_PRIVATE (self);
if (s_ip4) {
const char *method = nm_setting_ip4_config_get_method (s_ip4);
if (method) {
/* Method must be 'auto' */
g_return_val_if_fail (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO) == 0, NULL);
}
send_hostname = nm_setting_ip4_config_get_dhcp_send_hostname (s_ip4);
if (send_hostname)
hostname = nm_setting_ip4_config_get_dhcp_hostname (s_ip4);
}
method = nm_setting_ip4_config_get_method (s_ip4);
g_return_val_if_fail (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO) == 0, NULL);
send_hostname = nm_setting_ip4_config_get_dhcp_send_hostname (s_ip4);
if (send_hostname) {
hostname = nm_setting_ip4_config_get_dhcp_hostname (s_ip4);
/* If we're supposed to send the hostname to the DHCP server but
* the user didn't specify one, then use the hostname from the
* hostname provider if there is one, otherwise use the persistent
......@@ -553,7 +546,8 @@ nm_dhcp_manager_start_ip4 (NMDHCPManager *self,
!strcmp (hostname, "localhost6.localdomain6")))
hostname = NULL;
}
}
} else
hostname = NULL;
return client_start (self, iface, hwaddr, uuid, FALSE, s_ip4, NULL, timeout, dhcp_anycast_addr, hostname, FALSE);
}
......@@ -570,15 +564,14 @@ nm_dhcp_manager_start_ip6 (NMDHCPManager *self,
gboolean info_only)
{
NMDHCPManagerPrivate *priv;
const char *hostname = NULL;
const char *hostname;
g_return_val_if_fail (self, NULL);
g_return_val_if_fail (NM_IS_DHCP_MANAGER (self), NULL);
priv = NM_DHCP_MANAGER_GET_PRIVATE (self);
if (s_ip6)
hostname = nm_setting_ip6_config_get_dhcp_hostname (s_ip6);
hostname = nm_setting_ip6_config_get_dhcp_hostname (s_ip6);
if (!hostname && priv->hostname_provider) {
hostname = nm_hostname_provider_get_hostname (priv->hostname_provider);
if ( g_strcmp0 (hostname, "localhost.localdomain") == 0
......
......@@ -144,16 +144,15 @@ get_best_ip4_device (NMManager *manager, gboolean fully_activated)
g_assert (connection);
s_ip4 = nm_connection_get_setting_ip4_config (connection);
if (s_ip4) {
/* Never set the default route through an IPv4LL-addressed device */
method = nm_setting_ip4_config_get_method (s_ip4);
if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL))
continue;
/* 'never-default' devices can't ever be the default */
if (nm_setting_ip4_config_get_never_default (s_ip4))
continue;
}
/* Never set the default route through an IPv4LL-addressed device */
method = nm_setting_ip4_config_get_method (s_ip4);
if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL))
continue;
/* 'never-default' devices can't ever be the default */
if (nm_setting_ip4_config_get_never_default (s_ip4))
continue;
prio = nm_device_get_priority (dev);
if (prio > 0 && prio < best_prio) {
......@@ -223,14 +222,13 @@ get_best_ip6_device (NMManager *manager, gboolean fully_activated)
g_assert (connection);
s_ip6 = nm_connection_get_setting_ip6_config (connection);
if (s_ip6) {
method = nm_setting_ip6_config_get_method (s_ip6);
if (!strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL))
continue;
if (nm_setting_ip6_config_get_never_default (s_ip6))
continue;
}
method = nm_setting_ip6_config_get_method (s_ip6);
if (!strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL))
continue;
if (nm_setting_ip6_config_get_never_default (s_ip6))
continue;
prio = nm_device_get_priority (dev);
if (prio > 0 && prio < best_prio) {
......@@ -575,7 +573,7 @@ get_best_ip4_config (NMPolicy *policy,
/* Check the user's preference from the NMConnection */
s_ip4 = nm_connection_get_setting_ip4_config (tmp);
if (s_ip4 && nm_setting_ip4_config_get_never_default (s_ip4))
if (nm_setting_ip4_config_get_never_default (s_ip4))
continue;
}
......@@ -753,7 +751,7 @@ get_best_ip6_config (NMPolicy *policy,
/* Check the user's preference from the NMConnection */
s_ip6 = nm_connection_get_setting_ip6_config (tmp);
if (s_ip6 && nm_setting_ip6_config_get_never_default (s_ip6))
if (nm_setting_ip6_config_get_never_default (s_ip6))
continue;
}
......
......@@ -68,6 +68,7 @@
#include "nm-settings-utils.h"
#include "nm-connection-provider.h"
#include "nm-config.h"
#include "NetworkManagerUtils.h"
/* LINKER CRACKROCK */
#define EXPORT(sym) void * __export_##sym = &sym;
......@@ -800,6 +801,8 @@ claim_connection (NMSettings *self,
return;
}
nm_utils_normalize_connection (NM_CONNECTION (connection), TRUE);
if (!nm_connection_verify (NM_CONNECTION (connection), &error)) {
nm_log_warn (LOGD_SETTINGS, "plugin provided invalid connection: '%s' / '%s' invalid: %d",
g_type_name (nm_connection_lookup_setting_type_by_quark (error->domain)),
......
......@@ -25,6 +25,8 @@ libifcfg_rh_io_la_SOURCES = \
utils.h
AM_CPPFLAGS = \
-I$(top_srcdir)/src/ \
-I$(top_srcdir)/src/platform \
-I$(top_srcdir)/src/wifi \
-I$(top_srcdir)/src/settings \
-I$(top_srcdir)/src/posix-signals \
......
......@@ -52,6 +52,7 @@
#include "wifi-utils.h"
#include "nm-posix-signals.h"
#include "NetworkManagerUtils.h"
#include "common.h"
#include "shvar.h"
......@@ -4646,10 +4647,6 @@ connection_from_file (const char *filename,
g_object_unref (connection);
connection = NULL;
goto done;
} else if (utils_ignore_ip_config (connection)) {
PLUGIN_WARN (IFCFG_PLUGIN_NAME, " warning: ignoring IP6 configuration");
g_object_unref (s_ip6);
s_ip6 = NULL;
} else {
const char *method;
......@@ -4664,11 +4661,7 @@ connection_from_file (const char *filename,
g_object_unref (connection);
connection = NULL;
goto done;
} else if (s_ip4 && utils_ignore_ip_config (connection)) {
PLUGIN_WARN (IFCFG_PLUGIN_NAME, " warning: ignoring IP4 configuration");
g_object_unref (s_ip4);
s_ip4 = NULL;
} else if (s_ip4)
} else
nm_connection_add_setting (connection, s_ip4);
/* There is only one DOMAIN variable and it is read and put to IPv4 config
......@@ -4703,6 +4696,8 @@ connection_from_file (const char *filename,
}
g_free (bootproto);
nm_utils_normalize_connection (connection, TRUE);
if (!nm_connection_verify (connection, error)) {
g_object_unref (connection);
connection = NULL;
......
......@@ -13,6 +13,8 @@ AM_CPPFLAGS = \
-I$(top_srcdir)/libnm-util \
-I$(top_builddir)/libnm-util \
-I$(top_srcdir)/libnm-glib \
-I$(top_srcdir)/src/ \
-I$(top_srcdir)/src/platform \
-I$(top_srcdir)/src/settings \
-I$(top_srcdir)/src/wifi \
-I$(top_srcdir)/src/posix-signals \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment