2008-06-10 15:54:23 +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
|
|
|
*
|
2014-04-07 15:25:09 +02:00
|
|
|
* Copyright (C) 2005 - 2014 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
|
|
|
*/
|
|
|
|
|
|
2011-03-14 01:00:56 -05:00
|
|
|
#include "config.h"
|
2014-11-13 10:07:02 -05:00
|
|
|
|
2005-12-31 08:21:24 +00:00
|
|
|
#include <netinet/in.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdlib.h>
|
2008-03-14 20:37:48 +00:00
|
|
|
#include <unistd.h>
|
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
|
|
|
#include <errno.h>
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2010-06-25 19:49:39 -07:00
|
|
|
#include <gudev/gudev.h>
|
|
|
|
|
|
2015-07-17 14:38:54 +02:00
|
|
|
#include "nm-default.h"
|
2008-06-10 15:54:23 +00:00
|
|
|
#include "nm-device-ethernet.h"
|
2005-12-31 08:21:24 +00:00
|
|
|
#include "nm-device-private.h"
|
|
|
|
|
#include "nm-activation-request.h"
|
|
|
|
|
#include "NetworkManagerUtils.h"
|
2006-11-25 15:41:04 +00:00
|
|
|
#include "nm-supplicant-manager.h"
|
2008-03-18 22:19:09 +00:00
|
|
|
#include "nm-supplicant-interface.h"
|
|
|
|
|
#include "nm-supplicant-config.h"
|
2008-03-11 16:37:41 +00:00
|
|
|
#include "ppp-manager/nm-ppp-manager.h"
|
2012-02-08 12:56:52 -05:00
|
|
|
#include "nm-enum-types.h"
|
2013-05-20 15:38:54 -03:00
|
|
|
#include "nm-platform.h"
|
2015-06-01 12:06:12 +02:00
|
|
|
#include "nm-platform-utils.h"
|
2013-10-04 16:56:34 -05:00
|
|
|
#include "nm-dcb.h"
|
2013-12-11 16:06:35 +01:00
|
|
|
#include "nm-settings-connection.h"
|
2014-09-08 16:11:51 -05:00
|
|
|
#include "nm-config.h"
|
|
|
|
|
#include "nm-device-ethernet-utils.h"
|
|
|
|
|
#include "nm-connection-provider.h"
|
2014-09-10 10:59:40 -05:00
|
|
|
#include "nm-device-factory.h"
|
2014-10-21 22:09:52 -04:00
|
|
|
#include "nm-core-internal.h"
|
2015-06-15 15:19:28 +02:00
|
|
|
#include "NetworkManagerUtils.h"
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2015-04-15 14:53:30 -04:00
|
|
|
#include "nmdbus-device-ethernet.h"
|
2007-02-12 09:23:43 +00:00
|
|
|
|
2014-08-02 15:14:26 +02:00
|
|
|
#include "nm-device-logging.h"
|
|
|
|
|
_LOG_DECLARE_SELF(NMDeviceEthernet);
|
2007-02-12 09:23:43 +00:00
|
|
|
|
2013-05-07 16:18:19 -04:00
|
|
|
G_DEFINE_TYPE (NMDeviceEthernet, nm_device_ethernet, NM_TYPE_DEVICE)
|
2007-02-12 09:23:43 +00:00
|
|
|
|
2008-06-10 15:54:23 +00:00
|
|
|
#define NM_DEVICE_ETHERNET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_ETHERNET, NMDeviceEthernetPrivate))
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2008-03-18 22:19:09 +00:00
|
|
|
#define WIRED_SECRETS_TRIES "wired-secrets-tries"
|
|
|
|
|
|
2013-12-09 09:33:13 +01:00
|
|
|
#define PPPOE_RECONNECT_DELAY 7
|
2015-04-28 10:05:42 +02:00
|
|
|
#define PPPOE_ENCAP_OVERHEAD 8 /* 2 bytes for PPP, 6 for PPPoE */
|
2013-12-09 09:33:13 +01:00
|
|
|
|
2008-03-18 22:19:09 +00:00
|
|
|
typedef struct Supplicant {
|
|
|
|
|
NMSupplicantManager *mgr;
|
|
|
|
|
NMSupplicantInterface *iface;
|
|
|
|
|
|
|
|
|
|
/* signal handler ids */
|
2016-01-04 10:29:06 +01:00
|
|
|
gulong iface_error_id;
|
|
|
|
|
gulong iface_state_id;
|
2008-09-25 10:02:28 +00:00
|
|
|
|
|
|
|
|
/* Timeouts and idles */
|
|
|
|
|
guint iface_con_error_cb_id;
|
|
|
|
|
guint con_timeout_id;
|
2008-03-18 22:19:09 +00:00
|
|
|
} Supplicant;
|
|
|
|
|
|
dcb: separate DCB enable/disable and wait for carrier changes (rh #799241) (rh #1081991)
Non-git-master versions of lldpad refuse to touch a device that doesn't
have a carrier. And when enabling/disabling DCB, the kernel driver will
reconfigure itself and may turn carrier off for a few seconds. So we
must ensure that before enabling/disabling DCB, the carrier is already
on. Next we must ensure that *after* enabling/disabling DCB, the
carrier is back on before doing further DCB setup.
There's a race condition between enabling/disabling DCB and receiving
the carrier event in NetworkManager that has to be handled carefully.
Because the carrier may not yet be down after the dcbtool call to
enable/disable DCB returns, we need to wait for a couple seconds for
the carrier to go down, and then again for it to come back up.
Otherwise we might see the still-on carrier, proceed with DCB setup,
and the carrier finally goes down halfway through the setup, which
will fail the operations with "DCB not enabled, link down, or DCB
not supported" errors from lldpad.
2014-03-27 13:49:50 -05:00
|
|
|
typedef enum {
|
|
|
|
|
DCB_WAIT_UNKNOWN = 0,
|
|
|
|
|
/* Ensure carrier is up before enabling DCB */
|
|
|
|
|
DCB_WAIT_CARRIER_PREENABLE_UP,
|
|
|
|
|
/* Wait for carrier down when device starts enabling */
|
|
|
|
|
DCB_WAIT_CARRIER_PRECONFIG_DOWN,
|
|
|
|
|
/* Wait for carrier up when device has finished enabling */
|
|
|
|
|
DCB_WAIT_CARRIER_PRECONFIG_UP,
|
|
|
|
|
/* Wait carrier down when device starts configuring */
|
|
|
|
|
DCB_WAIT_CARRIER_POSTCONFIG_DOWN,
|
|
|
|
|
/* Wait carrier up when device has finished configuring */
|
|
|
|
|
DCB_WAIT_CARRIER_POSTCONFIG_UP,
|
|
|
|
|
} DcbWait;
|
|
|
|
|
|
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
|
|
|
typedef struct {
|
2013-05-07 16:18:19 -04:00
|
|
|
guint32 speed;
|
|
|
|
|
|
2008-03-18 22:19:09 +00:00
|
|
|
Supplicant supplicant;
|
2009-09-28 12:57:18 -07:00
|
|
|
guint supplicant_timeout_id;
|
2008-03-11 16:37:41 +00:00
|
|
|
|
2010-06-25 19:49:39 -07:00
|
|
|
/* s390 */
|
|
|
|
|
char * subchan1;
|
|
|
|
|
char * subchan2;
|
|
|
|
|
char * subchan3;
|
2010-06-25 21:44:01 -07:00
|
|
|
char * subchannels; /* Composite used for checking unmanaged specs */
|
2015-09-18 22:49:13 +02:00
|
|
|
char ** subchannels_dbus; /* Array exported on D-Bus */
|
2014-04-07 15:25:09 +02:00
|
|
|
char * s390_nettype;
|
|
|
|
|
GHashTable * s390_options;
|
2010-06-25 19:49:39 -07:00
|
|
|
|
2008-03-11 16:37:41 +00:00
|
|
|
/* PPPoE */
|
|
|
|
|
NMPPPManager *ppp_manager;
|
|
|
|
|
NMIP4Config *pending_ip4_config;
|
2013-12-10 20:39:48 +01:00
|
|
|
gint32 last_pppoe_time;
|
2013-12-09 09:33:13 +01:00
|
|
|
guint pppoe_wait_id;
|
dcb: separate DCB enable/disable and wait for carrier changes (rh #799241) (rh #1081991)
Non-git-master versions of lldpad refuse to touch a device that doesn't
have a carrier. And when enabling/disabling DCB, the kernel driver will
reconfigure itself and may turn carrier off for a few seconds. So we
must ensure that before enabling/disabling DCB, the carrier is already
on. Next we must ensure that *after* enabling/disabling DCB, the
carrier is back on before doing further DCB setup.
There's a race condition between enabling/disabling DCB and receiving
the carrier event in NetworkManager that has to be handled carefully.
Because the carrier may not yet be down after the dcbtool call to
enable/disable DCB returns, we need to wait for a couple seconds for
the carrier to go down, and then again for it to come back up.
Otherwise we might see the still-on carrier, proceed with DCB setup,
and the carrier finally goes down halfway through the setup, which
will fail the operations with "DCB not enabled, link down, or DCB
not supported" errors from lldpad.
2014-03-27 13:49:50 -05:00
|
|
|
|
|
|
|
|
/* DCB */
|
|
|
|
|
DcbWait dcb_wait;
|
|
|
|
|
guint dcb_timeout_id;
|
2016-01-04 10:29:06 +01:00
|
|
|
gulong dcb_carrier_id;
|
2008-06-10 15:54:23 +00:00
|
|
|
} NMDeviceEthernetPrivate;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2007-02-12 09:23:43 +00:00
|
|
|
enum {
|
|
|
|
|
PROP_0,
|
2010-06-22 14:21:25 +02:00
|
|
|
PROP_PERM_HW_ADDRESS,
|
2007-02-12 09:23:43 +00:00
|
|
|
PROP_SPEED,
|
2015-09-18 22:49:13 +02:00
|
|
|
PROP_S390_SUBCHANNELS,
|
2007-02-12 09:23:43 +00:00
|
|
|
|
|
|
|
|
LAST_PROP
|
|
|
|
|
};
|
|
|
|
|
|
2008-03-12 Dan Williams <dcbw@redhat.com>
Move the 'carrier' property from NMDevice to NMDevice8023Ethernet;
convert the libnm-glib NMDevice8023Ethernet to cached properties
* introspection/nm-device-802-3-ethernet.xml
- New 'Carrier' property
- New 'PropertiesChanged' signal
* introspection/nm-device.xml
- Remove 'Carrier' property
- Remove 'CarrierChanged' signal
* src/nm-device-interface.c
src/nm-device-interface.h
- (nm_device_interface_init): remove 'carrier' property and
'carrier-changed' signal
* src/nm-device.c
src/nm-device.h
- (nm_device_get_carrier, nm_device_set_carrier): remove
- (nm_device_activate_stage5_ip_config_commit): don't bother updating
the link here; wired device will handle that
- (handle_dhcp_lease_change): don't bother updating link here
- (get_property, nm_device_class_init): remove carrier property
* src/nm-device-802-11-wireless.c
- (real_update_link, nm_device_802_11_wireless_class_init): remove
real_update_link(); wireless devices don't use carrier at all
- (link_timeout_cb, supplicant_iface_state_cb_handler,
supplicant_iface_connection_state_cb_handler,
supplicant_mgr_state_cb_handler): remove anything to do with carrier
* src/nm-device-802-3-ethernet.c
src/nm-device-802-3-ethernet.h
- (nm_device_802_3_ethernet_carrier_on,
nm_device_802_3_ethernet_carrier_off, constructor): use set_carrier()
instead of nm_device_set_carrier()
- (device_state_changed): update link from sysfs on activation;
replaces real_update_link()
- (real_update_link): remove, replaced by device_state_changed()
- (nm_device_802_3_ethernet_get_carrier, set_carrier): new functions
- (nm_device_802_3_ethernet_get_speed): move up with other getters/setters
- (real_get_generic_capabilities, real_can_interrupt_activation): use
new get_carrier function
- (get_property): add 'carrier' property
- (nm_device_802_3_ethernet_class_init): add 'carrier' property and
hook into property-changed signal helper
* src/NetworkManagerPolicy.c
- (device_carrier_changed): will only ever be called with a wired device
- (device_added): only hook up to carrier-changed for wired devices
* libnm-glib/nm-device.c
libnm-glib/nm-device.h
- (constructor, nm_device_class_init): remove carrier-changed signal
- (device_carrier_changed_proxy): remove; unused
- (nm_device_get_carrier): remove; carrier a property of wired devices
* libnm-glib/nm-device-802-3-ethernet.c
libnm-glib/nm-device-802-3-ethernet.h
- Convert to cached properties like AP and Wireless objects
- (nm_device_802_3_ethernet_get_hw_address): now returns a 'const char *'
instead of a 'char *', return value should not be freed
- (nm_device_802_3_ethernet_get_carrier): return current carrier status
- (constructor): hook into properties-changed helper
- (set_property, get_property): new functions
- (nm_device_802_3_ethernet_class_init): export GObject properties
* test/nm-tool.c
- (detail_device): strdup the wired hardware address too since it's
cached now
* libnm-glib/libnm-glib-test.c
- (dump_wired): strdup the wired hardware address too since it's
cached now
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3428 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-03-12 16:12:39 +00:00
|
|
|
|
2014-04-07 15:25:09 +02:00
|
|
|
static char *
|
|
|
|
|
get_link_basename (const char *parent_path, const char *name, GError **error)
|
|
|
|
|
{
|
2014-04-11 12:46:53 +02:00
|
|
|
char *link_dest, *path;
|
2014-04-07 15:25:09 +02:00
|
|
|
char *result = NULL;
|
|
|
|
|
|
|
|
|
|
path = g_strdup_printf ("%s/%s", parent_path, name);
|
2014-04-11 12:46:53 +02:00
|
|
|
link_dest = g_file_read_link (path, error);
|
|
|
|
|
if (link_dest) {
|
|
|
|
|
result = g_path_get_basename (link_dest);
|
|
|
|
|
g_free (link_dest);
|
|
|
|
|
}
|
2014-04-07 15:25:09 +02:00
|
|
|
g_free (path);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-25 19:49:39 -07:00
|
|
|
static void
|
|
|
|
|
_update_s390_subchannels (NMDeviceEthernet *self)
|
|
|
|
|
{
|
|
|
|
|
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
|
|
|
|
|
GUdevDevice *dev;
|
2010-11-19 16:17:40 -06:00
|
|
|
GUdevDevice *parent = NULL;
|
2010-06-25 19:49:39 -07:00
|
|
|
const char *parent_path, *item, *driver;
|
2015-06-15 15:19:28 +02:00
|
|
|
int ifindex;
|
2010-06-25 19:49:39 -07:00
|
|
|
GDir *dir;
|
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
2015-06-15 15:19:28 +02:00
|
|
|
ifindex = nm_device_get_ifindex (NM_DEVICE (self));
|
|
|
|
|
dev = (GUdevDevice *) nm_platform_link_get_udev_device (NM_PLATFORM_GET, ifindex);
|
2010-06-25 19:49:39 -07:00
|
|
|
if (!dev) {
|
2015-06-15 15:19:28 +02:00
|
|
|
_LOGW (LOGD_DEVICE | LOGD_HW, "failed to find device %d '%s' with udev",
|
|
|
|
|
ifindex, str_if_set (nm_device_get_iface (NM_DEVICE (self)), "(null)"));
|
2010-06-25 19:49:39 -07:00
|
|
|
goto out;
|
|
|
|
|
}
|
2015-06-15 15:19:28 +02:00
|
|
|
g_object_ref (dev);
|
2010-06-25 19:49:39 -07:00
|
|
|
|
|
|
|
|
/* Try for the "ccwgroup" parent */
|
|
|
|
|
parent = g_udev_device_get_parent_with_subsystem (dev, "ccwgroup", NULL);
|
|
|
|
|
if (!parent) {
|
|
|
|
|
/* FIXME: whatever 'lcs' devices' subsystem is here... */
|
|
|
|
|
if (!parent) {
|
|
|
|
|
/* Not an s390 device */
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
parent_path = g_udev_device_get_sysfs_path (parent);
|
|
|
|
|
dir = g_dir_open (parent_path, 0, &error);
|
|
|
|
|
if (!dir) {
|
2014-08-02 15:14:26 +02:00
|
|
|
_LOGW (LOGD_DEVICE | LOGD_HW, "failed to open directory '%s': %s",
|
|
|
|
|
parent_path, error && error->message ? error->message : "(unknown)");
|
2010-06-25 19:49:39 -07:00
|
|
|
g_clear_error (&error);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while ((item = g_dir_read_name (dir))) {
|
2014-04-07 15:25:09 +02:00
|
|
|
if (!strcmp (item, "cdev0")) {
|
|
|
|
|
priv->subchan1 = get_link_basename (parent_path, "cdev0", &error);
|
|
|
|
|
} else if (!strcmp (item, "cdev1")) {
|
|
|
|
|
priv->subchan2 = get_link_basename (parent_path, "cdev1", &error);
|
|
|
|
|
} else if (!strcmp (item, "cdev2")) {
|
|
|
|
|
priv->subchan3 = get_link_basename (parent_path, "cdev2", &error);
|
|
|
|
|
} else if (!strcmp (item, "driver")) {
|
|
|
|
|
priv->s390_nettype = get_link_basename (parent_path, "driver", &error);
|
|
|
|
|
} else if ( !strcmp (item, "layer2")
|
|
|
|
|
|| !strcmp (item, "portname")
|
|
|
|
|
|| !strcmp (item, "portno")) {
|
|
|
|
|
char *path, *value;
|
|
|
|
|
path = g_strdup_printf ("%s/%s", parent_path, item);
|
platform: add self argument to platform functions
Most nm_platform_*() functions operate on the platform
singleton nm_platform_get(). That made sense because the
NMPlatform instance was mainly to hook fake platform for
testing.
While the implicit argument saved some typing, I think explicit is
better. Especially, because NMPlatform could become a more usable
object then just a hook for testing.
With this change, NMPlatform instances can be used individually, not
only as a singleton instance.
Before this change, the constructor of NMLinuxPlatform could not
call any nm_platform_*() functions because the singleton was not
yet initialized. We could only instantiate an incomplete instance,
register it via nm_platform_setup(), and then complete initialization
via singleton->setup().
With this change, we can create and fully initialize NMPlatform instances
before/without setting them up them as singleton.
Also, currently there is no clear distinction between functions
that operate on the NMPlatform instance, and functions that can
be used stand-alone (e.g. nm_platform_ip4_address_to_string()).
The latter can not be mocked for testing. With this change, the
distinction becomes obvious. That is also useful because it becomes
clearer which functions make use of the platform cache and which not.
Inside nm-linux-platform.c, continue the pattern that the
self instance is named @platform. That makes sense because
its type is NMPlatform, and not NMLinuxPlatform what we
would expect from a paramter named @self.
This is a major diff that causes some pain when rebasing. Try
to rebase to the parent commit of this commit as a first step.
Then rebase on top of this commit using merge-strategy "ours".
2015-04-18 12:36:09 +02:00
|
|
|
value = nm_platform_sysctl_get (NM_PLATFORM_GET, path);
|
2014-04-07 15:25:09 +02:00
|
|
|
if (value && *value)
|
|
|
|
|
g_hash_table_insert (priv->s390_options, g_strdup (item), g_strdup (value));
|
|
|
|
|
else
|
2014-08-02 15:14:26 +02:00
|
|
|
_LOGW (LOGD_DEVICE | LOGD_HW, "error reading %s", path);
|
2014-04-07 15:25:09 +02:00
|
|
|
g_free (path);
|
|
|
|
|
g_free (value);
|
2010-06-25 19:49:39 -07:00
|
|
|
}
|
2014-04-07 15:25:09 +02:00
|
|
|
if (error) {
|
2014-08-02 15:14:26 +02:00
|
|
|
_LOGW (LOGD_DEVICE | LOGD_HW, "%s", error->message);
|
2014-04-07 15:25:09 +02:00
|
|
|
g_clear_error (&error);
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-06-25 19:49:39 -07:00
|
|
|
|
|
|
|
|
g_dir_close (dir);
|
|
|
|
|
|
2010-06-25 21:44:01 -07:00
|
|
|
if (priv->subchan3) {
|
|
|
|
|
priv->subchannels = g_strdup_printf ("%s,%s,%s",
|
|
|
|
|
priv->subchan1,
|
|
|
|
|
priv->subchan2,
|
|
|
|
|
priv->subchan3);
|
|
|
|
|
} else if (priv->subchan2) {
|
|
|
|
|
priv->subchannels = g_strdup_printf ("%s,%s",
|
|
|
|
|
priv->subchan1,
|
|
|
|
|
priv->subchan2);
|
|
|
|
|
} else
|
|
|
|
|
priv->subchannels = g_strdup (priv->subchan1);
|
|
|
|
|
|
2015-09-18 22:49:13 +02:00
|
|
|
priv->subchannels_dbus = g_new (char *, 3 + 1);
|
|
|
|
|
priv->subchannels_dbus[0] = g_strdup (priv->subchan1);
|
|
|
|
|
priv->subchannels_dbus[1] = g_strdup (priv->subchan2);
|
|
|
|
|
priv->subchannels_dbus[2] = g_strdup (priv->subchan3);
|
|
|
|
|
priv->subchannels_dbus[3] = NULL;
|
|
|
|
|
|
2010-06-25 21:46:57 -07:00
|
|
|
driver = nm_device_get_driver (NM_DEVICE (self));
|
2014-08-02 15:14:26 +02:00
|
|
|
_LOGI (LOGD_DEVICE | LOGD_HW, "found s390 '%s' subchannels [%s]",
|
|
|
|
|
driver ? driver : "(unknown driver)", priv->subchannels);
|
2010-06-25 21:46:57 -07:00
|
|
|
|
2010-06-25 19:49:39 -07:00
|
|
|
out:
|
|
|
|
|
if (parent)
|
|
|
|
|
g_object_unref (parent);
|
|
|
|
|
if (dev)
|
|
|
|
|
g_object_unref (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
|
|
|
static GObject*
|
|
|
|
|
constructor (GType type,
|
2014-04-07 15:25:09 +02:00
|
|
|
guint n_construct_params,
|
|
|
|
|
GObjectConstructParam *construct_params)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
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
|
|
|
GObject *object;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2008-06-10 15:54:23 +00:00
|
|
|
object = G_OBJECT_CLASS (nm_device_ethernet_parent_class)->constructor (type,
|
2009-08-03 17:15:03 -04:00
|
|
|
n_construct_params,
|
|
|
|
|
construct_params);
|
2012-02-22 23:59:50 -06:00
|
|
|
if (object) {
|
2014-08-02 15:14:26 +02:00
|
|
|
#ifndef G_DISABLE_ASSERT
|
|
|
|
|
int ifindex = nm_device_get_ifindex (NM_DEVICE (object));
|
platform: add self argument to platform functions
Most nm_platform_*() functions operate on the platform
singleton nm_platform_get(). That made sense because the
NMPlatform instance was mainly to hook fake platform for
testing.
While the implicit argument saved some typing, I think explicit is
better. Especially, because NMPlatform could become a more usable
object then just a hook for testing.
With this change, NMPlatform instances can be used individually, not
only as a singleton instance.
Before this change, the constructor of NMLinuxPlatform could not
call any nm_platform_*() functions because the singleton was not
yet initialized. We could only instantiate an incomplete instance,
register it via nm_platform_setup(), and then complete initialization
via singleton->setup().
With this change, we can create and fully initialize NMPlatform instances
before/without setting them up them as singleton.
Also, currently there is no clear distinction between functions
that operate on the NMPlatform instance, and functions that can
be used stand-alone (e.g. nm_platform_ip4_address_to_string()).
The latter can not be mocked for testing. With this change, the
distinction becomes obvious. That is also useful because it becomes
clearer which functions make use of the platform cache and which not.
Inside nm-linux-platform.c, continue the pattern that the
self instance is named @platform. That makes sense because
its type is NMPlatform, and not NMLinuxPlatform what we
would expect from a paramter named @self.
This is a major diff that causes some pain when rebasing. Try
to rebase to the parent commit of this commit as a first step.
Then rebase on top of this commit using merge-strategy "ours".
2015-04-18 12:36:09 +02:00
|
|
|
NMLinkType link_type = nm_platform_link_get_type (NM_PLATFORM_GET, ifindex);
|
2012-02-05 23:56:15 -06:00
|
|
|
|
2014-12-01 16:53:12 +01:00
|
|
|
g_assert ( link_type == NM_LINK_TYPE_ETHERNET
|
|
|
|
|
|| link_type == NM_LINK_TYPE_VETH
|
|
|
|
|
|| link_type == NM_LINK_TYPE_NONE);
|
2014-08-02 15:14:26 +02:00
|
|
|
#endif
|
2010-04-08 09:30:05 -07:00
|
|
|
|
2012-02-22 23:59:50 -06:00
|
|
|
/* s390 stuff */
|
2014-08-02 15:14:26 +02:00
|
|
|
_update_s390_subchannels (NM_DEVICE_ETHERNET (object));
|
2012-02-22 23:59:50 -06:00
|
|
|
}
|
2010-06-25 19:49:39 -07:00
|
|
|
|
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
|
|
|
return object;
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
2011-01-18 18:35:35 -06:00
|
|
|
static void
|
|
|
|
|
clear_secrets_tries (NMDevice *device)
|
|
|
|
|
{
|
|
|
|
|
NMActRequest *req;
|
|
|
|
|
NMConnection *connection;
|
|
|
|
|
|
|
|
|
|
req = nm_device_get_act_request (device);
|
|
|
|
|
if (req) {
|
2015-07-14 16:53:24 +02:00
|
|
|
connection = nm_act_request_get_applied_connection (req);
|
2011-01-18 18:35:35 -06:00
|
|
|
/* Clear wired secrets tries on success, failure, or when deactivating */
|
|
|
|
|
g_object_set_data (G_OBJECT (connection), WIRED_SECRETS_TRIES, NULL);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
device_state_changed (NMDevice *device,
|
|
|
|
|
NMDeviceState new_state,
|
|
|
|
|
NMDeviceState old_state,
|
2012-09-27 12:38:59 -04:00
|
|
|
NMDeviceStateReason reason)
|
2011-01-18 18:35:35 -06:00
|
|
|
{
|
2013-12-09 09:33:13 +01:00
|
|
|
if ( new_state == NM_DEVICE_STATE_ACTIVATED
|
|
|
|
|
|| new_state == NM_DEVICE_STATE_FAILED
|
|
|
|
|
|| new_state == NM_DEVICE_STATE_DISCONNECTED)
|
2011-01-18 18:35:35 -06:00
|
|
|
clear_secrets_tries (device);
|
|
|
|
|
}
|
|
|
|
|
|
2006-03-05 Dan Williams <dcbw@redhat.com>
Process netlink messages in device subclasses rather than in
NetworkManager.c. Also add support for recognizing Wireless Events.
* configure.in
- Find GLIB_GENMARSHAL
* src/Makefile.am
- Since we're marshalling custom types for wireless event signals,
we get to create our own marshallers using GLIB_GENMARSHAL
* src/NetworkManager.c
- (nm_monitor_wired_link_state): renamed to nm_monitor_setup
- (nm_monitor_setup): renamed from nm_monitor_wired_link_state, and
cut down somewhat. We no longer process signals here.
- (nm_data_new): create the netlink monitor here, and remove a
useless call to nm_policy_schedule_device_change_check()
- (nm_data_free): get rid of the netlink monitor here
- (nm_device_link_activated, nm_device_link_deactivated): removed
- (main): don't create the netlink monitor here, let nm_data_new
do that. Call nm_policy_schedule_device_change_check() right
before we jump to the mainloop to figure out which device
to use first
* src/NetworkManagerSystem.[ch]
- (nm_system_get_rtnl_index_from_iface, nm_system_get_iface_from_rtnl_index):
convert back and forth from interface names to interface
indexes
* src/nm-device-802-11-wireless.c
- (real_init): connect to wireless-event signals from the netlink
monitor object
- (nm_device_802_11_wireless_event): new function, schedule handler
for wireless event signals from the netlink monitor object. We
want the handler to run in the device's context
- (wireless_event_helper): handle wireless-event signals from netlink
- (nm_device_802_11_wireless_dispose): disconnect wireless-event
signal handler
* src/nm-device-802-11-wireless.h
- remove unused prototype for nm_device_802_11_wireless_new
* src/nm-device-802-3-ethernet.c
- (real_init): new function; set up signal handlers for link events
- (nm_device_802_3_ethernet_link_activated): new function, schedule
handler for netlink link activated events on device's main loop
- (link_activated_helper): when we get a link activated event, set
the device's link to be active
- (nm_device_802_3_ethernet_link_deactivated): new function; schedule
handler for netlink link deactivated events on device's main loop
- (link_deactivated_helper): when we get a link deactivated event, set
the device's link to be inactive
- (nm_device_802_3_ethernet_dispose): disconnect signal handler on
dispose
* src/nm-device-802-3-ethernet.h
- remove unused prototype for nm_device_802_3_ethernet_new
* src/nm-device.[ch]
- (nm_get_device_by_iface_locked): variant of nm_get_device_by_iface
but locks the device list
- (nm_device_set_active_link): a little bit of cleanup and de-indenting
* src/nm-netlink-monitor.[ch]
- (nm_netlink_monitor_class_install_signals): New signal
"wireless-event"
- (nm_netlink_monitor_new): keep reference to NMData so we can get
at the device list
- (nm_netlink_monitor_event_handler): expand for wireless events too
* src/nm-marshal-main.c
- Include generated nm-marshal.c and nm-marshal.h
* src/nm-marshal.list
- List of custom marshal functions
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1555 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-03-06 01:10:58 +00:00
|
|
|
static void
|
2014-04-07 15:25:09 +02:00
|
|
|
nm_device_ethernet_init (NMDeviceEthernet *self)
|
2006-03-05 Dan Williams <dcbw@redhat.com>
Process netlink messages in device subclasses rather than in
NetworkManager.c. Also add support for recognizing Wireless Events.
* configure.in
- Find GLIB_GENMARSHAL
* src/Makefile.am
- Since we're marshalling custom types for wireless event signals,
we get to create our own marshallers using GLIB_GENMARSHAL
* src/NetworkManager.c
- (nm_monitor_wired_link_state): renamed to nm_monitor_setup
- (nm_monitor_setup): renamed from nm_monitor_wired_link_state, and
cut down somewhat. We no longer process signals here.
- (nm_data_new): create the netlink monitor here, and remove a
useless call to nm_policy_schedule_device_change_check()
- (nm_data_free): get rid of the netlink monitor here
- (nm_device_link_activated, nm_device_link_deactivated): removed
- (main): don't create the netlink monitor here, let nm_data_new
do that. Call nm_policy_schedule_device_change_check() right
before we jump to the mainloop to figure out which device
to use first
* src/NetworkManagerSystem.[ch]
- (nm_system_get_rtnl_index_from_iface, nm_system_get_iface_from_rtnl_index):
convert back and forth from interface names to interface
indexes
* src/nm-device-802-11-wireless.c
- (real_init): connect to wireless-event signals from the netlink
monitor object
- (nm_device_802_11_wireless_event): new function, schedule handler
for wireless event signals from the netlink monitor object. We
want the handler to run in the device's context
- (wireless_event_helper): handle wireless-event signals from netlink
- (nm_device_802_11_wireless_dispose): disconnect wireless-event
signal handler
* src/nm-device-802-11-wireless.h
- remove unused prototype for nm_device_802_11_wireless_new
* src/nm-device-802-3-ethernet.c
- (real_init): new function; set up signal handlers for link events
- (nm_device_802_3_ethernet_link_activated): new function, schedule
handler for netlink link activated events on device's main loop
- (link_activated_helper): when we get a link activated event, set
the device's link to be active
- (nm_device_802_3_ethernet_link_deactivated): new function; schedule
handler for netlink link deactivated events on device's main loop
- (link_deactivated_helper): when we get a link deactivated event, set
the device's link to be inactive
- (nm_device_802_3_ethernet_dispose): disconnect signal handler on
dispose
* src/nm-device-802-3-ethernet.h
- remove unused prototype for nm_device_802_3_ethernet_new
* src/nm-device.[ch]
- (nm_get_device_by_iface_locked): variant of nm_get_device_by_iface
but locks the device list
- (nm_device_set_active_link): a little bit of cleanup and de-indenting
* src/nm-netlink-monitor.[ch]
- (nm_netlink_monitor_class_install_signals): New signal
"wireless-event"
- (nm_netlink_monitor_new): keep reference to NMData so we can get
at the device list
- (nm_netlink_monitor_event_handler): expand for wireless events too
* src/nm-marshal-main.c
- Include generated nm-marshal.c and nm-marshal.h
* src/nm-marshal.list
- List of custom marshal functions
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1555 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-03-06 01:10:58 +00:00
|
|
|
{
|
2014-04-07 15:25:09 +02:00
|
|
|
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
|
|
|
|
|
priv->s390_options = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
|
2006-03-05 Dan Williams <dcbw@redhat.com>
Process netlink messages in device subclasses rather than in
NetworkManager.c. Also add support for recognizing Wireless Events.
* configure.in
- Find GLIB_GENMARSHAL
* src/Makefile.am
- Since we're marshalling custom types for wireless event signals,
we get to create our own marshallers using GLIB_GENMARSHAL
* src/NetworkManager.c
- (nm_monitor_wired_link_state): renamed to nm_monitor_setup
- (nm_monitor_setup): renamed from nm_monitor_wired_link_state, and
cut down somewhat. We no longer process signals here.
- (nm_data_new): create the netlink monitor here, and remove a
useless call to nm_policy_schedule_device_change_check()
- (nm_data_free): get rid of the netlink monitor here
- (nm_device_link_activated, nm_device_link_deactivated): removed
- (main): don't create the netlink monitor here, let nm_data_new
do that. Call nm_policy_schedule_device_change_check() right
before we jump to the mainloop to figure out which device
to use first
* src/NetworkManagerSystem.[ch]
- (nm_system_get_rtnl_index_from_iface, nm_system_get_iface_from_rtnl_index):
convert back and forth from interface names to interface
indexes
* src/nm-device-802-11-wireless.c
- (real_init): connect to wireless-event signals from the netlink
monitor object
- (nm_device_802_11_wireless_event): new function, schedule handler
for wireless event signals from the netlink monitor object. We
want the handler to run in the device's context
- (wireless_event_helper): handle wireless-event signals from netlink
- (nm_device_802_11_wireless_dispose): disconnect wireless-event
signal handler
* src/nm-device-802-11-wireless.h
- remove unused prototype for nm_device_802_11_wireless_new
* src/nm-device-802-3-ethernet.c
- (real_init): new function; set up signal handlers for link events
- (nm_device_802_3_ethernet_link_activated): new function, schedule
handler for netlink link activated events on device's main loop
- (link_activated_helper): when we get a link activated event, set
the device's link to be active
- (nm_device_802_3_ethernet_link_deactivated): new function; schedule
handler for netlink link deactivated events on device's main loop
- (link_deactivated_helper): when we get a link deactivated event, set
the device's link to be inactive
- (nm_device_802_3_ethernet_dispose): disconnect signal handler on
dispose
* src/nm-device-802-3-ethernet.h
- remove unused prototype for nm_device_802_3_ethernet_new
* src/nm-device.[ch]
- (nm_get_device_by_iface_locked): variant of nm_get_device_by_iface
but locks the device list
- (nm_device_set_active_link): a little bit of cleanup and de-indenting
* src/nm-netlink-monitor.[ch]
- (nm_netlink_monitor_class_install_signals): New signal
"wireless-event"
- (nm_netlink_monitor_new): keep reference to NMData so we can get
at the device list
- (nm_netlink_monitor_event_handler): expand for wireless events too
* src/nm-marshal-main.c
- Include generated nm-marshal.c and nm-marshal.h
* src/nm-marshal.list
- List of custom marshal functions
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1555 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-03-06 01:10:58 +00:00
|
|
|
}
|
|
|
|
|
|
2014-09-05 08:50:02 -05:00
|
|
|
static void
|
2016-01-08 17:24:24 +01:00
|
|
|
realize_start_notify (NMDevice *device, const NMPlatformLink *plink)
|
2014-09-05 08:50:02 -05:00
|
|
|
{
|
2016-01-08 17:24:24 +01:00
|
|
|
NM_DEVICE_CLASS (nm_device_ethernet_parent_class)->realize_start_notify (device, plink);
|
2014-09-05 08:50:02 -05:00
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (device), NM_DEVICE_ETHERNET_PERMANENT_HW_ADDRESS);
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-17 15:15:38 +02:00
|
|
|
static NMDeviceCapabilities
|
2014-08-02 15:14:26 +02:00
|
|
|
get_generic_capabilities (NMDevice *device)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
2014-08-02 15:14:26 +02:00
|
|
|
NMDeviceEthernet *self = NM_DEVICE_ETHERNET (device);
|
|
|
|
|
|
platform: add self argument to platform functions
Most nm_platform_*() functions operate on the platform
singleton nm_platform_get(). That made sense because the
NMPlatform instance was mainly to hook fake platform for
testing.
While the implicit argument saved some typing, I think explicit is
better. Especially, because NMPlatform could become a more usable
object then just a hook for testing.
With this change, NMPlatform instances can be used individually, not
only as a singleton instance.
Before this change, the constructor of NMLinuxPlatform could not
call any nm_platform_*() functions because the singleton was not
yet initialized. We could only instantiate an incomplete instance,
register it via nm_platform_setup(), and then complete initialization
via singleton->setup().
With this change, we can create and fully initialize NMPlatform instances
before/without setting them up them as singleton.
Also, currently there is no clear distinction between functions
that operate on the NMPlatform instance, and functions that can
be used stand-alone (e.g. nm_platform_ip4_address_to_string()).
The latter can not be mocked for testing. With this change, the
distinction becomes obvious. That is also useful because it becomes
clearer which functions make use of the platform cache and which not.
Inside nm-linux-platform.c, continue the pattern that the
self instance is named @platform. That makes sense because
its type is NMPlatform, and not NMLinuxPlatform what we
would expect from a paramter named @self.
This is a major diff that causes some pain when rebasing. Try
to rebase to the parent commit of this commit as a first step.
Then rebase on top of this commit using merge-strategy "ours".
2015-04-18 12:36:09 +02:00
|
|
|
if (nm_platform_link_supports_carrier_detect (NM_PLATFORM_GET, nm_device_get_ifindex (device)))
|
2013-05-20 15:38:54 -03:00
|
|
|
return NM_DEVICE_CAP_CARRIER_DETECT;
|
|
|
|
|
else {
|
2014-08-02 15:14:26 +02:00
|
|
|
_LOGI (LOGD_HW, "driver '%s' does not support carrier detection.",
|
|
|
|
|
nm_device_get_driver (device));
|
2013-05-20 15:38:54 -03:00
|
|
|
return NM_DEVICE_CAP_NONE;
|
|
|
|
|
}
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
2015-09-18 22:49:13 +02:00
|
|
|
static guint32
|
|
|
|
|
_subchannels_count_num (const char * const *array)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
if (!array)
|
|
|
|
|
return 0;
|
|
|
|
|
for (i = 0; array[i]; i++)
|
|
|
|
|
/* NOP */;
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-09 17:53:01 -05:00
|
|
|
static gboolean
|
|
|
|
|
match_subchans (NMDeviceEthernet *self, NMSettingWired *s_wired, gboolean *try_mac)
|
|
|
|
|
{
|
|
|
|
|
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
|
2014-08-21 13:19:53 -04:00
|
|
|
const char * const *subchans;
|
2015-09-18 22:49:13 +02:00
|
|
|
guint32 num1, num2;
|
2010-08-09 17:53:01 -05:00
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
*try_mac = TRUE;
|
|
|
|
|
|
|
|
|
|
subchans = nm_setting_wired_get_s390_subchannels (s_wired);
|
2015-09-18 22:49:13 +02:00
|
|
|
num1 = _subchannels_count_num (subchans);
|
|
|
|
|
num2 = _subchannels_count_num ((const char * const *) priv->subchannels_dbus);
|
|
|
|
|
/* connection has no subchannels */
|
|
|
|
|
if (num1 == 0)
|
2010-08-09 17:53:01 -05:00
|
|
|
return TRUE;
|
|
|
|
|
/* connection requires subchannels but the device has none */
|
2015-09-18 22:49:13 +02:00
|
|
|
if (num2 == 0)
|
|
|
|
|
return FALSE;
|
|
|
|
|
/* number of subchannels differ */
|
|
|
|
|
if (num1 != num2)
|
2010-08-09 17:53:01 -05:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
/* Make sure each subchannel in the connection is a subchannel of this device */
|
2014-08-21 13:19:53 -04:00
|
|
|
for (i = 0; subchans[i]; i++) {
|
|
|
|
|
const char *candidate = subchans[i];
|
2010-08-09 17:53:01 -05:00
|
|
|
|
|
|
|
|
if ( (priv->subchan1 && !strcmp (priv->subchan1, candidate))
|
|
|
|
|
|| (priv->subchan2 && !strcmp (priv->subchan2, candidate))
|
|
|
|
|
|| (priv->subchan3 && !strcmp (priv->subchan3, candidate)))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
return FALSE; /* a subchannel was not found */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*try_mac = FALSE;
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-07 13:15:20 +01:00
|
|
|
static gboolean
|
2014-05-30 13:44:53 -05:00
|
|
|
check_connection_compatible (NMDevice *device, NMConnection *connection)
|
2011-12-07 13:15:20 +01:00
|
|
|
{
|
|
|
|
|
NMDeviceEthernet *self = NM_DEVICE_ETHERNET (device);
|
|
|
|
|
NMSettingWired *s_wired;
|
|
|
|
|
|
2014-05-30 13:44:53 -05:00
|
|
|
if (!NM_DEVICE_CLASS (nm_device_ethernet_parent_class)->check_connection_compatible (device, connection))
|
2013-03-07 07:44:36 -05:00
|
|
|
return FALSE;
|
|
|
|
|
|
2011-12-07 13:15:20 +01:00
|
|
|
s_wired = nm_connection_get_setting_wired (connection);
|
|
|
|
|
|
|
|
|
|
if (nm_connection_is_type (connection, NM_SETTING_PPPOE_SETTING_NAME)) {
|
|
|
|
|
/* NOP */
|
|
|
|
|
} else if (nm_connection_is_type (connection, NM_SETTING_WIRED_SETTING_NAME)) {
|
2014-05-30 13:44:53 -05:00
|
|
|
if (!s_wired)
|
2011-12-07 13:15:20 +01:00
|
|
|
return FALSE;
|
2014-05-30 13:44:53 -05:00
|
|
|
} else
|
2011-12-07 13:15:20 +01:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
if (s_wired) {
|
2014-10-03 17:37:26 -05:00
|
|
|
const char *mac, *perm_hw_addr;
|
2011-12-07 13:15:20 +01:00
|
|
|
gboolean try_mac = TRUE;
|
2014-10-22 12:31:31 -04:00
|
|
|
const char * const *mac_blacklist;
|
|
|
|
|
int i;
|
2011-12-07 13:15:20 +01:00
|
|
|
|
2014-05-30 13:44:53 -05:00
|
|
|
if (!match_subchans (self, s_wired, &try_mac))
|
2011-12-07 13:15:20 +01:00
|
|
|
return FALSE;
|
|
|
|
|
|
2014-10-03 17:37:26 -05:00
|
|
|
perm_hw_addr = nm_device_get_permanent_hw_address (device);
|
2011-12-07 13:15:20 +01:00
|
|
|
mac = nm_setting_wired_get_mac_address (s_wired);
|
2014-10-03 17:37:26 -05:00
|
|
|
if (perm_hw_addr) {
|
|
|
|
|
if (try_mac && mac && !nm_utils_hwaddr_matches (mac, -1, perm_hw_addr, -1))
|
2011-12-07 13:15:20 +01:00
|
|
|
return FALSE;
|
2014-05-30 13:44:53 -05:00
|
|
|
|
2014-10-03 17:37:26 -05:00
|
|
|
/* Check for MAC address blacklist */
|
|
|
|
|
mac_blacklist = nm_setting_wired_get_mac_address_blacklist (s_wired);
|
|
|
|
|
for (i = 0; mac_blacklist[i]; i++) {
|
|
|
|
|
if (!nm_utils_hwaddr_valid (mac_blacklist[i], ETH_ALEN)) {
|
|
|
|
|
g_warn_if_reached ();
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (nm_utils_hwaddr_matches (mac_blacklist[i], -1, perm_hw_addr, -1))
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
} else if (mac)
|
|
|
|
|
return FALSE;
|
2011-12-07 13:15:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2008-03-18 22:19:09 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
/* 802.1X */
|
|
|
|
|
|
|
|
|
|
static void
|
2016-01-19 13:56:47 +01:00
|
|
|
supplicant_interface_clear_handlers (NMDeviceEthernet *self)
|
2008-03-18 22:19:09 +00:00
|
|
|
{
|
2008-06-10 15:54:23 +00:00
|
|
|
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
|
2008-03-18 22:19:09 +00:00
|
|
|
|
2016-01-04 09:46:22 +01:00
|
|
|
nm_clear_g_source (&priv->supplicant_timeout_id);
|
2016-01-19 13:56:47 +01:00
|
|
|
nm_clear_g_source (&priv->supplicant.con_timeout_id);
|
2016-01-19 13:39:02 +01:00
|
|
|
nm_clear_g_source (&priv->supplicant.iface_con_error_cb_id);
|
2016-01-19 13:56:47 +01:00
|
|
|
nm_clear_g_signal_handler (priv->supplicant.iface, &priv->supplicant.iface_error_id);
|
2008-03-18 22:19:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2008-09-25 10:02:28 +00:00
|
|
|
supplicant_interface_release (NMDeviceEthernet *self)
|
2008-03-18 22:19:09 +00:00
|
|
|
{
|
2008-06-10 15:54:23 +00:00
|
|
|
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
|
2008-03-18 22:19:09 +00:00
|
|
|
|
2016-01-19 13:56:47 +01:00
|
|
|
supplicant_interface_clear_handlers (self);
|
2008-09-25 10:02:28 +00:00
|
|
|
|
2016-01-19 13:39:02 +01:00
|
|
|
nm_clear_g_signal_handler (priv->supplicant.iface, &priv->supplicant.iface_state_id);
|
2008-03-18 22:19:09 +00:00
|
|
|
|
|
|
|
|
if (priv->supplicant.iface) {
|
|
|
|
|
nm_supplicant_interface_disconnect (priv->supplicant.iface);
|
2016-01-19 15:42:24 +01:00
|
|
|
g_clear_object (&priv->supplicant.iface);
|
2008-03-18 22:19:09 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-13 13:11:51 -06:00
|
|
|
static void
|
|
|
|
|
wired_secrets_cb (NMActRequest *req,
|
settings: refactor call_id type of async functions for NMAgentManager, NMSettingsConnection and NMActRequest
Instead of having the call_id of type guint32, make it an (opaque)
pointer type.
This has the advantage of strong typing and avoids the possiblity
of reusing an invalid integer (or overflow of the call-id counter).
OTOH, it has the disadvantage, that after a call_id is disposed,
it might be reused for future invocations (because malloc might
reuse the memory).
In fact, it is always an error to use a call_id that is already
completed. This commit also adds assertions to the cancel() calls
that the provided call_id is a pending call. Hence, such a bug
will be uncovered by assertions (that only might not tigger in
certain unlikely cases where a call-id got reused).
Note that for NMAgentManager, save_secrets() and delete_secrets()
both returned a call_id. But they didn't also provide a callback when
the operation completes. So the user trying to cancel such a call,
cannot know whether the operation is still in process and he cannot
avoid triggering an assertion.
Fix that by not returning a call-id for these operations. No caller
cared about it anyway.
For NMSettingsConnection, also track the internally scheduled requests
for so that we can cancel them on dispose.
2015-09-02 22:43:04 +02:00
|
|
|
NMActRequestGetSecretsCallId call_id,
|
2015-07-14 16:53:24 +02:00
|
|
|
NMSettingsConnection *connection,
|
2010-12-13 13:11:51 -06:00
|
|
|
GError *error,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
2014-08-02 15:14:26 +02:00
|
|
|
NMDeviceEthernet *self = NM_DEVICE_ETHERNET (user_data);
|
|
|
|
|
NMDevice *dev = NM_DEVICE (self);
|
2010-12-13 13:11:51 -06:00
|
|
|
|
2015-09-03 10:24:09 +02:00
|
|
|
if (req != nm_device_get_act_request (dev))
|
|
|
|
|
return;
|
|
|
|
|
|
2010-12-13 13:11:51 -06:00
|
|
|
g_return_if_fail (nm_device_get_state (dev) == NM_DEVICE_STATE_NEED_AUTH);
|
2015-07-14 16:53:24 +02:00
|
|
|
g_return_if_fail (nm_act_request_get_settings_connection (req) == connection);
|
2010-12-13 13:11:51 -06:00
|
|
|
|
|
|
|
|
if (error) {
|
2014-08-02 15:14:26 +02:00
|
|
|
_LOGW (LOGD_ETHER, "%s", error->message);
|
2010-12-13 13:11:51 -06:00
|
|
|
nm_device_state_changed (dev,
|
|
|
|
|
NM_DEVICE_STATE_FAILED,
|
|
|
|
|
NM_DEVICE_STATE_REASON_NO_SECRETS);
|
|
|
|
|
} else
|
|
|
|
|
nm_device_activate_schedule_stage1_device_prepare (dev);
|
|
|
|
|
}
|
|
|
|
|
|
2008-03-18 22:19:09 +00:00
|
|
|
static gboolean
|
|
|
|
|
link_timeout_cb (gpointer user_data)
|
|
|
|
|
{
|
2008-06-10 15:54:23 +00:00
|
|
|
NMDeviceEthernet *self = NM_DEVICE_ETHERNET (user_data);
|
|
|
|
|
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
|
2008-03-18 22:19:09 +00:00
|
|
|
NMDevice *dev = NM_DEVICE (self);
|
|
|
|
|
NMActRequest *req;
|
2015-07-14 16:53:24 +02:00
|
|
|
NMConnection *applied_connection;
|
2008-03-18 22:19:09 +00:00
|
|
|
const char *setting_name;
|
|
|
|
|
|
2009-09-28 12:57:18 -07:00
|
|
|
priv->supplicant_timeout_id = 0;
|
2008-03-18 22:19:09 +00:00
|
|
|
|
|
|
|
|
req = nm_device_get_act_request (dev);
|
|
|
|
|
|
|
|
|
|
if (nm_device_get_state (dev) == NM_DEVICE_STATE_ACTIVATED) {
|
2012-06-04 16:02:20 -05:00
|
|
|
nm_device_state_changed (dev,
|
|
|
|
|
NM_DEVICE_STATE_FAILED,
|
|
|
|
|
NM_DEVICE_STATE_REASON_SUPPLICANT_TIMEOUT);
|
2008-03-18 22:19:09 +00:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Disconnect event during initial authentication and credentials
|
|
|
|
|
* ARE checked - we are likely to have wrong key. Ask the user for
|
|
|
|
|
* another one.
|
|
|
|
|
*/
|
|
|
|
|
if (nm_device_get_state (dev) != NM_DEVICE_STATE_CONFIG)
|
|
|
|
|
goto time_out;
|
|
|
|
|
|
2015-07-14 16:53:24 +02:00
|
|
|
nm_active_connection_clear_secrets (NM_ACTIVE_CONNECTION (req));
|
|
|
|
|
|
|
|
|
|
applied_connection = nm_act_request_get_applied_connection (req);
|
|
|
|
|
setting_name = nm_connection_need_secrets (applied_connection, NULL);
|
2008-03-18 22:19:09 +00:00
|
|
|
if (!setting_name)
|
|
|
|
|
goto time_out;
|
|
|
|
|
|
2014-08-02 15:14:26 +02:00
|
|
|
_LOGI (LOGD_DEVICE | LOGD_ETHER,
|
|
|
|
|
"Activation: (ethernet) disconnected during authentication, asking for new key.");
|
2008-09-25 10:02:28 +00:00
|
|
|
supplicant_interface_release (self);
|
2008-03-18 22:19:09 +00:00
|
|
|
|
2008-07-11 10:28:53 +00:00
|
|
|
nm_device_state_changed (dev, NM_DEVICE_STATE_NEED_AUTH, NM_DEVICE_STATE_REASON_SUPPLICANT_DISCONNECT);
|
2009-06-11 00:39:12 -04:00
|
|
|
nm_act_request_get_secrets (req,
|
|
|
|
|
setting_name,
|
2014-07-07 10:11:46 -04:00
|
|
|
NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW,
|
2009-06-11 00:39:12 -04:00
|
|
|
NULL,
|
2010-12-13 13:11:51 -06:00
|
|
|
wired_secrets_cb,
|
|
|
|
|
self);
|
2008-03-18 22:19:09 +00:00
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
time_out:
|
2014-08-02 15:14:26 +02:00
|
|
|
_LOGW (LOGD_DEVICE | LOGD_ETHER, "link timed out.");
|
2008-07-11 10:28:53 +00:00
|
|
|
nm_device_state_changed (dev, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_SUPPLICANT_DISCONNECT);
|
2008-03-18 22:19:09 +00:00
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static NMSupplicantConfig *
|
2015-11-18 22:03:00 +01:00
|
|
|
build_supplicant_config (NMDeviceEthernet *self,
|
|
|
|
|
GError **error)
|
2008-03-18 22:19:09 +00:00
|
|
|
{
|
2012-01-27 13:04:10 +01:00
|
|
|
const char *con_uuid;
|
2008-07-11 10:28:53 +00:00
|
|
|
NMSupplicantConfig *config = NULL;
|
2008-03-18 22:19:09 +00:00
|
|
|
NMSetting8021x *security;
|
|
|
|
|
NMConnection *connection;
|
2015-09-16 18:22:08 +02:00
|
|
|
guint32 mtu;
|
2008-03-18 22:19:09 +00:00
|
|
|
|
2015-07-14 16:53:24 +02:00
|
|
|
connection = nm_device_get_applied_connection (NM_DEVICE (self));
|
2012-02-23 13:58:41 -06:00
|
|
|
g_assert (connection);
|
2012-01-27 13:04:10 +01:00
|
|
|
con_uuid = nm_connection_get_uuid (connection);
|
2015-09-16 18:22:08 +02:00
|
|
|
mtu = nm_platform_link_get_mtu (NM_PLATFORM_GET,
|
|
|
|
|
nm_device_get_ifindex (NM_DEVICE (self)));
|
2008-03-18 22:19:09 +00:00
|
|
|
|
|
|
|
|
config = nm_supplicant_config_new ();
|
|
|
|
|
|
2011-12-05 12:27:47 +01:00
|
|
|
security = nm_connection_get_setting_802_1x (connection);
|
2015-11-18 22:03:00 +01:00
|
|
|
if (!nm_supplicant_config_add_setting_8021x (config, security, con_uuid, mtu, TRUE, error)) {
|
|
|
|
|
g_prefix_error (error, "802-1x-setting: ");
|
|
|
|
|
g_clear_object (&config);
|
2008-07-11 10:28:53 +00:00
|
|
|
}
|
2008-03-18 22:19:09 +00:00
|
|
|
|
2008-07-11 10:28:53 +00:00
|
|
|
return config;
|
2008-03-18 22:19:09 +00:00
|
|
|
}
|
|
|
|
|
|
2010-10-06 11:05:21 -05:00
|
|
|
static void
|
|
|
|
|
supplicant_iface_state_cb (NMSupplicantInterface *iface,
|
|
|
|
|
guint32 new_state,
|
|
|
|
|
guint32 old_state,
|
2012-09-12 11:58:41 -05:00
|
|
|
int disconnect_reason,
|
2010-10-06 11:05:21 -05:00
|
|
|
gpointer user_data)
|
2008-03-18 22:19:09 +00:00
|
|
|
{
|
2010-10-06 11:05:21 -05:00
|
|
|
NMDeviceEthernet *self = NM_DEVICE_ETHERNET (user_data);
|
|
|
|
|
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
|
|
|
|
|
NMDevice *device = NM_DEVICE (self);
|
|
|
|
|
NMSupplicantConfig *config;
|
|
|
|
|
gboolean success = FALSE;
|
|
|
|
|
NMDeviceState devstate;
|
2015-11-18 22:03:00 +01:00
|
|
|
GError *error = NULL;
|
2010-10-06 11:05:21 -05:00
|
|
|
|
|
|
|
|
if (new_state == old_state)
|
|
|
|
|
return;
|
|
|
|
|
|
2014-08-02 15:14:26 +02:00
|
|
|
_LOGI (LOGD_DEVICE | LOGD_ETHER, "supplicant interface state: %s -> %s",
|
|
|
|
|
nm_supplicant_interface_state_to_string (old_state),
|
|
|
|
|
nm_supplicant_interface_state_to_string (new_state));
|
2008-03-18 22:19:09 +00:00
|
|
|
|
2010-10-06 11:05:21 -05:00
|
|
|
devstate = nm_device_get_state (device);
|
2008-03-18 22:19:09 +00:00
|
|
|
|
2010-10-06 11:05:21 -05:00
|
|
|
switch (new_state) {
|
|
|
|
|
case NM_SUPPLICANT_INTERFACE_STATE_READY:
|
2015-11-18 22:03:00 +01:00
|
|
|
config = build_supplicant_config (self, &error);
|
2008-03-18 22:19:09 +00:00
|
|
|
if (config) {
|
2015-11-18 22:03:00 +01:00
|
|
|
success = nm_supplicant_interface_set_config (priv->supplicant.iface, config, &error);
|
2008-03-18 22:19:09 +00:00
|
|
|
g_object_unref (config);
|
|
|
|
|
|
2010-04-07 13:24:25 -07:00
|
|
|
if (!success) {
|
2014-08-02 15:14:26 +02:00
|
|
|
_LOGE (LOGD_DEVICE | LOGD_ETHER,
|
2015-11-18 22:03:00 +01:00
|
|
|
"Activation: (ethernet) couldn't send security configuration to the supplicant: %s",
|
|
|
|
|
error ? error->message : "<BUG>");
|
|
|
|
|
g_clear_error (&error);
|
2010-04-07 13:24:25 -07:00
|
|
|
}
|
|
|
|
|
} else {
|
2015-11-18 22:03:00 +01:00
|
|
|
_LOGE (LOGD_DEVICE | LOGD_ETHER,
|
|
|
|
|
"Activation: (ethernet) couldn't build security configuration: %s",
|
|
|
|
|
error ? error->message : "<BUG>");
|
|
|
|
|
g_clear_error (&error);
|
2010-04-07 13:24:25 -07:00
|
|
|
}
|
2008-03-18 22:19:09 +00:00
|
|
|
|
2010-10-06 11:05:21 -05:00
|
|
|
if (!success) {
|
|
|
|
|
nm_device_state_changed (device,
|
|
|
|
|
NM_DEVICE_STATE_FAILED,
|
|
|
|
|
NM_DEVICE_STATE_REASON_SUPPLICANT_CONFIG_FAILED);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case NM_SUPPLICANT_INTERFACE_STATE_COMPLETED:
|
2016-01-19 13:56:47 +01:00
|
|
|
supplicant_interface_clear_handlers (self);
|
2008-03-18 22:19:09 +00:00
|
|
|
|
|
|
|
|
/* If this is the initial association during device activation,
|
|
|
|
|
* schedule the next activation stage.
|
|
|
|
|
*/
|
2010-10-06 11:05:21 -05:00
|
|
|
if (devstate == NM_DEVICE_STATE_CONFIG) {
|
2014-08-02 15:14:26 +02:00
|
|
|
_LOGI (LOGD_DEVICE | LOGD_ETHER,
|
|
|
|
|
"Activation: (ethernet) Stage 2 of 5 (Device Configure) successful.");
|
2010-10-06 11:05:21 -05:00
|
|
|
nm_device_activate_schedule_stage3_ip_config_start (device);
|
2008-03-18 22:19:09 +00:00
|
|
|
}
|
2010-10-06 11:05:21 -05:00
|
|
|
break;
|
|
|
|
|
case NM_SUPPLICANT_INTERFACE_STATE_DISCONNECTED:
|
|
|
|
|
if ((devstate == NM_DEVICE_STATE_ACTIVATED) || nm_device_is_activating (device)) {
|
2008-03-18 22:19:09 +00:00
|
|
|
/* Start the link timeout so we allow some time for reauthentication */
|
2009-09-28 12:57:18 -07:00
|
|
|
if (!priv->supplicant_timeout_id)
|
2010-10-06 11:05:21 -05:00
|
|
|
priv->supplicant_timeout_id = g_timeout_add_seconds (15, link_timeout_cb, device);
|
2008-03-18 22:19:09 +00:00
|
|
|
}
|
2010-10-06 11:05:21 -05:00
|
|
|
break;
|
|
|
|
|
case NM_SUPPLICANT_INTERFACE_STATE_DOWN:
|
|
|
|
|
supplicant_interface_release (self);
|
2008-03-18 22:19:09 +00:00
|
|
|
|
2010-10-06 11:05:21 -05:00
|
|
|
if ((devstate == NM_DEVICE_STATE_ACTIVATED) || nm_device_is_activating (device)) {
|
|
|
|
|
nm_device_state_changed (device,
|
|
|
|
|
NM_DEVICE_STATE_FAILED,
|
|
|
|
|
NM_DEVICE_STATE_REASON_SUPPLICANT_FAILED);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2008-03-18 22:19:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
supplicant_iface_connection_error_cb_handler (gpointer user_data)
|
|
|
|
|
{
|
2008-06-10 15:54:23 +00:00
|
|
|
NMDeviceEthernet *self = NM_DEVICE_ETHERNET (user_data);
|
2008-09-25 10:02:28 +00:00
|
|
|
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
|
2008-03-18 22:19:09 +00:00
|
|
|
|
2008-09-25 10:02:28 +00:00
|
|
|
supplicant_interface_release (self);
|
2008-07-11 10:28:53 +00:00
|
|
|
nm_device_state_changed (NM_DEVICE (self), NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_SUPPLICANT_CONFIG_FAILED);
|
2008-03-18 22:19:09 +00:00
|
|
|
|
2008-09-25 10:02:28 +00:00
|
|
|
priv->supplicant.iface_con_error_cb_id = 0;
|
2008-03-18 22:19:09 +00:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
supplicant_iface_connection_error_cb (NMSupplicantInterface *iface,
|
|
|
|
|
const char *name,
|
|
|
|
|
const char *message,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
2008-09-25 10:02:28 +00:00
|
|
|
NMDeviceEthernet *self = NM_DEVICE_ETHERNET (user_data);
|
|
|
|
|
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
|
|
|
|
|
guint id;
|
2008-03-18 22:19:09 +00:00
|
|
|
|
2014-08-02 15:14:26 +02:00
|
|
|
_LOGW (LOGD_DEVICE | LOGD_ETHER,
|
|
|
|
|
"Activation: (ethernet) association request to the supplicant failed: %s - %s",
|
|
|
|
|
name, message);
|
2008-09-25 10:02:28 +00:00
|
|
|
|
|
|
|
|
if (priv->supplicant.iface_con_error_cb_id)
|
|
|
|
|
g_source_remove (priv->supplicant.iface_con_error_cb_id);
|
2008-03-18 22:19:09 +00:00
|
|
|
|
2008-09-25 10:02:28 +00:00
|
|
|
id = g_idle_add (supplicant_iface_connection_error_cb_handler, self);
|
|
|
|
|
priv->supplicant.iface_con_error_cb_id = id;
|
2008-03-18 22:19:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static NMActStageReturn
|
2008-06-10 15:54:23 +00:00
|
|
|
handle_auth_or_fail (NMDeviceEthernet *self,
|
2008-03-18 22:19:09 +00:00
|
|
|
NMActRequest *req,
|
|
|
|
|
gboolean new_secrets)
|
|
|
|
|
{
|
|
|
|
|
const char *setting_name;
|
|
|
|
|
guint32 tries;
|
2015-07-14 16:53:24 +02:00
|
|
|
NMConnection *applied_connection;
|
2008-03-18 22:19:09 +00:00
|
|
|
|
2015-07-14 16:53:24 +02:00
|
|
|
applied_connection = nm_act_request_get_applied_connection (req);
|
2008-03-18 22:19:09 +00:00
|
|
|
|
2015-07-14 16:53:24 +02:00
|
|
|
tries = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (applied_connection), WIRED_SECRETS_TRIES));
|
2008-03-18 22:19:09 +00:00
|
|
|
if (tries > 3)
|
|
|
|
|
return NM_ACT_STAGE_RETURN_FAILURE;
|
|
|
|
|
|
2008-07-11 10:28:53 +00:00
|
|
|
nm_device_state_changed (NM_DEVICE (self), NM_DEVICE_STATE_NEED_AUTH, NM_DEVICE_STATE_REASON_NONE);
|
2008-03-18 22:19:09 +00:00
|
|
|
|
2015-07-14 16:53:24 +02:00
|
|
|
nm_active_connection_clear_secrets (NM_ACTIVE_CONNECTION (req));
|
|
|
|
|
|
|
|
|
|
setting_name = nm_connection_need_secrets (applied_connection, NULL);
|
2008-03-18 22:19:09 +00:00
|
|
|
if (setting_name) {
|
2014-07-07 10:11:46 -04:00
|
|
|
NMSecretAgentGetSecretsFlags flags = NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION;
|
2008-03-18 22:19:09 +00:00
|
|
|
|
2013-12-11 16:06:35 +01:00
|
|
|
if (new_secrets)
|
2014-07-07 10:11:46 -04:00
|
|
|
flags |= NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW;
|
2011-01-26 18:36:08 -06:00
|
|
|
nm_act_request_get_secrets (req, setting_name, flags, NULL, wired_secrets_cb, self);
|
2008-03-18 22:19:09 +00:00
|
|
|
|
2015-07-14 16:53:24 +02:00
|
|
|
g_object_set_data (G_OBJECT (applied_connection), WIRED_SECRETS_TRIES, GUINT_TO_POINTER (++tries));
|
2014-08-02 15:14:26 +02:00
|
|
|
} else
|
|
|
|
|
_LOGI (LOGD_DEVICE, "Cleared secrets, but setting didn't need any secrets.");
|
2008-03-18 22:19:09 +00:00
|
|
|
|
|
|
|
|
return NM_ACT_STAGE_RETURN_POSTPONE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
supplicant_connection_timeout_cb (gpointer user_data)
|
|
|
|
|
{
|
2008-06-10 15:54:23 +00:00
|
|
|
NMDeviceEthernet *self = NM_DEVICE_ETHERNET (user_data);
|
2008-09-25 10:02:28 +00:00
|
|
|
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
|
2008-03-18 22:19:09 +00:00
|
|
|
NMDevice *device = NM_DEVICE (self);
|
|
|
|
|
NMActRequest *req;
|
2013-12-11 16:06:35 +01:00
|
|
|
NMConnection *connection;
|
|
|
|
|
guint64 timestamp = 0;
|
|
|
|
|
gboolean new_secrets = TRUE;
|
2008-03-18 22:19:09 +00:00
|
|
|
|
2008-09-25 10:02:28 +00:00
|
|
|
priv->supplicant.con_timeout_id = 0;
|
|
|
|
|
|
2013-12-11 16:06:35 +01:00
|
|
|
/* Authentication failed; either driver problems, the encryption key is
|
|
|
|
|
* wrong, the passwords or certificates were wrong or the Ethernet switch's
|
|
|
|
|
* port is not configured for 802.1x. */
|
2014-08-02 15:14:26 +02:00
|
|
|
_LOGW (LOGD_DEVICE | LOGD_ETHER,
|
|
|
|
|
"Activation: (ethernet) association took too long.");
|
2008-03-18 22:19:09 +00:00
|
|
|
|
2008-09-25 10:02:28 +00:00
|
|
|
supplicant_interface_release (self);
|
2008-03-18 22:19:09 +00:00
|
|
|
req = nm_device_get_act_request (device);
|
|
|
|
|
g_assert (req);
|
|
|
|
|
|
2015-07-14 16:53:24 +02:00
|
|
|
connection = nm_act_request_get_applied_connection (req);
|
2013-12-11 16:06:35 +01:00
|
|
|
g_assert (connection);
|
|
|
|
|
|
|
|
|
|
/* Ask for new secrets only if we've never activated this connection
|
|
|
|
|
* before. If we've connected before, don't bother the user with dialogs,
|
|
|
|
|
* just retry or fail, and if we never connect the user can fix the
|
|
|
|
|
* password somewhere else. */
|
|
|
|
|
if (nm_settings_connection_get_timestamp (NM_SETTINGS_CONNECTION (connection), ×tamp))
|
|
|
|
|
new_secrets = !timestamp;
|
|
|
|
|
|
2014-08-02 15:14:26 +02:00
|
|
|
if (handle_auth_or_fail (self, req, new_secrets) == NM_ACT_STAGE_RETURN_POSTPONE)
|
|
|
|
|
_LOGW (LOGD_DEVICE | LOGD_ETHER, "Activation: (ethernet) asking for new secrets");
|
|
|
|
|
else
|
2008-07-11 10:28:53 +00:00
|
|
|
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_NO_SECRETS);
|
2008-03-18 22:19:09 +00:00
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
2008-06-10 15:54:23 +00:00
|
|
|
supplicant_interface_init (NMDeviceEthernet *self)
|
2008-03-18 22:19:09 +00:00
|
|
|
{
|
2008-06-10 15:54:23 +00:00
|
|
|
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
|
2008-03-18 22:19:09 +00:00
|
|
|
|
2016-01-19 15:42:24 +01:00
|
|
|
supplicant_interface_release (self);
|
|
|
|
|
|
|
|
|
|
priv->supplicant.iface = nm_supplicant_manager_create_interface (priv->supplicant.mgr,
|
|
|
|
|
nm_device_get_iface (NM_DEVICE (self)),
|
|
|
|
|
FALSE);
|
|
|
|
|
|
2008-03-18 22:19:09 +00:00
|
|
|
if (!priv->supplicant.iface) {
|
2014-08-02 15:14:26 +02:00
|
|
|
_LOGE (LOGD_DEVICE | LOGD_ETHER,
|
|
|
|
|
"Couldn't initialize supplicant interface");
|
2008-03-18 22:19:09 +00:00
|
|
|
return FALSE;
|
2008-03-11 16:37:41 +00:00
|
|
|
}
|
2008-03-18 22:19:09 +00:00
|
|
|
|
|
|
|
|
/* Listen for it's state signals */
|
|
|
|
|
priv->supplicant.iface_state_id = g_signal_connect (priv->supplicant.iface,
|
2012-09-12 11:28:02 -05:00
|
|
|
NM_SUPPLICANT_INTERFACE_STATE,
|
2010-10-06 11:05:21 -05:00
|
|
|
G_CALLBACK (supplicant_iface_state_cb),
|
|
|
|
|
self);
|
2008-03-18 22:19:09 +00:00
|
|
|
|
|
|
|
|
/* Hook up error signal handler to capture association errors */
|
|
|
|
|
priv->supplicant.iface_error_id = g_signal_connect (priv->supplicant.iface,
|
2010-10-06 11:05:21 -05:00
|
|
|
"connection-error",
|
|
|
|
|
G_CALLBACK (supplicant_iface_connection_error_cb),
|
|
|
|
|
self);
|
2008-03-18 22:19:09 +00:00
|
|
|
|
|
|
|
|
/* Set up a timeout on the connection attempt to fail it after 25 seconds */
|
2008-12-31 18:57:36 -05:00
|
|
|
priv->supplicant.con_timeout_id = g_timeout_add_seconds (25, supplicant_connection_timeout_cb, self);
|
2008-03-18 22:19:09 +00:00
|
|
|
|
|
|
|
|
return TRUE;
|
2008-03-11 16:37:41 +00:00
|
|
|
}
|
|
|
|
|
|
2013-12-09 09:33:13 +01:00
|
|
|
static gboolean
|
|
|
|
|
pppoe_reconnect_delay (gpointer user_data)
|
|
|
|
|
{
|
2014-08-02 15:14:26 +02:00
|
|
|
NMDeviceEthernet *self = NM_DEVICE_ETHERNET (user_data);
|
|
|
|
|
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
|
2013-12-09 09:33:13 +01:00
|
|
|
|
|
|
|
|
priv->pppoe_wait_id = 0;
|
2014-08-02 15:14:26 +02:00
|
|
|
_LOGI (LOGD_DEVICE, "PPPoE reconnect delay complete, resuming connection...");
|
|
|
|
|
nm_device_activate_schedule_stage2_device_config (NM_DEVICE (self));
|
2013-12-09 09:33:13 +01:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-22 14:21:25 +02:00
|
|
|
static NMActStageReturn
|
2012-09-27 12:12:15 -04:00
|
|
|
act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason)
|
2010-06-22 14:21:25 +02:00
|
|
|
{
|
|
|
|
|
NMDeviceEthernet *self = NM_DEVICE_ETHERNET (dev);
|
2013-12-09 09:33:13 +01:00
|
|
|
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
|
2010-06-22 14:21:25 +02:00
|
|
|
NMSettingWired *s_wired;
|
2014-07-30 10:57:45 -04:00
|
|
|
const char *cloned_mac;
|
2010-06-22 14:21:25 +02:00
|
|
|
NMActStageReturn ret = NM_ACT_STAGE_RETURN_SUCCESS;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE);
|
|
|
|
|
|
2012-02-28 18:35:30 -06:00
|
|
|
ret = NM_DEVICE_CLASS (nm_device_ethernet_parent_class)->act_stage1_prepare (dev, reason);
|
|
|
|
|
if (ret == NM_ACT_STAGE_RETURN_SUCCESS) {
|
2016-02-11 21:33:15 +01:00
|
|
|
s_wired = (NMSettingWired *) nm_device_get_applied_setting (dev, NM_TYPE_SETTING_WIRED);
|
2013-04-10 13:34:32 -05:00
|
|
|
if (s_wired) {
|
|
|
|
|
/* Set device MAC address if the connection wants to change it */
|
|
|
|
|
cloned_mac = nm_setting_wired_get_cloned_mac_address (s_wired);
|
2014-07-30 10:57:45 -04:00
|
|
|
if (cloned_mac)
|
|
|
|
|
nm_device_set_hw_addr (dev, cloned_mac, "set", LOGD_ETHER);
|
2013-04-10 13:34:32 -05:00
|
|
|
}
|
2013-12-09 09:33:13 +01:00
|
|
|
|
|
|
|
|
/* If we're re-activating a PPPoE connection a short while after
|
|
|
|
|
* a previous PPPoE connection was torn down, wait a bit to allow the
|
|
|
|
|
* remote side to handle the disconnection. Otherwise the peer may
|
|
|
|
|
* get confused and fail to negotiate the new connection. (rh #1023503)
|
|
|
|
|
*/
|
|
|
|
|
if (priv->last_pppoe_time) {
|
2013-12-10 20:39:48 +01:00
|
|
|
gint32 delay = nm_utils_get_monotonic_timestamp_s () - priv->last_pppoe_time;
|
2013-12-09 09:33:13 +01:00
|
|
|
|
2016-02-11 21:33:15 +01:00
|
|
|
if ( delay < PPPOE_RECONNECT_DELAY
|
|
|
|
|
&& nm_device_get_applied_setting (dev, NM_TYPE_SETTING_PPPOE)) {
|
2014-08-02 15:14:26 +02:00
|
|
|
_LOGI (LOGD_DEVICE, "delaying PPPoE reconnect for %d seconds to ensure peer is ready...",
|
|
|
|
|
delay);
|
2013-12-09 09:33:13 +01:00
|
|
|
g_assert (!priv->pppoe_wait_id);
|
|
|
|
|
priv->pppoe_wait_id = g_timeout_add_seconds (delay,
|
|
|
|
|
pppoe_reconnect_delay,
|
|
|
|
|
self);
|
|
|
|
|
ret = NM_ACT_STAGE_RETURN_POSTPONE;
|
|
|
|
|
} else
|
|
|
|
|
priv->last_pppoe_time = 0;
|
|
|
|
|
}
|
2012-02-28 18:35:30 -06:00
|
|
|
}
|
2010-06-22 14:21:25 +02:00
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2008-03-18 22:19:09 +00:00
|
|
|
static NMActStageReturn
|
2008-07-11 10:28:53 +00:00
|
|
|
nm_8021x_stage2_config (NMDeviceEthernet *self, NMDeviceStateReason *reason)
|
2008-03-18 22:19:09 +00:00
|
|
|
{
|
2013-06-12 10:48:03 -05:00
|
|
|
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
|
2008-03-18 22:19:09 +00:00
|
|
|
NMConnection *connection;
|
|
|
|
|
NMSetting8021x *security;
|
|
|
|
|
const char *setting_name;
|
|
|
|
|
NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
|
|
|
|
|
|
2015-07-14 16:53:24 +02:00
|
|
|
connection = nm_device_get_applied_connection (NM_DEVICE (self));
|
2012-02-23 13:58:41 -06:00
|
|
|
g_assert (connection);
|
2011-12-05 12:27:47 +01:00
|
|
|
security = nm_connection_get_setting_802_1x (connection);
|
2008-03-18 22:19:09 +00:00
|
|
|
if (!security) {
|
2014-08-02 15:14:26 +02:00
|
|
|
_LOGE (LOGD_DEVICE, "Invalid or missing 802.1X security");
|
2008-07-11 10:28:53 +00:00
|
|
|
*reason = NM_DEVICE_STATE_REASON_CONFIG_FAILED;
|
2008-03-18 22:19:09 +00:00
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-12 10:48:03 -05:00
|
|
|
if (!priv->supplicant.mgr)
|
2015-01-06 11:54:27 +01:00
|
|
|
priv->supplicant.mgr = g_object_ref (nm_supplicant_manager_get ());
|
2013-06-12 10:48:03 -05:00
|
|
|
|
2008-03-18 22:19:09 +00:00
|
|
|
/* If we need secrets, get them */
|
|
|
|
|
setting_name = nm_connection_need_secrets (connection, NULL);
|
|
|
|
|
if (setting_name) {
|
2008-07-11 10:28:53 +00:00
|
|
|
NMActRequest *req = nm_device_get_act_request (NM_DEVICE (self));
|
|
|
|
|
|
2014-08-02 15:14:26 +02:00
|
|
|
_LOGI (LOGD_DEVICE | LOGD_ETHER,
|
|
|
|
|
"Activation: (ethernet) connection '%s' has security, but secrets are required.",
|
|
|
|
|
nm_connection_get_id (connection));
|
2008-03-18 22:19:09 +00:00
|
|
|
|
2008-07-11 10:28:53 +00:00
|
|
|
ret = handle_auth_or_fail (self, req, FALSE);
|
|
|
|
|
if (ret != NM_ACT_STAGE_RETURN_POSTPONE)
|
|
|
|
|
*reason = NM_DEVICE_STATE_REASON_NO_SECRETS;
|
2008-03-18 22:19:09 +00:00
|
|
|
} else {
|
2014-08-02 15:14:26 +02:00
|
|
|
_LOGI (LOGD_DEVICE | LOGD_ETHER,
|
|
|
|
|
"Activation: (ethernet) connection '%s' requires no security. No secrets needed.",
|
|
|
|
|
nm_connection_get_id (connection));
|
2008-03-18 22:19:09 +00:00
|
|
|
|
|
|
|
|
if (supplicant_interface_init (self))
|
|
|
|
|
ret = NM_ACT_STAGE_RETURN_POSTPONE;
|
2008-07-11 10:28:53 +00:00
|
|
|
else
|
|
|
|
|
*reason = NM_DEVICE_STATE_REASON_CONFIG_FAILED;
|
2008-03-18 22:19:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
2008-03-11 16:37:41 +00:00
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/* PPPoE */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
ppp_state_changed (NMPPPManager *ppp_manager, NMPPPStatus status, gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMDevice *device = NM_DEVICE (user_data);
|
|
|
|
|
|
|
|
|
|
switch (status) {
|
|
|
|
|
case NM_PPP_STATUS_DISCONNECT:
|
2008-07-11 10:28:53 +00:00
|
|
|
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_PPP_DISCONNECT);
|
2008-03-11 16:37:41 +00:00
|
|
|
break;
|
|
|
|
|
case NM_PPP_STATUS_DEAD:
|
2008-07-11 10:28:53 +00:00
|
|
|
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_PPP_FAILED);
|
2008-03-11 16:37:41 +00:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
ppp_ip4_config (NMPPPManager *ppp_manager,
|
2011-10-09 22:50:04 -05:00
|
|
|
const char *iface,
|
|
|
|
|
NMIP4Config *config,
|
|
|
|
|
gpointer user_data)
|
2008-03-11 16:37:41 +00:00
|
|
|
{
|
|
|
|
|
NMDevice *device = NM_DEVICE (user_data);
|
|
|
|
|
|
2009-09-09 07:44:21 -07:00
|
|
|
/* Ignore PPP IP4 events that come in after initial configuration */
|
2011-10-09 23:48:13 -05:00
|
|
|
if (nm_device_activate_ip4_state_in_conf (device)) {
|
2011-10-09 22:50:04 -05:00
|
|
|
nm_device_set_ip_iface (device, iface);
|
|
|
|
|
nm_device_activate_schedule_ip4_config_result (device, config);
|
|
|
|
|
}
|
2008-03-11 16:37:41 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
static NMActStageReturn
|
2009-08-17 15:35:02 -05:00
|
|
|
pppoe_stage3_ip4_config_start (NMDeviceEthernet *self, NMDeviceStateReason *reason)
|
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
|
|
|
{
|
2008-06-10 15:54:23 +00:00
|
|
|
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 13:44:36 -04:00
|
|
|
NMSettingPppoe *s_pppoe;
|
2008-03-11 16:37:41 +00:00
|
|
|
NMActRequest *req;
|
|
|
|
|
GError *err = NULL;
|
2008-07-11 10:28:53 +00:00
|
|
|
NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
|
2008-03-11 16:37:41 +00:00
|
|
|
|
|
|
|
|
req = nm_device_get_act_request (NM_DEVICE (self));
|
|
|
|
|
g_assert (req);
|
|
|
|
|
|
2016-02-11 21:33:15 +01:00
|
|
|
s_pppoe = (NMSettingPppoe *) nm_device_get_applied_setting (self, NM_TYPE_SETTING_PPPOE);
|
2008-10-02 17:10:00 +00:00
|
|
|
g_assert (s_pppoe);
|
|
|
|
|
|
2008-08-04 21:37:11 +00:00
|
|
|
priv->ppp_manager = nm_ppp_manager_new (nm_device_get_iface (NM_DEVICE (self)));
|
2009-11-22 23:56:16 -08:00
|
|
|
if (nm_ppp_manager_start (priv->ppp_manager, req, nm_setting_pppoe_get_username (s_pppoe), 30, &err)) {
|
2015-12-07 19:47:24 +01:00
|
|
|
g_signal_connect (priv->ppp_manager, NM_PPP_MANAGER_STATE_CHANGED,
|
|
|
|
|
G_CALLBACK (ppp_state_changed),
|
|
|
|
|
self);
|
2008-03-11 16:37:41 +00:00
|
|
|
g_signal_connect (priv->ppp_manager, "ip4-config",
|
2015-12-07 19:47:24 +01:00
|
|
|
G_CALLBACK (ppp_ip4_config),
|
|
|
|
|
self);
|
2008-03-11 16:37:41 +00:00
|
|
|
ret = NM_ACT_STAGE_RETURN_POSTPONE;
|
|
|
|
|
} else {
|
2014-08-02 15:14:26 +02:00
|
|
|
_LOGW (LOGD_DEVICE, "PPPoE failed to start: %s", err->message);
|
2008-03-11 16:37:41 +00:00
|
|
|
g_error_free (err);
|
|
|
|
|
|
2015-07-23 10:03:21 -05:00
|
|
|
nm_exported_object_clear_and_unexport (&priv->ppp_manager);
|
2008-03-11 16:37:41 +00:00
|
|
|
|
2008-07-11 10:28:53 +00:00
|
|
|
*reason = NM_DEVICE_STATE_REASON_PPP_START_FAILED;
|
2008-03-11 16:37:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
dcb: separate DCB enable/disable and wait for carrier changes (rh #799241) (rh #1081991)
Non-git-master versions of lldpad refuse to touch a device that doesn't
have a carrier. And when enabling/disabling DCB, the kernel driver will
reconfigure itself and may turn carrier off for a few seconds. So we
must ensure that before enabling/disabling DCB, the carrier is already
on. Next we must ensure that *after* enabling/disabling DCB, the
carrier is back on before doing further DCB setup.
There's a race condition between enabling/disabling DCB and receiving
the carrier event in NetworkManager that has to be handled carefully.
Because the carrier may not yet be down after the dcbtool call to
enable/disable DCB returns, we need to wait for a couple seconds for
the carrier to go down, and then again for it to come back up.
Otherwise we might see the still-on carrier, proceed with DCB setup,
and the carrier finally goes down halfway through the setup, which
will fail the operations with "DCB not enabled, link down, or DCB
not supported" errors from lldpad.
2014-03-27 13:49:50 -05:00
|
|
|
/****************************************************************/
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
dcb_timeout_cleanup (NMDevice *device)
|
|
|
|
|
{
|
|
|
|
|
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (device);
|
|
|
|
|
|
2016-01-04 09:46:22 +01:00
|
|
|
nm_clear_g_source (&priv->dcb_timeout_id);
|
dcb: separate DCB enable/disable and wait for carrier changes (rh #799241) (rh #1081991)
Non-git-master versions of lldpad refuse to touch a device that doesn't
have a carrier. And when enabling/disabling DCB, the kernel driver will
reconfigure itself and may turn carrier off for a few seconds. So we
must ensure that before enabling/disabling DCB, the carrier is already
on. Next we must ensure that *after* enabling/disabling DCB, the
carrier is back on before doing further DCB setup.
There's a race condition between enabling/disabling DCB and receiving
the carrier event in NetworkManager that has to be handled carefully.
Because the carrier may not yet be down after the dcbtool call to
enable/disable DCB returns, we need to wait for a couple seconds for
the carrier to go down, and then again for it to come back up.
Otherwise we might see the still-on carrier, proceed with DCB setup,
and the carrier finally goes down halfway through the setup, which
will fail the operations with "DCB not enabled, link down, or DCB
not supported" errors from lldpad.
2014-03-27 13:49:50 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
dcb_carrier_cleanup (NMDevice *device)
|
|
|
|
|
{
|
|
|
|
|
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (device);
|
|
|
|
|
|
2016-01-04 10:35:11 +01:00
|
|
|
nm_clear_g_signal_handler (device, &priv->dcb_carrier_id);
|
dcb: separate DCB enable/disable and wait for carrier changes (rh #799241) (rh #1081991)
Non-git-master versions of lldpad refuse to touch a device that doesn't
have a carrier. And when enabling/disabling DCB, the kernel driver will
reconfigure itself and may turn carrier off for a few seconds. So we
must ensure that before enabling/disabling DCB, the carrier is already
on. Next we must ensure that *after* enabling/disabling DCB, the
carrier is back on before doing further DCB setup.
There's a race condition between enabling/disabling DCB and receiving
the carrier event in NetworkManager that has to be handled carefully.
Because the carrier may not yet be down after the dcbtool call to
enable/disable DCB returns, we need to wait for a couple seconds for
the carrier to go down, and then again for it to come back up.
Otherwise we might see the still-on carrier, proceed with DCB setup,
and the carrier finally goes down halfway through the setup, which
will fail the operations with "DCB not enabled, link down, or DCB
not supported" errors from lldpad.
2014-03-27 13:49:50 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void dcb_state (NMDevice *device, gboolean timeout);
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
dcb_carrier_timeout (gpointer user_data)
|
|
|
|
|
{
|
2014-08-02 15:14:26 +02:00
|
|
|
NMDeviceEthernet *self = NM_DEVICE_ETHERNET (user_data);
|
|
|
|
|
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
|
dcb: separate DCB enable/disable and wait for carrier changes (rh #799241) (rh #1081991)
Non-git-master versions of lldpad refuse to touch a device that doesn't
have a carrier. And when enabling/disabling DCB, the kernel driver will
reconfigure itself and may turn carrier off for a few seconds. So we
must ensure that before enabling/disabling DCB, the carrier is already
on. Next we must ensure that *after* enabling/disabling DCB, the
carrier is back on before doing further DCB setup.
There's a race condition between enabling/disabling DCB and receiving
the carrier event in NetworkManager that has to be handled carefully.
Because the carrier may not yet be down after the dcbtool call to
enable/disable DCB returns, we need to wait for a couple seconds for
the carrier to go down, and then again for it to come back up.
Otherwise we might see the still-on carrier, proceed with DCB setup,
and the carrier finally goes down halfway through the setup, which
will fail the operations with "DCB not enabled, link down, or DCB
not supported" errors from lldpad.
2014-03-27 13:49:50 -05:00
|
|
|
NMDevice *device = NM_DEVICE (user_data);
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (nm_device_get_state (device) == NM_DEVICE_STATE_CONFIG, G_SOURCE_REMOVE);
|
|
|
|
|
|
|
|
|
|
priv->dcb_timeout_id = 0;
|
|
|
|
|
if (priv->dcb_wait != DCB_WAIT_CARRIER_POSTCONFIG_DOWN) {
|
2014-08-02 15:14:26 +02:00
|
|
|
_LOGW (LOGD_DCB, "DCB: timed out waiting for carrier (step %d)",
|
|
|
|
|
priv->dcb_wait);
|
dcb: separate DCB enable/disable and wait for carrier changes (rh #799241) (rh #1081991)
Non-git-master versions of lldpad refuse to touch a device that doesn't
have a carrier. And when enabling/disabling DCB, the kernel driver will
reconfigure itself and may turn carrier off for a few seconds. So we
must ensure that before enabling/disabling DCB, the carrier is already
on. Next we must ensure that *after* enabling/disabling DCB, the
carrier is back on before doing further DCB setup.
There's a race condition between enabling/disabling DCB and receiving
the carrier event in NetworkManager that has to be handled carefully.
Because the carrier may not yet be down after the dcbtool call to
enable/disable DCB returns, we need to wait for a couple seconds for
the carrier to go down, and then again for it to come back up.
Otherwise we might see the still-on carrier, proceed with DCB setup,
and the carrier finally goes down halfway through the setup, which
will fail the operations with "DCB not enabled, link down, or DCB
not supported" errors from lldpad.
2014-03-27 13:49:50 -05:00
|
|
|
}
|
|
|
|
|
dcb_state (device, TRUE);
|
|
|
|
|
return G_SOURCE_REMOVE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
dcb_configure (NMDevice *device)
|
|
|
|
|
{
|
2014-08-02 15:14:26 +02:00
|
|
|
NMDeviceEthernet *self = NM_DEVICE_ETHERNET (device);
|
dcb: separate DCB enable/disable and wait for carrier changes (rh #799241) (rh #1081991)
Non-git-master versions of lldpad refuse to touch a device that doesn't
have a carrier. And when enabling/disabling DCB, the kernel driver will
reconfigure itself and may turn carrier off for a few seconds. So we
must ensure that before enabling/disabling DCB, the carrier is already
on. Next we must ensure that *after* enabling/disabling DCB, the
carrier is back on before doing further DCB setup.
There's a race condition between enabling/disabling DCB and receiving
the carrier event in NetworkManager that has to be handled carefully.
Because the carrier may not yet be down after the dcbtool call to
enable/disable DCB returns, we need to wait for a couple seconds for
the carrier to go down, and then again for it to come back up.
Otherwise we might see the still-on carrier, proceed with DCB setup,
and the carrier finally goes down halfway through the setup, which
will fail the operations with "DCB not enabled, link down, or DCB
not supported" errors from lldpad.
2014-03-27 13:49:50 -05:00
|
|
|
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (device);
|
|
|
|
|
NMSettingDcb *s_dcb;
|
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
|
|
dcb_timeout_cleanup (device);
|
|
|
|
|
|
2016-02-11 21:33:15 +01:00
|
|
|
s_dcb = (NMSettingDcb *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_DCB);
|
dcb: separate DCB enable/disable and wait for carrier changes (rh #799241) (rh #1081991)
Non-git-master versions of lldpad refuse to touch a device that doesn't
have a carrier. And when enabling/disabling DCB, the kernel driver will
reconfigure itself and may turn carrier off for a few seconds. So we
must ensure that before enabling/disabling DCB, the carrier is already
on. Next we must ensure that *after* enabling/disabling DCB, the
carrier is back on before doing further DCB setup.
There's a race condition between enabling/disabling DCB and receiving
the carrier event in NetworkManager that has to be handled carefully.
Because the carrier may not yet be down after the dcbtool call to
enable/disable DCB returns, we need to wait for a couple seconds for
the carrier to go down, and then again for it to come back up.
Otherwise we might see the still-on carrier, proceed with DCB setup,
and the carrier finally goes down halfway through the setup, which
will fail the operations with "DCB not enabled, link down, or DCB
not supported" errors from lldpad.
2014-03-27 13:49:50 -05:00
|
|
|
g_assert (s_dcb);
|
2014-08-02 15:14:26 +02:00
|
|
|
if (!nm_dcb_setup (nm_device_get_iface (device), s_dcb, &error)) {
|
|
|
|
|
_LOGW (LOGD_DCB, "Activation: (ethernet) failed to enable DCB/FCoE: %s",
|
|
|
|
|
error->message);
|
dcb: separate DCB enable/disable and wait for carrier changes (rh #799241) (rh #1081991)
Non-git-master versions of lldpad refuse to touch a device that doesn't
have a carrier. And when enabling/disabling DCB, the kernel driver will
reconfigure itself and may turn carrier off for a few seconds. So we
must ensure that before enabling/disabling DCB, the carrier is already
on. Next we must ensure that *after* enabling/disabling DCB, the
carrier is back on before doing further DCB setup.
There's a race condition between enabling/disabling DCB and receiving
the carrier event in NetworkManager that has to be handled carefully.
Because the carrier may not yet be down after the dcbtool call to
enable/disable DCB returns, we need to wait for a couple seconds for
the carrier to go down, and then again for it to come back up.
Otherwise we might see the still-on carrier, proceed with DCB setup,
and the carrier finally goes down halfway through the setup, which
will fail the operations with "DCB not enabled, link down, or DCB
not supported" errors from lldpad.
2014-03-27 13:49:50 -05:00
|
|
|
g_clear_error (&error);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Pause again just in case the device takes the carrier down when
|
|
|
|
|
* setting specific DCB attributes.
|
|
|
|
|
*/
|
2014-08-02 15:14:26 +02:00
|
|
|
_LOGD (LOGD_DCB, "waiting for carrier (postconfig down)");
|
dcb: separate DCB enable/disable and wait for carrier changes (rh #799241) (rh #1081991)
Non-git-master versions of lldpad refuse to touch a device that doesn't
have a carrier. And when enabling/disabling DCB, the kernel driver will
reconfigure itself and may turn carrier off for a few seconds. So we
must ensure that before enabling/disabling DCB, the carrier is already
on. Next we must ensure that *after* enabling/disabling DCB, the
carrier is back on before doing further DCB setup.
There's a race condition between enabling/disabling DCB and receiving
the carrier event in NetworkManager that has to be handled carefully.
Because the carrier may not yet be down after the dcbtool call to
enable/disable DCB returns, we need to wait for a couple seconds for
the carrier to go down, and then again for it to come back up.
Otherwise we might see the still-on carrier, proceed with DCB setup,
and the carrier finally goes down halfway through the setup, which
will fail the operations with "DCB not enabled, link down, or DCB
not supported" errors from lldpad.
2014-03-27 13:49:50 -05:00
|
|
|
priv->dcb_wait = DCB_WAIT_CARRIER_POSTCONFIG_DOWN;
|
|
|
|
|
priv->dcb_timeout_id = g_timeout_add_seconds (3, dcb_carrier_timeout, device);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
dcb_enable (NMDevice *device)
|
|
|
|
|
{
|
2014-08-02 15:14:26 +02:00
|
|
|
NMDeviceEthernet *self = NM_DEVICE_ETHERNET (device);
|
|
|
|
|
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
|
dcb: separate DCB enable/disable and wait for carrier changes (rh #799241) (rh #1081991)
Non-git-master versions of lldpad refuse to touch a device that doesn't
have a carrier. And when enabling/disabling DCB, the kernel driver will
reconfigure itself and may turn carrier off for a few seconds. So we
must ensure that before enabling/disabling DCB, the carrier is already
on. Next we must ensure that *after* enabling/disabling DCB, the
carrier is back on before doing further DCB setup.
There's a race condition between enabling/disabling DCB and receiving
the carrier event in NetworkManager that has to be handled carefully.
Because the carrier may not yet be down after the dcbtool call to
enable/disable DCB returns, we need to wait for a couple seconds for
the carrier to go down, and then again for it to come back up.
Otherwise we might see the still-on carrier, proceed with DCB setup,
and the carrier finally goes down halfway through the setup, which
will fail the operations with "DCB not enabled, link down, or DCB
not supported" errors from lldpad.
2014-03-27 13:49:50 -05:00
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
|
|
dcb_timeout_cleanup (device);
|
2014-08-02 15:14:26 +02:00
|
|
|
if (!nm_dcb_enable (nm_device_get_iface (device), TRUE, &error)) {
|
|
|
|
|
_LOGW (LOGD_DCB, "Activation: (ethernet) failed to enable DCB/FCoE: %s",
|
|
|
|
|
error->message);
|
dcb: separate DCB enable/disable and wait for carrier changes (rh #799241) (rh #1081991)
Non-git-master versions of lldpad refuse to touch a device that doesn't
have a carrier. And when enabling/disabling DCB, the kernel driver will
reconfigure itself and may turn carrier off for a few seconds. So we
must ensure that before enabling/disabling DCB, the carrier is already
on. Next we must ensure that *after* enabling/disabling DCB, the
carrier is back on before doing further DCB setup.
There's a race condition between enabling/disabling DCB and receiving
the carrier event in NetworkManager that has to be handled carefully.
Because the carrier may not yet be down after the dcbtool call to
enable/disable DCB returns, we need to wait for a couple seconds for
the carrier to go down, and then again for it to come back up.
Otherwise we might see the still-on carrier, proceed with DCB setup,
and the carrier finally goes down halfway through the setup, which
will fail the operations with "DCB not enabled, link down, or DCB
not supported" errors from lldpad.
2014-03-27 13:49:50 -05:00
|
|
|
g_clear_error (&error);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Pause for 3 seconds after enabling DCB to let the card reconfigure
|
|
|
|
|
* itself. Drivers will often re-initialize internal settings which
|
|
|
|
|
* takes the carrier down for 2 or more seconds. During this time,
|
|
|
|
|
* lldpad will refuse to do anything else with the card since the carrier
|
|
|
|
|
* is down. But NM might get the carrier-down signal long after calling
|
|
|
|
|
* "dcbtool dcb on", so we have to first wait for the carrier to go down.
|
|
|
|
|
*/
|
2014-08-02 15:14:26 +02:00
|
|
|
_LOGD (LOGD_DCB, "waiting for carrier (preconfig down)");
|
dcb: separate DCB enable/disable and wait for carrier changes (rh #799241) (rh #1081991)
Non-git-master versions of lldpad refuse to touch a device that doesn't
have a carrier. And when enabling/disabling DCB, the kernel driver will
reconfigure itself and may turn carrier off for a few seconds. So we
must ensure that before enabling/disabling DCB, the carrier is already
on. Next we must ensure that *after* enabling/disabling DCB, the
carrier is back on before doing further DCB setup.
There's a race condition between enabling/disabling DCB and receiving
the carrier event in NetworkManager that has to be handled carefully.
Because the carrier may not yet be down after the dcbtool call to
enable/disable DCB returns, we need to wait for a couple seconds for
the carrier to go down, and then again for it to come back up.
Otherwise we might see the still-on carrier, proceed with DCB setup,
and the carrier finally goes down halfway through the setup, which
will fail the operations with "DCB not enabled, link down, or DCB
not supported" errors from lldpad.
2014-03-27 13:49:50 -05:00
|
|
|
priv->dcb_wait = DCB_WAIT_CARRIER_PRECONFIG_DOWN;
|
|
|
|
|
priv->dcb_timeout_id = g_timeout_add_seconds (3, dcb_carrier_timeout, device);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
dcb_state (NMDevice *device, gboolean timeout)
|
|
|
|
|
{
|
2014-08-02 15:14:26 +02:00
|
|
|
NMDeviceEthernet *self = NM_DEVICE_ETHERNET (device);
|
|
|
|
|
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
|
dcb: separate DCB enable/disable and wait for carrier changes (rh #799241) (rh #1081991)
Non-git-master versions of lldpad refuse to touch a device that doesn't
have a carrier. And when enabling/disabling DCB, the kernel driver will
reconfigure itself and may turn carrier off for a few seconds. So we
must ensure that before enabling/disabling DCB, the carrier is already
on. Next we must ensure that *after* enabling/disabling DCB, the
carrier is back on before doing further DCB setup.
There's a race condition between enabling/disabling DCB and receiving
the carrier event in NetworkManager that has to be handled carefully.
Because the carrier may not yet be down after the dcbtool call to
enable/disable DCB returns, we need to wait for a couple seconds for
the carrier to go down, and then again for it to come back up.
Otherwise we might see the still-on carrier, proceed with DCB setup,
and the carrier finally goes down halfway through the setup, which
will fail the operations with "DCB not enabled, link down, or DCB
not supported" errors from lldpad.
2014-03-27 13:49:50 -05:00
|
|
|
gboolean carrier;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (nm_device_get_state (device) == NM_DEVICE_STATE_CONFIG);
|
|
|
|
|
|
|
|
|
|
|
platform: add self argument to platform functions
Most nm_platform_*() functions operate on the platform
singleton nm_platform_get(). That made sense because the
NMPlatform instance was mainly to hook fake platform for
testing.
While the implicit argument saved some typing, I think explicit is
better. Especially, because NMPlatform could become a more usable
object then just a hook for testing.
With this change, NMPlatform instances can be used individually, not
only as a singleton instance.
Before this change, the constructor of NMLinuxPlatform could not
call any nm_platform_*() functions because the singleton was not
yet initialized. We could only instantiate an incomplete instance,
register it via nm_platform_setup(), and then complete initialization
via singleton->setup().
With this change, we can create and fully initialize NMPlatform instances
before/without setting them up them as singleton.
Also, currently there is no clear distinction between functions
that operate on the NMPlatform instance, and functions that can
be used stand-alone (e.g. nm_platform_ip4_address_to_string()).
The latter can not be mocked for testing. With this change, the
distinction becomes obvious. That is also useful because it becomes
clearer which functions make use of the platform cache and which not.
Inside nm-linux-platform.c, continue the pattern that the
self instance is named @platform. That makes sense because
its type is NMPlatform, and not NMLinuxPlatform what we
would expect from a paramter named @self.
This is a major diff that causes some pain when rebasing. Try
to rebase to the parent commit of this commit as a first step.
Then rebase on top of this commit using merge-strategy "ours".
2015-04-18 12:36:09 +02:00
|
|
|
carrier = nm_platform_link_is_connected (NM_PLATFORM_GET, nm_device_get_ifindex (device));
|
2014-08-02 15:14:26 +02:00
|
|
|
_LOGD (LOGD_DCB, "dcb_state() wait %d carrier %d timeout %d", priv->dcb_wait, carrier, timeout);
|
dcb: separate DCB enable/disable and wait for carrier changes (rh #799241) (rh #1081991)
Non-git-master versions of lldpad refuse to touch a device that doesn't
have a carrier. And when enabling/disabling DCB, the kernel driver will
reconfigure itself and may turn carrier off for a few seconds. So we
must ensure that before enabling/disabling DCB, the carrier is already
on. Next we must ensure that *after* enabling/disabling DCB, the
carrier is back on before doing further DCB setup.
There's a race condition between enabling/disabling DCB and receiving
the carrier event in NetworkManager that has to be handled carefully.
Because the carrier may not yet be down after the dcbtool call to
enable/disable DCB returns, we need to wait for a couple seconds for
the carrier to go down, and then again for it to come back up.
Otherwise we might see the still-on carrier, proceed with DCB setup,
and the carrier finally goes down halfway through the setup, which
will fail the operations with "DCB not enabled, link down, or DCB
not supported" errors from lldpad.
2014-03-27 13:49:50 -05:00
|
|
|
|
|
|
|
|
switch (priv->dcb_wait) {
|
|
|
|
|
case DCB_WAIT_CARRIER_PREENABLE_UP:
|
|
|
|
|
if (timeout || carrier) {
|
2014-08-02 15:14:26 +02:00
|
|
|
_LOGD (LOGD_DCB, "dcb_state() enabling DCB");
|
dcb: separate DCB enable/disable and wait for carrier changes (rh #799241) (rh #1081991)
Non-git-master versions of lldpad refuse to touch a device that doesn't
have a carrier. And when enabling/disabling DCB, the kernel driver will
reconfigure itself and may turn carrier off for a few seconds. So we
must ensure that before enabling/disabling DCB, the carrier is already
on. Next we must ensure that *after* enabling/disabling DCB, the
carrier is back on before doing further DCB setup.
There's a race condition between enabling/disabling DCB and receiving
the carrier event in NetworkManager that has to be handled carefully.
Because the carrier may not yet be down after the dcbtool call to
enable/disable DCB returns, we need to wait for a couple seconds for
the carrier to go down, and then again for it to come back up.
Otherwise we might see the still-on carrier, proceed with DCB setup,
and the carrier finally goes down halfway through the setup, which
will fail the operations with "DCB not enabled, link down, or DCB
not supported" errors from lldpad.
2014-03-27 13:49:50 -05:00
|
|
|
dcb_timeout_cleanup (device);
|
|
|
|
|
if (!dcb_enable (device)) {
|
|
|
|
|
dcb_carrier_cleanup (device);
|
|
|
|
|
nm_device_state_changed (device,
|
2014-07-26 21:46:34 +02:00
|
|
|
NM_DEVICE_STATE_FAILED,
|
dcb: separate DCB enable/disable and wait for carrier changes (rh #799241) (rh #1081991)
Non-git-master versions of lldpad refuse to touch a device that doesn't
have a carrier. And when enabling/disabling DCB, the kernel driver will
reconfigure itself and may turn carrier off for a few seconds. So we
must ensure that before enabling/disabling DCB, the carrier is already
on. Next we must ensure that *after* enabling/disabling DCB, the
carrier is back on before doing further DCB setup.
There's a race condition between enabling/disabling DCB and receiving
the carrier event in NetworkManager that has to be handled carefully.
Because the carrier may not yet be down after the dcbtool call to
enable/disable DCB returns, we need to wait for a couple seconds for
the carrier to go down, and then again for it to come back up.
Otherwise we might see the still-on carrier, proceed with DCB setup,
and the carrier finally goes down halfway through the setup, which
will fail the operations with "DCB not enabled, link down, or DCB
not supported" errors from lldpad.
2014-03-27 13:49:50 -05:00
|
|
|
NM_DEVICE_STATE_REASON_DCB_FCOE_FAILED);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case DCB_WAIT_CARRIER_PRECONFIG_DOWN:
|
|
|
|
|
dcb_timeout_cleanup (device);
|
|
|
|
|
priv->dcb_wait = DCB_WAIT_CARRIER_PRECONFIG_UP;
|
|
|
|
|
|
|
|
|
|
if (!carrier) {
|
|
|
|
|
/* Wait for the carrier to come back up */
|
2014-08-02 15:14:26 +02:00
|
|
|
_LOGD (LOGD_DCB, "waiting for carrier (preconfig up)");
|
dcb: separate DCB enable/disable and wait for carrier changes (rh #799241) (rh #1081991)
Non-git-master versions of lldpad refuse to touch a device that doesn't
have a carrier. And when enabling/disabling DCB, the kernel driver will
reconfigure itself and may turn carrier off for a few seconds. So we
must ensure that before enabling/disabling DCB, the carrier is already
on. Next we must ensure that *after* enabling/disabling DCB, the
carrier is back on before doing further DCB setup.
There's a race condition between enabling/disabling DCB and receiving
the carrier event in NetworkManager that has to be handled carefully.
Because the carrier may not yet be down after the dcbtool call to
enable/disable DCB returns, we need to wait for a couple seconds for
the carrier to go down, and then again for it to come back up.
Otherwise we might see the still-on carrier, proceed with DCB setup,
and the carrier finally goes down halfway through the setup, which
will fail the operations with "DCB not enabled, link down, or DCB
not supported" errors from lldpad.
2014-03-27 13:49:50 -05:00
|
|
|
priv->dcb_timeout_id = g_timeout_add_seconds (5, dcb_carrier_timeout, device);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2014-08-02 15:14:26 +02:00
|
|
|
_LOGD (LOGD_DCB, "dcb_state() preconfig down falling through");
|
dcb: separate DCB enable/disable and wait for carrier changes (rh #799241) (rh #1081991)
Non-git-master versions of lldpad refuse to touch a device that doesn't
have a carrier. And when enabling/disabling DCB, the kernel driver will
reconfigure itself and may turn carrier off for a few seconds. So we
must ensure that before enabling/disabling DCB, the carrier is already
on. Next we must ensure that *after* enabling/disabling DCB, the
carrier is back on before doing further DCB setup.
There's a race condition between enabling/disabling DCB and receiving
the carrier event in NetworkManager that has to be handled carefully.
Because the carrier may not yet be down after the dcbtool call to
enable/disable DCB returns, we need to wait for a couple seconds for
the carrier to go down, and then again for it to come back up.
Otherwise we might see the still-on carrier, proceed with DCB setup,
and the carrier finally goes down halfway through the setup, which
will fail the operations with "DCB not enabled, link down, or DCB
not supported" errors from lldpad.
2014-03-27 13:49:50 -05:00
|
|
|
/* carrier never went down? fall through */
|
|
|
|
|
case DCB_WAIT_CARRIER_PRECONFIG_UP:
|
|
|
|
|
if (timeout || carrier) {
|
2014-08-02 15:14:26 +02:00
|
|
|
_LOGD (LOGD_DCB, "dcb_state() preconfig up configuring DCB");
|
dcb: separate DCB enable/disable and wait for carrier changes (rh #799241) (rh #1081991)
Non-git-master versions of lldpad refuse to touch a device that doesn't
have a carrier. And when enabling/disabling DCB, the kernel driver will
reconfigure itself and may turn carrier off for a few seconds. So we
must ensure that before enabling/disabling DCB, the carrier is already
on. Next we must ensure that *after* enabling/disabling DCB, the
carrier is back on before doing further DCB setup.
There's a race condition between enabling/disabling DCB and receiving
the carrier event in NetworkManager that has to be handled carefully.
Because the carrier may not yet be down after the dcbtool call to
enable/disable DCB returns, we need to wait for a couple seconds for
the carrier to go down, and then again for it to come back up.
Otherwise we might see the still-on carrier, proceed with DCB setup,
and the carrier finally goes down halfway through the setup, which
will fail the operations with "DCB not enabled, link down, or DCB
not supported" errors from lldpad.
2014-03-27 13:49:50 -05:00
|
|
|
dcb_timeout_cleanup (device);
|
|
|
|
|
if (!dcb_configure (device)) {
|
|
|
|
|
dcb_carrier_cleanup (device);
|
|
|
|
|
nm_device_state_changed (device,
|
2014-07-26 21:46:34 +02:00
|
|
|
NM_DEVICE_STATE_FAILED,
|
dcb: separate DCB enable/disable and wait for carrier changes (rh #799241) (rh #1081991)
Non-git-master versions of lldpad refuse to touch a device that doesn't
have a carrier. And when enabling/disabling DCB, the kernel driver will
reconfigure itself and may turn carrier off for a few seconds. So we
must ensure that before enabling/disabling DCB, the carrier is already
on. Next we must ensure that *after* enabling/disabling DCB, the
carrier is back on before doing further DCB setup.
There's a race condition between enabling/disabling DCB and receiving
the carrier event in NetworkManager that has to be handled carefully.
Because the carrier may not yet be down after the dcbtool call to
enable/disable DCB returns, we need to wait for a couple seconds for
the carrier to go down, and then again for it to come back up.
Otherwise we might see the still-on carrier, proceed with DCB setup,
and the carrier finally goes down halfway through the setup, which
will fail the operations with "DCB not enabled, link down, or DCB
not supported" errors from lldpad.
2014-03-27 13:49:50 -05:00
|
|
|
NM_DEVICE_STATE_REASON_DCB_FCOE_FAILED);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case DCB_WAIT_CARRIER_POSTCONFIG_DOWN:
|
|
|
|
|
dcb_timeout_cleanup (device);
|
|
|
|
|
priv->dcb_wait = DCB_WAIT_CARRIER_POSTCONFIG_UP;
|
|
|
|
|
|
|
|
|
|
if (!carrier) {
|
|
|
|
|
/* Wait for the carrier to come back up */
|
2014-08-02 15:14:26 +02:00
|
|
|
_LOGD (LOGD_DCB, "waiting for carrier (postconfig up)");
|
dcb: separate DCB enable/disable and wait for carrier changes (rh #799241) (rh #1081991)
Non-git-master versions of lldpad refuse to touch a device that doesn't
have a carrier. And when enabling/disabling DCB, the kernel driver will
reconfigure itself and may turn carrier off for a few seconds. So we
must ensure that before enabling/disabling DCB, the carrier is already
on. Next we must ensure that *after* enabling/disabling DCB, the
carrier is back on before doing further DCB setup.
There's a race condition between enabling/disabling DCB and receiving
the carrier event in NetworkManager that has to be handled carefully.
Because the carrier may not yet be down after the dcbtool call to
enable/disable DCB returns, we need to wait for a couple seconds for
the carrier to go down, and then again for it to come back up.
Otherwise we might see the still-on carrier, proceed with DCB setup,
and the carrier finally goes down halfway through the setup, which
will fail the operations with "DCB not enabled, link down, or DCB
not supported" errors from lldpad.
2014-03-27 13:49:50 -05:00
|
|
|
priv->dcb_timeout_id = g_timeout_add_seconds (5, dcb_carrier_timeout, device);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2014-08-02 15:14:26 +02:00
|
|
|
_LOGD (LOGD_DCB, "dcb_state() postconfig down falling through");
|
dcb: separate DCB enable/disable and wait for carrier changes (rh #799241) (rh #1081991)
Non-git-master versions of lldpad refuse to touch a device that doesn't
have a carrier. And when enabling/disabling DCB, the kernel driver will
reconfigure itself and may turn carrier off for a few seconds. So we
must ensure that before enabling/disabling DCB, the carrier is already
on. Next we must ensure that *after* enabling/disabling DCB, the
carrier is back on before doing further DCB setup.
There's a race condition between enabling/disabling DCB and receiving
the carrier event in NetworkManager that has to be handled carefully.
Because the carrier may not yet be down after the dcbtool call to
enable/disable DCB returns, we need to wait for a couple seconds for
the carrier to go down, and then again for it to come back up.
Otherwise we might see the still-on carrier, proceed with DCB setup,
and the carrier finally goes down halfway through the setup, which
will fail the operations with "DCB not enabled, link down, or DCB
not supported" errors from lldpad.
2014-03-27 13:49:50 -05:00
|
|
|
/* carrier never went down? fall through */
|
|
|
|
|
case DCB_WAIT_CARRIER_POSTCONFIG_UP:
|
|
|
|
|
if (timeout || carrier) {
|
2014-08-02 15:14:26 +02:00
|
|
|
_LOGD (LOGD_DCB, "dcb_state() postconfig up starting IP");
|
dcb: separate DCB enable/disable and wait for carrier changes (rh #799241) (rh #1081991)
Non-git-master versions of lldpad refuse to touch a device that doesn't
have a carrier. And when enabling/disabling DCB, the kernel driver will
reconfigure itself and may turn carrier off for a few seconds. So we
must ensure that before enabling/disabling DCB, the carrier is already
on. Next we must ensure that *after* enabling/disabling DCB, the
carrier is back on before doing further DCB setup.
There's a race condition between enabling/disabling DCB and receiving
the carrier event in NetworkManager that has to be handled carefully.
Because the carrier may not yet be down after the dcbtool call to
enable/disable DCB returns, we need to wait for a couple seconds for
the carrier to go down, and then again for it to come back up.
Otherwise we might see the still-on carrier, proceed with DCB setup,
and the carrier finally goes down halfway through the setup, which
will fail the operations with "DCB not enabled, link down, or DCB
not supported" errors from lldpad.
2014-03-27 13:49:50 -05:00
|
|
|
dcb_timeout_cleanup (device);
|
|
|
|
|
dcb_carrier_cleanup (device);
|
|
|
|
|
priv->dcb_wait = DCB_WAIT_UNKNOWN;
|
|
|
|
|
nm_device_activate_schedule_stage3_ip_config_start (device);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
dcb_carrier_changed (NMDevice *device, GParamSpec *pspec, gpointer unused)
|
|
|
|
|
{
|
2014-08-02 15:14:26 +02:00
|
|
|
NMDeviceEthernet *self = NM_DEVICE_ETHERNET (device);
|
|
|
|
|
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
|
dcb: separate DCB enable/disable and wait for carrier changes (rh #799241) (rh #1081991)
Non-git-master versions of lldpad refuse to touch a device that doesn't
have a carrier. And when enabling/disabling DCB, the kernel driver will
reconfigure itself and may turn carrier off for a few seconds. So we
must ensure that before enabling/disabling DCB, the carrier is already
on. Next we must ensure that *after* enabling/disabling DCB, the
carrier is back on before doing further DCB setup.
There's a race condition between enabling/disabling DCB and receiving
the carrier event in NetworkManager that has to be handled carefully.
Because the carrier may not yet be down after the dcbtool call to
enable/disable DCB returns, we need to wait for a couple seconds for
the carrier to go down, and then again for it to come back up.
Otherwise we might see the still-on carrier, proceed with DCB setup,
and the carrier finally goes down halfway through the setup, which
will fail the operations with "DCB not enabled, link down, or DCB
not supported" errors from lldpad.
2014-03-27 13:49:50 -05:00
|
|
|
|
|
|
|
|
g_return_if_fail (nm_device_get_state (device) == NM_DEVICE_STATE_CONFIG);
|
|
|
|
|
|
|
|
|
|
if (priv->dcb_timeout_id) {
|
2014-08-02 15:14:26 +02:00
|
|
|
_LOGD (LOGD_DCB, "carrier_changed() calling dcb_state()");
|
dcb: separate DCB enable/disable and wait for carrier changes (rh #799241) (rh #1081991)
Non-git-master versions of lldpad refuse to touch a device that doesn't
have a carrier. And when enabling/disabling DCB, the kernel driver will
reconfigure itself and may turn carrier off for a few seconds. So we
must ensure that before enabling/disabling DCB, the carrier is already
on. Next we must ensure that *after* enabling/disabling DCB, the
carrier is back on before doing further DCB setup.
There's a race condition between enabling/disabling DCB and receiving
the carrier event in NetworkManager that has to be handled carefully.
Because the carrier may not yet be down after the dcbtool call to
enable/disable DCB returns, we need to wait for a couple seconds for
the carrier to go down, and then again for it to come back up.
Otherwise we might see the still-on carrier, proceed with DCB setup,
and the carrier finally goes down halfway through the setup, which
will fail the operations with "DCB not enabled, link down, or DCB
not supported" errors from lldpad.
2014-03-27 13:49:50 -05:00
|
|
|
dcb_state (device, FALSE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/****************************************************************/
|
|
|
|
|
|
2015-05-12 14:44:03 +02:00
|
|
|
static gboolean
|
|
|
|
|
wake_on_lan_enable (NMDevice *device)
|
|
|
|
|
{
|
|
|
|
|
NMSettingWiredWakeOnLan wol;
|
|
|
|
|
NMSettingWired *s_wired;
|
|
|
|
|
const char *password = NULL;
|
|
|
|
|
gs_free char *value = NULL;
|
|
|
|
|
|
2016-02-11 21:33:15 +01:00
|
|
|
s_wired = (NMSettingWired *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_WIRED);
|
2015-05-12 14:44:03 +02:00
|
|
|
if (s_wired) {
|
|
|
|
|
wol = nm_setting_wired_get_wake_on_lan (s_wired);
|
|
|
|
|
password = nm_setting_wired_get_wake_on_lan_password (s_wired);
|
|
|
|
|
if (wol != NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT)
|
|
|
|
|
goto found;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
value = nm_config_data_get_connection_default (NM_CONFIG_GET_DATA,
|
|
|
|
|
"ethernet.wake-on-lan",
|
|
|
|
|
device);
|
2015-09-21 18:24:07 +02:00
|
|
|
|
2015-05-12 14:44:03 +02:00
|
|
|
if (value) {
|
|
|
|
|
wol = _nm_utils_ascii_str_to_int64 (value, 10,
|
|
|
|
|
NM_SETTING_WIRED_WAKE_ON_LAN_NONE,
|
2015-09-21 18:24:07 +02:00
|
|
|
G_MAXINT32,
|
2015-05-12 14:44:03 +02:00
|
|
|
NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT);
|
2015-09-21 18:24:07 +02:00
|
|
|
|
|
|
|
|
if ( NM_FLAGS_ANY (wol, NM_SETTING_WIRED_WAKE_ON_LAN_EXCLUSIVE_FLAGS)
|
|
|
|
|
&& !nm_utils_is_power_of_two (wol)) {
|
|
|
|
|
nm_log_dbg (LOGD_ETHER, "invalid default value %u for wake-on-lan", (guint) wol);
|
|
|
|
|
wol = NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT;
|
|
|
|
|
}
|
2015-05-12 14:44:03 +02:00
|
|
|
if (wol != NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT)
|
|
|
|
|
goto found;
|
|
|
|
|
}
|
2015-09-21 18:24:07 +02:00
|
|
|
wol = NM_SETTING_WIRED_WAKE_ON_LAN_IGNORE;
|
2015-05-12 14:44:03 +02:00
|
|
|
found:
|
|
|
|
|
return nmp_utils_ethtool_set_wake_on_lan (nm_device_get_iface (device), wol, password);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/****************************************************************/
|
|
|
|
|
|
2008-03-11 16:37:41 +00:00
|
|
|
static NMActStageReturn
|
2012-09-27 12:12:15 -04:00
|
|
|
act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
|
2008-03-11 16:37:41 +00:00
|
|
|
{
|
2014-08-02 15:14:26 +02:00
|
|
|
NMDeviceEthernet *self = NM_DEVICE_ETHERNET (device);
|
|
|
|
|
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
|
2009-08-17 15:35:02 -05:00
|
|
|
NMSettingConnection *s_con;
|
2008-10-26 17:41:37 +00:00
|
|
|
const char *connection_type;
|
2009-08-17 15:35:02 -05:00
|
|
|
NMActStageReturn ret = NM_ACT_STAGE_RETURN_SUCCESS;
|
2013-10-04 16:56:34 -05:00
|
|
|
NMSettingDcb *s_dcb;
|
2008-03-11 16:37:41 +00:00
|
|
|
|
2008-07-11 10:28:53 +00:00
|
|
|
g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE);
|
|
|
|
|
|
2016-02-11 21:33:15 +01:00
|
|
|
s_con = NM_SETTING_CONNECTION (nm_device_get_applied_setting (device,
|
|
|
|
|
NM_TYPE_SETTING_CONNECTION));
|
2009-08-17 15:35:02 -05:00
|
|
|
g_assert (s_con);
|
2008-03-11 16:37:41 +00:00
|
|
|
|
dcb: separate DCB enable/disable and wait for carrier changes (rh #799241) (rh #1081991)
Non-git-master versions of lldpad refuse to touch a device that doesn't
have a carrier. And when enabling/disabling DCB, the kernel driver will
reconfigure itself and may turn carrier off for a few seconds. So we
must ensure that before enabling/disabling DCB, the carrier is already
on. Next we must ensure that *after* enabling/disabling DCB, the
carrier is back on before doing further DCB setup.
There's a race condition between enabling/disabling DCB and receiving
the carrier event in NetworkManager that has to be handled carefully.
Because the carrier may not yet be down after the dcbtool call to
enable/disable DCB returns, we need to wait for a couple seconds for
the carrier to go down, and then again for it to come back up.
Otherwise we might see the still-on carrier, proceed with DCB setup,
and the carrier finally goes down halfway through the setup, which
will fail the operations with "DCB not enabled, link down, or DCB
not supported" errors from lldpad.
2014-03-27 13:49:50 -05:00
|
|
|
dcb_timeout_cleanup (device);
|
|
|
|
|
dcb_carrier_cleanup (device);
|
|
|
|
|
|
2009-08-17 15:35:02 -05:00
|
|
|
/* 802.1x has to run before any IP configuration since the 802.1x auth
|
|
|
|
|
* process opens the port up for normal traffic.
|
|
|
|
|
*/
|
|
|
|
|
connection_type = nm_setting_connection_get_connection_type (s_con);
|
2008-10-26 17:41:37 +00:00
|
|
|
if (!strcmp (connection_type, NM_SETTING_WIRED_SETTING_NAME)) {
|
2008-03-18 22:19:09 +00:00
|
|
|
NMSetting8021x *security;
|
|
|
|
|
|
2016-02-11 21:33:15 +01:00
|
|
|
security = (NMSetting8021x *) nm_device_get_applied_setting (device,
|
|
|
|
|
NM_TYPE_SETTING_802_1X);
|
dcb: separate DCB enable/disable and wait for carrier changes (rh #799241) (rh #1081991)
Non-git-master versions of lldpad refuse to touch a device that doesn't
have a carrier. And when enabling/disabling DCB, the kernel driver will
reconfigure itself and may turn carrier off for a few seconds. So we
must ensure that before enabling/disabling DCB, the carrier is already
on. Next we must ensure that *after* enabling/disabling DCB, the
carrier is back on before doing further DCB setup.
There's a race condition between enabling/disabling DCB and receiving
the carrier event in NetworkManager that has to be handled carefully.
Because the carrier may not yet be down after the dcbtool call to
enable/disable DCB returns, we need to wait for a couple seconds for
the carrier to go down, and then again for it to come back up.
Otherwise we might see the still-on carrier, proceed with DCB setup,
and the carrier finally goes down halfway through the setup, which
will fail the operations with "DCB not enabled, link down, or DCB
not supported" errors from lldpad.
2014-03-27 13:49:50 -05:00
|
|
|
if (security) {
|
|
|
|
|
/* FIXME: for now 802.1x is mutually exclusive with DCB */
|
2014-08-02 15:14:26 +02:00
|
|
|
return nm_8021x_stage2_config (self, reason);
|
dcb: separate DCB enable/disable and wait for carrier changes (rh #799241) (rh #1081991)
Non-git-master versions of lldpad refuse to touch a device that doesn't
have a carrier. And when enabling/disabling DCB, the kernel driver will
reconfigure itself and may turn carrier off for a few seconds. So we
must ensure that before enabling/disabling DCB, the carrier is already
on. Next we must ensure that *after* enabling/disabling DCB, the
carrier is back on before doing further DCB setup.
There's a race condition between enabling/disabling DCB and receiving
the carrier event in NetworkManager that has to be handled carefully.
Because the carrier may not yet be down after the dcbtool call to
enable/disable DCB returns, we need to wait for a couple seconds for
the carrier to go down, and then again for it to come back up.
Otherwise we might see the still-on carrier, proceed with DCB setup,
and the carrier finally goes down halfway through the setup, which
will fail the operations with "DCB not enabled, link down, or DCB
not supported" errors from lldpad.
2014-03-27 13:49:50 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-12 14:44:03 +02:00
|
|
|
wake_on_lan_enable (device);
|
|
|
|
|
|
dcb: separate DCB enable/disable and wait for carrier changes (rh #799241) (rh #1081991)
Non-git-master versions of lldpad refuse to touch a device that doesn't
have a carrier. And when enabling/disabling DCB, the kernel driver will
reconfigure itself and may turn carrier off for a few seconds. So we
must ensure that before enabling/disabling DCB, the carrier is already
on. Next we must ensure that *after* enabling/disabling DCB, the
carrier is back on before doing further DCB setup.
There's a race condition between enabling/disabling DCB and receiving
the carrier event in NetworkManager that has to be handled carefully.
Because the carrier may not yet be down after the dcbtool call to
enable/disable DCB returns, we need to wait for a couple seconds for
the carrier to go down, and then again for it to come back up.
Otherwise we might see the still-on carrier, proceed with DCB setup,
and the carrier finally goes down halfway through the setup, which
will fail the operations with "DCB not enabled, link down, or DCB
not supported" errors from lldpad.
2014-03-27 13:49:50 -05:00
|
|
|
/* DCB and FCoE setup */
|
2016-02-11 21:33:15 +01:00
|
|
|
s_dcb = (NMSettingDcb *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_DCB);
|
dcb: separate DCB enable/disable and wait for carrier changes (rh #799241) (rh #1081991)
Non-git-master versions of lldpad refuse to touch a device that doesn't
have a carrier. And when enabling/disabling DCB, the kernel driver will
reconfigure itself and may turn carrier off for a few seconds. So we
must ensure that before enabling/disabling DCB, the carrier is already
on. Next we must ensure that *after* enabling/disabling DCB, the
carrier is back on before doing further DCB setup.
There's a race condition between enabling/disabling DCB and receiving
the carrier event in NetworkManager that has to be handled carefully.
Because the carrier may not yet be down after the dcbtool call to
enable/disable DCB returns, we need to wait for a couple seconds for
the carrier to go down, and then again for it to come back up.
Otherwise we might see the still-on carrier, proceed with DCB setup,
and the carrier finally goes down halfway through the setup, which
will fail the operations with "DCB not enabled, link down, or DCB
not supported" errors from lldpad.
2014-03-27 13:49:50 -05:00
|
|
|
if (s_dcb) {
|
|
|
|
|
/* lldpad really really wants the carrier to be up */
|
platform: add self argument to platform functions
Most nm_platform_*() functions operate on the platform
singleton nm_platform_get(). That made sense because the
NMPlatform instance was mainly to hook fake platform for
testing.
While the implicit argument saved some typing, I think explicit is
better. Especially, because NMPlatform could become a more usable
object then just a hook for testing.
With this change, NMPlatform instances can be used individually, not
only as a singleton instance.
Before this change, the constructor of NMLinuxPlatform could not
call any nm_platform_*() functions because the singleton was not
yet initialized. We could only instantiate an incomplete instance,
register it via nm_platform_setup(), and then complete initialization
via singleton->setup().
With this change, we can create and fully initialize NMPlatform instances
before/without setting them up them as singleton.
Also, currently there is no clear distinction between functions
that operate on the NMPlatform instance, and functions that can
be used stand-alone (e.g. nm_platform_ip4_address_to_string()).
The latter can not be mocked for testing. With this change, the
distinction becomes obvious. That is also useful because it becomes
clearer which functions make use of the platform cache and which not.
Inside nm-linux-platform.c, continue the pattern that the
self instance is named @platform. That makes sense because
its type is NMPlatform, and not NMLinuxPlatform what we
would expect from a paramter named @self.
This is a major diff that causes some pain when rebasing. Try
to rebase to the parent commit of this commit as a first step.
Then rebase on top of this commit using merge-strategy "ours".
2015-04-18 12:36:09 +02:00
|
|
|
if (nm_platform_link_is_connected (NM_PLATFORM_GET, nm_device_get_ifindex (device))) {
|
dcb: separate DCB enable/disable and wait for carrier changes (rh #799241) (rh #1081991)
Non-git-master versions of lldpad refuse to touch a device that doesn't
have a carrier. And when enabling/disabling DCB, the kernel driver will
reconfigure itself and may turn carrier off for a few seconds. So we
must ensure that before enabling/disabling DCB, the carrier is already
on. Next we must ensure that *after* enabling/disabling DCB, the
carrier is back on before doing further DCB setup.
There's a race condition between enabling/disabling DCB and receiving
the carrier event in NetworkManager that has to be handled carefully.
Because the carrier may not yet be down after the dcbtool call to
enable/disable DCB returns, we need to wait for a couple seconds for
the carrier to go down, and then again for it to come back up.
Otherwise we might see the still-on carrier, proceed with DCB setup,
and the carrier finally goes down halfway through the setup, which
will fail the operations with "DCB not enabled, link down, or DCB
not supported" errors from lldpad.
2014-03-27 13:49:50 -05:00
|
|
|
if (!dcb_enable (device)) {
|
|
|
|
|
*reason = NM_DEVICE_STATE_REASON_DCB_FCOE_FAILED;
|
|
|
|
|
return NM_ACT_STAGE_RETURN_FAILURE;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2014-08-02 15:14:26 +02:00
|
|
|
_LOGD (LOGD_DCB, "waiting for carrier (preenable up)");
|
dcb: separate DCB enable/disable and wait for carrier changes (rh #799241) (rh #1081991)
Non-git-master versions of lldpad refuse to touch a device that doesn't
have a carrier. And when enabling/disabling DCB, the kernel driver will
reconfigure itself and may turn carrier off for a few seconds. So we
must ensure that before enabling/disabling DCB, the carrier is already
on. Next we must ensure that *after* enabling/disabling DCB, the
carrier is back on before doing further DCB setup.
There's a race condition between enabling/disabling DCB and receiving
the carrier event in NetworkManager that has to be handled carefully.
Because the carrier may not yet be down after the dcbtool call to
enable/disable DCB returns, we need to wait for a couple seconds for
the carrier to go down, and then again for it to come back up.
Otherwise we might see the still-on carrier, proceed with DCB setup,
and the carrier finally goes down halfway through the setup, which
will fail the operations with "DCB not enabled, link down, or DCB
not supported" errors from lldpad.
2014-03-27 13:49:50 -05:00
|
|
|
priv->dcb_wait = DCB_WAIT_CARRIER_PREENABLE_UP;
|
|
|
|
|
priv->dcb_timeout_id = g_timeout_add_seconds (4, dcb_carrier_timeout, device);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Watch carrier independently of NMDeviceClass::carrier_changed so
|
|
|
|
|
* we get instant notifications of disconnection that aren't deferred.
|
|
|
|
|
*/
|
|
|
|
|
priv->dcb_carrier_id = g_signal_connect (device,
|
|
|
|
|
"notify::" NM_DEVICE_CARRIER,
|
|
|
|
|
G_CALLBACK (dcb_carrier_changed),
|
|
|
|
|
NULL);
|
|
|
|
|
ret = NM_ACT_STAGE_RETURN_POSTPONE;
|
2008-03-11 16:37:41 +00:00
|
|
|
}
|
|
|
|
|
|
2015-04-28 10:05:42 +02:00
|
|
|
/* PPPoE setup */
|
2015-07-14 16:53:24 +02:00
|
|
|
if (nm_connection_is_type (nm_device_get_applied_connection (device),
|
2015-04-28 10:05:42 +02:00
|
|
|
NM_SETTING_PPPOE_SETTING_NAME)) {
|
|
|
|
|
NMSettingPpp *s_ppp;
|
|
|
|
|
|
2016-02-11 21:33:15 +01:00
|
|
|
s_ppp = (NMSettingPpp *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_PPP);
|
2015-04-28 10:05:42 +02:00
|
|
|
if (s_ppp) {
|
|
|
|
|
guint32 mtu = 0, mru = 0, mxu;
|
|
|
|
|
|
|
|
|
|
mtu = nm_setting_ppp_get_mtu (s_ppp);
|
|
|
|
|
mru = nm_setting_ppp_get_mru (s_ppp);
|
|
|
|
|
mxu = mru > mtu ? mru : mtu;
|
|
|
|
|
if (mxu) {
|
|
|
|
|
_LOGD (LOGD_PPP, "set MTU to %u (PPP interface MRU %u, MTU %u)",
|
|
|
|
|
mxu + PPPOE_ENCAP_OVERHEAD, mru, mtu);
|
|
|
|
|
nm_platform_link_set_mtu (NM_PLATFORM_GET,
|
|
|
|
|
nm_device_get_ifindex (device),
|
|
|
|
|
mxu + PPPOE_ENCAP_OVERHEAD);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-03-11 16:37:41 +00:00
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-17 15:35:02 -05:00
|
|
|
static NMActStageReturn
|
2012-09-27 12:12:15 -04:00
|
|
|
act_stage3_ip4_config_start (NMDevice *device,
|
|
|
|
|
NMIP4Config **out_config,
|
|
|
|
|
NMDeviceStateReason *reason)
|
2009-08-17 15:35:02 -05:00
|
|
|
{
|
|
|
|
|
NMSettingConnection *s_con;
|
|
|
|
|
const char *connection_type;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE);
|
|
|
|
|
|
2016-02-11 21:33:15 +01:00
|
|
|
s_con = NM_SETTING_CONNECTION (nm_device_get_applied_setting (device, NM_TYPE_SETTING_CONNECTION));
|
2009-08-17 15:35:02 -05:00
|
|
|
g_assert (s_con);
|
|
|
|
|
|
|
|
|
|
connection_type = nm_setting_connection_get_connection_type (s_con);
|
|
|
|
|
if (!strcmp (connection_type, NM_SETTING_PPPOE_SETTING_NAME))
|
|
|
|
|
return pppoe_stage3_ip4_config_start (NM_DEVICE_ETHERNET (device), reason);
|
|
|
|
|
|
2011-10-09 22:50:04 -05:00
|
|
|
return NM_DEVICE_CLASS (nm_device_ethernet_parent_class)->act_stage3_ip4_config_start (device, out_config, reason);
|
2009-08-17 15:35:02 -05:00
|
|
|
}
|
|
|
|
|
|
2011-10-09 22:50:04 -05:00
|
|
|
static void
|
2012-09-27 12:12:15 -04:00
|
|
|
ip4_config_pre_commit (NMDevice *device, NMIP4Config *config)
|
2008-03-11 16:37:41 +00:00
|
|
|
{
|
2011-10-09 22:50:04 -05:00
|
|
|
NMConnection *connection;
|
|
|
|
|
NMSettingWired *s_wired;
|
|
|
|
|
guint32 mtu;
|
2009-08-17 19:48:42 -05:00
|
|
|
|
2011-10-09 22:50:04 -05:00
|
|
|
/* MTU only set for plain ethernet */
|
|
|
|
|
if (NM_DEVICE_ETHERNET_GET_PRIVATE (device)->ppp_manager)
|
|
|
|
|
return;
|
2009-08-17 19:48:42 -05:00
|
|
|
|
2015-07-14 16:53:24 +02:00
|
|
|
connection = nm_device_get_applied_connection (device);
|
2011-10-09 22:50:04 -05:00
|
|
|
g_assert (connection);
|
|
|
|
|
s_wired = nm_connection_get_setting_wired (connection);
|
|
|
|
|
g_assert (s_wired);
|
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
|
|
|
|
2011-10-09 22:50:04 -05:00
|
|
|
/* MTU override */
|
|
|
|
|
mtu = nm_setting_wired_get_mtu (s_wired);
|
|
|
|
|
if (mtu)
|
2014-10-09 18:51:11 +02:00
|
|
|
nm_ip4_config_set_mtu (config, mtu, NM_IP_CONFIG_SOURCE_USER);
|
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
|
|
|
}
|
|
|
|
|
|
2008-03-11 16:37:41 +00:00
|
|
|
static void
|
2012-09-27 12:12:15 -04:00
|
|
|
deactivate (NMDevice *device)
|
2008-03-11 16:37:41 +00:00
|
|
|
{
|
2010-06-24 15:14:53 -07:00
|
|
|
NMDeviceEthernet *self = NM_DEVICE_ETHERNET (device);
|
|
|
|
|
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
|
2013-10-04 16:56:34 -05:00
|
|
|
NMSettingDcb *s_dcb;
|
|
|
|
|
GError *error = NULL;
|
2008-03-11 16:37:41 +00:00
|
|
|
|
2011-01-18 18:35:35 -06:00
|
|
|
/* Clear wired secrets tries when deactivating */
|
|
|
|
|
clear_secrets_tries (device);
|
|
|
|
|
|
2016-01-04 09:46:22 +01:00
|
|
|
nm_clear_g_source (&priv->pppoe_wait_id);
|
2013-12-09 09:33:13 +01:00
|
|
|
|
2008-03-11 16:37:41 +00:00
|
|
|
if (priv->pending_ip4_config) {
|
|
|
|
|
g_object_unref (priv->pending_ip4_config);
|
|
|
|
|
priv->pending_ip4_config = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-23 10:03:21 -05:00
|
|
|
nm_exported_object_clear_and_unexport (&priv->ppp_manager);
|
2008-03-18 22:19:09 +00:00
|
|
|
|
2010-06-24 15:14:53 -07:00
|
|
|
supplicant_interface_release (self);
|
2010-06-22 14:21:25 +02:00
|
|
|
|
dcb: separate DCB enable/disable and wait for carrier changes (rh #799241) (rh #1081991)
Non-git-master versions of lldpad refuse to touch a device that doesn't
have a carrier. And when enabling/disabling DCB, the kernel driver will
reconfigure itself and may turn carrier off for a few seconds. So we
must ensure that before enabling/disabling DCB, the carrier is already
on. Next we must ensure that *after* enabling/disabling DCB, the
carrier is back on before doing further DCB setup.
There's a race condition between enabling/disabling DCB and receiving
the carrier event in NetworkManager that has to be handled carefully.
Because the carrier may not yet be down after the dcbtool call to
enable/disable DCB returns, we need to wait for a couple seconds for
the carrier to go down, and then again for it to come back up.
Otherwise we might see the still-on carrier, proceed with DCB setup,
and the carrier finally goes down halfway through the setup, which
will fail the operations with "DCB not enabled, link down, or DCB
not supported" errors from lldpad.
2014-03-27 13:49:50 -05:00
|
|
|
priv->dcb_wait = DCB_WAIT_UNKNOWN;
|
|
|
|
|
dcb_timeout_cleanup (device);
|
|
|
|
|
dcb_carrier_cleanup (device);
|
|
|
|
|
|
2013-10-04 16:56:34 -05:00
|
|
|
/* Tear down DCB/FCoE if it was enabled */
|
2016-02-11 21:33:15 +01:00
|
|
|
s_dcb = (NMSettingDcb *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_DCB);
|
2013-10-04 16:56:34 -05:00
|
|
|
if (s_dcb) {
|
|
|
|
|
if (!nm_dcb_cleanup (nm_device_get_iface (device), &error)) {
|
2014-08-02 15:14:26 +02:00
|
|
|
_LOGW (LOGD_DEVICE | LOGD_HW, "failed to disable DCB/FCoE: %s",
|
|
|
|
|
error->message);
|
2013-10-04 16:56:34 -05:00
|
|
|
g_clear_error (&error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-09 09:33:13 +01:00
|
|
|
/* Set last PPPoE connection time */
|
2016-02-11 21:33:15 +01:00
|
|
|
if (nm_device_get_applied_setting (device, NM_TYPE_SETTING_PPPOE))
|
2013-12-10 20:39:48 +01:00
|
|
|
NM_DEVICE_ETHERNET_GET_PRIVATE (device)->last_pppoe_time = nm_utils_get_monotonic_timestamp_s ();
|
2013-12-09 09:33:13 +01:00
|
|
|
|
2010-09-27 09:53:51 +02:00
|
|
|
/* Reset MAC address back to initial address */
|
2014-10-03 17:37:26 -05:00
|
|
|
if (nm_device_get_initial_hw_address (device))
|
|
|
|
|
nm_device_set_hw_addr (device, nm_device_get_initial_hw_address (device), "reset", LOGD_ETHER);
|
2008-03-11 16:37:41 +00:00
|
|
|
}
|
|
|
|
|
|
2011-01-10 23:39:12 -06:00
|
|
|
static gboolean
|
2012-09-27 12:12:15 -04:00
|
|
|
complete_connection (NMDevice *device,
|
|
|
|
|
NMConnection *connection,
|
|
|
|
|
const char *specific_object,
|
|
|
|
|
const GSList *existing_connections,
|
|
|
|
|
GError **error)
|
2011-01-10 23:39:12 -06:00
|
|
|
{
|
|
|
|
|
NMSettingWired *s_wired;
|
libnm, core, cli, tui: fix the capitalization of various types
GLib/Gtk have mostly settled on the convention that two-letter
acronyms in type names remain all-caps (eg, "IO"), but longer acronyms
become initial-caps-only (eg, "Tcp").
NM was inconsistent, with most long acronyms using initial caps only
(Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP,
PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all
three-or-more-letter-long acronyms (and update nmcli and nmtui for the
libnm changes).
2014-06-26 13:44:36 -04:00
|
|
|
NMSettingPppoe *s_pppoe;
|
2014-07-30 10:57:45 -04:00
|
|
|
const char *setting_mac;
|
2014-10-03 17:37:26 -05:00
|
|
|
const char *perm_hw_addr;
|
2011-01-10 23:39:12 -06:00
|
|
|
|
2011-12-05 12:27:47 +01:00
|
|
|
s_pppoe = nm_connection_get_setting_pppoe (connection);
|
2011-01-10 23:39:12 -06:00
|
|
|
|
|
|
|
|
/* We can't telepathically figure out the service name or username, so if
|
|
|
|
|
* those weren't given, we can't complete the connection.
|
|
|
|
|
*/
|
|
|
|
|
if (s_pppoe && !nm_setting_verify (NM_SETTING (s_pppoe), NULL, error))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
/* Default to an ethernet-only connection, but if a PPPoE setting was given
|
|
|
|
|
* then PPPoE should be our connection type.
|
|
|
|
|
*/
|
2011-01-13 13:28:52 -06:00
|
|
|
nm_utils_complete_generic (connection,
|
2011-03-28 10:42:19 -05:00
|
|
|
s_pppoe ? NM_SETTING_PPPOE_SETTING_NAME : NM_SETTING_WIRED_SETTING_NAME,
|
2011-01-13 13:28:52 -06:00
|
|
|
existing_connections,
|
2011-02-25 11:58:16 -06:00
|
|
|
NULL,
|
2014-08-25 16:21:59 +02:00
|
|
|
s_pppoe ? _("PPPoE connection") : _("Wired connection"),
|
2014-08-05 17:11:57 -04:00
|
|
|
NULL,
|
2011-02-25 11:58:16 -06:00
|
|
|
s_pppoe ? FALSE : TRUE); /* No IPv6 by default yet for PPPoE */
|
2011-01-10 23:39:12 -06:00
|
|
|
|
2011-12-05 12:27:47 +01:00
|
|
|
s_wired = nm_connection_get_setting_wired (connection);
|
2011-01-10 23:39:12 -06:00
|
|
|
if (!s_wired) {
|
|
|
|
|
s_wired = (NMSettingWired *) nm_setting_wired_new ();
|
|
|
|
|
nm_connection_add_setting (connection, NM_SETTING (s_wired));
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-03 17:37:26 -05:00
|
|
|
perm_hw_addr = nm_device_get_permanent_hw_address (device);
|
|
|
|
|
if (perm_hw_addr) {
|
|
|
|
|
setting_mac = nm_setting_wired_get_mac_address (s_wired);
|
|
|
|
|
if (setting_mac) {
|
|
|
|
|
/* Make sure the setting MAC (if any) matches the device's permanent MAC */
|
|
|
|
|
if (!nm_utils_hwaddr_matches (setting_mac, -1, perm_hw_addr, -1)) {
|
|
|
|
|
g_set_error_literal (error,
|
|
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
|
|
|
|
_("connection does not match device"));
|
|
|
|
|
g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_MAC_ADDRESS);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2014-07-30 10:57:45 -04:00
|
|
|
g_object_set (G_OBJECT (s_wired),
|
2014-10-03 17:37:26 -05:00
|
|
|
NM_SETTING_WIRED_MAC_ADDRESS, perm_hw_addr,
|
2014-07-30 10:57:45 -04:00
|
|
|
NULL);
|
2011-01-10 23:39:12 -06:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-08 16:11:51 -05:00
|
|
|
static NMConnection *
|
|
|
|
|
new_default_connection (NMDevice *self)
|
|
|
|
|
{
|
|
|
|
|
NMConnection *connection;
|
|
|
|
|
const GSList *connections;
|
|
|
|
|
NMSetting *setting;
|
|
|
|
|
const char *hw_address;
|
|
|
|
|
char *defname, *uuid;
|
|
|
|
|
|
2015-01-07 17:09:52 +01:00
|
|
|
if (nm_config_get_no_auto_default_for_device (nm_config_get (), self))
|
2014-09-08 16:11:51 -05:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
hw_address = nm_device_get_hw_address (self);
|
|
|
|
|
if (!hw_address)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
connection = nm_simple_connection_new ();
|
|
|
|
|
setting = nm_setting_connection_new ();
|
|
|
|
|
nm_connection_add_setting (connection, setting);
|
|
|
|
|
|
|
|
|
|
connections = nm_connection_provider_get_connections (nm_connection_provider_get ());
|
|
|
|
|
defname = nm_device_ethernet_utils_get_default_wired_name (connections);
|
|
|
|
|
uuid = nm_utils_uuid_generate ();
|
|
|
|
|
g_object_set (setting,
|
|
|
|
|
NM_SETTING_CONNECTION_ID, defname,
|
|
|
|
|
NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME,
|
|
|
|
|
NM_SETTING_CONNECTION_AUTOCONNECT, TRUE,
|
2015-08-31 16:32:33 +02:00
|
|
|
NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY, NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY_MIN,
|
2014-09-08 16:11:51 -05:00
|
|
|
NM_SETTING_CONNECTION_UUID, uuid,
|
|
|
|
|
NM_SETTING_CONNECTION_TIMESTAMP, (guint64) time (NULL),
|
|
|
|
|
NULL);
|
|
|
|
|
g_free (uuid);
|
|
|
|
|
g_free (defname);
|
|
|
|
|
|
|
|
|
|
/* Lock the connection to the device */
|
|
|
|
|
setting = nm_setting_wired_new ();
|
2014-09-24 13:15:42 -04:00
|
|
|
g_object_set (setting, NM_SETTING_WIRED_MAC_ADDRESS, hw_address, NULL);
|
2014-09-08 16:11:51 -05:00
|
|
|
nm_connection_add_setting (connection, setting);
|
|
|
|
|
|
|
|
|
|
return connection;
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-23 17:02:16 +01:00
|
|
|
static NMMatchSpecMatchType
|
2009-06-11 00:39:12 -04:00
|
|
|
spec_match_list (NMDevice *device, const GSList *specs)
|
|
|
|
|
{
|
2015-01-23 17:02:16 +01:00
|
|
|
NMMatchSpecMatchType matched = NM_MATCH_SPEC_NO_MATCH, m;
|
2010-05-26 16:28:51 -07:00
|
|
|
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (device);
|
2009-06-11 00:39:12 -04:00
|
|
|
|
2015-01-23 17:02:16 +01:00
|
|
|
if (priv->subchannels)
|
|
|
|
|
matched = nm_match_spec_s390_subchannels (specs, priv->subchannels);
|
|
|
|
|
if (matched != NM_MATCH_SPEC_NEG_MATCH) {
|
|
|
|
|
m = NM_DEVICE_CLASS (nm_device_ethernet_parent_class)->spec_match_list (device, specs);
|
|
|
|
|
matched = MAX (matched, m);
|
|
|
|
|
}
|
|
|
|
|
return matched;
|
2009-06-11 00:39:12 -04:00
|
|
|
}
|
|
|
|
|
|
2013-08-22 15:03:30 +02:00
|
|
|
static void
|
|
|
|
|
update_connection (NMDevice *device, NMConnection *connection)
|
2009-08-03 17:15:03 -04:00
|
|
|
{
|
2013-11-06 20:20:58 -06:00
|
|
|
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (device);
|
2013-08-22 15:03:30 +02:00
|
|
|
NMSettingWired *s_wired = nm_connection_get_setting_wired (connection);
|
2014-10-03 17:37:26 -05:00
|
|
|
const char *perm_hw_addr = nm_device_get_permanent_hw_address (device);
|
2014-06-21 12:44:56 -04:00
|
|
|
const char *mac = nm_device_get_hw_address (device);
|
2013-11-06 20:20:58 -06:00
|
|
|
const char *mac_prop = NM_SETTING_WIRED_MAC_ADDRESS;
|
2014-04-07 15:25:09 +02:00
|
|
|
GHashTableIter iter;
|
|
|
|
|
gpointer key, value;
|
2011-10-14 10:13:49 -04:00
|
|
|
|
2013-08-22 15:03:30 +02:00
|
|
|
if (!s_wired) {
|
|
|
|
|
s_wired = (NMSettingWired *) nm_setting_wired_new ();
|
|
|
|
|
nm_connection_add_setting (connection, (NMSetting *) s_wired);
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-06 20:20:58 -06:00
|
|
|
/* If the device reports a permanent address, use that for the MAC address
|
|
|
|
|
* and the current MAC, if different, is the cloned MAC.
|
|
|
|
|
*/
|
2014-10-03 17:37:26 -05:00
|
|
|
if (perm_hw_addr) {
|
|
|
|
|
g_object_set (s_wired, NM_SETTING_WIRED_MAC_ADDRESS, perm_hw_addr, NULL);
|
2013-11-06 20:20:58 -06:00
|
|
|
|
|
|
|
|
mac_prop = NULL;
|
2014-10-03 17:37:26 -05:00
|
|
|
if (mac && !nm_utils_hwaddr_matches (perm_hw_addr, -1, mac, -1))
|
2013-11-06 20:20:58 -06:00
|
|
|
mac_prop = NM_SETTING_WIRED_CLONED_MAC_ADDRESS;
|
|
|
|
|
}
|
2013-08-22 15:03:30 +02:00
|
|
|
|
2014-07-30 10:57:45 -04:00
|
|
|
if (mac_prop && mac && nm_utils_hwaddr_valid (mac, ETH_ALEN))
|
|
|
|
|
g_object_set (s_wired, mac_prop, mac, NULL);
|
2013-08-22 15:03:30 +02:00
|
|
|
|
|
|
|
|
/* We don't set the MTU as we don't know whether it was set explicitly */
|
2014-04-07 15:25:09 +02:00
|
|
|
|
|
|
|
|
/* s390 */
|
2015-09-18 22:49:13 +02:00
|
|
|
if (priv->subchannels_dbus)
|
|
|
|
|
g_object_set (s_wired, NM_SETTING_WIRED_S390_SUBCHANNELS, priv->subchannels_dbus, NULL);
|
2014-04-07 15:25:09 +02:00
|
|
|
if (priv->s390_nettype)
|
|
|
|
|
g_object_set (s_wired, NM_SETTING_WIRED_S390_NETTYPE, priv->s390_nettype, NULL);
|
|
|
|
|
g_hash_table_iter_init (&iter, priv->s390_options);
|
|
|
|
|
while (g_hash_table_iter_next (&iter, &key, &value)) {
|
|
|
|
|
nm_setting_wired_add_s390_option (s_wired, (const char *) key, (const char *) value);
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-03 17:15:03 -04:00
|
|
|
}
|
|
|
|
|
|
2013-05-07 16:18:19 -04:00
|
|
|
static void
|
|
|
|
|
get_link_speed (NMDevice *device)
|
|
|
|
|
{
|
2014-08-02 15:14:26 +02:00
|
|
|
NMDeviceEthernet *self = NM_DEVICE_ETHERNET (device);
|
|
|
|
|
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
|
2013-05-07 16:18:19 -04:00
|
|
|
guint32 speed;
|
|
|
|
|
|
2015-06-01 12:06:12 +02:00
|
|
|
if (!nmp_utils_ethtool_get_link_speed (nm_device_get_iface (device), &speed))
|
2013-05-07 16:18:19 -04:00
|
|
|
return;
|
|
|
|
|
if (priv->speed == speed)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
priv->speed = speed;
|
|
|
|
|
g_object_notify (G_OBJECT (device), "speed");
|
|
|
|
|
|
2014-08-02 15:14:26 +02:00
|
|
|
_LOGD (LOGD_HW | LOGD_ETHER, "speed is now %d Mb/s", speed);
|
2013-05-07 16:18:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
carrier_changed (NMDevice *device, gboolean carrier)
|
|
|
|
|
{
|
|
|
|
|
if (carrier)
|
|
|
|
|
get_link_speed (device);
|
|
|
|
|
|
|
|
|
|
NM_DEVICE_CLASS (nm_device_ethernet_parent_class)->carrier_changed (device, carrier);
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-13 16:29:37 -05:00
|
|
|
static void
|
|
|
|
|
link_changed (NMDevice *device, NMPlatformLink *info)
|
|
|
|
|
{
|
|
|
|
|
NMDeviceEthernet *self = NM_DEVICE_ETHERNET (device);
|
|
|
|
|
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
|
2015-12-13 22:09:59 +01:00
|
|
|
static const guint8 zero_hwaddr[ETH_ALEN];
|
|
|
|
|
const guint8 *hwaddr;
|
|
|
|
|
gsize hwaddrlen = 0;
|
2015-04-13 16:29:37 -05:00
|
|
|
|
|
|
|
|
NM_DEVICE_CLASS (nm_device_ethernet_parent_class)->link_changed (device, info);
|
2015-06-15 14:41:35 +02:00
|
|
|
if (!priv->subchan1 && info->initialized)
|
2015-04-13 16:29:37 -05:00
|
|
|
_update_s390_subchannels (self);
|
2015-12-13 22:09:59 +01:00
|
|
|
|
|
|
|
|
if (!nm_device_get_initial_hw_address (device)) {
|
|
|
|
|
hwaddr = nm_platform_link_get_address (NM_PLATFORM_GET,
|
|
|
|
|
nm_device_get_ifindex (self),
|
|
|
|
|
&hwaddrlen);
|
|
|
|
|
if (!nm_utils_hwaddr_matches (hwaddr, hwaddrlen, zero_hwaddr, ETH_ALEN)) {
|
|
|
|
|
_LOGD (LOGD_DEVICE, "device got a valid hw address");
|
|
|
|
|
nm_device_update_hw_address (self);
|
|
|
|
|
nm_device_update_initial_hw_address (self);
|
|
|
|
|
if (nm_device_get_state (device) == NM_DEVICE_STATE_UNAVAILABLE) {
|
|
|
|
|
/*
|
|
|
|
|
* If the device is UNAVAILABLE, any previous try to
|
|
|
|
|
* bring it up probably has failed because of the
|
|
|
|
|
* invalid hardware address; try again.
|
|
|
|
|
*/
|
|
|
|
|
nm_device_bring_up (self, TRUE, NULL);
|
|
|
|
|
nm_device_queue_recheck_available (device,
|
|
|
|
|
NM_DEVICE_STATE_REASON_NONE,
|
|
|
|
|
NM_DEVICE_STATE_REASON_NONE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
is_available (NMDevice *device, NMDeviceCheckDevAvailableFlags flags)
|
|
|
|
|
{
|
|
|
|
|
if (!NM_DEVICE_CLASS (nm_device_ethernet_parent_class)->is_available (device, flags))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
return !!nm_device_get_initial_hw_address (device);
|
2015-04-13 16:29:37 -05:00
|
|
|
}
|
|
|
|
|
|
2007-09-13 18:09:28 +00:00
|
|
|
static void
|
2009-07-07 14:39:08 -04:00
|
|
|
dispose (GObject *object)
|
2007-09-13 18:09:28 +00:00
|
|
|
{
|
2008-09-25 10:02:28 +00:00
|
|
|
NMDeviceEthernet *self = NM_DEVICE_ETHERNET (object);
|
|
|
|
|
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
|
2007-09-13 18:09:28 +00:00
|
|
|
|
2016-01-19 15:42:24 +01:00
|
|
|
supplicant_interface_release (self);
|
|
|
|
|
|
2016-01-04 09:46:22 +01:00
|
|
|
nm_clear_g_source (&priv->pppoe_wait_id);
|
2013-12-09 09:33:13 +01:00
|
|
|
|
dcb: separate DCB enable/disable and wait for carrier changes (rh #799241) (rh #1081991)
Non-git-master versions of lldpad refuse to touch a device that doesn't
have a carrier. And when enabling/disabling DCB, the kernel driver will
reconfigure itself and may turn carrier off for a few seconds. So we
must ensure that before enabling/disabling DCB, the carrier is already
on. Next we must ensure that *after* enabling/disabling DCB, the
carrier is back on before doing further DCB setup.
There's a race condition between enabling/disabling DCB and receiving
the carrier event in NetworkManager that has to be handled carefully.
Because the carrier may not yet be down after the dcbtool call to
enable/disable DCB returns, we need to wait for a couple seconds for
the carrier to go down, and then again for it to come back up.
Otherwise we might see the still-on carrier, proceed with DCB setup,
and the carrier finally goes down halfway through the setup, which
will fail the operations with "DCB not enabled, link down, or DCB
not supported" errors from lldpad.
2014-03-27 13:49:50 -05:00
|
|
|
dcb_timeout_cleanup (NM_DEVICE (self));
|
|
|
|
|
dcb_carrier_cleanup (NM_DEVICE (self));
|
|
|
|
|
|
2008-06-10 15:54:23 +00:00
|
|
|
G_OBJECT_CLASS (nm_device_ethernet_parent_class)->dispose (object);
|
2007-09-13 18:09:28 +00:00
|
|
|
}
|
|
|
|
|
|
2014-04-07 15:34:10 +02:00
|
|
|
static void
|
|
|
|
|
finalize (GObject *object)
|
|
|
|
|
{
|
|
|
|
|
NMDeviceEthernet *self = NM_DEVICE_ETHERNET (object);
|
|
|
|
|
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
g_clear_object (&priv->supplicant.mgr);
|
|
|
|
|
g_free (priv->subchan1);
|
|
|
|
|
g_free (priv->subchan2);
|
|
|
|
|
g_free (priv->subchan3);
|
|
|
|
|
g_free (priv->subchannels);
|
2015-09-18 22:49:13 +02:00
|
|
|
g_strfreev (priv->subchannels_dbus);
|
2014-04-07 15:34:10 +02:00
|
|
|
g_free (priv->s390_nettype);
|
|
|
|
|
g_hash_table_destroy (priv->s390_options);
|
|
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (nm_device_ethernet_parent_class)->finalize (object);
|
|
|
|
|
}
|
|
|
|
|
|
2007-02-12 09:23:43 +00:00
|
|
|
static void
|
|
|
|
|
get_property (GObject *object, guint prop_id,
|
2009-09-14 12:54:09 -07:00
|
|
|
GValue *value, GParamSpec *pspec)
|
2007-02-12 09:23:43 +00:00
|
|
|
{
|
2009-09-14 12:54:09 -07:00
|
|
|
NMDeviceEthernet *self = NM_DEVICE_ETHERNET (object);
|
|
|
|
|
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
|
2007-02-12 09:23:43 +00:00
|
|
|
|
|
|
|
|
switch (prop_id) {
|
2010-06-22 14:21:25 +02:00
|
|
|
case PROP_PERM_HW_ADDRESS:
|
2014-10-03 17:37:26 -05:00
|
|
|
g_value_set_string (value, nm_device_get_permanent_hw_address (NM_DEVICE (object)));
|
2007-02-16 11:23:49 +00:00
|
|
|
break;
|
2007-02-12 09:23:43 +00:00
|
|
|
case PROP_SPEED:
|
2013-05-07 16:18:19 -04:00
|
|
|
g_value_set_uint (value, priv->speed);
|
2007-02-12 09:23:43 +00:00
|
|
|
break;
|
2015-09-18 22:49:13 +02:00
|
|
|
case PROP_S390_SUBCHANNELS:
|
|
|
|
|
g_value_set_boxed (value, priv->subchannels_dbus);
|
|
|
|
|
break;
|
2007-02-12 09:23:43 +00:00
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
2009-06-11 00:39:12 -04:00
|
|
|
static void
|
|
|
|
|
set_property (GObject *object, guint prop_id,
|
|
|
|
|
const GValue *value, GParamSpec *pspec)
|
|
|
|
|
{
|
|
|
|
|
switch (prop_id) {
|
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-12-31 08:21:24 +00:00
|
|
|
|
|
|
|
|
static void
|
2008-06-10 15:54:23 +00:00
|
|
|
nm_device_ethernet_class_init (NMDeviceEthernetClass *klass)
|
2005-12-31 08:21:24 +00:00
|
|
|
{
|
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
NMDeviceClass *parent_class = NM_DEVICE_CLASS (klass);
|
|
|
|
|
|
2008-06-10 15:54:23 +00:00
|
|
|
g_type_class_add_private (object_class, sizeof (NMDeviceEthernetPrivate));
|
2007-02-05 12:14:09 +00:00
|
|
|
|
2014-10-09 12:42:29 -05:00
|
|
|
NM_DEVICE_CLASS_DECLARE_TYPES (klass, NM_SETTING_WIRED_SETTING_NAME, NM_LINK_TYPE_ETHERNET)
|
2013-08-22 15:03:30 +02:00
|
|
|
|
2007-02-05 12:14:09 +00:00
|
|
|
/* virtual methods */
|
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
|
|
|
object_class->constructor = constructor;
|
2009-07-07 14:39:08 -04:00
|
|
|
object_class->dispose = dispose;
|
2014-04-07 15:34:10 +02:00
|
|
|
object_class->finalize = finalize;
|
2007-02-12 09:23:43 +00:00
|
|
|
object_class->get_property = get_property;
|
2009-06-11 00:39:12 -04:00
|
|
|
object_class->set_property = set_property;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2012-09-27 12:12:15 -04:00
|
|
|
parent_class->get_generic_capabilities = get_generic_capabilities;
|
2016-01-08 17:24:24 +01:00
|
|
|
parent_class->realize_start_notify = realize_start_notify;
|
2012-09-27 12:12:15 -04:00
|
|
|
parent_class->check_connection_compatible = check_connection_compatible;
|
|
|
|
|
parent_class->complete_connection = complete_connection;
|
2014-09-08 16:11:51 -05:00
|
|
|
parent_class->new_default_connection = new_default_connection;
|
2012-09-27 12:12:15 -04:00
|
|
|
|
|
|
|
|
parent_class->act_stage1_prepare = act_stage1_prepare;
|
|
|
|
|
parent_class->act_stage2_config = act_stage2_config;
|
|
|
|
|
parent_class->act_stage3_ip4_config_start = act_stage3_ip4_config_start;
|
|
|
|
|
parent_class->ip4_config_pre_commit = ip4_config_pre_commit;
|
|
|
|
|
parent_class->deactivate = deactivate;
|
2009-06-11 00:39:12 -04:00
|
|
|
parent_class->spec_match_list = spec_match_list;
|
2013-08-22 15:03:30 +02:00
|
|
|
parent_class->update_connection = update_connection;
|
2013-05-07 16:18:19 -04:00
|
|
|
parent_class->carrier_changed = carrier_changed;
|
2015-04-13 16:29:37 -05:00
|
|
|
parent_class->link_changed = link_changed;
|
2015-12-13 22:09:59 +01:00
|
|
|
parent_class->is_available = is_available;
|
2005-12-31 08:21:24 +00:00
|
|
|
|
2012-09-27 12:38:59 -04:00
|
|
|
parent_class->state_changed = device_state_changed;
|
|
|
|
|
|
2007-02-12 09:23:43 +00:00
|
|
|
/* properties */
|
2010-06-22 14:21:25 +02:00
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_PERM_HW_ADDRESS,
|
2014-06-09 16:17:37 -04:00
|
|
|
g_param_spec_string (NM_DEVICE_ETHERNET_PERMANENT_HW_ADDRESS, "", "",
|
|
|
|
|
NULL,
|
|
|
|
|
G_PARAM_READABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
2007-02-12 09:23:43 +00:00
|
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_SPEED,
|
2014-06-09 16:17:37 -04:00
|
|
|
g_param_spec_uint (NM_DEVICE_ETHERNET_SPEED, "", "",
|
|
|
|
|
0, G_MAXUINT32, 0,
|
|
|
|
|
G_PARAM_READABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
2007-02-12 09:23:43 +00:00
|
|
|
|
2015-09-18 22:49:13 +02:00
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_S390_SUBCHANNELS,
|
|
|
|
|
g_param_spec_boxed (NM_DEVICE_ETHERNET_S390_SUBCHANNELS, "", "",
|
|
|
|
|
G_TYPE_STRV,
|
|
|
|
|
G_PARAM_READABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
2015-04-13 13:31:42 -04:00
|
|
|
nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass),
|
2015-04-15 14:53:30 -04:00
|
|
|
NMDBUS_TYPE_DEVICE_ETHERNET_SKELETON,
|
|
|
|
|
NULL);
|
2005-12-31 08:21:24 +00:00
|
|
|
}
|
2014-09-10 10:59:40 -05:00
|
|
|
|
|
|
|
|
/*************************************************************/
|
|
|
|
|
|
|
|
|
|
#define NM_TYPE_ETHERNET_FACTORY (nm_ethernet_factory_get_type ())
|
|
|
|
|
#define NM_ETHERNET_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_ETHERNET_FACTORY, NMEthernetFactory))
|
|
|
|
|
|
|
|
|
|
static NMDevice *
|
2014-09-05 08:50:02 -05:00
|
|
|
create_device (NMDeviceFactory *factory,
|
|
|
|
|
const char *iface,
|
2016-01-10 15:13:20 +01:00
|
|
|
const NMPlatformLink *plink,
|
2014-09-05 08:50:02 -05:00
|
|
|
NMConnection *connection,
|
|
|
|
|
gboolean *out_ignore)
|
2014-09-10 10:59:40 -05:00
|
|
|
{
|
2014-09-17 14:17:30 -05:00
|
|
|
return (NMDevice *) g_object_new (NM_TYPE_DEVICE_ETHERNET,
|
2014-09-05 08:50:02 -05:00
|
|
|
NM_DEVICE_IFACE, iface,
|
2014-09-17 14:17:30 -05:00
|
|
|
NM_DEVICE_TYPE_DESC, "Ethernet",
|
|
|
|
|
NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_ETHERNET,
|
2015-12-08 14:51:12 +01:00
|
|
|
NM_DEVICE_LINK_TYPE, NM_LINK_TYPE_ETHERNET,
|
2014-09-17 14:17:30 -05:00
|
|
|
NULL);
|
2014-09-10 10:59:40 -05:00
|
|
|
}
|
|
|
|
|
|
2014-09-17 14:17:30 -05:00
|
|
|
NM_DEVICE_FACTORY_DEFINE_INTERNAL (ETHERNET, Ethernet, ethernet,
|
|
|
|
|
NM_DEVICE_FACTORY_DECLARE_LINK_TYPES (NM_LINK_TYPE_ETHERNET)
|
|
|
|
|
NM_DEVICE_FACTORY_DECLARE_SETTING_TYPES (NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_PPPOE_SETTING_NAME),
|
2014-09-05 08:50:02 -05:00
|
|
|
factory_iface->create_device = create_device;
|
2014-09-10 10:59:40 -05:00
|
|
|
)
|
|
|
|
|
|