summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2015-05-06 09:53:44 -0500
committerDan Williams <dcbw@redhat.com>2015-05-06 16:14:25 -0500
commit8fa0f4690f6f97b046399e33de1d1d6d81235636 (patch)
tree31c1e7b9b7528db8f40aebb419889054621b2f38
parentaba250a7d4e72a7a98e6d43b1fb36689671b4855 (diff)
downloadNetworkManager-dcbw/dfa-early.tar.gz
core: let plugins indicate links which should be ignoreddcbw/dfa-early
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).
-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/wwan/nm-wwan-factory.c10
-rw-r--r--src/nm-manager.c23
17 files changed, 50 insertions, 27 deletions
diff --git a/src/devices/bluetooth/nm-bluez-manager.c b/src/devices/bluetooth/nm-bluez-manager.c
index d325f44c8c..2e1c46b13c 100644
--- a/src/devices/bluetooth/nm-bluez-manager.c
+++ b/src/devices/bluetooth/nm-bluez-manager.c
@@ -37,6 +37,7 @@
#include "nm-connection-provider.h"
#include "nm-device-bt.h"
#include "nm-core-internal.h"
+#include "nm-platform.h"
typedef struct {
int bluez_version;
@@ -369,6 +370,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)
)
@@ -403,10 +405,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 951954ba6e..17fb12c919 100644
--- a/src/devices/nm-device-bond.c
+++ b/src/devices/nm-device-bond.c
@@ -553,7 +553,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 ffec9764dd..221bed97bb 100644
--- a/src/devices/nm-device-bridge.c
+++ b/src/devices/nm-device-bridge.c
@@ -477,7 +477,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 114b2c9eb3..3337a106d4 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 bb3d4af941..04f03fbbe5 100644
--- a/src/devices/nm-device-veth.c
+++ b/src/devices/nm-device-veth.c
@@ -177,7 +177,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/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 6bb867ca71..848ccd26bf 100644
--- a/src/nm-manager.c
+++ b/src/nm-manager.c
@@ -1905,20 +1905,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;
}
}
@@ -1926,10 +1924,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: