core: fix matching of default metric value for static routes

When NM tries to match a generated connection to a persistent one, it
considers also the metric of static routes. However, if the field is
set to -1 (use default value for the device) on the persistent
connection, the comparison will always fail because the generated
connection contains the actual value read from kernel.

To fix the issue, modify check_possible_match() to deal correctly with
-1 and translate it to the expected value for the current device when
performing the comparison.

This allows connections with static routes and default metric to
properly be re-assumed when NM is restarted.

https://bugzilla.redhat.com/show_bug.cgi?id=1302532
This commit is contained in:
Beniamino Galvani
2016-02-01 14:16:30 +01:00
parent 8682bb7f5f
commit 08c3378f64
4 changed files with 239 additions and 20 deletions

View File

@@ -328,6 +328,8 @@ typedef gboolean (NMUtilsMatchFilterFunc) (NMConnection *connection, gpointer us
NMConnection *nm_utils_match_connection (GSList *connections,
NMConnection *original,
gboolean device_has_carrier,
gint64 default_v4_metric,
gint64 default_v6_metric,
NMUtilsMatchFilterFunc match_filter_func,
gpointer match_filter_data);