core: don't have IP4 and IP6 configs on slaves
Although it's convenient in some places to have IP configs on all connections, it makes more sense in other places to not have IP configs on slaves. (eg, it's confusing for nmcli, etc, to report a full NMSettingIP4Config on a slave device). So revert parts of the earlier patch. However, it's still safe to assume that s_ip4 != NULL if method != DISABLED, so some of the earlier simplifications can stay. Also, add nm_utils_get_ip_config_method(), which returns the correct IP config method for a connection, whether the connection has IP4 and IP6 settings objects or not, and use that to keep some more of the simplifications from the earlier patch.
This commit is contained in:
@@ -294,13 +294,9 @@ nm_utils_get_shared_wifi_permission (NMConnection *connection)
|
|||||||
{
|
{
|
||||||
NMSettingWireless *s_wifi;
|
NMSettingWireless *s_wifi;
|
||||||
NMSettingWirelessSecurity *s_wsec;
|
NMSettingWirelessSecurity *s_wsec;
|
||||||
NMSettingIP4Config *s_ip4;
|
|
||||||
const char *method = NULL;
|
const char *method = NULL;
|
||||||
|
|
||||||
s_ip4 = nm_connection_get_setting_ip4_config (connection);
|
method = nm_utils_get_ip_config_method (connection, NM_TYPE_SETTING_IP4_CONFIG);
|
||||||
method = nm_setting_ip4_config_get_method (s_ip4);
|
|
||||||
g_assert (method);
|
|
||||||
|
|
||||||
if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_SHARED) != 0)
|
if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_SHARED) != 0)
|
||||||
return NULL; /* Not shared */
|
return NULL; /* Not shared */
|
||||||
|
|
||||||
@@ -592,33 +588,30 @@ nm_utils_normalize_connection (NMConnection *connection,
|
|||||||
s_ip4 = nm_connection_get_setting_ip4_config (connection);
|
s_ip4 = nm_connection_get_setting_ip4_config (connection);
|
||||||
s_ip6 = nm_connection_get_setting_ip6_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)) {
|
if (nm_setting_connection_get_master (s_con)) {
|
||||||
default_ip4_method = NM_SETTING_IP4_CONFIG_METHOD_DISABLED;
|
/* Slave connections don't have IP configuration. */
|
||||||
default_ip6_method = NM_SETTING_IP6_CONFIG_METHOD_IGNORE;
|
|
||||||
|
|
||||||
if (s_ip4) {
|
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_DISABLED) != 0) {
|
if (g_strcmp0 (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED) != 0) {
|
||||||
nm_log_warn (LOGD_SETTINGS, "ignoring IP4 config on slave '%s'",
|
nm_log_warn (LOGD_SETTINGS, "ignoring IP4 config on slave '%s'",
|
||||||
nm_connection_get_id (connection));
|
nm_connection_get_id (connection));
|
||||||
|
}
|
||||||
nm_connection_remove_setting (connection, NM_TYPE_SETTING_IP4_CONFIG);
|
nm_connection_remove_setting (connection, NM_TYPE_SETTING_IP4_CONFIG);
|
||||||
s_ip4 = NULL;
|
s_ip4 = NULL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (s_ip6) {
|
if (s_ip6) {
|
||||||
method = nm_setting_ip6_config_get_method (s_ip6);
|
method = nm_setting_ip6_config_get_method (s_ip6);
|
||||||
if (g_strcmp0 (method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE) != 0) {
|
if (g_strcmp0 (method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE) != 0) {
|
||||||
nm_log_warn (LOGD_SETTINGS, "ignoring IP6 config on slave '%s'",
|
nm_log_warn (LOGD_SETTINGS, "ignoring IP6 config on slave '%s'",
|
||||||
nm_connection_get_id (connection));
|
nm_connection_get_id (connection));
|
||||||
|
}
|
||||||
nm_connection_remove_setting (connection, NM_TYPE_SETTING_IP6_CONFIG);
|
nm_connection_remove_setting (connection, NM_TYPE_SETTING_IP6_CONFIG);
|
||||||
s_ip6 = NULL;
|
s_ip6 = NULL;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
}
|
/* Ensure all non-slave connections have IP4 and IP6 settings objects. If no
|
||||||
|
|
||||||
/* Ensure all connections have IP4 and IP6 settings objects. If no
|
|
||||||
* IP6 setting was specified, then assume that means IP6 config is allowed
|
* 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
|
* to fail. But if no IP4 setting was specified, assume the caller was just
|
||||||
* being lazy.
|
* being lazy.
|
||||||
@@ -641,6 +634,50 @@ nm_utils_normalize_connection (NMConnection *connection,
|
|||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
nm_utils_get_ip_config_method (NMConnection *connection,
|
||||||
|
GType ip_setting_type)
|
||||||
|
{
|
||||||
|
NMSettingConnection *s_con;
|
||||||
|
NMSettingIP4Config *s_ip4;
|
||||||
|
NMSettingIP6Config *s_ip6;
|
||||||
|
const char *method;
|
||||||
|
|
||||||
|
s_con = nm_connection_get_setting_connection (connection);
|
||||||
|
|
||||||
|
if (ip_setting_type == NM_TYPE_SETTING_IP4_CONFIG) {
|
||||||
|
g_return_val_if_fail (s_con != NULL, NM_SETTING_IP4_CONFIG_METHOD_AUTO);
|
||||||
|
|
||||||
|
if (nm_setting_connection_get_master (s_con))
|
||||||
|
return NM_SETTING_IP4_CONFIG_METHOD_DISABLED;
|
||||||
|
else {
|
||||||
|
s_ip4 = nm_connection_get_setting_ip4_config (connection);
|
||||||
|
g_return_val_if_fail (s_ip4 != NULL, NM_SETTING_IP4_CONFIG_METHOD_AUTO);
|
||||||
|
method = nm_setting_ip4_config_get_method (s_ip4);
|
||||||
|
g_return_val_if_fail (method != NULL, NM_SETTING_IP4_CONFIG_METHOD_AUTO);
|
||||||
|
|
||||||
|
return method;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (ip_setting_type == NM_TYPE_SETTING_IP6_CONFIG) {
|
||||||
|
g_return_val_if_fail (s_con != NULL, NM_SETTING_IP6_CONFIG_METHOD_AUTO);
|
||||||
|
|
||||||
|
if (nm_setting_connection_get_master (s_con))
|
||||||
|
return NM_SETTING_IP6_CONFIG_METHOD_IGNORE;
|
||||||
|
else {
|
||||||
|
s_ip6 = nm_connection_get_setting_ip6_config (connection);
|
||||||
|
g_return_val_if_fail (s_ip6 != NULL, NM_SETTING_IP6_CONFIG_METHOD_AUTO);
|
||||||
|
method = nm_setting_ip6_config_get_method (s_ip6);
|
||||||
|
g_return_val_if_fail (method != NULL, NM_SETTING_IP6_CONFIG_METHOD_AUTO);
|
||||||
|
|
||||||
|
return method;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else
|
||||||
|
g_assert_not_reached ();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
nm_utils_complete_generic (NMConnection *connection,
|
nm_utils_complete_generic (NMConnection *connection,
|
||||||
|
@@ -84,6 +84,8 @@ gboolean nm_utils_get_proc_sys_net_value_with_bounds (const char *path,
|
|||||||
|
|
||||||
void nm_utils_normalize_connection (NMConnection *connection,
|
void nm_utils_normalize_connection (NMConnection *connection,
|
||||||
gboolean default_enable_ipv6);
|
gboolean default_enable_ipv6);
|
||||||
|
const char *nm_utils_get_ip_config_method (NMConnection *connection,
|
||||||
|
GType ip_setting_type);
|
||||||
|
|
||||||
void nm_utils_complete_generic (NMConnection *connection,
|
void nm_utils_complete_generic (NMConnection *connection,
|
||||||
const char *ctype,
|
const char *ctype,
|
||||||
|
@@ -1298,7 +1298,6 @@ can_auto_connect (NMDevice *dev,
|
|||||||
NMDeviceWifi *self = NM_DEVICE_WIFI (dev);
|
NMDeviceWifi *self = NM_DEVICE_WIFI (dev);
|
||||||
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
|
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
|
||||||
GSList *ap_iter;
|
GSList *ap_iter;
|
||||||
NMSettingIP4Config *s_ip4;
|
|
||||||
const char *method = NULL;
|
const char *method = NULL;
|
||||||
guint64 timestamp = 0;
|
guint64 timestamp = 0;
|
||||||
|
|
||||||
@@ -1315,8 +1314,7 @@ can_auto_connect (NMDevice *dev,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Use the connection if it's a shared connection */
|
/* Use the connection if it's a shared connection */
|
||||||
s_ip4 = nm_connection_get_setting_ip4_config (connection);
|
method = nm_utils_get_ip_config_method (connection, NM_TYPE_SETTING_IP4_CONFIG);
|
||||||
method = nm_setting_ip4_config_get_method (s_ip4);
|
|
||||||
if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_SHARED))
|
if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_SHARED))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
@@ -1490,15 +1488,14 @@ scanning_allowed (NMDeviceWifi *self)
|
|||||||
req = nm_device_get_act_request (NM_DEVICE (self));
|
req = nm_device_get_act_request (NM_DEVICE (self));
|
||||||
if (req) {
|
if (req) {
|
||||||
NMConnection *connection;
|
NMConnection *connection;
|
||||||
NMSettingIP4Config *s_ip4;
|
|
||||||
NMSettingWireless *s_wifi;
|
NMSettingWireless *s_wifi;
|
||||||
const char *ip4_method = NULL;
|
const char *ip4_method = NULL;
|
||||||
const GByteArray *bssid;
|
const GByteArray *bssid;
|
||||||
|
|
||||||
/* Don't scan when a shared connection is active; it makes drivers mad */
|
/* Don't scan when a shared connection is active; it makes drivers mad */
|
||||||
connection = nm_act_request_get_connection (req);
|
connection = nm_act_request_get_connection (req);
|
||||||
s_ip4 = nm_connection_get_setting_ip4_config (connection);
|
ip4_method = nm_utils_get_ip_config_method (connection, NM_TYPE_SETTING_IP4_CONFIG);
|
||||||
ip4_method = nm_setting_ip4_config_get_method (s_ip4);
|
|
||||||
if (!strcmp (ip4_method, NM_SETTING_IP4_CONFIG_METHOD_SHARED))
|
if (!strcmp (ip4_method, NM_SETTING_IP4_CONFIG_METHOD_SHARED))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
@@ -1012,18 +1012,14 @@ nm_device_release_one_slave (NMDevice *dev, NMDevice *slave, gboolean failed)
|
|||||||
static gboolean
|
static gboolean
|
||||||
connection_is_static (NMConnection *connection)
|
connection_is_static (NMConnection *connection)
|
||||||
{
|
{
|
||||||
NMSettingIP4Config *s_ip4;
|
|
||||||
NMSettingIP6Config *s_ip6;
|
|
||||||
const char *method;
|
const char *method;
|
||||||
|
|
||||||
s_ip4 = nm_connection_get_setting_ip4_config (connection);
|
method = nm_utils_get_ip_config_method (connection, NM_TYPE_SETTING_IP4_CONFIG);
|
||||||
method = nm_setting_ip4_config_get_method (s_ip4);
|
|
||||||
if ( strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL) != 0
|
if ( strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL) != 0
|
||||||
&& strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED) != 0)
|
&& strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED) != 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
s_ip6 = nm_connection_get_setting_ip6_config (connection);
|
method = nm_utils_get_ip_config_method (connection, NM_TYPE_SETTING_IP6_CONFIG);
|
||||||
method = nm_setting_ip6_config_get_method (s_ip6);
|
|
||||||
if ( strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_MANUAL) != 0
|
if ( strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_MANUAL) != 0
|
||||||
&& strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE) != 0)
|
&& strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE) != 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -2170,8 +2166,7 @@ nm_device_handle_autoip4_event (NMDevice *self,
|
|||||||
{
|
{
|
||||||
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
||||||
NMConnection *connection = NULL;
|
NMConnection *connection = NULL;
|
||||||
NMSettingIP4Config *s_ip4 = NULL;
|
const char *iface, *method;
|
||||||
const char *iface, *method = NULL;
|
|
||||||
NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE;
|
NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE;
|
||||||
|
|
||||||
g_return_if_fail (event != NULL);
|
g_return_if_fail (event != NULL);
|
||||||
@@ -2183,9 +2178,8 @@ nm_device_handle_autoip4_event (NMDevice *self,
|
|||||||
g_assert (connection);
|
g_assert (connection);
|
||||||
|
|
||||||
/* Ignore if the connection isn't an AutoIP connection */
|
/* Ignore if the connection isn't an AutoIP connection */
|
||||||
s_ip4 = nm_connection_get_setting_ip4_config (connection);
|
method = nm_utils_get_ip_config_method (connection, NM_TYPE_SETTING_IP4_CONFIG);
|
||||||
method = nm_setting_ip4_config_get_method (s_ip4);
|
if (g_strcmp0 (method, NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL) != 0)
|
||||||
if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL) != 0)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
iface = nm_device_get_iface (self);
|
iface = nm_device_get_iface (self);
|
||||||
@@ -2695,11 +2689,9 @@ have_any_ready_slaves (NMDevice *device, const GSList *slaves)
|
|||||||
static gboolean
|
static gboolean
|
||||||
ip4_requires_slaves (NMConnection *connection)
|
ip4_requires_slaves (NMConnection *connection)
|
||||||
{
|
{
|
||||||
NMSettingIP4Config *s_ip4;
|
const char *method;
|
||||||
const char *method = NM_SETTING_IP4_CONFIG_METHOD_AUTO;
|
|
||||||
|
|
||||||
s_ip4 = nm_connection_get_setting_ip4_config (connection);
|
method = nm_utils_get_ip_config_method (connection, NM_TYPE_SETTING_IP4_CONFIG);
|
||||||
method = nm_setting_ip4_config_get_method (s_ip4);
|
|
||||||
return strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO) == 0;
|
return strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2710,9 +2702,8 @@ act_stage3_ip4_config_start (NMDevice *self,
|
|||||||
{
|
{
|
||||||
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
||||||
NMConnection *connection;
|
NMConnection *connection;
|
||||||
NMSettingIP4Config *s_ip4;
|
|
||||||
NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
|
NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
|
||||||
const char *method = NM_SETTING_IP4_CONFIG_METHOD_AUTO;
|
const char *method;
|
||||||
GSList *slaves;
|
GSList *slaves;
|
||||||
gboolean ready_slaves;
|
gboolean ready_slaves;
|
||||||
|
|
||||||
@@ -2721,8 +2712,9 @@ act_stage3_ip4_config_start (NMDevice *self,
|
|||||||
connection = nm_device_get_connection (self);
|
connection = nm_device_get_connection (self);
|
||||||
g_assert (connection);
|
g_assert (connection);
|
||||||
|
|
||||||
s_ip4 = nm_connection_get_setting_ip4_config (connection);
|
method = nm_utils_get_ip_config_method (connection, NM_TYPE_SETTING_IP4_CONFIG);
|
||||||
method = nm_setting_ip4_config_get_method (s_ip4);
|
if (priv->master)
|
||||||
|
g_assert_cmpstr (method, ==, NM_SETTING_IP4_CONFIG_METHOD_DISABLED);
|
||||||
|
|
||||||
if ( strcmp (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_master (self)
|
||||||
@@ -3228,11 +3220,9 @@ done:
|
|||||||
static gboolean
|
static gboolean
|
||||||
ip6_requires_slaves (NMConnection *connection)
|
ip6_requires_slaves (NMConnection *connection)
|
||||||
{
|
{
|
||||||
NMSettingIP6Config *s_ip6;
|
const char *method;
|
||||||
const char *method = NM_SETTING_IP6_CONFIG_METHOD_AUTO;
|
|
||||||
|
|
||||||
s_ip6 = nm_connection_get_setting_ip6_config (connection);
|
method = nm_utils_get_ip_config_method (connection, NM_TYPE_SETTING_IP6_CONFIG);
|
||||||
method = nm_setting_ip6_config_get_method (s_ip6);
|
|
||||||
|
|
||||||
/* SLAAC, DHCP, and Link-Local depend on connectivity (and thus slaves)
|
/* SLAAC, DHCP, and Link-Local depend on connectivity (and thus slaves)
|
||||||
* to complete addressing. SLAAC and DHCP obviously need a peer to
|
* to complete addressing. SLAAC and DHCP obviously need a peer to
|
||||||
@@ -3252,8 +3242,7 @@ act_stage3_ip6_config_start (NMDevice *self,
|
|||||||
const char *ip_iface;
|
const char *ip_iface;
|
||||||
NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
|
NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
|
||||||
NMConnection *connection;
|
NMConnection *connection;
|
||||||
NMSettingIP6Config *s_ip6;
|
const char *method;
|
||||||
const char *method = NM_SETTING_IP6_CONFIG_METHOD_AUTO;
|
|
||||||
int conf_use_tempaddr;
|
int conf_use_tempaddr;
|
||||||
NMSettingIP6ConfigPrivacy ip6_privacy = NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN;
|
NMSettingIP6ConfigPrivacy ip6_privacy = NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN;
|
||||||
const char *ip6_privacy_str = "0\n";
|
const char *ip6_privacy_str = "0\n";
|
||||||
@@ -3267,8 +3256,9 @@ act_stage3_ip6_config_start (NMDevice *self,
|
|||||||
connection = nm_device_get_connection (self);
|
connection = nm_device_get_connection (self);
|
||||||
g_assert (connection);
|
g_assert (connection);
|
||||||
|
|
||||||
s_ip6 = nm_connection_get_setting_ip6_config (connection);
|
method = nm_utils_get_ip_config_method (connection, NM_TYPE_SETTING_IP6_CONFIG);
|
||||||
method = nm_setting_ip6_config_get_method (s_ip6);
|
if (priv->master)
|
||||||
|
g_assert_cmpstr (method, ==, NM_SETTING_IP6_CONFIG_METHOD_IGNORE);
|
||||||
|
|
||||||
if ( strcmp (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_master (self)
|
||||||
@@ -3343,8 +3333,12 @@ act_stage3_ip6_config_start (NMDevice *self,
|
|||||||
conf_use_tempaddr = ip6_use_tempaddr ();
|
conf_use_tempaddr = ip6_use_tempaddr ();
|
||||||
if (conf_use_tempaddr >= 0)
|
if (conf_use_tempaddr >= 0)
|
||||||
ip6_privacy = conf_use_tempaddr;
|
ip6_privacy = conf_use_tempaddr;
|
||||||
else
|
else {
|
||||||
|
NMSettingIP6Config *s_ip6 = nm_connection_get_setting_ip6_config (connection);
|
||||||
|
|
||||||
|
if (s_ip6)
|
||||||
ip6_privacy = nm_setting_ip6_config_get_ip6_privacy (s_ip6);
|
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);
|
ip6_privacy = CLAMP (ip6_privacy, NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN, NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR);
|
||||||
|
|
||||||
switch (ip6_privacy) {
|
switch (ip6_privacy) {
|
||||||
@@ -3856,9 +3850,8 @@ nm_device_activate_ip4_config_commit (gpointer user_data)
|
|||||||
NMDevice *self = NM_DEVICE (user_data);
|
NMDevice *self = NM_DEVICE (user_data);
|
||||||
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
||||||
NMActRequest *req;
|
NMActRequest *req;
|
||||||
const char *iface, *method = NULL;
|
const char *iface, *method;
|
||||||
NMConnection *connection;
|
NMConnection *connection;
|
||||||
NMSettingIP4Config *s_ip4;
|
|
||||||
NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE;
|
NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE;
|
||||||
int ifindex;
|
int ifindex;
|
||||||
|
|
||||||
@@ -3889,8 +3882,7 @@ nm_device_activate_ip4_config_commit (gpointer user_data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Start IPv4 sharing if we need it */
|
/* Start IPv4 sharing if we need it */
|
||||||
s_ip4 = nm_connection_get_setting_ip4_config (connection);
|
method = nm_utils_get_ip_config_method (connection, NM_TYPE_SETTING_IP4_CONFIG);
|
||||||
method = nm_setting_ip4_config_get_method (s_ip4);
|
|
||||||
|
|
||||||
if (strcmp (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)) {
|
if (!start_sharing (self, priv->ip4_config)) {
|
||||||
@@ -5003,8 +4995,7 @@ dispose (GObject *object)
|
|||||||
*/
|
*/
|
||||||
if (nm_device_can_assume_connections (self) && (priv->state == NM_DEVICE_STATE_ACTIVATED)) {
|
if (nm_device_can_assume_connections (self) && (priv->state == NM_DEVICE_STATE_ACTIVATED)) {
|
||||||
NMConnection *connection;
|
NMConnection *connection;
|
||||||
NMSettingIP4Config *s_ip4 = NULL;
|
const char *method;
|
||||||
const char *method = NULL;
|
|
||||||
|
|
||||||
connection = nm_device_get_connection (self);
|
connection = nm_device_get_connection (self);
|
||||||
if (connection) {
|
if (connection) {
|
||||||
@@ -5012,8 +5003,7 @@ dispose (GObject *object)
|
|||||||
* All IPv6 connections can be left up, so we don't have
|
* All IPv6 connections can be left up, so we don't have
|
||||||
* to check that.
|
* to check that.
|
||||||
*/
|
*/
|
||||||
s_ip4 = nm_connection_get_setting_ip4_config (connection);
|
method = nm_utils_get_ip_config_method (connection, NM_TYPE_SETTING_IP4_CONFIG);
|
||||||
method = nm_setting_ip4_config_get_method (s_ip4);
|
|
||||||
if ( !strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO)
|
if ( !strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO)
|
||||||
|| !strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL)
|
|| !strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL)
|
||||||
|| !strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED))
|
|| !strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED))
|
||||||
@@ -6404,8 +6394,6 @@ ip4_match_config (NMDevice *self, NMConnection *connection)
|
|||||||
NMDHCPManager *dhcp_mgr;
|
NMDHCPManager *dhcp_mgr;
|
||||||
const char *method;
|
const char *method;
|
||||||
|
|
||||||
s_ip4 = nm_connection_get_setting_ip4_config (connection);
|
|
||||||
|
|
||||||
/* Get any saved leases that apply to this connection */
|
/* Get any saved leases that apply to this connection */
|
||||||
dhcp_mgr = nm_dhcp_manager_get ();
|
dhcp_mgr = nm_dhcp_manager_get ();
|
||||||
leases = nm_dhcp_manager_get_lease_config (dhcp_mgr,
|
leases = nm_dhcp_manager_get_lease_config (dhcp_mgr,
|
||||||
@@ -6414,7 +6402,7 @@ ip4_match_config (NMDevice *self, NMConnection *connection)
|
|||||||
FALSE);
|
FALSE);
|
||||||
g_object_unref (dhcp_mgr);
|
g_object_unref (dhcp_mgr);
|
||||||
|
|
||||||
method = nm_setting_ip4_config_get_method (s_ip4);
|
method = nm_utils_get_ip_config_method (connection, NM_TYPE_SETTING_IP4_CONFIG);
|
||||||
if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO)) {
|
if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO)) {
|
||||||
gboolean found = FALSE;
|
gboolean found = FALSE;
|
||||||
|
|
||||||
@@ -6455,6 +6443,8 @@ ip4_match_config (NMDevice *self, NMConnection *connection)
|
|||||||
/* Everything below for static addressing */
|
/* Everything below for static addressing */
|
||||||
|
|
||||||
/* Find all IP4 addresses of this connection on the device */
|
/* Find all IP4 addresses of this connection on the device */
|
||||||
|
s_ip4 = nm_connection_get_setting_ip4_config (connection);
|
||||||
|
if (s_ip4) {
|
||||||
num = nm_setting_ip4_config_get_num_addresses (s_ip4);
|
num = nm_setting_ip4_config_get_num_addresses (s_ip4);
|
||||||
for (i = 0; i < num; i++) {
|
for (i = 0; i < num; i++) {
|
||||||
NMIP4Address *addr = nm_setting_ip4_config_get_address (s_ip4, i);
|
NMIP4Address *addr = nm_setting_ip4_config_get_address (s_ip4, i);
|
||||||
@@ -6464,6 +6454,7 @@ ip4_match_config (NMDevice *self, NMConnection *connection)
|
|||||||
nm_ip4_address_get_prefix (addr)))
|
nm_ip4_address_get_prefix (addr)))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Success; all the connection's static IP addresses are assigned to the device */
|
/* Success; all the connection's static IP addresses are assigned to the device */
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@@ -143,14 +143,15 @@ get_best_ip4_device (NMManager *manager, gboolean fully_activated)
|
|||||||
connection = nm_act_request_get_connection (req);
|
connection = nm_act_request_get_connection (req);
|
||||||
g_assert (connection);
|
g_assert (connection);
|
||||||
|
|
||||||
s_ip4 = nm_connection_get_setting_ip4_config (connection);
|
method = nm_utils_get_ip_config_method (connection, NM_TYPE_SETTING_IP4_CONFIG);
|
||||||
|
/* If IPv4 is disabled or link-local-only, it can't be the default */
|
||||||
/* Never set the default route through an IPv4LL-addressed device */
|
if ( !strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED)
|
||||||
method = nm_setting_ip4_config_get_method (s_ip4);
|
|| !strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL))
|
||||||
if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL))
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* 'never-default' devices can't ever be the default */
|
/* 'never-default' devices can't ever be the default */
|
||||||
|
s_ip4 = nm_connection_get_setting_ip4_config (connection);
|
||||||
|
g_assert (s_ip4);
|
||||||
if (nm_setting_ip4_config_get_never_default (s_ip4))
|
if (nm_setting_ip4_config_get_never_default (s_ip4))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -221,12 +222,13 @@ get_best_ip6_device (NMManager *manager, gboolean fully_activated)
|
|||||||
connection = nm_act_request_get_connection (req);
|
connection = nm_act_request_get_connection (req);
|
||||||
g_assert (connection);
|
g_assert (connection);
|
||||||
|
|
||||||
s_ip6 = nm_connection_get_setting_ip6_config (connection);
|
method = nm_utils_get_ip_config_method (connection, NM_TYPE_SETTING_IP6_CONFIG);
|
||||||
|
if ( !strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE)
|
||||||
method = nm_setting_ip6_config_get_method (s_ip6);
|
|| !strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL))
|
||||||
if (!strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL))
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
s_ip6 = nm_connection_get_setting_ip6_config (connection);
|
||||||
|
g_assert (s_ip6);
|
||||||
if (nm_setting_ip6_config_get_never_default (s_ip6))
|
if (nm_setting_ip6_config_get_never_default (s_ip6))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user