summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2015-05-06 09:53:44 -0500
committerThomas Haller <thaller@redhat.com>2015-06-17 16:33:16 +0200
commited0c2281870c19c6b284f2704ef97ffaaf160e76 (patch)
treee726b03b54c129754f7726683e2e62597d636e14
parentd5e0a6ff86e93d1863c318cf0890363439afefeb (diff)
core: let plugins indicate links which should be ignored
Instead of hacky stuff in the Manager, let plugins themselves indicate which links should be ignored (because they are really child links that are controlled by a different device that the plugin handles). (cherry picked from commit 8fa0f4690f6f97b046399e33de1d1d6d81235636)
-rw-r--r--src/devices/bluetooth/nm-bluez-manager.c11
-rw-r--r--src/devices/nm-device-bond.c2
-rw-r--r--src/devices/nm-device-bridge.c2
-rw-r--r--src/devices/nm-device-ethernet.c2
-rw-r--r--src/devices/nm-device-factory.c3
-rw-r--r--src/devices/nm-device-factory.h6
-rw-r--r--src/devices/nm-device-gre.c2
-rw-r--r--src/devices/nm-device-infiniband.c2
-rw-r--r--src/devices/nm-device-macvlan.c2
-rw-r--r--src/devices/nm-device-tun.c2
-rw-r--r--src/devices/nm-device-veth.c2
-rw-r--r--src/devices/nm-device-vlan.c2
-rw-r--r--src/devices/nm-device-vxlan.c2
-rw-r--r--src/devices/team/nm-team-factory.c2
-rw-r--r--src/devices/wifi/nm-wifi-factory.c2
-rw-r--r--src/devices/wimax/nm-wimax-factory.c2
-rw-r--r--src/devices/wwan/nm-wwan-factory.c10
-rw-r--r--src/nm-manager.c23
18 files changed, 51 insertions, 28 deletions
diff --git a/src/devices/bluetooth/nm-bluez-manager.c b/src/devices/bluetooth/nm-bluez-manager.c
index d2e5e96e08..df4eb46d93 100644
--- a/src/devices/bluetooth/nm-bluez-manager.c
+++ b/src/devices/bluetooth/nm-bluez-manager.c
@@ -38,6 +38,7 @@
#include "nm-device-bt.h"
#include "nm-dbus-manager.h"
+#include "nm-platform.h"
typedef struct {
int bluez_version;
@@ -370,6 +371,7 @@ start (NMDeviceFactory *factory)
}
NM_DEVICE_FACTORY_DECLARE_TYPES (
+ NM_DEVICE_FACTORY_DECLARE_LINK_TYPES (NM_LINK_TYPE_BNEP)
NM_DEVICE_FACTORY_DECLARE_SETTING_TYPES (NM_SETTING_BLUETOOTH_SETTING_NAME)
)
@@ -404,10 +406,19 @@ nm_bluez_manager_init (NMBluezManager *self)
g_assert (priv->provider);
}
+static NMDevice *
+new_link (NMDeviceFactory *factory, NMPlatformLink *plink, gboolean *out_ignore, GError **error)
+{
+ g_warn_if_fail (plink->type == NM_LINK_TYPE_BNEP);
+ *out_ignore = TRUE;
+ return NULL;
+}
+
static void
device_factory_interface_init (NMDeviceFactory *factory_iface)
{
factory_iface->get_supported_types = get_supported_types;
+ factory_iface->new_link = new_link;
factory_iface->start = start;
}
diff --git a/src/devices/nm-device-bond.c b/src/devices/nm-device-bond.c
index 878d3bb7db..3b77d685da 100644
--- a/src/devices/nm-device-bond.c
+++ b/src/devices/nm-device-bond.c
@@ -555,7 +555,7 @@ nm_device_bond_class_init (NMDeviceBondClass *klass)
#define NM_BOND_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_BOND_FACTORY, NMBondFactory))
static NMDevice *
-new_link (NMDeviceFactory *factory, NMPlatformLink *plink, GError **error)
+new_link (NMDeviceFactory *factory, NMPlatformLink *plink, gboolean *out_ignore, GError **error)
{
return (NMDevice *) g_object_new (NM_TYPE_DEVICE_BOND,
NM_DEVICE_PLATFORM_DEVICE, plink,
diff --git a/src/devices/nm-device-bridge.c b/src/devices/nm-device-bridge.c
index 89f1ba0c60..3cf7889a81 100644
--- a/src/devices/nm-device-bridge.c
+++ b/src/devices/nm-device-bridge.c
@@ -478,7 +478,7 @@ nm_device_bridge_class_init (NMDeviceBridgeClass *klass)
#define NM_BRIDGE_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_BRIDGE_FACTORY, NMBridgeFactory))
static NMDevice *
-new_link (NMDeviceFactory *factory, NMPlatformLink *plink, GError **error)
+new_link (NMDeviceFactory *factory, NMPlatformLink *plink, gboolean *out_ignore, GError **error)
{
return (NMDevice *) g_object_new (NM_TYPE_DEVICE_BRIDGE,
NM_DEVICE_PLATFORM_DEVICE, plink,
diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c
index 356e31dba5..bc5273f531 100644
--- a/src/devices/nm-device-ethernet.c
+++ b/src/devices/nm-device-ethernet.c
@@ -1693,7 +1693,7 @@ nm_device_ethernet_class_init (NMDeviceEthernetClass *klass)
#define NM_ETHERNET_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_ETHERNET_FACTORY, NMEthernetFactory))
static NMDevice *
-new_link (NMDeviceFactory *factory, NMPlatformLink *plink, GError **error)
+new_link (NMDeviceFactory *factory, NMPlatformLink *plink, gboolean *out_ignore, GError **error)
{
return (NMDevice *) g_object_new (NM_TYPE_DEVICE_ETHERNET,
NM_DEVICE_PLATFORM_DEVICE, plink,
diff --git a/src/devices/nm-device-factory.c b/src/devices/nm-device-factory.c
index 0357845c12..de7e9d7312 100644
--- a/src/devices/nm-device-factory.c
+++ b/src/devices/nm-device-factory.c
@@ -81,6 +81,7 @@ nm_device_factory_start (NMDeviceFactory *factory)
NMDevice *
nm_device_factory_new_link (NMDeviceFactory *factory,
NMPlatformLink *plink,
+ gboolean *out_ignore,
GError **error)
{
NMDeviceFactory *interface;
@@ -114,7 +115,7 @@ nm_device_factory_new_link (NMDeviceFactory *factory,
return NULL;
}
- return interface->new_link (factory, plink, error);
+ return interface->new_link (factory, plink, out_ignore, error);
}
NMDevice *
diff --git a/src/devices/nm-device-factory.h b/src/devices/nm-device-factory.h
index 40050d4dd3..34c056d20f 100644
--- a/src/devices/nm-device-factory.h
+++ b/src/devices/nm-device-factory.h
@@ -93,6 +93,7 @@ struct _NMDeviceFactory {
* new_link:
* @factory: the #NMDeviceFactory
* @plink: the new link
+ * @out_ignore: on return, %TRUE if the link should be ignored
* @error: error if the link could be claimed but an error occurred
*
* The NetworkManager core was notified of a new link which the plugin
@@ -101,6 +102,9 @@ struct _NMDeviceFactory {
* is supported but the device could not be created, %NULL should be
* returned and @error should be set.
*
+ * If the plugin cannot create a #NMDevice for the link and wants the
+ * core to ignore it, set @out_ignore to %TRUE and return no error.
+ *
* @plink is guaranteed to be one of the types the factory returns in
* get_supported_types().
*
@@ -108,6 +112,7 @@ struct _NMDeviceFactory {
*/
NMDevice * (*new_link) (NMDeviceFactory *factory,
NMPlatformLink *plink,
+ gboolean *out_ignore,
GError **error);
/**
@@ -201,6 +206,7 @@ void nm_device_factory_start (NMDeviceFactory *factory);
NMDevice * nm_device_factory_new_link (NMDeviceFactory *factory,
NMPlatformLink *plink,
+ gboolean *out_ignore,
GError **error);
NMDevice * nm_device_factory_create_virtual_device_for_connection (NMDeviceFactory *factory,
diff --git a/src/devices/nm-device-gre.c b/src/devices/nm-device-gre.c
index 9e592b51f9..b3510d2e25 100644
--- a/src/devices/nm-device-gre.c
+++ b/src/devices/nm-device-gre.c
@@ -267,7 +267,7 @@ nm_device_gre_class_init (NMDeviceGreClass *klass)
#define NM_GRE_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_GRE_FACTORY, NMGreFactory))
static NMDevice *
-new_link (NMDeviceFactory *factory, NMPlatformLink *plink, GError **error)
+new_link (NMDeviceFactory *factory, NMPlatformLink *plink, gboolean *out_ignore, GError **error)
{
return (NMDevice *) g_object_new (NM_TYPE_DEVICE_GRE,
NM_DEVICE_PLATFORM_DEVICE, plink,
diff --git a/src/devices/nm-device-infiniband.c b/src/devices/nm-device-infiniband.c
index f9cd946d44..5e89660e7d 100644
--- a/src/devices/nm-device-infiniband.c
+++ b/src/devices/nm-device-infiniband.c
@@ -293,7 +293,7 @@ nm_device_infiniband_class_init (NMDeviceInfinibandClass *klass)
#define NM_INFINIBAND_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_INFINIBAND_FACTORY, NMInfinibandFactory))
static NMDevice *
-new_link (NMDeviceFactory *factory, NMPlatformLink *plink, GError **error)
+new_link (NMDeviceFactory *factory, NMPlatformLink *plink, gboolean *out_ignore, GError **error)
{
return (NMDevice *) g_object_new (NM_TYPE_DEVICE_INFINIBAND,
NM_DEVICE_PLATFORM_DEVICE, plink,
diff --git a/src/devices/nm-device-macvlan.c b/src/devices/nm-device-macvlan.c
index 4235b62783..0bfe3fe9fc 100644
--- a/src/devices/nm-device-macvlan.c
+++ b/src/devices/nm-device-macvlan.c
@@ -175,7 +175,7 @@ nm_device_macvlan_class_init (NMDeviceMacvlanClass *klass)
#define NM_MACVLAN_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_MACVLAN_FACTORY, NMMacvlanFactory))
static NMDevice *
-new_link (NMDeviceFactory *factory, NMPlatformLink *plink, GError **error)
+new_link (NMDeviceFactory *factory, NMPlatformLink *plink, gboolean *out_ignore, GError **error)
{
return (NMDevice *) g_object_new (NM_TYPE_DEVICE_MACVLAN,
NM_DEVICE_PLATFORM_DEVICE, plink,
diff --git a/src/devices/nm-device-tun.c b/src/devices/nm-device-tun.c
index 54cbbf82f3..5aaff8b1a0 100644
--- a/src/devices/nm-device-tun.c
+++ b/src/devices/nm-device-tun.c
@@ -270,7 +270,7 @@ nm_device_tun_class_init (NMDeviceTunClass *klass)
#define NM_TUN_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_TUN_FACTORY, NMTunFactory))
static NMDevice *
-new_link (NMDeviceFactory *factory, NMPlatformLink *plink, GError **error)
+new_link (NMDeviceFactory *factory, NMPlatformLink *plink, gboolean *out_ignore, GError **error)
{
const char *mode = NULL;
diff --git a/src/devices/nm-device-veth.c b/src/devices/nm-device-veth.c
index ba0b304b0b..c0b9873f4d 100644
--- a/src/devices/nm-device-veth.c
+++ b/src/devices/nm-device-veth.c
@@ -165,7 +165,7 @@ nm_device_veth_class_init (NMDeviceVethClass *klass)
#define NM_VETH_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_VETH_FACTORY, NMVethFactory))
static NMDevice *
-new_link (NMDeviceFactory *factory, NMPlatformLink *plink, GError **error)
+new_link (NMDeviceFactory *factory, NMPlatformLink *plink, gboolean *out_ignore, GError **error)
{
return (NMDevice *) g_object_new (NM_TYPE_DEVICE_VETH,
NM_DEVICE_PLATFORM_DEVICE, plink,
diff --git a/src/devices/nm-device-vlan.c b/src/devices/nm-device-vlan.c
index ce2005a8ad..fcbe402aba 100644
--- a/src/devices/nm-device-vlan.c
+++ b/src/devices/nm-device-vlan.c
@@ -628,7 +628,7 @@ nm_device_vlan_class_init (NMDeviceVlanClass *klass)
#define NM_VLAN_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_VLAN_FACTORY, NMVlanFactory))
static NMDevice *
-new_link (NMDeviceFactory *factory, NMPlatformLink *plink, GError **error)
+new_link (NMDeviceFactory *factory, NMPlatformLink *plink, gboolean *out_ignore, GError **error)
{
int parent_ifindex = -1;
NMDevice *parent, *device;
diff --git a/src/devices/nm-device-vxlan.c b/src/devices/nm-device-vxlan.c
index c0492aee34..7811934d2a 100644
--- a/src/devices/nm-device-vxlan.c
+++ b/src/devices/nm-device-vxlan.c
@@ -353,7 +353,7 @@ nm_device_vxlan_class_init (NMDeviceVxlanClass *klass)
#define NM_VXLAN_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_VXLAN_FACTORY, NMVxlanFactory))
static NMDevice *
-new_link (NMDeviceFactory *factory, NMPlatformLink *plink, GError **error)
+new_link (NMDeviceFactory *factory, NMPlatformLink *plink, gboolean *out_ignore, GError **error)
{
return (NMDevice *) g_object_new (NM_TYPE_DEVICE_VXLAN,
NM_DEVICE_PLATFORM_DEVICE, plink,
diff --git a/src/devices/team/nm-team-factory.c b/src/devices/team/nm-team-factory.c
index f21f07502c..d87919b6b7 100644
--- a/src/devices/team/nm-team-factory.c
+++ b/src/devices/team/nm-team-factory.c
@@ -48,7 +48,7 @@ nm_device_factory_create (GError **error)
/************************************************************************/
static NMDevice *
-new_link (NMDeviceFactory *factory, NMPlatformLink *plink, GError **error)
+new_link (NMDeviceFactory *factory, NMPlatformLink *plink, gboolean *out_ignore, GError **error)
{
return nm_device_team_new (plink);
}
diff --git a/src/devices/wifi/nm-wifi-factory.c b/src/devices/wifi/nm-wifi-factory.c
index 19578b3d58..c4b4042e70 100644
--- a/src/devices/wifi/nm-wifi-factory.c
+++ b/src/devices/wifi/nm-wifi-factory.c
@@ -59,7 +59,7 @@ nm_device_factory_create (GError **error)
/**************************************************************************/
static NMDevice *
-new_link (NMDeviceFactory *factory, NMPlatformLink *plink, GError **error)
+new_link (NMDeviceFactory *factory, NMPlatformLink *plink, gboolean *out_ignore, GError **error)
{
if (plink->type == NM_LINK_TYPE_WIFI)
return nm_device_wifi_new (plink);
diff --git a/src/devices/wimax/nm-wimax-factory.c b/src/devices/wimax/nm-wimax-factory.c
index ffda4674e5..7dc580fc9e 100644
--- a/src/devices/wimax/nm-wimax-factory.c
+++ b/src/devices/wimax/nm-wimax-factory.c
@@ -56,7 +56,7 @@ nm_device_factory_create (GError **error)
/**************************************************************************/
static NMDevice *
-new_link (NMDeviceFactory *factory, NMPlatformLink *plink, GError **error)
+new_link (NMDeviceFactory *factory, NMPlatformLink *plink, gboolean *out_ignore, GError **error)
{
/* FIXME: check udev 'DEVTYPE' instead; but since we only support Intel
* WiMAX devices for now this is appropriate.
diff --git a/src/devices/wwan/nm-wwan-factory.c b/src/devices/wwan/nm-wwan-factory.c
index b6870d0dde..49b0b0af53 100644
--- a/src/devices/wwan/nm-wwan-factory.c
+++ b/src/devices/wwan/nm-wwan-factory.c
@@ -30,6 +30,7 @@
#include "nm-modem-manager.h"
#include "nm-device-modem.h"
#include "nm-logging.h"
+#include "nm-platform.h"
static GType nm_wwan_factory_get_type (void);
@@ -94,6 +95,14 @@ NM_DEVICE_FACTORY_DECLARE_TYPES (
NM_DEVICE_FACTORY_DECLARE_SETTING_TYPES (NM_SETTING_GSM_SETTING_NAME, NM_SETTING_CDMA_SETTING_NAME)
)
+static NMDevice *
+new_link (NMDeviceFactory *factory, NMPlatformLink *plink, gboolean *out_ignore, GError **error)
+{
+ g_warn_if_fail (plink->type == NM_LINK_TYPE_WWAN_ETHERNET);
+ *out_ignore = TRUE;
+ return NULL;
+}
+
static void
start (NMDeviceFactory *factory)
{
@@ -117,6 +126,7 @@ static void
device_factory_interface_init (NMDeviceFactory *factory_iface)
{
factory_iface->get_supported_types = get_supported_types;
+ factory_iface->new_link = new_link;
factory_iface->start = start;
}
diff --git a/src/nm-manager.c b/src/nm-manager.c
index 0b75ae4918..6d52cf44cf 100644
--- a/src/nm-manager.c
+++ b/src/nm-manager.c
@@ -1910,20 +1910,18 @@ platform_link_added (NMManager *self,
if (nm_manager_get_device_by_ifindex (self, ifindex))
return;
- /* Ignore Bluetooth PAN interfaces; they are handled by their NMDeviceBt
- * parent and don't get a separate interface.
- */
- if (plink->type == NM_LINK_TYPE_BNEP)
- return;
-
/* Try registered device factories */
factory = nm_device_factory_manager_find_factory_for_link_type (plink->type);
if (factory) {
- device = nm_device_factory_new_link (factory, plink, &error);
+ gboolean ignore = FALSE;
+
+ device = nm_device_factory_new_link (factory, plink, &ignore, &error);
if (!device) {
- nm_log_warn (LOGD_HW, "%s: factory failed to create device: %s",
- plink->name, error->message);
- g_clear_error (&error);
+ if (!ignore) {
+ nm_log_warn (LOGD_HW, "%s: factory failed to create device: %s",
+ plink->name, error->message);
+ g_clear_error (&error);
+ }
return;
}
}
@@ -1931,10 +1929,7 @@ platform_link_added (NMManager *self,
if (device == NULL) {
switch (plink->type) {
case NM_LINK_TYPE_WWAN_ETHERNET:
- /* WWAN pseudo-ethernet interfaces are handled automatically by
- * their NMDeviceModem and don't get a separate NMDevice object.
- */
- break;
+ case NM_LINK_TYPE_BNEP:
case NM_LINK_TYPE_OLPC_MESH:
case NM_LINK_TYPE_TEAM:
case NM_LINK_TYPE_WIFI: