2008-07-09 14:05:49 +00:00
|
|
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
2005-12-31 08:21:24 +00:00
|
|
|
/* NetworkManager -- Network link manager
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
2008-06-26 18:31:52 +00:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2005-12-31 08:21:24 +00:00
|
|
|
*
|
2012-02-21 15:44:19 +01:00
|
|
|
* Copyright (C) 2005 - 2012 Red Hat, Inc.
|
2008-11-03 04:13:42 +00:00
|
|
|
* Copyright (C) 2006 - 2008 Novell, Inc.
|
2005-12-31 08:21:24 +00:00
|
|
|
*/
|
|
|
|
|
|
2010-10-08 22:45:35 -05:00
|
|
|
#include <config.h>
|
2005-12-31 08:21:24 +00:00
|
|
|
#include <glib.h>
|
|
|
|
|
#include <glib/gi18n.h>
|
|
|
|
|
#include <dbus/dbus.h>
|
|
|
|
|
#include <netinet/in.h>
|
|
|
|
|
#include <string.h>
|
2008-03-14 20:37:48 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <errno.h>
|
2012-06-01 16:48:57 +02:00
|
|
|
#include <linux/sockios.h>
|
|
|
|
|
#include <linux/ethtool.h>
|
2008-03-14 20:37:48 +00:00
|
|
|
#include <sys/ioctl.h>
|
2008-07-09 14:05:49 +00:00
|
|
|
#include <signal.h>
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
#include <sys/wait.h>
|
|
|
|
|
#include <arpa/inet.h>
|
2008-08-15 15:34:28 +00:00
|
|
|
#include <fcntl.h>
|
2011-09-23 13:46:41 +02:00
|
|
|
#include <linux/if.h>
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2013-08-29 15:37:57 -04:00
|
|
|
#include "libgsystem.h"
|
2008-12-31 18:57:36 -05:00
|
|
|
#include "nm-glib-compat.h"
|
2007-05-07 15:17:45 +00:00
|
|
|
#include "nm-device.h"
|
2005-12-31 08:21:24 +00:00
|
|
|
#include "nm-device-private.h"
|
2012-09-19 10:56:30 -04:00
|
|
|
#include "nm-device-ethernet.h"
|
2005-12-31 08:21:24 +00:00
|
|
|
#include "NetworkManagerUtils.h"
|
2013-01-21 15:12:24 +01:00
|
|
|
#include "nm-platform.h"
|
2013-05-30 16:53:23 +02:00
|
|
|
#include "nm-rdisc.h"
|
|
|
|
|
#include "nm-lndp-rdisc.h"
|
2005-12-31 08:21:24 +00:00
|
|
|
#include "nm-dhcp-manager.h"
|
2007-02-12 09:23:43 +00:00
|
|
|
#include "nm-dbus-manager.h"
|
2005-12-31 08:21:24 +00:00
|
|
|
#include "nm-utils.h"
|
2010-04-07 12:31:39 -07:00
|
|
|
#include "nm-logging.h"
|
2007-11-07 16:06:43 +00:00
|
|
|
#include "nm-setting-ip4-config.h"
|
2009-07-29 12:12:41 -04:00
|
|
|
#include "nm-setting-ip6-config.h"
|
2007-12-31 17:05:25 +00:00
|
|
|
#include "nm-setting-connection.h"
|
2008-05-29 20:58:52 +00:00
|
|
|
#include "nm-dnsmasq-manager.h"
|
2008-07-17 17:04:13 +00:00
|
|
|
#include "nm-dhcp4-config.h"
|
2013-05-09 10:24:08 -04:00
|
|
|
#include "nm-rfkill-manager.h"
|
2011-10-07 15:58:08 +02:00
|
|
|
#include "nm-firewall-manager.h"
|
2011-11-18 00:34:08 -06:00
|
|
|
#include "nm-properties-changed-signal.h"
|
2012-02-08 12:56:52 -05:00
|
|
|
#include "nm-enum-types.h"
|
2012-02-09 16:32:48 -06:00
|
|
|
#include "nm-settings-connection.h"
|
2012-05-02 10:28:16 -05:00
|
|
|
#include "nm-connection-provider.h"
|
2012-05-21 14:10:05 +02:00
|
|
|
#include "nm-posix-signals.h"
|
2012-06-01 16:53:23 -05:00
|
|
|
#include "nm-manager-auth.h"
|
2012-08-01 11:16:48 -06:00
|
|
|
#include "nm-dbus-glib-types.h"
|
2012-06-03 19:32:16 -05:00
|
|
|
#include "nm-dispatcher.h"
|
2013-03-20 09:48:24 -04:00
|
|
|
#include "nm-config-device.h"
|
2013-03-19 10:24:35 -04:00
|
|
|
#include "nm-config.h"
|
2013-04-04 10:20:24 -04:00
|
|
|
#include "nm-platform.h"
|
2011-11-18 00:34:08 -06:00
|
|
|
|
|
|
|
|
static void impl_device_disconnect (NMDevice *device, DBusGMethodInvocation *context);
|
|
|
|
|
|
2013-05-08 16:52:36 -04:00
|
|
|
#include "nm-device-glue.h"
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2012-01-29 22:40:37 +01:00
|
|
|
#define DBUS_G_TYPE_UINT_STRUCT (dbus_g_type_get_struct ("GValueArray", G_TYPE_UINT, G_TYPE_UINT, G_TYPE_INVALID))
|
|
|
|
|
|
2013-05-22 16:12:23 +02:00
|
|
|
/* default to installed helper, but can be modified for testing */
|
|
|
|
|
const char *nm_device_autoipd_helper_path = LIBEXECDIR "/nm-avahi-autoipd.action";
|
|
|
|
|
|
2011-11-18 00:05:37 -06:00
|
|
|
/***********************************************************/
|
|
|
|
|
#define NM_DEVICE_ERROR (nm_device_error_quark ())
|
|
|
|
|
|
|
|
|
|
static GQuark
|
|
|
|
|
nm_device_error_quark (void)
|
|
|
|
|
{
|
|
|
|
|
static GQuark quark = 0;
|
|
|
|
|
if (!quark)
|
|
|
|
|
quark = g_quark_from_static_string ("nm-device-error");
|
|
|
|
|
return quark;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***********************************************************/
|
|
|
|
|
|
2009-07-15 17:22:10 -04:00
|
|
|
enum {
|
2011-11-18 00:09:37 -06:00
|
|
|
STATE_CHANGED,
|
2009-07-15 17:22:10 -04:00
|
|
|
AUTOCONNECT_ALLOWED,
|
2012-06-01 15:27:39 -05:00
|
|
|
AUTH_REQUEST,
|
2012-05-29 09:56:50 -05:00
|
|
|
IP4_CONFIG_CHANGED,
|
|
|
|
|
IP6_CONFIG_CHANGED,
|
2009-07-15 17:22:10 -04:00
|
|
|
LAST_SIGNAL,
|
|
|
|
|
};
|
|
|
|
|
static guint signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
|
2011-11-18 00:34:08 -06:00
|
|
|
enum {
|
|
|
|
|
PROP_0,
|
2013-05-29 12:57:13 -03:00
|
|
|
PROP_PLATFORM_DEVICE,
|
2011-11-18 00:34:08 -06:00
|
|
|
PROP_UDI,
|
|
|
|
|
PROP_IFACE,
|
|
|
|
|
PROP_IP_IFACE,
|
|
|
|
|
PROP_DRIVER,
|
2012-06-01 16:48:57 +02:00
|
|
|
PROP_DRIVER_VERSION,
|
|
|
|
|
PROP_FIRMWARE_VERSION,
|
2011-11-18 00:34:08 -06:00
|
|
|
PROP_CAPABILITIES,
|
2013-05-07 10:23:44 -04:00
|
|
|
PROP_CARRIER,
|
2011-11-18 00:34:08 -06:00
|
|
|
PROP_IP4_ADDRESS,
|
|
|
|
|
PROP_IP4_CONFIG,
|
|
|
|
|
PROP_DHCP4_CONFIG,
|
|
|
|
|
PROP_IP6_CONFIG,
|
|
|
|
|
PROP_DHCP6_CONFIG,
|
|
|
|
|
PROP_STATE,
|
2012-01-29 22:40:37 +01:00
|
|
|
PROP_STATE_REASON,
|
2011-11-18 00:34:08 -06:00
|
|
|
PROP_ACTIVE_CONNECTION,
|
|
|
|
|
PROP_DEVICE_TYPE,
|
|
|
|
|
PROP_MANAGED,
|
2012-05-14 15:32:54 +02:00
|
|
|
PROP_AUTOCONNECT,
|
2011-11-18 00:34:08 -06:00
|
|
|
PROP_FIRMWARE_MISSING,
|
|
|
|
|
PROP_TYPE_DESC,
|
|
|
|
|
PROP_RFKILL_TYPE,
|
|
|
|
|
PROP_IFINDEX,
|
2012-08-01 11:16:48 -06:00
|
|
|
PROP_AVAILABLE_CONNECTIONS,
|
2013-01-24 17:47:59 -06:00
|
|
|
PROP_IS_MASTER,
|
2013-05-01 09:28:16 -04:00
|
|
|
PROP_HW_ADDRESS,
|
2013-08-13 17:45:34 -04:00
|
|
|
PROP_HAS_PENDING_ACTION,
|
2011-11-18 00:34:08 -06:00
|
|
|
LAST_PROP
|
|
|
|
|
};
|
|
|
|
|
|
2012-05-23 13:07:58 +02:00
|
|
|
#define DEFAULT_AUTOCONNECT TRUE
|
|
|
|
|
|
2011-11-18 00:34:08 -06:00
|
|
|
/***********************************************************/
|
|
|
|
|
|
2013-03-20 09:48:24 -04:00
|
|
|
static void nm_device_config_device_interface_init (NMConfigDeviceInterface *iface);
|
|
|
|
|
|
|
|
|
|
G_DEFINE_ABSTRACT_TYPE_WITH_CODE (NMDevice, nm_device, G_TYPE_OBJECT,
|
|
|
|
|
G_IMPLEMENT_INTERFACE (NM_TYPE_CONFIG_DEVICE, nm_device_config_device_interface_init))
|
2011-11-18 00:34:08 -06:00
|
|
|
|
2005-12-31 08:21:24 +00:00
|
|
|
#define NM_DEVICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE, NMDevicePrivate))
|
|
|
|
|
|
2011-10-09 23:48:13 -05:00
|
|
|
typedef enum {
|
|
|
|
|
IP_NONE = 0,
|
2012-11-15 17:52:24 -06:00
|
|
|
IP_WAIT,
|
2011-10-09 23:48:13 -05:00
|
|
|
IP_CONF,
|
2013-06-27 17:51:24 +02:00
|
|
|
IP_DONE,
|
|
|
|
|
IP_FAIL
|
2011-10-09 23:48:13 -05:00
|
|
|
} IpState;
|
|
|
|
|
|
2011-12-08 11:46:58 -06:00
|
|
|
typedef struct {
|
|
|
|
|
NMDeviceState state;
|
|
|
|
|
NMDeviceStateReason reason;
|
|
|
|
|
guint id;
|
|
|
|
|
} QueuedState;
|
|
|
|
|
|
2012-11-14 14:05:30 -06:00
|
|
|
typedef struct {
|
|
|
|
|
NMDevice *slave;
|
|
|
|
|
gboolean enslaved;
|
|
|
|
|
guint watch_id;
|
|
|
|
|
} SlaveInfo;
|
|
|
|
|
|
2013-06-11 17:05:49 -05:00
|
|
|
typedef struct {
|
|
|
|
|
guint log_domain;
|
|
|
|
|
guint timeout;
|
|
|
|
|
guint watch;
|
|
|
|
|
GPid pid;
|
|
|
|
|
} PingInfo;
|
|
|
|
|
|
2009-07-07 14:34:01 -04:00
|
|
|
typedef struct {
|
|
|
|
|
gboolean disposed;
|
|
|
|
|
gboolean initialized;
|
2013-05-20 16:15:37 -03:00
|
|
|
gboolean in_state_changed;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
NMDeviceState state;
|
2012-01-29 22:40:37 +01:00
|
|
|
NMDeviceStateReason state_reason;
|
2011-12-08 11:46:58 -06:00
|
|
|
QueuedState queued_state;
|
2013-04-04 10:20:24 -04:00
|
|
|
guint queued_ip_config_id;
|
2013-08-13 17:45:34 -04:00
|
|
|
guint pending_actions;
|
2007-02-05 12:14:09 +00:00
|
|
|
|
2009-07-07 14:34:01 -04:00
|
|
|
char * udi;
|
|
|
|
|
char * path;
|
|
|
|
|
char * iface; /* may change, could be renamed by user */
|
2010-04-21 14:58:25 -07:00
|
|
|
int ifindex;
|
2013-08-22 19:15:05 +02:00
|
|
|
gboolean is_software;
|
2009-07-07 14:34:01 -04:00
|
|
|
char * ip_iface;
|
2010-04-21 14:58:25 -07:00
|
|
|
int ip_ifindex;
|
2009-07-07 14:34:01 -04:00
|
|
|
NMDeviceType type;
|
|
|
|
|
char * type_desc;
|
|
|
|
|
guint32 capabilities;
|
|
|
|
|
char * driver;
|
2012-06-01 16:48:57 +02:00
|
|
|
char * driver_version;
|
|
|
|
|
char * firmware_version;
|
2010-03-25 11:36:19 -07:00
|
|
|
RfKillType rfkill_type;
|
2010-05-25 10:52:25 -07:00
|
|
|
gboolean firmware_missing;
|
2012-08-01 11:16:48 -06:00
|
|
|
GHashTable * available_connections;
|
2013-05-01 09:28:16 -04:00
|
|
|
guint8 hw_addr[NM_UTILS_HWADDR_LEN_MAX];
|
|
|
|
|
guint hw_addr_len;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2013-04-24 10:40:58 -04:00
|
|
|
gboolean manager_managed; /* whether managed by NMManager or not */
|
|
|
|
|
gboolean default_unmanaged; /* whether unmanaged by default */
|
2013-08-05 10:03:41 +02:00
|
|
|
gboolean is_nm_owned; /* whether the device is a device owned and created by NM */
|
2013-08-07 11:41:40 +02:00
|
|
|
guint delete_on_deactivate_id; /* event id for scheduled link_delete action (g_idle_add) */
|
2013-04-24 10:40:58 -04:00
|
|
|
|
2009-07-07 14:34:01 -04:00
|
|
|
guint32 ip4_address;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2009-07-07 14:34:01 -04:00
|
|
|
NMActRequest * act_request;
|
2007-01-04 12:06:26 +00:00
|
|
|
guint act_source_id;
|
2009-07-07 14:34:01 -04:00
|
|
|
gpointer act_source_func;
|
2009-07-29 12:12:41 -04:00
|
|
|
guint act_source6_id;
|
|
|
|
|
gpointer act_source6_func;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2013-05-07 10:23:44 -04:00
|
|
|
/* Link stuff */
|
|
|
|
|
guint link_connected_id;
|
|
|
|
|
guint link_disconnected_id;
|
|
|
|
|
guint carrier_defer_id;
|
|
|
|
|
gboolean carrier;
|
|
|
|
|
gboolean ignore_carrier;
|
|
|
|
|
|
2010-01-13 18:06:05 -08:00
|
|
|
/* Generic DHCP stuff */
|
2010-01-13 17:59:54 -08:00
|
|
|
NMDHCPManager * dhcp_manager;
|
2010-01-13 18:06:05 -08:00
|
|
|
guint32 dhcp_timeout;
|
|
|
|
|
GByteArray * dhcp_anycast_address;
|
2010-01-13 17:59:54 -08:00
|
|
|
|
2009-07-29 12:12:41 -04:00
|
|
|
/* IP4 configuration info */
|
2013-08-01 10:34:46 -05:00
|
|
|
NMIP4Config * ip4_config; /* Combined config from VPN, settings, and device */
|
2011-10-09 23:48:13 -05:00
|
|
|
IpState ip4_state;
|
2013-08-01 10:34:46 -05:00
|
|
|
NMIP4Config * dev_ip4_config; /* Config from DHCP, PPP, LLv4, etc */
|
2013-08-01 15:44:53 -05:00
|
|
|
NMIP4Config * ext_ip4_config; /* Stuff added outside NM */
|
2013-08-01 10:34:46 -05:00
|
|
|
|
|
|
|
|
/* DHCPv4 tracking */
|
2010-01-12 22:09:28 -08:00
|
|
|
NMDHCPClient * dhcp4_client;
|
2010-01-13 18:06:05 -08:00
|
|
|
gulong dhcp4_state_sigid;
|
|
|
|
|
gulong dhcp4_timeout_sigid;
|
2009-07-07 14:34:01 -04:00
|
|
|
NMDHCP4Config * dhcp4_config;
|
2013-08-01 10:59:42 -05:00
|
|
|
NMIP4Config * vpn4_config; /* routes added by a VPN which uses this device */
|
2008-05-29 20:58:52 +00:00
|
|
|
|
2013-06-11 17:05:49 -05:00
|
|
|
PingInfo gw_ping;
|
|
|
|
|
|
2008-07-09 14:05:49 +00:00
|
|
|
/* dnsmasq stuff for shared connections */
|
2009-07-07 14:34:01 -04:00
|
|
|
NMDnsMasqManager *dnsmasq_manager;
|
|
|
|
|
gulong dnsmasq_state_id;
|
2008-07-09 14:05:49 +00:00
|
|
|
|
2011-10-07 15:58:08 +02:00
|
|
|
/* Firewall Manager */
|
|
|
|
|
NMFirewallManager *fw_manager;
|
|
|
|
|
DBusGProxyCall *fw_call;
|
|
|
|
|
|
2008-07-09 14:05:49 +00:00
|
|
|
/* avahi-autoipd stuff */
|
2009-07-07 14:34:01 -04:00
|
|
|
GPid aipd_pid;
|
|
|
|
|
guint aipd_watch;
|
|
|
|
|
guint aipd_timeout;
|
2009-07-29 12:12:41 -04:00
|
|
|
|
|
|
|
|
/* IP6 configuration info */
|
2009-07-30 13:50:42 -04:00
|
|
|
NMIP6Config * ip6_config;
|
2011-10-09 23:48:13 -05:00
|
|
|
IpState ip6_state;
|
2013-08-01 10:59:42 -05:00
|
|
|
NMIP6Config * vpn6_config; /* routes added by a VPN which uses this device */
|
2011-10-21 14:25:35 -05:00
|
|
|
|
2013-05-30 16:53:23 +02:00
|
|
|
NMRDisc * rdisc;
|
|
|
|
|
gulong rdisc_config_changed_sigid;
|
2011-10-21 14:25:35 -05:00
|
|
|
/* IP6 config from autoconf */
|
|
|
|
|
NMIP6Config * ac_ip6_config;
|
2009-09-16 13:18:24 +02:00
|
|
|
|
2010-05-03 03:42:43 -07:00
|
|
|
char * ip6_accept_ra_path;
|
2011-07-12 09:08:04 +02:00
|
|
|
gint32 ip6_accept_ra_save;
|
2010-05-03 03:42:43 -07:00
|
|
|
|
2012-02-21 15:44:19 +01:00
|
|
|
/* IPv6 privacy extensions (RFC4941) */
|
|
|
|
|
char * ip6_privacy_tempaddr_path;
|
|
|
|
|
gint32 ip6_privacy_tempaddr_save;
|
|
|
|
|
|
2010-01-14 00:45:10 -08:00
|
|
|
NMDHCPClient * dhcp6_client;
|
2013-05-30 16:53:23 +02:00
|
|
|
NMRDiscDHCPLevel dhcp6_mode;
|
2010-01-14 00:45:10 -08:00
|
|
|
gulong dhcp6_state_sigid;
|
|
|
|
|
gulong dhcp6_timeout_sigid;
|
|
|
|
|
NMDHCP6Config * dhcp6_config;
|
2011-10-21 14:25:35 -05:00
|
|
|
/* IP6 config from DHCP */
|
|
|
|
|
NMIP6Config * dhcp6_ip6_config;
|
2010-01-14 00:45:10 -08:00
|
|
|
|
2012-05-14 15:32:54 +02:00
|
|
|
/* allow autoconnect feature */
|
|
|
|
|
gboolean autoconnect;
|
2011-10-18 13:48:47 +02:00
|
|
|
|
2013-07-25 15:36:45 +02:00
|
|
|
/* master interface for bridge/bond/team slave */
|
2012-11-14 14:05:30 -06:00
|
|
|
NMDevice * master;
|
|
|
|
|
gboolean enslaved;
|
|
|
|
|
|
2013-01-24 17:47:59 -06:00
|
|
|
/* slave management */
|
|
|
|
|
gboolean is_master;
|
|
|
|
|
GSList * slaves; /* list of SlaveInfo */
|
2012-05-02 10:28:16 -05:00
|
|
|
|
|
|
|
|
NMConnectionProvider *con_provider;
|
2012-08-01 11:16:48 -06:00
|
|
|
|
|
|
|
|
/* connection provider signals for available connections property */
|
|
|
|
|
guint cp_added_id;
|
|
|
|
|
guint cp_loaded_id;
|
|
|
|
|
guint cp_removed_id;
|
|
|
|
|
guint cp_updated_id;
|
2012-11-12 13:29:06 -05:00
|
|
|
|
2009-07-07 14:34:01 -04:00
|
|
|
} NMDevicePrivate;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2009-08-05 18:03:09 -04:00
|
|
|
static gboolean nm_device_set_ip4_config (NMDevice *dev,
|
|
|
|
|
NMIP4Config *config,
|
2013-06-26 00:16:45 +02:00
|
|
|
gboolean commit,
|
2009-08-05 18:03:09 -04:00
|
|
|
NMDeviceStateReason *reason);
|
2013-08-01 10:34:46 -05:00
|
|
|
static gboolean ip4_config_merge_and_apply (NMDevice *self,
|
|
|
|
|
NMIP4Config *config,
|
2013-08-01 15:44:53 -05:00
|
|
|
gboolean commit,
|
2013-08-01 10:34:46 -05:00
|
|
|
NMDeviceStateReason *out_reason);
|
|
|
|
|
|
2009-08-05 18:03:09 -04:00
|
|
|
static gboolean nm_device_set_ip6_config (NMDevice *dev,
|
|
|
|
|
NMIP6Config *config,
|
2013-06-26 00:16:45 +02:00
|
|
|
gboolean commit,
|
2009-08-05 18:03:09 -04:00
|
|
|
NMDeviceStateReason *reason);
|
2008-11-07 13:57:39 +00:00
|
|
|
|
2011-11-09 23:05:18 -06:00
|
|
|
static gboolean nm_device_activate_ip6_config_commit (gpointer user_data);
|
|
|
|
|
|
2012-09-27 12:12:15 -04:00
|
|
|
static gboolean check_connection_available (NMDevice *device, NMConnection *connection);
|
2012-08-01 11:16:48 -06:00
|
|
|
|
2013-02-12 17:59:37 -05:00
|
|
|
static gboolean spec_match_list (NMDevice *device, const GSList *specs);
|
|
|
|
|
|
2012-08-01 11:16:48 -06:00
|
|
|
static void _clear_available_connections (NMDevice *device, gboolean do_signal);
|
|
|
|
|
|
2011-01-05 16:23:00 -06:00
|
|
|
static void dhcp4_cleanup (NMDevice *self, gboolean stop, gboolean release);
|
2010-05-03 01:19:54 -07:00
|
|
|
|
2011-09-19 14:19:53 +02:00
|
|
|
static const char *reason_to_string (NMDeviceStateReason reason);
|
|
|
|
|
|
2013-06-11 17:05:49 -05:00
|
|
|
static void ip_check_gw_ping_cleanup (NMDevice *self);
|
|
|
|
|
|
2012-08-01 11:16:48 -06:00
|
|
|
static void cp_connection_added (NMConnectionProvider *cp, NMConnection *connection, gpointer user_data);
|
|
|
|
|
static void cp_connections_loaded (NMConnectionProvider *cp, NMConnection *connection, gpointer user_data);
|
|
|
|
|
static void cp_connection_removed (NMConnectionProvider *cp, NMConnection *connection, gpointer user_data);
|
|
|
|
|
static void cp_connection_updated (NMConnectionProvider *cp, NMConnection *connection, gpointer user_data);
|
|
|
|
|
|
2012-11-14 14:05:30 -06:00
|
|
|
static const char *state_to_string (NMDeviceState state);
|
|
|
|
|
|
2013-08-02 18:51:06 +02:00
|
|
|
static void link_changed_cb (NMPlatform *platform, int ifindex, NMPlatformLink *info, NMPlatformReason reason, NMDevice *device);
|
2013-05-07 10:23:44 -04:00
|
|
|
static void check_carrier (NMDevice *device);
|
2012-11-12 13:29:06 -05:00
|
|
|
|
2013-04-04 10:20:24 -04:00
|
|
|
static void nm_device_queued_ip_config_change_clear (NMDevice *self);
|
|
|
|
|
static void update_ip_config (NMDevice *self);
|
2013-08-02 18:51:06 +02:00
|
|
|
static void device_ip_changed (NMPlatform *platform, int ifindex, gpointer platform_object, NMPlatformReason reason, gpointer user_data);
|
2013-04-04 10:20:24 -04:00
|
|
|
|
|
|
|
|
static const char const *platform_ip_signals[] = {
|
|
|
|
|
NM_PLATFORM_IP4_ADDRESS_ADDED,
|
|
|
|
|
NM_PLATFORM_IP4_ADDRESS_CHANGED,
|
|
|
|
|
NM_PLATFORM_IP4_ADDRESS_REMOVED,
|
|
|
|
|
NM_PLATFORM_IP4_ROUTE_ADDED,
|
|
|
|
|
NM_PLATFORM_IP4_ROUTE_CHANGED,
|
|
|
|
|
NM_PLATFORM_IP4_ROUTE_REMOVED,
|
|
|
|
|
NM_PLATFORM_IP6_ADDRESS_ADDED,
|
|
|
|
|
NM_PLATFORM_IP6_ADDRESS_CHANGED,
|
|
|
|
|
NM_PLATFORM_IP6_ADDRESS_REMOVED,
|
|
|
|
|
NM_PLATFORM_IP6_ROUTE_ADDED,
|
|
|
|
|
NM_PLATFORM_IP6_ROUTE_CHANGED,
|
|
|
|
|
NM_PLATFORM_IP6_ROUTE_REMOVED,
|
|
|
|
|
};
|
|
|
|
|
static const int n_platform_ip_signals = G_N_ELEMENTS (platform_ip_signals);
|
|
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
static void
|
2009-07-07 14:34:01 -04:00
|
|
|
nm_device_init (NMDevice *self)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
2009-07-07 14:34:01 -04:00
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
priv->type = NM_DEVICE_TYPE_UNKNOWN;
|
2013-05-17 10:58:38 -05:00
|
|
|
priv->capabilities = NM_DEVICE_CAP_NM_SUPPORTED;
|
2009-07-07 14:34:01 -04:00
|
|
|
priv->state = NM_DEVICE_STATE_UNMANAGED;
|
2012-01-29 22:40:37 +01:00
|
|
|
priv->state_reason = NM_DEVICE_STATE_REASON_NONE;
|
2009-07-15 13:48:28 -04:00
|
|
|
priv->dhcp_timeout = 0;
|
2010-03-25 11:36:19 -07:00
|
|
|
priv->rfkill_type = RFKILL_TYPE_UNKNOWN;
|
2012-05-23 13:07:58 +02:00
|
|
|
priv->autoconnect = DEFAULT_AUTOCONNECT;
|
2012-08-01 11:16:48 -06:00
|
|
|
priv->available_connections = g_hash_table_new_full (g_direct_hash, g_direct_equal, g_object_unref, NULL);
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
2010-05-03 03:42:43 -07:00
|
|
|
static void
|
|
|
|
|
update_accept_ra_save (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv;
|
|
|
|
|
const char *ip_iface;
|
|
|
|
|
char *new_path;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (NM_IS_DEVICE (self));
|
|
|
|
|
|
|
|
|
|
priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
ip_iface = nm_device_get_ip_iface (self);
|
|
|
|
|
|
|
|
|
|
new_path = g_strdup_printf ("/proc/sys/net/ipv6/conf/%s/accept_ra", ip_iface);
|
|
|
|
|
g_assert (new_path);
|
|
|
|
|
|
|
|
|
|
if (priv->ip6_accept_ra_path) {
|
|
|
|
|
/* If the IP iface is different from before, use the new value */
|
|
|
|
|
if (!strcmp (new_path, priv->ip6_accept_ra_path)) {
|
|
|
|
|
g_free (new_path);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
g_free (priv->ip6_accept_ra_path);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Grab the original value of "accept_ra" so we can restore it when NM exits */
|
|
|
|
|
priv->ip6_accept_ra_path = new_path;
|
2011-07-12 09:08:04 +02:00
|
|
|
if (!nm_utils_get_proc_sys_net_value_with_bounds (priv->ip6_accept_ra_path,
|
|
|
|
|
ip_iface,
|
|
|
|
|
&priv->ip6_accept_ra_save,
|
2013-02-19 17:38:11 -06:00
|
|
|
0, 2)) {
|
2010-05-03 03:42:43 -07:00
|
|
|
g_free (priv->ip6_accept_ra_path);
|
|
|
|
|
priv->ip6_accept_ra_path = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-21 15:44:19 +01:00
|
|
|
static void
|
|
|
|
|
update_ip6_privacy_save (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv;
|
|
|
|
|
const char *ip_iface;
|
|
|
|
|
char *new_path;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (NM_IS_DEVICE (self));
|
|
|
|
|
|
|
|
|
|
priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
ip_iface = nm_device_get_ip_iface (self);
|
|
|
|
|
|
|
|
|
|
new_path = g_strdup_printf ("/proc/sys/net/ipv6/conf/%s/use_tempaddr", ip_iface);
|
|
|
|
|
g_assert (new_path);
|
|
|
|
|
|
|
|
|
|
if (priv->ip6_privacy_tempaddr_path) {
|
|
|
|
|
/* If the IP iface is different from before, use the new value */
|
|
|
|
|
if (!strcmp (new_path, priv->ip6_privacy_tempaddr_path)) {
|
|
|
|
|
g_free (new_path);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
g_free (priv->ip6_privacy_tempaddr_path);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Grab the original value of "use_tempaddr" so we can restore it when NM exits */
|
|
|
|
|
priv->ip6_privacy_tempaddr_path = new_path;
|
|
|
|
|
if (!nm_utils_get_proc_sys_net_value (priv->ip6_privacy_tempaddr_path,
|
|
|
|
|
ip_iface,
|
|
|
|
|
&priv->ip6_privacy_tempaddr_save)) {
|
|
|
|
|
g_free (priv->ip6_privacy_tempaddr_path);
|
|
|
|
|
priv->ip6_privacy_tempaddr_path = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-01 16:48:57 +02:00
|
|
|
/*
|
|
|
|
|
* Get driver info from SIOCETHTOOL ioctl() for 'iface'
|
|
|
|
|
* Returns driver and firmware versions to 'driver_version and' 'firmware_version'
|
|
|
|
|
*/
|
|
|
|
|
static gboolean
|
|
|
|
|
device_get_driver_info (const char *iface, char **driver_version, char **firmware_version)
|
|
|
|
|
{
|
|
|
|
|
struct ethtool_drvinfo drvinfo;
|
|
|
|
|
struct ifreq req;
|
|
|
|
|
int fd;
|
|
|
|
|
|
|
|
|
|
fd = socket (PF_INET, SOCK_DGRAM, 0);
|
|
|
|
|
if (fd < 0) {
|
|
|
|
|
nm_log_warn (LOGD_HW, "couldn't open control socket.");
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Get driver and firmware version info */
|
2012-09-03 16:16:40 +02:00
|
|
|
memset (&drvinfo, 0, sizeof (drvinfo));
|
2012-06-01 16:48:57 +02:00
|
|
|
memset (&req, 0, sizeof (struct ifreq));
|
|
|
|
|
strncpy (req.ifr_name, iface, IFNAMSIZ);
|
|
|
|
|
drvinfo.cmd = ETHTOOL_GDRVINFO;
|
|
|
|
|
req.ifr_data = &drvinfo;
|
|
|
|
|
|
|
|
|
|
errno = 0;
|
|
|
|
|
if (ioctl (fd, SIOCETHTOOL, &req) < 0) {
|
|
|
|
|
nm_log_dbg (LOGD_HW, "SIOCETHTOOL ioctl() failed: cmd=ETHTOOL_GDRVINFO, iface=%s, errno=%d",
|
|
|
|
|
iface, errno);
|
|
|
|
|
close (fd);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
if (driver_version)
|
|
|
|
|
*driver_version = g_strdup (drvinfo.version);
|
|
|
|
|
if (firmware_version)
|
|
|
|
|
*firmware_version = g_strdup (drvinfo.fw_version);
|
|
|
|
|
|
|
|
|
|
close (fd);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-07 10:23:44 -04:00
|
|
|
static gboolean
|
|
|
|
|
device_has_capability (NMDevice *device, NMDeviceCapabilities caps)
|
|
|
|
|
{
|
|
|
|
|
return !!(NM_DEVICE_GET_PRIVATE (device)->capabilities & caps);
|
|
|
|
|
}
|
|
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
static GObject*
|
|
|
|
|
constructor (GType type,
|
2012-06-01 16:48:57 +02:00
|
|
|
guint n_construct_params,
|
|
|
|
|
GObjectConstructParam *construct_params)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
2007-02-05 12:14:09 +00:00
|
|
|
GObject *object;
|
|
|
|
|
NMDevice *dev;
|
2007-03-02 Tambet Ingo <tambet@ximian.com>
* libnm-glib/nm-device-802-11-wireless.c: Cache networks (bssids) list.
We get signalled when it changes.
* libnm-glib/nm-client.c: Cache NMState and device list, we get signalled
when it changes.
* libnm-glib/nm-device.c: Cache the device state property.
* libnm-glib/nm-access-point.c: Cache the strength property.
* src/nm-device-802-11-wireless.c: Fix wireless device scanning scheduler.
The new algorithm is to start from SCAN_INTERVAL_MIN (currently defined as 0)
and add a SCAN_INTERVAL_STEP (currently 20 seconds) with each successful scan
until SCAN_INTERVAL_MAX (currently 120 seconds) is reached. Do not scan while
the device is down, activating, or activated (in case of A/B/G cards).
Remove some old dead ifdef'ed out code that used to configure wireless devices,
it's all done through supplicant now.
* src/supplicant-manager/nm-supplicant-interface.c: Fix the reference
counting issues with pending calls which caused leaks and crashes when
interface was removed (now that the interface actually gets removed).
* src/nm-call-store.c: Make a copy of data before running a foreach
with user callback on it - The most common usage pattern is to cancel
(and thus remove) all pending calls with foreach which would modify
the hash table we're iterating over.
* src/nm-manager.c: When a device is added, make sure it is "up". When
it's removed or disabled due to disabling wireless or networking, bring
it down.
* include/NetworkManager.h: Add new device state NM_DEVICE_STATE_DOWN.
* src/nm-device-802-11-wireless.c:
* src/nm-device-802-3-ethernet.c:
* src/nm-device.c:
- Remove "init" virtual function, all gobjects have a place for that
already (constructor).
- Replace "start" virtual function with "bring_up", devices can be
brought up and down more than just on startup now.
- Add "is_up" virtual function.
- Implement one way to bring a device down instead of previous 4 different
ways, each of witch did something different.
* src/NetworkManagerUtils.c (nm_dev_sock_open): This doesn't need an NMDevice,
all it needs is the device interface.
Get rid of NMData.dev_list (3 members to go).
Get rif of NMData in a lot of places.
* gnome/libnm_glib/libnm_glib.c: Make it compile again.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2395 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-03-02 09:30:48 +00:00
|
|
|
NMDevicePrivate *priv;
|
2013-08-05 17:15:07 -04:00
|
|
|
NMPlatform *platform;
|
|
|
|
|
int i;
|
2013-08-05 16:39:20 -05:00
|
|
|
static guint32 id = 0;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
object = G_OBJECT_CLASS (nm_device_parent_class)->constructor (type,
|
2012-06-01 16:48:57 +02:00
|
|
|
n_construct_params,
|
|
|
|
|
construct_params);
|
2007-02-05 12:14:09 +00:00
|
|
|
if (!object)
|
|
|
|
|
return NULL;
|
2006-01-19 18:00:48 +00:00
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
dev = NM_DEVICE (object);
|
2007-03-02 Tambet Ingo <tambet@ximian.com>
* libnm-glib/nm-device-802-11-wireless.c: Cache networks (bssids) list.
We get signalled when it changes.
* libnm-glib/nm-client.c: Cache NMState and device list, we get signalled
when it changes.
* libnm-glib/nm-device.c: Cache the device state property.
* libnm-glib/nm-access-point.c: Cache the strength property.
* src/nm-device-802-11-wireless.c: Fix wireless device scanning scheduler.
The new algorithm is to start from SCAN_INTERVAL_MIN (currently defined as 0)
and add a SCAN_INTERVAL_STEP (currently 20 seconds) with each successful scan
until SCAN_INTERVAL_MAX (currently 120 seconds) is reached. Do not scan while
the device is down, activating, or activated (in case of A/B/G cards).
Remove some old dead ifdef'ed out code that used to configure wireless devices,
it's all done through supplicant now.
* src/supplicant-manager/nm-supplicant-interface.c: Fix the reference
counting issues with pending calls which caused leaks and crashes when
interface was removed (now that the interface actually gets removed).
* src/nm-call-store.c: Make a copy of data before running a foreach
with user callback on it - The most common usage pattern is to cancel
(and thus remove) all pending calls with foreach which would modify
the hash table we're iterating over.
* src/nm-manager.c: When a device is added, make sure it is "up". When
it's removed or disabled due to disabling wireless or networking, bring
it down.
* include/NetworkManager.h: Add new device state NM_DEVICE_STATE_DOWN.
* src/nm-device-802-11-wireless.c:
* src/nm-device-802-3-ethernet.c:
* src/nm-device.c:
- Remove "init" virtual function, all gobjects have a place for that
already (constructor).
- Replace "start" virtual function with "bring_up", devices can be
brought up and down more than just on startup now.
- Add "is_up" virtual function.
- Implement one way to bring a device down instead of previous 4 different
ways, each of witch did something different.
* src/NetworkManagerUtils.c (nm_dev_sock_open): This doesn't need an NMDevice,
all it needs is the device interface.
Get rid of NMData.dev_list (3 members to go).
Get rif of NMData in a lot of places.
* gnome/libnm_glib/libnm_glib.c: Make it compile again.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2395 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-03-02 09:30:48 +00:00
|
|
|
priv = NM_DEVICE_GET_PRIVATE (dev);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-11-29 14:38:07 +00:00
|
|
|
if (!priv->iface) {
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_err (LOGD_DEVICE, "No device interface provided, ignoring");
|
2007-08-26 15:55:27 +00:00
|
|
|
goto error;
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-05 16:39:20 -05:00
|
|
|
if (!priv->udi) {
|
|
|
|
|
/* Use a placeholder UDI until we get a real one */
|
|
|
|
|
priv->udi = g_strdup_printf ("/virtual/device/placeholder/%d", id++);
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-17 10:58:38 -05:00
|
|
|
if (NM_DEVICE_GET_CLASS (dev)->get_generic_capabilities)
|
|
|
|
|
priv->capabilities |= NM_DEVICE_GET_CLASS (dev)->get_generic_capabilities (dev);
|
2006-01-02 02:50:47 +00:00
|
|
|
|
2010-01-13 17:59:54 -08:00
|
|
|
priv->dhcp_manager = nm_dhcp_manager_get ();
|
|
|
|
|
|
2011-10-07 15:58:08 +02:00
|
|
|
priv->fw_manager = nm_firewall_manager_get ();
|
|
|
|
|
|
2012-06-01 16:48:57 +02:00
|
|
|
device_get_driver_info (priv->iface, &priv->driver_version, &priv->firmware_version);
|
|
|
|
|
|
2010-05-03 03:42:43 -07:00
|
|
|
update_accept_ra_save (dev);
|
2012-02-21 15:44:19 +01:00
|
|
|
update_ip6_privacy_save (dev);
|
2013-04-04 10:20:24 -04:00
|
|
|
update_ip_config (dev);
|
2010-05-03 03:42:43 -07:00
|
|
|
|
2013-08-05 17:15:07 -04:00
|
|
|
/* Watch for external IP config changes */
|
|
|
|
|
platform = nm_platform_get ();
|
|
|
|
|
for (i = 0; i < n_platform_ip_signals; i++) {
|
|
|
|
|
g_signal_connect (platform, platform_ip_signals[i],
|
|
|
|
|
G_CALLBACK (device_ip_changed), dev);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_signal_connect (platform, NM_PLATFORM_LINK_CHANGED,
|
|
|
|
|
G_CALLBACK (link_changed_cb), dev);
|
|
|
|
|
|
2007-08-26 15:55:27 +00:00
|
|
|
priv->initialized = TRUE;
|
2007-02-05 12:14:09 +00:00
|
|
|
return object;
|
2007-08-26 15:55:27 +00:00
|
|
|
|
|
|
|
|
error:
|
|
|
|
|
g_object_unref (dev);
|
|
|
|
|
return NULL;
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
2011-10-14 10:13:49 -04:00
|
|
|
static void
|
|
|
|
|
constructed (GObject *object)
|
|
|
|
|
{
|
|
|
|
|
NMDevice *dev = NM_DEVICE (object);
|
2013-05-07 10:23:44 -04:00
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (dev);
|
2011-10-14 10:13:49 -04:00
|
|
|
|
2013-05-01 09:28:16 -04:00
|
|
|
nm_device_update_hw_address (dev);
|
2011-10-14 10:13:49 -04:00
|
|
|
|
|
|
|
|
if (NM_DEVICE_GET_CLASS (dev)->update_permanent_hw_address)
|
|
|
|
|
NM_DEVICE_GET_CLASS (dev)->update_permanent_hw_address (dev);
|
|
|
|
|
|
|
|
|
|
if (NM_DEVICE_GET_CLASS (dev)->update_initial_hw_address)
|
|
|
|
|
NM_DEVICE_GET_CLASS (dev)->update_initial_hw_address (dev);
|
|
|
|
|
|
2013-03-19 10:24:35 -04:00
|
|
|
/* Have to call update_initial_hw_address() before calling get_ignore_carrier() */
|
2013-05-07 10:23:44 -04:00
|
|
|
if (device_has_capability (dev, NM_DEVICE_CAP_CARRIER_DETECT)) {
|
|
|
|
|
priv->ignore_carrier = nm_config_get_ignore_carrier (nm_config_get (), NM_CONFIG_DEVICE (dev));
|
|
|
|
|
|
|
|
|
|
check_carrier (dev);
|
|
|
|
|
nm_log_info (LOGD_HW,
|
|
|
|
|
"(%s): carrier is %s%s",
|
|
|
|
|
nm_device_get_iface (NM_DEVICE (dev)),
|
|
|
|
|
priv->carrier ? "ON" : "OFF",
|
|
|
|
|
priv->ignore_carrier ? " (but ignored)" : "");
|
|
|
|
|
} else {
|
|
|
|
|
/* Fake online link when carrier detection is not available. */
|
|
|
|
|
priv->carrier = TRUE;
|
2013-03-19 10:24:35 -04:00
|
|
|
}
|
|
|
|
|
|
2013-08-26 13:12:37 -05:00
|
|
|
if (priv->ifindex > 0)
|
|
|
|
|
priv->is_software = nm_platform_link_is_software (priv->ifindex);
|
|
|
|
|
|
2011-10-14 10:13:49 -04:00
|
|
|
if (G_OBJECT_CLASS (nm_device_parent_class)->constructed)
|
|
|
|
|
G_OBJECT_CLASS (nm_device_parent_class)->constructed (object);
|
|
|
|
|
}
|
|
|
|
|
|
2008-04-28 Dan Williams <dcbw@redhat.com>
Fix the device up/down ambiguities. Up/down state used to be a
conglomeration of hardware state (IFF_UP) and any device-specific things
(supplicant, periodic timers, etc) that the device used to indicate
readiness. Unfortunately, if the hardware was already IFF_UP for some
reason, then the device specific stuff wouldn't get run, and the device
would be stuck.
* src/nm-device.c
src/nm-device.h
- Create hw_is_up, hw_bring_up, and hw_take_down
- Rename bring_down -> take_down
- (real_hw_is_up): check interface flags for IFF_UP
- (nm_device_hw_is_up): let subclasses figure out their own HW state
- (nm_device_is_up): make static; only used locally
- (nm_device_hw_bring_up): update the hardware and IPv4 addresses even
if the device is already up; if the device isn't up, bring it up
- (nm_device_hw_take_down): just take down hardware
- (nm_device_bring_up): bring up HW first, then device specific stuff
- (nm_device_take_down): always deactivate device when called; always
try to take hardware down too
- (nm_device_state_changed): take device down when entering unmanaged
state from a higher state
* src/nm-device-802-11-wireless.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
- (real_take_down, supplicant_iface_state_cb_handler,
supplicant_iface_connection_state_cb_handler,
supplicant_mgr_state_cb_handler): fix some messages
* src/nm-device-802-3-ethernet.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3618 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-29 15:36:29 +00:00
|
|
|
static gboolean
|
2013-06-13 15:13:58 -05:00
|
|
|
nm_device_is_up (NMDevice *self)
|
2008-04-28 Dan Williams <dcbw@redhat.com>
Fix the device up/down ambiguities. Up/down state used to be a
conglomeration of hardware state (IFF_UP) and any device-specific things
(supplicant, periodic timers, etc) that the device used to indicate
readiness. Unfortunately, if the hardware was already IFF_UP for some
reason, then the device specific stuff wouldn't get run, and the device
would be stuck.
* src/nm-device.c
src/nm-device.h
- Create hw_is_up, hw_bring_up, and hw_take_down
- Rename bring_down -> take_down
- (real_hw_is_up): check interface flags for IFF_UP
- (nm_device_hw_is_up): let subclasses figure out their own HW state
- (nm_device_is_up): make static; only used locally
- (nm_device_hw_bring_up): update the hardware and IPv4 addresses even
if the device is already up; if the device isn't up, bring it up
- (nm_device_hw_take_down): just take down hardware
- (nm_device_bring_up): bring up HW first, then device specific stuff
- (nm_device_take_down): always deactivate device when called; always
try to take hardware down too
- (nm_device_state_changed): take device down when entering unmanaged
state from a higher state
* src/nm-device-802-11-wireless.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
- (real_take_down, supplicant_iface_state_cb_handler,
supplicant_iface_connection_state_cb_handler,
supplicant_mgr_state_cb_handler): fix some messages
* src/nm-device-802-3-ethernet.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3618 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-29 15:36:29 +00:00
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (self), FALSE);
|
|
|
|
|
|
2013-06-13 15:13:58 -05:00
|
|
|
if (NM_DEVICE_GET_CLASS (self)->is_up)
|
|
|
|
|
return NM_DEVICE_GET_CLASS (self)->is_up (self);
|
2008-04-28 Dan Williams <dcbw@redhat.com>
Fix the device up/down ambiguities. Up/down state used to be a
conglomeration of hardware state (IFF_UP) and any device-specific things
(supplicant, periodic timers, etc) that the device used to indicate
readiness. Unfortunately, if the hardware was already IFF_UP for some
reason, then the device specific stuff wouldn't get run, and the device
would be stuck.
* src/nm-device.c
src/nm-device.h
- Create hw_is_up, hw_bring_up, and hw_take_down
- Rename bring_down -> take_down
- (real_hw_is_up): check interface flags for IFF_UP
- (nm_device_hw_is_up): let subclasses figure out their own HW state
- (nm_device_is_up): make static; only used locally
- (nm_device_hw_bring_up): update the hardware and IPv4 addresses even
if the device is already up; if the device isn't up, bring it up
- (nm_device_hw_take_down): just take down hardware
- (nm_device_bring_up): bring up HW first, then device specific stuff
- (nm_device_take_down): always deactivate device when called; always
try to take hardware down too
- (nm_device_state_changed): take device down when entering unmanaged
state from a higher state
* src/nm-device-802-11-wireless.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
- (real_take_down, supplicant_iface_state_cb_handler,
supplicant_iface_connection_state_cb_handler,
supplicant_mgr_state_cb_handler): fix some messages
* src/nm-device-802-3-ethernet.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3618 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-29 15:36:29 +00:00
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-22 16:43:15 +01:00
|
|
|
static gboolean
|
2013-06-13 15:13:58 -05:00
|
|
|
is_up (NMDevice *device)
|
2013-01-22 16:43:15 +01:00
|
|
|
{
|
|
|
|
|
int ifindex = nm_device_get_ip_ifindex (device);
|
|
|
|
|
|
2013-01-21 15:12:24 +01:00
|
|
|
return ifindex ? nm_platform_link_is_up (ifindex) : TRUE;
|
2013-01-22 16:43:15 +01:00
|
|
|
}
|
|
|
|
|
|
2009-06-11 00:39:12 -04:00
|
|
|
void
|
|
|
|
|
nm_device_set_path (NMDevice *self, const char *path)
|
|
|
|
|
{
|
2009-07-07 14:34:01 -04:00
|
|
|
NMDevicePrivate *priv;
|
|
|
|
|
|
2009-06-11 00:39:12 -04:00
|
|
|
g_return_if_fail (self != NULL);
|
|
|
|
|
|
2009-07-07 14:34:01 -04:00
|
|
|
priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
g_return_if_fail (priv->path == NULL);
|
|
|
|
|
|
|
|
|
|
priv->path = g_strdup (path);
|
2009-06-11 00:39:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char *
|
|
|
|
|
nm_device_get_path (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (self != NULL, NULL);
|
|
|
|
|
|
2009-07-07 14:34:01 -04:00
|
|
|
return NM_DEVICE_GET_PRIVATE (self)->path;
|
2009-06-11 00:39:12 -04:00
|
|
|
}
|
2005-12-31 08:21:24 +00:00
|
|
|
|
|
|
|
|
const char *
|
|
|
|
|
nm_device_get_udi (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (self != NULL, NULL);
|
|
|
|
|
|
2009-07-07 14:34:01 -04:00
|
|
|
return NM_DEVICE_GET_PRIVATE (self)->udi;
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Get/set functions for iface
|
|
|
|
|
*/
|
|
|
|
|
const char *
|
|
|
|
|
nm_device_get_iface (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (self != NULL, NULL);
|
|
|
|
|
|
2009-07-07 14:34:01 -04:00
|
|
|
return NM_DEVICE_GET_PRIVATE (self)->iface;
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
2010-04-21 14:58:25 -07:00
|
|
|
int
|
|
|
|
|
nm_device_get_ifindex (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (self != NULL, 0);
|
|
|
|
|
|
|
|
|
|
return NM_DEVICE_GET_PRIVATE (self)->ifindex;
|
|
|
|
|
}
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2013-08-22 19:15:05 +02:00
|
|
|
gboolean
|
|
|
|
|
nm_device_is_software (NMDevice *device)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
|
|
|
|
|
|
|
|
|
|
return priv->is_software;
|
|
|
|
|
}
|
|
|
|
|
|
2008-03-07 Dan Williams <dcbw@redhat.com>
First pass of multiple active device support. Expect bugs.
* src/nm-ip4-config.c
src/nm-ip4-config.h
- (nm_ip4_config_get_secondary, nm_ip4_config_set_secondary): remove;
there are better ways to do this in the named manager
* src/nm-device.c
src/nm-device.h
- (nm_device_can_activate): return whether the device can activate a
connection right now; taking into account things like carrier state
and rfkill state
- (nm_device_get_best_auto_connection): renamed from
nm_device_get_best_connection
- (real_act_stage4_get_ip4_config): MTU stuff is now handled in the
device subclasses themselves, so that each device can override the
MTU from it's NMSetting subclass if needed
- (nm_device_set_ip4_config): set MTU when setting up routes and stuff
in NetworkManagerSystem.c, not here
* src/named-manager/nm-named-manager.c
src/named-manager/nm-named-manager.h
- (nm_named_manager_name_owner_changed,
nm_named_manager_dbus_connection_changed): fix for changes to
rewrite_resolv_conf()
- (compute_nameservers): don't need the NMNamedManager at all, remove
from parameter list
- (merge_one_ip4_config): new function; merge ip4 configs together
- (rewrite_resolv_conf): write out resolv.conf from all the stored
ip4 configs; the VPN config takes precedence, then the best
device config, then the rest of the configs
- (get_domain_for_config): take the NMNamedManager as an argument
to check whether the config is the VPN config
- (add_ip4_config_to_named): fixups for removal of the 'secondary'
attribute from ip4 configs
- (add_all_ip4_configs_to_named): add all the configs in priority order
- (remove_ip4_config_from_named): fix for changes to
get_domain_for_config()
- (nm_named_manager_add_ip4_config): assign the config to the right slot
based on its type; callers must pass in the type now
- (get_last_default_domain): remove, unused
- (nm_named_manager_remove_ip4_config): handle config slots correctly
* src/nm-device-802-11-wireless.c
- (real_can_activate): new function
- (real_get_best_auto_connection): renamed from real_get_best_connection
- (real_act_stage4_get_ip4_config): handle MTU override
* src/nm-device-802-3-ethernet.c
- (real_can_activate): new function
- (real_get_best_auto_connection): renamed from real_get_best_connection
- (real_act_stage4_get_ip4_config): new function; handle MTU override
* src/vpn-manager/nm-vpn-connection.c
- (nm_vpn_connection_ip4_config_get): don't need to set the 'secondary'
attribute on the ip4 config
* src/NetworkManagerPolicy.c
- (nm_policy_auto_get_best_device): remove
- (nm_policy_device_change_check): remove
- (update_default_route): new function; set the default route via
the specified device
- (get_device_priority): new function; return the priority number of
a device type WRT which one should have the default route. Order is
(highest to lowest) wired, wireless, GSM, CDMA.
- (update_routing_and_dns): new function; determine which device should
have the default route, then update the routing table and DNS
- (maybe_auto_activate_device): new function; if a device is now
available for activation, find out what connection it would like to
activate and do it
- (schedule_activate_check): new function; if a device can be activated
now, schedule the activation. Each device may have only one
pending activation at a given time.
- (device_state_changed): if activation was canceled, try again,
possibly with another connection; if the device was activated,
update routing and DNS; if the device was deactivated, try again
with another connection
- (device_carrier_changed): if there is no carrier, deactivate the
device; otherwise schedule an activation check for the device
- (wireless_networks_changed): schedule an activation check for the
device
- (device_added): keep track of the signal handler IDs so they can
be removed when the device goes away
- (device_removed): remove any signal handlers that might be attached
to the device; update routing and DNS
- (schedule_activate_all): new function
- (connections_added, connection_added, connection_updated): when
connections change, schedule all devices for an activation check
- (connection_removed): when a device is deactivated because its
connection was removed, schedule another activation check for it
- (nm_policy_destroy): destroy pending activations and disconnect
all device signal handlers
* src/nm-manager.c
- (nm_manager_activate_device): if the device was already actived,
deactivate it
- (deactivate_old_device): remove
- (connection_added_default_handler, impl_manager_activate_device):
don't deactivate other devices when activating this one
* src/backends/NetworkManagerGentoo.c
src/backends/NetworkManagerFrugalware.c
src/backends/NetworkManagerPaldo.c
src/backends/NetworkManagerRedHat.c
src/backends/NetworkManagerSlackware.c
src/backends/NetworkManagerArch.c
src/backends/NetworkManagerSuSE.c
src/backends/NetworkManagerDebian.c
- (nm_system_get_mtu): remove; MTU should be provided through the
distro's system settings service plugin instead
- (nm_system_device_add_default_route_via_device): remove
- (nm_system_device_add_default_route_via_device_with_iface): remove
- (nm_system_device_replace_default_route): new function; call
generic implementation
* src/backends/NetworkManagerGeneric.c
src/backends/NetworkManagerGeneric.h
- (nm_generic_device_add_default_route_via_device,
nm_generic_device_add_default_route_via_device_with_iface): remove
- (nm_generic_device_replace_default_route): replace the default route
with the given route via some gateway
* src/NetworkManagerSystem.c
src/NetworkManagerSystem.h
- (nm_system_device_set_from_ip4_config): let the policy handle updates
to routing and DNS; but set the MTU here
- (nm_system_vpn_device_set_from_ip4_config): set the route with the
ip_iface of the active device; use the standard MTU setting function
- (nm_system_set_mtu): remove
- (nm_system_device_set_mtu): consolidate MTU setting code in one place
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3391 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-03-07 19:41:32 +00:00
|
|
|
const char *
|
2007-12-06 14:51:43 +00:00
|
|
|
nm_device_get_ip_iface (NMDevice *self)
|
|
|
|
|
{
|
2009-07-07 14:34:01 -04:00
|
|
|
NMDevicePrivate *priv;
|
|
|
|
|
|
2007-12-06 14:51:43 +00:00
|
|
|
g_return_val_if_fail (self != NULL, NULL);
|
|
|
|
|
|
2009-07-07 14:34:01 -04:00
|
|
|
priv = NM_DEVICE_GET_PRIVATE (self);
|
2007-12-06 14:51:43 +00:00
|
|
|
/* If it's not set, default to iface */
|
2009-07-07 14:34:01 -04:00
|
|
|
return priv->ip_iface ? priv->ip_iface : priv->iface;
|
2007-12-06 14:51:43 +00:00
|
|
|
}
|
|
|
|
|
|
2010-04-21 14:58:25 -07:00
|
|
|
int
|
|
|
|
|
nm_device_get_ip_ifindex (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (self != NULL, 0);
|
|
|
|
|
|
|
|
|
|
priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
/* If it's not set, default to iface */
|
|
|
|
|
return priv->ip_iface ? priv->ip_ifindex : priv->ifindex;
|
|
|
|
|
}
|
2007-12-06 14:51:43 +00:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
nm_device_set_ip_iface (NMDevice *self, const char *iface)
|
|
|
|
|
{
|
2010-04-21 14:58:25 -07:00
|
|
|
NMDevicePrivate *priv;
|
2010-06-10 10:16:39 -07:00
|
|
|
char *old_ip_iface;
|
2010-04-21 14:58:25 -07:00
|
|
|
|
2007-12-06 14:51:43 +00:00
|
|
|
g_return_if_fail (NM_IS_DEVICE (self));
|
|
|
|
|
|
2010-04-21 14:58:25 -07:00
|
|
|
priv = NM_DEVICE_GET_PRIVATE (self);
|
2010-06-10 10:16:39 -07:00
|
|
|
old_ip_iface = priv->ip_iface;
|
2010-04-21 14:58:25 -07:00
|
|
|
priv->ip_ifindex = 0;
|
|
|
|
|
|
|
|
|
|
priv->ip_iface = g_strdup (iface);
|
|
|
|
|
if (priv->ip_iface) {
|
2013-01-21 15:12:24 +01:00
|
|
|
priv->ip_ifindex = nm_platform_link_get_ifindex (priv->ip_iface);
|
2012-05-15 09:44:49 -05:00
|
|
|
if (priv->ip_ifindex <= 0) {
|
|
|
|
|
/* Device IP interface must always be a kernel network interface */
|
2010-04-21 14:58:25 -07:00
|
|
|
nm_log_warn (LOGD_HW, "(%s): failed to look up interface index", iface);
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-06-10 10:16:39 -07:00
|
|
|
|
|
|
|
|
/* Emit change notification */
|
|
|
|
|
if (g_strcmp0 (old_ip_iface, priv->ip_iface))
|
2011-11-18 00:34:08 -06:00
|
|
|
g_object_notify (G_OBJECT (self), NM_DEVICE_IP_IFACE);
|
2010-06-10 10:16:39 -07:00
|
|
|
g_free (old_ip_iface);
|
2007-12-06 14:51:43 +00:00
|
|
|
}
|
|
|
|
|
|
2013-05-01 09:28:16 -04:00
|
|
|
static guint
|
2013-07-19 12:05:19 -05:00
|
|
|
get_hw_address_length (NMDevice *dev, gboolean *out_permanent)
|
2013-05-01 09:28:16 -04:00
|
|
|
{
|
2013-06-05 17:41:57 -03:00
|
|
|
size_t len;
|
|
|
|
|
|
|
|
|
|
if (nm_platform_link_get_address (nm_device_get_ip_ifindex (dev), &len))
|
|
|
|
|
return len;
|
2013-05-01 09:28:16 -04:00
|
|
|
else
|
2013-06-05 17:41:57 -03:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static guint
|
2013-07-19 12:05:19 -05:00
|
|
|
nm_device_get_hw_address_length (NMDevice *dev, gboolean *out_permanent)
|
2013-06-05 17:41:57 -03:00
|
|
|
{
|
2013-07-19 12:05:19 -05:00
|
|
|
return NM_DEVICE_GET_CLASS (dev)->get_hw_address_length (dev, out_permanent);
|
2013-05-01 09:28:16 -04:00
|
|
|
}
|
|
|
|
|
|
2012-06-13 12:53:39 -05:00
|
|
|
const guint8 *
|
|
|
|
|
nm_device_get_hw_address (NMDevice *dev, guint *out_len)
|
|
|
|
|
{
|
2013-05-01 09:28:16 -04:00
|
|
|
NMDevicePrivate *priv;
|
|
|
|
|
|
2012-06-13 12:53:39 -05:00
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (dev), NULL);
|
2013-05-01 09:28:16 -04:00
|
|
|
priv = NM_DEVICE_GET_PRIVATE (dev);
|
2012-06-13 12:53:39 -05:00
|
|
|
|
2013-05-01 09:28:16 -04:00
|
|
|
if (out_len)
|
|
|
|
|
*out_len = priv->hw_addr_len;
|
|
|
|
|
|
|
|
|
|
if (priv->hw_addr_len == 0)
|
|
|
|
|
return NULL;
|
|
|
|
|
else
|
|
|
|
|
return priv->hw_addr;
|
2012-06-13 12:53:39 -05:00
|
|
|
}
|
2007-12-06 14:51:43 +00:00
|
|
|
|
2005-12-31 08:21:24 +00:00
|
|
|
/*
|
|
|
|
|
* Get/set functions for driver
|
|
|
|
|
*/
|
|
|
|
|
const char *
|
|
|
|
|
nm_device_get_driver (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (self != NULL, NULL);
|
|
|
|
|
|
2009-07-07 14:34:01 -04:00
|
|
|
return NM_DEVICE_GET_PRIVATE (self)->driver;
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
2012-06-01 16:48:57 +02:00
|
|
|
const char *
|
|
|
|
|
nm_device_get_driver_version (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (self != NULL, NULL);
|
|
|
|
|
|
|
|
|
|
return NM_DEVICE_GET_PRIVATE (self)->driver_version;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char *
|
|
|
|
|
nm_device_get_firmware_version (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (self != NULL, NULL);
|
|
|
|
|
|
|
|
|
|
return NM_DEVICE_GET_PRIVATE (self)->firmware_version;
|
|
|
|
|
}
|
|
|
|
|
|
2005-12-31 08:21:24 +00:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Get/set functions for type
|
|
|
|
|
*/
|
|
|
|
|
NMDeviceType
|
|
|
|
|
nm_device_get_device_type (NMDevice *self)
|
|
|
|
|
{
|
2008-06-10 15:54:23 +00:00
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (self), NM_DEVICE_TYPE_UNKNOWN);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2009-07-07 14:34:01 -04:00
|
|
|
return NM_DEVICE_GET_PRIVATE (self)->type;
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2012-05-17 17:01:50 -05:00
|
|
|
/**
|
|
|
|
|
* nm_device_get_priority():
|
|
|
|
|
* @dev: the #NMDevice
|
|
|
|
|
*
|
|
|
|
|
* Returns: the device's routing priority. Lower numbers means a "better"
|
|
|
|
|
* device, eg higher priority.
|
|
|
|
|
*/
|
2008-09-30 15:04:10 +00:00
|
|
|
int
|
|
|
|
|
nm_device_get_priority (NMDevice *dev)
|
|
|
|
|
{
|
2012-05-17 17:01:50 -05:00
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (dev), 100);
|
|
|
|
|
|
|
|
|
|
/* Device 'priority' is used for two things:
|
|
|
|
|
*
|
|
|
|
|
* a) two devices on the same IP subnet: the "better" (ie, lower number)
|
|
|
|
|
* device is the default outgoing device for that subnet
|
|
|
|
|
* b) default route: the "better" device gets the default route. This can
|
|
|
|
|
* always be modified by setting a connection to never-default=TRUE, in
|
|
|
|
|
* which case that device will never take the default route when
|
|
|
|
|
* it's using that connection.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
switch (nm_device_get_device_type (dev)) {
|
|
|
|
|
case NM_DEVICE_TYPE_ETHERNET:
|
|
|
|
|
return 1;
|
|
|
|
|
case NM_DEVICE_TYPE_INFINIBAND:
|
|
|
|
|
return 2;
|
|
|
|
|
case NM_DEVICE_TYPE_ADSL:
|
|
|
|
|
return 3;
|
|
|
|
|
case NM_DEVICE_TYPE_WIMAX:
|
|
|
|
|
return 4;
|
|
|
|
|
case NM_DEVICE_TYPE_BOND:
|
|
|
|
|
return 5;
|
2013-07-25 15:36:45 +02:00
|
|
|
case NM_DEVICE_TYPE_TEAM:
|
2012-05-17 17:01:50 -05:00
|
|
|
return 6;
|
2013-07-25 15:36:45 +02:00
|
|
|
case NM_DEVICE_TYPE_VLAN:
|
2012-05-17 17:01:50 -05:00
|
|
|
return 7;
|
2013-07-25 15:36:45 +02:00
|
|
|
case NM_DEVICE_TYPE_MODEM:
|
2012-05-17 17:01:50 -05:00
|
|
|
return 8;
|
2013-07-25 15:36:45 +02:00
|
|
|
case NM_DEVICE_TYPE_BT:
|
2012-05-17 17:01:50 -05:00
|
|
|
return 9;
|
2013-07-25 15:36:45 +02:00
|
|
|
case NM_DEVICE_TYPE_WIFI:
|
2012-05-17 17:01:50 -05:00
|
|
|
return 10;
|
2013-07-25 15:36:45 +02:00
|
|
|
case NM_DEVICE_TYPE_OLPC_MESH:
|
|
|
|
|
return 11;
|
2012-05-17 17:01:50 -05:00
|
|
|
default:
|
|
|
|
|
return 20;
|
|
|
|
|
}
|
2008-09-30 15:04:10 +00:00
|
|
|
}
|
|
|
|
|
|
2009-07-07 14:24:12 -04:00
|
|
|
const char *
|
|
|
|
|
nm_device_get_type_desc (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (self != NULL, NULL);
|
|
|
|
|
|
2009-07-07 14:34:01 -04:00
|
|
|
return NM_DEVICE_GET_PRIVATE (self)->type_desc;
|
2009-07-07 14:24:12 -04:00
|
|
|
}
|
|
|
|
|
|
2012-05-02 10:28:16 -05:00
|
|
|
void
|
|
|
|
|
nm_device_set_connection_provider (NMDevice *device,
|
|
|
|
|
NMConnectionProvider *provider)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (device != NULL);
|
|
|
|
|
g_return_if_fail (NM_IS_CONNECTION_PROVIDER (provider));
|
|
|
|
|
|
|
|
|
|
priv = NM_DEVICE_GET_PRIVATE (device);
|
|
|
|
|
g_return_if_fail (priv->con_provider == NULL);
|
|
|
|
|
|
|
|
|
|
priv->con_provider = provider;
|
2012-08-01 11:16:48 -06:00
|
|
|
priv->cp_added_id = g_signal_connect (priv->con_provider,
|
|
|
|
|
NM_CP_SIGNAL_CONNECTION_ADDED,
|
|
|
|
|
G_CALLBACK (cp_connection_added),
|
|
|
|
|
device);
|
|
|
|
|
|
|
|
|
|
priv->cp_loaded_id = g_signal_connect (priv->con_provider,
|
|
|
|
|
NM_CP_SIGNAL_CONNECTIONS_LOADED,
|
|
|
|
|
G_CALLBACK (cp_connections_loaded),
|
|
|
|
|
device);
|
|
|
|
|
|
|
|
|
|
priv->cp_removed_id = g_signal_connect (priv->con_provider,
|
|
|
|
|
NM_CP_SIGNAL_CONNECTION_REMOVED,
|
|
|
|
|
G_CALLBACK (cp_connection_removed),
|
|
|
|
|
device);
|
|
|
|
|
|
|
|
|
|
priv->cp_updated_id = g_signal_connect (priv->con_provider,
|
|
|
|
|
NM_CP_SIGNAL_CONNECTION_UPDATED,
|
|
|
|
|
G_CALLBACK (cp_connection_updated),
|
|
|
|
|
device);
|
2012-05-02 10:28:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NMConnectionProvider *
|
|
|
|
|
nm_device_get_connection_provider (NMDevice *device)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (device != NULL, NULL);
|
|
|
|
|
|
|
|
|
|
return NM_DEVICE_GET_PRIVATE (device)->con_provider;
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-14 14:05:30 -06:00
|
|
|
static SlaveInfo *
|
|
|
|
|
find_slave_info (NMDevice *self, NMDevice *slave)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
SlaveInfo *info;
|
|
|
|
|
GSList *iter;
|
|
|
|
|
|
|
|
|
|
for (iter = priv->slaves; iter; iter = g_slist_next (iter)) {
|
|
|
|
|
info = iter->data;
|
|
|
|
|
if (info->slave == slave)
|
|
|
|
|
return info;
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
free_slave_info (SlaveInfo *info)
|
|
|
|
|
{
|
|
|
|
|
g_signal_handler_disconnect (info->slave, info->watch_id);
|
|
|
|
|
g_clear_object (&info->slave);
|
|
|
|
|
memset (info, 0, sizeof (*info));
|
|
|
|
|
g_free (info);
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-28 18:35:30 -06:00
|
|
|
/**
|
|
|
|
|
* nm_device_enslave_slave:
|
|
|
|
|
* @dev: the master device
|
|
|
|
|
* @slave: the slave device to enslave
|
2012-11-04 17:51:34 -06:00
|
|
|
* @connection: the slave device's connection
|
2012-02-28 18:35:30 -06:00
|
|
|
*
|
2013-07-25 15:36:45 +02:00
|
|
|
* If @dev is capable of enslaving other devices (ie it's a bridge, bond, team,
|
|
|
|
|
* etc) then this function enslaves @slave.
|
2012-02-28 18:35:30 -06:00
|
|
|
*
|
|
|
|
|
* Returns: %TRUE on success, %FALSE on failure or if this device cannot enslave
|
|
|
|
|
* other devices.
|
|
|
|
|
*/
|
2012-11-14 14:05:30 -06:00
|
|
|
static gboolean
|
2012-11-04 17:51:34 -06:00
|
|
|
nm_device_enslave_slave (NMDevice *dev, NMDevice *slave, NMConnection *connection)
|
2012-02-28 18:35:30 -06:00
|
|
|
{
|
2012-11-14 14:05:30 -06:00
|
|
|
SlaveInfo *info;
|
|
|
|
|
gboolean success = FALSE;
|
|
|
|
|
|
2012-02-28 18:35:30 -06:00
|
|
|
g_return_val_if_fail (dev != NULL, FALSE);
|
|
|
|
|
g_return_val_if_fail (slave != NULL, FALSE);
|
|
|
|
|
g_return_val_if_fail (nm_device_get_state (slave) >= NM_DEVICE_STATE_DISCONNECTED, FALSE);
|
2012-11-14 14:05:30 -06:00
|
|
|
g_return_val_if_fail (NM_DEVICE_GET_CLASS (dev)->enslave_slave != NULL, FALSE);
|
2012-02-28 18:35:30 -06:00
|
|
|
|
2012-11-14 14:05:30 -06:00
|
|
|
info = find_slave_info (dev, slave);
|
|
|
|
|
if (!info)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
g_warn_if_fail (info->enslaved == FALSE);
|
|
|
|
|
success = NM_DEVICE_GET_CLASS (dev)->enslave_slave (dev, slave, connection);
|
|
|
|
|
if (success) {
|
|
|
|
|
info->enslaved = TRUE;
|
|
|
|
|
nm_device_slave_notify_enslaved (info->slave, TRUE, FALSE);
|
|
|
|
|
}
|
2013-01-18 14:34:40 -06:00
|
|
|
|
|
|
|
|
/* Ensure the device's hardware address is up-to-date; it often changes
|
|
|
|
|
* when slaves change.
|
|
|
|
|
*/
|
2013-05-01 09:28:16 -04:00
|
|
|
nm_device_update_hw_address (dev);
|
2013-01-18 14:34:40 -06:00
|
|
|
|
2013-01-25 11:59:05 -06:00
|
|
|
/* Restart IP configuration if we're waiting for slaves. Do this
|
|
|
|
|
* after updating the hardware address as IP config may need the
|
|
|
|
|
* new address.
|
|
|
|
|
*/
|
|
|
|
|
if (success) {
|
|
|
|
|
if (NM_DEVICE_GET_PRIVATE (dev)->ip4_state == IP_WAIT)
|
|
|
|
|
nm_device_activate_stage3_ip4_start (dev);
|
|
|
|
|
|
|
|
|
|
if (NM_DEVICE_GET_PRIVATE (dev)->ip6_state == IP_WAIT)
|
|
|
|
|
nm_device_activate_stage3_ip6_start (dev);
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-14 14:05:30 -06:00
|
|
|
return success;
|
2012-02-28 18:35:30 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2012-11-14 14:05:30 -06:00
|
|
|
* nm_device_release_one_slave:
|
2012-02-28 18:35:30 -06:00
|
|
|
* @dev: the master device
|
|
|
|
|
* @slave: the slave device to release
|
2012-11-14 14:05:30 -06:00
|
|
|
* @failed: %TRUE if the release was unexpected, ie the master failed
|
2012-02-28 18:35:30 -06:00
|
|
|
*
|
2013-07-25 15:36:45 +02:00
|
|
|
* If @dev is capable of enslaving other devices (ie it's a bridge, bond, team,
|
|
|
|
|
* etc) then this function releases the previously enslaved @slave.
|
2012-02-28 18:35:30 -06:00
|
|
|
*
|
|
|
|
|
* Returns: %TRUE on success, %FALSE on failure, if this device cannot enslave
|
|
|
|
|
* other devices, or if @slave was never enslaved.
|
|
|
|
|
*/
|
2012-11-14 14:05:30 -06:00
|
|
|
static gboolean
|
|
|
|
|
nm_device_release_one_slave (NMDevice *dev, NMDevice *slave, gboolean failed)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (dev);
|
|
|
|
|
SlaveInfo *info;
|
|
|
|
|
gboolean success = FALSE;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (slave != NULL, FALSE);
|
|
|
|
|
g_return_val_if_fail (NM_DEVICE_GET_CLASS (dev)->release_slave != NULL, FALSE);
|
|
|
|
|
|
|
|
|
|
info = find_slave_info (dev, slave);
|
|
|
|
|
if (!info)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
if (info->enslaved) {
|
|
|
|
|
success = NM_DEVICE_GET_CLASS (dev)->release_slave (dev, slave);
|
|
|
|
|
g_warn_if_fail (success);
|
|
|
|
|
}
|
|
|
|
|
nm_device_slave_notify_enslaved (info->slave, FALSE, failed);
|
|
|
|
|
|
|
|
|
|
priv->slaves = g_slist_remove (priv->slaves, info);
|
|
|
|
|
free_slave_info (info);
|
2013-01-18 14:34:40 -06:00
|
|
|
|
|
|
|
|
/* Ensure the device's hardware address is up-to-date; it often changes
|
|
|
|
|
* when slaves change.
|
|
|
|
|
*/
|
2013-05-01 09:28:16 -04:00
|
|
|
nm_device_update_hw_address (dev);
|
2013-01-18 14:34:40 -06:00
|
|
|
|
2012-11-14 14:05:30 -06:00
|
|
|
return success;
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-12 10:43:45 -04:00
|
|
|
static gboolean
|
|
|
|
|
connection_is_static (NMConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
NMSettingIP4Config *ip4;
|
|
|
|
|
NMSettingIP6Config *ip6;
|
|
|
|
|
const char *method;
|
|
|
|
|
|
|
|
|
|
ip4 = nm_connection_get_setting_ip4_config (connection);
|
|
|
|
|
if (ip4) {
|
|
|
|
|
method = nm_setting_ip4_config_get_method (ip4);
|
|
|
|
|
if ( g_strcmp0 (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL) != 0
|
|
|
|
|
&& g_strcmp0 (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED) != 0)
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ip6 = nm_connection_get_setting_ip6_config (connection);
|
|
|
|
|
if (ip6) {
|
|
|
|
|
method = nm_setting_ip6_config_get_method (ip6);
|
|
|
|
|
if ( g_strcmp0 (method, NM_SETTING_IP6_CONFIG_METHOD_MANUAL) != 0
|
|
|
|
|
&& g_strcmp0 (method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE) != 0)
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
has_static_connection (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
const GSList *connections, *iter;
|
|
|
|
|
|
|
|
|
|
connections = nm_connection_provider_get_connections (priv->con_provider);
|
|
|
|
|
for (iter = connections; iter; iter = iter->next) {
|
|
|
|
|
NMConnection *connection = iter->data;
|
|
|
|
|
|
|
|
|
|
if ( nm_device_check_connection_compatible (self, connection, NULL)
|
|
|
|
|
&& connection_is_static (connection))
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-07 10:23:44 -04:00
|
|
|
static void
|
|
|
|
|
carrier_changed (NMDevice *device, gboolean carrier)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
|
|
|
|
|
|
2013-07-12 10:43:45 -04:00
|
|
|
if (!nm_device_get_managed (device))
|
2013-05-07 10:23:44 -04:00
|
|
|
return;
|
|
|
|
|
|
2013-07-12 10:43:45 -04:00
|
|
|
if (priv->ignore_carrier) {
|
|
|
|
|
/* Ignore all carrier-off, and ignore carrier-on on connected devices */
|
|
|
|
|
if (!carrier || priv->state > NM_DEVICE_STATE_DISCONNECTED)
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-07 10:23:44 -04:00
|
|
|
if (nm_device_is_master (device)) {
|
2013-07-25 15:36:45 +02:00
|
|
|
/* Bridge/bond/team carrier does not affect its own activation,
|
|
|
|
|
* but when carrier comes on, if there are slaves waiting,
|
|
|
|
|
* it will restart them.
|
2013-05-07 10:23:44 -04:00
|
|
|
*/
|
|
|
|
|
if (!carrier)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (nm_device_activate_ip4_state_in_wait (device))
|
|
|
|
|
nm_device_activate_stage3_ip4_start (device);
|
|
|
|
|
if (nm_device_activate_ip6_state_in_wait (device))
|
|
|
|
|
nm_device_activate_stage3_ip6_start (device);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
} else if (nm_device_get_enslaved (device) && !carrier) {
|
2013-07-25 15:36:45 +02:00
|
|
|
/* Slaves don't deactivate when they lose carrier; for
|
|
|
|
|
* bonds/teams in particular that would be actively
|
|
|
|
|
* counterproductive.
|
2013-05-07 10:23:44 -04:00
|
|
|
*/
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (carrier) {
|
|
|
|
|
g_warn_if_fail (priv->state >= NM_DEVICE_STATE_UNAVAILABLE);
|
|
|
|
|
|
|
|
|
|
if (priv->state == NM_DEVICE_STATE_UNAVAILABLE) {
|
|
|
|
|
nm_device_queue_state (device, NM_DEVICE_STATE_DISCONNECTED,
|
|
|
|
|
NM_DEVICE_STATE_REASON_CARRIER);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
g_return_if_fail (priv->state >= NM_DEVICE_STATE_UNAVAILABLE);
|
|
|
|
|
|
|
|
|
|
if (priv->state == NM_DEVICE_STATE_UNAVAILABLE) {
|
|
|
|
|
if (nm_device_queued_state_peek (device) >= NM_DEVICE_STATE_DISCONNECTED)
|
|
|
|
|
nm_device_queued_state_clear (device);
|
|
|
|
|
} else {
|
|
|
|
|
nm_device_queue_state (device, NM_DEVICE_STATE_UNAVAILABLE,
|
|
|
|
|
NM_DEVICE_STATE_REASON_CARRIER);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
|
nm_device_has_carrier (NMDevice *device)
|
|
|
|
|
{
|
|
|
|
|
return NM_DEVICE_GET_PRIVATE (device)->carrier;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Returns %TRUE if @device is unavailable for connections because it
|
|
|
|
|
* needs carrier but does not have it.
|
|
|
|
|
*/
|
|
|
|
|
static gboolean
|
|
|
|
|
nm_device_is_unavailable_because_of_carrier (NMDevice *device)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
|
|
|
|
|
|
|
|
|
|
return !priv->carrier && !priv->ignore_carrier;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define LINK_DISCONNECT_DELAY 4
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
link_disconnect_action_cb (gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMDevice *device = NM_DEVICE (user_data);
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
|
|
|
|
|
|
|
|
|
|
priv->carrier_defer_id = 0;
|
|
|
|
|
|
|
|
|
|
nm_log_info (LOGD_DEVICE, "(%s): link disconnected (calling deferred action)",
|
|
|
|
|
nm_device_get_iface (device));
|
|
|
|
|
|
|
|
|
|
NM_DEVICE_GET_CLASS (device)->carrier_changed (device, FALSE);
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
nm_device_set_carrier (NMDevice *device, gboolean carrier)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
|
|
|
|
|
NMDeviceClass *klass = NM_DEVICE_GET_CLASS (device);
|
|
|
|
|
NMDeviceState state = nm_device_get_state (device);
|
|
|
|
|
const char *iface = nm_device_get_iface (device);
|
|
|
|
|
|
|
|
|
|
if (priv->carrier == carrier)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
priv->carrier = carrier;
|
|
|
|
|
g_object_notify (G_OBJECT (device), NM_DEVICE_CARRIER);
|
|
|
|
|
|
|
|
|
|
if (priv->carrier) {
|
|
|
|
|
nm_log_info (LOGD_DEVICE, "(%s): link connected", iface);
|
|
|
|
|
if (priv->carrier_defer_id) {
|
|
|
|
|
g_source_remove (priv->carrier_defer_id);
|
|
|
|
|
priv->carrier_defer_id = 0;
|
|
|
|
|
}
|
|
|
|
|
klass->carrier_changed (device, TRUE);
|
|
|
|
|
} else if (state <= NM_DEVICE_STATE_DISCONNECTED) {
|
|
|
|
|
nm_log_info (LOGD_DEVICE, "(%s): link disconnected", iface);
|
|
|
|
|
klass->carrier_changed (device, FALSE);
|
|
|
|
|
} else {
|
|
|
|
|
nm_log_info (LOGD_DEVICE, "(%s): link disconnected (deferring action for %d seconds)",
|
|
|
|
|
iface, LINK_DISCONNECT_DELAY);
|
|
|
|
|
priv->carrier_defer_id = g_timeout_add_seconds (LINK_DISCONNECT_DELAY,
|
|
|
|
|
link_disconnect_action_cb, device);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2013-08-02 18:51:06 +02:00
|
|
|
link_changed_cb (NMPlatform *platform, int ifindex, NMPlatformLink *info, NMPlatformReason reason, NMDevice *device)
|
2013-05-07 10:23:44 -04:00
|
|
|
{
|
2013-07-27 10:41:44 +02:00
|
|
|
NMDeviceClass *klass = NM_DEVICE_GET_CLASS (device);
|
2013-08-05 16:39:20 -05:00
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
|
2013-07-27 10:41:44 +02:00
|
|
|
|
2013-08-27 14:17:30 +02:00
|
|
|
/* Ignore other devices. */
|
2013-04-25 15:46:39 -04:00
|
|
|
if (ifindex != nm_device_get_ifindex (device))
|
|
|
|
|
return;
|
|
|
|
|
|
2013-08-27 14:17:30 +02:00
|
|
|
/* We don't filter by 'reason' because we are interested in *all* link
|
|
|
|
|
* changes. For example a call to nm_platform_link_set_up() may result
|
|
|
|
|
* in an internal carrier change (i.e. we ask the kernel to set IFF_UP
|
|
|
|
|
* and it results in also setting IFF_LOWER_UP.
|
|
|
|
|
*/
|
|
|
|
|
|
2013-08-05 16:39:20 -05:00
|
|
|
if (info->udi && g_strcmp0 (info->udi, priv->udi)) {
|
|
|
|
|
/* Update UDI to what udev gives us */
|
|
|
|
|
g_free (priv->udi);
|
|
|
|
|
priv->udi = g_strdup (info->udi);
|
|
|
|
|
g_object_notify (G_OBJECT (device), NM_DEVICE_UDI);
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-27 10:41:44 +02:00
|
|
|
if (klass->link_changed)
|
|
|
|
|
klass->link_changed (device, info);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
link_changed (NMDevice *device, NMPlatformLink *info)
|
|
|
|
|
{
|
2013-08-27 14:17:30 +02:00
|
|
|
/* Update carrier from link event if applicable. */
|
2013-04-25 15:46:39 -04:00
|
|
|
if ( device_has_capability (device, NM_DEVICE_CAP_CARRIER_DETECT)
|
|
|
|
|
&& !device_has_capability (device, NM_DEVICE_CAP_NONSTANDARD_CARRIER))
|
2013-01-21 15:12:24 +01:00
|
|
|
nm_device_set_carrier (device, info->connected);
|
2013-05-07 10:23:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
check_carrier (NMDevice *device)
|
|
|
|
|
{
|
2013-01-21 15:12:24 +01:00
|
|
|
int ifindex = nm_device_get_ip_ifindex (device);
|
2013-05-07 10:23:44 -04:00
|
|
|
|
2013-01-21 15:12:24 +01:00
|
|
|
if (!device_has_capability (device, NM_DEVICE_CAP_NONSTANDARD_CARRIER))
|
|
|
|
|
nm_device_set_carrier (device, nm_platform_link_is_connected (ifindex));
|
2013-05-07 10:23:44 -04:00
|
|
|
}
|
|
|
|
|
|
2012-11-14 14:05:30 -06:00
|
|
|
static void
|
|
|
|
|
slave_state_changed (NMDevice *slave,
|
|
|
|
|
NMDeviceState slave_new_state,
|
|
|
|
|
NMDeviceState slave_old_state,
|
|
|
|
|
NMDeviceStateReason reason,
|
|
|
|
|
NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
gboolean release = FALSE;
|
|
|
|
|
|
|
|
|
|
nm_log_dbg (LOGD_DEVICE, "(%s): slave %s state change %d (%s) -> %d (%s)",
|
|
|
|
|
nm_device_get_iface (self),
|
|
|
|
|
nm_device_get_iface (slave),
|
|
|
|
|
slave_old_state,
|
|
|
|
|
state_to_string (slave_old_state),
|
|
|
|
|
slave_new_state,
|
|
|
|
|
state_to_string (slave_new_state));
|
|
|
|
|
|
|
|
|
|
g_assert (priv->state > NM_DEVICE_STATE_DISCONNECTED);
|
|
|
|
|
g_assert (priv->state <= NM_DEVICE_STATE_ACTIVATED);
|
|
|
|
|
|
|
|
|
|
/* Don't try to enslave slaves until the master is ready */
|
|
|
|
|
if (priv->state < NM_DEVICE_STATE_CONFIG)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (slave_new_state == NM_DEVICE_STATE_IP_CONFIG)
|
|
|
|
|
nm_device_enslave_slave (self, slave, nm_device_get_connection (slave));
|
|
|
|
|
else if (slave_new_state > NM_DEVICE_STATE_ACTIVATED)
|
|
|
|
|
release = TRUE;
|
|
|
|
|
else if ( slave_new_state <= NM_DEVICE_STATE_DISCONNECTED
|
|
|
|
|
&& slave_old_state > NM_DEVICE_STATE_DISCONNECTED) {
|
|
|
|
|
/* Catch failures due to unavailable or unmanaged */
|
|
|
|
|
release = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (release) {
|
|
|
|
|
nm_device_release_one_slave (self, slave, FALSE);
|
2013-07-25 15:36:45 +02:00
|
|
|
/* Bridge/bond/team interfaces are left up until manually deactivated */
|
2013-01-18 10:54:24 -06:00
|
|
|
if (priv->slaves == NULL && priv->state == NM_DEVICE_STATE_ACTIVATED) {
|
|
|
|
|
nm_log_dbg (LOGD_DEVICE, "(%s): last slave removed; remaining activated",
|
|
|
|
|
nm_device_get_iface (self));
|
2012-11-14 14:05:30 -06:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_device_master_add_slave:
|
|
|
|
|
* @dev: the master device
|
|
|
|
|
* @slave: the slave device to enslave
|
|
|
|
|
*
|
2013-07-25 15:36:45 +02:00
|
|
|
* If @dev is capable of enslaving other devices (ie it's a bridge, bond, team,
|
|
|
|
|
* etc) then this function adds @slave to the slave list for later enslavement.
|
2012-11-14 14:05:30 -06:00
|
|
|
*
|
|
|
|
|
* Returns: %TRUE on success, %FALSE on failure
|
|
|
|
|
*/
|
2012-02-28 18:35:30 -06:00
|
|
|
gboolean
|
2012-11-14 14:05:30 -06:00
|
|
|
nm_device_master_add_slave (NMDevice *dev, NMDevice *slave)
|
2012-02-28 18:35:30 -06:00
|
|
|
{
|
2012-11-14 14:05:30 -06:00
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (dev);
|
|
|
|
|
SlaveInfo *info;
|
|
|
|
|
|
2012-02-28 18:35:30 -06:00
|
|
|
g_return_val_if_fail (dev != NULL, FALSE);
|
|
|
|
|
g_return_val_if_fail (slave != NULL, FALSE);
|
2012-11-14 14:05:30 -06:00
|
|
|
g_return_val_if_fail (nm_device_get_state (slave) >= NM_DEVICE_STATE_DISCONNECTED, FALSE);
|
|
|
|
|
g_return_val_if_fail (NM_DEVICE_GET_CLASS (dev)->enslave_slave != NULL, FALSE);
|
|
|
|
|
|
|
|
|
|
if (!find_slave_info (dev, slave)) {
|
|
|
|
|
info = g_malloc0 (sizeof (SlaveInfo));
|
|
|
|
|
info->slave = g_object_ref (slave);
|
|
|
|
|
info->watch_id = g_signal_connect (slave, "state-changed",
|
|
|
|
|
G_CALLBACK (slave_state_changed), dev);
|
|
|
|
|
priv->slaves = g_slist_prepend (priv->slaves, info);
|
|
|
|
|
}
|
2012-02-28 18:35:30 -06:00
|
|
|
|
2012-11-14 14:05:30 -06:00
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_device_master_get_slaves:
|
|
|
|
|
* @dev: the master device
|
|
|
|
|
*
|
|
|
|
|
* Returns: any slaves of which @device is the master. Caller owns returned list.
|
|
|
|
|
*/
|
|
|
|
|
GSList *
|
|
|
|
|
nm_device_master_get_slaves (NMDevice *dev)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (dev);
|
|
|
|
|
GSList *slaves = NULL, *iter;
|
|
|
|
|
|
|
|
|
|
for (iter = priv->slaves; iter; iter = g_slist_next (iter))
|
|
|
|
|
slaves = g_slist_prepend (slaves, ((SlaveInfo *) iter->data)->slave);
|
|
|
|
|
|
|
|
|
|
return slaves;
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-28 13:37:04 -06:00
|
|
|
/**
|
|
|
|
|
* nm_device_master_get_slave_by_ifindex:
|
|
|
|
|
* @dev: the master device
|
|
|
|
|
* @ifindex: the slave's interface index
|
|
|
|
|
*
|
|
|
|
|
* Returns: the slave with the given @ifindex of which @device is the master,
|
2013-08-08 15:34:33 +02:00
|
|
|
* or %NULL if no device with @ifindex is a slave of @device.
|
2013-01-28 13:37:04 -06:00
|
|
|
*/
|
|
|
|
|
NMDevice *
|
|
|
|
|
nm_device_master_get_slave_by_ifindex (NMDevice *dev, int ifindex)
|
|
|
|
|
{
|
|
|
|
|
GSList *iter;
|
|
|
|
|
|
|
|
|
|
for (iter = NM_DEVICE_GET_PRIVATE (dev)->slaves; iter; iter = g_slist_next (iter)) {
|
|
|
|
|
SlaveInfo *info = iter->data;
|
|
|
|
|
|
|
|
|
|
if (nm_device_get_ip_ifindex (info->slave) == ifindex)
|
|
|
|
|
return info->slave;
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-24 17:47:59 -06:00
|
|
|
/**
|
|
|
|
|
* nm_device_is_master:
|
|
|
|
|
* @dev: the device
|
|
|
|
|
*
|
2013-07-25 15:36:45 +02:00
|
|
|
* Returns: whether @dev can enslave other devices (eg, bridge or bond or team)
|
2013-01-24 17:47:59 -06:00
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
nm_device_is_master (NMDevice *dev)
|
|
|
|
|
{
|
|
|
|
|
return NM_DEVICE_GET_PRIVATE (dev)->is_master;
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-14 14:05:30 -06:00
|
|
|
/* release all slaves */
|
|
|
|
|
static void
|
|
|
|
|
nm_device_master_release_slaves (NMDevice *self, gboolean failed)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
|
2013-05-15 14:39:16 -05:00
|
|
|
while (priv->slaves) {
|
|
|
|
|
SlaveInfo *info = priv->slaves->data;
|
|
|
|
|
|
|
|
|
|
nm_device_release_one_slave (self, info->slave, failed);
|
|
|
|
|
}
|
2012-11-14 14:05:30 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_device_slave_notify_enslaved:
|
|
|
|
|
* @dev: the slave device
|
|
|
|
|
* @enslaved: %TRUE if the device is now enslaved, %FALSE if released
|
|
|
|
|
* @master_failed: if released, indicates whether the release was unexpected,
|
|
|
|
|
* ie the master device failed.
|
|
|
|
|
*
|
|
|
|
|
* Notifies a slave that it has been enslaved or released. If released, provides
|
|
|
|
|
* information on whether the release was expected or not, and thus whether the
|
|
|
|
|
* slave should fail it's activation or gracefully deactivate.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
nm_device_slave_notify_enslaved (NMDevice *dev,
|
|
|
|
|
gboolean enslaved,
|
|
|
|
|
gboolean master_failed)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (dev);
|
|
|
|
|
NMConnection *connection = nm_device_get_connection (dev);
|
|
|
|
|
|
|
|
|
|
if (enslaved) {
|
2013-01-17 15:44:30 -06:00
|
|
|
g_assert (priv->master);
|
2012-11-14 14:05:30 -06:00
|
|
|
g_warn_if_fail (priv->enslaved == FALSE);
|
|
|
|
|
g_warn_if_fail (priv->state == NM_DEVICE_STATE_IP_CONFIG);
|
|
|
|
|
|
|
|
|
|
nm_log_info (LOGD_DEVICE,
|
|
|
|
|
"Activation (%s) connection '%s' enslaved, continuing activation",
|
|
|
|
|
nm_device_get_iface (dev),
|
|
|
|
|
nm_connection_get_id (connection));
|
|
|
|
|
|
|
|
|
|
/* Now that we're enslaved, proceed with activation. Remember, slaves
|
|
|
|
|
* don't have any IP configuration, so they skip directly to SECONDARIES.
|
|
|
|
|
*/
|
|
|
|
|
priv->enslaved = TRUE;
|
|
|
|
|
priv->ip4_state = IP_DONE;
|
|
|
|
|
priv->ip6_state = IP_DONE;
|
|
|
|
|
nm_device_queue_state (dev, NM_DEVICE_STATE_SECONDARIES, NM_DEVICE_STATE_REASON_NONE);
|
|
|
|
|
} else {
|
|
|
|
|
NMDeviceState new_state = NM_DEVICE_STATE_DISCONNECTED;
|
|
|
|
|
NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE;
|
|
|
|
|
|
2013-01-17 15:44:30 -06:00
|
|
|
if ( priv->state > NM_DEVICE_STATE_DISCONNECTED
|
|
|
|
|
&& priv->state <= NM_DEVICE_STATE_ACTIVATED) {
|
|
|
|
|
if (master_failed) {
|
|
|
|
|
new_state = NM_DEVICE_STATE_FAILED;
|
|
|
|
|
reason = NM_DEVICE_STATE_REASON_DEPENDENCY_FAILED;
|
|
|
|
|
|
|
|
|
|
nm_log_warn (LOGD_DEVICE,
|
|
|
|
|
"Activation (%s) connection '%s' master failed",
|
|
|
|
|
nm_device_get_iface (dev),
|
|
|
|
|
nm_connection_get_id (connection));
|
|
|
|
|
} else {
|
|
|
|
|
nm_log_dbg (LOGD_DEVICE,
|
|
|
|
|
"Activation (%s) connection '%s' master deactivated",
|
|
|
|
|
nm_device_get_iface (dev),
|
|
|
|
|
nm_connection_get_id (connection));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nm_device_queue_state (dev, new_state, reason);
|
2012-11-14 14:05:30 -06:00
|
|
|
}
|
|
|
|
|
}
|
2012-02-28 18:35:30 -06:00
|
|
|
}
|
|
|
|
|
|
2013-01-18 11:03:29 -06:00
|
|
|
/**
|
|
|
|
|
* nm_device_get_enslaved:
|
|
|
|
|
* @device: the #NMDevice
|
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE if the device is enslaved to a master device (eg bridge or
|
2013-07-25 15:36:45 +02:00
|
|
|
* bond or team), %FALSE if not
|
2013-01-18 11:03:29 -06:00
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
nm_device_get_enslaved (NMDevice *device)
|
|
|
|
|
{
|
|
|
|
|
return NM_DEVICE_GET_PRIVATE (device)->enslaved;
|
|
|
|
|
}
|
|
|
|
|
|
2005-12-31 08:21:24 +00:00
|
|
|
/*
|
|
|
|
|
* nm_device_get_act_request
|
|
|
|
|
*
|
|
|
|
|
* Return the devices activation request, if any.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
NMActRequest *
|
|
|
|
|
nm_device_get_act_request (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (self != NULL, NULL);
|
|
|
|
|
|
2009-07-07 14:34:01 -04:00
|
|
|
return NM_DEVICE_GET_PRIVATE (self)->act_request;
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
2013-05-07 10:23:44 -04:00
|
|
|
NMConnection *
|
|
|
|
|
nm_device_get_connection (NMDevice *self)
|
2012-11-12 13:29:06 -05:00
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
|
2013-05-07 10:23:44 -04:00
|
|
|
return priv->act_request ? nm_act_request_get_connection (priv->act_request) : NULL;
|
2012-11-12 13:29:06 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
2013-05-07 10:23:44 -04:00
|
|
|
is_available (NMDevice *device)
|
2012-11-12 13:29:06 -05:00
|
|
|
{
|
2013-05-07 10:23:44 -04:00
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
|
2011-10-18 13:48:48 +02:00
|
|
|
|
2013-07-12 10:43:45 -04:00
|
|
|
if (!priv->carrier) {
|
|
|
|
|
if (priv->ignore_carrier && has_static_connection (device))
|
|
|
|
|
return TRUE;
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
2011-10-18 13:48:48 +02:00
|
|
|
}
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2013-07-12 10:43:45 -04:00
|
|
|
/**
|
|
|
|
|
* nm_device_is_available:
|
|
|
|
|
* @self: the #NMDevice
|
|
|
|
|
*
|
|
|
|
|
* Checks if @self would currently be capable of activating a
|
|
|
|
|
* connection. In particular, it checks that the device is ready (eg,
|
|
|
|
|
* is not missing firmware), that it has carrier (if necessary), and
|
|
|
|
|
* that any necessary external software (eg, ModemManager,
|
|
|
|
|
* wpa_supplicant) is available.
|
|
|
|
|
*
|
|
|
|
|
* @self can only be in a state higher than
|
|
|
|
|
* %NM_DEVICE_STATE_UNAVAILABLE when nm_device_is_available() returns
|
|
|
|
|
* %TRUE. (But note that it can still be %NM_DEVICE_STATE_UNMANAGED
|
|
|
|
|
* when it is available.)
|
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE or %FALSE
|
|
|
|
|
*/
|
2008-03-07 Dan Williams <dcbw@redhat.com>
First pass of multiple active device support. Expect bugs.
* src/nm-ip4-config.c
src/nm-ip4-config.h
- (nm_ip4_config_get_secondary, nm_ip4_config_set_secondary): remove;
there are better ways to do this in the named manager
* src/nm-device.c
src/nm-device.h
- (nm_device_can_activate): return whether the device can activate a
connection right now; taking into account things like carrier state
and rfkill state
- (nm_device_get_best_auto_connection): renamed from
nm_device_get_best_connection
- (real_act_stage4_get_ip4_config): MTU stuff is now handled in the
device subclasses themselves, so that each device can override the
MTU from it's NMSetting subclass if needed
- (nm_device_set_ip4_config): set MTU when setting up routes and stuff
in NetworkManagerSystem.c, not here
* src/named-manager/nm-named-manager.c
src/named-manager/nm-named-manager.h
- (nm_named_manager_name_owner_changed,
nm_named_manager_dbus_connection_changed): fix for changes to
rewrite_resolv_conf()
- (compute_nameservers): don't need the NMNamedManager at all, remove
from parameter list
- (merge_one_ip4_config): new function; merge ip4 configs together
- (rewrite_resolv_conf): write out resolv.conf from all the stored
ip4 configs; the VPN config takes precedence, then the best
device config, then the rest of the configs
- (get_domain_for_config): take the NMNamedManager as an argument
to check whether the config is the VPN config
- (add_ip4_config_to_named): fixups for removal of the 'secondary'
attribute from ip4 configs
- (add_all_ip4_configs_to_named): add all the configs in priority order
- (remove_ip4_config_from_named): fix for changes to
get_domain_for_config()
- (nm_named_manager_add_ip4_config): assign the config to the right slot
based on its type; callers must pass in the type now
- (get_last_default_domain): remove, unused
- (nm_named_manager_remove_ip4_config): handle config slots correctly
* src/nm-device-802-11-wireless.c
- (real_can_activate): new function
- (real_get_best_auto_connection): renamed from real_get_best_connection
- (real_act_stage4_get_ip4_config): handle MTU override
* src/nm-device-802-3-ethernet.c
- (real_can_activate): new function
- (real_get_best_auto_connection): renamed from real_get_best_connection
- (real_act_stage4_get_ip4_config): new function; handle MTU override
* src/vpn-manager/nm-vpn-connection.c
- (nm_vpn_connection_ip4_config_get): don't need to set the 'secondary'
attribute on the ip4 config
* src/NetworkManagerPolicy.c
- (nm_policy_auto_get_best_device): remove
- (nm_policy_device_change_check): remove
- (update_default_route): new function; set the default route via
the specified device
- (get_device_priority): new function; return the priority number of
a device type WRT which one should have the default route. Order is
(highest to lowest) wired, wireless, GSM, CDMA.
- (update_routing_and_dns): new function; determine which device should
have the default route, then update the routing table and DNS
- (maybe_auto_activate_device): new function; if a device is now
available for activation, find out what connection it would like to
activate and do it
- (schedule_activate_check): new function; if a device can be activated
now, schedule the activation. Each device may have only one
pending activation at a given time.
- (device_state_changed): if activation was canceled, try again,
possibly with another connection; if the device was activated,
update routing and DNS; if the device was deactivated, try again
with another connection
- (device_carrier_changed): if there is no carrier, deactivate the
device; otherwise schedule an activation check for the device
- (wireless_networks_changed): schedule an activation check for the
device
- (device_added): keep track of the signal handler IDs so they can
be removed when the device goes away
- (device_removed): remove any signal handlers that might be attached
to the device; update routing and DNS
- (schedule_activate_all): new function
- (connections_added, connection_added, connection_updated): when
connections change, schedule all devices for an activation check
- (connection_removed): when a device is deactivated because its
connection was removed, schedule another activation check for it
- (nm_policy_destroy): destroy pending activations and disconnect
all device signal handlers
* src/nm-manager.c
- (nm_manager_activate_device): if the device was already actived,
deactivate it
- (deactivate_old_device): remove
- (connection_added_default_handler, impl_manager_activate_device):
don't deactivate other devices when activating this one
* src/backends/NetworkManagerGentoo.c
src/backends/NetworkManagerFrugalware.c
src/backends/NetworkManagerPaldo.c
src/backends/NetworkManagerRedHat.c
src/backends/NetworkManagerSlackware.c
src/backends/NetworkManagerArch.c
src/backends/NetworkManagerSuSE.c
src/backends/NetworkManagerDebian.c
- (nm_system_get_mtu): remove; MTU should be provided through the
distro's system settings service plugin instead
- (nm_system_device_add_default_route_via_device): remove
- (nm_system_device_add_default_route_via_device_with_iface): remove
- (nm_system_device_replace_default_route): new function; call
generic implementation
* src/backends/NetworkManagerGeneric.c
src/backends/NetworkManagerGeneric.h
- (nm_generic_device_add_default_route_via_device,
nm_generic_device_add_default_route_via_device_with_iface): remove
- (nm_generic_device_replace_default_route): replace the default route
with the given route via some gateway
* src/NetworkManagerSystem.c
src/NetworkManagerSystem.h
- (nm_system_device_set_from_ip4_config): let the policy handle updates
to routing and DNS; but set the MTU here
- (nm_system_vpn_device_set_from_ip4_config): set the route with the
ip_iface of the active device; use the standard MTU setting function
- (nm_system_set_mtu): remove
- (nm_system_device_set_mtu): consolidate MTU setting code in one place
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3391 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-03-07 19:41:32 +00:00
|
|
|
gboolean
|
2013-03-19 09:17:41 -04:00
|
|
|
nm_device_is_available (NMDevice *self)
|
2008-03-07 Dan Williams <dcbw@redhat.com>
First pass of multiple active device support. Expect bugs.
* src/nm-ip4-config.c
src/nm-ip4-config.h
- (nm_ip4_config_get_secondary, nm_ip4_config_set_secondary): remove;
there are better ways to do this in the named manager
* src/nm-device.c
src/nm-device.h
- (nm_device_can_activate): return whether the device can activate a
connection right now; taking into account things like carrier state
and rfkill state
- (nm_device_get_best_auto_connection): renamed from
nm_device_get_best_connection
- (real_act_stage4_get_ip4_config): MTU stuff is now handled in the
device subclasses themselves, so that each device can override the
MTU from it's NMSetting subclass if needed
- (nm_device_set_ip4_config): set MTU when setting up routes and stuff
in NetworkManagerSystem.c, not here
* src/named-manager/nm-named-manager.c
src/named-manager/nm-named-manager.h
- (nm_named_manager_name_owner_changed,
nm_named_manager_dbus_connection_changed): fix for changes to
rewrite_resolv_conf()
- (compute_nameservers): don't need the NMNamedManager at all, remove
from parameter list
- (merge_one_ip4_config): new function; merge ip4 configs together
- (rewrite_resolv_conf): write out resolv.conf from all the stored
ip4 configs; the VPN config takes precedence, then the best
device config, then the rest of the configs
- (get_domain_for_config): take the NMNamedManager as an argument
to check whether the config is the VPN config
- (add_ip4_config_to_named): fixups for removal of the 'secondary'
attribute from ip4 configs
- (add_all_ip4_configs_to_named): add all the configs in priority order
- (remove_ip4_config_from_named): fix for changes to
get_domain_for_config()
- (nm_named_manager_add_ip4_config): assign the config to the right slot
based on its type; callers must pass in the type now
- (get_last_default_domain): remove, unused
- (nm_named_manager_remove_ip4_config): handle config slots correctly
* src/nm-device-802-11-wireless.c
- (real_can_activate): new function
- (real_get_best_auto_connection): renamed from real_get_best_connection
- (real_act_stage4_get_ip4_config): handle MTU override
* src/nm-device-802-3-ethernet.c
- (real_can_activate): new function
- (real_get_best_auto_connection): renamed from real_get_best_connection
- (real_act_stage4_get_ip4_config): new function; handle MTU override
* src/vpn-manager/nm-vpn-connection.c
- (nm_vpn_connection_ip4_config_get): don't need to set the 'secondary'
attribute on the ip4 config
* src/NetworkManagerPolicy.c
- (nm_policy_auto_get_best_device): remove
- (nm_policy_device_change_check): remove
- (update_default_route): new function; set the default route via
the specified device
- (get_device_priority): new function; return the priority number of
a device type WRT which one should have the default route. Order is
(highest to lowest) wired, wireless, GSM, CDMA.
- (update_routing_and_dns): new function; determine which device should
have the default route, then update the routing table and DNS
- (maybe_auto_activate_device): new function; if a device is now
available for activation, find out what connection it would like to
activate and do it
- (schedule_activate_check): new function; if a device can be activated
now, schedule the activation. Each device may have only one
pending activation at a given time.
- (device_state_changed): if activation was canceled, try again,
possibly with another connection; if the device was activated,
update routing and DNS; if the device was deactivated, try again
with another connection
- (device_carrier_changed): if there is no carrier, deactivate the
device; otherwise schedule an activation check for the device
- (wireless_networks_changed): schedule an activation check for the
device
- (device_added): keep track of the signal handler IDs so they can
be removed when the device goes away
- (device_removed): remove any signal handlers that might be attached
to the device; update routing and DNS
- (schedule_activate_all): new function
- (connections_added, connection_added, connection_updated): when
connections change, schedule all devices for an activation check
- (connection_removed): when a device is deactivated because its
connection was removed, schedule another activation check for it
- (nm_policy_destroy): destroy pending activations and disconnect
all device signal handlers
* src/nm-manager.c
- (nm_manager_activate_device): if the device was already actived,
deactivate it
- (deactivate_old_device): remove
- (connection_added_default_handler, impl_manager_activate_device):
don't deactivate other devices when activating this one
* src/backends/NetworkManagerGentoo.c
src/backends/NetworkManagerFrugalware.c
src/backends/NetworkManagerPaldo.c
src/backends/NetworkManagerRedHat.c
src/backends/NetworkManagerSlackware.c
src/backends/NetworkManagerArch.c
src/backends/NetworkManagerSuSE.c
src/backends/NetworkManagerDebian.c
- (nm_system_get_mtu): remove; MTU should be provided through the
distro's system settings service plugin instead
- (nm_system_device_add_default_route_via_device): remove
- (nm_system_device_add_default_route_via_device_with_iface): remove
- (nm_system_device_replace_default_route): new function; call
generic implementation
* src/backends/NetworkManagerGeneric.c
src/backends/NetworkManagerGeneric.h
- (nm_generic_device_add_default_route_via_device,
nm_generic_device_add_default_route_via_device_with_iface): remove
- (nm_generic_device_replace_default_route): replace the default route
with the given route via some gateway
* src/NetworkManagerSystem.c
src/NetworkManagerSystem.h
- (nm_system_device_set_from_ip4_config): let the policy handle updates
to routing and DNS; but set the MTU here
- (nm_system_vpn_device_set_from_ip4_config): set the route with the
ip_iface of the active device; use the standard MTU setting function
- (nm_system_set_mtu): remove
- (nm_system_device_set_mtu): consolidate MTU setting code in one place
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3391 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-03-07 19:41:32 +00:00
|
|
|
{
|
2010-05-25 10:52:25 -07:00
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
if (priv->firmware_missing)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2013-05-07 10:23:44 -04:00
|
|
|
return NM_DEVICE_GET_CLASS (self)->is_available (self);
|
2008-03-07 Dan Williams <dcbw@redhat.com>
First pass of multiple active device support. Expect bugs.
* src/nm-ip4-config.c
src/nm-ip4-config.h
- (nm_ip4_config_get_secondary, nm_ip4_config_set_secondary): remove;
there are better ways to do this in the named manager
* src/nm-device.c
src/nm-device.h
- (nm_device_can_activate): return whether the device can activate a
connection right now; taking into account things like carrier state
and rfkill state
- (nm_device_get_best_auto_connection): renamed from
nm_device_get_best_connection
- (real_act_stage4_get_ip4_config): MTU stuff is now handled in the
device subclasses themselves, so that each device can override the
MTU from it's NMSetting subclass if needed
- (nm_device_set_ip4_config): set MTU when setting up routes and stuff
in NetworkManagerSystem.c, not here
* src/named-manager/nm-named-manager.c
src/named-manager/nm-named-manager.h
- (nm_named_manager_name_owner_changed,
nm_named_manager_dbus_connection_changed): fix for changes to
rewrite_resolv_conf()
- (compute_nameservers): don't need the NMNamedManager at all, remove
from parameter list
- (merge_one_ip4_config): new function; merge ip4 configs together
- (rewrite_resolv_conf): write out resolv.conf from all the stored
ip4 configs; the VPN config takes precedence, then the best
device config, then the rest of the configs
- (get_domain_for_config): take the NMNamedManager as an argument
to check whether the config is the VPN config
- (add_ip4_config_to_named): fixups for removal of the 'secondary'
attribute from ip4 configs
- (add_all_ip4_configs_to_named): add all the configs in priority order
- (remove_ip4_config_from_named): fix for changes to
get_domain_for_config()
- (nm_named_manager_add_ip4_config): assign the config to the right slot
based on its type; callers must pass in the type now
- (get_last_default_domain): remove, unused
- (nm_named_manager_remove_ip4_config): handle config slots correctly
* src/nm-device-802-11-wireless.c
- (real_can_activate): new function
- (real_get_best_auto_connection): renamed from real_get_best_connection
- (real_act_stage4_get_ip4_config): handle MTU override
* src/nm-device-802-3-ethernet.c
- (real_can_activate): new function
- (real_get_best_auto_connection): renamed from real_get_best_connection
- (real_act_stage4_get_ip4_config): new function; handle MTU override
* src/vpn-manager/nm-vpn-connection.c
- (nm_vpn_connection_ip4_config_get): don't need to set the 'secondary'
attribute on the ip4 config
* src/NetworkManagerPolicy.c
- (nm_policy_auto_get_best_device): remove
- (nm_policy_device_change_check): remove
- (update_default_route): new function; set the default route via
the specified device
- (get_device_priority): new function; return the priority number of
a device type WRT which one should have the default route. Order is
(highest to lowest) wired, wireless, GSM, CDMA.
- (update_routing_and_dns): new function; determine which device should
have the default route, then update the routing table and DNS
- (maybe_auto_activate_device): new function; if a device is now
available for activation, find out what connection it would like to
activate and do it
- (schedule_activate_check): new function; if a device can be activated
now, schedule the activation. Each device may have only one
pending activation at a given time.
- (device_state_changed): if activation was canceled, try again,
possibly with another connection; if the device was activated,
update routing and DNS; if the device was deactivated, try again
with another connection
- (device_carrier_changed): if there is no carrier, deactivate the
device; otherwise schedule an activation check for the device
- (wireless_networks_changed): schedule an activation check for the
device
- (device_added): keep track of the signal handler IDs so they can
be removed when the device goes away
- (device_removed): remove any signal handlers that might be attached
to the device; update routing and DNS
- (schedule_activate_all): new function
- (connections_added, connection_added, connection_updated): when
connections change, schedule all devices for an activation check
- (connection_removed): when a device is deactivated because its
connection was removed, schedule another activation check for it
- (nm_policy_destroy): destroy pending activations and disconnect
all device signal handlers
* src/nm-manager.c
- (nm_manager_activate_device): if the device was already actived,
deactivate it
- (deactivate_old_device): remove
- (connection_added_default_handler, impl_manager_activate_device):
don't deactivate other devices when activating this one
* src/backends/NetworkManagerGentoo.c
src/backends/NetworkManagerFrugalware.c
src/backends/NetworkManagerPaldo.c
src/backends/NetworkManagerRedHat.c
src/backends/NetworkManagerSlackware.c
src/backends/NetworkManagerArch.c
src/backends/NetworkManagerSuSE.c
src/backends/NetworkManagerDebian.c
- (nm_system_get_mtu): remove; MTU should be provided through the
distro's system settings service plugin instead
- (nm_system_device_add_default_route_via_device): remove
- (nm_system_device_add_default_route_via_device_with_iface): remove
- (nm_system_device_replace_default_route): new function; call
generic implementation
* src/backends/NetworkManagerGeneric.c
src/backends/NetworkManagerGeneric.h
- (nm_generic_device_add_default_route_via_device,
nm_generic_device_add_default_route_via_device_with_iface): remove
- (nm_generic_device_replace_default_route): replace the default route
with the given route via some gateway
* src/NetworkManagerSystem.c
src/NetworkManagerSystem.h
- (nm_system_device_set_from_ip4_config): let the policy handle updates
to routing and DNS; but set the MTU here
- (nm_system_vpn_device_set_from_ip4_config): set the route with the
ip_iface of the active device; use the standard MTU setting function
- (nm_system_set_mtu): remove
- (nm_system_device_set_mtu): consolidate MTU setting code in one place
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3391 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-03-07 19:41:32 +00:00
|
|
|
}
|
|
|
|
|
|
2013-07-12 10:43:45 -04:00
|
|
|
/**
|
|
|
|
|
* nm_device_can_activate:
|
|
|
|
|
* @self: the #NMDevice
|
|
|
|
|
* @connection: (allow-none) an #NMConnection, or %NULL
|
|
|
|
|
*
|
|
|
|
|
* Checks if @self can currently activate @connection. In particular,
|
|
|
|
|
* this requires that @self is available (per
|
|
|
|
|
* nm_device_is_available()); that it is either managed or able to
|
|
|
|
|
* become managed; and that it is able to activate @connection in its
|
|
|
|
|
* current state (eg, if @connection requires carrier, then @self has
|
|
|
|
|
* carrier).
|
|
|
|
|
*
|
|
|
|
|
* If @connection is %NULL, this just checks that @self could
|
|
|
|
|
* theoretically activate *some* connection.
|
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE or %FALSE
|
|
|
|
|
*/
|
2013-04-24 10:40:58 -04:00
|
|
|
gboolean
|
2013-07-12 10:43:45 -04:00
|
|
|
nm_device_can_activate (NMDevice *self, NMConnection *connection)
|
2013-04-24 10:40:58 -04:00
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
if (!priv->manager_managed)
|
|
|
|
|
return FALSE;
|
2013-07-12 10:43:45 -04:00
|
|
|
|
|
|
|
|
if ( connection
|
|
|
|
|
&& !nm_device_check_connection_compatible (self, connection, NULL))
|
2013-04-24 10:40:58 -04:00
|
|
|
return FALSE;
|
|
|
|
|
|
2013-07-12 10:43:45 -04:00
|
|
|
if (priv->default_unmanaged) {
|
|
|
|
|
if (!nm_device_is_available (self))
|
|
|
|
|
return FALSE;
|
|
|
|
|
} else if (priv->state < NM_DEVICE_STATE_DISCONNECTED) {
|
|
|
|
|
if (priv->state != NM_DEVICE_STATE_UNAVAILABLE || priv->carrier || !priv->ignore_carrier)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
/* @self is UNAVAILABLE because it doesn't have carrier, but
|
|
|
|
|
* ignore-carrier is set, so we might be able to ignore that.
|
|
|
|
|
*/
|
|
|
|
|
if (connection && connection_is_static (connection))
|
|
|
|
|
return TRUE;
|
|
|
|
|
else if (!connection && has_static_connection (self))
|
|
|
|
|
return TRUE;
|
|
|
|
|
else
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
2013-04-24 10:40:58 -04:00
|
|
|
}
|
|
|
|
|
|
2013-03-19 10:24:35 -04:00
|
|
|
gboolean
|
|
|
|
|
nm_device_ignore_carrier (NMDevice *dev)
|
|
|
|
|
{
|
|
|
|
|
return NM_DEVICE_GET_PRIVATE (dev)->ignore_carrier;
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-17 23:28:30 -06:00
|
|
|
gboolean
|
|
|
|
|
nm_device_get_enabled (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (self), FALSE);
|
|
|
|
|
|
|
|
|
|
if (NM_DEVICE_GET_CLASS (self)->get_enabled)
|
|
|
|
|
return NM_DEVICE_GET_CLASS (self)->get_enabled (self);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-17 23:38:08 -06:00
|
|
|
void
|
|
|
|
|
nm_device_set_enabled (NMDevice *self, gboolean enabled)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (NM_IS_DEVICE (self));
|
|
|
|
|
|
|
|
|
|
if (NM_DEVICE_GET_CLASS (self)->set_enabled)
|
|
|
|
|
NM_DEVICE_GET_CLASS (self)->set_enabled (self, enabled);
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-18 12:02:58 -06:00
|
|
|
RfKillType
|
|
|
|
|
nm_device_get_rfkill_type (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (self), FALSE);
|
|
|
|
|
|
|
|
|
|
return NM_DEVICE_GET_PRIVATE (self)->rfkill_type;
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-15 17:22:10 -04:00
|
|
|
static gboolean
|
|
|
|
|
autoconnect_allowed_accumulator (GSignalInvocationHint *ihint,
|
|
|
|
|
GValue *return_accu,
|
|
|
|
|
const GValue *handler_return, gpointer data)
|
|
|
|
|
{
|
|
|
|
|
if (!g_value_get_boolean (handler_return))
|
|
|
|
|
g_value_set_boolean (return_accu, FALSE);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
|
nm_device_autoconnect_allowed (NMDevice *self)
|
|
|
|
|
{
|
2009-09-16 13:18:24 +02:00
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
2013-03-22 10:49:19 +01:00
|
|
|
GValue instance = G_VALUE_INIT;
|
|
|
|
|
GValue retval = G_VALUE_INIT;
|
2009-07-15 17:22:10 -04:00
|
|
|
|
|
|
|
|
g_value_init (&instance, G_TYPE_OBJECT);
|
|
|
|
|
g_value_take_object (&instance, self);
|
|
|
|
|
|
|
|
|
|
g_value_init (&retval, G_TYPE_BOOLEAN);
|
2012-05-14 15:32:54 +02:00
|
|
|
if (priv->autoconnect)
|
2009-09-16 13:18:24 +02:00
|
|
|
g_value_set_boolean (&retval, TRUE);
|
2012-05-14 15:32:54 +02:00
|
|
|
else
|
|
|
|
|
g_value_set_boolean (&retval, FALSE);
|
2009-07-15 17:22:10 -04:00
|
|
|
|
|
|
|
|
/* Use g_signal_emitv() rather than g_signal_emit() to avoid the return
|
|
|
|
|
* value being changed if no handlers are connected */
|
|
|
|
|
g_signal_emitv (&instance, signals[AUTOCONNECT_ALLOWED], 0, &retval);
|
|
|
|
|
return g_value_get_boolean (&retval);
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-06 16:16:54 -05:00
|
|
|
static gboolean
|
|
|
|
|
can_auto_connect (NMDevice *device,
|
|
|
|
|
NMConnection *connection,
|
|
|
|
|
char **specific_object)
|
|
|
|
|
{
|
|
|
|
|
NMSettingConnection *s_con;
|
|
|
|
|
|
|
|
|
|
s_con = nm_connection_get_setting_connection (connection);
|
|
|
|
|
if (!nm_setting_connection_get_autoconnect (s_con))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2013-07-12 10:43:45 -04:00
|
|
|
return nm_device_can_activate (device, connection);
|
2013-03-06 16:16:54 -05:00
|
|
|
}
|
|
|
|
|
|
2013-06-27 14:39:13 +02:00
|
|
|
static gboolean
|
|
|
|
|
device_has_config (NMDevice *device)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
|
|
|
|
|
|
|
|
|
|
/* Check for IP configuration. */
|
|
|
|
|
if (priv->ip4_config && nm_ip4_config_get_num_addresses (priv->ip4_config))
|
|
|
|
|
return TRUE;
|
|
|
|
|
if (priv->ip6_config && nm_ip6_config_get_num_addresses (priv->ip6_config))
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
/* The existence of a software device is good enough. */
|
|
|
|
|
if (nm_device_is_software (device))
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NMConnection *
|
|
|
|
|
nm_device_generate_connection (NMDevice *device)
|
|
|
|
|
{
|
|
|
|
|
NMDeviceClass *klass = NM_DEVICE_GET_CLASS (device);
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
|
|
|
|
|
const char *ifname = nm_device_get_iface (device);
|
|
|
|
|
NMConnection *connection;
|
|
|
|
|
NMSetting *s_con;
|
|
|
|
|
NMSetting *s_ip4;
|
|
|
|
|
NMSetting *s_ip6;
|
|
|
|
|
gs_free char *uuid = NULL;
|
|
|
|
|
gs_free char *name = NULL;
|
|
|
|
|
|
|
|
|
|
/* If update_connection() is not implemented, just fail. */
|
|
|
|
|
if (!klass->update_connection)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
/* Return NULL if device is unconfigured. */
|
|
|
|
|
if (!device_has_config (device))
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
nm_log_info (LOGD_DEVICE, "(%s): Generating connection from current device status.", ifname);
|
|
|
|
|
|
|
|
|
|
connection = nm_connection_new ();
|
|
|
|
|
s_con = nm_setting_connection_new ();
|
|
|
|
|
s_ip4 = nm_setting_ip4_config_new ();
|
|
|
|
|
s_ip6 = nm_setting_ip6_config_new ();
|
|
|
|
|
uuid = nm_utils_uuid_generate ();
|
|
|
|
|
name = g_strdup_printf ("%s", ifname);
|
|
|
|
|
|
|
|
|
|
g_object_set (s_con,
|
|
|
|
|
NM_SETTING_CONNECTION_UUID, uuid,
|
|
|
|
|
NM_SETTING_CONNECTION_ID, name,
|
|
|
|
|
NM_SETTING_CONNECTION_AUTOCONNECT, FALSE,
|
|
|
|
|
NM_SETTING_CONNECTION_TIMESTAMP, (guint64) time (NULL),
|
|
|
|
|
NULL);
|
|
|
|
|
if (klass->connection_type)
|
|
|
|
|
g_object_set (s_con, NM_SETTING_CONNECTION_TYPE, klass->connection_type, NULL);
|
|
|
|
|
nm_ip4_config_update_setting (priv->ip4_config, (NMSettingIP4Config *) s_ip4);
|
|
|
|
|
nm_ip6_config_update_setting (priv->ip6_config, (NMSettingIP6Config *) s_ip6);
|
|
|
|
|
|
|
|
|
|
nm_connection_add_setting (connection, s_con);
|
|
|
|
|
nm_connection_add_setting (connection, s_ip4);
|
|
|
|
|
nm_connection_add_setting (connection, s_ip6);
|
|
|
|
|
|
|
|
|
|
klass->update_connection (device, connection);
|
|
|
|
|
|
|
|
|
|
/* Check the connection in case of update_connection() bug. */
|
|
|
|
|
g_return_val_if_fail (nm_connection_verify (connection, NULL), NULL);
|
|
|
|
|
|
|
|
|
|
return connection;
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-13 13:52:55 -04:00
|
|
|
/**
|
|
|
|
|
* nm_device_get_best_auto_connection:
|
|
|
|
|
* @dev: an #NMDevice
|
|
|
|
|
* @connections: (element-type #NMConnection): a list of connections
|
|
|
|
|
* @specific_object: (out) (transfer full): on output, the path of an
|
|
|
|
|
* object associated with the returned connection, to be passed to
|
|
|
|
|
* nm_manager_activate_connection(), or %NULL.
|
|
|
|
|
*
|
|
|
|
|
* Looks through @connections to see if there is a connection that can
|
|
|
|
|
* be auto-activated on @dev right now. This requires, at a minimum,
|
|
|
|
|
* that the connection be compatible with @dev, and that it have the
|
|
|
|
|
* #NMSettingConnection:autoconnect property set. Some devices impose
|
|
|
|
|
* additional requirements. (Eg, a Wi-Fi connection can only be
|
|
|
|
|
* activated if its SSID was seen in the last scan.)
|
|
|
|
|
*
|
|
|
|
|
* Returns: an auto-activatable #NMConnection, or %NULL if none are
|
|
|
|
|
* available.
|
|
|
|
|
*/
|
|
|
|
|
|
2007-09-09 17:58:44 +00:00
|
|
|
NMConnection *
|
2008-03-07 Dan Williams <dcbw@redhat.com>
First pass of multiple active device support. Expect bugs.
* src/nm-ip4-config.c
src/nm-ip4-config.h
- (nm_ip4_config_get_secondary, nm_ip4_config_set_secondary): remove;
there are better ways to do this in the named manager
* src/nm-device.c
src/nm-device.h
- (nm_device_can_activate): return whether the device can activate a
connection right now; taking into account things like carrier state
and rfkill state
- (nm_device_get_best_auto_connection): renamed from
nm_device_get_best_connection
- (real_act_stage4_get_ip4_config): MTU stuff is now handled in the
device subclasses themselves, so that each device can override the
MTU from it's NMSetting subclass if needed
- (nm_device_set_ip4_config): set MTU when setting up routes and stuff
in NetworkManagerSystem.c, not here
* src/named-manager/nm-named-manager.c
src/named-manager/nm-named-manager.h
- (nm_named_manager_name_owner_changed,
nm_named_manager_dbus_connection_changed): fix for changes to
rewrite_resolv_conf()
- (compute_nameservers): don't need the NMNamedManager at all, remove
from parameter list
- (merge_one_ip4_config): new function; merge ip4 configs together
- (rewrite_resolv_conf): write out resolv.conf from all the stored
ip4 configs; the VPN config takes precedence, then the best
device config, then the rest of the configs
- (get_domain_for_config): take the NMNamedManager as an argument
to check whether the config is the VPN config
- (add_ip4_config_to_named): fixups for removal of the 'secondary'
attribute from ip4 configs
- (add_all_ip4_configs_to_named): add all the configs in priority order
- (remove_ip4_config_from_named): fix for changes to
get_domain_for_config()
- (nm_named_manager_add_ip4_config): assign the config to the right slot
based on its type; callers must pass in the type now
- (get_last_default_domain): remove, unused
- (nm_named_manager_remove_ip4_config): handle config slots correctly
* src/nm-device-802-11-wireless.c
- (real_can_activate): new function
- (real_get_best_auto_connection): renamed from real_get_best_connection
- (real_act_stage4_get_ip4_config): handle MTU override
* src/nm-device-802-3-ethernet.c
- (real_can_activate): new function
- (real_get_best_auto_connection): renamed from real_get_best_connection
- (real_act_stage4_get_ip4_config): new function; handle MTU override
* src/vpn-manager/nm-vpn-connection.c
- (nm_vpn_connection_ip4_config_get): don't need to set the 'secondary'
attribute on the ip4 config
* src/NetworkManagerPolicy.c
- (nm_policy_auto_get_best_device): remove
- (nm_policy_device_change_check): remove
- (update_default_route): new function; set the default route via
the specified device
- (get_device_priority): new function; return the priority number of
a device type WRT which one should have the default route. Order is
(highest to lowest) wired, wireless, GSM, CDMA.
- (update_routing_and_dns): new function; determine which device should
have the default route, then update the routing table and DNS
- (maybe_auto_activate_device): new function; if a device is now
available for activation, find out what connection it would like to
activate and do it
- (schedule_activate_check): new function; if a device can be activated
now, schedule the activation. Each device may have only one
pending activation at a given time.
- (device_state_changed): if activation was canceled, try again,
possibly with another connection; if the device was activated,
update routing and DNS; if the device was deactivated, try again
with another connection
- (device_carrier_changed): if there is no carrier, deactivate the
device; otherwise schedule an activation check for the device
- (wireless_networks_changed): schedule an activation check for the
device
- (device_added): keep track of the signal handler IDs so they can
be removed when the device goes away
- (device_removed): remove any signal handlers that might be attached
to the device; update routing and DNS
- (schedule_activate_all): new function
- (connections_added, connection_added, connection_updated): when
connections change, schedule all devices for an activation check
- (connection_removed): when a device is deactivated because its
connection was removed, schedule another activation check for it
- (nm_policy_destroy): destroy pending activations and disconnect
all device signal handlers
* src/nm-manager.c
- (nm_manager_activate_device): if the device was already actived,
deactivate it
- (deactivate_old_device): remove
- (connection_added_default_handler, impl_manager_activate_device):
don't deactivate other devices when activating this one
* src/backends/NetworkManagerGentoo.c
src/backends/NetworkManagerFrugalware.c
src/backends/NetworkManagerPaldo.c
src/backends/NetworkManagerRedHat.c
src/backends/NetworkManagerSlackware.c
src/backends/NetworkManagerArch.c
src/backends/NetworkManagerSuSE.c
src/backends/NetworkManagerDebian.c
- (nm_system_get_mtu): remove; MTU should be provided through the
distro's system settings service plugin instead
- (nm_system_device_add_default_route_via_device): remove
- (nm_system_device_add_default_route_via_device_with_iface): remove
- (nm_system_device_replace_default_route): new function; call
generic implementation
* src/backends/NetworkManagerGeneric.c
src/backends/NetworkManagerGeneric.h
- (nm_generic_device_add_default_route_via_device,
nm_generic_device_add_default_route_via_device_with_iface): remove
- (nm_generic_device_replace_default_route): replace the default route
with the given route via some gateway
* src/NetworkManagerSystem.c
src/NetworkManagerSystem.h
- (nm_system_device_set_from_ip4_config): let the policy handle updates
to routing and DNS; but set the MTU here
- (nm_system_vpn_device_set_from_ip4_config): set the route with the
ip_iface of the active device; use the standard MTU setting function
- (nm_system_set_mtu): remove
- (nm_system_device_set_mtu): consolidate MTU setting code in one place
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3391 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-03-07 19:41:32 +00:00
|
|
|
nm_device_get_best_auto_connection (NMDevice *dev,
|
|
|
|
|
GSList *connections,
|
|
|
|
|
char **specific_object)
|
2007-09-09 17:58:44 +00:00
|
|
|
{
|
2013-03-06 16:16:54 -05:00
|
|
|
GSList *iter;
|
2007-09-09 17:58:44 +00:00
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (dev), NULL);
|
2007-09-10 19:11:40 +00:00
|
|
|
g_return_val_if_fail (specific_object != NULL, NULL);
|
|
|
|
|
g_return_val_if_fail (*specific_object == NULL, NULL);
|
2007-09-09 17:58:44 +00:00
|
|
|
|
2012-11-08 13:15:51 -05:00
|
|
|
for (iter = connections; iter; iter = iter->next) {
|
|
|
|
|
NMConnection *connection = NM_CONNECTION (iter->data);
|
2012-11-12 13:29:06 -05:00
|
|
|
|
2013-03-06 16:16:54 -05:00
|
|
|
if (NM_DEVICE_GET_CLASS (dev)->can_auto_connect (dev, connection, specific_object))
|
|
|
|
|
return connection;
|
2012-11-08 13:15:51 -05:00
|
|
|
}
|
|
|
|
|
|
2013-03-06 16:16:54 -05:00
|
|
|
return NULL;
|
2007-09-09 17:58:44 +00:00
|
|
|
}
|
|
|
|
|
|
2011-01-10 23:39:12 -06:00
|
|
|
gboolean
|
|
|
|
|
nm_device_complete_connection (NMDevice *self,
|
|
|
|
|
NMConnection *connection,
|
|
|
|
|
const char *specific_object,
|
|
|
|
|
const GSList *existing_connections,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
|
|
|
|
gboolean success = FALSE;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (self != NULL, FALSE);
|
|
|
|
|
g_return_val_if_fail (connection != NULL, FALSE);
|
|
|
|
|
|
|
|
|
|
if (!NM_DEVICE_GET_CLASS (self)->complete_connection) {
|
2011-11-18 00:05:37 -06:00
|
|
|
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CONNECTION_INVALID,
|
2011-01-10 23:39:12 -06:00
|
|
|
"Device class %s had no complete_connection method",
|
|
|
|
|
G_OBJECT_TYPE_NAME (self));
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
success = NM_DEVICE_GET_CLASS (self)->complete_connection (self,
|
|
|
|
|
connection,
|
|
|
|
|
specific_object,
|
|
|
|
|
existing_connections,
|
|
|
|
|
error);
|
|
|
|
|
if (success)
|
|
|
|
|
success = nm_connection_verify (connection, error);
|
|
|
|
|
|
|
|
|
|
return success;
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-07 07:44:36 -05:00
|
|
|
static gboolean
|
|
|
|
|
check_connection_compatible (NMDevice *device,
|
|
|
|
|
NMConnection *connection,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
|
|
|
|
NMSettingConnection *s_con;
|
|
|
|
|
const char *config_iface, *device_iface;
|
|
|
|
|
|
|
|
|
|
s_con = nm_connection_get_setting_connection (connection);
|
|
|
|
|
g_assert (s_con);
|
|
|
|
|
|
|
|
|
|
config_iface = nm_setting_connection_get_interface_name (s_con);
|
|
|
|
|
device_iface = nm_device_get_iface (device);
|
2013-04-04 11:06:39 -04:00
|
|
|
if (config_iface && strcmp (config_iface, device_iface) != 0) {
|
|
|
|
|
g_set_error (error,
|
|
|
|
|
NM_DEVICE_ERROR, NM_DEVICE_ERROR_CONNECTION_INVALID,
|
|
|
|
|
"The connection is not valid for this interface.");
|
2013-03-07 07:44:36 -05:00
|
|
|
return FALSE;
|
2013-04-04 11:06:39 -04:00
|
|
|
}
|
2013-03-07 07:44:36 -05:00
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-13 13:52:55 -04:00
|
|
|
/**
|
|
|
|
|
* nm_device_check_connection_compatible:
|
|
|
|
|
* @device: an #NMDevice
|
|
|
|
|
* @connection: an #NMConnection
|
|
|
|
|
* @error: return location for an error, or %NULL
|
|
|
|
|
*
|
|
|
|
|
* Checks if @connection could potentially be activated on @device.
|
|
|
|
|
* This means only that @device has the proper capabilities, and that
|
|
|
|
|
* @connection is not locked to some other device. It does not
|
|
|
|
|
* necessarily mean that @connection could be activated on @device
|
|
|
|
|
* right now. (Eg, it might refer to a Wi-Fi network that is not
|
|
|
|
|
* currently available.)
|
|
|
|
|
*
|
|
|
|
|
* Returns: #TRUE if @connection could potentially be activated on
|
|
|
|
|
* @device.
|
|
|
|
|
*/
|
2011-11-17 23:04:47 -06:00
|
|
|
gboolean
|
|
|
|
|
nm_device_check_connection_compatible (NMDevice *device,
|
|
|
|
|
NMConnection *connection,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (device), FALSE);
|
|
|
|
|
g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
|
|
|
|
|
|
2013-03-07 07:44:36 -05:00
|
|
|
return NM_DEVICE_GET_CLASS (device)->check_connection_compatible (device, connection, error);
|
2011-11-17 23:04:47 -06:00
|
|
|
}
|
|
|
|
|
|
2013-06-27 14:39:13 +02:00
|
|
|
/**
|
|
|
|
|
* nm_device_can_assume_connections:
|
|
|
|
|
* @device: #NMDevice instance
|
|
|
|
|
*
|
|
|
|
|
* This is a convenience function to determine whether connection assumption
|
|
|
|
|
* via old match_l2_config() or new update_connection() virtual functions
|
|
|
|
|
* is available for this device.
|
|
|
|
|
*
|
|
|
|
|
* Use this function when you need to determine whether full cleanup should
|
|
|
|
|
* be performed for this device or whether the device should be kept running
|
|
|
|
|
* between NetworkManager runs.
|
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE for assumable connections and %FALS for full-cleanup connections.
|
|
|
|
|
*
|
|
|
|
|
* FIXME: Consider turning this method into (a) a device capability or (b) a class
|
|
|
|
|
* method.
|
|
|
|
|
*/
|
2011-11-17 23:10:11 -06:00
|
|
|
gboolean
|
|
|
|
|
nm_device_can_assume_connections (NMDevice *device)
|
|
|
|
|
{
|
2013-06-27 14:39:13 +02:00
|
|
|
NMDeviceClass *klass = NM_DEVICE_GET_CLASS (device);
|
2011-11-17 23:10:11 -06:00
|
|
|
|
2013-06-27 14:39:13 +02:00
|
|
|
return klass->match_l2_config || klass->update_connection;
|
2011-11-17 23:10:11 -06:00
|
|
|
}
|
|
|
|
|
|
2008-05-29 20:58:52 +00:00
|
|
|
static void
|
|
|
|
|
dnsmasq_state_changed_cb (NMDnsMasqManager *manager, guint32 status, gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMDevice *self = NM_DEVICE (user_data);
|
|
|
|
|
|
|
|
|
|
switch (status) {
|
|
|
|
|
case NM_DNSMASQ_STATUS_DEAD:
|
2008-07-11 10:28:53 +00:00
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_SHARED_START_FAILED);
|
2008-05-29 20:58:52 +00:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-03-23 17:36:52 -04:00
|
|
|
static void
|
2009-07-29 12:12:41 -04:00
|
|
|
activation_source_clear (NMDevice *self, gboolean remove_source, int family)
|
2009-03-23 17:36:52 -04:00
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
2009-07-29 12:12:41 -04:00
|
|
|
guint *act_source_id;
|
|
|
|
|
gpointer *act_source_func;
|
|
|
|
|
|
|
|
|
|
if (family == AF_INET6) {
|
|
|
|
|
act_source_id = &priv->act_source6_id;
|
|
|
|
|
act_source_func = &priv->act_source6_func;
|
|
|
|
|
} else {
|
|
|
|
|
act_source_id = &priv->act_source_id;
|
|
|
|
|
act_source_func = &priv->act_source_func;
|
|
|
|
|
}
|
2009-03-23 17:36:52 -04:00
|
|
|
|
2009-07-29 12:12:41 -04:00
|
|
|
if (*act_source_id) {
|
2009-03-23 17:36:52 -04:00
|
|
|
if (remove_source)
|
2009-07-29 12:12:41 -04:00
|
|
|
g_source_remove (*act_source_id);
|
|
|
|
|
*act_source_id = 0;
|
|
|
|
|
*act_source_func = NULL;
|
2009-03-23 17:36:52 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2009-07-29 12:12:41 -04:00
|
|
|
activation_source_schedule (NMDevice *self, GSourceFunc func, int family)
|
2009-03-23 17:36:52 -04:00
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
2009-07-29 12:12:41 -04:00
|
|
|
guint *act_source_id;
|
|
|
|
|
gpointer *act_source_func;
|
2009-03-23 17:36:52 -04:00
|
|
|
|
2009-07-29 12:12:41 -04:00
|
|
|
if (family == AF_INET6) {
|
|
|
|
|
act_source_id = &priv->act_source6_id;
|
|
|
|
|
act_source_func = &priv->act_source6_func;
|
|
|
|
|
} else {
|
|
|
|
|
act_source_id = &priv->act_source_id;
|
|
|
|
|
act_source_func = &priv->act_source_func;
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-07 12:31:39 -07:00
|
|
|
if (*act_source_id) {
|
|
|
|
|
nm_log_err (LOGD_DEVICE, "activation stage already scheduled");
|
|
|
|
|
}
|
2009-03-23 17:36:52 -04:00
|
|
|
|
|
|
|
|
/* Don't bother rescheduling the same function that's about to
|
|
|
|
|
* run anyway. Fixes issues with crappy wireless drivers sending
|
|
|
|
|
* streams of associate events before NM has had a chance to process
|
|
|
|
|
* the first one.
|
|
|
|
|
*/
|
2009-07-29 12:12:41 -04:00
|
|
|
if (!*act_source_id || (*act_source_func != func)) {
|
|
|
|
|
activation_source_clear (self, TRUE, family);
|
|
|
|
|
*act_source_id = g_idle_add (func, self);
|
|
|
|
|
*act_source_func = func;
|
2009-03-23 17:36:52 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-05-03 01:19:54 -07:00
|
|
|
gboolean
|
|
|
|
|
nm_device_ip_config_should_fail (NMDevice *self, gboolean ip6)
|
|
|
|
|
{
|
|
|
|
|
NMConnection *connection;
|
|
|
|
|
NMSettingIP4Config *s_ip4;
|
|
|
|
|
NMSettingIP6Config *s_ip6;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (self != NULL, TRUE);
|
|
|
|
|
|
2011-12-05 12:27:49 +01:00
|
|
|
connection = nm_device_get_connection (self);
|
2010-05-03 01:19:54 -07:00
|
|
|
g_assert (connection);
|
|
|
|
|
|
|
|
|
|
/* Fail the connection if the failed IP method is required to complete */
|
|
|
|
|
if (ip6) {
|
2011-10-09 22:50:04 -05:00
|
|
|
s_ip6 = nm_connection_get_setting_ip6_config (connection);
|
2010-05-03 01:19:54 -07:00
|
|
|
if (s_ip6 && !nm_setting_ip6_config_get_may_fail (s_ip6))
|
|
|
|
|
return TRUE;
|
|
|
|
|
} else {
|
2011-10-09 22:50:04 -05:00
|
|
|
s_ip4 = nm_connection_get_setting_ip4_config (connection);
|
2010-05-03 01:19:54 -07:00
|
|
|
if (s_ip4 && !nm_setting_ip4_config_get_may_fail (s_ip4))
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-14 00:45:10 -08:00
|
|
|
static NMActStageReturn
|
2012-09-27 12:12:15 -04:00
|
|
|
act_stage1_prepare (NMDevice *self, NMDeviceStateReason *reason)
|
2010-01-14 00:45:10 -08:00
|
|
|
{
|
2012-11-14 14:05:30 -06:00
|
|
|
return NM_ACT_STAGE_RETURN_SUCCESS;
|
2011-10-18 13:48:48 +02:00
|
|
|
}
|
|
|
|
|
|
2005-12-31 08:21:24 +00:00
|
|
|
/*
|
|
|
|
|
* nm_device_activate_stage1_device_prepare
|
|
|
|
|
*
|
|
|
|
|
* Prepare for device activation
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
static gboolean
|
2007-01-04 12:06:26 +00:00
|
|
|
nm_device_activate_stage1_device_prepare (gpointer user_data)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
2007-06-11 13:36:34 +00:00
|
|
|
NMDevice *self = NM_DEVICE (user_data);
|
2010-01-27 16:20:09 -08:00
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
2009-07-29 12:12:41 -04:00
|
|
|
const char *iface;
|
2007-01-04 12:06:26 +00:00
|
|
|
NMActStageReturn ret;
|
2008-07-11 10:28:53 +00:00
|
|
|
NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-01-04 12:06:26 +00:00
|
|
|
/* Clear the activation source ID now that this stage has run */
|
2009-07-29 12:12:41 -04:00
|
|
|
activation_source_clear (self, FALSE, 0);
|
2006-12-28 22:13:59 +00:00
|
|
|
|
2011-10-09 23:48:13 -05:00
|
|
|
priv->ip4_state = priv->ip6_state = IP_NONE;
|
2010-01-27 16:20:09 -08:00
|
|
|
|
2005-12-31 08:21:24 +00:00
|
|
|
iface = nm_device_get_iface (self);
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_DEVICE, "Activation (%s) Stage 1 of 5 (Device Prepare) started...", iface);
|
2008-07-11 10:28:53 +00:00
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_PREPARE, NM_DEVICE_STATE_REASON_NONE);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2008-07-11 10:28:53 +00:00
|
|
|
ret = NM_DEVICE_GET_CLASS (self)->act_stage1_prepare (self, &reason);
|
2006-12-28 22:13:59 +00:00
|
|
|
if (ret == NM_ACT_STAGE_RETURN_POSTPONE) {
|
2006-01-03 17:07:07 +00:00
|
|
|
goto out;
|
2006-12-28 22:13:59 +00:00
|
|
|
} else if (ret == NM_ACT_STAGE_RETURN_FAILURE) {
|
2008-07-11 10:28:53 +00:00
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, reason);
|
2006-01-03 17:07:07 +00:00
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
g_assert (ret == NM_ACT_STAGE_RETURN_SUCCESS);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-06-11 13:36:34 +00:00
|
|
|
nm_device_activate_schedule_stage2_device_config (self);
|
2006-01-03 17:07:07 +00:00
|
|
|
|
|
|
|
|
out:
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_DEVICE, "Activation (%s) Stage 1 of 5 (Device Prepare) complete.", iface);
|
2005-12-31 08:21:24 +00:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* nm_device_activate_schedule_stage1_device_prepare
|
|
|
|
|
*
|
|
|
|
|
* Prepare a device for activation
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
void
|
2007-06-11 13:36:34 +00:00
|
|
|
nm_device_activate_schedule_stage1_device_prepare (NMDevice *self)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
2007-06-11 13:36:34 +00:00
|
|
|
NMDevicePrivate *priv;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-06-11 13:36:34 +00:00
|
|
|
g_return_if_fail (NM_IS_DEVICE (self));
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-06-11 13:36:34 +00:00
|
|
|
priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
g_return_if_fail (priv->act_request);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2009-07-29 12:12:41 -04:00
|
|
|
activation_source_schedule (self, nm_device_activate_stage1_device_prepare, 0);
|
2006-12-28 22:13:59 +00:00
|
|
|
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_DEVICE, "Activation (%s) Stage 1 of 5 (Device Prepare) scheduled...",
|
|
|
|
|
nm_device_get_iface (self));
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
2006-01-03 17:07:07 +00:00
|
|
|
static NMActStageReturn
|
2012-09-27 12:12:15 -04:00
|
|
|
act_stage2_config (NMDevice *dev, NMDeviceStateReason *reason)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
2012-11-14 14:05:30 -06:00
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (dev);
|
|
|
|
|
GSList *iter;
|
|
|
|
|
|
|
|
|
|
/* If we have slaves that aren't yet enslaved, do that now */
|
|
|
|
|
for (iter = priv->slaves; iter; iter = g_slist_next (iter)) {
|
|
|
|
|
SlaveInfo *info = iter->data;
|
|
|
|
|
|
|
|
|
|
if (nm_device_get_state (info->slave) == NM_DEVICE_STATE_IP_CONFIG)
|
|
|
|
|
nm_device_enslave_slave (dev, info->slave, nm_device_get_connection (info->slave));
|
|
|
|
|
}
|
|
|
|
|
|
2005-12-31 08:21:24 +00:00
|
|
|
/* Nothing to do */
|
2006-01-03 17:07:07 +00:00
|
|
|
return NM_ACT_STAGE_RETURN_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
2005-12-31 08:21:24 +00:00
|
|
|
/*
|
|
|
|
|
* nm_device_activate_stage2_device_config
|
|
|
|
|
*
|
|
|
|
|
* Determine device parameters and set those on the device, ie
|
2007-06-27 16:18:52 +00:00
|
|
|
* for wireless devices, set SSID, keys, etc.
|
2005-12-31 08:21:24 +00:00
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
static gboolean
|
2007-01-04 12:06:26 +00:00
|
|
|
nm_device_activate_stage2_device_config (gpointer user_data)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
2007-06-11 13:36:34 +00:00
|
|
|
NMDevice *self = NM_DEVICE (user_data);
|
2007-01-04 12:06:26 +00:00
|
|
|
const char * iface;
|
|
|
|
|
NMActStageReturn ret;
|
2008-07-11 10:28:53 +00:00
|
|
|
NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE;
|
2008-08-18 18:29:47 +00:00
|
|
|
gboolean no_firmware = FALSE;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-01-04 12:06:26 +00:00
|
|
|
/* Clear the activation source ID now that this stage has run */
|
2009-07-29 12:12:41 -04:00
|
|
|
activation_source_clear (self, FALSE, 0);
|
2006-12-28 22:13:59 +00:00
|
|
|
|
2005-12-31 08:21:24 +00:00
|
|
|
iface = nm_device_get_iface (self);
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_DEVICE, "Activation (%s) Stage 2 of 5 (Device Configure) starting...", iface);
|
2008-07-11 10:28:53 +00:00
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_CONFIG, NM_DEVICE_STATE_REASON_NONE);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2013-06-13 15:13:58 -05:00
|
|
|
if (!nm_device_bring_up (self, FALSE, &no_firmware)) {
|
2008-08-18 18:29:47 +00:00
|
|
|
if (no_firmware)
|
|
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_FIRMWARE_MISSING);
|
|
|
|
|
else
|
|
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_CONFIG_FAILED);
|
2007-03-12 04:49:29 +00:00
|
|
|
goto out;
|
|
|
|
|
}
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2008-07-11 10:28:53 +00:00
|
|
|
ret = NM_DEVICE_GET_CLASS (self)->act_stage2_config (self, &reason);
|
2006-01-03 17:07:07 +00:00
|
|
|
if (ret == NM_ACT_STAGE_RETURN_POSTPONE)
|
|
|
|
|
goto out;
|
|
|
|
|
else if (ret == NM_ACT_STAGE_RETURN_FAILURE)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
2008-07-11 10:28:53 +00:00
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, reason);
|
2005-12-31 08:21:24 +00:00
|
|
|
goto out;
|
|
|
|
|
}
|
2006-01-03 17:07:07 +00:00
|
|
|
g_assert (ret == NM_ACT_STAGE_RETURN_SUCCESS);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_DEVICE, "Activation (%s) Stage 2 of 5 (Device Configure) successful.", iface);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-06-11 13:36:34 +00:00
|
|
|
nm_device_activate_schedule_stage3_ip_config_start (self);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
|
|
|
|
out:
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_DEVICE, "Activation (%s) Stage 2 of 5 (Device Configure) complete.", iface);
|
2005-12-31 08:21:24 +00:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* nm_device_activate_schedule_stage2_device_config
|
|
|
|
|
*
|
|
|
|
|
* Schedule setup of the hardware device
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
void
|
2007-06-11 13:36:34 +00:00
|
|
|
nm_device_activate_schedule_stage2_device_config (NMDevice *self)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
2007-06-11 13:36:34 +00:00
|
|
|
NMDevicePrivate *priv;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-06-11 13:36:34 +00:00
|
|
|
g_return_if_fail (NM_IS_DEVICE (self));
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-06-11 13:36:34 +00:00
|
|
|
priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
g_return_if_fail (priv->act_request);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2009-07-29 12:12:41 -04:00
|
|
|
activation_source_schedule (self, nm_device_activate_stage2_device_config, 0);
|
2006-12-28 22:13:59 +00:00
|
|
|
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_DEVICE, "Activation (%s) Stage 2 of 5 (Device Configure) scheduled...",
|
2006-12-28 22:13:59 +00:00
|
|
|
nm_device_get_iface (self));
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
2011-10-07 11:50:37 -05:00
|
|
|
/*********************************************/
|
|
|
|
|
/* avahi-autoipd stuff */
|
|
|
|
|
|
2008-07-09 14:05:49 +00:00
|
|
|
static void
|
|
|
|
|
aipd_timeout_remove (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
if (priv->aipd_timeout) {
|
|
|
|
|
g_source_remove (priv->aipd_timeout);
|
|
|
|
|
priv->aipd_timeout = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
aipd_cleanup (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
if (priv->aipd_watch) {
|
|
|
|
|
g_source_remove (priv->aipd_watch);
|
|
|
|
|
priv->aipd_watch = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2008-07-27 19:42:54 +00:00
|
|
|
if (priv->aipd_pid > 0) {
|
|
|
|
|
kill (priv->aipd_pid, SIGKILL);
|
2008-08-27 17:22:32 +00:00
|
|
|
|
|
|
|
|
/* ensure the child is reaped */
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_dbg (LOGD_AUTOIP4, "waiting for avahi-autoipd pid %d to exit", priv->aipd_pid);
|
2008-08-27 17:22:32 +00:00
|
|
|
waitpid (priv->aipd_pid, NULL, 0);
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_dbg (LOGD_AUTOIP4, "avahi-autoip pid %d cleaned up", priv->aipd_pid);
|
2008-08-27 17:22:32 +00:00
|
|
|
|
2008-07-27 19:42:54 +00:00
|
|
|
priv->aipd_pid = -1;
|
|
|
|
|
}
|
|
|
|
|
|
2008-07-09 14:05:49 +00:00
|
|
|
aipd_timeout_remove (self);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static NMIP4Config *
|
2013-07-31 23:59:50 +02:00
|
|
|
aipd_get_ip4_config (NMDevice *self, guint32 lla)
|
2008-07-09 14:05:49 +00:00
|
|
|
{
|
|
|
|
|
NMIP4Config *config = NULL;
|
2013-06-29 13:33:36 +02:00
|
|
|
NMPlatformIP4Address address;
|
2013-07-31 23:07:32 +02:00
|
|
|
NMPlatformIP4Route route;
|
2008-07-09 14:05:49 +00:00
|
|
|
|
|
|
|
|
config = nm_ip4_config_new ();
|
2011-10-09 22:50:04 -05:00
|
|
|
g_assert (config);
|
2008-07-11 10:28:53 +00:00
|
|
|
|
2013-06-29 13:33:36 +02:00
|
|
|
memset (&address, 0, sizeof (address));
|
2013-07-31 23:59:50 +02:00
|
|
|
address.address = lla;
|
2013-06-29 13:33:36 +02:00
|
|
|
address.plen = 16;
|
|
|
|
|
nm_ip4_config_add_address (config, &address);
|
2008-07-09 14:05:49 +00:00
|
|
|
|
2010-06-09 15:01:23 +02:00
|
|
|
/* Add a multicast route for link-local connections: destination= 224.0.0.0, netmask=240.0.0.0 */
|
2013-07-31 23:07:32 +02:00
|
|
|
memset (&route, 0, sizeof (route));
|
|
|
|
|
route.network = htonl (0xE0000000L);
|
|
|
|
|
route.plen = 4;
|
|
|
|
|
nm_ip4_config_add_route (config, &route);
|
2010-06-09 15:01:23 +02:00
|
|
|
|
2013-07-31 23:07:32 +02:00
|
|
|
return config;
|
2008-07-09 14:05:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define IPV4LL_NETWORK (htonl (0xA9FE0000L))
|
|
|
|
|
#define IPV4LL_NETMASK (htonl (0xFFFF0000L))
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
nm_device_handle_autoip4_event (NMDevice *self,
|
|
|
|
|
const char *event,
|
|
|
|
|
const char *address)
|
|
|
|
|
{
|
2011-10-09 23:48:13 -05:00
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
2008-07-09 14:05:49 +00:00
|
|
|
NMConnection *connection = NULL;
|
|
|
|
|
NMSettingIP4Config *s_ip4 = NULL;
|
2008-10-29 14:35:25 +00:00
|
|
|
const char *iface, *method = NULL;
|
2013-08-01 10:34:46 -05:00
|
|
|
NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE;
|
2008-07-09 14:05:49 +00:00
|
|
|
|
|
|
|
|
g_return_if_fail (event != NULL);
|
|
|
|
|
|
2011-10-09 23:48:13 -05:00
|
|
|
if (priv->act_request == NULL)
|
2008-07-09 14:05:49 +00:00
|
|
|
return;
|
|
|
|
|
|
2011-10-09 23:48:13 -05:00
|
|
|
connection = nm_act_request_get_connection (priv->act_request);
|
|
|
|
|
g_assert (connection);
|
2008-07-09 14:05:49 +00:00
|
|
|
|
|
|
|
|
/* Ignore if the connection isn't an AutoIP connection */
|
2011-10-09 22:50:04 -05:00
|
|
|
s_ip4 = nm_connection_get_setting_ip4_config (connection);
|
2008-10-29 14:35:25 +00:00
|
|
|
if (s_ip4)
|
|
|
|
|
method = nm_setting_ip4_config_get_method (s_ip4);
|
|
|
|
|
|
2011-10-09 22:50:04 -05:00
|
|
|
if (g_strcmp0 (method, NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL) != 0)
|
2008-07-09 14:05:49 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
iface = nm_device_get_iface (self);
|
|
|
|
|
|
|
|
|
|
if (strcmp (event, "BIND") == 0) {
|
2013-07-31 23:59:50 +02:00
|
|
|
guint32 lla;
|
2011-10-09 22:50:04 -05:00
|
|
|
NMIP4Config *config;
|
2008-07-09 14:05:49 +00:00
|
|
|
|
2011-10-09 22:50:04 -05:00
|
|
|
if (inet_pton (AF_INET, address, &lla) <= 0) {
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_err (LOGD_AUTOIP4, "(%s): invalid address %s received from avahi-autoipd.",
|
2008-07-09 14:05:49 +00:00
|
|
|
iface, address);
|
2008-07-11 10:28:53 +00:00
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_AUTOIP_ERROR);
|
2008-07-09 14:05:49 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-31 23:59:50 +02:00
|
|
|
if ((lla & IPV4LL_NETMASK) != IPV4LL_NETWORK) {
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_err (LOGD_AUTOIP4, "(%s): invalid address %s received from avahi-autoipd (not link-local).",
|
2008-07-09 14:05:49 +00:00
|
|
|
iface, address);
|
2008-07-11 10:28:53 +00:00
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_AUTOIP_ERROR);
|
2008-07-09 14:05:49 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-09 22:50:04 -05:00
|
|
|
config = aipd_get_ip4_config (self, lla);
|
|
|
|
|
if (config == NULL) {
|
|
|
|
|
nm_log_err (LOGD_AUTOIP4, "failed to get autoip config");
|
|
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-09 23:48:13 -05:00
|
|
|
if (priv->ip4_state == IP_CONF) {
|
2008-07-09 14:05:49 +00:00
|
|
|
aipd_timeout_remove (self);
|
2011-10-09 22:50:04 -05:00
|
|
|
nm_device_activate_schedule_ip4_config_result (self, config);
|
2011-10-09 23:48:13 -05:00
|
|
|
} else if (priv->ip4_state == IP_DONE) {
|
2013-08-01 15:44:53 -05:00
|
|
|
if (!ip4_config_merge_and_apply (self, config, TRUE, &reason)) {
|
2013-08-01 10:34:46 -05:00
|
|
|
nm_log_err (LOGD_AUTOIP4, "(%s): failed to update IP4 config for autoip change.",
|
|
|
|
|
nm_device_get_iface (self));
|
|
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, reason);
|
|
|
|
|
}
|
2011-10-09 23:48:13 -05:00
|
|
|
} else
|
|
|
|
|
g_assert_not_reached ();
|
2011-10-09 22:50:04 -05:00
|
|
|
|
2011-10-09 23:48:13 -05:00
|
|
|
g_object_unref (config);
|
2008-07-09 14:05:49 +00:00
|
|
|
} else {
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_warn (LOGD_AUTOIP4, "(%s): autoip address %s no longer valid because '%s'.",
|
2008-07-09 14:05:49 +00:00
|
|
|
iface, address, event);
|
|
|
|
|
|
|
|
|
|
/* The address is gone; terminate the connection or fail activation */
|
2008-07-11 10:28:53 +00:00
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_IP_CONFIG_EXPIRED);
|
2008-07-09 14:05:49 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
aipd_watch_cb (GPid pid, gint status, gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMDevice *self = NM_DEVICE (user_data);
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
NMDeviceState state;
|
|
|
|
|
const char *iface;
|
|
|
|
|
|
|
|
|
|
if (!priv->aipd_watch)
|
|
|
|
|
return;
|
|
|
|
|
priv->aipd_watch = 0;
|
|
|
|
|
|
|
|
|
|
iface = nm_device_get_iface (self);
|
|
|
|
|
|
2010-04-07 12:31:39 -07:00
|
|
|
if (WIFEXITED (status)) {
|
|
|
|
|
nm_log_dbg (LOGD_AUTOIP4, "(%s): avahi-autoipd exited with error code %d",
|
|
|
|
|
iface, WEXITSTATUS (status));
|
|
|
|
|
} else if (WIFSTOPPED (status)) {
|
|
|
|
|
nm_log_warn (LOGD_AUTOIP4, "(%s): avahi-autoipd stopped unexpectedly with signal %d",
|
|
|
|
|
iface, WSTOPSIG (status));
|
|
|
|
|
} else if (WIFSIGNALED (status)) {
|
|
|
|
|
nm_log_warn (LOGD_AUTOIP4, "(%s): avahi-autoipd died with signal %d",
|
|
|
|
|
iface, WTERMSIG (status));
|
|
|
|
|
} else {
|
|
|
|
|
nm_log_warn (LOGD_AUTOIP4, "(%s): avahi-autoipd died from an unknown cause", iface);
|
|
|
|
|
}
|
2008-07-09 14:05:49 +00:00
|
|
|
|
|
|
|
|
aipd_cleanup (self);
|
|
|
|
|
|
|
|
|
|
state = nm_device_get_state (self);
|
|
|
|
|
if (nm_device_is_activating (self) || (state == NM_DEVICE_STATE_ACTIVATED))
|
2008-07-11 10:28:53 +00:00
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_AUTOIP_FAILED);
|
2008-07-09 14:05:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
aipd_timeout_cb (gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMDevice *self = NM_DEVICE (user_data);
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
|
2011-10-09 23:48:13 -05:00
|
|
|
if (priv->aipd_timeout) {
|
|
|
|
|
nm_log_info (LOGD_AUTOIP4, "(%s): avahi-autoipd timed out.", nm_device_get_iface (self));
|
|
|
|
|
priv->aipd_timeout = 0;
|
|
|
|
|
aipd_cleanup (self);
|
2008-07-09 14:05:49 +00:00
|
|
|
|
2011-10-09 23:48:13 -05:00
|
|
|
if (priv->ip4_state == IP_CONF)
|
|
|
|
|
nm_device_activate_schedule_ip4_config_timeout (self);
|
|
|
|
|
}
|
2008-07-09 14:05:49 +00:00
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
aipd_child_setup (gpointer user_data G_GNUC_UNUSED)
|
|
|
|
|
{
|
|
|
|
|
/* We are in the child process at this point.
|
|
|
|
|
* Give child it's own program group for signal
|
|
|
|
|
* separation.
|
|
|
|
|
*/
|
|
|
|
|
pid_t pid = getpid ();
|
|
|
|
|
setpgid (pid, pid);
|
2012-05-21 14:10:05 +02:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* We blocked signals in main(). We need to restore original signal
|
|
|
|
|
* mask for avahi-autoipd here so that it can receive signals.
|
|
|
|
|
*/
|
|
|
|
|
nm_unblock_posix_signals (NULL);
|
2008-07-09 14:05:49 +00:00
|
|
|
}
|
|
|
|
|
|
2011-10-09 22:50:04 -05:00
|
|
|
static NMActStageReturn
|
|
|
|
|
aipd_start (NMDevice *self, NMDeviceStateReason *reason)
|
2008-07-09 14:05:49 +00:00
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
2011-10-09 22:50:04 -05:00
|
|
|
const char *iface = nm_device_get_iface (self);
|
2010-08-08 01:36:35 -05:00
|
|
|
char *argv[6], *cmdline;
|
2008-07-09 14:05:49 +00:00
|
|
|
const char **aipd_binary = NULL;
|
|
|
|
|
static const char *aipd_paths[] = {
|
|
|
|
|
"/usr/sbin/avahi-autoipd",
|
|
|
|
|
"/usr/local/sbin/avahi-autoipd",
|
|
|
|
|
NULL
|
|
|
|
|
};
|
2010-08-08 01:36:35 -05:00
|
|
|
int i = 0;
|
2011-10-09 22:50:04 -05:00
|
|
|
GError *error = NULL;
|
2008-07-09 14:05:49 +00:00
|
|
|
|
|
|
|
|
aipd_cleanup (self);
|
|
|
|
|
|
|
|
|
|
/* Find avahi-autoipd */
|
|
|
|
|
aipd_binary = aipd_paths;
|
|
|
|
|
while (*aipd_binary != NULL) {
|
|
|
|
|
if (g_file_test (*aipd_binary, G_FILE_TEST_EXISTS))
|
|
|
|
|
break;
|
|
|
|
|
aipd_binary++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!*aipd_binary) {
|
2011-10-09 22:50:04 -05:00
|
|
|
nm_log_warn (LOGD_DEVICE | LOGD_AUTOIP4,
|
|
|
|
|
"Activation (%s) Stage 3 of 5 (IP Configure Start) failed"
|
|
|
|
|
" to start avahi-autoipd: not found", iface);
|
|
|
|
|
*reason = NM_DEVICE_STATE_REASON_AUTOIP_START_FAILED;
|
|
|
|
|
return NM_ACT_STAGE_RETURN_FAILURE;
|
2008-07-09 14:05:49 +00:00
|
|
|
}
|
|
|
|
|
|
2010-08-08 01:36:35 -05:00
|
|
|
argv[i++] = (char *) (*aipd_binary);
|
|
|
|
|
argv[i++] = "--script";
|
2013-05-22 16:12:23 +02:00
|
|
|
argv[i++] = (char *) nm_device_autoipd_helper_path;
|
|
|
|
|
|
2010-08-08 01:36:35 -05:00
|
|
|
if (nm_logging_level_enabled (LOGL_DEBUG))
|
|
|
|
|
argv[i++] = "--debug";
|
|
|
|
|
argv[i++] = (char *) nm_device_get_ip_iface (self);
|
|
|
|
|
argv[i++] = NULL;
|
|
|
|
|
|
|
|
|
|
cmdline = g_strjoinv (" ", argv);
|
2011-10-09 22:50:04 -05:00
|
|
|
nm_log_dbg (LOGD_AUTOIP4, "running: %s", cmdline);
|
2010-08-08 01:36:35 -05:00
|
|
|
g_free (cmdline);
|
2008-07-09 14:05:49 +00:00
|
|
|
|
2011-10-09 22:50:04 -05:00
|
|
|
if (!g_spawn_async ("/", argv, NULL, G_SPAWN_DO_NOT_REAP_CHILD,
|
|
|
|
|
&aipd_child_setup, NULL, &(priv->aipd_pid), &error)) {
|
|
|
|
|
nm_log_warn (LOGD_DEVICE | LOGD_AUTOIP4,
|
|
|
|
|
"Activation (%s) Stage 3 of 5 (IP Configure Start) failed"
|
|
|
|
|
" to start avahi-autoipd: %s",
|
|
|
|
|
iface,
|
|
|
|
|
error && error->message ? error->message : "(unknown)");
|
|
|
|
|
g_clear_error (&error);
|
|
|
|
|
aipd_cleanup (self);
|
|
|
|
|
return NM_ACT_STAGE_RETURN_FAILURE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nm_log_info (LOGD_DEVICE | LOGD_AUTOIP4,
|
|
|
|
|
"Activation (%s) Stage 3 of 5 (IP Configure Start) started"
|
|
|
|
|
" avahi-autoipd...", iface);
|
2008-07-09 14:05:49 +00:00
|
|
|
|
|
|
|
|
/* Monitor the child process so we know when it dies */
|
|
|
|
|
priv->aipd_watch = g_child_watch_add (priv->aipd_pid, aipd_watch_cb, self);
|
|
|
|
|
|
|
|
|
|
/* Start a timeout to bound the address attempt */
|
2008-12-31 18:57:36 -05:00
|
|
|
priv->aipd_timeout = g_timeout_add_seconds (20, aipd_timeout_cb, self);
|
2008-07-09 14:05:49 +00:00
|
|
|
|
2011-10-09 22:50:04 -05:00
|
|
|
return NM_ACT_STAGE_RETURN_POSTPONE;
|
2008-07-09 14:05:49 +00:00
|
|
|
}
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2011-10-07 11:50:37 -05:00
|
|
|
/*********************************************/
|
|
|
|
|
/* DHCPv4 stuff */
|
|
|
|
|
|
2010-01-12 22:09:28 -08:00
|
|
|
static void
|
|
|
|
|
dhcp4_add_option_cb (gpointer key, gpointer value, gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
nm_dhcp4_config_add_option (NM_DHCP4_CONFIG (user_data),
|
|
|
|
|
(const char *) key,
|
|
|
|
|
(const char *) value);
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-01 10:34:46 -05:00
|
|
|
static gboolean
|
|
|
|
|
ip4_config_merge_and_apply (NMDevice *self,
|
|
|
|
|
NMIP4Config *config,
|
2013-08-01 15:44:53 -05:00
|
|
|
gboolean commit,
|
2013-08-01 10:34:46 -05:00
|
|
|
NMDeviceStateReason *out_reason)
|
2010-01-12 22:09:28 -08:00
|
|
|
{
|
2013-08-01 10:34:46 -05:00
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
2010-01-12 22:09:28 -08:00
|
|
|
NMConnection *connection;
|
2013-08-01 10:34:46 -05:00
|
|
|
gboolean success;
|
|
|
|
|
NMIP4Config *composite;
|
2010-01-12 22:09:28 -08:00
|
|
|
|
2013-08-01 10:34:46 -05:00
|
|
|
/* Merge all the configs into the composite config */
|
|
|
|
|
if (config) {
|
|
|
|
|
g_clear_object (&priv->dev_ip4_config);
|
|
|
|
|
priv->dev_ip4_config = g_object_ref (config);
|
2011-10-07 12:05:51 -05:00
|
|
|
}
|
2010-01-14 00:45:10 -08:00
|
|
|
|
2013-08-01 10:34:46 -05:00
|
|
|
composite = nm_ip4_config_new ();
|
2013-08-01 15:44:53 -05:00
|
|
|
if (priv->dev_ip4_config)
|
|
|
|
|
nm_ip4_config_merge (composite, priv->dev_ip4_config);
|
2013-08-01 10:59:42 -05:00
|
|
|
if (priv->vpn4_config)
|
|
|
|
|
nm_ip4_config_merge (composite, priv->vpn4_config);
|
2013-08-01 15:44:53 -05:00
|
|
|
if (priv->ext_ip4_config)
|
|
|
|
|
nm_ip4_config_merge (composite, priv->ext_ip4_config);
|
2010-01-14 00:45:10 -08:00
|
|
|
|
2013-08-01 10:34:46 -05:00
|
|
|
/* Merge user overrides into the composite config */
|
2013-08-01 15:44:53 -05:00
|
|
|
connection = nm_device_get_connection (self);
|
|
|
|
|
if (connection)
|
|
|
|
|
nm_ip4_config_merge_setting (composite, nm_connection_get_setting_ip4_config (connection));
|
2013-08-01 10:34:46 -05:00
|
|
|
|
|
|
|
|
/* Allow setting MTU etc */
|
2013-08-01 15:44:53 -05:00
|
|
|
if (commit) {
|
|
|
|
|
if (NM_DEVICE_GET_CLASS (self)->ip4_config_pre_commit)
|
|
|
|
|
NM_DEVICE_GET_CLASS (self)->ip4_config_pre_commit (self, composite);
|
|
|
|
|
}
|
2011-10-09 22:50:04 -05:00
|
|
|
|
2013-08-01 15:44:53 -05:00
|
|
|
success = nm_device_set_ip4_config (self, composite, commit, out_reason);
|
2013-08-01 10:34:46 -05:00
|
|
|
g_object_unref (composite);
|
|
|
|
|
return success;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
dhcp4_lease_change (NMDevice *self, NMIP4Config *config)
|
|
|
|
|
{
|
|
|
|
|
NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (config != NULL);
|
|
|
|
|
|
2013-08-01 15:44:53 -05:00
|
|
|
if (!ip4_config_merge_and_apply (self, config, TRUE, &reason)) {
|
2013-08-01 10:34:46 -05:00
|
|
|
nm_log_warn (LOGD_DHCP4, "(%s): failed to update IPv4 config for DHCP change.",
|
|
|
|
|
nm_device_get_ip_iface (self));
|
|
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, reason);
|
|
|
|
|
} else {
|
|
|
|
|
/* Notify dispatcher scripts of new DHCP4 config */
|
|
|
|
|
nm_dispatcher_call (DISPATCHER_ACTION_DHCP4_CHANGE,
|
|
|
|
|
nm_device_get_connection (self),
|
|
|
|
|
self,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL);
|
|
|
|
|
}
|
2010-01-12 22:09:28 -08:00
|
|
|
}
|
|
|
|
|
|
2011-10-07 12:23:35 -05:00
|
|
|
static void
|
|
|
|
|
dhcp4_fail (NMDevice *device, gboolean timeout)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
|
|
|
|
|
|
|
|
|
|
nm_dhcp4_config_reset (priv->dhcp4_config);
|
|
|
|
|
|
2011-10-09 23:48:13 -05:00
|
|
|
if (timeout || (priv->ip4_state == IP_CONF))
|
2011-10-09 22:50:04 -05:00
|
|
|
nm_device_activate_schedule_ip4_config_timeout (device);
|
2013-07-02 16:42:49 +02:00
|
|
|
else if (priv->ip4_state == IP_FAIL)
|
2011-10-07 12:23:35 -05:00
|
|
|
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_IP_CONFIG_EXPIRED);
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-12 22:09:28 -08:00
|
|
|
static void
|
2011-10-07 12:05:51 -05:00
|
|
|
dhcp4_state_changed (NMDHCPClient *client,
|
|
|
|
|
NMDHCPState state,
|
|
|
|
|
gpointer user_data)
|
2010-01-12 22:09:28 -08:00
|
|
|
{
|
|
|
|
|
NMDevice *device = NM_DEVICE (user_data);
|
2011-10-09 22:50:04 -05:00
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
|
2010-01-12 22:09:28 -08:00
|
|
|
NMDeviceState dev_state;
|
2011-10-09 22:50:04 -05:00
|
|
|
NMIP4Config *config;
|
2010-01-12 22:09:28 -08:00
|
|
|
|
2011-10-07 12:05:51 -05:00
|
|
|
g_return_if_fail (nm_dhcp_client_get_ipv6 (client) == FALSE);
|
2010-01-12 22:09:28 -08:00
|
|
|
|
2011-10-07 12:05:51 -05:00
|
|
|
nm_log_dbg (LOGD_DHCP4, "(%s): new DHCPv4 client state %d",
|
|
|
|
|
nm_device_get_iface (device), state);
|
|
|
|
|
|
|
|
|
|
dev_state = nm_device_get_state (device);
|
2010-05-01 09:26:57 -07:00
|
|
|
|
2010-01-12 22:09:28 -08:00
|
|
|
switch (state) {
|
|
|
|
|
case DHC_BOUND4: /* lease obtained */
|
|
|
|
|
case DHC_RENEW4: /* lease renewed */
|
|
|
|
|
case DHC_REBOOT: /* have valid lease, but now obtained a different one */
|
|
|
|
|
case DHC_REBIND4: /* new, different lease */
|
2011-10-09 22:50:04 -05:00
|
|
|
config = nm_dhcp_client_get_ip4_config (priv->dhcp4_client, FALSE);
|
2013-08-01 10:34:46 -05:00
|
|
|
if (!config) {
|
|
|
|
|
nm_log_warn (LOGD_DHCP4, "(%s): failed to get IPv4 config in response to DHCP event.",
|
|
|
|
|
nm_device_get_ip_iface (device));
|
|
|
|
|
nm_device_state_changed (device,
|
|
|
|
|
NM_DEVICE_STATE_FAILED,
|
|
|
|
|
NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-09 23:48:13 -05:00
|
|
|
if (priv->ip4_state == IP_CONF)
|
2011-10-09 22:50:04 -05:00
|
|
|
nm_device_activate_schedule_ip4_config_result (device, config);
|
2011-10-09 23:48:13 -05:00
|
|
|
else if (priv->ip4_state == IP_DONE)
|
2011-10-09 22:50:04 -05:00
|
|
|
dhcp4_lease_change (device, config);
|
2013-08-01 10:34:46 -05:00
|
|
|
g_object_unref (config);
|
2011-10-09 23:48:13 -05:00
|
|
|
|
2013-08-01 10:34:46 -05:00
|
|
|
/* Update the DHCP4 config object with new DHCP options */
|
|
|
|
|
nm_dhcp4_config_reset (priv->dhcp4_config);
|
|
|
|
|
nm_dhcp_client_foreach_option (priv->dhcp4_client,
|
|
|
|
|
dhcp4_add_option_cb,
|
|
|
|
|
priv->dhcp4_config);
|
|
|
|
|
g_object_notify (G_OBJECT (device), NM_DEVICE_DHCP4_CONFIG);
|
2010-01-12 22:09:28 -08:00
|
|
|
break;
|
|
|
|
|
case DHC_TIMEOUT: /* timed out contacting DHCP server */
|
2011-10-07 12:23:35 -05:00
|
|
|
dhcp4_fail (device, TRUE);
|
2010-01-12 22:09:28 -08:00
|
|
|
break;
|
2010-05-01 10:16:38 -07:00
|
|
|
case DHC_END: /* dhclient exited normally */
|
2010-01-12 22:09:28 -08:00
|
|
|
case DHC_FAIL: /* all attempts to contact server timed out, sleeping */
|
|
|
|
|
case DHC_ABEND: /* dhclient exited abnormally */
|
2010-01-13 17:59:54 -08:00
|
|
|
/* dhclient quit and can't get/renew a lease; so kill the connection */
|
2011-10-07 12:23:35 -05:00
|
|
|
dhcp4_fail (device, FALSE);
|
2010-01-12 22:09:28 -08:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2011-10-07 12:05:51 -05:00
|
|
|
dhcp4_timeout (NMDHCPClient *client, gpointer user_data)
|
2010-01-12 22:09:28 -08:00
|
|
|
{
|
|
|
|
|
NMDevice *device = NM_DEVICE (user_data);
|
|
|
|
|
|
2011-10-07 12:05:51 -05:00
|
|
|
g_return_if_fail (nm_device_get_act_request (device) != NULL);
|
|
|
|
|
g_return_if_fail (nm_dhcp_client_get_ipv6 (client) == FALSE);
|
2010-01-12 22:09:28 -08:00
|
|
|
|
2011-01-05 16:23:00 -06:00
|
|
|
nm_dhcp_client_stop (client, FALSE);
|
2011-10-07 12:23:35 -05:00
|
|
|
dhcp4_fail (device, TRUE);
|
2010-01-12 22:09:28 -08:00
|
|
|
}
|
|
|
|
|
|
2011-01-05 14:07:32 -06:00
|
|
|
static NMActStageReturn
|
|
|
|
|
dhcp4_start (NMDevice *self,
|
|
|
|
|
NMConnection *connection,
|
|
|
|
|
NMDeviceStateReason *reason)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
2011-01-05 16:23:00 -06:00
|
|
|
NMSettingIP4Config *s_ip4;
|
2011-01-05 14:07:32 -06:00
|
|
|
guint8 *anycast = NULL;
|
2012-06-13 13:28:55 -05:00
|
|
|
GByteArray *tmp = NULL;
|
2011-01-05 14:07:32 -06:00
|
|
|
|
2011-12-05 12:27:47 +01:00
|
|
|
s_ip4 = nm_connection_get_setting_ip4_config (connection);
|
2011-01-05 14:07:32 -06:00
|
|
|
|
|
|
|
|
if (priv->dhcp_anycast_address)
|
|
|
|
|
anycast = priv->dhcp_anycast_address->data;
|
|
|
|
|
|
|
|
|
|
/* Clear old exported DHCP options */
|
|
|
|
|
if (priv->dhcp4_config)
|
|
|
|
|
g_object_unref (priv->dhcp4_config);
|
|
|
|
|
priv->dhcp4_config = nm_dhcp4_config_new ();
|
|
|
|
|
|
2013-05-01 09:28:16 -04:00
|
|
|
if (priv->hw_addr_len) {
|
|
|
|
|
tmp = g_byte_array_sized_new (priv->hw_addr_len);
|
|
|
|
|
g_byte_array_append (tmp, priv->hw_addr, priv->hw_addr_len);
|
2012-06-13 13:28:55 -05:00
|
|
|
}
|
|
|
|
|
|
2011-01-05 16:23:00 -06:00
|
|
|
/* Begin DHCP on the interface */
|
2011-01-05 14:07:32 -06:00
|
|
|
g_warn_if_fail (priv->dhcp4_client == NULL);
|
|
|
|
|
priv->dhcp4_client = nm_dhcp_manager_start_ip4 (priv->dhcp_manager,
|
|
|
|
|
nm_device_get_ip_iface (self),
|
2012-06-13 13:28:55 -05:00
|
|
|
tmp,
|
2011-03-08 13:41:28 +01:00
|
|
|
nm_connection_get_uuid (connection),
|
2011-01-05 14:07:32 -06:00
|
|
|
s_ip4,
|
|
|
|
|
priv->dhcp_timeout,
|
|
|
|
|
anycast);
|
2012-06-13 13:28:55 -05:00
|
|
|
|
|
|
|
|
if (tmp)
|
|
|
|
|
g_byte_array_free (tmp, TRUE);
|
|
|
|
|
|
2011-01-05 14:07:32 -06:00
|
|
|
if (!priv->dhcp4_client) {
|
|
|
|
|
*reason = NM_DEVICE_STATE_REASON_DHCP_START_FAILED;
|
|
|
|
|
return NM_ACT_STAGE_RETURN_FAILURE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
priv->dhcp4_state_sigid = g_signal_connect (priv->dhcp4_client,
|
|
|
|
|
"state-changed",
|
2011-10-07 12:05:51 -05:00
|
|
|
G_CALLBACK (dhcp4_state_changed),
|
2011-01-05 14:07:32 -06:00
|
|
|
self);
|
|
|
|
|
priv->dhcp4_timeout_sigid = g_signal_connect (priv->dhcp4_client,
|
|
|
|
|
"timeout",
|
2011-10-07 12:05:51 -05:00
|
|
|
G_CALLBACK (dhcp4_timeout),
|
2011-01-05 14:07:32 -06:00
|
|
|
self);
|
|
|
|
|
|
|
|
|
|
/* DHCP devices will be notified by the DHCP manager when stuff happens */
|
|
|
|
|
return NM_ACT_STAGE_RETURN_POSTPONE;
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-05 16:23:00 -06:00
|
|
|
gboolean
|
|
|
|
|
nm_device_dhcp4_renew (NMDevice *self, gboolean release)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
NMActStageReturn ret;
|
|
|
|
|
NMDeviceStateReason reason;
|
|
|
|
|
NMConnection *connection;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (priv->dhcp4_client != NULL, FALSE);
|
|
|
|
|
|
2011-09-21 00:30:38 -05:00
|
|
|
nm_log_info (LOGD_DHCP4, "(%s): DHCPv4 lease renewal requested",
|
|
|
|
|
nm_device_get_iface (self));
|
|
|
|
|
|
2011-01-05 16:23:00 -06:00
|
|
|
/* Terminate old DHCP instance and release the old lease */
|
2011-09-21 00:30:38 -05:00
|
|
|
dhcp4_cleanup (self, TRUE, release);
|
2011-01-05 16:23:00 -06:00
|
|
|
|
2011-12-05 12:27:49 +01:00
|
|
|
connection = nm_device_get_connection (self);
|
2011-01-05 16:23:00 -06:00
|
|
|
g_assert (connection);
|
|
|
|
|
|
|
|
|
|
/* Start DHCP again on the interface */
|
|
|
|
|
ret = dhcp4_start (self, connection, &reason);
|
|
|
|
|
|
|
|
|
|
return (ret != NM_ACT_STAGE_RETURN_FAILURE);
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-07 11:50:37 -05:00
|
|
|
/*********************************************/
|
|
|
|
|
|
|
|
|
|
static GHashTable *shared_ips = NULL;
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
release_shared_ip (gpointer data)
|
|
|
|
|
{
|
|
|
|
|
g_hash_table_remove (shared_ips, data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static guint32
|
|
|
|
|
reserve_shared_ip (void)
|
|
|
|
|
{
|
|
|
|
|
guint32 start = (guint32) ntohl (0x0a2a0001); /* 10.42.0.1 */
|
|
|
|
|
guint32 count = 0;
|
|
|
|
|
|
|
|
|
|
while (g_hash_table_lookup (shared_ips, GUINT_TO_POINTER (start + count))) {
|
|
|
|
|
count += ntohl (0x100);
|
|
|
|
|
if (count > ntohl (0xFE00)) {
|
|
|
|
|
nm_log_err (LOGD_SHARING, "ran out of shared IP addresses!");
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_hash_table_insert (shared_ips, GUINT_TO_POINTER (start + count), GUINT_TO_POINTER (TRUE));
|
|
|
|
|
return start + count;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static NMIP4Config *
|
2011-10-09 22:50:04 -05:00
|
|
|
shared4_new_config (NMDevice *self, NMDeviceStateReason *reason)
|
2011-10-07 11:50:37 -05:00
|
|
|
{
|
|
|
|
|
NMIP4Config *config = NULL;
|
2013-06-29 13:33:36 +02:00
|
|
|
NMPlatformIP4Address address;
|
2011-10-07 11:50:37 -05:00
|
|
|
guint32 tmp_addr;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (self != NULL, NULL);
|
|
|
|
|
|
|
|
|
|
if (G_UNLIKELY (shared_ips == NULL))
|
|
|
|
|
shared_ips = g_hash_table_new (g_direct_hash, g_direct_equal);
|
|
|
|
|
|
|
|
|
|
tmp_addr = reserve_shared_ip ();
|
|
|
|
|
if (!tmp_addr) {
|
|
|
|
|
*reason = NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE;
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
config = nm_ip4_config_new ();
|
2013-06-29 13:33:36 +02:00
|
|
|
memset (&address, 0, sizeof (address));
|
|
|
|
|
address.address = tmp_addr;
|
|
|
|
|
address.plen = 24;
|
|
|
|
|
nm_ip4_config_add_address (config, &address);
|
2011-10-07 11:50:37 -05:00
|
|
|
|
|
|
|
|
/* Remove the address lock when the object gets disposed */
|
|
|
|
|
g_object_set_data_full (G_OBJECT (config), "shared-ip",
|
|
|
|
|
GUINT_TO_POINTER (tmp_addr), release_shared_ip);
|
|
|
|
|
|
|
|
|
|
return config;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*********************************************/
|
|
|
|
|
|
2013-01-25 11:59:05 -06:00
|
|
|
static gboolean
|
|
|
|
|
have_any_ready_slaves (NMDevice *device, const GSList *slaves)
|
|
|
|
|
{
|
|
|
|
|
const GSList *iter;
|
|
|
|
|
|
|
|
|
|
/* Any enslaved slave is "ready" in the generic case as it's
|
|
|
|
|
* at least >= NM_DEVCIE_STATE_IP_CONFIG and has had Layer 2
|
|
|
|
|
* properties set up.
|
|
|
|
|
*/
|
|
|
|
|
for (iter = slaves; iter; iter = g_slist_next (iter)) {
|
|
|
|
|
if (nm_device_get_enslaved (iter->data))
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
ip4_requires_slaves (NMConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
NMSettingIP4Config *s_ip4;
|
|
|
|
|
const char *method = NM_SETTING_IP4_CONFIG_METHOD_AUTO;
|
|
|
|
|
|
|
|
|
|
s_ip4 = nm_connection_get_setting_ip4_config (connection);
|
|
|
|
|
if (s_ip4)
|
|
|
|
|
method = nm_setting_ip4_config_get_method (s_ip4);
|
|
|
|
|
|
|
|
|
|
return g_strcmp0 (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO) == 0;
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-03 17:47:38 +00:00
|
|
|
static NMActStageReturn
|
2012-09-27 12:12:15 -04:00
|
|
|
act_stage3_ip4_config_start (NMDevice *self,
|
|
|
|
|
NMIP4Config **out_config,
|
|
|
|
|
NMDeviceStateReason *reason)
|
2007-06-06 13:33:51 +00:00
|
|
|
{
|
2010-04-23 12:56:33 -07:00
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
2009-05-03 00:51:09 -04:00
|
|
|
NMConnection *connection;
|
2008-07-03 16:22:17 +00:00
|
|
|
NMSettingIP4Config *s_ip4;
|
2011-12-06 17:00:40 -06:00
|
|
|
NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
|
2011-10-09 22:50:04 -05:00
|
|
|
const char *method = NM_SETTING_IP4_CONFIG_METHOD_AUTO;
|
2013-01-25 11:59:05 -06:00
|
|
|
GSList *slaves;
|
|
|
|
|
gboolean ready_slaves;
|
2008-07-09 14:05:49 +00:00
|
|
|
|
2008-07-11 10:28:53 +00:00
|
|
|
g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE);
|
|
|
|
|
|
2013-06-07 15:11:23 -05:00
|
|
|
connection = nm_device_get_connection (self);
|
|
|
|
|
g_assert (connection);
|
|
|
|
|
|
|
|
|
|
/* If we did not receive IP4 configuration information, default to DHCP.
|
|
|
|
|
* Slaves, on the other hand, never have any IP configuration themselves,
|
|
|
|
|
* since the master handles all of that.
|
|
|
|
|
*/
|
|
|
|
|
s_ip4 = nm_connection_get_setting_ip4_config (connection);
|
|
|
|
|
if (priv->master) /* eg, device is a slave */
|
|
|
|
|
method = NM_SETTING_IP4_CONFIG_METHOD_DISABLED;
|
|
|
|
|
else if (s_ip4)
|
|
|
|
|
method = nm_setting_ip4_config_get_method (s_ip4);
|
|
|
|
|
else
|
|
|
|
|
method = NM_SETTING_IP4_CONFIG_METHOD_AUTO;
|
|
|
|
|
|
|
|
|
|
if ( g_strcmp0 (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL) != 0
|
|
|
|
|
&& nm_device_is_master (self)
|
2013-05-07 10:23:44 -04:00
|
|
|
&& nm_device_is_unavailable_because_of_carrier (self)) {
|
|
|
|
|
nm_log_info (LOGD_IP4 | LOGD_DEVICE,
|
|
|
|
|
"(%s): IPv4 config waiting until carrier is on",
|
|
|
|
|
nm_device_get_ip_iface (self));
|
|
|
|
|
return NM_ACT_STAGE_RETURN_WAIT;
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-25 11:59:05 -06:00
|
|
|
if (priv->is_master && ip4_requires_slaves (connection)) {
|
|
|
|
|
/* If the master has no ready slaves, and depends on slaves for
|
|
|
|
|
* a successful IPv4 attempt, then postpone IPv4 addressing.
|
|
|
|
|
*/
|
|
|
|
|
slaves = nm_device_master_get_slaves (self);
|
|
|
|
|
ready_slaves = NM_DEVICE_GET_CLASS (self)->have_any_ready_slaves (self, slaves);
|
|
|
|
|
g_slist_free (slaves);
|
|
|
|
|
|
|
|
|
|
if (ready_slaves == FALSE) {
|
|
|
|
|
nm_log_info (LOGD_DEVICE | LOGD_IP4,
|
|
|
|
|
"(%s): IPv4 config waiting until slaves are ready",
|
|
|
|
|
nm_device_get_ip_iface (self));
|
|
|
|
|
return NM_ACT_STAGE_RETURN_WAIT;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-09 22:50:04 -05:00
|
|
|
/* Start IPv4 addressing based on the method requested */
|
|
|
|
|
if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO) == 0)
|
2011-01-05 16:23:00 -06:00
|
|
|
ret = dhcp4_start (self, connection, reason);
|
2011-10-09 22:50:04 -05:00
|
|
|
else if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL) == 0)
|
|
|
|
|
ret = aipd_start (self, reason);
|
|
|
|
|
else if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL) == 0) {
|
|
|
|
|
/* Use only IPv4 config from the connection data */
|
|
|
|
|
*out_config = nm_ip4_config_new ();
|
|
|
|
|
g_assert (*out_config);
|
2011-12-06 17:00:40 -06:00
|
|
|
ret = NM_ACT_STAGE_RETURN_SUCCESS;
|
2011-10-09 22:50:04 -05:00
|
|
|
} else if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_SHARED) == 0) {
|
|
|
|
|
*out_config = shared4_new_config (self, reason);
|
2011-12-06 17:00:40 -06:00
|
|
|
if (*out_config) {
|
2011-10-09 22:50:04 -05:00
|
|
|
priv->dnsmasq_manager = nm_dnsmasq_manager_new (nm_device_get_ip_iface (self));
|
2011-12-06 17:00:40 -06:00
|
|
|
ret = NM_ACT_STAGE_RETURN_SUCCESS;
|
|
|
|
|
} else
|
2008-07-09 14:05:49 +00:00
|
|
|
ret = NM_ACT_STAGE_RETURN_FAILURE;
|
2013-05-07 13:08:33 -05:00
|
|
|
} else if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED) == 0) {
|
2010-04-23 12:56:33 -07:00
|
|
|
/* Nothing to do... */
|
|
|
|
|
ret = NM_ACT_STAGE_RETURN_STOP;
|
2011-12-06 17:00:40 -06:00
|
|
|
} else {
|
2013-05-07 13:08:33 -05:00
|
|
|
nm_log_warn (LOGD_IP4, "(%s): unhandled IPv4 config method '%s'; will fail",
|
|
|
|
|
nm_device_get_ip_iface (self), method);
|
2006-01-03 17:47:38 +00:00
|
|
|
}
|
2007-02-05 09:50:11 +00:00
|
|
|
|
2006-01-03 17:47:38 +00:00
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-07 11:53:09 -05:00
|
|
|
/*********************************************/
|
|
|
|
|
/* DHCPv6 stuff */
|
|
|
|
|
|
2011-10-07 12:06:26 -05:00
|
|
|
static void
|
|
|
|
|
dhcp6_add_option_cb (gpointer key, gpointer value, gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
nm_dhcp6_config_add_option (NM_DHCP6_CONFIG (user_data),
|
|
|
|
|
(const char *) key,
|
|
|
|
|
(const char *) value);
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-21 14:25:35 -05:00
|
|
|
static gboolean
|
|
|
|
|
ip6_config_merge_and_apply (NMDevice *self,
|
|
|
|
|
NMDeviceStateReason *out_reason)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
NMConnection *connection;
|
2012-05-24 15:37:40 +02:00
|
|
|
gboolean success;
|
2011-10-21 14:25:35 -05:00
|
|
|
NMIP6Config *composite;
|
|
|
|
|
|
2011-12-05 12:27:49 +01:00
|
|
|
connection = nm_device_get_connection (self);
|
2011-10-21 14:25:35 -05:00
|
|
|
g_assert (connection);
|
|
|
|
|
|
|
|
|
|
/* If no config was passed in, create a new one */
|
|
|
|
|
composite = nm_ip6_config_new ();
|
|
|
|
|
g_assert (composite);
|
|
|
|
|
|
2013-08-01 10:59:42 -05:00
|
|
|
/* Merge all the IP configs into the composite config */
|
2013-06-14 21:42:22 +02:00
|
|
|
if (priv->ac_ip6_config)
|
2013-07-04 13:34:44 +02:00
|
|
|
nm_ip6_config_merge (composite, priv->ac_ip6_config);
|
2013-06-14 21:42:22 +02:00
|
|
|
if (priv->dhcp6_ip6_config)
|
2013-07-04 13:34:44 +02:00
|
|
|
nm_ip6_config_merge (composite, priv->dhcp6_ip6_config);
|
2013-08-01 10:59:42 -05:00
|
|
|
if (priv->vpn6_config)
|
|
|
|
|
nm_ip6_config_merge (composite, priv->vpn6_config);
|
2011-10-21 14:25:35 -05:00
|
|
|
|
|
|
|
|
/* Merge user overrides into the composite config */
|
2013-07-03 10:26:19 +02:00
|
|
|
nm_ip6_config_merge_setting (composite, nm_connection_get_setting_ip6_config (connection));
|
2011-10-21 14:25:35 -05:00
|
|
|
|
2013-06-26 00:16:45 +02:00
|
|
|
success = nm_device_set_ip6_config (self, composite, TRUE, out_reason);
|
2011-10-21 14:25:35 -05:00
|
|
|
g_object_unref (composite);
|
|
|
|
|
return success;
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-09 22:50:04 -05:00
|
|
|
static void
|
2011-10-21 14:25:35 -05:00
|
|
|
dhcp6_lease_change (NMDevice *device)
|
2011-10-07 12:06:26 -05:00
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
|
|
|
|
|
NMConnection *connection;
|
2011-10-09 22:50:04 -05:00
|
|
|
NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE;
|
2011-10-07 12:06:26 -05:00
|
|
|
|
2011-10-21 14:25:35 -05:00
|
|
|
if (priv->dhcp6_ip6_config == NULL) {
|
2011-10-09 22:50:04 -05:00
|
|
|
nm_log_warn (LOGD_DHCP6, "(%s): failed to get DHCPv6 config for rebind",
|
2011-10-07 12:06:26 -05:00
|
|
|
nm_device_get_ip_iface (device));
|
2011-10-09 22:50:04 -05:00
|
|
|
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_IP_CONFIG_EXPIRED);
|
|
|
|
|
return;
|
2011-10-07 12:06:26 -05:00
|
|
|
}
|
|
|
|
|
|
2011-10-09 22:50:04 -05:00
|
|
|
g_assert (priv->dhcp6_client); /* sanity check */
|
2011-10-07 12:05:51 -05:00
|
|
|
|
2011-12-05 12:27:49 +01:00
|
|
|
connection = nm_device_get_connection (device);
|
2011-10-07 12:05:51 -05:00
|
|
|
g_assert (connection);
|
|
|
|
|
|
2011-10-21 14:25:35 -05:00
|
|
|
/* Apply the updated config */
|
2013-06-14 21:42:22 +02:00
|
|
|
if (ip6_config_merge_and_apply (device, &reason) == FALSE) {
|
2011-10-09 22:50:04 -05:00
|
|
|
nm_log_warn (LOGD_DHCP6, "(%s): failed to update IPv6 config in response to DHCP event.",
|
2011-10-07 12:05:51 -05:00
|
|
|
nm_device_get_ip_iface (device));
|
|
|
|
|
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, reason);
|
2011-10-21 14:25:35 -05:00
|
|
|
} else {
|
|
|
|
|
/* Notify dispatcher scripts of new DHCPv6 config */
|
2012-06-05 11:20:11 -05:00
|
|
|
nm_dispatcher_call (DISPATCHER_ACTION_DHCP6_CHANGE, connection, device, NULL, NULL);
|
2011-10-07 12:05:51 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-07 12:23:35 -05:00
|
|
|
static void
|
|
|
|
|
dhcp6_fail (NMDevice *device, gboolean timeout)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
|
|
|
|
|
|
|
|
|
|
nm_dhcp6_config_reset (priv->dhcp6_config);
|
|
|
|
|
|
2011-10-09 23:48:13 -05:00
|
|
|
if (timeout || (priv->ip6_state == IP_CONF))
|
2011-10-09 22:50:04 -05:00
|
|
|
nm_device_activate_schedule_ip6_config_timeout (device);
|
2013-07-02 16:42:49 +02:00
|
|
|
else if (priv->ip6_state == IP_FAIL)
|
2011-10-07 12:23:35 -05:00
|
|
|
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_IP_CONFIG_EXPIRED);
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-07 12:05:51 -05:00
|
|
|
static void
|
|
|
|
|
dhcp6_state_changed (NMDHCPClient *client,
|
|
|
|
|
NMDHCPState state,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMDevice *device = NM_DEVICE (user_data);
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
|
|
|
|
|
NMDeviceState dev_state;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (nm_dhcp_client_get_ipv6 (client) == TRUE);
|
|
|
|
|
|
|
|
|
|
nm_log_dbg (LOGD_DHCP6, "(%s): new DHCPv6 client state %d",
|
|
|
|
|
nm_device_get_iface (device), state);
|
|
|
|
|
|
|
|
|
|
dev_state = nm_device_get_state (device);
|
|
|
|
|
|
|
|
|
|
switch (state) {
|
|
|
|
|
case DHC_BOUND6:
|
|
|
|
|
case DHC_RENEW6: /* lease renewed */
|
|
|
|
|
case DHC_REBOOT: /* have valid lease, but now obtained a different one */
|
|
|
|
|
case DHC_REBIND6: /* new, different lease */
|
2011-10-21 14:25:35 -05:00
|
|
|
if (priv->dhcp6_ip6_config)
|
|
|
|
|
g_object_unref (priv->dhcp6_ip6_config);
|
|
|
|
|
priv->dhcp6_ip6_config = nm_dhcp_client_get_ip6_config (priv->dhcp6_client, FALSE);
|
2013-06-14 21:42:22 +02:00
|
|
|
if (priv->ip6_state == IP_CONF) {
|
|
|
|
|
if (priv->dhcp6_ip6_config == NULL) {
|
|
|
|
|
/* FIXME: Initial DHCP failed; should we fail IPv6 entirely then? */
|
|
|
|
|
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_DHCP_FAILED);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
nm_device_activate_schedule_ip6_config_result (device);
|
|
|
|
|
} else if (priv->ip6_state == IP_DONE)
|
2011-10-21 14:25:35 -05:00
|
|
|
dhcp6_lease_change (device);
|
2011-10-09 22:50:04 -05:00
|
|
|
|
2011-10-21 14:25:35 -05:00
|
|
|
if (priv->dhcp6_ip6_config) {
|
2011-10-09 22:50:04 -05:00
|
|
|
/* Update the DHCP6 config object with new DHCP options */
|
|
|
|
|
nm_dhcp6_config_reset (priv->dhcp6_config);
|
|
|
|
|
nm_dhcp_client_foreach_option (priv->dhcp6_client,
|
|
|
|
|
dhcp6_add_option_cb,
|
|
|
|
|
priv->dhcp6_config);
|
2011-11-18 00:34:08 -06:00
|
|
|
g_object_notify (G_OBJECT (device), NM_DEVICE_DHCP6_CONFIG);
|
2011-10-09 22:50:04 -05:00
|
|
|
}
|
2011-10-07 12:05:51 -05:00
|
|
|
break;
|
|
|
|
|
case DHC_TIMEOUT: /* timed out contacting DHCP server */
|
2011-10-07 12:23:35 -05:00
|
|
|
dhcp6_fail (device, TRUE);
|
2011-10-07 12:05:51 -05:00
|
|
|
break;
|
|
|
|
|
case DHC_END: /* dhclient exited normally */
|
|
|
|
|
/* In IPv6 info-only mode, the client doesn't handle leases so it
|
|
|
|
|
* may exit right after getting a response from the server. That's
|
|
|
|
|
* normal. In that case we just ignore the exit.
|
|
|
|
|
*/
|
2013-05-30 16:53:23 +02:00
|
|
|
if (priv->dhcp6_mode == NM_RDISC_DHCP_LEVEL_OTHERCONF)
|
2011-10-07 12:05:51 -05:00
|
|
|
break;
|
|
|
|
|
/* Otherwise, fall through */
|
|
|
|
|
case DHC_FAIL: /* all attempts to contact server timed out, sleeping */
|
|
|
|
|
case DHC_ABEND: /* dhclient exited abnormally */
|
|
|
|
|
/* dhclient quit and can't get/renew a lease; so kill the connection */
|
2011-10-07 12:23:35 -05:00
|
|
|
dhcp6_fail (device, FALSE);
|
2011-10-07 12:05:51 -05:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
dhcp6_timeout (NMDHCPClient *client, gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMDevice *device = NM_DEVICE (user_data);
|
2012-12-13 10:52:10 -06:00
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
|
2011-10-07 12:05:51 -05:00
|
|
|
|
|
|
|
|
g_return_if_fail (nm_device_get_act_request (device) != NULL);
|
|
|
|
|
g_return_if_fail (nm_dhcp_client_get_ipv6 (client) == TRUE);
|
|
|
|
|
|
|
|
|
|
nm_dhcp_client_stop (client, FALSE);
|
2013-05-30 16:53:23 +02:00
|
|
|
if (priv->dhcp6_mode == NM_RDISC_DHCP_LEVEL_MANAGED)
|
2012-12-13 10:52:10 -06:00
|
|
|
dhcp6_fail (device, TRUE);
|
|
|
|
|
else {
|
|
|
|
|
/* not a hard failure; just live with the RA info */
|
|
|
|
|
nm_dhcp6_config_reset (priv->dhcp6_config);
|
|
|
|
|
if (priv->dhcp6_ip6_config)
|
|
|
|
|
g_object_unref (priv->dhcp6_ip6_config);
|
|
|
|
|
priv->dhcp6_ip6_config = NULL;
|
|
|
|
|
|
2013-06-14 21:42:22 +02:00
|
|
|
if (priv->ip6_state == IP_CONF)
|
|
|
|
|
nm_device_activate_schedule_ip6_config_result (device);
|
2012-12-13 10:52:10 -06:00
|
|
|
}
|
2011-10-07 12:05:51 -05:00
|
|
|
}
|
|
|
|
|
|
2010-01-27 16:20:09 -08:00
|
|
|
static NMActStageReturn
|
|
|
|
|
dhcp6_start (NMDevice *self,
|
|
|
|
|
NMConnection *connection,
|
|
|
|
|
guint32 dhcp_opt,
|
|
|
|
|
NMDeviceStateReason *reason)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
|
|
|
|
|
guint8 *anycast = NULL;
|
2012-06-13 13:28:55 -05:00
|
|
|
GByteArray *tmp = NULL;
|
2010-01-27 16:20:09 -08:00
|
|
|
|
|
|
|
|
if (!connection) {
|
2011-12-05 12:27:49 +01:00
|
|
|
connection = nm_device_get_connection (self);
|
2010-01-27 16:20:09 -08:00
|
|
|
g_assert (connection);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Begin a DHCP transaction on the interface */
|
|
|
|
|
|
|
|
|
|
if (priv->dhcp_anycast_address)
|
|
|
|
|
anycast = priv->dhcp_anycast_address->data;
|
|
|
|
|
|
|
|
|
|
/* Clear old exported DHCP options */
|
|
|
|
|
if (priv->dhcp6_config)
|
|
|
|
|
g_object_unref (priv->dhcp6_config);
|
|
|
|
|
priv->dhcp6_config = nm_dhcp6_config_new ();
|
|
|
|
|
|
2011-10-21 14:25:35 -05:00
|
|
|
g_warn_if_fail (priv->dhcp6_ip6_config == NULL);
|
|
|
|
|
if (priv->dhcp6_ip6_config) {
|
|
|
|
|
g_object_unref (priv->dhcp6_ip6_config);
|
|
|
|
|
priv->dhcp6_ip6_config = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-01 09:28:16 -04:00
|
|
|
if (priv->hw_addr_len) {
|
|
|
|
|
tmp = g_byte_array_sized_new (priv->hw_addr_len);
|
|
|
|
|
g_byte_array_append (tmp, priv->hw_addr, priv->hw_addr_len);
|
2012-06-13 13:28:55 -05:00
|
|
|
}
|
|
|
|
|
|
2010-01-27 16:20:09 -08:00
|
|
|
priv->dhcp6_client = nm_dhcp_manager_start_ip6 (priv->dhcp_manager,
|
2012-06-13 13:28:55 -05:00
|
|
|
nm_device_get_ip_iface (self),
|
|
|
|
|
tmp,
|
2011-03-08 13:41:28 +01:00
|
|
|
nm_connection_get_uuid (connection),
|
2011-10-21 14:25:35 -05:00
|
|
|
nm_connection_get_setting_ip6_config (connection),
|
2010-01-27 16:20:09 -08:00
|
|
|
priv->dhcp_timeout,
|
|
|
|
|
anycast,
|
2013-05-30 16:53:23 +02:00
|
|
|
(dhcp_opt == NM_RDISC_DHCP_LEVEL_OTHERCONF) ? TRUE : FALSE);
|
2012-06-13 13:28:55 -05:00
|
|
|
if (tmp)
|
|
|
|
|
g_byte_array_free (tmp, TRUE);
|
|
|
|
|
|
2010-01-27 16:20:09 -08:00
|
|
|
if (priv->dhcp6_client) {
|
|
|
|
|
priv->dhcp6_state_sigid = g_signal_connect (priv->dhcp6_client,
|
|
|
|
|
"state-changed",
|
2011-10-07 12:05:51 -05:00
|
|
|
G_CALLBACK (dhcp6_state_changed),
|
2010-01-27 16:20:09 -08:00
|
|
|
self);
|
|
|
|
|
priv->dhcp6_timeout_sigid = g_signal_connect (priv->dhcp6_client,
|
|
|
|
|
"timeout",
|
2011-10-07 12:05:51 -05:00
|
|
|
G_CALLBACK (dhcp6_timeout),
|
2010-01-27 16:20:09 -08:00
|
|
|
self);
|
|
|
|
|
|
|
|
|
|
/* DHCP devices will be notified by the DHCP manager when stuff happens */
|
|
|
|
|
ret = NM_ACT_STAGE_RETURN_POSTPONE;
|
|
|
|
|
} else {
|
|
|
|
|
*reason = NM_DEVICE_STATE_REASON_DHCP_START_FAILED;
|
|
|
|
|
ret = NM_ACT_STAGE_RETURN_FAILURE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-07 11:53:09 -05:00
|
|
|
/******************************************/
|
|
|
|
|
|
2013-05-30 16:53:23 +02:00
|
|
|
static void dhcp6_cleanup (NMDevice *self, gboolean stop, gboolean release);
|
|
|
|
|
|
2011-10-07 11:53:09 -05:00
|
|
|
static void
|
2013-05-30 16:53:23 +02:00
|
|
|
rdisc_config_changed (NMRDisc *rdisc, NMRDiscConfigMap changed, NMDevice *device)
|
2011-10-07 11:53:09 -05:00
|
|
|
{
|
2013-05-30 16:53:23 +02:00
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
|
2011-10-07 11:53:09 -05:00
|
|
|
NMConnection *connection;
|
2013-05-30 16:53:23 +02:00
|
|
|
int i;
|
|
|
|
|
NMDeviceStateReason reason;
|
2011-10-07 11:53:09 -05:00
|
|
|
|
2013-05-30 16:53:23 +02:00
|
|
|
g_return_if_fail (priv->act_request);
|
|
|
|
|
connection = nm_device_get_connection (device);
|
2011-10-07 11:53:09 -05:00
|
|
|
g_assert (connection);
|
|
|
|
|
|
2013-05-30 16:53:23 +02:00
|
|
|
if (!priv->ac_ip6_config)
|
|
|
|
|
priv->ac_ip6_config = nm_ip6_config_new ();
|
2011-10-07 11:53:09 -05:00
|
|
|
|
2013-05-30 16:53:23 +02:00
|
|
|
if (changed & NM_RDISC_CONFIG_GATEWAYS) {
|
|
|
|
|
/* Use the first gateway as ordered in router discovery cache. */
|
|
|
|
|
if (rdisc->gateways->len) {
|
|
|
|
|
NMRDiscGateway *gateway = &g_array_index (rdisc->gateways, NMRDiscGateway, 0);
|
2011-10-07 11:53:09 -05:00
|
|
|
|
2013-05-30 16:53:23 +02:00
|
|
|
nm_ip6_config_set_gateway (priv->ac_ip6_config, &gateway->address);
|
|
|
|
|
} else
|
|
|
|
|
nm_ip6_config_set_gateway (priv->ac_ip6_config, NULL);
|
2011-10-07 11:53:09 -05:00
|
|
|
}
|
|
|
|
|
|
2013-05-30 16:53:23 +02:00
|
|
|
if (changed & NM_RDISC_CONFIG_ADDRESSES) {
|
|
|
|
|
/* Rebuild address list from router discovery cache. */
|
|
|
|
|
nm_ip6_config_reset_addresses (priv->ac_ip6_config);
|
2011-10-07 11:53:09 -05:00
|
|
|
|
2013-05-30 16:53:23 +02:00
|
|
|
for (i = 0; i < rdisc->addresses->len; i++) {
|
|
|
|
|
NMRDiscAddress *discovered_address = &g_array_index (rdisc->addresses, NMRDiscAddress, i);
|
|
|
|
|
NMPlatformIP6Address address;
|
|
|
|
|
|
|
|
|
|
memset (&address, 0, sizeof (address));
|
|
|
|
|
address.address = discovered_address->address;
|
|
|
|
|
address.plen = 128;
|
2013-07-29 14:53:06 +02:00
|
|
|
address.timestamp = discovered_address->timestamp;
|
|
|
|
|
address.lifetime = discovered_address->lifetime;
|
|
|
|
|
address.preferred = discovered_address->preferred;
|
2013-05-30 16:53:23 +02:00
|
|
|
|
|
|
|
|
nm_ip6_config_add_address (priv->ac_ip6_config, &address);
|
2013-06-14 21:42:22 +02:00
|
|
|
}
|
2011-10-07 11:53:09 -05:00
|
|
|
}
|
|
|
|
|
|
2013-05-30 16:53:23 +02:00
|
|
|
if (changed & NM_RDISC_CONFIG_ROUTES) {
|
|
|
|
|
/* Rebuild route list from router discovery cache. */
|
|
|
|
|
nm_ip6_config_reset_routes (priv->ac_ip6_config);
|
2011-10-07 11:53:09 -05:00
|
|
|
|
2013-05-30 16:53:23 +02:00
|
|
|
for (i = 0; i < rdisc->routes->len; i++) {
|
|
|
|
|
NMRDiscRoute *discovered_route = &g_array_index (rdisc->routes, NMRDiscRoute, i);
|
2013-07-31 23:07:32 +02:00
|
|
|
NMPlatformIP6Route route;
|
2011-10-07 11:53:09 -05:00
|
|
|
|
2013-07-31 23:07:32 +02:00
|
|
|
memset (&route, 0, sizeof (route));
|
|
|
|
|
route.network = discovered_route->network;
|
|
|
|
|
route.plen = discovered_route->plen;
|
|
|
|
|
route.gateway = discovered_route->gateway;
|
2013-05-30 16:53:23 +02:00
|
|
|
|
2013-07-31 23:07:32 +02:00
|
|
|
nm_ip6_config_add_route (priv->ac_ip6_config, &route);
|
2013-06-14 21:42:22 +02:00
|
|
|
}
|
2011-10-07 11:53:09 -05:00
|
|
|
}
|
|
|
|
|
|
2013-05-30 16:53:23 +02:00
|
|
|
if (changed & NM_RDISC_CONFIG_DNS_SERVERS) {
|
|
|
|
|
/* Rebuild DNS server list from router discovery cache. */
|
|
|
|
|
nm_ip6_config_reset_nameservers (priv->ac_ip6_config);
|
2011-10-07 11:53:09 -05:00
|
|
|
|
2013-05-30 16:53:23 +02:00
|
|
|
for (i = 0; i < rdisc->dns_servers->len; i++) {
|
|
|
|
|
NMRDiscDNSServer *discovered_server = &g_array_index (rdisc->dns_servers, NMRDiscDNSServer, i);
|
2011-10-07 11:53:09 -05:00
|
|
|
|
2013-05-30 16:53:23 +02:00
|
|
|
nm_ip6_config_add_nameserver (priv->ac_ip6_config, &discovered_server->address);
|
|
|
|
|
}
|
2011-10-07 11:53:09 -05:00
|
|
|
}
|
|
|
|
|
|
2013-05-30 16:53:23 +02:00
|
|
|
if (changed & NM_RDISC_CONFIG_DNS_DOMAINS) {
|
|
|
|
|
for (i = 0; i < rdisc->dns_domains->len; i++) {
|
|
|
|
|
NMRDiscDNSDomain *discovered_domain = &g_array_index (rdisc->dns_domains, NMRDiscDNSDomain, i);
|
2011-10-09 22:50:04 -05:00
|
|
|
|
2013-05-30 16:53:23 +02:00
|
|
|
nm_ip6_config_add_domain (priv->ac_ip6_config, discovered_domain->domain);
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-10-09 22:50:04 -05:00
|
|
|
|
2013-05-30 16:53:23 +02:00
|
|
|
if (changed & NM_RDISC_CONFIG_DHCP_LEVEL) {
|
|
|
|
|
dhcp6_cleanup (device, TRUE, TRUE);
|
|
|
|
|
|
|
|
|
|
priv->dhcp6_mode = rdisc->dhcp_level;
|
|
|
|
|
|
|
|
|
|
switch (priv->dhcp6_mode) {
|
|
|
|
|
case NM_RDISC_DHCP_LEVEL_NONE:
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
nm_log_info (LOGD_DEVICE | LOGD_DHCP6,
|
|
|
|
|
"Activation (%s) Stage 3 of 5 (IP Configure Start) starting DHCPv6"
|
|
|
|
|
" as requested by IPv6 router...",
|
|
|
|
|
priv->iface);
|
|
|
|
|
switch (dhcp6_start (device, connection, priv->dhcp6_mode, &reason)) {
|
|
|
|
|
case NM_ACT_STAGE_RETURN_SUCCESS:
|
|
|
|
|
g_warn_if_reached ();
|
|
|
|
|
break;
|
|
|
|
|
case NM_ACT_STAGE_RETURN_POSTPONE:
|
|
|
|
|
return;
|
|
|
|
|
default:
|
|
|
|
|
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, reason);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-10-09 22:50:04 -05:00
|
|
|
}
|
2013-05-30 16:53:23 +02:00
|
|
|
|
|
|
|
|
nm_device_activate_schedule_ip6_config_result (device);
|
2011-10-07 11:53:09 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
2011-10-09 22:50:04 -05:00
|
|
|
addrconf6_start (NMDevice *self)
|
2011-10-07 11:53:09 -05:00
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
NMConnection *connection;
|
|
|
|
|
|
2011-12-05 12:27:49 +01:00
|
|
|
connection = nm_device_get_connection (self);
|
2011-10-07 11:53:09 -05:00
|
|
|
g_assert (connection);
|
|
|
|
|
|
2011-10-21 14:25:35 -05:00
|
|
|
g_warn_if_fail (priv->ac_ip6_config == NULL);
|
|
|
|
|
if (priv->ac_ip6_config) {
|
|
|
|
|
g_object_unref (priv->ac_ip6_config);
|
|
|
|
|
priv->ac_ip6_config = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-30 16:53:23 +02:00
|
|
|
priv->rdisc = nm_lndp_rdisc_new (nm_device_get_ip_ifindex (self), nm_device_get_ip_iface (self));
|
|
|
|
|
nm_platform_sysctl_set (priv->ip6_accept_ra_path, "0");
|
|
|
|
|
|
|
|
|
|
if (!priv->rdisc) {
|
|
|
|
|
nm_log_err (LOGD_IP6, "Failed to start router discovery.");
|
|
|
|
|
return FALSE;
|
2011-10-09 22:50:04 -05:00
|
|
|
}
|
2011-10-07 11:53:09 -05:00
|
|
|
|
2013-05-30 16:53:23 +02:00
|
|
|
priv->rdisc_config_changed_sigid = g_signal_connect (
|
|
|
|
|
priv->rdisc, NM_RDISC_CONFIG_CHANGED, G_CALLBACK (rdisc_config_changed), self);
|
|
|
|
|
|
|
|
|
|
/* FIXME: what if interface has no lladdr, like PPP? */
|
|
|
|
|
if (priv->hw_addr_len)
|
|
|
|
|
nm_rdisc_set_lladdr (priv->rdisc, (const char *) priv->hw_addr, priv->hw_addr_len);
|
|
|
|
|
|
|
|
|
|
nm_rdisc_start (priv->rdisc);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
2011-10-07 11:53:09 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
addrconf6_cleanup (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
|
2013-05-30 16:53:23 +02:00
|
|
|
if (priv->rdisc_config_changed_sigid) {
|
|
|
|
|
g_signal_handler_disconnect (priv->rdisc,
|
|
|
|
|
priv->rdisc_config_changed_sigid);
|
|
|
|
|
priv->rdisc_config_changed_sigid = 0;
|
2011-10-07 11:53:09 -05:00
|
|
|
}
|
|
|
|
|
|
2013-05-30 16:53:23 +02:00
|
|
|
g_clear_object (&priv->ac_ip6_config);
|
|
|
|
|
g_clear_object (&priv->rdisc);
|
2011-10-07 11:53:09 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/******************************************/
|
|
|
|
|
|
2012-08-01 21:10:15 +02:00
|
|
|
/* Get net.ipv6.conf.default.use_tempaddr value from /etc/sysctl.conf or
|
|
|
|
|
* /lib/sysctl.d/sysctl.conf
|
|
|
|
|
*/
|
|
|
|
|
static int
|
|
|
|
|
ip6_use_tempaddr (void)
|
|
|
|
|
{
|
|
|
|
|
char *contents = NULL;
|
|
|
|
|
gsize len = 0;
|
|
|
|
|
const char *group_name = "[forged_group]\n";
|
|
|
|
|
char *sysctl_data = NULL;
|
|
|
|
|
GKeyFile *keyfile;
|
|
|
|
|
GError *error = NULL;
|
|
|
|
|
int tmp, ret = -1;
|
|
|
|
|
|
|
|
|
|
/* Read file contents to a string. */
|
|
|
|
|
if (!g_file_get_contents ("/etc/sysctl.conf", &contents, &len, NULL))
|
|
|
|
|
if (!g_file_get_contents ("/lib/sysctl.d/sysctl.conf", &contents, &len, NULL))
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
/* Prepend a group so that we can use GKeyFile parser. */
|
|
|
|
|
sysctl_data = g_strdup_printf ("%s%s", group_name, contents);
|
|
|
|
|
|
|
|
|
|
keyfile = g_key_file_new ();
|
|
|
|
|
if (!g_key_file_load_from_data (keyfile, sysctl_data, len + strlen (group_name), G_KEY_FILE_NONE, NULL))
|
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
|
|
tmp = g_key_file_get_integer (keyfile, "forged_group", "net.ipv6.conf.default.use_tempaddr", &error);
|
|
|
|
|
if (error == NULL)
|
|
|
|
|
ret = tmp;
|
|
|
|
|
|
|
|
|
|
done:
|
|
|
|
|
g_free (contents);
|
|
|
|
|
g_free (sysctl_data);
|
|
|
|
|
g_clear_error (&error);
|
|
|
|
|
g_key_file_free (keyfile);
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-25 11:59:05 -06:00
|
|
|
static gboolean
|
|
|
|
|
ip6_requires_slaves (NMConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
NMSettingIP6Config *s_ip6;
|
|
|
|
|
const char *method = NM_SETTING_IP6_CONFIG_METHOD_AUTO;
|
|
|
|
|
|
|
|
|
|
s_ip6 = nm_connection_get_setting_ip6_config (connection);
|
|
|
|
|
if (s_ip6)
|
|
|
|
|
method = nm_setting_ip6_config_get_method (s_ip6);
|
|
|
|
|
|
|
|
|
|
/* SLAAC, DHCP, and Link-Local depend on connectivity (and thus slaves)
|
|
|
|
|
* to complete addressing. SLAAC and DHCP obviously need a peer to
|
|
|
|
|
* provide a prefix, while Link-Local must perform DAD on the local link.
|
|
|
|
|
*/
|
|
|
|
|
return g_strcmp0 (method, NM_SETTING_IP6_CONFIG_METHOD_AUTO) == 0
|
|
|
|
|
|| g_strcmp0 (method, NM_SETTING_IP6_CONFIG_METHOD_DHCP) == 0
|
|
|
|
|
|| g_strcmp0 (method, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL) == 0;
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-29 12:12:41 -04:00
|
|
|
static NMActStageReturn
|
2012-09-27 12:12:15 -04:00
|
|
|
act_stage3_ip6_config_start (NMDevice *self,
|
|
|
|
|
NMIP6Config **out_config,
|
|
|
|
|
NMDeviceStateReason *reason)
|
2009-07-29 12:12:41 -04:00
|
|
|
{
|
2009-07-30 13:50:42 -04:00
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
2010-01-27 16:20:09 -08:00
|
|
|
const char *ip_iface;
|
2010-04-30 15:49:41 -07:00
|
|
|
NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
|
2010-01-14 00:45:10 -08:00
|
|
|
NMConnection *connection;
|
2012-02-21 15:44:19 +01:00
|
|
|
NMSettingIP6Config *s_ip6;
|
2013-05-07 13:08:33 -05:00
|
|
|
const char *method = NM_SETTING_IP6_CONFIG_METHOD_AUTO;
|
2012-02-21 15:44:19 +01:00
|
|
|
int conf_use_tempaddr;
|
|
|
|
|
NMSettingIP6ConfigPrivacy ip6_privacy = NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN;
|
|
|
|
|
const char *ip6_privacy_str = "0\n";
|
2013-01-25 11:59:05 -06:00
|
|
|
GSList *slaves;
|
|
|
|
|
gboolean ready_slaves;
|
2009-07-30 13:50:42 -04:00
|
|
|
|
|
|
|
|
g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE);
|
|
|
|
|
|
2013-06-07 15:11:23 -05:00
|
|
|
ip_iface = nm_device_get_ip_iface (self);
|
2013-05-07 10:23:44 -04:00
|
|
|
|
2011-12-05 12:27:49 +01:00
|
|
|
connection = nm_device_get_connection (self);
|
2010-01-14 00:45:10 -08:00
|
|
|
g_assert (connection);
|
|
|
|
|
|
2013-06-07 15:11:23 -05:00
|
|
|
/* If we did not receive IP6 configuration information, default to AUTO.
|
|
|
|
|
* Slaves, on the other hand, never have any IP configuration themselves,
|
|
|
|
|
* since the master handles all of that.
|
|
|
|
|
*/
|
|
|
|
|
s_ip6 = nm_connection_get_setting_ip6_config (connection);
|
|
|
|
|
if (priv->master) /* eg, device is a slave */
|
|
|
|
|
method = NM_SETTING_IP6_CONFIG_METHOD_IGNORE;
|
|
|
|
|
else if (s_ip6)
|
|
|
|
|
method = nm_setting_ip6_config_get_method (s_ip6);
|
|
|
|
|
else
|
|
|
|
|
method = NM_SETTING_IP6_CONFIG_METHOD_AUTO;
|
|
|
|
|
|
|
|
|
|
if ( g_strcmp0 (method, NM_SETTING_IP6_CONFIG_METHOD_MANUAL) != 0
|
|
|
|
|
&& nm_device_is_master (self)
|
|
|
|
|
&& nm_device_is_unavailable_because_of_carrier (self)) {
|
|
|
|
|
nm_log_info (LOGD_IP6 | LOGD_DEVICE,
|
|
|
|
|
"(%s): IPv6 config waiting until carrier is on", ip_iface);
|
|
|
|
|
return NM_ACT_STAGE_RETURN_WAIT;
|
|
|
|
|
}
|
2010-01-14 00:45:10 -08:00
|
|
|
|
2013-01-25 11:59:05 -06:00
|
|
|
if (priv->is_master && ip6_requires_slaves (connection)) {
|
|
|
|
|
/* If the master has no ready slaves, and depends on slaves for
|
|
|
|
|
* a successful IPv6 attempt, then postpone IPv6 addressing.
|
|
|
|
|
*/
|
|
|
|
|
slaves = nm_device_master_get_slaves (self);
|
|
|
|
|
ready_slaves = NM_DEVICE_GET_CLASS (self)->have_any_ready_slaves (self, slaves);
|
|
|
|
|
g_slist_free (slaves);
|
|
|
|
|
|
|
|
|
|
if (ready_slaves == FALSE) {
|
|
|
|
|
nm_log_info (LOGD_DEVICE | LOGD_IP6,
|
|
|
|
|
"(%s): IPv6 config waiting until slaves are ready",
|
|
|
|
|
ip_iface);
|
|
|
|
|
return NM_ACT_STAGE_RETURN_WAIT;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-05-03 03:42:43 -07:00
|
|
|
update_accept_ra_save (self);
|
2012-02-21 15:44:19 +01:00
|
|
|
update_ip6_privacy_save (self);
|
2010-05-03 03:42:43 -07:00
|
|
|
|
2013-05-30 16:53:23 +02:00
|
|
|
priv->dhcp6_mode = NM_RDISC_DHCP_LEVEL_NONE;
|
2010-05-01 10:16:38 -07:00
|
|
|
|
2013-05-07 13:08:33 -05:00
|
|
|
if ( strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_AUTO) == 0
|
|
|
|
|
|| strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL) == 0) {
|
2011-10-09 22:50:04 -05:00
|
|
|
if (!addrconf6_start (self)) {
|
2010-04-30 16:10:29 -07:00
|
|
|
*reason = NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE;
|
2011-10-09 22:50:04 -05:00
|
|
|
ret = NM_ACT_STAGE_RETURN_FAILURE;
|
|
|
|
|
} else
|
|
|
|
|
ret = NM_ACT_STAGE_RETURN_POSTPONE;
|
2013-05-07 13:08:33 -05:00
|
|
|
} else if (strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_DHCP) == 0) {
|
2010-07-27 21:43:42 -07:00
|
|
|
/* Router advertisements shouldn't be used in pure DHCP mode */
|
|
|
|
|
if (priv->ip6_accept_ra_path)
|
2012-11-16 13:57:47 -06:00
|
|
|
nm_utils_do_sysctl (priv->ip6_accept_ra_path, "0");
|
2010-07-27 21:43:42 -07:00
|
|
|
|
2013-05-30 16:53:23 +02:00
|
|
|
priv->dhcp6_mode = NM_RDISC_DHCP_LEVEL_MANAGED;
|
2010-07-27 21:43:42 -07:00
|
|
|
ret = dhcp6_start (self, connection, priv->dhcp6_mode, reason);
|
2013-05-07 13:08:33 -05:00
|
|
|
} else if (strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE) == 0) {
|
2010-05-05 13:20:18 -07:00
|
|
|
/* reset the saved RA value when ipv6 is ignored */
|
|
|
|
|
if (priv->ip6_accept_ra_path) {
|
|
|
|
|
nm_utils_do_sysctl (priv->ip6_accept_ra_path,
|
2012-11-16 13:57:47 -06:00
|
|
|
priv->ip6_accept_ra_save ? "1" : "0");
|
2010-05-05 13:20:18 -07:00
|
|
|
}
|
2010-04-23 12:56:33 -07:00
|
|
|
ret = NM_ACT_STAGE_RETURN_STOP;
|
2013-05-07 13:08:33 -05:00
|
|
|
} else if (strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_MANUAL) == 0) {
|
2011-10-09 22:50:04 -05:00
|
|
|
/* New blank config */
|
|
|
|
|
*out_config = nm_ip6_config_new ();
|
|
|
|
|
g_assert (*out_config);
|
|
|
|
|
|
2010-05-03 03:42:43 -07:00
|
|
|
/* Router advertisements shouldn't be used in manual mode */
|
|
|
|
|
if (priv->ip6_accept_ra_path)
|
2012-11-16 13:57:47 -06:00
|
|
|
nm_utils_do_sysctl (priv->ip6_accept_ra_path, "0");
|
2010-04-30 15:49:41 -07:00
|
|
|
ret = NM_ACT_STAGE_RETURN_SUCCESS;
|
2011-12-06 17:00:40 -06:00
|
|
|
} else {
|
2013-05-07 13:08:33 -05:00
|
|
|
nm_log_warn (LOGD_IP6, "(%s): unhandled IPv6 config method '%s'; will fail",
|
|
|
|
|
nm_device_get_ip_iface (self), method);
|
2010-05-03 03:42:43 -07:00
|
|
|
}
|
2010-04-30 15:49:41 -07:00
|
|
|
|
|
|
|
|
/* Other methods (shared) aren't implemented yet */
|
2010-01-14 00:45:10 -08:00
|
|
|
|
2012-02-21 15:44:19 +01:00
|
|
|
/* Enable/disable IPv6 Privacy Extensions.
|
|
|
|
|
* If a global value is configured by sysadmin (e.g. /etc/sysctl.conf),
|
|
|
|
|
* use that value instead of per-connection value.
|
|
|
|
|
*/
|
2012-08-01 21:10:15 +02:00
|
|
|
conf_use_tempaddr = ip6_use_tempaddr ();
|
2012-02-21 15:44:19 +01:00
|
|
|
if (conf_use_tempaddr >= 0)
|
|
|
|
|
ip6_privacy = conf_use_tempaddr;
|
2013-05-07 13:08:33 -05:00
|
|
|
else if (s_ip6)
|
|
|
|
|
ip6_privacy = nm_setting_ip6_config_get_ip6_privacy (s_ip6);
|
2012-02-27 16:42:07 +01:00
|
|
|
ip6_privacy = CLAMP (ip6_privacy, NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN, NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR);
|
2012-02-21 15:44:19 +01:00
|
|
|
|
|
|
|
|
switch (ip6_privacy) {
|
|
|
|
|
case NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN:
|
|
|
|
|
case NM_SETTING_IP6_CONFIG_PRIVACY_DISABLED:
|
2012-11-16 13:57:47 -06:00
|
|
|
ip6_privacy_str = "0";
|
2012-02-21 15:44:19 +01:00
|
|
|
break;
|
|
|
|
|
case NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_PUBLIC_ADDR:
|
2012-11-16 13:57:47 -06:00
|
|
|
ip6_privacy_str = "1";
|
2012-02-21 15:44:19 +01:00
|
|
|
break;
|
|
|
|
|
case NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR:
|
2012-11-16 13:57:47 -06:00
|
|
|
ip6_privacy_str = "2";
|
2012-02-21 15:44:19 +01:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (priv->ip6_privacy_tempaddr_path)
|
|
|
|
|
nm_utils_do_sysctl (priv->ip6_privacy_tempaddr_path, ip6_privacy_str);
|
|
|
|
|
|
2010-01-14 00:45:10 -08:00
|
|
|
return ret;
|
2009-07-29 12:12:41 -04:00
|
|
|
}
|
|
|
|
|
|
2012-11-15 17:52:24 -06:00
|
|
|
/**
|
|
|
|
|
* nm_device_activate_stage3_ip4_start:
|
|
|
|
|
* @self: the device
|
|
|
|
|
*
|
|
|
|
|
* Try starting IPv4 configuration.
|
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
nm_device_activate_stage3_ip4_start (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
NMActStageReturn ret;
|
|
|
|
|
NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE;
|
|
|
|
|
NMIP4Config *ip4_config = NULL;
|
|
|
|
|
|
|
|
|
|
g_assert (priv->ip4_state == IP_WAIT);
|
|
|
|
|
|
|
|
|
|
priv->ip4_state = IP_CONF;
|
|
|
|
|
ret = NM_DEVICE_GET_CLASS (self)->act_stage3_ip4_config_start (self, &ip4_config, &reason);
|
|
|
|
|
if (ret == NM_ACT_STAGE_RETURN_SUCCESS) {
|
|
|
|
|
g_assert (ip4_config);
|
|
|
|
|
nm_device_activate_schedule_ip4_config_result (self, ip4_config);
|
|
|
|
|
g_object_unref (ip4_config);
|
|
|
|
|
} else if (ret == NM_ACT_STAGE_RETURN_FAILURE) {
|
|
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, reason);
|
|
|
|
|
return FALSE;
|
|
|
|
|
} else if (ret == NM_ACT_STAGE_RETURN_STOP) {
|
|
|
|
|
/* Early finish */
|
2013-06-27 17:51:24 +02:00
|
|
|
priv->ip4_state = IP_FAIL;
|
2012-11-15 17:52:24 -06:00
|
|
|
} else if (ret == NM_ACT_STAGE_RETURN_WAIT) {
|
|
|
|
|
/* Wait for something to try IP config again */
|
|
|
|
|
priv->ip4_state = IP_WAIT;
|
|
|
|
|
} else
|
|
|
|
|
g_assert (ret == NM_ACT_STAGE_RETURN_POSTPONE);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_device_activate_stage3_ip6_start:
|
|
|
|
|
* @self: the device
|
|
|
|
|
*
|
|
|
|
|
* Try starting IPv6 configuration.
|
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
nm_device_activate_stage3_ip6_start (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
NMActStageReturn ret;
|
|
|
|
|
NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE;
|
|
|
|
|
NMIP6Config *ip6_config = NULL;
|
|
|
|
|
|
|
|
|
|
g_assert (priv->ip6_state == IP_WAIT);
|
|
|
|
|
|
|
|
|
|
priv->ip6_state = IP_CONF;
|
|
|
|
|
ret = NM_DEVICE_GET_CLASS (self)->act_stage3_ip6_config_start (self, &ip6_config, &reason);
|
|
|
|
|
if (ret == NM_ACT_STAGE_RETURN_SUCCESS) {
|
|
|
|
|
g_assert (ip6_config);
|
2013-06-14 21:42:22 +02:00
|
|
|
/* Here we get a static IPv6 config, like for Shared where it's
|
|
|
|
|
* autogenerated or from modems where it comes from ModemManager.
|
|
|
|
|
*/
|
|
|
|
|
g_warn_if_fail (priv->ac_ip6_config == NULL);
|
|
|
|
|
priv->ac_ip6_config = ip6_config;
|
|
|
|
|
nm_device_activate_schedule_ip6_config_result (self);
|
2012-11-15 17:52:24 -06:00
|
|
|
} else if (ret == NM_ACT_STAGE_RETURN_FAILURE) {
|
|
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, reason);
|
|
|
|
|
return FALSE;
|
|
|
|
|
} else if (ret == NM_ACT_STAGE_RETURN_STOP) {
|
|
|
|
|
/* Early finish */
|
2013-06-27 17:51:24 +02:00
|
|
|
priv->ip6_state = IP_FAIL;
|
2012-11-15 17:52:24 -06:00
|
|
|
} else if (ret == NM_ACT_STAGE_RETURN_WAIT) {
|
|
|
|
|
/* Wait for something to try IP config again */
|
|
|
|
|
priv->ip6_state = IP_WAIT;
|
|
|
|
|
} else
|
|
|
|
|
g_assert (ret == NM_ACT_STAGE_RETURN_POSTPONE);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2006-01-03 17:47:38 +00:00
|
|
|
|
2005-12-31 08:21:24 +00:00
|
|
|
/*
|
|
|
|
|
* nm_device_activate_stage3_ip_config_start
|
|
|
|
|
*
|
2009-07-29 12:12:41 -04:00
|
|
|
* Begin automatic/manual IP configuration
|
2005-12-31 08:21:24 +00:00
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
static gboolean
|
2007-01-04 12:06:26 +00:00
|
|
|
nm_device_activate_stage3_ip_config_start (gpointer user_data)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
2007-06-11 13:36:34 +00:00
|
|
|
NMDevice *self = NM_DEVICE (user_data);
|
2011-10-09 22:50:04 -05:00
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
2008-07-11 10:28:53 +00:00
|
|
|
const char *iface;
|
2011-10-09 22:50:04 -05:00
|
|
|
int ifindex;
|
2012-11-14 14:05:30 -06:00
|
|
|
NMDevice *master;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-01-04 12:06:26 +00:00
|
|
|
/* Clear the activation source ID now that this stage has run */
|
2009-07-29 12:12:41 -04:00
|
|
|
activation_source_clear (self, FALSE, 0);
|
|
|
|
|
|
2005-12-31 08:21:24 +00:00
|
|
|
iface = nm_device_get_iface (self);
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_DEVICE, "Activation (%s) Stage 3 of 5 (IP Configure Start) started...", iface);
|
2008-07-11 10:28:53 +00:00
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_IP_CONFIG, NM_DEVICE_STATE_REASON_NONE);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2011-10-09 22:50:04 -05:00
|
|
|
/* Make sure the interface is up before trying to do anything with it */
|
|
|
|
|
ifindex = nm_device_get_ip_ifindex (self);
|
2013-01-21 15:12:24 +01:00
|
|
|
if (ifindex && !nm_platform_link_is_up (ifindex))
|
|
|
|
|
nm_platform_link_set_up (ifindex);
|
2011-10-09 22:50:04 -05:00
|
|
|
|
2012-11-15 17:52:24 -06:00
|
|
|
priv->ip4_state = priv->ip6_state = IP_WAIT;
|
2011-10-09 23:48:13 -05:00
|
|
|
|
2012-11-14 14:05:30 -06:00
|
|
|
/* If the device is a slave, then we don't do any IP configuration but we
|
|
|
|
|
* use the IP config stage to indicate to the master we're ready for
|
|
|
|
|
* enslavement. Either the master has already enslaved us, in which case
|
|
|
|
|
* our state transition to SECONDARIES is already queued courtesy of
|
|
|
|
|
* nm_device_slave_notify_enslaved(), or the master is still activating,
|
|
|
|
|
* in which case we postpone activation here until the master enslaves us,
|
|
|
|
|
* which calls nm_device_slave_notify_enslaved().
|
|
|
|
|
*/
|
2012-08-22 09:38:01 -05:00
|
|
|
master = nm_active_connection_get_master (NM_ACTIVE_CONNECTION (priv->act_request));
|
2012-11-14 14:05:30 -06:00
|
|
|
if (master) {
|
|
|
|
|
if (priv->enslaved == FALSE) {
|
|
|
|
|
nm_log_info (LOGD_DEVICE, "Activation (%s) connection '%s' waiting on master '%s'",
|
|
|
|
|
nm_device_get_iface (self),
|
|
|
|
|
nm_connection_get_id (nm_device_get_connection (self)),
|
|
|
|
|
nm_device_get_iface (master));
|
|
|
|
|
}
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* IPv4 */
|
2012-11-15 17:52:24 -06:00
|
|
|
if (!nm_device_activate_stage3_ip4_start (self))
|
2005-12-31 08:21:24 +00:00
|
|
|
goto out;
|
|
|
|
|
|
2012-11-14 14:05:30 -06:00
|
|
|
/* IPv6 */
|
2012-11-15 17:52:24 -06:00
|
|
|
if (!nm_device_activate_stage3_ip6_start (self))
|
2009-07-29 12:12:41 -04:00
|
|
|
goto out;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
|
|
|
|
out:
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_DEVICE, "Activation (%s) Stage 3 of 5 (IP Configure Start) complete.", iface);
|
2005-12-31 08:21:24 +00:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2012-03-21 15:03:23 -05:00
|
|
|
static void
|
|
|
|
|
fw_add_to_zone_cb (GError *error, gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMDevice *self = NM_DEVICE (user_data);
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
priv->fw_call = NULL;
|
|
|
|
|
|
|
|
|
|
if (error) {
|
|
|
|
|
/* FIXME: fail the device activation? */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
activation_source_schedule (self, nm_device_activate_stage3_ip_config_start, 0);
|
|
|
|
|
|
|
|
|
|
nm_log_info (LOGD_DEVICE, "Activation (%s) Stage 3 of 5 (IP Configure Start) scheduled.",
|
|
|
|
|
nm_device_get_iface (self));
|
|
|
|
|
}
|
|
|
|
|
|
2005-12-31 08:21:24 +00:00
|
|
|
/*
|
|
|
|
|
* nm_device_activate_schedule_stage3_ip_config_start
|
|
|
|
|
*
|
|
|
|
|
* Schedule IP configuration start
|
|
|
|
|
*/
|
2006-01-07 16:22:17 +00:00
|
|
|
void
|
2007-06-11 13:36:34 +00:00
|
|
|
nm_device_activate_schedule_stage3_ip_config_start (NMDevice *self)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
2007-06-11 13:36:34 +00:00
|
|
|
NMDevicePrivate *priv;
|
2012-03-21 15:03:23 -05:00
|
|
|
NMConnection *connection;
|
|
|
|
|
NMSettingConnection *s_con = NULL;
|
|
|
|
|
NMDeviceState state;
|
|
|
|
|
const char *zone;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-06-11 13:36:34 +00:00
|
|
|
g_return_if_fail (NM_IS_DEVICE (self));
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-06-11 13:36:34 +00:00
|
|
|
priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
g_return_if_fail (priv->act_request);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2012-03-21 15:03:23 -05:00
|
|
|
state = nm_device_get_state (self);
|
2006-12-28 22:13:59 +00:00
|
|
|
|
2012-03-21 15:03:23 -05:00
|
|
|
/* Add the interface to the specified firewall zone */
|
|
|
|
|
connection = nm_device_get_connection (self);
|
|
|
|
|
g_assert (connection);
|
|
|
|
|
s_con = nm_connection_get_setting_connection (connection);
|
|
|
|
|
|
|
|
|
|
zone = nm_setting_connection_get_zone (s_con);
|
|
|
|
|
nm_log_dbg (LOGD_DEVICE, "Activation (%s) setting firewall zone '%s'",
|
|
|
|
|
nm_device_get_iface (self), zone ? zone : "default");
|
|
|
|
|
priv->fw_call = nm_firewall_manager_add_or_change_zone (priv->fw_manager,
|
|
|
|
|
nm_device_get_ip_iface (self),
|
|
|
|
|
zone,
|
|
|
|
|
TRUE,
|
|
|
|
|
fw_add_to_zone_cb,
|
|
|
|
|
self);
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
2006-01-03 17:47:38 +00:00
|
|
|
static NMActStageReturn
|
2012-09-27 12:12:15 -04:00
|
|
|
act_stage4_ip4_config_timeout (NMDevice *self, NMDeviceStateReason *reason)
|
2006-01-03 17:47:38 +00:00
|
|
|
{
|
2010-05-03 01:19:54 -07:00
|
|
|
if (nm_device_ip_config_should_fail (self, FALSE)) {
|
|
|
|
|
*reason = NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE;
|
|
|
|
|
return NM_ACT_STAGE_RETURN_FAILURE;
|
|
|
|
|
}
|
|
|
|
|
return NM_ACT_STAGE_RETURN_SUCCESS;
|
2006-01-03 17:47:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-12-31 08:21:24 +00:00
|
|
|
/*
|
2009-07-29 12:12:41 -04:00
|
|
|
* nm_device_activate_stage4_ip4_config_timeout
|
2005-12-31 08:21:24 +00:00
|
|
|
*
|
2009-07-29 12:12:41 -04:00
|
|
|
* Time out on retrieving the IPv4 config.
|
2005-12-31 08:21:24 +00:00
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
static gboolean
|
2011-10-09 22:50:04 -05:00
|
|
|
nm_device_activate_ip4_config_timeout (gpointer user_data)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
2007-06-11 13:36:34 +00:00
|
|
|
NMDevice *self = NM_DEVICE (user_data);
|
2011-07-25 17:43:48 -04:00
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
2008-07-11 10:28:53 +00:00
|
|
|
const char *iface;
|
2007-01-04 12:06:26 +00:00
|
|
|
NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
|
2008-07-11 10:28:53 +00:00
|
|
|
NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-01-04 12:06:26 +00:00
|
|
|
/* Clear the activation source ID now that this stage has run */
|
2009-07-29 12:12:41 -04:00
|
|
|
activation_source_clear (self, FALSE, AF_INET);
|
2007-01-04 12:06:26 +00:00
|
|
|
|
2006-01-03 17:47:38 +00:00
|
|
|
iface = nm_device_get_iface (self);
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_DEVICE | LOGD_IP4,
|
2011-10-09 22:50:04 -05:00
|
|
|
"Activation (%s) Stage 4 of 5 (IPv4 Configure Timeout) started...",
|
2010-04-07 12:31:39 -07:00
|
|
|
iface);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2011-10-07 13:08:43 -05:00
|
|
|
ret = NM_DEVICE_GET_CLASS (self)->act_stage4_ip4_config_timeout (self, &reason);
|
2010-05-03 01:19:54 -07:00
|
|
|
if (ret == NM_ACT_STAGE_RETURN_POSTPONE)
|
2006-01-03 17:47:38 +00:00
|
|
|
goto out;
|
2010-05-03 01:19:54 -07:00
|
|
|
else if (ret == NM_ACT_STAGE_RETURN_FAILURE) {
|
2008-07-11 10:28:53 +00:00
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, reason);
|
2006-01-03 17:47:38 +00:00
|
|
|
goto out;
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
2006-01-03 17:47:38 +00:00
|
|
|
g_assert (ret == NM_ACT_STAGE_RETURN_SUCCESS);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2013-06-27 17:51:24 +02:00
|
|
|
priv->ip4_state = IP_FAIL;
|
2011-10-09 22:50:04 -05:00
|
|
|
|
|
|
|
|
/* If IPv4 failed and IPv6 failed, the activation fails */
|
2013-06-27 17:51:24 +02:00
|
|
|
if (priv->ip6_state == IP_FAIL)
|
2011-10-09 22:50:04 -05:00
|
|
|
nm_device_state_changed (self,
|
2013-06-27 17:51:24 +02:00
|
|
|
NM_DEVICE_STATE_FAILED,
|
|
|
|
|
NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE);
|
2009-07-29 12:12:41 -04:00
|
|
|
|
|
|
|
|
out:
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_DEVICE | LOGD_IP4,
|
2011-10-09 22:50:04 -05:00
|
|
|
"Activation (%s) Stage 4 of 5 (IPv4 Configure Timeout) complete.",
|
2010-04-07 12:31:39 -07:00
|
|
|
iface);
|
2009-07-29 12:12:41 -04:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2011-10-09 22:50:04 -05:00
|
|
|
* nm_device_activate_schedule_ip4_config_timeout
|
2009-07-29 12:12:41 -04:00
|
|
|
*
|
|
|
|
|
* Deal with a timeout of the IPv4 configuration
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
void
|
2011-10-09 22:50:04 -05:00
|
|
|
nm_device_activate_schedule_ip4_config_timeout (NMDevice *self)
|
2009-07-29 12:12:41 -04:00
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (NM_IS_DEVICE (self));
|
|
|
|
|
|
|
|
|
|
priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
g_return_if_fail (priv->act_request);
|
|
|
|
|
|
2011-10-09 22:50:04 -05:00
|
|
|
activation_source_schedule (self, nm_device_activate_ip4_config_timeout, AF_INET);
|
2009-07-29 12:12:41 -04:00
|
|
|
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_DEVICE | LOGD_IP4,
|
2011-10-09 22:50:04 -05:00
|
|
|
"Activation (%s) Stage 4 of 5 (IPv4 Configure Timeout) scheduled...",
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_device_get_iface (self));
|
2009-07-29 12:12:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static NMActStageReturn
|
2012-09-27 12:12:15 -04:00
|
|
|
act_stage4_ip6_config_timeout (NMDevice *self, NMDeviceStateReason *reason)
|
2009-07-29 12:12:41 -04:00
|
|
|
{
|
2010-05-03 01:19:54 -07:00
|
|
|
if (nm_device_ip_config_should_fail (self, TRUE)) {
|
|
|
|
|
*reason = NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE;
|
|
|
|
|
return NM_ACT_STAGE_RETURN_FAILURE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NM_ACT_STAGE_RETURN_SUCCESS;
|
2009-07-29 12:12:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2011-10-09 22:50:04 -05:00
|
|
|
* nm_device_activate_ip6_config_timeout
|
2009-07-29 12:12:41 -04:00
|
|
|
*
|
|
|
|
|
* Time out on retrieving the IPv6 config.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
static gboolean
|
2011-10-09 22:50:04 -05:00
|
|
|
nm_device_activate_ip6_config_timeout (gpointer user_data)
|
2009-07-29 12:12:41 -04:00
|
|
|
{
|
|
|
|
|
NMDevice *self = NM_DEVICE (user_data);
|
2011-07-25 17:43:48 -04:00
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
2009-07-29 12:12:41 -04:00
|
|
|
const char *iface;
|
|
|
|
|
NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
|
|
|
|
|
NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE;
|
|
|
|
|
|
|
|
|
|
/* Clear the activation source ID now that this stage has run */
|
|
|
|
|
activation_source_clear (self, FALSE, AF_INET6);
|
|
|
|
|
|
|
|
|
|
iface = nm_device_get_iface (self);
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_DEVICE | LOGD_IP6,
|
2011-10-09 22:50:04 -05:00
|
|
|
"Activation (%s) Stage 4 of 5 (IPv6 Configure Timeout) started...",
|
2010-04-07 12:31:39 -07:00
|
|
|
iface);
|
2009-07-29 12:12:41 -04:00
|
|
|
|
2011-10-07 13:08:43 -05:00
|
|
|
ret = NM_DEVICE_GET_CLASS (self)->act_stage4_ip6_config_timeout (self, &reason);
|
2010-05-03 01:19:54 -07:00
|
|
|
if (ret == NM_ACT_STAGE_RETURN_POSTPONE)
|
2009-07-29 12:12:41 -04:00
|
|
|
goto out;
|
2010-05-03 01:19:54 -07:00
|
|
|
else if (ret == NM_ACT_STAGE_RETURN_FAILURE) {
|
2009-07-29 12:12:41 -04:00
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, reason);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
g_assert (ret == NM_ACT_STAGE_RETURN_SUCCESS);
|
|
|
|
|
|
2013-07-02 16:42:49 +02:00
|
|
|
priv->ip6_state = IP_FAIL;
|
2011-10-09 22:50:04 -05:00
|
|
|
|
|
|
|
|
/* If IPv6 failed and IPv4 failed, the activation fails */
|
2013-06-27 17:51:24 +02:00
|
|
|
if (priv->ip4_state == IP_FAIL)
|
2011-10-09 22:50:04 -05:00
|
|
|
nm_device_state_changed (self,
|
2013-06-27 17:51:24 +02:00
|
|
|
NM_DEVICE_STATE_FAILED,
|
|
|
|
|
NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
|
|
|
|
out:
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_DEVICE | LOGD_IP6,
|
2011-10-09 22:50:04 -05:00
|
|
|
"Activation (%s) Stage 4 of 5 (IPv6 Configure Timeout) complete.",
|
2010-04-07 12:31:39 -07:00
|
|
|
iface);
|
2005-12-31 08:21:24 +00:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2011-10-09 22:50:04 -05:00
|
|
|
* nm_device_activate_schedule_ip6_config_timeout
|
2005-12-31 08:21:24 +00:00
|
|
|
*
|
2009-07-29 12:12:41 -04:00
|
|
|
* Deal with a timeout of the IPv6 configuration
|
2005-12-31 08:21:24 +00:00
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
void
|
2011-10-09 22:50:04 -05:00
|
|
|
nm_device_activate_schedule_ip6_config_timeout (NMDevice *self)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
2007-06-11 13:36:34 +00:00
|
|
|
NMDevicePrivate *priv;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-06-11 13:36:34 +00:00
|
|
|
g_return_if_fail (NM_IS_DEVICE (self));
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-06-11 13:36:34 +00:00
|
|
|
priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
g_return_if_fail (priv->act_request);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2011-10-09 22:50:04 -05:00
|
|
|
activation_source_schedule (self, nm_device_activate_ip6_config_timeout, AF_INET6);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_DEVICE | LOGD_IP6,
|
2011-10-09 22:50:04 -05:00
|
|
|
"Activation (%s) Stage 4 of 5 (IPv6 Configure Timeout) scheduled...",
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_device_get_iface (self));
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
2008-08-15 15:34:28 +00:00
|
|
|
static void
|
|
|
|
|
share_child_setup (gpointer user_data G_GNUC_UNUSED)
|
|
|
|
|
{
|
|
|
|
|
/* We are in the child process at this point */
|
|
|
|
|
pid_t pid = getpid ();
|
|
|
|
|
setpgid (pid, pid);
|
2012-05-21 14:10:05 +02:00
|
|
|
|
|
|
|
|
nm_unblock_posix_signals (NULL);
|
2008-08-15 15:34:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
share_init (void)
|
|
|
|
|
{
|
2009-07-29 12:12:41 -04:00
|
|
|
int status;
|
2008-08-15 15:34:28 +00:00
|
|
|
char *modules[] = { "ip_tables", "iptable_nat", "nf_nat_ftp", "nf_nat_irc",
|
|
|
|
|
"nf_nat_sip", "nf_nat_tftp", "nf_nat_pptp", "nf_nat_h323",
|
|
|
|
|
NULL };
|
|
|
|
|
char **iter;
|
|
|
|
|
|
2012-11-16 13:57:47 -06:00
|
|
|
if (!nm_utils_do_sysctl ("/proc/sys/net/ipv4/ip_forward", "1")) {
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_err (LOGD_SHARING, "Error starting IP forwarding: (%d) %s",
|
|
|
|
|
errno, strerror (errno));
|
2009-07-29 12:12:41 -04:00
|
|
|
return FALSE;
|
2008-08-15 15:34:28 +00:00
|
|
|
}
|
|
|
|
|
|
2012-11-16 13:57:47 -06:00
|
|
|
if (!nm_utils_do_sysctl ("/proc/sys/net/ipv4/ip_dynaddr", "1")) {
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_err (LOGD_SHARING, "error starting IP forwarding: (%d) %s",
|
|
|
|
|
errno, strerror (errno));
|
2008-08-15 15:34:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (iter = modules; *iter; iter++) {
|
|
|
|
|
char *argv[3] = { "/sbin/modprobe", *iter, NULL };
|
|
|
|
|
char *envp[1] = { NULL };
|
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
|
|
if (!g_spawn_sync ("/", argv, envp, G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL,
|
|
|
|
|
share_child_setup, NULL, NULL, NULL, &status, &error)) {
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_err (LOGD_SHARING, "error loading NAT module %s: (%d) %s",
|
|
|
|
|
*iter, error ? error->code : 0,
|
|
|
|
|
(error && error->message) ? error->message : "unknown");
|
2008-08-15 15:34:28 +00:00
|
|
|
if (error)
|
|
|
|
|
g_error_free (error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
add_share_rule (NMActRequest *req, const char *table, const char *fmt, ...)
|
|
|
|
|
{
|
|
|
|
|
va_list args;
|
|
|
|
|
char *cmd;
|
|
|
|
|
|
|
|
|
|
va_start (args, fmt);
|
|
|
|
|
cmd = g_strdup_vprintf (fmt, args);
|
|
|
|
|
va_end (args);
|
|
|
|
|
|
|
|
|
|
nm_act_request_add_share_rule (req, table, cmd);
|
|
|
|
|
g_free (cmd);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
2011-10-09 23:48:13 -05:00
|
|
|
start_sharing (NMDevice *self, NMIP4Config *config)
|
2008-08-15 15:34:28 +00:00
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
NMActRequest *req;
|
|
|
|
|
GError *error = NULL;
|
|
|
|
|
char str_addr[INET_ADDRSTRLEN + 1];
|
|
|
|
|
char str_mask[INET_ADDRSTRLEN + 1];
|
|
|
|
|
guint32 netmask, network;
|
2013-06-29 13:33:36 +02:00
|
|
|
const NMPlatformIP4Address *ip4_addr;
|
2008-10-22 16:32:13 +00:00
|
|
|
const char *ip_iface;
|
2008-08-15 15:34:28 +00:00
|
|
|
|
2011-10-09 23:48:13 -05:00
|
|
|
g_return_val_if_fail (config != NULL, FALSE);
|
2008-08-15 15:34:28 +00:00
|
|
|
|
2011-10-09 23:48:13 -05:00
|
|
|
ip_iface = nm_device_get_ip_iface (self);
|
2008-08-15 15:34:28 +00:00
|
|
|
|
2011-10-09 23:48:13 -05:00
|
|
|
ip4_addr = nm_ip4_config_get_address (config, 0);
|
2013-06-29 13:33:36 +02:00
|
|
|
if (!ip4_addr || !ip4_addr->address)
|
2008-08-15 15:34:28 +00:00
|
|
|
return FALSE;
|
|
|
|
|
|
2013-06-29 13:33:36 +02:00
|
|
|
netmask = nm_utils_ip4_prefix_to_netmask (ip4_addr->plen);
|
2008-08-15 15:34:28 +00:00
|
|
|
if (!inet_ntop (AF_INET, &netmask, str_mask, sizeof (str_mask)))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2013-06-29 13:33:36 +02:00
|
|
|
network = ip4_addr->address & netmask;
|
2008-08-15 15:34:28 +00:00
|
|
|
if (!inet_ntop (AF_INET, &network, str_addr, sizeof (str_addr)))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
if (!share_init ())
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
req = nm_device_get_act_request (self);
|
|
|
|
|
g_assert (req);
|
|
|
|
|
|
2008-10-22 16:32:13 +00:00
|
|
|
add_share_rule (req, "filter", "INPUT --in-interface %s --protocol tcp --destination-port 53 --jump ACCEPT", ip_iface);
|
|
|
|
|
add_share_rule (req, "filter", "INPUT --in-interface %s --protocol udp --destination-port 53 --jump ACCEPT", ip_iface);
|
|
|
|
|
add_share_rule (req, "filter", "INPUT --in-interface %s --protocol tcp --destination-port 67 --jump ACCEPT", ip_iface);
|
|
|
|
|
add_share_rule (req, "filter", "INPUT --in-interface %s --protocol udp --destination-port 67 --jump ACCEPT", ip_iface);
|
|
|
|
|
add_share_rule (req, "filter", "FORWARD --in-interface %s --jump REJECT", ip_iface);
|
|
|
|
|
add_share_rule (req, "filter", "FORWARD --out-interface %s --jump REJECT", ip_iface);
|
|
|
|
|
add_share_rule (req, "filter", "FORWARD --in-interface %s --out-interface %s --jump ACCEPT", ip_iface, ip_iface);
|
|
|
|
|
add_share_rule (req, "filter", "FORWARD --source %s/%s --in-interface %s --jump ACCEPT", str_addr, str_mask, ip_iface);
|
|
|
|
|
add_share_rule (req, "filter", "FORWARD --destination %s/%s --out-interface %s --match state --state ESTABLISHED,RELATED --jump ACCEPT", str_addr, str_mask, ip_iface);
|
2011-09-06 18:31:40 -05:00
|
|
|
add_share_rule (req, "nat", "POSTROUTING --source %s/%s ! --destination %s/%s --jump MASQUERADE", str_addr, str_mask, str_addr, str_mask);
|
2008-08-15 15:34:28 +00:00
|
|
|
|
|
|
|
|
nm_act_request_set_shared (req, TRUE);
|
|
|
|
|
|
2011-10-09 23:48:13 -05:00
|
|
|
if (!nm_dnsmasq_manager_start (priv->dnsmasq_manager, config, &error)) {
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_err (LOGD_SHARING, "(%s/%s): failed to start dnsmasq: %s",
|
2012-12-04 15:39:55 +01:00
|
|
|
nm_device_get_iface (self), ip_iface,
|
|
|
|
|
(error && error->message) ? error->message : "(unknown)");
|
2008-08-15 15:34:28 +00:00
|
|
|
g_error_free (error);
|
|
|
|
|
nm_act_request_set_shared (req, FALSE);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
priv->dnsmasq_state_id = g_signal_connect (priv->dnsmasq_manager, "state-changed",
|
|
|
|
|
G_CALLBACK (dnsmasq_state_changed_cb),
|
|
|
|
|
self);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2005-12-31 08:21:24 +00:00
|
|
|
|
|
|
|
|
static gboolean
|
2011-10-09 22:50:04 -05:00
|
|
|
nm_device_activate_ip4_config_commit (gpointer user_data)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
2007-06-11 13:36:34 +00:00
|
|
|
NMDevice *self = NM_DEVICE (user_data);
|
2009-08-05 18:03:09 -04:00
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
2011-10-09 22:50:04 -05:00
|
|
|
NMActRequest *req;
|
2008-10-29 14:35:25 +00:00
|
|
|
const char *iface, *method = NULL;
|
2008-05-29 20:58:52 +00:00
|
|
|
NMConnection *connection;
|
|
|
|
|
NMSettingIP4Config *s_ip4;
|
2008-07-11 10:28:53 +00:00
|
|
|
NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE;
|
2011-10-09 22:50:04 -05:00
|
|
|
int ifindex;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-01-04 12:06:26 +00:00
|
|
|
/* Clear the activation source ID now that this stage has run */
|
2011-12-06 17:17:34 -06:00
|
|
|
activation_source_clear (self, FALSE, AF_INET);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2011-12-06 16:36:37 -06:00
|
|
|
iface = nm_device_get_iface (self);
|
|
|
|
|
nm_log_info (LOGD_DEVICE, "Activation (%s) Stage 5 of 5 (IPv4 Commit) started...",
|
|
|
|
|
iface);
|
|
|
|
|
|
2011-10-09 22:50:04 -05:00
|
|
|
req = nm_device_get_act_request (self);
|
|
|
|
|
g_assert (req);
|
|
|
|
|
connection = nm_act_request_get_connection (req);
|
|
|
|
|
g_assert (connection);
|
|
|
|
|
|
|
|
|
|
/* Make sure the interface is up again just because */
|
|
|
|
|
ifindex = nm_device_get_ip_ifindex (self);
|
2013-01-21 15:12:24 +01:00
|
|
|
if (ifindex && !nm_platform_link_is_up (ifindex))
|
|
|
|
|
nm_platform_link_set_up (ifindex);
|
2009-08-05 18:03:09 -04:00
|
|
|
|
2013-08-01 10:34:46 -05:00
|
|
|
/* NULL to use the existing priv->dev_ip4_config */
|
2013-08-01 15:44:53 -05:00
|
|
|
if (!ip4_config_merge_and_apply (self, NULL, TRUE, &reason)) {
|
2011-10-09 22:50:04 -05:00
|
|
|
nm_log_info (LOGD_DEVICE | LOGD_IP4,
|
|
|
|
|
"Activation (%s) Stage 5 of 5 (IPv4 Commit) failed",
|
|
|
|
|
iface);
|
2008-07-11 10:28:53 +00:00
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, reason);
|
2008-05-29 20:58:52 +00:00
|
|
|
goto out;
|
|
|
|
|
}
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2011-10-09 22:50:04 -05:00
|
|
|
/* Start IPv4 sharing if we need it */
|
|
|
|
|
s_ip4 = nm_connection_get_setting_ip4_config (connection);
|
|
|
|
|
if (s_ip4)
|
|
|
|
|
method = nm_setting_ip4_config_get_method (s_ip4);
|
|
|
|
|
|
|
|
|
|
if (g_strcmp0 (method, NM_SETTING_IP4_CONFIG_METHOD_SHARED) == 0) {
|
2013-08-01 10:34:46 -05:00
|
|
|
if (!start_sharing (self, priv->ip4_config)) {
|
2011-10-09 22:50:04 -05:00
|
|
|
nm_log_warn (LOGD_SHARING, "Activation (%s) Stage 5 of 5 (IPv4 Commit) start sharing failed.", iface);
|
|
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_SHARED_START_FAILED);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
2009-07-29 12:12:41 -04:00
|
|
|
}
|
|
|
|
|
|
2013-06-11 17:05:49 -05:00
|
|
|
/* Enter the IP_CHECK state if this is the first method to complete */
|
2011-10-09 23:48:13 -05:00
|
|
|
priv->ip4_state = IP_DONE;
|
2011-10-09 22:50:04 -05:00
|
|
|
if (nm_device_get_state (self) == NM_DEVICE_STATE_IP_CONFIG)
|
2013-06-11 17:05:49 -05:00
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_IP_CHECK, NM_DEVICE_STATE_REASON_NONE);
|
2011-10-09 22:50:04 -05:00
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
nm_log_info (LOGD_DEVICE, "Activation (%s) Stage 5 of 5 (IPv4 Commit) complete.",
|
|
|
|
|
iface);
|
2008-10-29 14:35:25 +00:00
|
|
|
|
2011-10-09 22:50:04 -05:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
nm_device_activate_schedule_ip4_config_result (NMDevice *self, NMIP4Config *config)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (NM_IS_DEVICE (self));
|
2013-08-01 10:34:46 -05:00
|
|
|
g_return_if_fail (NM_IS_IP4_CONFIG (config));
|
2011-10-09 22:50:04 -05:00
|
|
|
priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
|
2013-08-01 10:34:46 -05:00
|
|
|
g_clear_object (&priv->dev_ip4_config);
|
|
|
|
|
priv->dev_ip4_config = g_object_ref (config);
|
2011-10-09 22:50:04 -05:00
|
|
|
|
2012-03-21 15:03:23 -05:00
|
|
|
activation_source_schedule (self, nm_device_activate_ip4_config_commit, AF_INET);
|
|
|
|
|
|
|
|
|
|
nm_log_info (LOGD_DEVICE | LOGD_IP4,
|
|
|
|
|
"Activation (%s) Stage 5 of 5 (IPv4 Configure Commit) scheduled...",
|
|
|
|
|
nm_device_get_iface (self));
|
2011-10-09 22:50:04 -05:00
|
|
|
}
|
|
|
|
|
|
2011-10-09 23:48:13 -05:00
|
|
|
gboolean
|
|
|
|
|
nm_device_activate_ip4_state_in_conf (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (self != NULL, FALSE);
|
|
|
|
|
return NM_DEVICE_GET_PRIVATE (self)->ip4_state == IP_CONF;
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-28 13:34:44 -06:00
|
|
|
gboolean
|
|
|
|
|
nm_device_activate_ip4_state_in_wait (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (self != NULL, FALSE);
|
|
|
|
|
return NM_DEVICE_GET_PRIVATE (self)->ip4_state == IP_WAIT;
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-09 22:50:04 -05:00
|
|
|
static gboolean
|
|
|
|
|
nm_device_activate_ip6_config_commit (gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMDevice *self = NM_DEVICE (user_data);
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
NMActRequest *req;
|
|
|
|
|
const char *iface;
|
|
|
|
|
NMConnection *connection;
|
|
|
|
|
NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE;
|
|
|
|
|
int ifindex;
|
|
|
|
|
|
|
|
|
|
/* Clear the activation source ID now that this stage has run */
|
2011-12-06 17:17:34 -06:00
|
|
|
activation_source_clear (self, FALSE, AF_INET6);
|
2011-10-09 22:50:04 -05:00
|
|
|
|
2011-12-06 16:36:37 -06:00
|
|
|
iface = nm_device_get_iface (self);
|
|
|
|
|
nm_log_info (LOGD_DEVICE, "Activation (%s) Stage 5 of 5 (IPv6 Commit) started...",
|
|
|
|
|
iface);
|
|
|
|
|
|
2011-10-09 22:50:04 -05:00
|
|
|
req = nm_device_get_act_request (self);
|
|
|
|
|
g_assert (req);
|
|
|
|
|
connection = nm_act_request_get_connection (req);
|
|
|
|
|
g_assert (connection);
|
|
|
|
|
|
|
|
|
|
/* Make sure the interface is up again just because */
|
|
|
|
|
ifindex = nm_device_get_ip_ifindex (self);
|
2013-01-21 15:12:24 +01:00
|
|
|
if (ifindex && !nm_platform_link_is_up (ifindex))
|
|
|
|
|
nm_platform_link_set_up (ifindex);
|
2011-10-09 22:50:04 -05:00
|
|
|
|
|
|
|
|
/* Allow setting MTU etc */
|
|
|
|
|
if (NM_DEVICE_GET_CLASS (self)->ip6_config_pre_commit)
|
2013-06-14 21:42:22 +02:00
|
|
|
NM_DEVICE_GET_CLASS (self)->ip6_config_pre_commit (self);
|
2011-10-09 22:50:04 -05:00
|
|
|
|
2013-06-14 21:42:22 +02:00
|
|
|
if (ip6_config_merge_and_apply (self, &reason)) {
|
2013-06-11 17:05:49 -05:00
|
|
|
/* Enter the IP_CHECK state if this is the first method to complete */
|
2011-10-21 14:25:35 -05:00
|
|
|
priv->ip6_state = IP_DONE;
|
|
|
|
|
if (nm_device_get_state (self) == NM_DEVICE_STATE_IP_CONFIG)
|
2013-06-11 17:05:49 -05:00
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_IP_CHECK, NM_DEVICE_STATE_REASON_NONE);
|
2011-10-21 14:25:35 -05:00
|
|
|
} else {
|
2011-10-09 22:50:04 -05:00
|
|
|
nm_log_info (LOGD_DEVICE | LOGD_IP6,
|
|
|
|
|
"Activation (%s) Stage 5 of 5 (IPv6 Commit) failed",
|
|
|
|
|
iface);
|
|
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, reason);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nm_log_info (LOGD_DEVICE, "Activation (%s) Stage 5 of 5 (IPv6 Commit) complete.",
|
2010-04-07 12:31:39 -07:00
|
|
|
iface);
|
2008-09-05 02:55:40 +00:00
|
|
|
|
2005-12-31 08:21:24 +00:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-09 22:50:04 -05:00
|
|
|
void
|
2013-06-14 21:42:22 +02:00
|
|
|
nm_device_activate_schedule_ip6_config_result (NMDevice *self)
|
2011-10-09 22:50:04 -05:00
|
|
|
{
|
|
|
|
|
g_return_if_fail (NM_IS_DEVICE (self));
|
|
|
|
|
|
2012-03-21 15:03:23 -05:00
|
|
|
activation_source_schedule (self, nm_device_activate_ip6_config_commit, AF_INET6);
|
|
|
|
|
|
2013-06-14 21:42:22 +02:00
|
|
|
nm_log_info (LOGD_DEVICE | LOGD_IP6,
|
2012-03-21 15:03:23 -05:00
|
|
|
"Activation (%s) Stage 5 of 5 (IPv6 Commit) scheduled...",
|
|
|
|
|
nm_device_get_iface (self));
|
2011-10-09 22:50:04 -05:00
|
|
|
}
|
|
|
|
|
|
2011-10-09 23:48:13 -05:00
|
|
|
gboolean
|
|
|
|
|
nm_device_activate_ip6_state_in_conf (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (self != NULL, FALSE);
|
|
|
|
|
return NM_DEVICE_GET_PRIVATE (self)->ip6_state == IP_CONF;
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-28 13:34:44 -06:00
|
|
|
gboolean
|
|
|
|
|
nm_device_activate_ip6_state_in_wait (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (self != NULL, FALSE);
|
|
|
|
|
return NM_DEVICE_GET_PRIVATE (self)->ip6_state == IP_WAIT;
|
|
|
|
|
}
|
|
|
|
|
|
2007-09-11 18:02:27 +00:00
|
|
|
static void
|
|
|
|
|
clear_act_request (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate * priv;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (self != NULL);
|
|
|
|
|
|
|
|
|
|
priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
|
2007-09-11 19:20:34 +00:00
|
|
|
if (!priv->act_request)
|
2007-09-11 18:02:27 +00:00
|
|
|
return;
|
|
|
|
|
|
2012-02-03 14:53:09 -06:00
|
|
|
nm_active_connection_set_default (NM_ACTIVE_CONNECTION (priv->act_request), FALSE);
|
2008-06-10 02:01:13 +00:00
|
|
|
|
2007-09-11 18:02:27 +00:00
|
|
|
g_object_unref (priv->act_request);
|
|
|
|
|
priv->act_request = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-13 17:59:54 -08:00
|
|
|
static void
|
2011-01-05 16:23:00 -06:00
|
|
|
dhcp4_cleanup (NMDevice *self, gboolean stop, gboolean release)
|
2010-01-13 17:59:54 -08:00
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
if (priv->dhcp4_config) {
|
2011-11-18 00:34:08 -06:00
|
|
|
g_object_notify (G_OBJECT (self), NM_DEVICE_DHCP4_CONFIG);
|
2010-01-13 17:59:54 -08:00
|
|
|
g_object_unref (priv->dhcp4_config);
|
|
|
|
|
priv->dhcp4_config = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (priv->dhcp4_client) {
|
|
|
|
|
/* Stop any ongoing DHCP transaction on this device */
|
2010-01-13 18:06:05 -08:00
|
|
|
if (priv->dhcp4_state_sigid) {
|
|
|
|
|
g_signal_handler_disconnect (priv->dhcp4_client, priv->dhcp4_state_sigid);
|
|
|
|
|
priv->dhcp4_state_sigid = 0;
|
2010-01-13 17:59:54 -08:00
|
|
|
}
|
|
|
|
|
|
2010-01-13 18:06:05 -08:00
|
|
|
if (priv->dhcp4_timeout_sigid) {
|
|
|
|
|
g_signal_handler_disconnect (priv->dhcp4_client, priv->dhcp4_timeout_sigid);
|
|
|
|
|
priv->dhcp4_timeout_sigid = 0;
|
2010-01-13 17:59:54 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (stop)
|
2011-01-05 16:23:00 -06:00
|
|
|
nm_dhcp_client_stop (priv->dhcp4_client, release);
|
2010-01-13 17:59:54 -08:00
|
|
|
|
|
|
|
|
g_object_unref (priv->dhcp4_client);
|
|
|
|
|
priv->dhcp4_client = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-14 00:45:10 -08:00
|
|
|
static void
|
2011-01-05 16:23:00 -06:00
|
|
|
dhcp6_cleanup (NMDevice *self, gboolean stop, gboolean release)
|
2010-01-14 00:45:10 -08:00
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
|
2013-05-30 16:53:23 +02:00
|
|
|
priv->dhcp6_mode = NM_RDISC_DHCP_LEVEL_NONE;
|
2010-05-01 10:16:38 -07:00
|
|
|
|
2011-10-21 14:25:35 -05:00
|
|
|
if (priv->dhcp6_ip6_config) {
|
|
|
|
|
g_object_unref (priv->dhcp6_ip6_config);
|
|
|
|
|
priv->dhcp6_ip6_config = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-14 00:45:10 -08:00
|
|
|
if (priv->dhcp6_config) {
|
2011-11-18 00:34:08 -06:00
|
|
|
g_object_notify (G_OBJECT (self), NM_DEVICE_DHCP6_CONFIG);
|
2010-01-14 00:45:10 -08:00
|
|
|
g_object_unref (priv->dhcp6_config);
|
|
|
|
|
priv->dhcp6_config = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (priv->dhcp6_client) {
|
|
|
|
|
if (priv->dhcp6_state_sigid) {
|
|
|
|
|
g_signal_handler_disconnect (priv->dhcp6_client, priv->dhcp6_state_sigid);
|
|
|
|
|
priv->dhcp6_state_sigid = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (priv->dhcp6_timeout_sigid) {
|
|
|
|
|
g_signal_handler_disconnect (priv->dhcp6_client, priv->dhcp6_timeout_sigid);
|
|
|
|
|
priv->dhcp6_timeout_sigid = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (stop)
|
2011-01-05 16:23:00 -06:00
|
|
|
nm_dhcp_client_stop (priv->dhcp6_client, release);
|
2010-01-14 00:45:10 -08:00
|
|
|
|
|
|
|
|
g_object_unref (priv->dhcp6_client);
|
|
|
|
|
priv->dhcp6_client = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
dnsmasq_cleanup (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
if (!priv->dnsmasq_manager)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (priv->dnsmasq_state_id) {
|
|
|
|
|
g_signal_handler_disconnect (priv->dnsmasq_manager, priv->dnsmasq_state_id);
|
|
|
|
|
priv->dnsmasq_state_id = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nm_dnsmasq_manager_stop (priv->dnsmasq_manager);
|
|
|
|
|
g_object_unref (priv->dnsmasq_manager);
|
|
|
|
|
priv->dnsmasq_manager = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-17 22:39:34 -06:00
|
|
|
static void
|
|
|
|
|
_update_ip4_address (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
struct ifreq req;
|
|
|
|
|
guint32 new_address;
|
|
|
|
|
int fd;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (self != NULL);
|
|
|
|
|
|
|
|
|
|
fd = socket (PF_INET, SOCK_DGRAM, 0);
|
|
|
|
|
if (fd < 0) {
|
|
|
|
|
nm_log_err (LOGD_IP4, "couldn't open control socket.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
memset (&req, 0, sizeof (struct ifreq));
|
|
|
|
|
strncpy (req.ifr_name, nm_device_get_ip_iface (self), IFNAMSIZ);
|
|
|
|
|
if (ioctl (fd, SIOCGIFADDR, &req) == 0) {
|
|
|
|
|
new_address = ((struct sockaddr_in *)(&req.ifr_addr))->sin_addr.s_addr;
|
|
|
|
|
if (new_address != priv->ip4_address)
|
|
|
|
|
priv->ip4_address = new_address;
|
|
|
|
|
}
|
|
|
|
|
close (fd);
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-05 10:03:41 +02:00
|
|
|
|
2013-08-07 11:41:40 +02:00
|
|
|
/*
|
|
|
|
|
* delete_on_deactivate_link_delete
|
|
|
|
|
*
|
|
|
|
|
* Function will be queued with g_idle_add to call
|
|
|
|
|
* nm_platform_link_delete for the underlying resources
|
|
|
|
|
* of the device.
|
|
|
|
|
*/
|
|
|
|
|
static gboolean
|
|
|
|
|
delete_on_deactivate_link_delete (gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
int ifindex = GPOINTER_TO_INT (user_data);
|
|
|
|
|
|
|
|
|
|
nm_log_dbg (LOGD_DEVICE, "device deactivated: cleanup and delete virtual link #%d", ifindex);
|
|
|
|
|
nm_platform_link_delete (ifindex);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
delete_on_deactivate_unschedule (NMDevicePrivate *priv)
|
|
|
|
|
{
|
|
|
|
|
if (priv->delete_on_deactivate_id) {
|
|
|
|
|
g_source_remove (priv->delete_on_deactivate_id);
|
|
|
|
|
priv->delete_on_deactivate_id = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
delete_on_deactivate_check_and_schedule (NMDevice *self, int ifindex)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv;
|
|
|
|
|
|
|
|
|
|
if (ifindex <= 0)
|
|
|
|
|
return;
|
|
|
|
|
if (!nm_device_get_is_nm_owned (self))
|
|
|
|
|
return;
|
|
|
|
|
if (!nm_device_is_software (self))
|
|
|
|
|
return;
|
|
|
|
|
if (nm_device_get_state (self) == NM_DEVICE_STATE_UNMANAGED)
|
|
|
|
|
return;
|
|
|
|
|
nm_log_dbg (LOGD_DEVICE, "Schedule cleanup and delete virtual link #%d for [%s]",
|
|
|
|
|
ifindex, nm_device_get_iface (self));
|
|
|
|
|
priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
delete_on_deactivate_unschedule (priv); /* always cancel and reschedule */
|
|
|
|
|
priv->delete_on_deactivate_id = g_idle_add (delete_on_deactivate_link_delete, GINT_TO_POINTER (ifindex));
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-05 10:03:41 +02:00
|
|
|
gboolean
|
|
|
|
|
nm_device_get_is_nm_owned (NMDevice *device)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (device), FALSE);
|
|
|
|
|
return NM_DEVICE_GET_PRIVATE (device)->is_nm_owned;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
|
nm_device_set_is_nm_owned (NMDevice *device,
|
|
|
|
|
gboolean is_nm_owned)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (NM_IS_DEVICE (device));
|
|
|
|
|
|
|
|
|
|
priv = NM_DEVICE_GET_PRIVATE (device);
|
|
|
|
|
|
|
|
|
|
if (is_nm_owned == priv->is_nm_owned)
|
|
|
|
|
return TRUE;
|
|
|
|
|
if (!is_nm_owned)
|
|
|
|
|
return FALSE;
|
|
|
|
|
priv->is_nm_owned = TRUE;
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-12-31 08:21:24 +00:00
|
|
|
/*
|
2011-02-24 11:27:42 -06:00
|
|
|
* nm_device_deactivate
|
2005-12-31 08:21:24 +00:00
|
|
|
*
|
2011-02-24 11:27:42 -06:00
|
|
|
* Remove a device's routing table entries and IP address.
|
2005-12-31 08:21:24 +00:00
|
|
|
*
|
|
|
|
|
*/
|
2011-02-24 11:27:42 -06:00
|
|
|
static void
|
2011-11-17 23:55:34 -06:00
|
|
|
nm_device_deactivate (NMDevice *self, NMDeviceStateReason reason)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
2011-11-17 23:55:34 -06:00
|
|
|
NMDevicePrivate *priv;
|
2011-02-24 11:27:42 -06:00
|
|
|
NMDeviceStateReason ignored = NM_DEVICE_STATE_REASON_NONE;
|
2012-02-10 16:45:24 +01:00
|
|
|
NMConnection *connection = NULL;
|
|
|
|
|
NMSettingConnection *s_con = NULL;
|
2013-03-04 11:53:11 +01:00
|
|
|
int ifindex;
|
2008-03-17 20:59:54 +00:00
|
|
|
|
2011-11-17 23:55:34 -06:00
|
|
|
g_return_if_fail (NM_IS_DEVICE (self));
|
2008-03-17 20:59:54 +00:00
|
|
|
|
2011-09-19 14:19:53 +02:00
|
|
|
nm_log_info (LOGD_DEVICE, "(%s): deactivating device (reason '%s') [%d]",
|
|
|
|
|
nm_device_get_iface (self), reason_to_string (reason), reason);
|
2011-02-24 11:27:42 -06:00
|
|
|
|
|
|
|
|
/* Save whether or not we tried IPv6 for later */
|
2011-11-17 23:55:34 -06:00
|
|
|
priv = NM_DEVICE_GET_PRIVATE (self);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2011-10-07 15:58:08 +02:00
|
|
|
/* Clean up when device was deactivated during call to firewall */
|
|
|
|
|
if (priv->fw_call) {
|
2012-02-10 16:45:24 +01:00
|
|
|
nm_firewall_manager_cancel_call (priv->fw_manager, priv->fw_call);
|
2011-10-07 15:58:08 +02:00
|
|
|
priv->fw_call = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-10 16:45:24 +01:00
|
|
|
if (priv->act_request)
|
|
|
|
|
connection = nm_act_request_get_connection (priv->act_request);
|
|
|
|
|
if (connection) {
|
|
|
|
|
s_con = nm_connection_get_setting_connection (connection);
|
|
|
|
|
nm_firewall_manager_remove_from_zone (priv->fw_manager,
|
|
|
|
|
nm_device_get_ip_iface (self),
|
|
|
|
|
nm_setting_connection_get_zone (s_con));
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-11 17:05:49 -05:00
|
|
|
ip_check_gw_ping_cleanup (self);
|
|
|
|
|
|
2008-03-17 20:59:54 +00:00
|
|
|
/* Break the activation chain */
|
2009-07-29 12:12:41 -04:00
|
|
|
activation_source_clear (self, TRUE, AF_INET);
|
|
|
|
|
activation_source_clear (self, TRUE, AF_INET6);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2011-12-08 11:46:58 -06:00
|
|
|
/* Clear any queued transitions */
|
2012-08-30 15:59:31 -05:00
|
|
|
nm_device_queued_state_clear (self);
|
2013-04-04 10:20:24 -04:00
|
|
|
nm_device_queued_ip_config_change_clear (self);
|
2008-04-17 23:04:34 +00:00
|
|
|
|
2011-10-09 23:48:13 -05:00
|
|
|
priv->ip4_state = priv->ip6_state = IP_NONE;
|
|
|
|
|
|
2011-01-05 16:23:00 -06:00
|
|
|
dhcp4_cleanup (self, TRUE, FALSE);
|
|
|
|
|
dhcp6_cleanup (self, TRUE, FALSE);
|
2010-01-14 00:45:10 -08:00
|
|
|
addrconf6_cleanup (self);
|
|
|
|
|
dnsmasq_cleanup (self);
|
2008-07-09 14:05:49 +00:00
|
|
|
aipd_cleanup (self);
|
|
|
|
|
|
2010-05-03 03:42:43 -07:00
|
|
|
/* Turn off router advertisements until they are needed */
|
|
|
|
|
if (priv->ip6_accept_ra_path)
|
2012-11-16 13:57:47 -06:00
|
|
|
nm_utils_do_sysctl (priv->ip6_accept_ra_path, "0");
|
2010-05-03 03:42:43 -07:00
|
|
|
|
2012-02-21 15:44:19 +01:00
|
|
|
/* Turn off IPv6 privacy extensions */
|
|
|
|
|
if (priv->ip6_privacy_tempaddr_path)
|
2012-11-16 13:57:47 -06:00
|
|
|
nm_utils_do_sysctl (priv->ip6_privacy_tempaddr_path, "0");
|
2012-02-21 15:44:19 +01:00
|
|
|
|
2006-01-13 16:53:55 +00:00
|
|
|
/* Call device type-specific deactivation */
|
2011-02-24 11:27:42 -06:00
|
|
|
if (NM_DEVICE_GET_CLASS (self)->deactivate)
|
|
|
|
|
NM_DEVICE_GET_CLASS (self)->deactivate (self);
|
2006-01-13 16:53:55 +00:00
|
|
|
|
2012-11-14 14:05:30 -06:00
|
|
|
/* master: release slaves */
|
|
|
|
|
nm_device_master_release_slaves (self, FALSE);
|
|
|
|
|
|
|
|
|
|
/* slave: mark no longer enslaved */
|
2013-01-17 17:11:04 -06:00
|
|
|
g_clear_object (&priv->master);
|
2012-11-14 14:05:30 -06:00
|
|
|
priv->enslaved = FALSE;
|
|
|
|
|
|
2008-08-14 17:45:47 +00:00
|
|
|
/* Tear down an existing activation request */
|
|
|
|
|
clear_act_request (self);
|
|
|
|
|
|
2005-12-31 08:21:24 +00:00
|
|
|
/* Take out any entries in the routing table and any IP address the device had. */
|
2011-07-22 13:37:29 -05:00
|
|
|
ifindex = nm_device_get_ip_ifindex (self);
|
2012-05-15 09:44:49 -05:00
|
|
|
if (ifindex > 0) {
|
2013-03-04 11:53:11 +01:00
|
|
|
nm_platform_route_flush (ifindex);
|
2013-03-04 11:53:11 +01:00
|
|
|
nm_platform_address_flush (ifindex);
|
2011-12-12 14:01:21 -06:00
|
|
|
}
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2009-07-30 13:50:42 -04:00
|
|
|
/* Clean up nameservers and addresses */
|
2013-06-26 00:16:45 +02:00
|
|
|
nm_device_set_ip4_config (self, NULL, TRUE, &ignored);
|
|
|
|
|
nm_device_set_ip6_config (self, NULL, TRUE, &ignored);
|
2013-08-01 15:44:53 -05:00
|
|
|
g_clear_object (&priv->ext_ip4_config);
|
2013-08-01 10:59:42 -05:00
|
|
|
g_clear_object (&priv->vpn4_config);
|
|
|
|
|
g_clear_object (&priv->vpn6_config);
|
2013-06-24 22:43:33 -05:00
|
|
|
|
|
|
|
|
/* Clear legacy IPv4 address property */
|
|
|
|
|
priv->ip4_address = 0;
|
|
|
|
|
g_object_notify (G_OBJECT (self), NM_DEVICE_IP4_ADDRESS);
|
|
|
|
|
|
|
|
|
|
/* Only clear ip_iface after flushing all routes and addreses, since
|
|
|
|
|
* those are identified by ip_iface, not by iface (which might be a tty
|
|
|
|
|
* or ATM device).
|
|
|
|
|
*/
|
|
|
|
|
nm_device_set_ip_iface (self, NULL);
|
2013-08-07 11:41:40 +02:00
|
|
|
|
|
|
|
|
/* Check if the device was deactivated, and if so, delete_link.
|
|
|
|
|
* Don't call delete_link synchronously because we are currently
|
|
|
|
|
* handling a state change -- which is not reentrant. */
|
|
|
|
|
delete_on_deactivate_check_and_schedule (self, ifindex);
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
2012-06-01 16:53:23 -05:00
|
|
|
static void
|
|
|
|
|
disconnect_cb (NMDevice *device,
|
|
|
|
|
DBusGMethodInvocation *context,
|
|
|
|
|
GError *error,
|
|
|
|
|
gpointer user_data)
|
2009-09-16 13:18:24 +02:00
|
|
|
{
|
2012-06-01 16:53:23 -05:00
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
|
|
|
|
|
GError *local = NULL;
|
2011-11-17 23:44:17 -06:00
|
|
|
|
2012-06-01 16:53:23 -05:00
|
|
|
if (error)
|
|
|
|
|
dbus_g_method_return_error (context, error);
|
|
|
|
|
else {
|
|
|
|
|
/* Authorized */
|
|
|
|
|
if (priv->state <= NM_DEVICE_STATE_DISCONNECTED) {
|
|
|
|
|
local = g_error_new_literal (NM_DEVICE_ERROR,
|
|
|
|
|
NM_DEVICE_ERROR_NOT_ACTIVE,
|
|
|
|
|
"Device is not active");
|
|
|
|
|
dbus_g_method_return_error (context, local);
|
|
|
|
|
g_error_free (local);
|
|
|
|
|
} else {
|
|
|
|
|
priv->autoconnect = FALSE;
|
|
|
|
|
nm_device_state_changed (device,
|
|
|
|
|
NM_DEVICE_STATE_DISCONNECTED,
|
|
|
|
|
NM_DEVICE_STATE_REASON_USER_REQUESTED);
|
|
|
|
|
dbus_g_method_return (context);
|
|
|
|
|
}
|
2011-11-17 23:44:17 -06:00
|
|
|
}
|
2009-09-16 13:18:24 +02:00
|
|
|
}
|
|
|
|
|
|
2011-11-18 00:34:08 -06:00
|
|
|
static void
|
|
|
|
|
impl_device_disconnect (NMDevice *device, DBusGMethodInvocation *context)
|
|
|
|
|
{
|
2012-06-01 16:53:23 -05:00
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
|
|
if (NM_DEVICE_GET_PRIVATE (device)->act_request == NULL) {
|
|
|
|
|
error = g_error_new_literal (NM_DEVICE_ERROR,
|
|
|
|
|
NM_DEVICE_ERROR_NOT_ACTIVE,
|
|
|
|
|
"This device is not active");
|
|
|
|
|
dbus_g_method_return_error (context, error);
|
|
|
|
|
g_error_free (error);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Ask the manager to authenticate this request for us */
|
|
|
|
|
g_signal_emit (device, signals[AUTH_REQUEST], 0,
|
|
|
|
|
context,
|
|
|
|
|
NM_AUTH_PERMISSION_NETWORK_CONTROL,
|
|
|
|
|
TRUE,
|
|
|
|
|
disconnect_cb,
|
|
|
|
|
NULL);
|
2011-11-18 00:34:08 -06:00
|
|
|
}
|
|
|
|
|
|
2012-11-13 17:36:39 -06:00
|
|
|
void
|
|
|
|
|
nm_device_activate (NMDevice *self, NMActRequest *req)
|
2007-09-14 19:51:04 +00:00
|
|
|
{
|
2011-11-17 23:50:13 -06:00
|
|
|
NMDevicePrivate *priv;
|
|
|
|
|
NMConnection *connection;
|
|
|
|
|
|
2012-11-13 17:36:39 -06:00
|
|
|
g_return_if_fail (NM_IS_DEVICE (self));
|
|
|
|
|
g_return_if_fail (NM_IS_ACT_REQUEST (req));
|
2011-11-17 23:50:13 -06:00
|
|
|
|
|
|
|
|
priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
connection = nm_act_request_get_connection (req);
|
|
|
|
|
g_assert (connection);
|
|
|
|
|
|
|
|
|
|
nm_log_info (LOGD_DEVICE, "Activation (%s) starting connection '%s'",
|
|
|
|
|
nm_device_get_iface (self),
|
|
|
|
|
nm_connection_get_id (connection));
|
2007-09-14 19:51:04 +00:00
|
|
|
|
2013-04-24 10:40:58 -04:00
|
|
|
if (priv->state < NM_DEVICE_STATE_DISCONNECTED) {
|
2013-07-12 10:43:45 -04:00
|
|
|
g_return_if_fail (nm_device_can_activate (self, connection));
|
2013-04-24 10:40:58 -04:00
|
|
|
|
|
|
|
|
if (priv->state == NM_DEVICE_STATE_UNMANAGED) {
|
|
|
|
|
nm_device_state_changed (self,
|
|
|
|
|
NM_DEVICE_STATE_UNAVAILABLE,
|
|
|
|
|
NM_DEVICE_STATE_REASON_NONE);
|
|
|
|
|
}
|
|
|
|
|
if (priv->state == NM_DEVICE_STATE_UNAVAILABLE) {
|
|
|
|
|
nm_device_state_changed (self,
|
|
|
|
|
NM_DEVICE_STATE_DISCONNECTED,
|
|
|
|
|
NM_DEVICE_STATE_REASON_NONE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-13 17:36:39 -06:00
|
|
|
g_warn_if_fail (priv->state == NM_DEVICE_STATE_DISCONNECTED);
|
2007-10-01 15:38:39 +00:00
|
|
|
|
|
|
|
|
priv->act_request = g_object_ref (req);
|
2012-04-24 16:27:00 +02:00
|
|
|
g_object_notify (G_OBJECT (self), NM_DEVICE_ACTIVE_CONNECTION);
|
2007-09-27 04:52:03 +00:00
|
|
|
|
2013-06-26 00:39:46 +02:00
|
|
|
if (priv->state_reason == NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED) {
|
2012-11-13 17:46:59 -06:00
|
|
|
/* If it's an assumed connection, let the device subclass short-circuit
|
|
|
|
|
* the normal connection process and just copy its IP configs from the
|
|
|
|
|
* interface.
|
|
|
|
|
*/
|
2013-06-26 00:39:46 +02:00
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_IP_CONFIG, NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED);
|
2012-11-13 17:46:59 -06:00
|
|
|
nm_device_activate_schedule_stage3_ip_config_start (self);
|
|
|
|
|
} else {
|
2012-11-14 14:05:30 -06:00
|
|
|
NMDevice *master;
|
2012-02-26 17:40:22 -06:00
|
|
|
|
2009-08-05 18:03:09 -04:00
|
|
|
/* HACK: update the state a bit early to avoid a race between the
|
|
|
|
|
* scheduled stage1 handler and nm_policy_device_change_check() thinking
|
|
|
|
|
* that the activation request isn't deferred because the deferred bit
|
|
|
|
|
* gets cleared a bit too early, when the connection becomes valid.
|
|
|
|
|
*/
|
|
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_PREPARE, NM_DEVICE_STATE_REASON_NONE);
|
2012-02-26 17:40:22 -06:00
|
|
|
|
|
|
|
|
/* Handle any dependencies this connection might have */
|
2012-08-22 09:38:01 -05:00
|
|
|
master = nm_active_connection_get_master (NM_ACTIVE_CONNECTION (req));
|
2012-11-14 14:05:30 -06:00
|
|
|
if (master) {
|
|
|
|
|
/* Master should at least already be activating */
|
|
|
|
|
g_assert (nm_device_get_state (master) > NM_DEVICE_STATE_DISCONNECTED);
|
|
|
|
|
|
|
|
|
|
g_assert (priv->master == NULL);
|
|
|
|
|
priv->master = g_object_ref (master);
|
|
|
|
|
nm_device_master_add_slave (master, self);
|
2012-02-26 17:40:22 -06:00
|
|
|
}
|
2012-11-14 14:05:30 -06:00
|
|
|
|
|
|
|
|
nm_device_activate_schedule_stage1_device_prepare (self);
|
2009-08-05 18:03:09 -04:00
|
|
|
}
|
2007-09-14 19:51:04 +00:00
|
|
|
}
|
|
|
|
|
|
2005-12-31 08:21:24 +00:00
|
|
|
/*
|
|
|
|
|
* nm_device_is_activating
|
|
|
|
|
*
|
|
|
|
|
* Return whether or not the device is currently activating itself.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
gboolean
|
2007-02-05 12:14:09 +00:00
|
|
|
nm_device_is_activating (NMDevice *device)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
2007-09-21 03:49:28 +00:00
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
|
2011-03-17 13:39:31 -05:00
|
|
|
NMDeviceState state;
|
2007-09-21 03:49:28 +00:00
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (device), FALSE);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2011-03-17 13:39:31 -05:00
|
|
|
state = nm_device_get_state (device);
|
|
|
|
|
if (state >= NM_DEVICE_STATE_PREPARE && state <= NM_DEVICE_STATE_SECONDARIES)
|
2007-02-05 12:14:09 +00:00
|
|
|
return TRUE;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-09-21 03:49:28 +00:00
|
|
|
/* There's a small race between the time when stage 1 is scheduled
|
|
|
|
|
* and when the device actually sets STATE_PREPARE when the activation
|
|
|
|
|
* handler is actually run. If there's an activation handler scheduled
|
|
|
|
|
* we're activating anyway.
|
|
|
|
|
*/
|
2011-03-17 13:39:31 -05:00
|
|
|
return priv->act_source_id ? TRUE : FALSE;
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2013-05-07 10:23:44 -04:00
|
|
|
static gboolean
|
|
|
|
|
can_interrupt_activation (NMDevice *device)
|
|
|
|
|
{
|
|
|
|
|
/* Devices that support carrier detect can interrupt activation
|
|
|
|
|
* if the link becomes inactive.
|
|
|
|
|
*/
|
|
|
|
|
return nm_device_is_unavailable_because_of_carrier (device);
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-22 22:40:14 +00:00
|
|
|
gboolean
|
|
|
|
|
nm_device_can_interrupt_activation (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
gboolean interrupt = FALSE;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (self != NULL, FALSE);
|
|
|
|
|
|
|
|
|
|
if (NM_DEVICE_GET_CLASS (self)->can_interrupt_activation)
|
|
|
|
|
interrupt = NM_DEVICE_GET_CLASS (self)->can_interrupt_activation (self);
|
|
|
|
|
return interrupt;
|
|
|
|
|
}
|
2006-01-03 22:11:35 +00:00
|
|
|
|
2005-12-31 08:21:24 +00:00
|
|
|
/* IP Configuration stuff */
|
|
|
|
|
|
2008-09-18 Dan Williams <dcbw@redhat.com>
Implement support for honoring configured and automatic hostnames, and for
setting the configured hostname.
* introspection/nm-ip4-config.xml
src/nm-ip4-config.c
src/nm-ip4-config.h
src/dhcp-manager/nm-dhcp-manager.c
- Remove useless hostname property; it's not really part of the IPv4
config
* introspection/nm-settings-system.xml
libnm-glib/nm-dbus-settings-system.c
libnm-glib/nm-dbus-settings-system.h
- Add SetHostname() call to system settings D-Bus interface
- Add Hostname property to system settings D-Bus interface
- (nm_dbus_settings_system_save_hostname,
nm_dbus_settings_system_get_hostname): implement
* src/nm-device.c
src/nm-device.h
- (nm_device_get_dhcp4_config): implement
* src/nm-manager.c
src/nm-manager.h
- Fetch and track system settings service hostname changes, and proxy
the changes via a GObject property of the manager
* system-settings/src/nm-system-config-interface.c
system-settings/src/nm-system-config-interface.h
- Replace nm_system_config_interface_supports_add() with a capabilities
bitfield
* system-settings/src/nm-system-config-error.c
system-settings/src/nm-system-config-error.h
- Add additional errors
* system-settings/src/dbus-settings.c
system-settings/src/dbus-settings.h
- (get_property, nm_sysconfig_settings_class_init): add hostname
property; first plugin returning a hostname wins
- (impl_settings_add_connection): use plugin capabilities instead of
nm_system_config_interface_supports_add()
- (impl_settings_save_hostname): implement hostname saving
* src/NetworkManagerPolicy.c
- (lookup_thread_run_cb, lookup_thread_worker, lookup_thread_new,
lookup_thread_die): implement an asynchronous hostname lookup thread
which given an IPv4 address tries to look up the hostname for that
address with reverse DNS
- (get_best_device): split out best device code from
update_routing_and_dns()
- (update_etc_hosts): update /etc/hosts with the machine's new hostname
to preserve the 127.0.0.1 reverse mapping that so many things require
- (set_system_hostname): set a given hostname
- (update_system_hostname): implement hostname policy; a configured
hostname (from the system settings service) is used if available,
otherwise an automatically determined hostname from DHCP, VPN, etc.
If there was no automatically determined hostname, reverse DNS of
the best device's IP address will be used, and as a last resort the
hostname 'localhost.localdomain' is set.
- (update_routing_and_dns): use get_best_device(); update the system
hostname when the network config changes
- (hostname_changed): update system hostname if the system settings
service signals a hostname change
- (nm_policy_new): list for system settings service hostname changes
- (nm_policy_destroy): ensure that an in-progress hostname lookup thread
gets told to die
* system-settings/plugins/keyfile/plugin.c
system-settings/plugins/ifcfg-suse/plugin.c
- (get_property, sc_plugin_ifcfg_class_init): implement hostname and
capabilities properties
* system-settings/plugins/ifcfg-fedora/shvar.c
- (svOpenFile): re-enable R/W access of ifcfg files since the plugin
writes out /etc/sysconfig/network now
* system-settings/plugins/ifcfg-fedora/plugin.c
- (plugin_get_hostname): get hostname from /etc/sysconfig/network
- (plugin_set_hostname): save hostname to /etc/sysconfig/network
- (sc_network_changed_cb): handle changes to /etc/sysconfig/network
- (sc_plugin_ifcfg_init): monitor /etc/sysconfig/network for changes
- (get_property, set_property, sc_plugin_ifcfg_class_init): implement
hostname get/set and capabilities get
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4077 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-09-18 15:16:44 +00:00
|
|
|
NMDHCP4Config *
|
|
|
|
|
nm_device_get_dhcp4_config (NMDevice *self)
|
|
|
|
|
{
|
2010-01-14 00:45:10 -08:00
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (self), NULL);
|
2008-09-18 Dan Williams <dcbw@redhat.com>
Implement support for honoring configured and automatic hostnames, and for
setting the configured hostname.
* introspection/nm-ip4-config.xml
src/nm-ip4-config.c
src/nm-ip4-config.h
src/dhcp-manager/nm-dhcp-manager.c
- Remove useless hostname property; it's not really part of the IPv4
config
* introspection/nm-settings-system.xml
libnm-glib/nm-dbus-settings-system.c
libnm-glib/nm-dbus-settings-system.h
- Add SetHostname() call to system settings D-Bus interface
- Add Hostname property to system settings D-Bus interface
- (nm_dbus_settings_system_save_hostname,
nm_dbus_settings_system_get_hostname): implement
* src/nm-device.c
src/nm-device.h
- (nm_device_get_dhcp4_config): implement
* src/nm-manager.c
src/nm-manager.h
- Fetch and track system settings service hostname changes, and proxy
the changes via a GObject property of the manager
* system-settings/src/nm-system-config-interface.c
system-settings/src/nm-system-config-interface.h
- Replace nm_system_config_interface_supports_add() with a capabilities
bitfield
* system-settings/src/nm-system-config-error.c
system-settings/src/nm-system-config-error.h
- Add additional errors
* system-settings/src/dbus-settings.c
system-settings/src/dbus-settings.h
- (get_property, nm_sysconfig_settings_class_init): add hostname
property; first plugin returning a hostname wins
- (impl_settings_add_connection): use plugin capabilities instead of
nm_system_config_interface_supports_add()
- (impl_settings_save_hostname): implement hostname saving
* src/NetworkManagerPolicy.c
- (lookup_thread_run_cb, lookup_thread_worker, lookup_thread_new,
lookup_thread_die): implement an asynchronous hostname lookup thread
which given an IPv4 address tries to look up the hostname for that
address with reverse DNS
- (get_best_device): split out best device code from
update_routing_and_dns()
- (update_etc_hosts): update /etc/hosts with the machine's new hostname
to preserve the 127.0.0.1 reverse mapping that so many things require
- (set_system_hostname): set a given hostname
- (update_system_hostname): implement hostname policy; a configured
hostname (from the system settings service) is used if available,
otherwise an automatically determined hostname from DHCP, VPN, etc.
If there was no automatically determined hostname, reverse DNS of
the best device's IP address will be used, and as a last resort the
hostname 'localhost.localdomain' is set.
- (update_routing_and_dns): use get_best_device(); update the system
hostname when the network config changes
- (hostname_changed): update system hostname if the system settings
service signals a hostname change
- (nm_policy_new): list for system settings service hostname changes
- (nm_policy_destroy): ensure that an in-progress hostname lookup thread
gets told to die
* system-settings/plugins/keyfile/plugin.c
system-settings/plugins/ifcfg-suse/plugin.c
- (get_property, sc_plugin_ifcfg_class_init): implement hostname and
capabilities properties
* system-settings/plugins/ifcfg-fedora/shvar.c
- (svOpenFile): re-enable R/W access of ifcfg files since the plugin
writes out /etc/sysconfig/network now
* system-settings/plugins/ifcfg-fedora/plugin.c
- (plugin_get_hostname): get hostname from /etc/sysconfig/network
- (plugin_set_hostname): save hostname to /etc/sysconfig/network
- (sc_network_changed_cb): handle changes to /etc/sysconfig/network
- (sc_plugin_ifcfg_init): monitor /etc/sysconfig/network for changes
- (get_property, set_property, sc_plugin_ifcfg_class_init): implement
hostname get/set and capabilities get
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4077 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-09-18 15:16:44 +00:00
|
|
|
|
2010-01-14 00:45:10 -08:00
|
|
|
return NM_DEVICE_GET_PRIVATE (self)->dhcp4_config;
|
2008-09-18 Dan Williams <dcbw@redhat.com>
Implement support for honoring configured and automatic hostnames, and for
setting the configured hostname.
* introspection/nm-ip4-config.xml
src/nm-ip4-config.c
src/nm-ip4-config.h
src/dhcp-manager/nm-dhcp-manager.c
- Remove useless hostname property; it's not really part of the IPv4
config
* introspection/nm-settings-system.xml
libnm-glib/nm-dbus-settings-system.c
libnm-glib/nm-dbus-settings-system.h
- Add SetHostname() call to system settings D-Bus interface
- Add Hostname property to system settings D-Bus interface
- (nm_dbus_settings_system_save_hostname,
nm_dbus_settings_system_get_hostname): implement
* src/nm-device.c
src/nm-device.h
- (nm_device_get_dhcp4_config): implement
* src/nm-manager.c
src/nm-manager.h
- Fetch and track system settings service hostname changes, and proxy
the changes via a GObject property of the manager
* system-settings/src/nm-system-config-interface.c
system-settings/src/nm-system-config-interface.h
- Replace nm_system_config_interface_supports_add() with a capabilities
bitfield
* system-settings/src/nm-system-config-error.c
system-settings/src/nm-system-config-error.h
- Add additional errors
* system-settings/src/dbus-settings.c
system-settings/src/dbus-settings.h
- (get_property, nm_sysconfig_settings_class_init): add hostname
property; first plugin returning a hostname wins
- (impl_settings_add_connection): use plugin capabilities instead of
nm_system_config_interface_supports_add()
- (impl_settings_save_hostname): implement hostname saving
* src/NetworkManagerPolicy.c
- (lookup_thread_run_cb, lookup_thread_worker, lookup_thread_new,
lookup_thread_die): implement an asynchronous hostname lookup thread
which given an IPv4 address tries to look up the hostname for that
address with reverse DNS
- (get_best_device): split out best device code from
update_routing_and_dns()
- (update_etc_hosts): update /etc/hosts with the machine's new hostname
to preserve the 127.0.0.1 reverse mapping that so many things require
- (set_system_hostname): set a given hostname
- (update_system_hostname): implement hostname policy; a configured
hostname (from the system settings service) is used if available,
otherwise an automatically determined hostname from DHCP, VPN, etc.
If there was no automatically determined hostname, reverse DNS of
the best device's IP address will be used, and as a last resort the
hostname 'localhost.localdomain' is set.
- (update_routing_and_dns): use get_best_device(); update the system
hostname when the network config changes
- (hostname_changed): update system hostname if the system settings
service signals a hostname change
- (nm_policy_new): list for system settings service hostname changes
- (nm_policy_destroy): ensure that an in-progress hostname lookup thread
gets told to die
* system-settings/plugins/keyfile/plugin.c
system-settings/plugins/ifcfg-suse/plugin.c
- (get_property, sc_plugin_ifcfg_class_init): implement hostname and
capabilities properties
* system-settings/plugins/ifcfg-fedora/shvar.c
- (svOpenFile): re-enable R/W access of ifcfg files since the plugin
writes out /etc/sysconfig/network now
* system-settings/plugins/ifcfg-fedora/plugin.c
- (plugin_get_hostname): get hostname from /etc/sysconfig/network
- (plugin_set_hostname): save hostname to /etc/sysconfig/network
- (sc_network_changed_cb): handle changes to /etc/sysconfig/network
- (sc_plugin_ifcfg_init): monitor /etc/sysconfig/network for changes
- (get_property, set_property, sc_plugin_ifcfg_class_init): implement
hostname get/set and capabilities get
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4077 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-09-18 15:16:44 +00:00
|
|
|
}
|
2005-12-31 08:21:24 +00:00
|
|
|
|
|
|
|
|
NMIP4Config *
|
|
|
|
|
nm_device_get_ip4_config (NMDevice *self)
|
|
|
|
|
{
|
2010-01-14 00:45:10 -08:00
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (self), NULL);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2008-03-11 22:26:46 +00:00
|
|
|
return NM_DEVICE_GET_PRIVATE (self)->ip4_config;
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-11-07 13:57:39 +00:00
|
|
|
static gboolean
|
|
|
|
|
nm_device_set_ip4_config (NMDevice *self,
|
|
|
|
|
NMIP4Config *new_config,
|
2013-06-26 00:16:45 +02:00
|
|
|
gboolean commit,
|
2008-11-07 13:57:39 +00:00
|
|
|
NMDeviceStateReason *reason)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
2007-12-06 14:51:43 +00:00
|
|
|
NMDevicePrivate *priv;
|
|
|
|
|
const char *ip_iface;
|
2008-11-07 13:57:39 +00:00
|
|
|
NMIP4Config *old_config = NULL;
|
|
|
|
|
gboolean success = TRUE;
|
2011-07-22 14:09:16 -05:00
|
|
|
int ip_ifindex;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-12-06 14:51:43 +00:00
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (self), FALSE);
|
|
|
|
|
|
|
|
|
|
priv = NM_DEVICE_GET_PRIVATE (self);
|
2008-08-12 08:05:16 +00:00
|
|
|
ip_iface = nm_device_get_ip_iface (self);
|
2012-05-29 09:56:50 -05:00
|
|
|
ip_ifindex = nm_device_get_ip_ifindex (self);
|
2007-02-16 11:23:49 +00:00
|
|
|
|
2008-11-07 13:57:39 +00:00
|
|
|
old_config = priv->ip4_config;
|
2008-03-11 02:46:35 +00:00
|
|
|
|
2013-07-02 22:22:57 +02:00
|
|
|
/* Always commit to nm-platform to update lifetimes */
|
|
|
|
|
if (commit && new_config)
|
|
|
|
|
success = nm_ip4_config_commit (new_config, ip_ifindex, nm_device_get_priority (self));
|
|
|
|
|
|
2013-07-04 15:40:01 +02:00
|
|
|
if (nm_ip4_config_equal (new_config, old_config))
|
2013-07-02 22:45:25 +02:00
|
|
|
return success;
|
2008-03-11 02:46:35 +00:00
|
|
|
|
2012-05-29 22:17:26 -05:00
|
|
|
priv->ip4_config = NULL;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2008-11-07 13:57:39 +00:00
|
|
|
if (new_config) {
|
|
|
|
|
priv->ip4_config = g_object_ref (new_config);
|
2007-12-06 14:51:43 +00:00
|
|
|
|
2013-06-26 00:16:45 +02:00
|
|
|
if (success || !commit) {
|
2008-11-07 13:57:39 +00:00
|
|
|
/* Export over D-Bus */
|
|
|
|
|
if (!nm_ip4_config_get_dbus_path (new_config))
|
|
|
|
|
nm_ip4_config_export (new_config);
|
2011-11-17 22:39:34 -06:00
|
|
|
_update_ip4_address (self);
|
2008-11-07 13:57:39 +00:00
|
|
|
}
|
2013-04-04 11:06:39 -04:00
|
|
|
|
|
|
|
|
if (!success && reason)
|
|
|
|
|
*reason = NM_DEVICE_STATE_REASON_CONFIG_FAILED;
|
2013-08-01 10:34:46 -05:00
|
|
|
} else {
|
|
|
|
|
/* Device config is invalid if combined config is invalid */
|
|
|
|
|
g_clear_object (&priv->dev_ip4_config);
|
2008-11-07 13:57:39 +00:00
|
|
|
}
|
2007-12-06 14:51:43 +00:00
|
|
|
|
2011-11-18 00:34:08 -06:00
|
|
|
g_object_notify (G_OBJECT (self), NM_DEVICE_IP4_CONFIG);
|
2012-05-29 09:56:50 -05:00
|
|
|
g_signal_emit (self, signals[IP4_CONFIG_CHANGED], 0, priv->ip4_config, old_config);
|
|
|
|
|
|
|
|
|
|
if (old_config)
|
|
|
|
|
g_object_unref (old_config);
|
2008-03-11 22:26:46 +00:00
|
|
|
|
2007-12-06 14:51:43 +00:00
|
|
|
return success;
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
2013-08-01 10:59:42 -05:00
|
|
|
void
|
|
|
|
|
nm_device_set_vpn4_config (NMDevice *device, NMIP4Config *config)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
|
|
|
|
|
|
|
|
|
|
if (priv->vpn4_config == config)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
g_clear_object (&priv->vpn4_config);
|
|
|
|
|
if (config)
|
|
|
|
|
priv->vpn4_config = g_object_ref (config);
|
|
|
|
|
|
|
|
|
|
/* NULL to use existing configs */
|
2013-08-01 15:44:53 -05:00
|
|
|
if (!ip4_config_merge_and_apply (device, NULL, TRUE, NULL)) {
|
2013-08-01 10:59:42 -05:00
|
|
|
nm_log_warn (LOGD_IP4, "(%s): failed to set VPN routes for device",
|
|
|
|
|
nm_device_get_ip_iface (device));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-29 12:12:41 -04:00
|
|
|
static gboolean
|
|
|
|
|
nm_device_set_ip6_config (NMDevice *self,
|
|
|
|
|
NMIP6Config *new_config,
|
2013-06-26 00:16:45 +02:00
|
|
|
gboolean commit,
|
2009-07-29 12:12:41 -04:00
|
|
|
NMDeviceStateReason *reason)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv;
|
|
|
|
|
const char *ip_iface;
|
|
|
|
|
NMIP6Config *old_config = NULL;
|
|
|
|
|
gboolean success = TRUE;
|
2011-07-22 14:24:18 -05:00
|
|
|
int ip_ifindex;
|
2009-07-29 12:12:41 -04:00
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (self), FALSE);
|
|
|
|
|
|
|
|
|
|
priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
ip_iface = nm_device_get_ip_iface (self);
|
2011-07-22 14:24:18 -05:00
|
|
|
ip_ifindex = nm_device_get_ip_ifindex (self);
|
2009-07-29 12:12:41 -04:00
|
|
|
|
|
|
|
|
old_config = priv->ip6_config;
|
|
|
|
|
|
2013-07-02 22:22:57 +02:00
|
|
|
/* Always commit to nm-platform to update lifetimes */
|
|
|
|
|
if (commit && new_config)
|
|
|
|
|
success = nm_ip6_config_commit (new_config, ip_ifindex, nm_device_get_priority (self));
|
|
|
|
|
|
2013-07-04 15:40:01 +02:00
|
|
|
if (nm_ip6_config_equal (new_config, old_config))
|
2013-07-02 22:45:25 +02:00
|
|
|
return success;
|
2009-07-29 12:12:41 -04:00
|
|
|
|
2012-05-29 22:17:26 -05:00
|
|
|
priv->ip6_config = NULL;
|
2009-07-29 12:12:41 -04:00
|
|
|
|
|
|
|
|
if (new_config) {
|
|
|
|
|
priv->ip6_config = g_object_ref (new_config);
|
|
|
|
|
|
2013-06-26 00:16:45 +02:00
|
|
|
if (success || !commit) {
|
2009-07-29 12:12:41 -04:00
|
|
|
/* Export over D-Bus */
|
|
|
|
|
if (!nm_ip6_config_get_dbus_path (new_config))
|
|
|
|
|
nm_ip6_config_export (new_config);
|
|
|
|
|
}
|
2013-04-04 11:06:39 -04:00
|
|
|
|
|
|
|
|
if (!success && reason)
|
|
|
|
|
*reason = NM_DEVICE_STATE_REASON_CONFIG_FAILED;
|
2009-07-29 12:12:41 -04:00
|
|
|
}
|
|
|
|
|
|
2011-11-18 00:34:08 -06:00
|
|
|
g_object_notify (G_OBJECT (self), NM_DEVICE_IP6_CONFIG);
|
2012-05-29 09:56:50 -05:00
|
|
|
g_signal_emit (self, signals[IP6_CONFIG_CHANGED], 0, priv->ip6_config, old_config);
|
|
|
|
|
|
|
|
|
|
if (old_config)
|
|
|
|
|
g_object_unref (old_config);
|
2009-07-29 12:12:41 -04:00
|
|
|
|
|
|
|
|
return success;
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-01 10:59:42 -05:00
|
|
|
void
|
|
|
|
|
nm_device_set_vpn6_config (NMDevice *device, NMIP6Config *config)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
|
|
|
|
|
|
|
|
|
|
if (priv->vpn6_config == config)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
g_clear_object (&priv->vpn6_config);
|
|
|
|
|
if (config)
|
|
|
|
|
priv->vpn6_config = g_object_ref (config);
|
|
|
|
|
|
|
|
|
|
/* NULL to use existing configs */
|
|
|
|
|
if (!ip6_config_merge_and_apply (device, NULL)) {
|
|
|
|
|
nm_log_warn (LOGD_IP6, "(%s): failed to set VPN routes for device",
|
|
|
|
|
nm_device_get_ip_iface (device));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-14 00:45:10 -08:00
|
|
|
NMDHCP6Config *
|
|
|
|
|
nm_device_get_dhcp6_config (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (self), NULL);
|
|
|
|
|
|
|
|
|
|
return NM_DEVICE_GET_PRIVATE (self)->dhcp6_config;
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-29 12:12:41 -04:00
|
|
|
NMIP6Config *
|
|
|
|
|
nm_device_get_ip6_config (NMDevice *self)
|
|
|
|
|
{
|
2010-01-14 00:45:10 -08:00
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (self), NULL);
|
2009-07-29 12:12:41 -04:00
|
|
|
|
|
|
|
|
return NM_DEVICE_GET_PRIVATE (self)->ip6_config;
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-11 17:05:49 -05:00
|
|
|
/****************************************************************/
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
ip_check_gw_ping_cleanup (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
if (priv->gw_ping.watch) {
|
|
|
|
|
g_source_remove (priv->gw_ping.watch);
|
|
|
|
|
priv->gw_ping.watch = 0;
|
|
|
|
|
}
|
|
|
|
|
if (priv->gw_ping.timeout) {
|
|
|
|
|
g_source_remove (priv->gw_ping.timeout);
|
|
|
|
|
priv->gw_ping.timeout = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (priv->gw_ping.pid) {
|
|
|
|
|
guint count = 20;
|
|
|
|
|
int status;
|
|
|
|
|
|
|
|
|
|
kill (priv->gw_ping.pid, SIGKILL);
|
|
|
|
|
do {
|
|
|
|
|
if (waitpid (priv->gw_ping.pid, &status, WNOHANG) != 0)
|
|
|
|
|
break;
|
|
|
|
|
g_usleep (G_USEC_PER_SEC / 20);
|
|
|
|
|
} while (count--);
|
|
|
|
|
|
|
|
|
|
priv->gw_ping.pid = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
ip_check_ping_watch_cb (GPid pid, gint status, gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMDevice *self = NM_DEVICE (user_data);
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
const char *iface;
|
|
|
|
|
guint log_domain = priv->gw_ping.log_domain;
|
|
|
|
|
|
|
|
|
|
if (!priv->gw_ping.watch)
|
|
|
|
|
return;
|
|
|
|
|
priv->gw_ping.watch = 0;
|
|
|
|
|
priv->gw_ping.pid = 0;
|
|
|
|
|
|
|
|
|
|
iface = nm_device_get_iface (self);
|
|
|
|
|
|
|
|
|
|
if (WIFEXITED (status)) {
|
|
|
|
|
if (WEXITSTATUS (status) == 0)
|
|
|
|
|
nm_log_dbg (log_domain, "(%s): gateway ping succeeded", iface);
|
|
|
|
|
else {
|
|
|
|
|
nm_log_warn (log_domain, "(%s): gateway ping failed with error code %d",
|
|
|
|
|
iface, WEXITSTATUS (status));
|
|
|
|
|
}
|
|
|
|
|
} else
|
|
|
|
|
nm_log_warn (log_domain, "(%s): ping stopped unexpectedly with status %d", iface, status);
|
|
|
|
|
|
|
|
|
|
/* We've got connectivity, proceed to secondaries */
|
|
|
|
|
ip_check_gw_ping_cleanup (self);
|
|
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_SECONDARIES, NM_DEVICE_STATE_REASON_NONE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
ip_check_ping_timeout_cb (gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMDevice *self = NM_DEVICE (user_data);
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
priv->gw_ping.timeout = 0;
|
|
|
|
|
|
|
|
|
|
nm_log_warn (priv->gw_ping.log_domain, "(%s): gateway ping timed out",
|
|
|
|
|
nm_device_get_iface (self));
|
|
|
|
|
|
|
|
|
|
ip_check_gw_ping_cleanup (self);
|
|
|
|
|
nm_device_state_changed (self, NM_DEVICE_STATE_SECONDARIES, NM_DEVICE_STATE_REASON_NONE);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
spawn_ping (NMDevice *self,
|
|
|
|
|
guint log_domain,
|
|
|
|
|
const char *binary,
|
|
|
|
|
const char *address,
|
|
|
|
|
guint timeout)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
const char *args[] = { binary, "-I", nm_device_get_ip_iface (self), "-c", "1", "-w", NULL, address, NULL };
|
|
|
|
|
GError *error = NULL;
|
|
|
|
|
char *str_timeout, *cmd;
|
|
|
|
|
gboolean success;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (priv->gw_ping.watch == 0, FALSE);
|
|
|
|
|
g_return_val_if_fail (priv->gw_ping.timeout == 0, FALSE);
|
|
|
|
|
|
|
|
|
|
args[6] = str_timeout = g_strdup_printf ("%u", timeout);
|
|
|
|
|
|
|
|
|
|
if (nm_logging_level_enabled (LOGL_DEBUG)) {
|
|
|
|
|
cmd = g_strjoinv (" ", (gchar **) args);
|
|
|
|
|
nm_log_dbg (log_domain, "(%s): running '%s'",
|
|
|
|
|
nm_device_get_iface (self),
|
|
|
|
|
cmd);
|
|
|
|
|
g_free (cmd);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
success = g_spawn_async ("/",
|
|
|
|
|
(gchar **) args,
|
|
|
|
|
NULL,
|
|
|
|
|
G_SPAWN_DO_NOT_REAP_CHILD,
|
|
|
|
|
nm_unblock_posix_signals,
|
|
|
|
|
NULL,
|
|
|
|
|
&priv->gw_ping.pid,
|
|
|
|
|
&error);
|
|
|
|
|
if (success) {
|
|
|
|
|
priv->gw_ping.log_domain = log_domain;
|
|
|
|
|
priv->gw_ping.watch = g_child_watch_add (priv->gw_ping.pid, ip_check_ping_watch_cb, self);
|
|
|
|
|
priv->gw_ping.timeout = g_timeout_add_seconds (timeout + 1, ip_check_ping_timeout_cb, self);
|
|
|
|
|
} else {
|
|
|
|
|
nm_log_warn (log_domain, "could not spawn %s: %s", binary, error->message);
|
|
|
|
|
g_clear_error (&error);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_free (str_timeout);
|
|
|
|
|
return success;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
nm_device_start_ip_check (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
NMConnection *connection;
|
|
|
|
|
NMSettingConnection *s_con;
|
|
|
|
|
guint timeout = 0;
|
|
|
|
|
const char *ping_binary = NULL;
|
|
|
|
|
char buf[INET6_ADDRSTRLEN] = { 0 };
|
|
|
|
|
guint log_domain = LOGD_IP4;
|
|
|
|
|
|
|
|
|
|
/* Shouldn't be any active ping here, since IP_CHECK happens after the
|
|
|
|
|
* first IP method completes. Any subsequently completing IP method doesn't
|
|
|
|
|
* get checked.
|
|
|
|
|
*/
|
|
|
|
|
g_assert (!priv->gw_ping.watch);
|
|
|
|
|
g_assert (!priv->gw_ping.timeout);
|
|
|
|
|
g_assert (!priv->gw_ping.pid);
|
|
|
|
|
g_assert (priv->ip4_state == IP_DONE || priv->ip6_state == IP_DONE);
|
|
|
|
|
|
|
|
|
|
connection = nm_device_get_connection (self);
|
|
|
|
|
g_assert (connection);
|
|
|
|
|
|
|
|
|
|
s_con = nm_connection_get_setting_connection (connection);
|
|
|
|
|
g_assert (s_con);
|
|
|
|
|
timeout = nm_setting_connection_get_gateway_ping_timeout (s_con);
|
|
|
|
|
|
|
|
|
|
if (timeout) {
|
2013-06-27 17:51:24 +02:00
|
|
|
if (priv->ip4_state == IP_DONE) {
|
2013-06-11 17:05:49 -05:00
|
|
|
guint gw = 0;
|
|
|
|
|
|
|
|
|
|
ping_binary = "/usr/bin/ping";
|
|
|
|
|
log_domain = LOGD_IP4;
|
|
|
|
|
|
|
|
|
|
gw = nm_ip4_config_get_gateway (priv->ip4_config);
|
|
|
|
|
if (gw && !inet_ntop (AF_INET, &gw, buf, sizeof (buf)))
|
|
|
|
|
buf[0] = '\0';
|
|
|
|
|
} else if (priv->ip6_config && priv->ip6_state == IP_DONE) {
|
|
|
|
|
const struct in6_addr *gw = NULL;
|
|
|
|
|
|
|
|
|
|
ping_binary = "/usr/bin/ping6";
|
|
|
|
|
log_domain = LOGD_IP6;
|
|
|
|
|
|
|
|
|
|
gw = nm_ip6_config_get_gateway (priv->ip6_config);
|
|
|
|
|
if (gw && !inet_ntop (AF_INET6, gw, buf, sizeof (buf)))
|
|
|
|
|
buf[0] = '\0';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (buf[0])
|
|
|
|
|
spawn_ping (self, log_domain, ping_binary, buf, timeout);
|
|
|
|
|
|
|
|
|
|
/* If no ping was started, just advance to SECONDARIES */
|
|
|
|
|
if (!priv->gw_ping.pid)
|
2013-07-02 15:19:41 +02:00
|
|
|
nm_device_queue_state (self, NM_DEVICE_STATE_SECONDARIES, NM_DEVICE_STATE_REASON_NONE);
|
2013-06-11 17:05:49 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/****************************************************************/
|
|
|
|
|
|
2008-05-14 01:55:49 +00:00
|
|
|
gboolean
|
2013-06-13 15:13:58 -05:00
|
|
|
nm_device_bring_up (NMDevice *self, gboolean block, gboolean *no_firmware)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
2007-03-12 04:49:29 +00:00
|
|
|
gboolean success;
|
2008-03-13 19:31:08 +00:00
|
|
|
guint32 tries = 0;
|
2007-03-12 04:49:29 +00:00
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (self), FALSE);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2013-06-13 15:13:58 -05:00
|
|
|
if (nm_device_is_up (self))
|
2008-04-28 Dan Williams <dcbw@redhat.com>
Fix the device up/down ambiguities. Up/down state used to be a
conglomeration of hardware state (IFF_UP) and any device-specific things
(supplicant, periodic timers, etc) that the device used to indicate
readiness. Unfortunately, if the hardware was already IFF_UP for some
reason, then the device specific stuff wouldn't get run, and the device
would be stuck.
* src/nm-device.c
src/nm-device.h
- Create hw_is_up, hw_bring_up, and hw_take_down
- Rename bring_down -> take_down
- (real_hw_is_up): check interface flags for IFF_UP
- (nm_device_hw_is_up): let subclasses figure out their own HW state
- (nm_device_is_up): make static; only used locally
- (nm_device_hw_bring_up): update the hardware and IPv4 addresses even
if the device is already up; if the device isn't up, bring it up
- (nm_device_hw_take_down): just take down hardware
- (nm_device_bring_up): bring up HW first, then device specific stuff
- (nm_device_take_down): always deactivate device when called; always
try to take hardware down too
- (nm_device_state_changed): take device down when entering unmanaged
state from a higher state
* src/nm-device-802-11-wireless.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
- (real_take_down, supplicant_iface_state_cb_handler,
supplicant_iface_connection_state_cb_handler,
supplicant_mgr_state_cb_handler): fix some messages
* src/nm-device-802-3-ethernet.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3618 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-29 15:36:29 +00:00
|
|
|
goto out;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_HW, "(%s): bringing up device.", nm_device_get_iface (self));
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2013-06-13 15:13:58 -05:00
|
|
|
if (NM_DEVICE_GET_CLASS (self)->bring_up) {
|
|
|
|
|
success = NM_DEVICE_GET_CLASS (self)->bring_up (self, no_firmware);
|
2008-04-28 Dan Williams <dcbw@redhat.com>
Fix the device up/down ambiguities. Up/down state used to be a
conglomeration of hardware state (IFF_UP) and any device-specific things
(supplicant, periodic timers, etc) that the device used to indicate
readiness. Unfortunately, if the hardware was already IFF_UP for some
reason, then the device specific stuff wouldn't get run, and the device
would be stuck.
* src/nm-device.c
src/nm-device.h
- Create hw_is_up, hw_bring_up, and hw_take_down
- Rename bring_down -> take_down
- (real_hw_is_up): check interface flags for IFF_UP
- (nm_device_hw_is_up): let subclasses figure out their own HW state
- (nm_device_is_up): make static; only used locally
- (nm_device_hw_bring_up): update the hardware and IPv4 addresses even
if the device is already up; if the device isn't up, bring it up
- (nm_device_hw_take_down): just take down hardware
- (nm_device_bring_up): bring up HW first, then device specific stuff
- (nm_device_take_down): always deactivate device when called; always
try to take hardware down too
- (nm_device_state_changed): take device down when entering unmanaged
state from a higher state
* src/nm-device-802-11-wireless.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
- (real_take_down, supplicant_iface_state_cb_handler,
supplicant_iface_connection_state_cb_handler,
supplicant_mgr_state_cb_handler): fix some messages
* src/nm-device-802-3-ethernet.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3618 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-29 15:36:29 +00:00
|
|
|
if (!success)
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Wait for the device to come up if requested */
|
2013-06-13 15:13:58 -05:00
|
|
|
while (block && !nm_device_is_up (self) && (tries++ < 50))
|
2008-04-28 Dan Williams <dcbw@redhat.com>
Fix the device up/down ambiguities. Up/down state used to be a
conglomeration of hardware state (IFF_UP) and any device-specific things
(supplicant, periodic timers, etc) that the device used to indicate
readiness. Unfortunately, if the hardware was already IFF_UP for some
reason, then the device specific stuff wouldn't get run, and the device
would be stuck.
* src/nm-device.c
src/nm-device.h
- Create hw_is_up, hw_bring_up, and hw_take_down
- Rename bring_down -> take_down
- (real_hw_is_up): check interface flags for IFF_UP
- (nm_device_hw_is_up): let subclasses figure out their own HW state
- (nm_device_is_up): make static; only used locally
- (nm_device_hw_bring_up): update the hardware and IPv4 addresses even
if the device is already up; if the device isn't up, bring it up
- (nm_device_hw_take_down): just take down hardware
- (nm_device_bring_up): bring up HW first, then device specific stuff
- (nm_device_take_down): always deactivate device when called; always
try to take hardware down too
- (nm_device_state_changed): take device down when entering unmanaged
state from a higher state
* src/nm-device-802-11-wireless.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
- (real_take_down, supplicant_iface_state_cb_handler,
supplicant_iface_connection_state_cb_handler,
supplicant_mgr_state_cb_handler): fix some messages
* src/nm-device-802-3-ethernet.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3618 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-29 15:36:29 +00:00
|
|
|
g_usleep (200);
|
2008-04-07 Dan Williams <dcbw@redhat.com>
* include/NetworkManager.h
- Remove the DOWN and CANCELLED device states
- Add UNMANAGED and UNAVAILABLE device states
- Document the device states
* introspection/nm-device.xml
src/nm-device-interface.c
src/nm-device-interface.h
- Add the 'managed' property
* test/nm-tool.c
- (detail_device): print out device state
* src/NetworkManagerSystem.h
src/backends/NetworkManagerArch.c
src/backends/NetworkManagerDebian.c
src/backends/NetworkManagerFrugalware.c
src/backends/NetworkManagerGentoo.c
src/backends/NetworkManagerMandriva.c
src/backends/NetworkManagerPaldo.c
src/backends/NetworkManagerRedHat.c
src/backends/NetworkManagerSlackware.c
src/backends/NetworkManagerSuSE.c
- (nm_system_device_get_system_config, nm_system_device_get_disabled
nm_system_device_free_system_config): remove; they were unused and
their functionality should be re-implemented in each distro's
system settings service plugin
* src/nm-gsm-device.c
src/nm-gsm-device.h
src/nm-cdma-device.c
src/nm-cdma-device.h
- (*_new): take the 'managed' argument
* src/nm-device.c
- (nm_device_set_address): remove, fold into nm_device_bring_up()
- (nm_device_init): start in unmanaged state, not disconnected
- (constructor): don't start device until the system settings service
has had a chance to figure out if the device is managed or not
- (nm_device_deactivate, nm_device_bring_up, nm_device_bring_down):
don't set device state here, let callers handle that as appropriate
- (nm_device_dispose): don't touch the device if it's not managed
- (set_property, get_property, nm_device_class_init): implement the
'managed' property
- (nm_device_state_changed): bring the device up if its now managed,
and deactivate it if it used to be active
- (nm_device_get_managed, nm_device_set_managed): do the right thing
with the managed state
* src/nm-hal-manager.c
- (wired_device_creator, wireless_device_creator, modem_device_creator):
take initial managed state and pass it along to device constructors
- (create_device_and_add_to_list): get managed state and pass to
type creators
* src/nm-device-802-11-wireless.c
- (real_can_activate): fold in most of
nm_device_802_11_wireless_can_activate()
- (can_scan): can't scan in UNAVAILABLE or UNMANAGED
- (link_timeout_cb): instead of deactivating, change device state and
let the device state handler to it
- (real_update_hw_address): clean up
- (state_changed_cb): when entering UNAVAILABLE state, schedule an idle
handler to transition to DISCONNECTED if the device isn't rfkilled
* src/nm-device-802-3-ethernet.c
- (set_carrier): move above callers and get rid of prototype
- (device_state_changed): when entering UNAVAILABLE state, schedule an
idle handler to transition to DISCONNECTED if the device has a
carrier
- (real_update_hw_address): clean up
- (link_timeout_cb, ppp_state_changed): change state instead of calling
deactivation directly as deactivation doesn't change state anymore
* src/NetworkManagerPolicy.c
- (schedule_activate_check): yay, remove wireless_enabled hack since
the NMManager and wireless devices work that out themselves now
- (device_state_changed): change to a switch and update for new device
states
- (device_carrier_changed): remove; device handles this now through
state changes
- (device_added): don't care about carrier any more; the initial
activation check will happen when the device transitions to
DISCONNECTED
* src/nm-manager.c
- (dispose): clear unmanaged devices
- (handle_unmanaged_devices): update unmanaged device list and toggle
the managed property on each device when needed
- (system_settings_properties_changed_cb): handle signals from the
system settings service
- (system_settings_get_unmanaged_devices_cb): handle callback from
getting the unmanaged device list method call
- (query_unmanaged_devices): ask the system settings service for its
list of unmanaged devices
- (nm_manager_name_owner_changed, initial_get_connections): get unmanaged
devices
- (manager_set_wireless_enabled): push rfkill state down to wireless
devices directly and let them handle the necessary state transitions
- (manager_device_state_changed): update for new device states
- (nm_manager_add_device): set initial rfkill state on wireless devices
- (nm_manager_remove_device): don't touch the device if it's unmanaged
- (nm_manager_activate_connection): return error if the device is
unmanaged
- (nm_manager_sleep): handle new device states correctly; don't change
the state of unavailable/unmanaged devices
* libnm-glib/nm-device-802-11-wireless.c
- (state_changed_cb): update for new device states
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3540 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 02:58:02 +00:00
|
|
|
|
2013-06-13 15:13:58 -05:00
|
|
|
if (!nm_device_is_up (self)) {
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_warn (LOGD_HW, "(%s): device not up after timeout!", nm_device_get_iface (self));
|
2008-04-28 Dan Williams <dcbw@redhat.com>
Fix the device up/down ambiguities. Up/down state used to be a
conglomeration of hardware state (IFF_UP) and any device-specific things
(supplicant, periodic timers, etc) that the device used to indicate
readiness. Unfortunately, if the hardware was already IFF_UP for some
reason, then the device specific stuff wouldn't get run, and the device
would be stuck.
* src/nm-device.c
src/nm-device.h
- Create hw_is_up, hw_bring_up, and hw_take_down
- Rename bring_down -> take_down
- (real_hw_is_up): check interface flags for IFF_UP
- (nm_device_hw_is_up): let subclasses figure out their own HW state
- (nm_device_is_up): make static; only used locally
- (nm_device_hw_bring_up): update the hardware and IPv4 addresses even
if the device is already up; if the device isn't up, bring it up
- (nm_device_hw_take_down): just take down hardware
- (nm_device_bring_up): bring up HW first, then device specific stuff
- (nm_device_take_down): always deactivate device when called; always
try to take hardware down too
- (nm_device_state_changed): take device down when entering unmanaged
state from a higher state
* src/nm-device-802-11-wireless.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
- (real_take_down, supplicant_iface_state_cb_handler,
supplicant_iface_connection_state_cb_handler,
supplicant_mgr_state_cb_handler): fix some messages
* src/nm-device-802-3-ethernet.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3618 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-29 15:36:29 +00:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
out:
|
2008-04-07 Dan Williams <dcbw@redhat.com>
* include/NetworkManager.h
- Remove the DOWN and CANCELLED device states
- Add UNMANAGED and UNAVAILABLE device states
- Document the device states
* introspection/nm-device.xml
src/nm-device-interface.c
src/nm-device-interface.h
- Add the 'managed' property
* test/nm-tool.c
- (detail_device): print out device state
* src/NetworkManagerSystem.h
src/backends/NetworkManagerArch.c
src/backends/NetworkManagerDebian.c
src/backends/NetworkManagerFrugalware.c
src/backends/NetworkManagerGentoo.c
src/backends/NetworkManagerMandriva.c
src/backends/NetworkManagerPaldo.c
src/backends/NetworkManagerRedHat.c
src/backends/NetworkManagerSlackware.c
src/backends/NetworkManagerSuSE.c
- (nm_system_device_get_system_config, nm_system_device_get_disabled
nm_system_device_free_system_config): remove; they were unused and
their functionality should be re-implemented in each distro's
system settings service plugin
* src/nm-gsm-device.c
src/nm-gsm-device.h
src/nm-cdma-device.c
src/nm-cdma-device.h
- (*_new): take the 'managed' argument
* src/nm-device.c
- (nm_device_set_address): remove, fold into nm_device_bring_up()
- (nm_device_init): start in unmanaged state, not disconnected
- (constructor): don't start device until the system settings service
has had a chance to figure out if the device is managed or not
- (nm_device_deactivate, nm_device_bring_up, nm_device_bring_down):
don't set device state here, let callers handle that as appropriate
- (nm_device_dispose): don't touch the device if it's not managed
- (set_property, get_property, nm_device_class_init): implement the
'managed' property
- (nm_device_state_changed): bring the device up if its now managed,
and deactivate it if it used to be active
- (nm_device_get_managed, nm_device_set_managed): do the right thing
with the managed state
* src/nm-hal-manager.c
- (wired_device_creator, wireless_device_creator, modem_device_creator):
take initial managed state and pass it along to device constructors
- (create_device_and_add_to_list): get managed state and pass to
type creators
* src/nm-device-802-11-wireless.c
- (real_can_activate): fold in most of
nm_device_802_11_wireless_can_activate()
- (can_scan): can't scan in UNAVAILABLE or UNMANAGED
- (link_timeout_cb): instead of deactivating, change device state and
let the device state handler to it
- (real_update_hw_address): clean up
- (state_changed_cb): when entering UNAVAILABLE state, schedule an idle
handler to transition to DISCONNECTED if the device isn't rfkilled
* src/nm-device-802-3-ethernet.c
- (set_carrier): move above callers and get rid of prototype
- (device_state_changed): when entering UNAVAILABLE state, schedule an
idle handler to transition to DISCONNECTED if the device has a
carrier
- (real_update_hw_address): clean up
- (link_timeout_cb, ppp_state_changed): change state instead of calling
deactivation directly as deactivation doesn't change state anymore
* src/NetworkManagerPolicy.c
- (schedule_activate_check): yay, remove wireless_enabled hack since
the NMManager and wireless devices work that out themselves now
- (device_state_changed): change to a switch and update for new device
states
- (device_carrier_changed): remove; device handles this now through
state changes
- (device_added): don't care about carrier any more; the initial
activation check will happen when the device transitions to
DISCONNECTED
* src/nm-manager.c
- (dispose): clear unmanaged devices
- (handle_unmanaged_devices): update unmanaged device list and toggle
the managed property on each device when needed
- (system_settings_properties_changed_cb): handle signals from the
system settings service
- (system_settings_get_unmanaged_devices_cb): handle callback from
getting the unmanaged device list method call
- (query_unmanaged_devices): ask the system settings service for its
list of unmanaged devices
- (nm_manager_name_owner_changed, initial_get_connections): get unmanaged
devices
- (manager_set_wireless_enabled): push rfkill state down to wireless
devices directly and let them handle the necessary state transitions
- (manager_device_state_changed): update for new device states
- (nm_manager_add_device): set initial rfkill state on wireless devices
- (nm_manager_remove_device): don't touch the device if it's unmanaged
- (nm_manager_activate_connection): return error if the device is
unmanaged
- (nm_manager_sleep): handle new device states correctly; don't change
the state of unavailable/unmanaged devices
* libnm-glib/nm-device-802-11-wireless.c
- (state_changed_cb): update for new device states
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3540 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 02:58:02 +00:00
|
|
|
/* Can only get HW address of some devices when they are up */
|
2013-05-01 09:28:16 -04:00
|
|
|
nm_device_update_hw_address (self);
|
2007-03-02 Tambet Ingo <tambet@ximian.com>
* libnm-glib/nm-device-802-11-wireless.c: Cache networks (bssids) list.
We get signalled when it changes.
* libnm-glib/nm-client.c: Cache NMState and device list, we get signalled
when it changes.
* libnm-glib/nm-device.c: Cache the device state property.
* libnm-glib/nm-access-point.c: Cache the strength property.
* src/nm-device-802-11-wireless.c: Fix wireless device scanning scheduler.
The new algorithm is to start from SCAN_INTERVAL_MIN (currently defined as 0)
and add a SCAN_INTERVAL_STEP (currently 20 seconds) with each successful scan
until SCAN_INTERVAL_MAX (currently 120 seconds) is reached. Do not scan while
the device is down, activating, or activated (in case of A/B/G cards).
Remove some old dead ifdef'ed out code that used to configure wireless devices,
it's all done through supplicant now.
* src/supplicant-manager/nm-supplicant-interface.c: Fix the reference
counting issues with pending calls which caused leaks and crashes when
interface was removed (now that the interface actually gets removed).
* src/nm-call-store.c: Make a copy of data before running a foreach
with user callback on it - The most common usage pattern is to cancel
(and thus remove) all pending calls with foreach which would modify
the hash table we're iterating over.
* src/nm-manager.c: When a device is added, make sure it is "up". When
it's removed or disabled due to disabling wireless or networking, bring
it down.
* include/NetworkManager.h: Add new device state NM_DEVICE_STATE_DOWN.
* src/nm-device-802-11-wireless.c:
* src/nm-device-802-3-ethernet.c:
* src/nm-device.c:
- Remove "init" virtual function, all gobjects have a place for that
already (constructor).
- Replace "start" virtual function with "bring_up", devices can be
brought up and down more than just on startup now.
- Add "is_up" virtual function.
- Implement one way to bring a device down instead of previous 4 different
ways, each of witch did something different.
* src/NetworkManagerUtils.c (nm_dev_sock_open): This doesn't need an NMDevice,
all it needs is the device interface.
Get rid of NMData.dev_list (3 members to go).
Get rif of NMData in a lot of places.
* gnome/libnm_glib/libnm_glib.c: Make it compile again.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2395 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-03-02 09:30:48 +00:00
|
|
|
|
2011-11-17 22:39:34 -06:00
|
|
|
_update_ip4_address (self);
|
2008-04-28 Dan Williams <dcbw@redhat.com>
Fix the device up/down ambiguities. Up/down state used to be a
conglomeration of hardware state (IFF_UP) and any device-specific things
(supplicant, periodic timers, etc) that the device used to indicate
readiness. Unfortunately, if the hardware was already IFF_UP for some
reason, then the device specific stuff wouldn't get run, and the device
would be stuck.
* src/nm-device.c
src/nm-device.h
- Create hw_is_up, hw_bring_up, and hw_take_down
- Rename bring_down -> take_down
- (real_hw_is_up): check interface flags for IFF_UP
- (nm_device_hw_is_up): let subclasses figure out their own HW state
- (nm_device_is_up): make static; only used locally
- (nm_device_hw_bring_up): update the hardware and IPv4 addresses even
if the device is already up; if the device isn't up, bring it up
- (nm_device_hw_take_down): just take down hardware
- (nm_device_bring_up): bring up HW first, then device specific stuff
- (nm_device_take_down): always deactivate device when called; always
try to take hardware down too
- (nm_device_state_changed): take device down when entering unmanaged
state from a higher state
* src/nm-device-802-11-wireless.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
- (real_take_down, supplicant_iface_state_cb_handler,
supplicant_iface_connection_state_cb_handler,
supplicant_mgr_state_cb_handler): fix some messages
* src/nm-device-802-3-ethernet.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3618 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-29 15:36:29 +00:00
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-22 16:43:15 +01:00
|
|
|
static gboolean
|
2013-06-13 15:13:58 -05:00
|
|
|
bring_up (NMDevice *device, gboolean *no_firmware)
|
2013-01-22 16:43:15 +01:00
|
|
|
{
|
|
|
|
|
int ifindex = nm_device_get_ip_ifindex (device);
|
2013-05-07 10:23:44 -04:00
|
|
|
gboolean result;
|
2013-01-22 16:43:15 +01:00
|
|
|
|
2013-05-07 10:23:44 -04:00
|
|
|
if (!ifindex)
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
2013-01-21 15:12:24 +01:00
|
|
|
result = nm_platform_link_set_up (ifindex);
|
2013-05-31 15:08:06 -05:00
|
|
|
if (no_firmware)
|
|
|
|
|
*no_firmware = nm_platform_get_error () == NM_PLATFORM_ERROR_NO_FIRMWARE;
|
2013-05-07 10:23:44 -04:00
|
|
|
|
|
|
|
|
/* Store carrier immediately. */
|
|
|
|
|
if (result && device_has_capability (device, NM_DEVICE_CAP_CARRIER_DETECT))
|
|
|
|
|
check_carrier (device);
|
|
|
|
|
|
|
|
|
|
return result;
|
2013-01-22 16:43:15 +01:00
|
|
|
}
|
|
|
|
|
|
2008-05-14 01:55:49 +00:00
|
|
|
void
|
2013-06-13 15:13:58 -05:00
|
|
|
nm_device_take_down (NMDevice *self, gboolean block)
|
2008-04-28 Dan Williams <dcbw@redhat.com>
Fix the device up/down ambiguities. Up/down state used to be a
conglomeration of hardware state (IFF_UP) and any device-specific things
(supplicant, periodic timers, etc) that the device used to indicate
readiness. Unfortunately, if the hardware was already IFF_UP for some
reason, then the device specific stuff wouldn't get run, and the device
would be stuck.
* src/nm-device.c
src/nm-device.h
- Create hw_is_up, hw_bring_up, and hw_take_down
- Rename bring_down -> take_down
- (real_hw_is_up): check interface flags for IFF_UP
- (nm_device_hw_is_up): let subclasses figure out their own HW state
- (nm_device_is_up): make static; only used locally
- (nm_device_hw_bring_up): update the hardware and IPv4 addresses even
if the device is already up; if the device isn't up, bring it up
- (nm_device_hw_take_down): just take down hardware
- (nm_device_bring_up): bring up HW first, then device specific stuff
- (nm_device_take_down): always deactivate device when called; always
try to take hardware down too
- (nm_device_state_changed): take device down when entering unmanaged
state from a higher state
* src/nm-device-802-11-wireless.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
- (real_take_down, supplicant_iface_state_cb_handler,
supplicant_iface_connection_state_cb_handler,
supplicant_mgr_state_cb_handler): fix some messages
* src/nm-device-802-3-ethernet.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3618 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-29 15:36:29 +00:00
|
|
|
{
|
|
|
|
|
guint32 tries = 0;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (NM_IS_DEVICE (self));
|
|
|
|
|
|
2013-06-13 15:13:58 -05:00
|
|
|
if (!nm_device_is_up (self))
|
2008-04-28 Dan Williams <dcbw@redhat.com>
Fix the device up/down ambiguities. Up/down state used to be a
conglomeration of hardware state (IFF_UP) and any device-specific things
(supplicant, periodic timers, etc) that the device used to indicate
readiness. Unfortunately, if the hardware was already IFF_UP for some
reason, then the device specific stuff wouldn't get run, and the device
would be stuck.
* src/nm-device.c
src/nm-device.h
- Create hw_is_up, hw_bring_up, and hw_take_down
- Rename bring_down -> take_down
- (real_hw_is_up): check interface flags for IFF_UP
- (nm_device_hw_is_up): let subclasses figure out their own HW state
- (nm_device_is_up): make static; only used locally
- (nm_device_hw_bring_up): update the hardware and IPv4 addresses even
if the device is already up; if the device isn't up, bring it up
- (nm_device_hw_take_down): just take down hardware
- (nm_device_bring_up): bring up HW first, then device specific stuff
- (nm_device_take_down): always deactivate device when called; always
try to take hardware down too
- (nm_device_state_changed): take device down when entering unmanaged
state from a higher state
* src/nm-device-802-11-wireless.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
- (real_take_down, supplicant_iface_state_cb_handler,
supplicant_iface_connection_state_cb_handler,
supplicant_mgr_state_cb_handler): fix some messages
* src/nm-device-802-3-ethernet.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3618 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-29 15:36:29 +00:00
|
|
|
return;
|
|
|
|
|
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_HW, "(%s): taking down device.", nm_device_get_iface (self));
|
2008-04-28 Dan Williams <dcbw@redhat.com>
Fix the device up/down ambiguities. Up/down state used to be a
conglomeration of hardware state (IFF_UP) and any device-specific things
(supplicant, periodic timers, etc) that the device used to indicate
readiness. Unfortunately, if the hardware was already IFF_UP for some
reason, then the device specific stuff wouldn't get run, and the device
would be stuck.
* src/nm-device.c
src/nm-device.h
- Create hw_is_up, hw_bring_up, and hw_take_down
- Rename bring_down -> take_down
- (real_hw_is_up): check interface flags for IFF_UP
- (nm_device_hw_is_up): let subclasses figure out their own HW state
- (nm_device_is_up): make static; only used locally
- (nm_device_hw_bring_up): update the hardware and IPv4 addresses even
if the device is already up; if the device isn't up, bring it up
- (nm_device_hw_take_down): just take down hardware
- (nm_device_bring_up): bring up HW first, then device specific stuff
- (nm_device_take_down): always deactivate device when called; always
try to take hardware down too
- (nm_device_state_changed): take device down when entering unmanaged
state from a higher state
* src/nm-device-802-11-wireless.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
- (real_take_down, supplicant_iface_state_cb_handler,
supplicant_iface_connection_state_cb_handler,
supplicant_mgr_state_cb_handler): fix some messages
* src/nm-device-802-3-ethernet.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3618 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-29 15:36:29 +00:00
|
|
|
|
2013-06-13 15:13:58 -05:00
|
|
|
if (NM_DEVICE_GET_CLASS (self)->take_down)
|
|
|
|
|
NM_DEVICE_GET_CLASS (self)->take_down (self);
|
2008-04-28 Dan Williams <dcbw@redhat.com>
Fix the device up/down ambiguities. Up/down state used to be a
conglomeration of hardware state (IFF_UP) and any device-specific things
(supplicant, periodic timers, etc) that the device used to indicate
readiness. Unfortunately, if the hardware was already IFF_UP for some
reason, then the device specific stuff wouldn't get run, and the device
would be stuck.
* src/nm-device.c
src/nm-device.h
- Create hw_is_up, hw_bring_up, and hw_take_down
- Rename bring_down -> take_down
- (real_hw_is_up): check interface flags for IFF_UP
- (nm_device_hw_is_up): let subclasses figure out their own HW state
- (nm_device_is_up): make static; only used locally
- (nm_device_hw_bring_up): update the hardware and IPv4 addresses even
if the device is already up; if the device isn't up, bring it up
- (nm_device_hw_take_down): just take down hardware
- (nm_device_bring_up): bring up HW first, then device specific stuff
- (nm_device_take_down): always deactivate device when called; always
try to take hardware down too
- (nm_device_state_changed): take device down when entering unmanaged
state from a higher state
* src/nm-device-802-11-wireless.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
- (real_take_down, supplicant_iface_state_cb_handler,
supplicant_iface_connection_state_cb_handler,
supplicant_mgr_state_cb_handler): fix some messages
* src/nm-device-802-3-ethernet.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3618 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-29 15:36:29 +00:00
|
|
|
|
|
|
|
|
/* Wait for the device to come up if requested */
|
2013-06-13 15:13:58 -05:00
|
|
|
while (block && nm_device_is_up (self) && (tries++ < 50))
|
2008-04-28 Dan Williams <dcbw@redhat.com>
Fix the device up/down ambiguities. Up/down state used to be a
conglomeration of hardware state (IFF_UP) and any device-specific things
(supplicant, periodic timers, etc) that the device used to indicate
readiness. Unfortunately, if the hardware was already IFF_UP for some
reason, then the device specific stuff wouldn't get run, and the device
would be stuck.
* src/nm-device.c
src/nm-device.h
- Create hw_is_up, hw_bring_up, and hw_take_down
- Rename bring_down -> take_down
- (real_hw_is_up): check interface flags for IFF_UP
- (nm_device_hw_is_up): let subclasses figure out their own HW state
- (nm_device_is_up): make static; only used locally
- (nm_device_hw_bring_up): update the hardware and IPv4 addresses even
if the device is already up; if the device isn't up, bring it up
- (nm_device_hw_take_down): just take down hardware
- (nm_device_bring_up): bring up HW first, then device specific stuff
- (nm_device_take_down): always deactivate device when called; always
try to take hardware down too
- (nm_device_state_changed): take device down when entering unmanaged
state from a higher state
* src/nm-device-802-11-wireless.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
- (real_take_down, supplicant_iface_state_cb_handler,
supplicant_iface_connection_state_cb_handler,
supplicant_mgr_state_cb_handler): fix some messages
* src/nm-device-802-3-ethernet.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3618 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-29 15:36:29 +00:00
|
|
|
g_usleep (200);
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-22 16:43:15 +01:00
|
|
|
static void
|
2013-06-13 15:13:58 -05:00
|
|
|
take_down (NMDevice *device)
|
2013-01-22 16:43:15 +01:00
|
|
|
{
|
2013-03-13 09:28:38 +01:00
|
|
|
int ifindex = nm_device_get_ip_ifindex (device);
|
|
|
|
|
|
2013-01-21 15:12:24 +01:00
|
|
|
if (ifindex)
|
|
|
|
|
nm_platform_link_set_down (ifindex);
|
2013-01-22 16:43:15 +01:00
|
|
|
}
|
|
|
|
|
|
2005-12-31 08:21:24 +00:00
|
|
|
static void
|
2009-07-07 14:34:01 -04:00
|
|
|
dispose (GObject *object)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
2007-02-05 12:14:09 +00:00
|
|
|
NMDevice *self = NM_DEVICE (object);
|
2009-07-07 14:34:01 -04:00
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
2013-06-13 15:13:58 -05:00
|
|
|
gboolean deconfigure = TRUE;
|
2013-04-04 10:20:24 -04:00
|
|
|
NMPlatform *platform;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2009-07-07 14:34:01 -04:00
|
|
|
if (priv->disposed || !priv->initialized)
|
2007-08-26 15:55:27 +00:00
|
|
|
goto out;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2009-07-07 14:34:01 -04:00
|
|
|
priv->disposed = TRUE;
|
2008-04-17 23:04:34 +00:00
|
|
|
|
2009-08-03 17:15:03 -04:00
|
|
|
/* Don't down can-assume-connection capable devices that are activated with
|
|
|
|
|
* a connection that can be assumed.
|
|
|
|
|
*/
|
2011-11-17 23:10:11 -06:00
|
|
|
if (nm_device_can_assume_connections (self) && (priv->state == NM_DEVICE_STATE_ACTIVATED)) {
|
2009-08-03 17:15:03 -04:00
|
|
|
NMConnection *connection;
|
2011-01-14 14:02:02 -06:00
|
|
|
NMSettingIP4Config *s_ip4 = NULL;
|
2009-08-03 17:15:03 -04:00
|
|
|
const char *method = NULL;
|
|
|
|
|
|
2011-12-05 12:27:49 +01:00
|
|
|
connection = nm_device_get_connection (self);
|
2010-07-16 17:45:48 -04:00
|
|
|
if (connection) {
|
2009-07-30 13:50:42 -04:00
|
|
|
/* Only static or DHCP IPv4 connections can be left up.
|
|
|
|
|
* All IPv6 connections can be left up, so we don't have
|
|
|
|
|
* to check that.
|
|
|
|
|
*/
|
2011-12-05 12:27:47 +01:00
|
|
|
s_ip4 = nm_connection_get_setting_ip4_config (connection);
|
2011-01-14 14:02:02 -06:00
|
|
|
if (s_ip4)
|
|
|
|
|
method = nm_setting_ip4_config_get_method (s_ip4);
|
2009-08-03 17:15:03 -04:00
|
|
|
if ( !method
|
|
|
|
|
|| !strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO)
|
2012-10-30 18:05:52 -05:00
|
|
|
|| !strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL)
|
|
|
|
|
|| !strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED))
|
2013-06-13 15:13:58 -05:00
|
|
|
deconfigure = FALSE;
|
2009-08-03 17:15:03 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-11 17:05:49 -05:00
|
|
|
ip_check_gw_ping_cleanup (self);
|
|
|
|
|
|
2011-12-08 11:46:58 -06:00
|
|
|
/* Clear any queued transitions */
|
2012-08-30 15:59:31 -05:00
|
|
|
nm_device_queued_state_clear (self);
|
2013-04-04 10:20:24 -04:00
|
|
|
nm_device_queued_ip_config_change_clear (self);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2010-01-13 17:59:54 -08:00
|
|
|
/* Clean up and stop DHCP */
|
2013-06-13 15:13:58 -05:00
|
|
|
dhcp4_cleanup (self, deconfigure, FALSE);
|
|
|
|
|
dhcp6_cleanup (self, deconfigure, FALSE);
|
2010-01-14 00:45:10 -08:00
|
|
|
addrconf6_cleanup (self);
|
|
|
|
|
dnsmasq_cleanup (self);
|
2010-01-13 17:59:54 -08:00
|
|
|
|
2012-11-14 14:05:30 -06:00
|
|
|
g_warn_if_fail (priv->slaves == NULL);
|
|
|
|
|
|
2010-01-14 00:45:10 -08:00
|
|
|
/* Take the device itself down and clear its IPv4 configuration */
|
2013-06-13 15:13:58 -05:00
|
|
|
if (nm_device_get_managed (self) && deconfigure) {
|
2008-10-11 19:57:45 +00:00
|
|
|
NMDeviceStateReason ignored = NM_DEVICE_STATE_REASON_NONE;
|
2008-07-11 10:28:53 +00:00
|
|
|
|
2013-06-12 10:48:03 -05:00
|
|
|
if (nm_device_get_act_request (self))
|
|
|
|
|
nm_device_deactivate (self, NM_DEVICE_STATE_REASON_REMOVED);
|
2013-06-26 00:16:45 +02:00
|
|
|
nm_device_set_ip4_config (self, NULL, TRUE, &ignored);
|
2013-06-12 10:48:03 -05:00
|
|
|
|
2013-06-13 15:13:58 -05:00
|
|
|
nm_device_take_down (self, FALSE);
|
2008-04-07 Dan Williams <dcbw@redhat.com>
* include/NetworkManager.h
- Remove the DOWN and CANCELLED device states
- Add UNMANAGED and UNAVAILABLE device states
- Document the device states
* introspection/nm-device.xml
src/nm-device-interface.c
src/nm-device-interface.h
- Add the 'managed' property
* test/nm-tool.c
- (detail_device): print out device state
* src/NetworkManagerSystem.h
src/backends/NetworkManagerArch.c
src/backends/NetworkManagerDebian.c
src/backends/NetworkManagerFrugalware.c
src/backends/NetworkManagerGentoo.c
src/backends/NetworkManagerMandriva.c
src/backends/NetworkManagerPaldo.c
src/backends/NetworkManagerRedHat.c
src/backends/NetworkManagerSlackware.c
src/backends/NetworkManagerSuSE.c
- (nm_system_device_get_system_config, nm_system_device_get_disabled
nm_system_device_free_system_config): remove; they were unused and
their functionality should be re-implemented in each distro's
system settings service plugin
* src/nm-gsm-device.c
src/nm-gsm-device.h
src/nm-cdma-device.c
src/nm-cdma-device.h
- (*_new): take the 'managed' argument
* src/nm-device.c
- (nm_device_set_address): remove, fold into nm_device_bring_up()
- (nm_device_init): start in unmanaged state, not disconnected
- (constructor): don't start device until the system settings service
has had a chance to figure out if the device is managed or not
- (nm_device_deactivate, nm_device_bring_up, nm_device_bring_down):
don't set device state here, let callers handle that as appropriate
- (nm_device_dispose): don't touch the device if it's not managed
- (set_property, get_property, nm_device_class_init): implement the
'managed' property
- (nm_device_state_changed): bring the device up if its now managed,
and deactivate it if it used to be active
- (nm_device_get_managed, nm_device_set_managed): do the right thing
with the managed state
* src/nm-hal-manager.c
- (wired_device_creator, wireless_device_creator, modem_device_creator):
take initial managed state and pass it along to device constructors
- (create_device_and_add_to_list): get managed state and pass to
type creators
* src/nm-device-802-11-wireless.c
- (real_can_activate): fold in most of
nm_device_802_11_wireless_can_activate()
- (can_scan): can't scan in UNAVAILABLE or UNMANAGED
- (link_timeout_cb): instead of deactivating, change device state and
let the device state handler to it
- (real_update_hw_address): clean up
- (state_changed_cb): when entering UNAVAILABLE state, schedule an idle
handler to transition to DISCONNECTED if the device isn't rfkilled
* src/nm-device-802-3-ethernet.c
- (set_carrier): move above callers and get rid of prototype
- (device_state_changed): when entering UNAVAILABLE state, schedule an
idle handler to transition to DISCONNECTED if the device has a
carrier
- (real_update_hw_address): clean up
- (link_timeout_cb, ppp_state_changed): change state instead of calling
deactivation directly as deactivation doesn't change state anymore
* src/NetworkManagerPolicy.c
- (schedule_activate_check): yay, remove wireless_enabled hack since
the NMManager and wireless devices work that out themselves now
- (device_state_changed): change to a switch and update for new device
states
- (device_carrier_changed): remove; device handles this now through
state changes
- (device_added): don't care about carrier any more; the initial
activation check will happen when the device transitions to
DISCONNECTED
* src/nm-manager.c
- (dispose): clear unmanaged devices
- (handle_unmanaged_devices): update unmanaged device list and toggle
the managed property on each device when needed
- (system_settings_properties_changed_cb): handle signals from the
system settings service
- (system_settings_get_unmanaged_devices_cb): handle callback from
getting the unmanaged device list method call
- (query_unmanaged_devices): ask the system settings service for its
list of unmanaged devices
- (nm_manager_name_owner_changed, initial_get_connections): get unmanaged
devices
- (manager_set_wireless_enabled): push rfkill state down to wireless
devices directly and let them handle the necessary state transitions
- (manager_device_state_changed): update for new device states
- (nm_manager_add_device): set initial rfkill state on wireless devices
- (nm_manager_remove_device): don't touch the device if it's unmanaged
- (nm_manager_activate_connection): return error if the device is
unmanaged
- (nm_manager_sleep): handle new device states correctly; don't change
the state of unavailable/unmanaged devices
* libnm-glib/nm-device-802-11-wireless.c
- (state_changed_cb): update for new device states
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3540 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 02:58:02 +00:00
|
|
|
}
|
2013-08-01 10:34:46 -05:00
|
|
|
g_clear_object (&priv->dev_ip4_config);
|
2013-08-01 15:44:53 -05:00
|
|
|
g_clear_object (&priv->ext_ip4_config);
|
2013-08-01 10:59:42 -05:00
|
|
|
g_clear_object (&priv->vpn4_config);
|
2013-08-01 10:34:46 -05:00
|
|
|
g_clear_object (&priv->ip4_config);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2013-08-01 10:59:42 -05:00
|
|
|
g_clear_object (&priv->ip6_config);
|
|
|
|
|
g_clear_object (&priv->ac_ip6_config);
|
|
|
|
|
g_clear_object (&priv->dhcp6_ip6_config);
|
|
|
|
|
g_clear_object (&priv->vpn6_config);
|
|
|
|
|
|
2013-08-07 11:41:40 +02:00
|
|
|
/* On dispose, do a final check whether we should delete_link */
|
|
|
|
|
delete_on_deactivate_check_and_schedule (self, nm_device_get_ip_ifindex (self));
|
|
|
|
|
|
2013-08-21 21:17:44 +02:00
|
|
|
/* Reset the saved RA value if the device is managed. */
|
|
|
|
|
if (priv->state > NM_DEVICE_STATE_UNMANAGED) {
|
|
|
|
|
/* reset the saved RA value */
|
|
|
|
|
if ( priv->ip6_accept_ra_path
|
|
|
|
|
&& g_file_test (priv->ip6_accept_ra_path, G_FILE_TEST_EXISTS)) {
|
|
|
|
|
nm_utils_do_sysctl (priv->ip6_accept_ra_path,
|
|
|
|
|
priv->ip6_accept_ra_save ? "1" : "0");
|
|
|
|
|
}
|
2010-06-30 13:37:34 -07:00
|
|
|
|
2013-08-21 21:17:44 +02:00
|
|
|
/* reset the saved use_tempaddr value */
|
|
|
|
|
if ( priv->ip6_privacy_tempaddr_path
|
|
|
|
|
&& g_file_test (priv->ip6_privacy_tempaddr_path, G_FILE_TEST_EXISTS)) {
|
|
|
|
|
char tmp[16];
|
2012-02-21 15:44:19 +01:00
|
|
|
|
2013-08-21 21:17:44 +02:00
|
|
|
snprintf (tmp, sizeof (tmp), "%d", priv->ip6_privacy_tempaddr_save);
|
|
|
|
|
nm_utils_do_sysctl (priv->ip6_privacy_tempaddr_path, tmp);
|
|
|
|
|
}
|
2012-02-21 15:44:19 +01:00
|
|
|
}
|
2013-08-21 21:17:44 +02:00
|
|
|
g_free (priv->ip6_accept_ra_path);
|
2012-02-21 15:44:19 +01:00
|
|
|
g_free (priv->ip6_privacy_tempaddr_path);
|
|
|
|
|
|
2013-05-07 10:23:44 -04:00
|
|
|
if (priv->carrier_defer_id) {
|
|
|
|
|
g_source_remove (priv->carrier_defer_id);
|
|
|
|
|
priv->carrier_defer_id = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-01 11:16:48 -06:00
|
|
|
if (priv->cp_added_id) {
|
|
|
|
|
g_signal_handler_disconnect (priv->con_provider, priv->cp_added_id);
|
|
|
|
|
priv->cp_added_id = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (priv->cp_loaded_id) {
|
|
|
|
|
g_signal_handler_disconnect (priv->con_provider, priv->cp_loaded_id);
|
|
|
|
|
priv->cp_loaded_id = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (priv->cp_removed_id) {
|
|
|
|
|
g_signal_handler_disconnect (priv->con_provider, priv->cp_removed_id);
|
|
|
|
|
priv->cp_removed_id = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (priv->cp_updated_id) {
|
|
|
|
|
g_signal_handler_disconnect (priv->con_provider, priv->cp_updated_id);
|
|
|
|
|
priv->cp_updated_id = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_hash_table_unref (priv->available_connections);
|
2013-08-05 17:15:07 -04:00
|
|
|
priv->available_connections = NULL;
|
2012-08-01 11:16:48 -06:00
|
|
|
|
2009-07-29 12:12:41 -04:00
|
|
|
activation_source_clear (self, TRUE, AF_INET);
|
|
|
|
|
activation_source_clear (self, TRUE, AF_INET6);
|
2006-12-28 22:13:59 +00:00
|
|
|
|
2010-01-14 00:45:10 -08:00
|
|
|
clear_act_request (self);
|
2008-05-29 20:58:52 +00:00
|
|
|
|
2013-04-04 10:20:24 -04:00
|
|
|
platform = nm_platform_get ();
|
|
|
|
|
g_signal_handlers_disconnect_by_func (platform, G_CALLBACK (device_ip_changed), self);
|
2013-04-25 15:46:39 -04:00
|
|
|
g_signal_handlers_disconnect_by_func (platform, G_CALLBACK (link_changed_cb), self);
|
2013-04-04 10:20:24 -04:00
|
|
|
|
2007-08-26 15:55:27 +00:00
|
|
|
out:
|
2007-02-05 12:14:09 +00:00
|
|
|
G_OBJECT_CLASS (nm_device_parent_class)->dispose (object);
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2009-07-07 14:34:01 -04:00
|
|
|
finalize (GObject *object)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
2007-02-05 12:14:09 +00:00
|
|
|
NMDevice *self = NM_DEVICE (object);
|
2009-07-07 14:34:01 -04:00
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2010-08-11 13:09:33 -05:00
|
|
|
if (priv->dhcp_manager)
|
|
|
|
|
g_object_unref (priv->dhcp_manager);
|
2010-01-13 17:59:54 -08:00
|
|
|
|
2011-10-07 15:58:08 +02:00
|
|
|
if (priv->fw_manager)
|
|
|
|
|
g_object_unref (priv->fw_manager);
|
|
|
|
|
|
2009-07-07 14:34:01 -04:00
|
|
|
g_free (priv->udi);
|
2013-02-24 18:08:38 +01:00
|
|
|
g_free (priv->path);
|
2009-07-07 14:34:01 -04:00
|
|
|
g_free (priv->iface);
|
|
|
|
|
g_free (priv->ip_iface);
|
|
|
|
|
g_free (priv->driver);
|
2012-06-01 16:48:57 +02:00
|
|
|
g_free (priv->driver_version);
|
|
|
|
|
g_free (priv->firmware_version);
|
2009-07-07 14:34:01 -04:00
|
|
|
g_free (priv->type_desc);
|
2009-07-15 13:53:49 -04:00
|
|
|
if (priv->dhcp_anycast_address)
|
|
|
|
|
g_byte_array_free (priv->dhcp_anycast_address, TRUE);
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
G_OBJECT_CLASS (nm_device_parent_class)->finalize (object);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
set_property (GObject *object, guint prop_id,
|
|
|
|
|
const GValue *value, GParamSpec *pspec)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (object);
|
2013-05-29 12:57:13 -03:00
|
|
|
NMPlatformLink *platform_device;
|
2013-05-01 09:28:16 -04:00
|
|
|
const char *hw_addr;
|
2007-02-05 12:14:09 +00:00
|
|
|
|
|
|
|
|
switch (prop_id) {
|
2013-05-29 12:57:13 -03:00
|
|
|
case PROP_PLATFORM_DEVICE:
|
|
|
|
|
platform_device = g_value_get_pointer (value);
|
|
|
|
|
if (platform_device) {
|
|
|
|
|
g_free (priv->udi);
|
|
|
|
|
priv->udi = g_strdup (platform_device->udi);
|
|
|
|
|
g_free (priv->iface);
|
|
|
|
|
priv->iface = g_strdup (platform_device->name);
|
|
|
|
|
priv->ifindex = platform_device->ifindex;
|
|
|
|
|
g_free (priv->driver);
|
|
|
|
|
priv->driver = g_strdup (platform_device->driver);
|
|
|
|
|
}
|
|
|
|
|
break;
|
2011-11-18 00:34:08 -06:00
|
|
|
case PROP_UDI:
|
2013-05-29 12:57:13 -03:00
|
|
|
if (g_value_get_string (value)) {
|
|
|
|
|
g_free (priv->udi);
|
|
|
|
|
priv->udi = g_value_dup_string (value);
|
|
|
|
|
}
|
2007-02-05 12:14:09 +00:00
|
|
|
break;
|
2011-11-18 00:34:08 -06:00
|
|
|
case PROP_IFACE:
|
2013-05-29 12:57:13 -03:00
|
|
|
if (g_value_get_string (value)) {
|
|
|
|
|
g_free (priv->iface);
|
|
|
|
|
priv->ifindex = 0;
|
|
|
|
|
priv->iface = g_value_dup_string (value);
|
|
|
|
|
|
|
|
|
|
/* Only look up the ifindex if it appears to be an actual kernel
|
|
|
|
|
* interface name. eg Bluetooth devices won't have one until we know
|
|
|
|
|
* the IP interface.
|
|
|
|
|
*/
|
|
|
|
|
if (priv->iface && !strchr (priv->iface, ':')) {
|
|
|
|
|
priv->ifindex = nm_platform_link_get_ifindex (priv->iface);
|
|
|
|
|
if (priv->ifindex <= 0)
|
|
|
|
|
nm_log_warn (LOGD_HW, "(%s): failed to look up interface index", priv->iface);
|
|
|
|
|
}
|
2010-04-21 14:58:25 -07:00
|
|
|
}
|
2007-02-05 12:14:09 +00:00
|
|
|
break;
|
2011-11-18 00:34:08 -06:00
|
|
|
case PROP_DRIVER:
|
2013-05-29 12:57:13 -03:00
|
|
|
if (g_value_get_string (value)) {
|
|
|
|
|
g_free (priv->driver);
|
|
|
|
|
priv->driver = g_value_dup_string (value);
|
|
|
|
|
}
|
2007-02-05 12:14:09 +00:00
|
|
|
break;
|
2012-06-01 16:48:57 +02:00
|
|
|
case PROP_DRIVER_VERSION:
|
|
|
|
|
g_free (priv->driver_version);
|
|
|
|
|
priv->driver_version = g_strdup (g_value_get_string (value));
|
|
|
|
|
break;
|
|
|
|
|
case PROP_FIRMWARE_VERSION:
|
|
|
|
|
g_free (priv->firmware_version);
|
|
|
|
|
priv->firmware_version = g_strdup (g_value_get_string (value));
|
|
|
|
|
break;
|
2011-11-18 00:34:08 -06:00
|
|
|
case PROP_IP4_ADDRESS:
|
2007-02-05 12:14:09 +00:00
|
|
|
priv->ip4_address = g_value_get_uint (value);
|
|
|
|
|
break;
|
2012-05-14 15:32:54 +02:00
|
|
|
case PROP_AUTOCONNECT:
|
|
|
|
|
priv->autoconnect = g_value_get_boolean (value);
|
|
|
|
|
break;
|
2011-11-18 00:34:08 -06:00
|
|
|
case PROP_FIRMWARE_MISSING:
|
2010-05-25 10:52:25 -07:00
|
|
|
priv->firmware_missing = g_value_get_boolean (value);
|
|
|
|
|
break;
|
2011-11-18 00:34:08 -06:00
|
|
|
case PROP_DEVICE_TYPE:
|
2009-07-07 22:25:58 -04:00
|
|
|
g_return_if_fail (priv->type == NM_DEVICE_TYPE_UNKNOWN);
|
|
|
|
|
priv->type = g_value_get_uint (value);
|
|
|
|
|
break;
|
2011-11-18 00:34:08 -06:00
|
|
|
case PROP_TYPE_DESC:
|
2009-07-07 14:24:12 -04:00
|
|
|
g_free (priv->type_desc);
|
|
|
|
|
priv->type_desc = g_value_dup_string (value);
|
|
|
|
|
break;
|
2011-11-18 00:34:08 -06:00
|
|
|
case PROP_RFKILL_TYPE:
|
2010-03-25 11:36:19 -07:00
|
|
|
priv->rfkill_type = g_value_get_uint (value);
|
|
|
|
|
break;
|
2013-01-24 17:47:59 -06:00
|
|
|
case PROP_IS_MASTER:
|
|
|
|
|
priv->is_master = g_value_get_boolean (value);
|
|
|
|
|
break;
|
2013-05-01 09:28:16 -04:00
|
|
|
case PROP_HW_ADDRESS:
|
2013-07-19 12:05:19 -05:00
|
|
|
priv->hw_addr_len = nm_device_get_hw_address_length (NM_DEVICE (object), NULL);
|
2013-05-01 09:28:16 -04:00
|
|
|
|
|
|
|
|
hw_addr = g_value_get_string (value);
|
|
|
|
|
if (!hw_addr)
|
|
|
|
|
break;
|
|
|
|
|
if (priv->hw_addr_len == 0) {
|
|
|
|
|
g_warn_if_fail (*hw_addr == '\0');
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-05 17:41:11 -03:00
|
|
|
if (!nm_utils_hwaddr_aton_len (hw_addr, priv->hw_addr, priv->hw_addr_len)) {
|
2013-05-01 09:28:16 -04:00
|
|
|
g_warning ("Could not parse hw-address '%s'", hw_addr);
|
|
|
|
|
memset (priv->hw_addr, 0, sizeof (priv->hw_addr));
|
|
|
|
|
}
|
|
|
|
|
break;
|
2007-02-05 12:14:09 +00:00
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-17 13:39:31 -05:00
|
|
|
static gboolean
|
2013-04-04 10:20:24 -04:00
|
|
|
has_ip_config (NMDevice *self)
|
2011-03-17 13:39:31 -05:00
|
|
|
{
|
2013-04-04 10:20:24 -04:00
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
|
2013-06-27 17:51:24 +02:00
|
|
|
if (priv->ip4_state != IP_DONE && priv->ip6_state != IP_DONE)
|
2013-04-04 10:20:24 -04:00
|
|
|
return FALSE;
|
|
|
|
|
|
2013-06-28 21:05:20 +02:00
|
|
|
if (priv->state == NM_DEVICE_STATE_UNMANAGED)
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
return (priv->state >= NM_DEVICE_STATE_IP_CONFIG
|
|
|
|
|
&& priv->state <= NM_DEVICE_STATE_DEACTIVATING);
|
2011-03-17 13:39:31 -05:00
|
|
|
}
|
|
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
static void
|
|
|
|
|
get_property (GObject *object, guint prop_id,
|
|
|
|
|
GValue *value, GParamSpec *pspec)
|
|
|
|
|
{
|
2008-07-17 17:04:13 +00:00
|
|
|
NMDevice *self = NM_DEVICE (object);
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
2011-05-26 18:27:01 -05:00
|
|
|
const char *ac_path = NULL;
|
2012-08-01 11:16:48 -06:00
|
|
|
GPtrArray *array;
|
|
|
|
|
GHashTableIter iter;
|
|
|
|
|
NMConnection *connection;
|
2007-02-05 12:14:09 +00:00
|
|
|
|
|
|
|
|
switch (prop_id) {
|
2011-11-18 00:34:08 -06:00
|
|
|
case PROP_UDI:
|
2007-02-05 12:14:09 +00:00
|
|
|
g_value_set_string (value, priv->udi);
|
|
|
|
|
break;
|
2011-11-18 00:34:08 -06:00
|
|
|
case PROP_IFACE:
|
2007-02-05 12:14:09 +00:00
|
|
|
g_value_set_string (value, priv->iface);
|
|
|
|
|
break;
|
2011-11-18 00:34:08 -06:00
|
|
|
case PROP_IP_IFACE:
|
2013-04-04 10:20:24 -04:00
|
|
|
if (has_ip_config (self))
|
2010-06-10 10:16:39 -07:00
|
|
|
g_value_set_string (value, nm_device_get_ip_iface (self));
|
|
|
|
|
else
|
|
|
|
|
g_value_set_string (value, NULL);
|
|
|
|
|
break;
|
2011-11-18 00:34:08 -06:00
|
|
|
case PROP_IFINDEX:
|
2010-04-21 14:58:25 -07:00
|
|
|
g_value_set_int (value, priv->ifindex);
|
|
|
|
|
break;
|
2011-11-18 00:34:08 -06:00
|
|
|
case PROP_DRIVER:
|
2007-02-05 12:14:09 +00:00
|
|
|
g_value_set_string (value, priv->driver);
|
|
|
|
|
break;
|
2012-06-01 16:48:57 +02:00
|
|
|
case PROP_DRIVER_VERSION:
|
|
|
|
|
g_value_set_string (value, priv->driver_version);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_FIRMWARE_VERSION:
|
|
|
|
|
g_value_set_string (value, priv->firmware_version);
|
|
|
|
|
break;
|
2011-11-18 00:34:08 -06:00
|
|
|
case PROP_CAPABILITIES:
|
2013-05-07 10:23:44 -04:00
|
|
|
g_value_set_uint (value, (priv->capabilities & ~NM_DEVICE_CAP_INTERNAL_MASK));
|
2007-02-05 12:14:09 +00:00
|
|
|
break;
|
2011-11-18 00:34:08 -06:00
|
|
|
case PROP_IP4_ADDRESS:
|
2007-02-05 12:14:09 +00:00
|
|
|
g_value_set_uint (value, priv->ip4_address);
|
|
|
|
|
break;
|
2013-05-07 10:23:44 -04:00
|
|
|
case PROP_CARRIER:
|
|
|
|
|
g_value_set_boolean (value, priv->carrier);
|
|
|
|
|
break;
|
2011-11-18 00:34:08 -06:00
|
|
|
case PROP_IP4_CONFIG:
|
2013-04-04 10:20:24 -04:00
|
|
|
if (has_ip_config (self) && priv->ip4_config)
|
2011-03-17 13:39:31 -05:00
|
|
|
g_value_set_boxed (value, nm_ip4_config_get_dbus_path (priv->ip4_config));
|
|
|
|
|
else
|
|
|
|
|
g_value_set_boxed (value, "/");
|
2007-02-16 11:23:49 +00:00
|
|
|
break;
|
2011-11-18 00:34:08 -06:00
|
|
|
case PROP_DHCP4_CONFIG:
|
2013-04-04 10:20:24 -04:00
|
|
|
if (has_ip_config (self) && priv->dhcp4_client)
|
2008-08-07 15:26:32 +00:00
|
|
|
g_value_set_boxed (value, nm_dhcp4_config_get_dbus_path (priv->dhcp4_config));
|
2008-07-17 17:04:13 +00:00
|
|
|
else
|
2008-08-07 15:26:32 +00:00
|
|
|
g_value_set_boxed (value, "/");
|
2008-07-17 17:04:13 +00:00
|
|
|
break;
|
2011-11-18 00:34:08 -06:00
|
|
|
case PROP_IP6_CONFIG:
|
2013-04-04 10:20:24 -04:00
|
|
|
if (has_ip_config (self) && priv->ip6_config)
|
2011-03-17 13:39:31 -05:00
|
|
|
g_value_set_boxed (value, nm_ip6_config_get_dbus_path (priv->ip6_config));
|
|
|
|
|
else
|
|
|
|
|
g_value_set_boxed (value, "/");
|
2009-07-29 12:12:41 -04:00
|
|
|
break;
|
2011-11-18 00:34:08 -06:00
|
|
|
case PROP_DHCP6_CONFIG:
|
2013-04-04 10:20:24 -04:00
|
|
|
if (has_ip_config (self) && priv->dhcp6_client)
|
2010-01-14 00:45:10 -08:00
|
|
|
g_value_set_boxed (value, nm_dhcp6_config_get_dbus_path (priv->dhcp6_config));
|
|
|
|
|
else
|
|
|
|
|
g_value_set_boxed (value, "/");
|
|
|
|
|
break;
|
2011-11-18 00:34:08 -06:00
|
|
|
case PROP_STATE:
|
2007-02-05 12:14:09 +00:00
|
|
|
g_value_set_uint (value, priv->state);
|
|
|
|
|
break;
|
2012-01-29 22:40:37 +01:00
|
|
|
case PROP_STATE_REASON:
|
2013-03-07 17:24:05 -06:00
|
|
|
g_value_take_boxed (value, dbus_g_type_specialized_construct (DBUS_G_TYPE_UINT_STRUCT));
|
2012-01-29 22:40:37 +01:00
|
|
|
dbus_g_type_struct_set (value,
|
|
|
|
|
0, priv->state,
|
|
|
|
|
1, priv->state_reason,
|
|
|
|
|
G_MAXUINT);
|
|
|
|
|
break;
|
2011-11-18 00:34:08 -06:00
|
|
|
case PROP_ACTIVE_CONNECTION:
|
2011-05-26 18:27:01 -05:00
|
|
|
if (priv->act_request)
|
2012-02-03 14:53:09 -06:00
|
|
|
ac_path = nm_active_connection_get_path (NM_ACTIVE_CONNECTION (priv->act_request));
|
2011-05-26 18:27:01 -05:00
|
|
|
g_value_set_boxed (value, ac_path ? ac_path : "/");
|
|
|
|
|
break;
|
2011-11-18 00:34:08 -06:00
|
|
|
case PROP_DEVICE_TYPE:
|
2007-02-05 12:14:09 +00:00
|
|
|
g_value_set_uint (value, priv->type);
|
|
|
|
|
break;
|
2011-11-18 00:34:08 -06:00
|
|
|
case PROP_MANAGED:
|
2013-04-24 10:40:58 -04:00
|
|
|
g_value_set_boolean (value, nm_device_get_managed (self));
|
2008-04-07 Dan Williams <dcbw@redhat.com>
* include/NetworkManager.h
- Remove the DOWN and CANCELLED device states
- Add UNMANAGED and UNAVAILABLE device states
- Document the device states
* introspection/nm-device.xml
src/nm-device-interface.c
src/nm-device-interface.h
- Add the 'managed' property
* test/nm-tool.c
- (detail_device): print out device state
* src/NetworkManagerSystem.h
src/backends/NetworkManagerArch.c
src/backends/NetworkManagerDebian.c
src/backends/NetworkManagerFrugalware.c
src/backends/NetworkManagerGentoo.c
src/backends/NetworkManagerMandriva.c
src/backends/NetworkManagerPaldo.c
src/backends/NetworkManagerRedHat.c
src/backends/NetworkManagerSlackware.c
src/backends/NetworkManagerSuSE.c
- (nm_system_device_get_system_config, nm_system_device_get_disabled
nm_system_device_free_system_config): remove; they were unused and
their functionality should be re-implemented in each distro's
system settings service plugin
* src/nm-gsm-device.c
src/nm-gsm-device.h
src/nm-cdma-device.c
src/nm-cdma-device.h
- (*_new): take the 'managed' argument
* src/nm-device.c
- (nm_device_set_address): remove, fold into nm_device_bring_up()
- (nm_device_init): start in unmanaged state, not disconnected
- (constructor): don't start device until the system settings service
has had a chance to figure out if the device is managed or not
- (nm_device_deactivate, nm_device_bring_up, nm_device_bring_down):
don't set device state here, let callers handle that as appropriate
- (nm_device_dispose): don't touch the device if it's not managed
- (set_property, get_property, nm_device_class_init): implement the
'managed' property
- (nm_device_state_changed): bring the device up if its now managed,
and deactivate it if it used to be active
- (nm_device_get_managed, nm_device_set_managed): do the right thing
with the managed state
* src/nm-hal-manager.c
- (wired_device_creator, wireless_device_creator, modem_device_creator):
take initial managed state and pass it along to device constructors
- (create_device_and_add_to_list): get managed state and pass to
type creators
* src/nm-device-802-11-wireless.c
- (real_can_activate): fold in most of
nm_device_802_11_wireless_can_activate()
- (can_scan): can't scan in UNAVAILABLE or UNMANAGED
- (link_timeout_cb): instead of deactivating, change device state and
let the device state handler to it
- (real_update_hw_address): clean up
- (state_changed_cb): when entering UNAVAILABLE state, schedule an idle
handler to transition to DISCONNECTED if the device isn't rfkilled
* src/nm-device-802-3-ethernet.c
- (set_carrier): move above callers and get rid of prototype
- (device_state_changed): when entering UNAVAILABLE state, schedule an
idle handler to transition to DISCONNECTED if the device has a
carrier
- (real_update_hw_address): clean up
- (link_timeout_cb, ppp_state_changed): change state instead of calling
deactivation directly as deactivation doesn't change state anymore
* src/NetworkManagerPolicy.c
- (schedule_activate_check): yay, remove wireless_enabled hack since
the NMManager and wireless devices work that out themselves now
- (device_state_changed): change to a switch and update for new device
states
- (device_carrier_changed): remove; device handles this now through
state changes
- (device_added): don't care about carrier any more; the initial
activation check will happen when the device transitions to
DISCONNECTED
* src/nm-manager.c
- (dispose): clear unmanaged devices
- (handle_unmanaged_devices): update unmanaged device list and toggle
the managed property on each device when needed
- (system_settings_properties_changed_cb): handle signals from the
system settings service
- (system_settings_get_unmanaged_devices_cb): handle callback from
getting the unmanaged device list method call
- (query_unmanaged_devices): ask the system settings service for its
list of unmanaged devices
- (nm_manager_name_owner_changed, initial_get_connections): get unmanaged
devices
- (manager_set_wireless_enabled): push rfkill state down to wireless
devices directly and let them handle the necessary state transitions
- (manager_device_state_changed): update for new device states
- (nm_manager_add_device): set initial rfkill state on wireless devices
- (nm_manager_remove_device): don't touch the device if it's unmanaged
- (nm_manager_activate_connection): return error if the device is
unmanaged
- (nm_manager_sleep): handle new device states correctly; don't change
the state of unavailable/unmanaged devices
* libnm-glib/nm-device-802-11-wireless.c
- (state_changed_cb): update for new device states
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3540 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 02:58:02 +00:00
|
|
|
break;
|
2012-05-14 15:32:54 +02:00
|
|
|
case PROP_AUTOCONNECT:
|
|
|
|
|
g_value_set_boolean (value, priv->autoconnect);
|
|
|
|
|
break;
|
2011-11-18 00:34:08 -06:00
|
|
|
case PROP_FIRMWARE_MISSING:
|
2010-05-25 10:52:25 -07:00
|
|
|
g_value_set_boolean (value, priv->firmware_missing);
|
|
|
|
|
break;
|
2011-11-18 00:34:08 -06:00
|
|
|
case PROP_TYPE_DESC:
|
2009-07-07 14:24:12 -04:00
|
|
|
g_value_set_string (value, priv->type_desc);
|
|
|
|
|
break;
|
2011-11-18 00:34:08 -06:00
|
|
|
case PROP_RFKILL_TYPE:
|
2010-03-25 11:36:19 -07:00
|
|
|
g_value_set_uint (value, priv->rfkill_type);
|
|
|
|
|
break;
|
2012-08-01 11:16:48 -06:00
|
|
|
case PROP_AVAILABLE_CONNECTIONS:
|
|
|
|
|
array = g_ptr_array_sized_new (g_hash_table_size (priv->available_connections));
|
|
|
|
|
g_hash_table_iter_init (&iter, priv->available_connections);
|
|
|
|
|
while (g_hash_table_iter_next (&iter, (gpointer) &connection, NULL))
|
|
|
|
|
g_ptr_array_add (array, g_strdup (nm_connection_get_path (connection)));
|
|
|
|
|
g_value_take_boxed (value, array);
|
|
|
|
|
break;
|
2013-01-24 17:47:59 -06:00
|
|
|
case PROP_IS_MASTER:
|
|
|
|
|
g_value_set_boolean (value, priv->is_master);
|
|
|
|
|
break;
|
2013-05-01 09:28:16 -04:00
|
|
|
case PROP_HW_ADDRESS:
|
|
|
|
|
if (priv->hw_addr_len)
|
2013-06-05 17:41:11 -03:00
|
|
|
g_value_take_string (value, nm_utils_hwaddr_ntoa_len (priv->hw_addr, priv->hw_addr_len));
|
2013-05-01 09:28:16 -04:00
|
|
|
else
|
|
|
|
|
g_value_set_string (value, NULL);
|
|
|
|
|
break;
|
2013-08-13 17:45:34 -04:00
|
|
|
case PROP_HAS_PENDING_ACTION:
|
|
|
|
|
g_value_set_boolean (value, nm_device_has_pending_action (self));
|
|
|
|
|
break;
|
2007-02-05 12:14:09 +00:00
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
nm_device_class_init (NMDeviceClass *klass)
|
|
|
|
|
{
|
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
g_type_class_add_private (object_class, sizeof (NMDevicePrivate));
|
|
|
|
|
|
|
|
|
|
/* Virtual methods */
|
2009-07-07 14:34:01 -04:00
|
|
|
object_class->dispose = dispose;
|
|
|
|
|
object_class->finalize = finalize;
|
2007-02-05 12:14:09 +00:00
|
|
|
object_class->set_property = set_property;
|
|
|
|
|
object_class->get_property = get_property;
|
|
|
|
|
object_class->constructor = constructor;
|
2011-10-14 10:13:49 -04:00
|
|
|
object_class->constructed = constructed;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2013-07-27 10:41:44 +02:00
|
|
|
klass->link_changed = link_changed;
|
|
|
|
|
|
2013-05-07 10:23:44 -04:00
|
|
|
klass->is_available = is_available;
|
2012-09-27 12:12:15 -04:00
|
|
|
klass->act_stage1_prepare = act_stage1_prepare;
|
|
|
|
|
klass->act_stage2_config = act_stage2_config;
|
|
|
|
|
klass->act_stage3_ip4_config_start = act_stage3_ip4_config_start;
|
|
|
|
|
klass->act_stage3_ip6_config_start = act_stage3_ip6_config_start;
|
|
|
|
|
klass->act_stage4_ip4_config_timeout = act_stage4_ip4_config_timeout;
|
|
|
|
|
klass->act_stage4_ip6_config_timeout = act_stage4_ip6_config_timeout;
|
2013-01-25 11:59:05 -06:00
|
|
|
klass->have_any_ready_slaves = have_any_ready_slaves;
|
|
|
|
|
|
2013-02-12 17:59:37 -05:00
|
|
|
klass->spec_match_list = spec_match_list;
|
2013-03-06 16:16:54 -05:00
|
|
|
klass->can_auto_connect = can_auto_connect;
|
2013-03-07 07:44:36 -05:00
|
|
|
klass->check_connection_compatible = check_connection_compatible;
|
2012-09-27 12:12:15 -04:00
|
|
|
klass->check_connection_available = check_connection_available;
|
2013-06-13 15:13:58 -05:00
|
|
|
klass->is_up = is_up;
|
|
|
|
|
klass->bring_up = bring_up;
|
|
|
|
|
klass->take_down = take_down;
|
2013-05-07 10:23:44 -04:00
|
|
|
klass->carrier_changed = carrier_changed;
|
|
|
|
|
klass->can_interrupt_activation = can_interrupt_activation;
|
2013-06-05 17:41:57 -03:00
|
|
|
klass->get_hw_address_length = get_hw_address_length;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
/* Properties */
|
2013-05-29 12:57:13 -03:00
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_PLATFORM_DEVICE,
|
|
|
|
|
g_param_spec_pointer (NM_DEVICE_PLATFORM_DEVICE,
|
|
|
|
|
"Platform Device",
|
|
|
|
|
"NMPlatform device object",
|
|
|
|
|
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
|
|
2011-11-18 00:34:08 -06:00
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_UDI,
|
|
|
|
|
g_param_spec_string (NM_DEVICE_UDI,
|
|
|
|
|
"UDI",
|
|
|
|
|
"Unique Device Identifier",
|
|
|
|
|
NULL,
|
2012-02-10 13:25:39 -06:00
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
|
2011-11-18 00:34:08 -06:00
|
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_IFACE,
|
|
|
|
|
g_param_spec_string (NM_DEVICE_IFACE,
|
|
|
|
|
"Interface",
|
|
|
|
|
"Interface",
|
|
|
|
|
NULL,
|
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_IP_IFACE,
|
|
|
|
|
g_param_spec_string (NM_DEVICE_IP_IFACE,
|
|
|
|
|
"IP Interface",
|
|
|
|
|
"IP Interface",
|
|
|
|
|
NULL,
|
2013-06-06 08:45:49 -03:00
|
|
|
G_PARAM_READABLE));
|
2011-11-18 00:34:08 -06:00
|
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_DRIVER,
|
|
|
|
|
g_param_spec_string (NM_DEVICE_DRIVER,
|
|
|
|
|
"Driver",
|
|
|
|
|
"Driver",
|
|
|
|
|
NULL,
|
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
|
|
2012-06-01 16:48:57 +02:00
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_DRIVER_VERSION,
|
|
|
|
|
g_param_spec_string (NM_DEVICE_DRIVER_VERSION,
|
|
|
|
|
"Driver Version",
|
|
|
|
|
"Driver Version",
|
|
|
|
|
NULL,
|
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_FIRMWARE_VERSION,
|
|
|
|
|
g_param_spec_string (NM_DEVICE_FIRMWARE_VERSION,
|
|
|
|
|
"Firmware Version",
|
|
|
|
|
"Firmware Version",
|
|
|
|
|
NULL,
|
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
|
|
2011-11-18 00:34:08 -06:00
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_CAPABILITIES,
|
|
|
|
|
g_param_spec_uint (NM_DEVICE_CAPABILITIES,
|
|
|
|
|
"Capabilities",
|
|
|
|
|
"Capabilities",
|
|
|
|
|
0, G_MAXUINT32, NM_DEVICE_CAP_NONE,
|
2013-05-17 10:58:38 -05:00
|
|
|
G_PARAM_READABLE));
|
2011-11-18 00:34:08 -06:00
|
|
|
|
2013-05-07 10:23:44 -04:00
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_CARRIER,
|
|
|
|
|
g_param_spec_boolean (NM_DEVICE_CARRIER,
|
|
|
|
|
"Carrier",
|
|
|
|
|
"Carrier",
|
|
|
|
|
FALSE,
|
|
|
|
|
G_PARAM_READABLE));
|
|
|
|
|
|
2011-11-18 00:34:08 -06:00
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_IP4_ADDRESS,
|
|
|
|
|
g_param_spec_uint (NM_DEVICE_IP4_ADDRESS,
|
|
|
|
|
"IP4 address",
|
|
|
|
|
"IP4 address",
|
|
|
|
|
0, G_MAXUINT32, 0, /* FIXME */
|
|
|
|
|
G_PARAM_READWRITE));
|
|
|
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_IP4_CONFIG,
|
|
|
|
|
g_param_spec_boxed (NM_DEVICE_IP4_CONFIG,
|
|
|
|
|
"IP4 Config",
|
|
|
|
|
"IP4 Config",
|
|
|
|
|
DBUS_TYPE_G_OBJECT_PATH,
|
|
|
|
|
G_PARAM_READWRITE));
|
|
|
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_DHCP4_CONFIG,
|
|
|
|
|
g_param_spec_boxed (NM_DEVICE_DHCP4_CONFIG,
|
|
|
|
|
"DHCP4 Config",
|
|
|
|
|
"DHCP4 Config",
|
|
|
|
|
DBUS_TYPE_G_OBJECT_PATH,
|
|
|
|
|
G_PARAM_READWRITE));
|
|
|
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_IP6_CONFIG,
|
|
|
|
|
g_param_spec_boxed (NM_DEVICE_IP6_CONFIG,
|
|
|
|
|
"IP6 Config",
|
|
|
|
|
"IP6 Config",
|
|
|
|
|
DBUS_TYPE_G_OBJECT_PATH,
|
|
|
|
|
G_PARAM_READWRITE));
|
|
|
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_DHCP6_CONFIG,
|
|
|
|
|
g_param_spec_boxed (NM_DEVICE_DHCP6_CONFIG,
|
|
|
|
|
"DHCP6 Config",
|
|
|
|
|
"DHCP6 Config",
|
|
|
|
|
DBUS_TYPE_G_OBJECT_PATH,
|
|
|
|
|
G_PARAM_READWRITE));
|
|
|
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_STATE,
|
|
|
|
|
g_param_spec_uint (NM_DEVICE_STATE,
|
|
|
|
|
"State",
|
|
|
|
|
"State",
|
|
|
|
|
0, G_MAXUINT32, NM_DEVICE_STATE_UNKNOWN,
|
|
|
|
|
G_PARAM_READABLE));
|
2012-01-29 22:40:37 +01:00
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_STATE_REASON,
|
|
|
|
|
g_param_spec_boxed (NM_DEVICE_STATE_REASON,
|
|
|
|
|
"StateReason",
|
|
|
|
|
"StateReason",
|
|
|
|
|
DBUS_G_TYPE_UINT_STRUCT,
|
|
|
|
|
G_PARAM_READABLE));
|
2011-11-18 00:34:08 -06:00
|
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_ACTIVE_CONNECTION,
|
|
|
|
|
g_param_spec_boxed (NM_DEVICE_ACTIVE_CONNECTION,
|
|
|
|
|
"ActiveConnection",
|
|
|
|
|
"ActiveConnection",
|
|
|
|
|
DBUS_TYPE_G_OBJECT_PATH,
|
|
|
|
|
G_PARAM_READABLE));
|
|
|
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_DEVICE_TYPE,
|
|
|
|
|
g_param_spec_uint (NM_DEVICE_DEVICE_TYPE,
|
|
|
|
|
"DeviceType",
|
|
|
|
|
"DeviceType",
|
|
|
|
|
0, G_MAXUINT32, NM_DEVICE_TYPE_UNKNOWN,
|
2013-05-07 12:18:41 -04:00
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
2011-11-18 00:34:08 -06:00
|
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_MANAGED,
|
|
|
|
|
g_param_spec_boolean (NM_DEVICE_MANAGED,
|
|
|
|
|
"Managed",
|
|
|
|
|
"Managed",
|
|
|
|
|
FALSE,
|
2013-04-24 10:40:58 -04:00
|
|
|
G_PARAM_READABLE));
|
2011-11-18 00:34:08 -06:00
|
|
|
|
2012-05-14 15:32:54 +02:00
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_AUTOCONNECT,
|
|
|
|
|
g_param_spec_boolean (NM_DEVICE_AUTOCONNECT,
|
|
|
|
|
"Autoconnect",
|
|
|
|
|
"Autoconnect",
|
2012-05-23 13:07:58 +02:00
|
|
|
DEFAULT_AUTOCONNECT,
|
2012-05-14 15:32:54 +02:00
|
|
|
G_PARAM_READWRITE));
|
|
|
|
|
|
2011-11-18 00:34:08 -06:00
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_FIRMWARE_MISSING,
|
|
|
|
|
g_param_spec_boolean (NM_DEVICE_FIRMWARE_MISSING,
|
|
|
|
|
"FirmwareMissing",
|
|
|
|
|
"Firmware missing",
|
|
|
|
|
FALSE,
|
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_TYPE_DESC,
|
|
|
|
|
g_param_spec_string (NM_DEVICE_TYPE_DESC,
|
|
|
|
|
"Type Description",
|
|
|
|
|
"Device type description",
|
|
|
|
|
NULL,
|
2013-05-07 12:18:41 -04:00
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
2011-11-18 00:34:08 -06:00
|
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_RFKILL_TYPE,
|
|
|
|
|
g_param_spec_uint (NM_DEVICE_RFKILL_TYPE,
|
|
|
|
|
"Rfkill Type",
|
|
|
|
|
"Type of rfkill switch (if any) supported by this device",
|
|
|
|
|
RFKILL_TYPE_WLAN,
|
|
|
|
|
RFKILL_TYPE_MAX,
|
|
|
|
|
RFKILL_TYPE_UNKNOWN,
|
2013-05-07 12:18:41 -04:00
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
2011-11-18 00:34:08 -06:00
|
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_IFINDEX,
|
|
|
|
|
g_param_spec_int (NM_DEVICE_IFINDEX,
|
|
|
|
|
"Ifindex",
|
|
|
|
|
"Ifindex",
|
|
|
|
|
0, G_MAXINT, 0,
|
2013-05-07 12:18:41 -04:00
|
|
|
G_PARAM_READABLE));
|
2011-11-18 00:34:08 -06:00
|
|
|
|
2012-08-01 11:16:48 -06:00
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_AVAILABLE_CONNECTIONS,
|
|
|
|
|
g_param_spec_boxed (NM_DEVICE_AVAILABLE_CONNECTIONS,
|
|
|
|
|
"AvailableConnections",
|
|
|
|
|
"AvailableConnections",
|
|
|
|
|
DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH,
|
|
|
|
|
G_PARAM_READABLE));
|
|
|
|
|
|
2013-01-24 17:47:59 -06:00
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_IS_MASTER,
|
|
|
|
|
g_param_spec_boolean (NM_DEVICE_IS_MASTER,
|
|
|
|
|
"IsMaster",
|
|
|
|
|
"IsMaster",
|
|
|
|
|
FALSE,
|
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
|
|
2013-05-01 09:28:16 -04:00
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_HW_ADDRESS,
|
|
|
|
|
g_param_spec_string (NM_DEVICE_HW_ADDRESS,
|
|
|
|
|
"Hardware Address",
|
|
|
|
|
"Hardware address",
|
|
|
|
|
NULL,
|
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
|
|
2013-08-13 17:45:34 -04:00
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_HAS_PENDING_ACTION,
|
|
|
|
|
g_param_spec_boolean (NM_DEVICE_HAS_PENDING_ACTION,
|
|
|
|
|
"Has pending action",
|
|
|
|
|
"Has pending action",
|
|
|
|
|
FALSE,
|
|
|
|
|
G_PARAM_READABLE));
|
|
|
|
|
|
2011-11-18 00:34:08 -06:00
|
|
|
/* Signals */
|
2011-11-18 00:09:37 -06:00
|
|
|
signals[STATE_CHANGED] =
|
|
|
|
|
g_signal_new ("state-changed",
|
|
|
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
2012-09-27 12:38:59 -04:00
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
|
G_STRUCT_OFFSET (NMDeviceClass, state_changed),
|
2013-05-06 13:37:25 -04:00
|
|
|
NULL, NULL, NULL,
|
2011-11-18 00:09:37 -06:00
|
|
|
G_TYPE_NONE, 3,
|
|
|
|
|
G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT);
|
|
|
|
|
|
2009-07-15 17:22:10 -04:00
|
|
|
signals[AUTOCONNECT_ALLOWED] =
|
|
|
|
|
g_signal_new ("autoconnect-allowed",
|
|
|
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
|
0,
|
2013-05-06 13:37:25 -04:00
|
|
|
autoconnect_allowed_accumulator, NULL, NULL,
|
2009-07-15 17:22:10 -04:00
|
|
|
G_TYPE_BOOLEAN, 0);
|
2011-11-18 00:05:37 -06:00
|
|
|
|
2012-06-01 15:27:39 -05:00
|
|
|
signals[AUTH_REQUEST] =
|
|
|
|
|
g_signal_new (NM_DEVICE_AUTH_REQUEST,
|
|
|
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
2013-05-06 13:37:25 -04:00
|
|
|
0, NULL, NULL, NULL,
|
2012-06-01 15:27:39 -05:00
|
|
|
/* dbus-glib context, permission, allow_interaction, callback, user_data */
|
|
|
|
|
G_TYPE_NONE, 5, G_TYPE_POINTER, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_POINTER, G_TYPE_POINTER);
|
|
|
|
|
|
2012-05-29 09:56:50 -05:00
|
|
|
signals[IP4_CONFIG_CHANGED] =
|
|
|
|
|
g_signal_new (NM_DEVICE_IP4_CONFIG_CHANGED,
|
|
|
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
2013-05-06 13:37:25 -04:00
|
|
|
0, NULL, NULL, NULL,
|
2012-05-29 09:56:50 -05:00
|
|
|
G_TYPE_NONE, 2, G_TYPE_OBJECT, G_TYPE_OBJECT);
|
|
|
|
|
|
|
|
|
|
signals[IP6_CONFIG_CHANGED] =
|
|
|
|
|
g_signal_new (NM_DEVICE_IP6_CONFIG_CHANGED,
|
|
|
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
2013-05-06 13:37:25 -04:00
|
|
|
0, NULL, NULL, NULL,
|
2012-05-29 09:56:50 -05:00
|
|
|
G_TYPE_NONE, 2, G_TYPE_OBJECT, G_TYPE_OBJECT);
|
|
|
|
|
|
2013-05-07 12:18:41 -04:00
|
|
|
nm_dbus_manager_register_exported_type (nm_dbus_manager_get (),
|
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
|
&dbus_glib_nm_device_object_info);
|
2011-11-18 00:34:08 -06:00
|
|
|
|
2011-11-18 00:05:37 -06:00
|
|
|
dbus_g_error_domain_register (NM_DEVICE_ERROR, NULL, NM_TYPE_DEVICE_ERROR);
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
2013-03-20 09:48:24 -04:00
|
|
|
static void
|
|
|
|
|
nm_device_config_device_interface_init (NMConfigDeviceInterface *iface)
|
|
|
|
|
{
|
|
|
|
|
iface->spec_match_list = (gboolean (*) (NMConfigDevice *, const GSList *)) nm_device_spec_match_list;
|
|
|
|
|
iface->get_hw_address = (const guint8 * (*) (NMConfigDevice *, guint *)) nm_device_get_hw_address;
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-01 10:32:11 -07:00
|
|
|
void
|
|
|
|
|
nm_device_set_firmware_missing (NMDevice *self, gboolean new_missing)
|
2010-05-25 10:52:25 -07:00
|
|
|
{
|
2010-07-01 10:32:11 -07:00
|
|
|
NMDevicePrivate *priv;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (NM_IS_DEVICE (self));
|
2010-05-25 10:52:25 -07:00
|
|
|
|
2010-07-01 10:32:11 -07:00
|
|
|
priv = NM_DEVICE_GET_PRIVATE (self);
|
2010-05-25 10:52:25 -07:00
|
|
|
if (priv->firmware_missing != new_missing) {
|
|
|
|
|
priv->firmware_missing = new_missing;
|
2011-11-18 00:34:08 -06:00
|
|
|
g_object_notify (G_OBJECT (self), NM_DEVICE_FIRMWARE_MISSING);
|
2010-05-25 10:52:25 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-01 10:32:11 -07:00
|
|
|
gboolean
|
|
|
|
|
nm_device_get_firmware_missing (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
return NM_DEVICE_GET_PRIVATE (self)->firmware_missing;
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-03 11:57:26 -05:00
|
|
|
static const char *
|
|
|
|
|
state_to_string (NMDeviceState state)
|
|
|
|
|
{
|
|
|
|
|
switch (state) {
|
|
|
|
|
case NM_DEVICE_STATE_UNMANAGED:
|
|
|
|
|
return "unmanaged";
|
|
|
|
|
case NM_DEVICE_STATE_UNAVAILABLE:
|
|
|
|
|
return "unavailable";
|
|
|
|
|
case NM_DEVICE_STATE_DISCONNECTED:
|
|
|
|
|
return "disconnected";
|
|
|
|
|
case NM_DEVICE_STATE_PREPARE:
|
|
|
|
|
return "prepare";
|
|
|
|
|
case NM_DEVICE_STATE_CONFIG:
|
|
|
|
|
return "config";
|
|
|
|
|
case NM_DEVICE_STATE_NEED_AUTH:
|
|
|
|
|
return "need-auth";
|
|
|
|
|
case NM_DEVICE_STATE_IP_CONFIG:
|
|
|
|
|
return "ip-config";
|
|
|
|
|
case NM_DEVICE_STATE_IP_CHECK:
|
|
|
|
|
return "ip-check";
|
|
|
|
|
case NM_DEVICE_STATE_SECONDARIES:
|
|
|
|
|
return "secondaries";
|
|
|
|
|
case NM_DEVICE_STATE_ACTIVATED:
|
|
|
|
|
return "activated";
|
|
|
|
|
case NM_DEVICE_STATE_DEACTIVATING:
|
|
|
|
|
return "deactivating";
|
|
|
|
|
case NM_DEVICE_STATE_FAILED:
|
|
|
|
|
return "failed";
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return "unknown";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const char *
|
|
|
|
|
reason_to_string (NMDeviceStateReason reason)
|
|
|
|
|
{
|
|
|
|
|
switch (reason) {
|
|
|
|
|
case NM_DEVICE_STATE_REASON_NONE:
|
|
|
|
|
return "none";
|
|
|
|
|
case NM_DEVICE_STATE_REASON_NOW_MANAGED:
|
|
|
|
|
return "managed";
|
|
|
|
|
case NM_DEVICE_STATE_REASON_NOW_UNMANAGED:
|
|
|
|
|
return "unmanaged";
|
|
|
|
|
case NM_DEVICE_STATE_REASON_CONFIG_FAILED:
|
|
|
|
|
return "config-failed";
|
|
|
|
|
case NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE:
|
|
|
|
|
return "ip-config-unavailable";
|
|
|
|
|
case NM_DEVICE_STATE_REASON_IP_CONFIG_EXPIRED:
|
|
|
|
|
return "ip-config-expired";
|
|
|
|
|
case NM_DEVICE_STATE_REASON_NO_SECRETS:
|
|
|
|
|
return "no-secrets";
|
|
|
|
|
case NM_DEVICE_STATE_REASON_SUPPLICANT_DISCONNECT:
|
|
|
|
|
return "supplicant-disconnect";
|
|
|
|
|
case NM_DEVICE_STATE_REASON_SUPPLICANT_CONFIG_FAILED:
|
|
|
|
|
return "supplicant-config-failed";
|
|
|
|
|
case NM_DEVICE_STATE_REASON_SUPPLICANT_FAILED:
|
|
|
|
|
return "supplicant-failed";
|
|
|
|
|
case NM_DEVICE_STATE_REASON_SUPPLICANT_TIMEOUT:
|
|
|
|
|
return "supplicant-timeout";
|
|
|
|
|
case NM_DEVICE_STATE_REASON_PPP_START_FAILED:
|
|
|
|
|
return "ppp-start-failed";
|
|
|
|
|
case NM_DEVICE_STATE_REASON_PPP_DISCONNECT:
|
|
|
|
|
return "ppp-disconnect";
|
|
|
|
|
case NM_DEVICE_STATE_REASON_PPP_FAILED:
|
|
|
|
|
return "ppp-failed";
|
|
|
|
|
case NM_DEVICE_STATE_REASON_DHCP_START_FAILED:
|
|
|
|
|
return "dhcp-start-failed";
|
|
|
|
|
case NM_DEVICE_STATE_REASON_DHCP_ERROR:
|
|
|
|
|
return "dhcp-error";
|
|
|
|
|
case NM_DEVICE_STATE_REASON_DHCP_FAILED:
|
|
|
|
|
return "dhcp-failed";
|
|
|
|
|
case NM_DEVICE_STATE_REASON_SHARED_START_FAILED:
|
|
|
|
|
return "sharing-start-failed";
|
|
|
|
|
case NM_DEVICE_STATE_REASON_SHARED_FAILED:
|
|
|
|
|
return "sharing-failed";
|
|
|
|
|
case NM_DEVICE_STATE_REASON_AUTOIP_START_FAILED:
|
|
|
|
|
return "autoip-start-failed";
|
|
|
|
|
case NM_DEVICE_STATE_REASON_AUTOIP_ERROR:
|
|
|
|
|
return "autoip-error";
|
|
|
|
|
case NM_DEVICE_STATE_REASON_AUTOIP_FAILED:
|
|
|
|
|
return "autoip-failed";
|
|
|
|
|
case NM_DEVICE_STATE_REASON_MODEM_BUSY:
|
|
|
|
|
return "modem-busy";
|
|
|
|
|
case NM_DEVICE_STATE_REASON_MODEM_NO_DIAL_TONE:
|
|
|
|
|
return "modem-no-dialtone";
|
|
|
|
|
case NM_DEVICE_STATE_REASON_MODEM_NO_CARRIER:
|
|
|
|
|
return "modem-no-carrier";
|
|
|
|
|
case NM_DEVICE_STATE_REASON_MODEM_DIAL_TIMEOUT:
|
|
|
|
|
return "modem-dial-timeout";
|
|
|
|
|
case NM_DEVICE_STATE_REASON_MODEM_DIAL_FAILED:
|
|
|
|
|
return "modem-dial-failed";
|
|
|
|
|
case NM_DEVICE_STATE_REASON_MODEM_INIT_FAILED:
|
|
|
|
|
return "modem-init-failed";
|
|
|
|
|
case NM_DEVICE_STATE_REASON_GSM_APN_FAILED:
|
|
|
|
|
return "gsm-apn-failed";
|
|
|
|
|
case NM_DEVICE_STATE_REASON_GSM_REGISTRATION_NOT_SEARCHING:
|
|
|
|
|
return "gsm-registration-idle";
|
|
|
|
|
case NM_DEVICE_STATE_REASON_GSM_REGISTRATION_DENIED:
|
|
|
|
|
return "gsm-registration-denied";
|
|
|
|
|
case NM_DEVICE_STATE_REASON_GSM_REGISTRATION_TIMEOUT:
|
|
|
|
|
return "gsm-registration-timeout";
|
|
|
|
|
case NM_DEVICE_STATE_REASON_GSM_REGISTRATION_FAILED:
|
|
|
|
|
return "gsm-registration-failed";
|
|
|
|
|
case NM_DEVICE_STATE_REASON_GSM_PIN_CHECK_FAILED:
|
|
|
|
|
return "gsm-pin-check-failed";
|
|
|
|
|
case NM_DEVICE_STATE_REASON_FIRMWARE_MISSING:
|
|
|
|
|
return "firmware-missing";
|
|
|
|
|
case NM_DEVICE_STATE_REASON_REMOVED:
|
|
|
|
|
return "removed";
|
|
|
|
|
case NM_DEVICE_STATE_REASON_SLEEPING:
|
|
|
|
|
return "sleeping";
|
|
|
|
|
case NM_DEVICE_STATE_REASON_CONNECTION_REMOVED:
|
|
|
|
|
return "connection-removed";
|
|
|
|
|
case NM_DEVICE_STATE_REASON_USER_REQUESTED:
|
|
|
|
|
return "user-requested";
|
|
|
|
|
case NM_DEVICE_STATE_REASON_CARRIER:
|
2011-05-09 13:55:19 -05:00
|
|
|
return "carrier-changed";
|
2011-05-03 11:57:26 -05:00
|
|
|
case NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED:
|
|
|
|
|
return "connection-assumed";
|
|
|
|
|
case NM_DEVICE_STATE_REASON_SUPPLICANT_AVAILABLE:
|
|
|
|
|
return "supplicant-available";
|
|
|
|
|
case NM_DEVICE_STATE_REASON_MODEM_NOT_FOUND:
|
|
|
|
|
return "modem-not-found";
|
|
|
|
|
case NM_DEVICE_STATE_REASON_BT_FAILED:
|
|
|
|
|
return "bluetooth-failed";
|
2011-11-13 19:06:29 +01:00
|
|
|
case NM_DEVICE_STATE_REASON_GSM_SIM_NOT_INSERTED:
|
|
|
|
|
return "gsm-sim-not-inserted";
|
|
|
|
|
case NM_DEVICE_STATE_REASON_GSM_SIM_PIN_REQUIRED:
|
|
|
|
|
return "gsm-sim-pin-required";
|
|
|
|
|
case NM_DEVICE_STATE_REASON_GSM_SIM_PUK_REQUIRED:
|
|
|
|
|
return "gsm-sim-puk-required";
|
|
|
|
|
case NM_DEVICE_STATE_REASON_GSM_SIM_WRONG:
|
|
|
|
|
return "gsm-sim-wrong";
|
2011-11-14 14:52:40 -05:00
|
|
|
case NM_DEVICE_STATE_REASON_INFINIBAND_MODE:
|
|
|
|
|
return "infiniband-mode";
|
2012-02-26 17:40:22 -06:00
|
|
|
case NM_DEVICE_STATE_REASON_DEPENDENCY_FAILED:
|
|
|
|
|
return "dependency-failed";
|
2011-05-26 13:04:59 -05:00
|
|
|
case NM_DEVICE_STATE_REASON_BR2684_FAILED:
|
2012-08-22 13:40:46 +02:00
|
|
|
return "br2684-bridge-failed";
|
2012-08-29 14:21:08 -05:00
|
|
|
case NM_DEVICE_STATE_REASON_MODEM_MANAGER_UNAVAILABLE:
|
|
|
|
|
return "modem-manager-unavailable";
|
2012-06-28 16:40:47 -05:00
|
|
|
case NM_DEVICE_STATE_REASON_SSID_NOT_FOUND:
|
|
|
|
|
return "SSID not found";
|
2012-09-21 14:36:46 +02:00
|
|
|
case NM_DEVICE_STATE_REASON_SECONDARY_CONNECTION_FAILED:
|
|
|
|
|
return "secondary-connection-failed";
|
2011-05-03 11:57:26 -05:00
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return "unknown";
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-13 17:45:34 -04:00
|
|
|
static inline gboolean
|
|
|
|
|
state_implies_pending_action (NMDeviceState state)
|
|
|
|
|
{
|
|
|
|
|
return ( state >= NM_DEVICE_STATE_PREPARE
|
|
|
|
|
&& state < NM_DEVICE_STATE_ACTIVATED);
|
|
|
|
|
}
|
|
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
void
|
2008-07-11 10:28:53 +00:00
|
|
|
nm_device_state_changed (NMDevice *device,
|
|
|
|
|
NMDeviceState state,
|
|
|
|
|
NMDeviceStateReason reason)
|
2007-02-05 12:14:09 +00:00
|
|
|
{
|
2009-07-07 14:34:01 -04:00
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
|
2007-03-02 Tambet Ingo <tambet@ximian.com>
* libnm-glib/nm-device-802-11-wireless.c: Cache networks (bssids) list.
We get signalled when it changes.
* libnm-glib/nm-client.c: Cache NMState and device list, we get signalled
when it changes.
* libnm-glib/nm-device.c: Cache the device state property.
* libnm-glib/nm-access-point.c: Cache the strength property.
* src/nm-device-802-11-wireless.c: Fix wireless device scanning scheduler.
The new algorithm is to start from SCAN_INTERVAL_MIN (currently defined as 0)
and add a SCAN_INTERVAL_STEP (currently 20 seconds) with each successful scan
until SCAN_INTERVAL_MAX (currently 120 seconds) is reached. Do not scan while
the device is down, activating, or activated (in case of A/B/G cards).
Remove some old dead ifdef'ed out code that used to configure wireless devices,
it's all done through supplicant now.
* src/supplicant-manager/nm-supplicant-interface.c: Fix the reference
counting issues with pending calls which caused leaks and crashes when
interface was removed (now that the interface actually gets removed).
* src/nm-call-store.c: Make a copy of data before running a foreach
with user callback on it - The most common usage pattern is to cancel
(and thus remove) all pending calls with foreach which would modify
the hash table we're iterating over.
* src/nm-manager.c: When a device is added, make sure it is "up". When
it's removed or disabled due to disabling wireless or networking, bring
it down.
* include/NetworkManager.h: Add new device state NM_DEVICE_STATE_DOWN.
* src/nm-device-802-11-wireless.c:
* src/nm-device-802-3-ethernet.c:
* src/nm-device.c:
- Remove "init" virtual function, all gobjects have a place for that
already (constructor).
- Replace "start" virtual function with "bring_up", devices can be
brought up and down more than just on startup now.
- Add "is_up" virtual function.
- Implement one way to bring a device down instead of previous 4 different
ways, each of witch did something different.
* src/NetworkManagerUtils.c (nm_dev_sock_open): This doesn't need an NMDevice,
all it needs is the device interface.
Get rid of NMData.dev_list (3 members to go).
Get rif of NMData in a lot of places.
* gnome/libnm_glib/libnm_glib.c: Make it compile again.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2395 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-03-02 09:30:48 +00:00
|
|
|
NMDeviceState old_state;
|
2008-04-27 14:30:06 +00:00
|
|
|
NMActRequest *req;
|
2008-08-18 18:29:47 +00:00
|
|
|
gboolean no_firmware = FALSE;
|
2012-06-28 12:09:03 -05:00
|
|
|
NMConnection *connection;
|
2007-03-02 Tambet Ingo <tambet@ximian.com>
* libnm-glib/nm-device-802-11-wireless.c: Cache networks (bssids) list.
We get signalled when it changes.
* libnm-glib/nm-client.c: Cache NMState and device list, we get signalled
when it changes.
* libnm-glib/nm-device.c: Cache the device state property.
* libnm-glib/nm-access-point.c: Cache the strength property.
* src/nm-device-802-11-wireless.c: Fix wireless device scanning scheduler.
The new algorithm is to start from SCAN_INTERVAL_MIN (currently defined as 0)
and add a SCAN_INTERVAL_STEP (currently 20 seconds) with each successful scan
until SCAN_INTERVAL_MAX (currently 120 seconds) is reached. Do not scan while
the device is down, activating, or activated (in case of A/B/G cards).
Remove some old dead ifdef'ed out code that used to configure wireless devices,
it's all done through supplicant now.
* src/supplicant-manager/nm-supplicant-interface.c: Fix the reference
counting issues with pending calls which caused leaks and crashes when
interface was removed (now that the interface actually gets removed).
* src/nm-call-store.c: Make a copy of data before running a foreach
with user callback on it - The most common usage pattern is to cancel
(and thus remove) all pending calls with foreach which would modify
the hash table we're iterating over.
* src/nm-manager.c: When a device is added, make sure it is "up". When
it's removed or disabled due to disabling wireless or networking, bring
it down.
* include/NetworkManager.h: Add new device state NM_DEVICE_STATE_DOWN.
* src/nm-device-802-11-wireless.c:
* src/nm-device-802-3-ethernet.c:
* src/nm-device.c:
- Remove "init" virtual function, all gobjects have a place for that
already (constructor).
- Replace "start" virtual function with "bring_up", devices can be
brought up and down more than just on startup now.
- Add "is_up" virtual function.
- Implement one way to bring a device down instead of previous 4 different
ways, each of witch did something different.
* src/NetworkManagerUtils.c (nm_dev_sock_open): This doesn't need an NMDevice,
all it needs is the device interface.
Get rid of NMData.dev_list (3 members to go).
Get rif of NMData in a lot of places.
* gnome/libnm_glib/libnm_glib.c: Make it compile again.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2395 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-03-02 09:30:48 +00:00
|
|
|
|
2012-10-06 12:37:34 -05:00
|
|
|
/* Track re-entry */
|
2013-05-20 16:15:37 -03:00
|
|
|
g_warn_if_fail (priv->in_state_changed == FALSE);
|
|
|
|
|
priv->in_state_changed = TRUE;
|
2012-10-06 12:37:34 -05:00
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
g_return_if_fail (NM_IS_DEVICE (device));
|
|
|
|
|
|
2010-07-01 10:32:11 -07:00
|
|
|
/* Do nothing if state isn't changing, but as a special case allow
|
|
|
|
|
* re-setting UNAVAILABLE if the device is missing firmware so that we
|
|
|
|
|
* can retry device initialization.
|
|
|
|
|
*/
|
|
|
|
|
if ( (priv->state == state)
|
2012-10-10 17:30:46 +02:00
|
|
|
&& !(state == NM_DEVICE_STATE_UNAVAILABLE && priv->firmware_missing)) {
|
2013-05-20 16:15:37 -03:00
|
|
|
priv->in_state_changed = FALSE;
|
2008-03-24 02:56:25 +00:00
|
|
|
return;
|
2012-10-10 17:30:46 +02:00
|
|
|
}
|
2008-03-24 02:56:25 +00:00
|
|
|
|
2008-04-27 14:30:06 +00:00
|
|
|
old_state = priv->state;
|
|
|
|
|
priv->state = state;
|
2012-01-29 22:40:37 +01:00
|
|
|
priv->state_reason = reason;
|
2009-05-12 12:05:47 -04:00
|
|
|
|
2013-08-13 17:45:34 -04:00
|
|
|
if ( state_implies_pending_action (state)
|
|
|
|
|
&& !state_implies_pending_action (old_state))
|
|
|
|
|
nm_device_add_pending_action (device, "activation");
|
|
|
|
|
|
2011-05-03 11:57:26 -05:00
|
|
|
nm_log_info (LOGD_DEVICE, "(%s): device state change: %s -> %s (reason '%s') [%d %d %d]",
|
|
|
|
|
nm_device_get_iface (device),
|
|
|
|
|
state_to_string (old_state),
|
|
|
|
|
state_to_string (state),
|
|
|
|
|
reason_to_string (reason),
|
|
|
|
|
old_state,
|
|
|
|
|
state,
|
|
|
|
|
reason);
|
2007-02-05 12:14:09 +00:00
|
|
|
|
2011-12-08 11:46:58 -06:00
|
|
|
/* Clear any queued transitions */
|
2012-08-30 15:59:31 -05:00
|
|
|
nm_device_queued_state_clear (device);
|
2007-06-13 11:58:25 +00:00
|
|
|
|
2008-04-27 14:30:06 +00:00
|
|
|
/* Cache the activation request for the dispatcher */
|
|
|
|
|
req = priv->act_request ? g_object_ref (priv->act_request) : NULL;
|
|
|
|
|
|
2012-08-01 11:16:48 -06:00
|
|
|
if (state <= NM_DEVICE_STATE_UNAVAILABLE)
|
|
|
|
|
_clear_available_connections (device, TRUE);
|
|
|
|
|
|
|
|
|
|
/* Update the available connections list when a device first becomes available */
|
|
|
|
|
if ( state >= NM_DEVICE_STATE_DISCONNECTED
|
|
|
|
|
&& old_state < NM_DEVICE_STATE_DISCONNECTED)
|
|
|
|
|
nm_device_recheck_available_connections (device);
|
|
|
|
|
|
2008-04-17 23:04:34 +00:00
|
|
|
/* Handle the new state here; but anything that could trigger
|
|
|
|
|
* another state change should be done below.
|
|
|
|
|
*/
|
2007-02-05 12:14:09 +00:00
|
|
|
switch (state) {
|
2008-04-28 Dan Williams <dcbw@redhat.com>
Fix the device up/down ambiguities. Up/down state used to be a
conglomeration of hardware state (IFF_UP) and any device-specific things
(supplicant, periodic timers, etc) that the device used to indicate
readiness. Unfortunately, if the hardware was already IFF_UP for some
reason, then the device specific stuff wouldn't get run, and the device
would be stuck.
* src/nm-device.c
src/nm-device.h
- Create hw_is_up, hw_bring_up, and hw_take_down
- Rename bring_down -> take_down
- (real_hw_is_up): check interface flags for IFF_UP
- (nm_device_hw_is_up): let subclasses figure out their own HW state
- (nm_device_is_up): make static; only used locally
- (nm_device_hw_bring_up): update the hardware and IPv4 addresses even
if the device is already up; if the device isn't up, bring it up
- (nm_device_hw_take_down): just take down hardware
- (nm_device_bring_up): bring up HW first, then device specific stuff
- (nm_device_take_down): always deactivate device when called; always
try to take hardware down too
- (nm_device_state_changed): take device down when entering unmanaged
state from a higher state
* src/nm-device-802-11-wireless.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
- (real_take_down, supplicant_iface_state_cb_handler,
supplicant_iface_connection_state_cb_handler,
supplicant_mgr_state_cb_handler): fix some messages
* src/nm-device-802-3-ethernet.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3618 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-29 15:36:29 +00:00
|
|
|
case NM_DEVICE_STATE_UNMANAGED:
|
2010-07-01 10:32:11 -07:00
|
|
|
nm_device_set_firmware_missing (device, FALSE);
|
2013-06-12 10:48:03 -05:00
|
|
|
if (old_state > NM_DEVICE_STATE_UNMANAGED) {
|
|
|
|
|
/* Clean up if the device is now unmanaged but was activated */
|
|
|
|
|
if (nm_device_get_act_request (device))
|
|
|
|
|
nm_device_deactivate (device, reason);
|
2013-06-13 15:13:58 -05:00
|
|
|
nm_device_take_down (device, TRUE);
|
2013-06-12 10:48:03 -05:00
|
|
|
}
|
2008-04-28 Dan Williams <dcbw@redhat.com>
Fix the device up/down ambiguities. Up/down state used to be a
conglomeration of hardware state (IFF_UP) and any device-specific things
(supplicant, periodic timers, etc) that the device used to indicate
readiness. Unfortunately, if the hardware was already IFF_UP for some
reason, then the device specific stuff wouldn't get run, and the device
would be stuck.
* src/nm-device.c
src/nm-device.h
- Create hw_is_up, hw_bring_up, and hw_take_down
- Rename bring_down -> take_down
- (real_hw_is_up): check interface flags for IFF_UP
- (nm_device_hw_is_up): let subclasses figure out their own HW state
- (nm_device_is_up): make static; only used locally
- (nm_device_hw_bring_up): update the hardware and IPv4 addresses even
if the device is already up; if the device isn't up, bring it up
- (nm_device_hw_take_down): just take down hardware
- (nm_device_bring_up): bring up HW first, then device specific stuff
- (nm_device_take_down): always deactivate device when called; always
try to take hardware down too
- (nm_device_state_changed): take device down when entering unmanaged
state from a higher state
* src/nm-device-802-11-wireless.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
- (real_take_down, supplicant_iface_state_cb_handler,
supplicant_iface_connection_state_cb_handler,
supplicant_mgr_state_cb_handler): fix some messages
* src/nm-device-802-3-ethernet.c
- (real_hw_is_up, real_hw_bring_up, real_hw_take_down): implement; just
check IFF_UP really
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3618 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-29 15:36:29 +00:00
|
|
|
break;
|
2008-04-07 Dan Williams <dcbw@redhat.com>
* include/NetworkManager.h
- Remove the DOWN and CANCELLED device states
- Add UNMANAGED and UNAVAILABLE device states
- Document the device states
* introspection/nm-device.xml
src/nm-device-interface.c
src/nm-device-interface.h
- Add the 'managed' property
* test/nm-tool.c
- (detail_device): print out device state
* src/NetworkManagerSystem.h
src/backends/NetworkManagerArch.c
src/backends/NetworkManagerDebian.c
src/backends/NetworkManagerFrugalware.c
src/backends/NetworkManagerGentoo.c
src/backends/NetworkManagerMandriva.c
src/backends/NetworkManagerPaldo.c
src/backends/NetworkManagerRedHat.c
src/backends/NetworkManagerSlackware.c
src/backends/NetworkManagerSuSE.c
- (nm_system_device_get_system_config, nm_system_device_get_disabled
nm_system_device_free_system_config): remove; they were unused and
their functionality should be re-implemented in each distro's
system settings service plugin
* src/nm-gsm-device.c
src/nm-gsm-device.h
src/nm-cdma-device.c
src/nm-cdma-device.h
- (*_new): take the 'managed' argument
* src/nm-device.c
- (nm_device_set_address): remove, fold into nm_device_bring_up()
- (nm_device_init): start in unmanaged state, not disconnected
- (constructor): don't start device until the system settings service
has had a chance to figure out if the device is managed or not
- (nm_device_deactivate, nm_device_bring_up, nm_device_bring_down):
don't set device state here, let callers handle that as appropriate
- (nm_device_dispose): don't touch the device if it's not managed
- (set_property, get_property, nm_device_class_init): implement the
'managed' property
- (nm_device_state_changed): bring the device up if its now managed,
and deactivate it if it used to be active
- (nm_device_get_managed, nm_device_set_managed): do the right thing
with the managed state
* src/nm-hal-manager.c
- (wired_device_creator, wireless_device_creator, modem_device_creator):
take initial managed state and pass it along to device constructors
- (create_device_and_add_to_list): get managed state and pass to
type creators
* src/nm-device-802-11-wireless.c
- (real_can_activate): fold in most of
nm_device_802_11_wireless_can_activate()
- (can_scan): can't scan in UNAVAILABLE or UNMANAGED
- (link_timeout_cb): instead of deactivating, change device state and
let the device state handler to it
- (real_update_hw_address): clean up
- (state_changed_cb): when entering UNAVAILABLE state, schedule an idle
handler to transition to DISCONNECTED if the device isn't rfkilled
* src/nm-device-802-3-ethernet.c
- (set_carrier): move above callers and get rid of prototype
- (device_state_changed): when entering UNAVAILABLE state, schedule an
idle handler to transition to DISCONNECTED if the device has a
carrier
- (real_update_hw_address): clean up
- (link_timeout_cb, ppp_state_changed): change state instead of calling
deactivation directly as deactivation doesn't change state anymore
* src/NetworkManagerPolicy.c
- (schedule_activate_check): yay, remove wireless_enabled hack since
the NMManager and wireless devices work that out themselves now
- (device_state_changed): change to a switch and update for new device
states
- (device_carrier_changed): remove; device handles this now through
state changes
- (device_added): don't care about carrier any more; the initial
activation check will happen when the device transitions to
DISCONNECTED
* src/nm-manager.c
- (dispose): clear unmanaged devices
- (handle_unmanaged_devices): update unmanaged device list and toggle
the managed property on each device when needed
- (system_settings_properties_changed_cb): handle signals from the
system settings service
- (system_settings_get_unmanaged_devices_cb): handle callback from
getting the unmanaged device list method call
- (query_unmanaged_devices): ask the system settings service for its
list of unmanaged devices
- (nm_manager_name_owner_changed, initial_get_connections): get unmanaged
devices
- (manager_set_wireless_enabled): push rfkill state down to wireless
devices directly and let them handle the necessary state transitions
- (manager_device_state_changed): update for new device states
- (nm_manager_add_device): set initial rfkill state on wireless devices
- (nm_manager_remove_device): don't touch the device if it's unmanaged
- (nm_manager_activate_connection): return error if the device is
unmanaged
- (nm_manager_sleep): handle new device states correctly; don't change
the state of unavailable/unmanaged devices
* libnm-glib/nm-device-802-11-wireless.c
- (state_changed_cb): update for new device states
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3540 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 02:58:02 +00:00
|
|
|
case NM_DEVICE_STATE_UNAVAILABLE:
|
2010-07-01 10:32:11 -07:00
|
|
|
if (old_state == NM_DEVICE_STATE_UNMANAGED || priv->firmware_missing) {
|
2013-06-13 15:13:58 -05:00
|
|
|
if (!nm_device_bring_up (device, TRUE, &no_firmware) && no_firmware)
|
2010-07-01 10:32:11 -07:00
|
|
|
nm_log_warn (LOGD_HW, "(%s): firmware may be missing.", nm_device_get_iface (device));
|
|
|
|
|
nm_device_set_firmware_missing (device, no_firmware ? TRUE : FALSE);
|
2008-08-18 18:29:47 +00:00
|
|
|
}
|
2009-08-05 18:03:09 -04:00
|
|
|
/* Ensure the device gets deactivated in response to stuff like
|
|
|
|
|
* carrier changes or rfkill. But don't deactivate devices that are
|
|
|
|
|
* about to assume a connection since that defeats the purpose of
|
|
|
|
|
* assuming the device's existing connection.
|
|
|
|
|
*/
|
2013-04-24 10:40:58 -04:00
|
|
|
if (reason != NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED &&
|
|
|
|
|
old_state != NM_DEVICE_STATE_UNMANAGED)
|
2011-11-17 23:55:34 -06:00
|
|
|
nm_device_deactivate (device, reason);
|
2009-08-05 18:03:09 -04:00
|
|
|
break;
|
2008-04-07 Dan Williams <dcbw@redhat.com>
* include/NetworkManager.h
- Remove the DOWN and CANCELLED device states
- Add UNMANAGED and UNAVAILABLE device states
- Document the device states
* introspection/nm-device.xml
src/nm-device-interface.c
src/nm-device-interface.h
- Add the 'managed' property
* test/nm-tool.c
- (detail_device): print out device state
* src/NetworkManagerSystem.h
src/backends/NetworkManagerArch.c
src/backends/NetworkManagerDebian.c
src/backends/NetworkManagerFrugalware.c
src/backends/NetworkManagerGentoo.c
src/backends/NetworkManagerMandriva.c
src/backends/NetworkManagerPaldo.c
src/backends/NetworkManagerRedHat.c
src/backends/NetworkManagerSlackware.c
src/backends/NetworkManagerSuSE.c
- (nm_system_device_get_system_config, nm_system_device_get_disabled
nm_system_device_free_system_config): remove; they were unused and
their functionality should be re-implemented in each distro's
system settings service plugin
* src/nm-gsm-device.c
src/nm-gsm-device.h
src/nm-cdma-device.c
src/nm-cdma-device.h
- (*_new): take the 'managed' argument
* src/nm-device.c
- (nm_device_set_address): remove, fold into nm_device_bring_up()
- (nm_device_init): start in unmanaged state, not disconnected
- (constructor): don't start device until the system settings service
has had a chance to figure out if the device is managed or not
- (nm_device_deactivate, nm_device_bring_up, nm_device_bring_down):
don't set device state here, let callers handle that as appropriate
- (nm_device_dispose): don't touch the device if it's not managed
- (set_property, get_property, nm_device_class_init): implement the
'managed' property
- (nm_device_state_changed): bring the device up if its now managed,
and deactivate it if it used to be active
- (nm_device_get_managed, nm_device_set_managed): do the right thing
with the managed state
* src/nm-hal-manager.c
- (wired_device_creator, wireless_device_creator, modem_device_creator):
take initial managed state and pass it along to device constructors
- (create_device_and_add_to_list): get managed state and pass to
type creators
* src/nm-device-802-11-wireless.c
- (real_can_activate): fold in most of
nm_device_802_11_wireless_can_activate()
- (can_scan): can't scan in UNAVAILABLE or UNMANAGED
- (link_timeout_cb): instead of deactivating, change device state and
let the device state handler to it
- (real_update_hw_address): clean up
- (state_changed_cb): when entering UNAVAILABLE state, schedule an idle
handler to transition to DISCONNECTED if the device isn't rfkilled
* src/nm-device-802-3-ethernet.c
- (set_carrier): move above callers and get rid of prototype
- (device_state_changed): when entering UNAVAILABLE state, schedule an
idle handler to transition to DISCONNECTED if the device has a
carrier
- (real_update_hw_address): clean up
- (link_timeout_cb, ppp_state_changed): change state instead of calling
deactivation directly as deactivation doesn't change state anymore
* src/NetworkManagerPolicy.c
- (schedule_activate_check): yay, remove wireless_enabled hack since
the NMManager and wireless devices work that out themselves now
- (device_state_changed): change to a switch and update for new device
states
- (device_carrier_changed): remove; device handles this now through
state changes
- (device_added): don't care about carrier any more; the initial
activation check will happen when the device transitions to
DISCONNECTED
* src/nm-manager.c
- (dispose): clear unmanaged devices
- (handle_unmanaged_devices): update unmanaged device list and toggle
the managed property on each device when needed
- (system_settings_properties_changed_cb): handle signals from the
system settings service
- (system_settings_get_unmanaged_devices_cb): handle callback from
getting the unmanaged device list method call
- (query_unmanaged_devices): ask the system settings service for its
list of unmanaged devices
- (nm_manager_name_owner_changed, initial_get_connections): get unmanaged
devices
- (manager_set_wireless_enabled): push rfkill state down to wireless
devices directly and let them handle the necessary state transitions
- (manager_device_state_changed): update for new device states
- (nm_manager_add_device): set initial rfkill state on wireless devices
- (nm_manager_remove_device): don't touch the device if it's unmanaged
- (nm_manager_activate_connection): return error if the device is
unmanaged
- (nm_manager_sleep): handle new device states correctly; don't change
the state of unavailable/unmanaged devices
* libnm-glib/nm-device-802-11-wireless.c
- (state_changed_cb): update for new device states
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3540 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 02:58:02 +00:00
|
|
|
case NM_DEVICE_STATE_DISCONNECTED:
|
|
|
|
|
if (old_state != NM_DEVICE_STATE_UNAVAILABLE)
|
2011-11-17 23:55:34 -06:00
|
|
|
nm_device_deactivate (device, reason);
|
2007-03-02 Tambet Ingo <tambet@ximian.com>
* libnm-glib/nm-device-802-11-wireless.c: Cache networks (bssids) list.
We get signalled when it changes.
* libnm-glib/nm-client.c: Cache NMState and device list, we get signalled
when it changes.
* libnm-glib/nm-device.c: Cache the device state property.
* libnm-glib/nm-access-point.c: Cache the strength property.
* src/nm-device-802-11-wireless.c: Fix wireless device scanning scheduler.
The new algorithm is to start from SCAN_INTERVAL_MIN (currently defined as 0)
and add a SCAN_INTERVAL_STEP (currently 20 seconds) with each successful scan
until SCAN_INTERVAL_MAX (currently 120 seconds) is reached. Do not scan while
the device is down, activating, or activated (in case of A/B/G cards).
Remove some old dead ifdef'ed out code that used to configure wireless devices,
it's all done through supplicant now.
* src/supplicant-manager/nm-supplicant-interface.c: Fix the reference
counting issues with pending calls which caused leaks and crashes when
interface was removed (now that the interface actually gets removed).
* src/nm-call-store.c: Make a copy of data before running a foreach
with user callback on it - The most common usage pattern is to cancel
(and thus remove) all pending calls with foreach which would modify
the hash table we're iterating over.
* src/nm-manager.c: When a device is added, make sure it is "up". When
it's removed or disabled due to disabling wireless or networking, bring
it down.
* include/NetworkManager.h: Add new device state NM_DEVICE_STATE_DOWN.
* src/nm-device-802-11-wireless.c:
* src/nm-device-802-3-ethernet.c:
* src/nm-device.c:
- Remove "init" virtual function, all gobjects have a place for that
already (constructor).
- Replace "start" virtual function with "bring_up", devices can be
brought up and down more than just on startup now.
- Add "is_up" virtual function.
- Implement one way to bring a device down instead of previous 4 different
ways, each of witch did something different.
* src/NetworkManagerUtils.c (nm_dev_sock_open): This doesn't need an NMDevice,
all it needs is the device interface.
Get rid of NMData.dev_list (3 members to go).
Get rif of NMData in a lot of places.
* gnome/libnm_glib/libnm_glib.c: Make it compile again.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2395 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-03-02 09:30:48 +00:00
|
|
|
break;
|
2008-04-17 23:04:34 +00:00
|
|
|
default:
|
2012-05-14 15:32:54 +02:00
|
|
|
priv->autoconnect = TRUE;
|
2008-04-17 23:04:34 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-18 00:34:08 -06:00
|
|
|
g_object_notify (G_OBJECT (device), NM_DEVICE_STATE);
|
2012-01-29 22:40:37 +01:00
|
|
|
g_object_notify (G_OBJECT (device), NM_DEVICE_STATE_REASON);
|
2009-05-12 12:05:47 -04:00
|
|
|
g_signal_emit_by_name (device, "state-changed", state, old_state, reason);
|
2008-04-17 23:04:34 +00:00
|
|
|
|
2008-04-27 14:30:06 +00:00
|
|
|
/* Post-process the event after internal notification */
|
|
|
|
|
|
2008-04-17 23:04:34 +00:00
|
|
|
switch (state) {
|
2009-09-14 13:24:29 -07:00
|
|
|
case NM_DEVICE_STATE_UNAVAILABLE:
|
|
|
|
|
/* If the device can activate now (ie, it's got a carrier, the supplicant
|
|
|
|
|
* is active, or whatever) schedule a delayed transition to DISCONNECTED
|
2010-09-25 00:34:10 -05:00
|
|
|
* to get things rolling. The device can't transition immediately because
|
2009-09-14 13:24:29 -07:00
|
|
|
* we can't change states again from the state handler for a variety of
|
|
|
|
|
* reasons.
|
|
|
|
|
*/
|
2013-03-19 09:17:41 -04:00
|
|
|
if (nm_device_is_available (device)) {
|
2010-04-08 15:51:54 -07:00
|
|
|
nm_log_dbg (LOGD_DEVICE, "(%s): device is available, will transition to DISCONNECTED",
|
2010-04-07 16:41:44 -07:00
|
|
|
nm_device_get_iface (device));
|
2011-12-08 11:46:58 -06:00
|
|
|
nm_device_queue_state (device, NM_DEVICE_STATE_DISCONNECTED, NM_DEVICE_STATE_REASON_NONE);
|
2010-04-08 15:51:54 -07:00
|
|
|
} else {
|
2013-04-24 10:40:58 -04:00
|
|
|
if (old_state == NM_DEVICE_STATE_UNMANAGED) {
|
|
|
|
|
nm_log_dbg (LOGD_DEVICE, "(%s): device not yet available for transition to DISCONNECTED",
|
|
|
|
|
nm_device_get_iface (device));
|
|
|
|
|
} else if (old_state > NM_DEVICE_STATE_UNAVAILABLE && priv->default_unmanaged)
|
|
|
|
|
nm_device_queue_state (device, NM_DEVICE_STATE_UNMANAGED, NM_DEVICE_STATE_REASON_NONE);
|
2010-04-07 16:41:44 -07:00
|
|
|
}
|
2009-09-14 13:24:29 -07:00
|
|
|
break;
|
2013-04-24 10:40:58 -04:00
|
|
|
case NM_DEVICE_STATE_DISCONNECTED:
|
|
|
|
|
if (old_state > NM_DEVICE_STATE_DISCONNECTED && priv->default_unmanaged)
|
|
|
|
|
nm_device_queue_state (device, NM_DEVICE_STATE_UNMANAGED, NM_DEVICE_STATE_REASON_NONE);
|
|
|
|
|
break;
|
2007-02-05 12:14:09 +00:00
|
|
|
case NM_DEVICE_STATE_ACTIVATED:
|
2010-04-07 12:31:39 -07:00
|
|
|
nm_log_info (LOGD_DEVICE, "Activation (%s) successful, device activated.",
|
|
|
|
|
nm_device_get_iface (device));
|
2012-06-05 11:20:11 -05:00
|
|
|
nm_dispatcher_call (DISPATCHER_ACTION_UP, nm_act_request_get_connection (req), device, NULL, NULL);
|
2007-02-05 12:14:09 +00:00
|
|
|
break;
|
|
|
|
|
case NM_DEVICE_STATE_FAILED:
|
2012-06-28 12:09:03 -05:00
|
|
|
connection = nm_act_request_get_connection (req);
|
|
|
|
|
nm_log_warn (LOGD_DEVICE | LOGD_WIFI,
|
|
|
|
|
"Activation (%s) failed for connection '%s'",
|
|
|
|
|
nm_device_get_iface (device),
|
|
|
|
|
nm_connection_get_id (connection));
|
2012-09-12 22:44:31 -05:00
|
|
|
|
2012-11-14 14:05:30 -06:00
|
|
|
/* Notify any slaves of the unexpected failure */
|
|
|
|
|
nm_device_master_release_slaves (device, TRUE);
|
|
|
|
|
|
2012-09-12 22:44:31 -05:00
|
|
|
/* If the connection doesn't yet have a timestamp, set it to zero so that
|
|
|
|
|
* we can distinguish between connections we've tried to activate and have
|
|
|
|
|
* failed (zero timestamp), connections that succeeded (non-zero timestamp),
|
|
|
|
|
* and those we haven't tried yet (no timestamp).
|
|
|
|
|
*/
|
|
|
|
|
if (!nm_settings_connection_get_timestamp (NM_SETTINGS_CONNECTION (connection), NULL)) {
|
|
|
|
|
nm_settings_connection_update_timestamp (NM_SETTINGS_CONNECTION (connection),
|
|
|
|
|
(guint64) 0,
|
|
|
|
|
TRUE);
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-14 13:24:29 -07:00
|
|
|
/* Schedule the transition to DISCONNECTED. The device can't transition
|
2010-09-25 00:34:10 -05:00
|
|
|
* immediately because we can't change states again from the state
|
2009-09-14 13:24:29 -07:00
|
|
|
* handler for a variety of reasons.
|
|
|
|
|
*/
|
2011-12-08 11:46:58 -06:00
|
|
|
nm_device_queue_state (device, NM_DEVICE_STATE_DISCONNECTED, NM_DEVICE_STATE_REASON_NONE);
|
2007-02-05 12:14:09 +00:00
|
|
|
break;
|
2013-06-11 17:05:49 -05:00
|
|
|
case NM_DEVICE_STATE_IP_CHECK:
|
|
|
|
|
nm_device_start_ip_check (device);
|
|
|
|
|
break;
|
2012-08-21 17:49:41 +02:00
|
|
|
case NM_DEVICE_STATE_SECONDARIES:
|
2013-06-11 17:05:49 -05:00
|
|
|
ip_check_gw_ping_cleanup (device);
|
2012-08-21 17:49:41 +02:00
|
|
|
nm_log_dbg (LOGD_DEVICE, "(%s): device entered SECONDARIES state",
|
|
|
|
|
nm_device_get_iface (device));
|
|
|
|
|
break;
|
2007-02-05 12:14:09 +00:00
|
|
|
default:
|
|
|
|
|
break;
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
2008-04-27 14:30:06 +00:00
|
|
|
|
2013-08-07 11:41:40 +02:00
|
|
|
if (state > NM_DEVICE_STATE_DISCONNECTED)
|
|
|
|
|
delete_on_deactivate_unschedule (priv);
|
|
|
|
|
|
2008-04-27 14:30:06 +00:00
|
|
|
if (old_state == NM_DEVICE_STATE_ACTIVATED)
|
2012-06-05 11:20:11 -05:00
|
|
|
nm_dispatcher_call (DISPATCHER_ACTION_DOWN, nm_act_request_get_connection (req), device, NULL, NULL);
|
2008-04-27 14:30:06 +00:00
|
|
|
|
|
|
|
|
/* Dispose of the cached activation request */
|
|
|
|
|
if (req)
|
|
|
|
|
g_object_unref (req);
|
2012-10-06 12:37:34 -05:00
|
|
|
|
2013-08-13 17:45:34 -04:00
|
|
|
if ( state_implies_pending_action (old_state)
|
|
|
|
|
&& !state_implies_pending_action (state))
|
|
|
|
|
nm_device_remove_pending_action (device, "activation");
|
|
|
|
|
|
2013-05-20 16:15:37 -03:00
|
|
|
priv->in_state_changed = FALSE;
|
2007-02-05 12:14:09 +00:00
|
|
|
}
|
|
|
|
|
|
2011-12-08 11:46:58 -06:00
|
|
|
static gboolean
|
|
|
|
|
queued_set_state (gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMDevice *self = NM_DEVICE (user_data);
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
2012-11-14 18:00:22 -06:00
|
|
|
NMDeviceState new_state;
|
|
|
|
|
NMDeviceStateReason new_reason;
|
2011-12-08 11:46:58 -06:00
|
|
|
|
|
|
|
|
if (priv->queued_state.id) {
|
|
|
|
|
nm_log_dbg (LOGD_DEVICE, "(%s): running queued state change to %s (id %d)",
|
|
|
|
|
nm_device_get_iface (self),
|
|
|
|
|
state_to_string (priv->queued_state.state),
|
|
|
|
|
priv->queued_state.id);
|
2012-11-14 18:00:22 -06:00
|
|
|
|
|
|
|
|
/* Clear queued state struct before triggering state change, since
|
|
|
|
|
* the state change may queue another state.
|
|
|
|
|
*/
|
2012-03-13 16:42:01 -05:00
|
|
|
priv->queued_state.id = 0;
|
2012-11-14 18:00:22 -06:00
|
|
|
new_state = priv->queued_state.state;
|
|
|
|
|
new_reason = priv->queued_state.reason;
|
|
|
|
|
nm_device_queued_state_clear (self);
|
|
|
|
|
|
|
|
|
|
nm_device_state_changed (self, new_state, new_reason);
|
2013-08-13 17:45:34 -04:00
|
|
|
nm_device_remove_pending_action (self, "queued state change");
|
2012-11-14 18:00:22 -06:00
|
|
|
} else {
|
|
|
|
|
g_warn_if_fail (priv->queued_state.state == NM_DEVICE_STATE_UNKNOWN);
|
|
|
|
|
g_warn_if_fail (priv->queued_state.reason == NM_DEVICE_STATE_REASON_NONE);
|
2011-12-08 11:46:58 -06:00
|
|
|
}
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
nm_device_queue_state (NMDevice *self,
|
|
|
|
|
NMDeviceState state,
|
|
|
|
|
NMDeviceStateReason reason)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (NM_IS_DEVICE (self));
|
|
|
|
|
|
|
|
|
|
priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
/* We should only ever have one delayed state transition at a time */
|
|
|
|
|
if (priv->queued_state.id) {
|
2013-06-19 14:56:26 -04:00
|
|
|
if (priv->queued_state.state == state)
|
|
|
|
|
return;
|
|
|
|
|
nm_log_warn (LOGD_DEVICE, "(%s): overwriting previously queued state change to %s (%s)",
|
|
|
|
|
nm_device_get_iface (self),
|
|
|
|
|
state_to_string (priv->queued_state.state),
|
|
|
|
|
reason_to_string (priv->queued_state.reason));
|
2012-08-30 15:59:31 -05:00
|
|
|
nm_device_queued_state_clear (self);
|
2011-12-08 11:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
priv->queued_state.state = state;
|
|
|
|
|
priv->queued_state.reason = reason;
|
|
|
|
|
priv->queued_state.id = g_idle_add (queued_set_state, self);
|
2013-08-13 17:45:34 -04:00
|
|
|
nm_device_add_pending_action (self, "queued state change");
|
2011-12-08 11:46:58 -06:00
|
|
|
|
2013-06-19 14:56:26 -04:00
|
|
|
nm_log_dbg (LOGD_DEVICE, "(%s): queued state change to %s due to %s (id %d)",
|
|
|
|
|
nm_device_get_iface (self), state_to_string (state), reason_to_string (reason),
|
2011-12-08 11:46:58 -06:00
|
|
|
priv->queued_state.id);
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-30 15:59:31 -05:00
|
|
|
NMDeviceState
|
|
|
|
|
nm_device_queued_state_peek (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (self), NM_DEVICE_STATE_UNKNOWN);
|
|
|
|
|
|
|
|
|
|
priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
return priv->queued_state.id ? priv->queued_state.state : NM_DEVICE_STATE_UNKNOWN;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
nm_device_queued_state_clear (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
if (priv->queued_state.id) {
|
|
|
|
|
nm_log_dbg (LOGD_DEVICE, "(%s): clearing queued state transition (id %d)",
|
|
|
|
|
nm_device_get_iface (self), priv->queued_state.id);
|
|
|
|
|
g_source_remove (priv->queued_state.id);
|
2013-08-13 17:45:34 -04:00
|
|
|
nm_device_remove_pending_action (self, "queued state change");
|
2012-08-30 15:59:31 -05:00
|
|
|
}
|
|
|
|
|
memset (&priv->queued_state, 0, sizeof (priv->queued_state));
|
|
|
|
|
}
|
|
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
NMDeviceState
|
|
|
|
|
nm_device_get_state (NMDevice *device)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (device), NM_DEVICE_STATE_UNKNOWN);
|
|
|
|
|
|
|
|
|
|
return NM_DEVICE_GET_PRIVATE (device)->state;
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
2008-04-07 Dan Williams <dcbw@redhat.com>
* include/NetworkManager.h
- Remove the DOWN and CANCELLED device states
- Add UNMANAGED and UNAVAILABLE device states
- Document the device states
* introspection/nm-device.xml
src/nm-device-interface.c
src/nm-device-interface.h
- Add the 'managed' property
* test/nm-tool.c
- (detail_device): print out device state
* src/NetworkManagerSystem.h
src/backends/NetworkManagerArch.c
src/backends/NetworkManagerDebian.c
src/backends/NetworkManagerFrugalware.c
src/backends/NetworkManagerGentoo.c
src/backends/NetworkManagerMandriva.c
src/backends/NetworkManagerPaldo.c
src/backends/NetworkManagerRedHat.c
src/backends/NetworkManagerSlackware.c
src/backends/NetworkManagerSuSE.c
- (nm_system_device_get_system_config, nm_system_device_get_disabled
nm_system_device_free_system_config): remove; they were unused and
their functionality should be re-implemented in each distro's
system settings service plugin
* src/nm-gsm-device.c
src/nm-gsm-device.h
src/nm-cdma-device.c
src/nm-cdma-device.h
- (*_new): take the 'managed' argument
* src/nm-device.c
- (nm_device_set_address): remove, fold into nm_device_bring_up()
- (nm_device_init): start in unmanaged state, not disconnected
- (constructor): don't start device until the system settings service
has had a chance to figure out if the device is managed or not
- (nm_device_deactivate, nm_device_bring_up, nm_device_bring_down):
don't set device state here, let callers handle that as appropriate
- (nm_device_dispose): don't touch the device if it's not managed
- (set_property, get_property, nm_device_class_init): implement the
'managed' property
- (nm_device_state_changed): bring the device up if its now managed,
and deactivate it if it used to be active
- (nm_device_get_managed, nm_device_set_managed): do the right thing
with the managed state
* src/nm-hal-manager.c
- (wired_device_creator, wireless_device_creator, modem_device_creator):
take initial managed state and pass it along to device constructors
- (create_device_and_add_to_list): get managed state and pass to
type creators
* src/nm-device-802-11-wireless.c
- (real_can_activate): fold in most of
nm_device_802_11_wireless_can_activate()
- (can_scan): can't scan in UNAVAILABLE or UNMANAGED
- (link_timeout_cb): instead of deactivating, change device state and
let the device state handler to it
- (real_update_hw_address): clean up
- (state_changed_cb): when entering UNAVAILABLE state, schedule an idle
handler to transition to DISCONNECTED if the device isn't rfkilled
* src/nm-device-802-3-ethernet.c
- (set_carrier): move above callers and get rid of prototype
- (device_state_changed): when entering UNAVAILABLE state, schedule an
idle handler to transition to DISCONNECTED if the device has a
carrier
- (real_update_hw_address): clean up
- (link_timeout_cb, ppp_state_changed): change state instead of calling
deactivation directly as deactivation doesn't change state anymore
* src/NetworkManagerPolicy.c
- (schedule_activate_check): yay, remove wireless_enabled hack since
the NMManager and wireless devices work that out themselves now
- (device_state_changed): change to a switch and update for new device
states
- (device_carrier_changed): remove; device handles this now through
state changes
- (device_added): don't care about carrier any more; the initial
activation check will happen when the device transitions to
DISCONNECTED
* src/nm-manager.c
- (dispose): clear unmanaged devices
- (handle_unmanaged_devices): update unmanaged device list and toggle
the managed property on each device when needed
- (system_settings_properties_changed_cb): handle signals from the
system settings service
- (system_settings_get_unmanaged_devices_cb): handle callback from
getting the unmanaged device list method call
- (query_unmanaged_devices): ask the system settings service for its
list of unmanaged devices
- (nm_manager_name_owner_changed, initial_get_connections): get unmanaged
devices
- (manager_set_wireless_enabled): push rfkill state down to wireless
devices directly and let them handle the necessary state transitions
- (manager_device_state_changed): update for new device states
- (nm_manager_add_device): set initial rfkill state on wireless devices
- (nm_manager_remove_device): don't touch the device if it's unmanaged
- (nm_manager_activate_connection): return error if the device is
unmanaged
- (nm_manager_sleep): handle new device states correctly; don't change
the state of unavailable/unmanaged devices
* libnm-glib/nm-device-802-11-wireless.c
- (state_changed_cb): update for new device states
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3540 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 02:58:02 +00:00
|
|
|
|
2013-04-04 10:20:24 -04:00
|
|
|
static void
|
|
|
|
|
update_ip_config (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
NMDeviceStateReason ignored = NM_DEVICE_STATE_REASON_NONE;
|
2013-08-01 15:44:53 -05:00
|
|
|
NMIP6Config *ip6_config = NULL;
|
2013-04-04 10:20:24 -04:00
|
|
|
int ifindex;
|
|
|
|
|
|
|
|
|
|
ifindex = nm_device_get_ip_ifindex (self);
|
|
|
|
|
if (!ifindex)
|
|
|
|
|
return;
|
|
|
|
|
|
2013-08-01 15:44:53 -05:00
|
|
|
g_clear_object (&priv->ext_ip4_config);
|
|
|
|
|
priv->ext_ip4_config = nm_ip4_config_capture (ifindex);
|
|
|
|
|
if (priv->dev_ip4_config)
|
|
|
|
|
nm_ip4_config_subtract (priv->ext_ip4_config, priv->dev_ip4_config);
|
|
|
|
|
if (priv->vpn4_config)
|
|
|
|
|
nm_ip4_config_subtract (priv->ext_ip4_config, priv->vpn4_config);
|
2013-04-04 10:20:24 -04:00
|
|
|
|
2013-08-01 15:44:53 -05:00
|
|
|
ip4_config_merge_and_apply (self, NULL, FALSE, NULL);
|
2013-04-04 10:20:24 -04:00
|
|
|
|
2013-08-01 15:44:53 -05:00
|
|
|
ip6_config = nm_ip6_config_capture (ifindex);
|
|
|
|
|
nm_device_set_ip6_config (self, ip6_config, FALSE, &ignored);
|
|
|
|
|
g_clear_object (&ip6_config);
|
2013-04-04 10:20:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
queued_ip_config_change (gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMDevice *self = NM_DEVICE (user_data);
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
/* Wait for any queued state changes */
|
|
|
|
|
if (priv->queued_state.id)
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
priv->queued_ip_config_id = 0;
|
|
|
|
|
update_ip_config (self);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2013-08-02 18:51:06 +02:00
|
|
|
device_ip_changed (NMPlatform *platform, int ifindex, gpointer platform_object, NMPlatformReason reason, gpointer user_data)
|
2013-04-04 10:20:24 -04:00
|
|
|
{
|
|
|
|
|
NMDevice *self = user_data;
|
|
|
|
|
|
|
|
|
|
if (nm_device_get_ip_ifindex (self) == ifindex) {
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
if (!priv->queued_ip_config_id)
|
|
|
|
|
priv->queued_ip_config_id = g_idle_add (queued_ip_config_change, self);
|
|
|
|
|
|
|
|
|
|
nm_log_dbg (LOGD_DEVICE, "(%s): queued IP config change",
|
|
|
|
|
nm_device_get_iface (self));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
nm_device_queued_ip_config_change_clear (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
if (priv->queued_ip_config_id) {
|
|
|
|
|
nm_log_dbg (LOGD_DEVICE, "(%s): clearing queued IP config change",
|
|
|
|
|
nm_device_get_iface (self));
|
|
|
|
|
g_source_remove (priv->queued_ip_config_id);
|
|
|
|
|
priv->queued_ip_config_id = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-04-07 Dan Williams <dcbw@redhat.com>
* include/NetworkManager.h
- Remove the DOWN and CANCELLED device states
- Add UNMANAGED and UNAVAILABLE device states
- Document the device states
* introspection/nm-device.xml
src/nm-device-interface.c
src/nm-device-interface.h
- Add the 'managed' property
* test/nm-tool.c
- (detail_device): print out device state
* src/NetworkManagerSystem.h
src/backends/NetworkManagerArch.c
src/backends/NetworkManagerDebian.c
src/backends/NetworkManagerFrugalware.c
src/backends/NetworkManagerGentoo.c
src/backends/NetworkManagerMandriva.c
src/backends/NetworkManagerPaldo.c
src/backends/NetworkManagerRedHat.c
src/backends/NetworkManagerSlackware.c
src/backends/NetworkManagerSuSE.c
- (nm_system_device_get_system_config, nm_system_device_get_disabled
nm_system_device_free_system_config): remove; they were unused and
their functionality should be re-implemented in each distro's
system settings service plugin
* src/nm-gsm-device.c
src/nm-gsm-device.h
src/nm-cdma-device.c
src/nm-cdma-device.h
- (*_new): take the 'managed' argument
* src/nm-device.c
- (nm_device_set_address): remove, fold into nm_device_bring_up()
- (nm_device_init): start in unmanaged state, not disconnected
- (constructor): don't start device until the system settings service
has had a chance to figure out if the device is managed or not
- (nm_device_deactivate, nm_device_bring_up, nm_device_bring_down):
don't set device state here, let callers handle that as appropriate
- (nm_device_dispose): don't touch the device if it's not managed
- (set_property, get_property, nm_device_class_init): implement the
'managed' property
- (nm_device_state_changed): bring the device up if its now managed,
and deactivate it if it used to be active
- (nm_device_get_managed, nm_device_set_managed): do the right thing
with the managed state
* src/nm-hal-manager.c
- (wired_device_creator, wireless_device_creator, modem_device_creator):
take initial managed state and pass it along to device constructors
- (create_device_and_add_to_list): get managed state and pass to
type creators
* src/nm-device-802-11-wireless.c
- (real_can_activate): fold in most of
nm_device_802_11_wireless_can_activate()
- (can_scan): can't scan in UNAVAILABLE or UNMANAGED
- (link_timeout_cb): instead of deactivating, change device state and
let the device state handler to it
- (real_update_hw_address): clean up
- (state_changed_cb): when entering UNAVAILABLE state, schedule an idle
handler to transition to DISCONNECTED if the device isn't rfkilled
* src/nm-device-802-3-ethernet.c
- (set_carrier): move above callers and get rid of prototype
- (device_state_changed): when entering UNAVAILABLE state, schedule an
idle handler to transition to DISCONNECTED if the device has a
carrier
- (real_update_hw_address): clean up
- (link_timeout_cb, ppp_state_changed): change state instead of calling
deactivation directly as deactivation doesn't change state anymore
* src/NetworkManagerPolicy.c
- (schedule_activate_check): yay, remove wireless_enabled hack since
the NMManager and wireless devices work that out themselves now
- (device_state_changed): change to a switch and update for new device
states
- (device_carrier_changed): remove; device handles this now through
state changes
- (device_added): don't care about carrier any more; the initial
activation check will happen when the device transitions to
DISCONNECTED
* src/nm-manager.c
- (dispose): clear unmanaged devices
- (handle_unmanaged_devices): update unmanaged device list and toggle
the managed property on each device when needed
- (system_settings_properties_changed_cb): handle signals from the
system settings service
- (system_settings_get_unmanaged_devices_cb): handle callback from
getting the unmanaged device list method call
- (query_unmanaged_devices): ask the system settings service for its
list of unmanaged devices
- (nm_manager_name_owner_changed, initial_get_connections): get unmanaged
devices
- (manager_set_wireless_enabled): push rfkill state down to wireless
devices directly and let them handle the necessary state transitions
- (manager_device_state_changed): update for new device states
- (nm_manager_add_device): set initial rfkill state on wireless devices
- (nm_manager_remove_device): don't touch the device if it's unmanaged
- (nm_manager_activate_connection): return error if the device is
unmanaged
- (nm_manager_sleep): handle new device states correctly; don't change
the state of unavailable/unmanaged devices
* libnm-glib/nm-device-802-11-wireless.c
- (state_changed_cb): update for new device states
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3540 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 02:58:02 +00:00
|
|
|
gboolean
|
|
|
|
|
nm_device_get_managed (NMDevice *device)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv;
|
|
|
|
|
|
2013-04-24 10:40:58 -04:00
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (device), FALSE);
|
2008-04-07 Dan Williams <dcbw@redhat.com>
* include/NetworkManager.h
- Remove the DOWN and CANCELLED device states
- Add UNMANAGED and UNAVAILABLE device states
- Document the device states
* introspection/nm-device.xml
src/nm-device-interface.c
src/nm-device-interface.h
- Add the 'managed' property
* test/nm-tool.c
- (detail_device): print out device state
* src/NetworkManagerSystem.h
src/backends/NetworkManagerArch.c
src/backends/NetworkManagerDebian.c
src/backends/NetworkManagerFrugalware.c
src/backends/NetworkManagerGentoo.c
src/backends/NetworkManagerMandriva.c
src/backends/NetworkManagerPaldo.c
src/backends/NetworkManagerRedHat.c
src/backends/NetworkManagerSlackware.c
src/backends/NetworkManagerSuSE.c
- (nm_system_device_get_system_config, nm_system_device_get_disabled
nm_system_device_free_system_config): remove; they were unused and
their functionality should be re-implemented in each distro's
system settings service plugin
* src/nm-gsm-device.c
src/nm-gsm-device.h
src/nm-cdma-device.c
src/nm-cdma-device.h
- (*_new): take the 'managed' argument
* src/nm-device.c
- (nm_device_set_address): remove, fold into nm_device_bring_up()
- (nm_device_init): start in unmanaged state, not disconnected
- (constructor): don't start device until the system settings service
has had a chance to figure out if the device is managed or not
- (nm_device_deactivate, nm_device_bring_up, nm_device_bring_down):
don't set device state here, let callers handle that as appropriate
- (nm_device_dispose): don't touch the device if it's not managed
- (set_property, get_property, nm_device_class_init): implement the
'managed' property
- (nm_device_state_changed): bring the device up if its now managed,
and deactivate it if it used to be active
- (nm_device_get_managed, nm_device_set_managed): do the right thing
with the managed state
* src/nm-hal-manager.c
- (wired_device_creator, wireless_device_creator, modem_device_creator):
take initial managed state and pass it along to device constructors
- (create_device_and_add_to_list): get managed state and pass to
type creators
* src/nm-device-802-11-wireless.c
- (real_can_activate): fold in most of
nm_device_802_11_wireless_can_activate()
- (can_scan): can't scan in UNAVAILABLE or UNMANAGED
- (link_timeout_cb): instead of deactivating, change device state and
let the device state handler to it
- (real_update_hw_address): clean up
- (state_changed_cb): when entering UNAVAILABLE state, schedule an idle
handler to transition to DISCONNECTED if the device isn't rfkilled
* src/nm-device-802-3-ethernet.c
- (set_carrier): move above callers and get rid of prototype
- (device_state_changed): when entering UNAVAILABLE state, schedule an
idle handler to transition to DISCONNECTED if the device has a
carrier
- (real_update_hw_address): clean up
- (link_timeout_cb, ppp_state_changed): change state instead of calling
deactivation directly as deactivation doesn't change state anymore
* src/NetworkManagerPolicy.c
- (schedule_activate_check): yay, remove wireless_enabled hack since
the NMManager and wireless devices work that out themselves now
- (device_state_changed): change to a switch and update for new device
states
- (device_carrier_changed): remove; device handles this now through
state changes
- (device_added): don't care about carrier any more; the initial
activation check will happen when the device transitions to
DISCONNECTED
* src/nm-manager.c
- (dispose): clear unmanaged devices
- (handle_unmanaged_devices): update unmanaged device list and toggle
the managed property on each device when needed
- (system_settings_properties_changed_cb): handle signals from the
system settings service
- (system_settings_get_unmanaged_devices_cb): handle callback from
getting the unmanaged device list method call
- (query_unmanaged_devices): ask the system settings service for its
list of unmanaged devices
- (nm_manager_name_owner_changed, initial_get_connections): get unmanaged
devices
- (manager_set_wireless_enabled): push rfkill state down to wireless
devices directly and let them handle the necessary state transitions
- (manager_device_state_changed): update for new device states
- (nm_manager_add_device): set initial rfkill state on wireless devices
- (nm_manager_remove_device): don't touch the device if it's unmanaged
- (nm_manager_activate_connection): return error if the device is
unmanaged
- (nm_manager_sleep): handle new device states correctly; don't change
the state of unavailable/unmanaged devices
* libnm-glib/nm-device-802-11-wireless.c
- (state_changed_cb): update for new device states
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3540 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 02:58:02 +00:00
|
|
|
|
|
|
|
|
priv = NM_DEVICE_GET_PRIVATE (device);
|
|
|
|
|
|
2013-04-24 10:40:58 -04:00
|
|
|
if (!priv->manager_managed)
|
|
|
|
|
return FALSE;
|
|
|
|
|
else if (priv->default_unmanaged)
|
|
|
|
|
return (priv->state != NM_DEVICE_STATE_UNMANAGED);
|
|
|
|
|
else
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
nm_device_set_managed_internal (NMDevice *device,
|
|
|
|
|
gboolean managed,
|
|
|
|
|
NMDeviceStateReason reason)
|
|
|
|
|
{
|
2013-01-21 17:57:50 -06:00
|
|
|
nm_log_dbg (LOGD_DEVICE, "(%s): now %s",
|
|
|
|
|
nm_device_get_iface (device),
|
|
|
|
|
managed ? "managed" : "unmanaged");
|
2008-04-07 Dan Williams <dcbw@redhat.com>
* include/NetworkManager.h
- Remove the DOWN and CANCELLED device states
- Add UNMANAGED and UNAVAILABLE device states
- Document the device states
* introspection/nm-device.xml
src/nm-device-interface.c
src/nm-device-interface.h
- Add the 'managed' property
* test/nm-tool.c
- (detail_device): print out device state
* src/NetworkManagerSystem.h
src/backends/NetworkManagerArch.c
src/backends/NetworkManagerDebian.c
src/backends/NetworkManagerFrugalware.c
src/backends/NetworkManagerGentoo.c
src/backends/NetworkManagerMandriva.c
src/backends/NetworkManagerPaldo.c
src/backends/NetworkManagerRedHat.c
src/backends/NetworkManagerSlackware.c
src/backends/NetworkManagerSuSE.c
- (nm_system_device_get_system_config, nm_system_device_get_disabled
nm_system_device_free_system_config): remove; they were unused and
their functionality should be re-implemented in each distro's
system settings service plugin
* src/nm-gsm-device.c
src/nm-gsm-device.h
src/nm-cdma-device.c
src/nm-cdma-device.h
- (*_new): take the 'managed' argument
* src/nm-device.c
- (nm_device_set_address): remove, fold into nm_device_bring_up()
- (nm_device_init): start in unmanaged state, not disconnected
- (constructor): don't start device until the system settings service
has had a chance to figure out if the device is managed or not
- (nm_device_deactivate, nm_device_bring_up, nm_device_bring_down):
don't set device state here, let callers handle that as appropriate
- (nm_device_dispose): don't touch the device if it's not managed
- (set_property, get_property, nm_device_class_init): implement the
'managed' property
- (nm_device_state_changed): bring the device up if its now managed,
and deactivate it if it used to be active
- (nm_device_get_managed, nm_device_set_managed): do the right thing
with the managed state
* src/nm-hal-manager.c
- (wired_device_creator, wireless_device_creator, modem_device_creator):
take initial managed state and pass it along to device constructors
- (create_device_and_add_to_list): get managed state and pass to
type creators
* src/nm-device-802-11-wireless.c
- (real_can_activate): fold in most of
nm_device_802_11_wireless_can_activate()
- (can_scan): can't scan in UNAVAILABLE or UNMANAGED
- (link_timeout_cb): instead of deactivating, change device state and
let the device state handler to it
- (real_update_hw_address): clean up
- (state_changed_cb): when entering UNAVAILABLE state, schedule an idle
handler to transition to DISCONNECTED if the device isn't rfkilled
* src/nm-device-802-3-ethernet.c
- (set_carrier): move above callers and get rid of prototype
- (device_state_changed): when entering UNAVAILABLE state, schedule an
idle handler to transition to DISCONNECTED if the device has a
carrier
- (real_update_hw_address): clean up
- (link_timeout_cb, ppp_state_changed): change state instead of calling
deactivation directly as deactivation doesn't change state anymore
* src/NetworkManagerPolicy.c
- (schedule_activate_check): yay, remove wireless_enabled hack since
the NMManager and wireless devices work that out themselves now
- (device_state_changed): change to a switch and update for new device
states
- (device_carrier_changed): remove; device handles this now through
state changes
- (device_added): don't care about carrier any more; the initial
activation check will happen when the device transitions to
DISCONNECTED
* src/nm-manager.c
- (dispose): clear unmanaged devices
- (handle_unmanaged_devices): update unmanaged device list and toggle
the managed property on each device when needed
- (system_settings_properties_changed_cb): handle signals from the
system settings service
- (system_settings_get_unmanaged_devices_cb): handle callback from
getting the unmanaged device list method call
- (query_unmanaged_devices): ask the system settings service for its
list of unmanaged devices
- (nm_manager_name_owner_changed, initial_get_connections): get unmanaged
devices
- (manager_set_wireless_enabled): push rfkill state down to wireless
devices directly and let them handle the necessary state transitions
- (manager_device_state_changed): update for new device states
- (nm_manager_add_device): set initial rfkill state on wireless devices
- (nm_manager_remove_device): don't touch the device if it's unmanaged
- (nm_manager_activate_connection): return error if the device is
unmanaged
- (nm_manager_sleep): handle new device states correctly; don't change
the state of unavailable/unmanaged devices
* libnm-glib/nm-device-802-11-wireless.c
- (state_changed_cb): update for new device states
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3540 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 02:58:02 +00:00
|
|
|
|
2011-11-18 00:34:08 -06:00
|
|
|
g_object_notify (G_OBJECT (device), NM_DEVICE_MANAGED);
|
2008-04-22 19:07:00 +00:00
|
|
|
|
2008-07-11 10:28:53 +00:00
|
|
|
if (managed)
|
2008-10-11 19:57:45 +00:00
|
|
|
nm_device_state_changed (device, NM_DEVICE_STATE_UNAVAILABLE, reason);
|
2008-07-11 10:28:53 +00:00
|
|
|
else
|
2008-10-11 19:57:45 +00:00
|
|
|
nm_device_state_changed (device, NM_DEVICE_STATE_UNMANAGED, reason);
|
2008-04-07 Dan Williams <dcbw@redhat.com>
* include/NetworkManager.h
- Remove the DOWN and CANCELLED device states
- Add UNMANAGED and UNAVAILABLE device states
- Document the device states
* introspection/nm-device.xml
src/nm-device-interface.c
src/nm-device-interface.h
- Add the 'managed' property
* test/nm-tool.c
- (detail_device): print out device state
* src/NetworkManagerSystem.h
src/backends/NetworkManagerArch.c
src/backends/NetworkManagerDebian.c
src/backends/NetworkManagerFrugalware.c
src/backends/NetworkManagerGentoo.c
src/backends/NetworkManagerMandriva.c
src/backends/NetworkManagerPaldo.c
src/backends/NetworkManagerRedHat.c
src/backends/NetworkManagerSlackware.c
src/backends/NetworkManagerSuSE.c
- (nm_system_device_get_system_config, nm_system_device_get_disabled
nm_system_device_free_system_config): remove; they were unused and
their functionality should be re-implemented in each distro's
system settings service plugin
* src/nm-gsm-device.c
src/nm-gsm-device.h
src/nm-cdma-device.c
src/nm-cdma-device.h
- (*_new): take the 'managed' argument
* src/nm-device.c
- (nm_device_set_address): remove, fold into nm_device_bring_up()
- (nm_device_init): start in unmanaged state, not disconnected
- (constructor): don't start device until the system settings service
has had a chance to figure out if the device is managed or not
- (nm_device_deactivate, nm_device_bring_up, nm_device_bring_down):
don't set device state here, let callers handle that as appropriate
- (nm_device_dispose): don't touch the device if it's not managed
- (set_property, get_property, nm_device_class_init): implement the
'managed' property
- (nm_device_state_changed): bring the device up if its now managed,
and deactivate it if it used to be active
- (nm_device_get_managed, nm_device_set_managed): do the right thing
with the managed state
* src/nm-hal-manager.c
- (wired_device_creator, wireless_device_creator, modem_device_creator):
take initial managed state and pass it along to device constructors
- (create_device_and_add_to_list): get managed state and pass to
type creators
* src/nm-device-802-11-wireless.c
- (real_can_activate): fold in most of
nm_device_802_11_wireless_can_activate()
- (can_scan): can't scan in UNAVAILABLE or UNMANAGED
- (link_timeout_cb): instead of deactivating, change device state and
let the device state handler to it
- (real_update_hw_address): clean up
- (state_changed_cb): when entering UNAVAILABLE state, schedule an idle
handler to transition to DISCONNECTED if the device isn't rfkilled
* src/nm-device-802-3-ethernet.c
- (set_carrier): move above callers and get rid of prototype
- (device_state_changed): when entering UNAVAILABLE state, schedule an
idle handler to transition to DISCONNECTED if the device has a
carrier
- (real_update_hw_address): clean up
- (link_timeout_cb, ppp_state_changed): change state instead of calling
deactivation directly as deactivation doesn't change state anymore
* src/NetworkManagerPolicy.c
- (schedule_activate_check): yay, remove wireless_enabled hack since
the NMManager and wireless devices work that out themselves now
- (device_state_changed): change to a switch and update for new device
states
- (device_carrier_changed): remove; device handles this now through
state changes
- (device_added): don't care about carrier any more; the initial
activation check will happen when the device transitions to
DISCONNECTED
* src/nm-manager.c
- (dispose): clear unmanaged devices
- (handle_unmanaged_devices): update unmanaged device list and toggle
the managed property on each device when needed
- (system_settings_properties_changed_cb): handle signals from the
system settings service
- (system_settings_get_unmanaged_devices_cb): handle callback from
getting the unmanaged device list method call
- (query_unmanaged_devices): ask the system settings service for its
list of unmanaged devices
- (nm_manager_name_owner_changed, initial_get_connections): get unmanaged
devices
- (manager_set_wireless_enabled): push rfkill state down to wireless
devices directly and let them handle the necessary state transitions
- (manager_device_state_changed): update for new device states
- (nm_manager_add_device): set initial rfkill state on wireless devices
- (nm_manager_remove_device): don't touch the device if it's unmanaged
- (nm_manager_activate_connection): return error if the device is
unmanaged
- (nm_manager_sleep): handle new device states correctly; don't change
the state of unavailable/unmanaged devices
* libnm-glib/nm-device-802-11-wireless.c
- (state_changed_cb): update for new device states
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3540 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 02:58:02 +00:00
|
|
|
}
|
|
|
|
|
|
2013-04-24 10:40:58 -04:00
|
|
|
void
|
|
|
|
|
nm_device_set_manager_managed (NMDevice *device,
|
|
|
|
|
gboolean managed,
|
|
|
|
|
NMDeviceStateReason reason)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv;
|
|
|
|
|
gboolean was_managed, now_managed;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (NM_IS_DEVICE (device));
|
|
|
|
|
|
|
|
|
|
priv = NM_DEVICE_GET_PRIVATE (device);
|
|
|
|
|
|
|
|
|
|
was_managed = nm_device_get_managed (device);
|
|
|
|
|
priv->manager_managed = managed;
|
|
|
|
|
now_managed = nm_device_get_managed (device);
|
|
|
|
|
|
|
|
|
|
if (was_managed != now_managed)
|
|
|
|
|
nm_device_set_managed_internal (device, now_managed, reason);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
nm_device_set_default_unmanaged (NMDevice *device,
|
|
|
|
|
gboolean default_unmanaged)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv;
|
|
|
|
|
gboolean was_managed, now_managed;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (NM_IS_DEVICE (device));
|
|
|
|
|
|
|
|
|
|
priv = NM_DEVICE_GET_PRIVATE (device);
|
|
|
|
|
|
|
|
|
|
was_managed = nm_device_get_managed (device);
|
|
|
|
|
priv->default_unmanaged = default_unmanaged;
|
|
|
|
|
now_managed = nm_device_get_managed (device);
|
|
|
|
|
|
|
|
|
|
if (was_managed != now_managed)
|
|
|
|
|
nm_device_set_managed_internal (device, now_managed,
|
|
|
|
|
default_unmanaged ? NM_DEVICE_STATE_REASON_NOW_UNMANAGED :
|
|
|
|
|
NM_DEVICE_STATE_REASON_NOW_MANAGED);
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-13 13:52:55 -04:00
|
|
|
/**
|
|
|
|
|
* nm_device_spec_match_list:
|
|
|
|
|
* @device: an #NMDevice
|
|
|
|
|
* @specs: (element-type utf8): a list of device specs
|
|
|
|
|
*
|
|
|
|
|
* Checks if @device matches any of the specifications in @specs. The
|
|
|
|
|
* currently-supported spec types are:
|
|
|
|
|
*
|
|
|
|
|
* "mac:00:11:22:33:44:55" - matches a device with the given
|
|
|
|
|
* hardware address
|
|
|
|
|
*
|
|
|
|
|
* "interface-name:foo0" - matches a device with the given
|
|
|
|
|
* interface name
|
|
|
|
|
*
|
|
|
|
|
* "s390-subchannels:00.11.22" - matches a device with the given
|
|
|
|
|
* z/VM / s390 subchannels.
|
|
|
|
|
*
|
2013-03-20 09:48:24 -04:00
|
|
|
* "*" - matches any device
|
|
|
|
|
*
|
2013-03-13 13:52:55 -04:00
|
|
|
* Returns: #TRUE if @device matches one of the specs in @specs
|
|
|
|
|
*/
|
2011-11-17 23:16:50 -06:00
|
|
|
gboolean
|
|
|
|
|
nm_device_spec_match_list (NMDevice *device, const GSList *specs)
|
2009-06-11 00:39:12 -04:00
|
|
|
{
|
2011-11-17 23:16:50 -06:00
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (device), FALSE);
|
2009-06-11 00:39:12 -04:00
|
|
|
|
2013-03-20 09:48:24 -04:00
|
|
|
return NM_DEVICE_GET_CLASS (device)->spec_match_list (device, specs);
|
2009-06-11 00:39:12 -04:00
|
|
|
}
|
|
|
|
|
|
2013-02-12 17:59:37 -05:00
|
|
|
static gboolean
|
|
|
|
|
spec_match_list (NMDevice *device, const GSList *specs)
|
|
|
|
|
{
|
2013-05-01 09:28:16 -04:00
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
|
2013-02-12 17:59:37 -05:00
|
|
|
char *hwaddr_str;
|
2013-03-25 15:17:35 -05:00
|
|
|
gboolean matched = FALSE;
|
2013-02-12 17:59:37 -05:00
|
|
|
|
2013-03-20 09:48:24 -04:00
|
|
|
if (nm_match_spec_string (specs, "*"))
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
2013-05-01 09:28:16 -04:00
|
|
|
if (priv->hw_addr_len) {
|
2013-06-05 17:41:11 -03:00
|
|
|
hwaddr_str = nm_utils_hwaddr_ntoa_len (priv->hw_addr, priv->hw_addr_len);
|
2013-03-25 15:17:35 -05:00
|
|
|
matched = nm_match_spec_hwaddr (specs, hwaddr_str);
|
|
|
|
|
g_free (hwaddr_str);
|
|
|
|
|
}
|
2013-02-12 17:59:37 -05:00
|
|
|
|
2013-02-12 18:00:48 -05:00
|
|
|
if (!matched)
|
|
|
|
|
matched = nm_match_spec_interface_name (specs, nm_device_get_iface (device));
|
|
|
|
|
|
2013-02-12 17:59:37 -05:00
|
|
|
return matched;
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-22 23:46:23 -06:00
|
|
|
static gboolean
|
|
|
|
|
ip4_match_config (NMDevice *self, NMConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
NMSettingIP4Config *s_ip4;
|
|
|
|
|
int i, num;
|
|
|
|
|
GSList *leases, *iter;
|
|
|
|
|
NMDHCPManager *dhcp_mgr;
|
|
|
|
|
const char *method;
|
|
|
|
|
|
|
|
|
|
s_ip4 = nm_connection_get_setting_ip4_config (connection);
|
|
|
|
|
|
|
|
|
|
/* Get any saved leases that apply to this connection */
|
|
|
|
|
dhcp_mgr = nm_dhcp_manager_get ();
|
|
|
|
|
leases = nm_dhcp_manager_get_lease_config (dhcp_mgr,
|
|
|
|
|
nm_device_get_iface (self),
|
2012-08-22 22:39:49 +02:00
|
|
|
nm_connection_get_uuid (connection),
|
|
|
|
|
FALSE);
|
2012-02-22 23:46:23 -06:00
|
|
|
g_object_unref (dhcp_mgr);
|
|
|
|
|
|
2012-06-19 18:45:49 +02:00
|
|
|
method = s_ip4 ? nm_setting_ip4_config_get_method (s_ip4) : NM_SETTING_IP4_CONFIG_METHOD_AUTO;
|
2012-02-22 23:46:23 -06:00
|
|
|
if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO)) {
|
|
|
|
|
gboolean found = FALSE;
|
|
|
|
|
|
|
|
|
|
/* Find at least one lease's address on the device */
|
|
|
|
|
for (iter = leases; iter; iter = g_slist_next (iter)) {
|
|
|
|
|
NMIP4Config *ip4_config = iter->data;
|
2013-06-29 13:33:36 +02:00
|
|
|
const NMPlatformIP4Address *address = nm_ip4_config_get_address (ip4_config, 0);
|
2012-02-22 23:46:23 -06:00
|
|
|
|
2013-06-29 13:33:36 +02:00
|
|
|
if (address && nm_platform_ip4_address_exists (nm_device_get_ip_ifindex (self),
|
|
|
|
|
address->address,
|
|
|
|
|
address->plen)) {
|
2012-02-22 23:46:23 -06:00
|
|
|
found = TRUE; /* Yay, device has same address as a lease */
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
g_slist_foreach (leases, (GFunc) g_object_unref, NULL);
|
|
|
|
|
g_slist_free (leases);
|
|
|
|
|
return found;
|
|
|
|
|
} else {
|
|
|
|
|
/* Maybe the connection used to be DHCP and there are stale leases; ignore them */
|
|
|
|
|
g_slist_foreach (leases, (GFunc) g_object_unref, NULL);
|
|
|
|
|
g_slist_free (leases);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED)) {
|
|
|
|
|
// FIXME: Enforce no ipv4 addresses?
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 'shared' and 'link-local' aren't supported methods because 'shared'
|
|
|
|
|
* requires too much iptables and dnsmasq state to be reclaimed, and
|
|
|
|
|
* avahi-autoipd isn't smart enough to allow the link-local address to be
|
|
|
|
|
* determined at any point other than when it was first assigned.
|
|
|
|
|
*/
|
|
|
|
|
if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
/* Everything below for static addressing */
|
|
|
|
|
|
|
|
|
|
/* Find all IP4 addresses of this connection on the device */
|
2012-06-19 18:45:49 +02:00
|
|
|
if (s_ip4) {
|
|
|
|
|
num = nm_setting_ip4_config_get_num_addresses (s_ip4);
|
|
|
|
|
for (i = 0; i < num; i++) {
|
|
|
|
|
NMIP4Address *addr = nm_setting_ip4_config_get_address (s_ip4, i);
|
|
|
|
|
|
2013-03-04 11:53:11 +01:00
|
|
|
if (!nm_platform_ip4_address_exists (nm_device_get_ip_ifindex (self),
|
|
|
|
|
nm_ip4_address_get_address (addr),
|
|
|
|
|
nm_ip4_address_get_prefix (addr)))
|
2012-06-19 18:45:49 +02:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
2012-02-22 23:46:23 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Success; all the connection's static IP addresses are assigned to the device */
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-13 13:52:55 -04:00
|
|
|
/**
|
|
|
|
|
* nm_device_find_assumable_connection:
|
|
|
|
|
* @device: an #NMDevice
|
|
|
|
|
* @connections: (element-type NMConnection): a list of connections
|
|
|
|
|
*
|
|
|
|
|
* Searches @connections for one that matches the currently-configured
|
|
|
|
|
* state of @device (in both L2 and L3 configuration). That is, it
|
|
|
|
|
* looks for the connection such that if you activated that connection
|
|
|
|
|
* on @device, it would result in @device having the configuration
|
|
|
|
|
* that it has now. This is used at startup to attempt to match
|
|
|
|
|
* already-active devices with corresponding #NMConnections.
|
|
|
|
|
*
|
|
|
|
|
* Some device types (eg, Wi-Fi) and subtypes (eg, PPPoE) can't be
|
|
|
|
|
* matched reliably, so this will always fail for those devices.
|
|
|
|
|
*
|
|
|
|
|
* Returns: (transfer none): an #NMConnection that matches @device's
|
|
|
|
|
* current state, or %NULL if none match.
|
|
|
|
|
*/
|
2013-03-06 14:58:03 -05:00
|
|
|
NMConnection *
|
|
|
|
|
nm_device_find_assumable_connection (NMDevice *device, const GSList *connections)
|
2012-02-22 23:46:23 -06:00
|
|
|
{
|
2013-03-06 14:58:03 -05:00
|
|
|
const GSList *iter;
|
2012-02-22 23:46:23 -06:00
|
|
|
|
2013-03-06 14:58:03 -05:00
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
|
2012-02-22 23:46:23 -06:00
|
|
|
|
2013-03-06 14:58:03 -05:00
|
|
|
if (!NM_DEVICE_GET_CLASS (device)->match_l2_config)
|
|
|
|
|
return NULL;
|
2012-02-22 23:46:23 -06:00
|
|
|
|
2013-03-06 14:58:03 -05:00
|
|
|
for (iter = connections; iter; iter = iter->next) {
|
|
|
|
|
NMConnection *candidate = NM_CONNECTION (iter->data);
|
|
|
|
|
|
|
|
|
|
if (!nm_device_check_connection_compatible (device, candidate, NULL))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (!ip4_match_config (device, candidate))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
/* FIXME: match IPv6 config */
|
|
|
|
|
|
|
|
|
|
if (NM_DEVICE_GET_CLASS (device)->match_l2_config (device, candidate))
|
|
|
|
|
return candidate;
|
|
|
|
|
}
|
2009-08-03 17:15:03 -04:00
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-22 23:51:42 -06:00
|
|
|
/**
|
|
|
|
|
* nm_device_hwaddr_matches:
|
|
|
|
|
* @device: the device to use when matching the hardware address
|
|
|
|
|
* @connection: the connection which supplies the hardware address
|
|
|
|
|
* @other_hwaddr: if given, use this address instead of the device's actual
|
|
|
|
|
* hardware address
|
|
|
|
|
* @other_hwaddr_len: length in bytes of @other_hwaddr
|
|
|
|
|
* @fail_if_no_hwaddr: whether to fail the match if @connection does not contain
|
|
|
|
|
* a hardware address
|
|
|
|
|
*
|
|
|
|
|
* Matches a the devices hardware address (or @other_hwaddr if given) against
|
|
|
|
|
* the hardware-specific setting in @connection. Allows for device-agnostic
|
|
|
|
|
* hardware address matching without having to know the internal details of
|
|
|
|
|
* the connection and which settings are used by each device subclass.
|
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE if the @device 's hardware address or @other_hwaddr matches
|
|
|
|
|
* a hardware address in a hardware-specific setting in @connection
|
|
|
|
|
*/
|
2012-02-12 13:54:09 -06:00
|
|
|
gboolean
|
|
|
|
|
nm_device_hwaddr_matches (NMDevice *device,
|
|
|
|
|
NMConnection *connection,
|
2012-02-22 23:51:42 -06:00
|
|
|
const guint8 *other_hwaddr,
|
|
|
|
|
guint other_hwaddr_len,
|
2012-02-12 13:54:09 -06:00
|
|
|
gboolean fail_if_no_hwaddr)
|
|
|
|
|
{
|
2013-05-01 09:28:16 -04:00
|
|
|
NMDevicePrivate *priv;
|
|
|
|
|
const GByteArray *setting_hwaddr;
|
|
|
|
|
|
2012-02-12 13:54:09 -06:00
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (device), FALSE);
|
2013-05-01 09:28:16 -04:00
|
|
|
priv = NM_DEVICE_GET_PRIVATE (device);
|
|
|
|
|
|
2012-02-22 23:51:42 -06:00
|
|
|
if (other_hwaddr)
|
2013-05-01 09:28:16 -04:00
|
|
|
g_return_val_if_fail (other_hwaddr_len != priv->hw_addr_len, FALSE);
|
|
|
|
|
|
|
|
|
|
if (!NM_DEVICE_GET_CLASS (device)->get_connection_hw_address)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
setting_hwaddr = NM_DEVICE_GET_CLASS (device)->get_connection_hw_address (device, connection);
|
|
|
|
|
if (setting_hwaddr) {
|
|
|
|
|
g_return_val_if_fail (setting_hwaddr->len == priv->hw_addr_len, FALSE);
|
|
|
|
|
|
|
|
|
|
if (other_hwaddr) {
|
|
|
|
|
if (memcmp (setting_hwaddr->data, other_hwaddr, priv->hw_addr_len) == 0)
|
|
|
|
|
return TRUE;
|
|
|
|
|
} else if (memcmp (setting_hwaddr->data, priv->hw_addr, priv->hw_addr_len) == 0)
|
|
|
|
|
return TRUE;
|
|
|
|
|
} else if (fail_if_no_hwaddr == FALSE)
|
|
|
|
|
return TRUE;
|
2012-02-22 23:51:42 -06:00
|
|
|
|
2012-02-12 13:54:09 -06:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-15 13:48:28 -04:00
|
|
|
void
|
2009-07-15 13:53:49 -04:00
|
|
|
nm_device_set_dhcp_timeout (NMDevice *device, guint32 timeout)
|
2009-07-15 13:48:28 -04:00
|
|
|
{
|
|
|
|
|
g_return_if_fail (NM_IS_DEVICE (device));
|
|
|
|
|
|
|
|
|
|
NM_DEVICE_GET_PRIVATE (device)->dhcp_timeout = timeout;
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-15 13:53:49 -04:00
|
|
|
void
|
|
|
|
|
nm_device_set_dhcp_anycast_address (NMDevice *device, guint8 *addr)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (NM_IS_DEVICE (device));
|
|
|
|
|
|
|
|
|
|
priv = NM_DEVICE_GET_PRIVATE (device);
|
|
|
|
|
|
|
|
|
|
if (priv->dhcp_anycast_address) {
|
|
|
|
|
g_byte_array_free (priv->dhcp_anycast_address, TRUE);
|
|
|
|
|
priv->dhcp_anycast_address = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (addr) {
|
|
|
|
|
priv->dhcp_anycast_address = g_byte_array_sized_new (ETH_ALEN);
|
|
|
|
|
g_byte_array_append (priv->dhcp_anycast_address, addr, ETH_ALEN);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-14 15:32:54 +02:00
|
|
|
gboolean
|
|
|
|
|
nm_device_get_autoconnect (NMDevice *device)
|
2009-09-16 13:18:24 +02:00
|
|
|
{
|
2012-05-14 15:32:54 +02:00
|
|
|
g_return_val_if_fail (NM_IS_DEVICE (device), FALSE);
|
|
|
|
|
|
|
|
|
|
return NM_DEVICE_GET_PRIVATE (device)->autoconnect;
|
2009-09-16 13:18:24 +02:00
|
|
|
}
|
|
|
|
|
|
2012-08-01 11:16:48 -06:00
|
|
|
static void
|
|
|
|
|
_signal_available_connections_changed (NMDevice *device)
|
|
|
|
|
{
|
|
|
|
|
g_object_notify (G_OBJECT (device), NM_DEVICE_AVAILABLE_CONNECTIONS);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
_clear_available_connections (NMDevice *device, gboolean do_signal)
|
|
|
|
|
{
|
|
|
|
|
g_hash_table_remove_all (NM_DEVICE_GET_PRIVATE (device)->available_connections);
|
|
|
|
|
if (do_signal == TRUE)
|
|
|
|
|
_signal_available_connections_changed (device);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
_try_add_available_connection (NMDevice *self, NMConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
if (nm_device_get_state (self) < NM_DEVICE_STATE_DISCONNECTED)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
if (nm_device_check_connection_compatible (self, connection, NULL)) {
|
|
|
|
|
/* Let subclasses implement additional checks on the connection */
|
|
|
|
|
if ( NM_DEVICE_GET_CLASS (self)->check_connection_available
|
|
|
|
|
&& NM_DEVICE_GET_CLASS (self)->check_connection_available (self, connection)) {
|
|
|
|
|
|
|
|
|
|
g_hash_table_insert (NM_DEVICE_GET_PRIVATE (self)->available_connections,
|
|
|
|
|
g_object_ref (connection),
|
|
|
|
|
GUINT_TO_POINTER (1));
|
2013-04-10 16:03:00 -05:00
|
|
|
return TRUE;
|
2012-08-01 11:16:48 -06:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
_del_available_connection (NMDevice *device, NMConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
return g_hash_table_remove (NM_DEVICE_GET_PRIVATE (device)->available_connections, connection);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
2012-09-27 12:12:15 -04:00
|
|
|
check_connection_available (NMDevice *device, NMConnection *connection)
|
2012-08-01 11:16:48 -06:00
|
|
|
{
|
|
|
|
|
/* Default is to assume the connection is available unless a subclass
|
|
|
|
|
* overrides this with more specific checks.
|
|
|
|
|
*/
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
nm_device_recheck_available_connections (NMDevice *device)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv;
|
|
|
|
|
const GSList *connections, *iter;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (NM_IS_DEVICE (device));
|
|
|
|
|
|
|
|
|
|
priv = NM_DEVICE_GET_PRIVATE(device);
|
|
|
|
|
|
|
|
|
|
_clear_available_connections (device, FALSE);
|
|
|
|
|
|
|
|
|
|
connections = nm_connection_provider_get_connections (priv->con_provider);
|
|
|
|
|
for (iter = connections; iter; iter = g_slist_next (iter))
|
|
|
|
|
_try_add_available_connection (device, NM_CONNECTION (iter->data));
|
|
|
|
|
|
|
|
|
|
_signal_available_connections_changed (device);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
cp_connection_added (NMConnectionProvider *cp, NMConnection *connection, gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
if (_try_add_available_connection (NM_DEVICE (user_data), connection))
|
|
|
|
|
_signal_available_connections_changed (NM_DEVICE (user_data));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
cp_connections_loaded (NMConnectionProvider *cp, NMConnection *connection, gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
const GSList *connections, *iter;
|
|
|
|
|
gboolean added = FALSE;
|
|
|
|
|
|
|
|
|
|
connections = nm_connection_provider_get_connections (cp);
|
|
|
|
|
for (iter = connections; iter; iter = g_slist_next (iter))
|
|
|
|
|
added |= _try_add_available_connection (NM_DEVICE (user_data), NM_CONNECTION (iter->data));
|
|
|
|
|
|
|
|
|
|
if (added)
|
|
|
|
|
_signal_available_connections_changed (NM_DEVICE (user_data));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
cp_connection_removed (NMConnectionProvider *cp, NMConnection *connection, gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
if (_del_available_connection (NM_DEVICE (user_data), connection))
|
|
|
|
|
_signal_available_connections_changed (NM_DEVICE (user_data));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
cp_connection_updated (NMConnectionProvider *cp, NMConnection *connection, gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
gboolean added, deleted;
|
|
|
|
|
|
|
|
|
|
/* FIXME: don't remove it from the hash if it's just going to get re-added */
|
|
|
|
|
deleted = _del_available_connection (NM_DEVICE (user_data), connection);
|
|
|
|
|
added = _try_add_available_connection (NM_DEVICE (user_data), connection);
|
|
|
|
|
|
|
|
|
|
/* Only signal if the connection was removed OR added, but not both */
|
|
|
|
|
if (added != deleted)
|
|
|
|
|
_signal_available_connections_changed (NM_DEVICE (user_data));
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-19 10:56:30 -04:00
|
|
|
gboolean
|
|
|
|
|
nm_device_supports_vlans (NMDevice *device)
|
|
|
|
|
{
|
|
|
|
|
/* At the moment, NM's VLAN code assumes all VLANs are over ethernet. */
|
|
|
|
|
return NM_IS_DEVICE_ETHERNET (device);
|
|
|
|
|
}
|
2012-06-13 11:32:47 -05:00
|
|
|
|
2013-05-01 09:28:16 -04:00
|
|
|
gboolean
|
|
|
|
|
nm_device_update_hw_address (NMDevice *dev)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (dev);
|
2013-07-19 12:05:19 -05:00
|
|
|
gboolean changed = FALSE, permanent = FALSE;
|
2013-05-01 09:28:16 -04:00
|
|
|
|
2013-07-19 12:05:19 -05:00
|
|
|
priv->hw_addr_len = nm_device_get_hw_address_length (dev, &permanent);
|
|
|
|
|
|
|
|
|
|
/* If the address can't be changed, don't bother trying */
|
|
|
|
|
if (permanent)
|
|
|
|
|
return FALSE;
|
2012-06-13 11:32:47 -05:00
|
|
|
|
2013-05-01 09:28:16 -04:00
|
|
|
if (priv->hw_addr_len) {
|
2013-01-21 15:12:24 +01:00
|
|
|
int ifindex = nm_device_get_ip_ifindex (dev);
|
2013-05-01 09:28:16 -04:00
|
|
|
gsize addrlen;
|
|
|
|
|
const guint8 *binaddr;
|
|
|
|
|
|
2013-01-21 15:12:24 +01:00
|
|
|
g_return_val_if_fail (ifindex > 0, FALSE);
|
2013-05-01 09:28:16 -04:00
|
|
|
|
2013-01-21 15:12:24 +01:00
|
|
|
binaddr = nm_platform_link_get_address (ifindex, &addrlen);
|
2013-05-01 09:28:16 -04:00
|
|
|
|
|
|
|
|
if (addrlen != priv->hw_addr_len) {
|
|
|
|
|
nm_log_err (LOGD_HW | LOGD_DEVICE,
|
|
|
|
|
"(%s): hardware address is wrong length (got %zd, expected %d)",
|
|
|
|
|
nm_device_get_iface (dev), addrlen, priv->hw_addr_len);
|
|
|
|
|
} else {
|
2013-01-21 15:12:24 +01:00
|
|
|
changed = !!memcmp (priv->hw_addr, binaddr, addrlen);
|
2013-05-01 09:28:16 -04:00
|
|
|
if (changed) {
|
2013-06-05 17:41:11 -03:00
|
|
|
char *addrstr = nm_utils_hwaddr_ntoa_len (binaddr, priv->hw_addr_len);
|
2013-01-21 15:12:24 +01:00
|
|
|
|
|
|
|
|
memcpy (priv->hw_addr, binaddr, addrlen);
|
2013-05-01 09:28:16 -04:00
|
|
|
nm_log_dbg (LOGD_HW | LOGD_DEVICE,
|
|
|
|
|
"(%s): hardware address is %s",
|
|
|
|
|
nm_device_get_iface (dev), addrstr);
|
|
|
|
|
g_free (addrstr);
|
|
|
|
|
g_object_notify (G_OBJECT (dev), NM_DEVICE_HW_ADDRESS);
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-06-13 11:32:47 -05:00
|
|
|
} else {
|
2013-05-01 09:28:16 -04:00
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
/* hw_addr_len is now 0; see if hw_addr was already empty */
|
|
|
|
|
for (i = 0; i < sizeof (priv->hw_addr) && !changed; i++) {
|
|
|
|
|
if (priv->hw_addr[i])
|
|
|
|
|
changed = TRUE;
|
|
|
|
|
}
|
|
|
|
|
if (changed) {
|
|
|
|
|
memset (priv->hw_addr, 0, sizeof (priv->hw_addr));
|
|
|
|
|
nm_log_dbg (LOGD_HW | LOGD_DEVICE,
|
|
|
|
|
"(%s): previous hardware address is no longer valid",
|
|
|
|
|
nm_device_get_iface (dev));
|
|
|
|
|
g_object_notify (G_OBJECT (dev), NM_DEVICE_HW_ADDRESS);
|
|
|
|
|
}
|
2012-06-13 11:32:47 -05:00
|
|
|
}
|
|
|
|
|
|
2013-05-01 09:28:16 -04:00
|
|
|
return changed;
|
2012-06-13 11:32:47 -05:00
|
|
|
}
|
2013-08-13 17:45:34 -04:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
nm_device_add_pending_action (NMDevice *device, const char *action)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
|
|
|
|
|
|
|
|
|
|
priv->pending_actions++;
|
|
|
|
|
nm_log_dbg (LOGD_DEVICE, "(%s): add_pending_action (%d): %s",
|
|
|
|
|
nm_device_get_iface (device), priv->pending_actions, action);
|
|
|
|
|
|
|
|
|
|
if (priv->pending_actions == 1)
|
|
|
|
|
g_object_notify (G_OBJECT (device), NM_DEVICE_HAS_PENDING_ACTION);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
nm_device_remove_pending_action (NMDevice *device, const char *action)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
|
|
|
|
|
|
|
|
|
|
priv->pending_actions--;
|
|
|
|
|
nm_log_dbg (LOGD_DEVICE, "(%s): remove_pending_action (%d): %s",
|
|
|
|
|
nm_device_get_iface (device), priv->pending_actions, action);
|
|
|
|
|
|
|
|
|
|
if (priv->pending_actions == 0)
|
|
|
|
|
g_object_notify (G_OBJECT (device), NM_DEVICE_HAS_PENDING_ACTION);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
|
nm_device_has_pending_action (NMDevice *device)
|
|
|
|
|
{
|
|
|
|
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
|
|
|
|
|
|
|
|
|
|
return priv->pending_actions > 0;
|
|
|
|
|
}
|