From 6e06a7d4a11ca85fdcdf98c41d28742ec3033f89 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 16 May 2014 17:51:27 +0200 Subject: [PATCH] core: match the NMSettingBridge:mac-address in NMDeviceBridge:check_connection_compatible() https://bugzilla.gnome.org/show_bug.cgi?id=729844 Signed-off-by: Thomas Haller --- src/devices/nm-device-bridge.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/devices/nm-device-bridge.c b/src/devices/nm-device-bridge.c index 663f3188f8..76138ae712 100644 --- a/src/devices/nm-device-bridge.c +++ b/src/devices/nm-device-bridge.c @@ -102,6 +102,7 @@ check_connection_compatible (NMDevice *device, { const char *iface; NMSettingBridge *s_bridge; + const GByteArray *mac_address; if (!NM_DEVICE_CLASS (nm_device_bridge_parent_class)->check_connection_compatible (device, connection, error)) return FALSE; @@ -121,6 +122,21 @@ check_connection_compatible (NMDevice *device, return FALSE; } + mac_address = nm_setting_bridge_get_mac_address (s_bridge); + if (mac_address) { + guint hw_len; + const guint8 *hw_addr; + + hw_addr = nm_device_get_hw_address (device, &hw_len); + if ( !hw_addr + || hw_len != mac_address->len + || memcmp (mac_address->data, hw_addr, hw_len) != 0) { + g_set_error (error, NM_BRIDGE_ERROR, NM_BRIDGE_ERROR_CONNECTION_INVALID, + "The bridge mac-address does not match the address of the device."); + return FALSE; + } + } + return TRUE; }