mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-06 23:40:16 +01:00
device: add default route penalty only if concheck is enabled
If we don't have connection checking functionality just avoid adding
a penalty to the defaut route of newly activated connections.
(cherry picked from commit 2524a6f852)
This commit is contained in:
parent
aaaa35a89e
commit
5651f0cef6
3 changed files with 13 additions and 2 deletions
|
|
@ -1499,18 +1499,20 @@ nm_device_get_priority (NMDevice *self)
|
|||
static guint32
|
||||
route_metric_with_penalty (NMDevice *self, guint32 metric)
|
||||
{
|
||||
#if WITH_CONCHECK
|
||||
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
||||
const guint32 PENALTY = 20000;
|
||||
|
||||
/* Beware: for IPv6, a metric of 0 effectively means 1024.
|
||||
* Only pass a normalized IPv6 metric (nm_utils_ip6_route_metric_normalize). */
|
||||
|
||||
if (priv->connectivity_state != NM_CONNECTIVITY_FULL) {
|
||||
if ( priv->connectivity_state != NM_CONNECTIVITY_FULL
|
||||
&& nm_connectivity_check_enabled (nm_connectivity_get ())) {
|
||||
if (metric >= G_MAXUINT32 - PENALTY)
|
||||
return G_MAXUINT32;
|
||||
return metric + PENALTY;
|
||||
}
|
||||
|
||||
#endif
|
||||
return metric;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -395,6 +395,14 @@ nm_connectivity_check_finish (NMConnectivity *self,
|
|||
return (NMConnectivityState) g_simple_async_result_get_op_res_gssize (simple);
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_connectivity_check_enabled (NMConnectivity *self)
|
||||
{
|
||||
NMConnectivityPrivate *priv = NM_CONNECTIVITY_GET_PRIVATE (self);
|
||||
|
||||
return (priv->uri && priv->interval && priv->curl_mhandle);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static gboolean
|
||||
|
|
|
|||
|
|
@ -48,5 +48,6 @@ void nm_connectivity_check_async (NMConnectivity *self,
|
|||
NMConnectivityState nm_connectivity_check_finish (NMConnectivity *self,
|
||||
GAsyncResult *result,
|
||||
GError **error);
|
||||
gboolean nm_connectivity_check_enabled (NMConnectivity *self);
|
||||
|
||||
#endif /* __NETWORKMANAGER_CONNECTIVITY_H__ */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue