mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-25 02:30:08 +01:00
core: overwrite the default route priority via connection setting
Make use of the new setting nm_setting_ip_config_get_route_metric() If set, this override the route metric determined based on the device type. Similarly for VPN also prefer the setting from the connection. Thereby change the default priority (for VPN that have their own device) to NM_VPN_ROUTE_METRIC_DEFAULT instead of NM_PLATFORM_ROUTE_METRIC_DEFAULT. The latter would be a very low priority compared to the default metrics for devices. Signed-off-by: Thomas Haller <thaller@redhat.com>
This commit is contained in:
parent
172c1eb652
commit
df923622b1
2 changed files with 44 additions and 12 deletions
|
|
@ -684,13 +684,33 @@ nm_device_get_priority (NMDevice *self)
|
|||
guint32
|
||||
nm_device_get_ip4_route_metric (NMDevice *self)
|
||||
{
|
||||
return nm_device_get_priority (self);
|
||||
NMConnection *connection;
|
||||
gint64 route_metric = -1;
|
||||
|
||||
g_return_val_if_fail (NM_IS_DEVICE (self), G_MAXUINT32);
|
||||
|
||||
connection = nm_device_get_connection (self);
|
||||
|
||||
if (connection)
|
||||
route_metric = nm_setting_ip_config_get_route_metric (nm_connection_get_setting_ip4_config (connection));
|
||||
|
||||
return route_metric >= 0 ? route_metric : nm_device_get_priority (self);
|
||||
}
|
||||
|
||||
guint32
|
||||
nm_device_get_ip6_route_metric (NMDevice *self)
|
||||
{
|
||||
return nm_device_get_priority (self);
|
||||
NMConnection *connection;
|
||||
gint64 route_metric = -1;
|
||||
|
||||
g_return_val_if_fail (NM_IS_DEVICE (self), G_MAXUINT32);
|
||||
|
||||
connection = nm_device_get_connection (self);
|
||||
|
||||
if (connection)
|
||||
route_metric = nm_setting_ip_config_get_route_metric (nm_connection_get_setting_ip6_config (connection));
|
||||
|
||||
return route_metric >= 0 ? route_metric : nm_device_get_priority (self);
|
||||
}
|
||||
|
||||
const char *
|
||||
|
|
|
|||
|
|
@ -1113,29 +1113,41 @@ nm_vpn_connection_config_get (DBusGProxy *proxy,
|
|||
guint32
|
||||
nm_vpn_connection_get_ip4_route_metric (NMVpnConnection *connection)
|
||||
{
|
||||
NMDevice *parent_dev;
|
||||
NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (connection);
|
||||
|
||||
if (priv->ip_ifindex)
|
||||
return NM_PLATFORM_ROUTE_METRIC_DEFAULT;
|
||||
else {
|
||||
NMDevice *parent_dev = nm_active_connection_get_device (NM_ACTIVE_CONNECTION (connection));
|
||||
if (priv->connection) {
|
||||
gint64 route_metric = nm_setting_ip_config_get_route_metric (nm_connection_get_setting_ip4_config (priv->connection));
|
||||
|
||||
return nm_device_get_ip4_route_metric (parent_dev);
|
||||
if (route_metric >= 0)
|
||||
return route_metric;
|
||||
}
|
||||
|
||||
if ( priv->ip_ifindex
|
||||
|| !(parent_dev = nm_active_connection_get_device (NM_ACTIVE_CONNECTION (connection))))
|
||||
return NM_VPN_ROUTE_METRIC_DEFAULT;
|
||||
|
||||
return nm_device_get_ip4_route_metric (parent_dev);
|
||||
}
|
||||
|
||||
guint32
|
||||
nm_vpn_connection_get_ip6_route_metric (NMVpnConnection *connection)
|
||||
{
|
||||
NMDevice *parent_dev;
|
||||
NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (connection);
|
||||
|
||||
if (priv->ip_ifindex)
|
||||
return NM_PLATFORM_ROUTE_METRIC_DEFAULT;
|
||||
else {
|
||||
NMDevice *parent_dev = nm_active_connection_get_device (NM_ACTIVE_CONNECTION (connection));
|
||||
if (priv->connection) {
|
||||
gint64 route_metric = nm_setting_ip_config_get_route_metric (nm_connection_get_setting_ip6_config (priv->connection));
|
||||
|
||||
return nm_device_get_ip6_route_metric (parent_dev);
|
||||
if (route_metric >= 0)
|
||||
return route_metric;
|
||||
}
|
||||
|
||||
if ( priv->ip_ifindex
|
||||
|| !(parent_dev = nm_active_connection_get_device (NM_ACTIVE_CONNECTION (connection))))
|
||||
return NM_VPN_ROUTE_METRIC_DEFAULT;
|
||||
|
||||
return nm_device_get_ip6_route_metric (parent_dev);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue