On Wed, 2017-09-27 at 11:02 +0200, Beniamino Galvani wrote:
--- src/devices/nm-device-ip-tunnel.c | 40 ++--------------------------- --------- src/devices/nm-device-macvlan.c | 41 +-------------------------- ------------ src/devices/nm-device-private.h | 2 ++ src/devices/nm-device-vlan.c | 40 +-------------------------- ----------- src/devices/nm-device-vxlan.c | 40 +-------------------------- ----------- src/devices/nm-device.c | 37 +++++++++++++++++++++++++++++++++++ 6 files changed, 44 insertions(+), 156 deletions(-)
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 86e2f9d36..e14a15f79 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -4390,6 +4390,43 @@ nm_device_complete_connection (NMDevice *self, return success; } +gboolean +nm_device_match_parent (NMDevice *self, const char *parent) +{ + NMDevice *parent_device; + + g_return_val_if_fail (parent, FALSE); + + parent_device = nm_device_parent_get_device (self); + if (!parent_device) + return FALSE; + + if (nm_utils_is_uuid (parent)) { + NMActiveConnection *ac; + NMConnection *connection; + + /* If the parent is a UUID, the connection matches if our parent + * device has that connection activated. + */ + ac = (NMActiveConnection *) nm_device_get_act_request (parent_device); + if (!ac) + return FALSE; + + connection = nm_active_connection_get_applied_connection (ac); + if (!connection) + return FALSE;
just nm_device_get_applied_connection() which looks up @ac internally? I see, in the later patch "device: match all UUIDs when no connection is active" you distinguish between !ac and !connection. But you don't need this distinction, because (I think?) that an activation request at this point always has an applied-connection.
+ + if (!nm_streq (parent, nm_connection_get_uuid (connection))) + return FALSE; + } else { + /* Interface name */ + if (!nm_streq (parent, nm_device_get_ip_iface (parent_device))) + return FALSE;
+1 for using nm_streq/nm_streq0. But in this case, I am not 100% sure that nm_device_get_ip_iface() returns non-NULL. Could you use nm_streq0()?
+ } + + return TRUE; +} + static gboolean check_connection_compatible (NMDevice *self, NMConnection *connection) {
The remaining 3 patches lgtm. best, Thomas
Attachment:
signature.asc
Description: This is a digitally signed message part