merge: branch 'bg/route-metric-reapply-rh1528071'
https://bugzilla.redhat.com/show_bug.cgi?id=1528071 https://github.com/NetworkManager/NetworkManager/pull/180
This commit is contained in:
@@ -10563,10 +10563,37 @@ nm_device_reactivate_ip4_config (NMDevice *self,
|
||||
_set_ip_state (self, AF_INET, IP_WAIT);
|
||||
if (!nm_device_activate_stage3_ip4_start (self))
|
||||
_LOGW (LOGD_IP4, "Failed to apply IPv4 configuration");
|
||||
} else {
|
||||
if (!ip_config_merge_and_apply (self, AF_INET, TRUE))
|
||||
_LOGW (LOGD_IP4, "Failed to reapply IPv4 configuration");
|
||||
return;
|
||||
}
|
||||
|
||||
if (s_ip4_old && s_ip4_new) {
|
||||
gint64 metric_old, metric_new;
|
||||
|
||||
/* For dynamic IP methods (DHCP, IPv4LL, WWAN) the route metric is
|
||||
* set at activation/renewal time using the value from static
|
||||
* configuration. To support runtime change we need to update the
|
||||
* dynamic configuration in place and tell the DHCP client the new
|
||||
* value to use for future renewals.
|
||||
*/
|
||||
metric_old = nm_setting_ip_config_get_route_metric (s_ip4_old);
|
||||
metric_new = nm_setting_ip_config_get_route_metric (s_ip4_new);
|
||||
|
||||
if (metric_old != metric_new) {
|
||||
if (priv->dev_ip4_config.orig) {
|
||||
nm_ip4_config_update_routes_metric ((NMIP4Config *) priv->dev_ip4_config.orig,
|
||||
nm_device_get_route_metric (self, AF_INET));
|
||||
}
|
||||
if (priv->wwan_ip_config_4.orig) {
|
||||
nm_ip4_config_update_routes_metric ((NMIP4Config *) priv->wwan_ip_config_4.orig,
|
||||
nm_device_get_route_metric (self, AF_INET));
|
||||
}
|
||||
if (priv->dhcp4.client)
|
||||
nm_dhcp_client_set_route_metric (priv->dhcp4.client, metric_new);
|
||||
}
|
||||
}
|
||||
|
||||
if (!ip_config_merge_and_apply (self, AF_INET, TRUE))
|
||||
_LOGW (LOGD_IP4, "Failed to reapply IPv4 configuration");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10608,10 +10635,36 @@ nm_device_reactivate_ip6_config (NMDevice *self,
|
||||
_set_ip_state (self, AF_INET6, IP_WAIT);
|
||||
if (!nm_device_activate_stage3_ip6_start (self))
|
||||
_LOGW (LOGD_IP6, "Failed to apply IPv6 configuration");
|
||||
} else {
|
||||
if (!ip_config_merge_and_apply (self, AF_INET6, TRUE))
|
||||
_LOGW (LOGD_IP4, "Failed to reapply IPv6 configuration");
|
||||
return;
|
||||
}
|
||||
|
||||
if (s_ip6_old && s_ip6_new) {
|
||||
gint64 metric_old, metric_new;
|
||||
|
||||
/* See comment in nm_device_reactivate_ip6_config() */
|
||||
metric_old = nm_setting_ip_config_get_route_metric (s_ip6_old);
|
||||
metric_new = nm_setting_ip_config_get_route_metric (s_ip6_new);
|
||||
|
||||
if (metric_old != metric_new) {
|
||||
if (priv->ac_ip6_config.orig) {
|
||||
nm_ip6_config_update_routes_metric ((NMIP6Config *) priv->ac_ip6_config.orig,
|
||||
nm_device_get_route_metric (self, AF_INET6));
|
||||
}
|
||||
if (priv->dhcp6.ip6_config.orig) {
|
||||
nm_ip6_config_update_routes_metric ((NMIP6Config *) priv->dhcp6.ip6_config.orig,
|
||||
nm_device_get_route_metric (self, AF_INET6));
|
||||
}
|
||||
if (priv->wwan_ip_config_6.orig) {
|
||||
nm_ip6_config_update_routes_metric ((NMIP6Config *) priv->wwan_ip_config_6.orig,
|
||||
nm_device_get_route_metric (self, AF_INET6));
|
||||
}
|
||||
if (priv->dhcp6.client)
|
||||
nm_dhcp_client_set_route_metric (priv->dhcp6.client, metric_new);
|
||||
}
|
||||
}
|
||||
|
||||
if (!ip_config_merge_and_apply (self, AF_INET6, TRUE))
|
||||
_LOGW (LOGD_IP4, "Failed to reapply IPv6 configuration");
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -51,7 +51,7 @@ enum {
|
||||
|
||||
static guint signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
NM_GOBJECT_PROPERTIES_DEFINE_BASE (
|
||||
NM_GOBJECT_PROPERTIES_DEFINE (NMDhcpClient,
|
||||
PROP_ADDR_FAMILY,
|
||||
PROP_FLAGS,
|
||||
PROP_HWADDR,
|
||||
@@ -163,6 +163,17 @@ nm_dhcp_client_get_route_table (NMDhcpClient *self)
|
||||
return NM_DHCP_CLIENT_GET_PRIVATE (self)->route_table;
|
||||
}
|
||||
|
||||
void
|
||||
nm_dhcp_client_set_route_table (NMDhcpClient *self, guint32 route_table)
|
||||
{
|
||||
NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE (self);
|
||||
|
||||
if (route_table != priv->route_table) {
|
||||
priv->route_table = route_table;
|
||||
_notify (self, PROP_ROUTE_TABLE);
|
||||
}
|
||||
}
|
||||
|
||||
guint32
|
||||
nm_dhcp_client_get_route_metric (NMDhcpClient *self)
|
||||
{
|
||||
@@ -171,6 +182,17 @@ nm_dhcp_client_get_route_metric (NMDhcpClient *self)
|
||||
return NM_DHCP_CLIENT_GET_PRIVATE (self)->route_metric;
|
||||
}
|
||||
|
||||
void
|
||||
nm_dhcp_client_set_route_metric (NMDhcpClient *self, guint32 route_metric)
|
||||
{
|
||||
NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE (self);
|
||||
|
||||
if (route_metric != priv->route_metric) {
|
||||
priv->route_metric = route_metric;
|
||||
_notify (self, PROP_ROUTE_METRIC);
|
||||
}
|
||||
}
|
||||
|
||||
guint32
|
||||
nm_dhcp_client_get_timeout (NMDhcpClient *self)
|
||||
{
|
||||
@@ -834,6 +856,9 @@ get_property (GObject *object, guint prop_id,
|
||||
case PROP_ROUTE_METRIC:
|
||||
g_value_set_uint (value, priv->route_metric);
|
||||
break;
|
||||
case PROP_ROUTE_TABLE:
|
||||
g_value_set_uint (value, priv->route_table);
|
||||
break;
|
||||
case PROP_TIMEOUT:
|
||||
g_value_set_uint (value, priv->timeout);
|
||||
break;
|
||||
@@ -889,11 +914,9 @@ set_property (GObject *object, guint prop_id,
|
||||
priv->uuid = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_ROUTE_TABLE:
|
||||
/* construct-only */
|
||||
priv->route_table = g_value_get_uint (value);
|
||||
break;
|
||||
case PROP_ROUTE_METRIC:
|
||||
/* construct-only */
|
||||
priv->route_metric = g_value_get_uint (value);
|
||||
break;
|
||||
case PROP_TIMEOUT:
|
||||
@@ -1002,13 +1025,13 @@ nm_dhcp_client_class_init (NMDhcpClientClass *client_class)
|
||||
obj_properties[PROP_ROUTE_TABLE] =
|
||||
g_param_spec_uint (NM_DHCP_CLIENT_ROUTE_TABLE, "", "",
|
||||
0, G_MAXUINT32, RT_TABLE_MAIN,
|
||||
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
obj_properties[PROP_ROUTE_METRIC] =
|
||||
g_param_spec_uint (NM_DHCP_CLIENT_ROUTE_METRIC, "", "",
|
||||
0, G_MAXUINT32, 0,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
obj_properties[PROP_TIMEOUT] =
|
||||
|
@@ -131,8 +131,12 @@ GBytes *nm_dhcp_client_get_hw_addr (NMDhcpClient *self);
|
||||
|
||||
guint32 nm_dhcp_client_get_route_table (NMDhcpClient *self);
|
||||
|
||||
void nm_dhcp_client_set_route_table (NMDhcpClient *self, guint32 route_table);
|
||||
|
||||
guint32 nm_dhcp_client_get_route_metric (NMDhcpClient *self);
|
||||
|
||||
void nm_dhcp_client_set_route_metric (NMDhcpClient *self, guint32 route_metric);
|
||||
|
||||
guint32 nm_dhcp_client_get_timeout (NMDhcpClient *self);
|
||||
|
||||
GBytes *nm_dhcp_client_get_client_id (NMDhcpClient *self);
|
||||
|
@@ -647,6 +647,37 @@ nm_ip4_config_capture (NMDedupMultiIndex *multi_idx, NMPlatform *platform, int i
|
||||
return self;
|
||||
}
|
||||
|
||||
void
|
||||
nm_ip4_config_update_routes_metric (NMIP4Config *self, gint64 metric)
|
||||
{
|
||||
gs_free NMPlatformIP4Route *routes = NULL;
|
||||
gboolean need_update = FALSE;
|
||||
const NMPlatformIP4Route *r;
|
||||
NMDedupMultiIter iter;
|
||||
guint num = 0, i = 0;
|
||||
|
||||
nm_ip_config_iter_ip4_route_for_each (&iter, self, &r) {
|
||||
if (r->metric != metric)
|
||||
need_update = TRUE;
|
||||
num++;
|
||||
}
|
||||
if (!need_update)
|
||||
return;
|
||||
|
||||
routes = g_new (NMPlatformIP4Route, num);
|
||||
nm_ip_config_iter_ip4_route_for_each (&iter, self, &r) {
|
||||
routes[i] = *r;
|
||||
routes[i].metric = metric;
|
||||
i++;
|
||||
}
|
||||
|
||||
g_object_freeze_notify (G_OBJECT (self));
|
||||
nm_ip4_config_reset_routes (self);
|
||||
for (i = 0; i < num; i++)
|
||||
nm_ip4_config_add_route (self, &routes[i], NULL);
|
||||
g_object_thaw_notify (G_OBJECT (self));
|
||||
}
|
||||
|
||||
void
|
||||
nm_ip4_config_add_dependent_routes (NMIP4Config *self,
|
||||
guint32 route_table,
|
||||
|
@@ -225,6 +225,7 @@ const NMPlatformIP4Route *_nmtst_ip4_config_get_route (const NMIP4Config *self,
|
||||
const NMPlatformIP4Route *nm_ip4_config_get_direct_route_for_host (const NMIP4Config *self,
|
||||
in_addr_t host,
|
||||
guint32 route_table);
|
||||
void nm_ip4_config_update_routes_metric (NMIP4Config *self, gint64 metric);
|
||||
|
||||
void nm_ip4_config_reset_nameservers (NMIP4Config *self);
|
||||
void nm_ip4_config_add_nameserver (NMIP4Config *self, guint32 nameserver);
|
||||
|
@@ -427,6 +427,37 @@ nm_ip6_config_capture (NMDedupMultiIndex *multi_idx, NMPlatform *platform, int i
|
||||
return self;
|
||||
}
|
||||
|
||||
void
|
||||
nm_ip6_config_update_routes_metric (NMIP6Config *self, gint64 metric)
|
||||
{
|
||||
gs_free NMPlatformIP6Route *routes = NULL;
|
||||
gboolean need_update = FALSE;
|
||||
const NMPlatformIP6Route *r;
|
||||
NMDedupMultiIter iter;
|
||||
guint num = 0, i = 0;
|
||||
|
||||
nm_ip_config_iter_ip6_route_for_each (&iter, self, &r) {
|
||||
if (r->metric != metric)
|
||||
need_update = TRUE;
|
||||
num++;
|
||||
}
|
||||
if (!need_update)
|
||||
return;
|
||||
|
||||
routes = g_new (NMPlatformIP6Route, num);
|
||||
nm_ip_config_iter_ip6_route_for_each (&iter, self, &r) {
|
||||
routes[i] = *r;
|
||||
routes[i].metric = metric;
|
||||
i++;
|
||||
}
|
||||
|
||||
g_object_freeze_notify (G_OBJECT (self));
|
||||
nm_ip6_config_reset_routes (self);
|
||||
for (i = 0; i < num; i++)
|
||||
nm_ip6_config_add_route (self, &routes[i], NULL);
|
||||
g_object_thaw_notify (G_OBJECT (self));
|
||||
}
|
||||
|
||||
void
|
||||
nm_ip6_config_add_dependent_routes (NMIP6Config *self,
|
||||
guint32 route_table,
|
||||
|
@@ -224,4 +224,6 @@ void nm_ip6_config_reset_routes_ndisc (NMIP6Config *self,
|
||||
guint32 route_metric,
|
||||
gboolean kernel_support_rta_pref);
|
||||
|
||||
void nm_ip6_config_update_routes_metric (NMIP6Config *self, gint64 metric);
|
||||
|
||||
#endif /* __NETWORKMANAGER_IP6_CONFIG_H__ */
|
||||
|
Reference in New Issue
Block a user