mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-26 05:20:08 +01:00
ethernet: make initial carrier check synchronous; require carrier for connection takeover (lp#417719)
This commit is contained in:
parent
ddce707d67
commit
0bbf8c5307
2 changed files with 24 additions and 4 deletions
|
|
@ -31,7 +31,7 @@
|
|||
#include <linux/ethtool.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
#include <net/if.h>
|
||||
#include <linux/if.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "nm-glib-compat.h"
|
||||
|
|
@ -263,6 +263,7 @@ constructor (GType type,
|
|||
caps = nm_device_get_capabilities (self);
|
||||
if (caps & NM_DEVICE_CAP_CARRIER_DETECT) {
|
||||
GError *error = NULL;
|
||||
guint32 ifflags = 0;
|
||||
|
||||
/* Only listen to netlink for cards that support carrier detect */
|
||||
priv->monitor = nm_netlink_monitor_get ();
|
||||
|
|
@ -274,9 +275,26 @@ constructor (GType type,
|
|||
G_CALLBACK (carrier_off),
|
||||
self);
|
||||
|
||||
/* Get initial link state */
|
||||
if (!nm_netlink_monitor_get_flags_sync (priv->monitor,
|
||||
priv->ifindex,
|
||||
&ifflags,
|
||||
&error)) {
|
||||
nm_warning ("couldn't get initial carrier state: (%d) %s",
|
||||
error ? error->code : -1,
|
||||
(error && error->message) ? error->message : "unknown");
|
||||
g_clear_error (&error);
|
||||
} else
|
||||
priv->carrier = !!(ifflags & IFF_LOWER_UP);
|
||||
|
||||
/* Request link state again just in case an error occurred getting the
|
||||
* initial link state.
|
||||
*/
|
||||
if (!nm_netlink_monitor_request_status (priv->monitor, &error)) {
|
||||
nm_warning ("couldn't request carrier state: %s", error ? error->message : "unknown");
|
||||
g_error_free (error);
|
||||
nm_warning ("couldn't request carrier state: (%d) %s",
|
||||
error ? error->code : -1,
|
||||
(error && error->message) ? error->message : "unknown");
|
||||
g_clear_error (&error);
|
||||
}
|
||||
} else {
|
||||
nm_info ("(%s): driver '%s' does not support carrier detection.",
|
||||
|
|
|
|||
|
|
@ -1201,6 +1201,7 @@ add_device (NMManager *self, NMDevice *device)
|
|||
NMConnection *existing = NULL;
|
||||
GHashTableIter iter;
|
||||
gpointer value;
|
||||
gboolean managed = FALSE;
|
||||
|
||||
priv->devices = g_slist_append (priv->devices, device);
|
||||
|
||||
|
|
@ -1265,13 +1266,14 @@ add_device (NMManager *self, NMDevice *device)
|
|||
TRUE,
|
||||
existing ? NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED :
|
||||
NM_DEVICE_STATE_REASON_NOW_MANAGED);
|
||||
managed = TRUE;
|
||||
}
|
||||
|
||||
nm_sysconfig_settings_device_added (priv->sys_settings, device);
|
||||
g_signal_emit (self, signals[DEVICE_ADDED], 0, device);
|
||||
|
||||
/* If the device has a connection it can assume, do that now */
|
||||
if (existing) {
|
||||
if (existing && managed && nm_device_is_available (device)) {
|
||||
const char *ac_path;
|
||||
GError *error = NULL;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue