mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-06 12:50:33 +01:00
core: fix metrics of user-added routes
Adding a route with a metric of 0 to an IP4 or IP6 setting used to implicitly mean "use the default metric for the device", but this got broken by722c9034. Fix that. https://bugzilla.gnome.org/show_bug.cgi?id=731402 (cherry picked from commitcdd09286d7)
This commit is contained in:
parent
1963addac6
commit
223a0dde1a
6 changed files with 24 additions and 10 deletions
|
|
@ -2629,8 +2629,11 @@ ip4_config_merge_and_apply (NMDevice *self,
|
|||
|
||||
/* Merge user overrides into the composite config */
|
||||
connection = nm_device_get_connection (self);
|
||||
if (connection)
|
||||
nm_ip4_config_merge_setting (composite, nm_connection_get_setting_ip4_config (connection));
|
||||
if (connection) {
|
||||
nm_ip4_config_merge_setting (composite,
|
||||
nm_connection_get_setting_ip4_config (connection),
|
||||
nm_device_get_priority (self));
|
||||
}
|
||||
|
||||
/* Allow setting MTU etc */
|
||||
if (commit) {
|
||||
|
|
@ -3071,8 +3074,11 @@ ip6_config_merge_and_apply (NMDevice *self,
|
|||
|
||||
/* Merge user overrides into the composite config */
|
||||
connection = nm_device_get_connection (self);
|
||||
if (connection)
|
||||
nm_ip6_config_merge_setting (composite, nm_connection_get_setting_ip6_config (connection));
|
||||
if (connection) {
|
||||
nm_ip6_config_merge_setting (composite,
|
||||
nm_connection_get_setting_ip6_config (connection),
|
||||
nm_device_get_priority (self));
|
||||
}
|
||||
|
||||
nm_ip6_config_addresses_sort (composite,
|
||||
priv->rdisc ? priv->rdisc_use_tempaddr : NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN);
|
||||
|
|
|
|||
|
|
@ -296,7 +296,7 @@ nm_ip4_config_commit (const NMIP4Config *config, int ifindex)
|
|||
}
|
||||
|
||||
void
|
||||
nm_ip4_config_merge_setting (NMIP4Config *config, NMSettingIP4Config *setting)
|
||||
nm_ip4_config_merge_setting (NMIP4Config *config, NMSettingIP4Config *setting, int default_route_metric)
|
||||
{
|
||||
guint naddresses, nroutes, nnameservers, nsearches;
|
||||
int i;
|
||||
|
|
@ -355,6 +355,8 @@ nm_ip4_config_merge_setting (NMIP4Config *config, NMSettingIP4Config *setting)
|
|||
route.plen = nm_ip4_route_get_prefix (s_route);
|
||||
route.gateway = nm_ip4_route_get_next_hop (s_route);
|
||||
route.metric = nm_ip4_route_get_metric (s_route);
|
||||
if (!route.metric)
|
||||
route.metric = default_route_metric;
|
||||
route.source = NM_PLATFORM_SOURCE_USER;
|
||||
|
||||
nm_ip4_config_add_route (config, &route);
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ const char * nm_ip4_config_get_dbus_path (const NMIP4Config *config);
|
|||
/* Integration with nm-platform and nm-setting */
|
||||
NMIP4Config *nm_ip4_config_capture (int ifindex, gboolean capture_resolv_conf);
|
||||
gboolean nm_ip4_config_commit (const NMIP4Config *config, int ifindex);
|
||||
void nm_ip4_config_merge_setting (NMIP4Config *config, NMSettingIP4Config *setting);
|
||||
void nm_ip4_config_merge_setting (NMIP4Config *config, NMSettingIP4Config *setting, int default_route_metric);
|
||||
NMSetting *nm_ip4_config_create_setting (const NMIP4Config *config);
|
||||
|
||||
/* Utility functions */
|
||||
|
|
|
|||
|
|
@ -401,7 +401,7 @@ nm_ip6_config_commit (const NMIP6Config *config, int ifindex)
|
|||
}
|
||||
|
||||
void
|
||||
nm_ip6_config_merge_setting (NMIP6Config *config, NMSettingIP6Config *setting)
|
||||
nm_ip6_config_merge_setting (NMIP6Config *config, NMSettingIP6Config *setting, int default_route_metric)
|
||||
{
|
||||
guint naddresses, nroutes, nnameservers, nsearches;
|
||||
int i;
|
||||
|
|
@ -457,6 +457,8 @@ nm_ip6_config_merge_setting (NMIP6Config *config, NMSettingIP6Config *setting)
|
|||
route.plen = nm_ip6_route_get_prefix (s_route);
|
||||
route.gateway = *nm_ip6_route_get_next_hop (s_route);
|
||||
route.metric = nm_ip6_route_get_metric (s_route);
|
||||
if (!route.metric)
|
||||
route.metric = default_route_metric;
|
||||
route.source = NM_PLATFORM_SOURCE_USER;
|
||||
|
||||
nm_ip6_config_add_route (config, &route);
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ const char * nm_ip6_config_get_dbus_path (const NMIP6Config *config);
|
|||
/* Integration with nm-platform and nm-setting */
|
||||
NMIP6Config *nm_ip6_config_capture (int ifindex, gboolean capture_resolv_conf, NMSettingIP6ConfigPrivacy use_temporary);
|
||||
gboolean nm_ip6_config_commit (const NMIP6Config *config, int ifindex);
|
||||
void nm_ip6_config_merge_setting (NMIP6Config *config, NMSettingIP6Config *setting);
|
||||
void nm_ip6_config_merge_setting (NMIP6Config *config, NMSettingIP6Config *setting, int default_route_metric);
|
||||
NMSetting *nm_ip6_config_create_setting (const NMIP6Config *config);
|
||||
|
||||
/* Utility functions */
|
||||
|
|
|
|||
|
|
@ -1208,7 +1208,9 @@ nm_vpn_connection_ip4_config_get (DBusGProxy *proxy,
|
|||
nm_ip4_config_set_never_default (config, g_value_get_boolean (val));
|
||||
|
||||
/* Merge in user overrides from the NMConnection's IPv4 setting */
|
||||
nm_ip4_config_merge_setting (config, nm_connection_get_setting_ip4_config (priv->connection));
|
||||
nm_ip4_config_merge_setting (config,
|
||||
nm_connection_get_setting_ip4_config (priv->connection),
|
||||
vpn_routing_metric (connection));
|
||||
|
||||
priv->ip4_config = config;
|
||||
nm_ip4_config_export (config);
|
||||
|
|
@ -1352,7 +1354,9 @@ nm_vpn_connection_ip6_config_get (DBusGProxy *proxy,
|
|||
nm_ip6_config_set_never_default (config, g_value_get_boolean (val));
|
||||
|
||||
/* Merge in user overrides from the NMConnection's IPv6 setting */
|
||||
nm_ip6_config_merge_setting (config, nm_connection_get_setting_ip6_config (priv->connection));
|
||||
nm_ip6_config_merge_setting (config,
|
||||
nm_connection_get_setting_ip6_config (priv->connection),
|
||||
vpn_routing_metric (connection));
|
||||
|
||||
priv->ip6_config = config;
|
||||
nm_ip6_config_export (config);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue