diff options
| author | Thomas Haller <thaller@redhat.com> | 2018-12-03 10:31:51 +0100 |
|---|---|---|
| committer | Thomas Haller <thaller@redhat.com> | 2018-12-11 11:30:17 +0100 |
| commit | e91ed81206c3462cac6cda30759909766dfa371b (patch) | |
| tree | 726cbeb9f83af8f4821fbb97f0bff5dfad153769 | |
| parent | 3f9bca51da856376e0de65593c17bcc6b4888489 (diff) | |
connectivity: fix determining the global connectivity state
Since we determine the connectivity state of each device individually,
the global connectivity state is an aggregate of all these states.
I am not sure about considering here devices that don't have the (best)
default route for their respective address family. But anyway.
When we aggregate the best connectivity, we chose the numerical largest
value. That is wrong, because PORTAL is numerically smaller than
LIMITED.
That means, if you have two devices, one with connectivity LIMITED and
one with connectivity PORTAL, then LIMITED wrongly wins.
Fixes: 6b7e9f9b225e81d365fd95901a88a7bc59c1eb39
https://bugzilla.redhat.com/show_bug.cgi?id=1619873
(cherry picked from commit ade753d06f4d8cac3a9c374fc1d9a409e2bce904)
(cherry picked from commit d1e98e334dd71b8fafa2512911b737adffddf569)
(cherry picked from commit 18103b00d8dd6dd99c9ff17d03cdf568a56d6720)
(cherry picked from commit 7e0938d5bda212f93e312113673f69b414713b35)
| -rw-r--r-- | src/nm-manager.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/nm-manager.c b/src/nm-manager.c index fdf7cee53d..bff2869f7c 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -2076,11 +2076,23 @@ device_connectivity_changed (NMDevice *device, NMConnectivityState state; const GSList *devices; - for (devices = priv->devices; devices; devices = devices->next) { - state = nm_device_get_connectivity_state (NM_DEVICE (devices->data)); - if (state > best_state) + best_state = nm_device_get_connectivity_state (device); + if (best_state < NM_CONNECTIVITY_FULL) { + /* FIXME: is this really correct, to considere devices that don't have + * (the best) default route for connectivity checking? */ + for (devices = priv->devices; devices; devices = devices->next) { + state = nm_device_get_connectivity_state (devices->data); + if (nm_connectivity_state_cmp (state, best_state) <= 0) + continue; best_state = state; + if (nm_connectivity_state_cmp (best_state, NM_CONNECTIVITY_FULL) >= 0) { + /* it doesn't get better than this. */ + break; + } + } } + nm_assert (best_state <= NM_CONNECTIVITY_FULL); + nm_assert (nm_connectivity_state_cmp (best_state, NM_CONNECTIVITY_FULL) <= 0); if (best_state != priv->connectivity_state) { priv->connectivity_state = best_state; |
