mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-26 20:30:08 +01:00
device: fix matching MAC address for VLAN and MACVLAN devices
VLAN and MACVLAN devices consider an ethernet.mac-address setting to find the parent device. This setting shall be the permanent MAC address of the device, not the current.
This commit is contained in:
parent
eb3247c097
commit
cc4371ef56
4 changed files with 22 additions and 19 deletions
|
|
@ -92,10 +92,10 @@ typedef struct {
|
|||
* @connection: the #NMConnection to return the parent name for, if supported
|
||||
*
|
||||
* Given a connection, returns the a parent interface name, parent connection
|
||||
* UUID, or parent device hardware address for @connection.
|
||||
* UUID, or parent device permanent hardware address for @connection.
|
||||
*
|
||||
* Returns: the parent interface name, parent connection UUID, parent
|
||||
* device hardware address, or %NULL
|
||||
* device permenent hardware address, or %NULL
|
||||
*/
|
||||
const char * (*get_connection_parent) (NMDeviceFactory *factory,
|
||||
NMConnection *connection);
|
||||
|
|
|
|||
|
|
@ -373,9 +373,8 @@ match_hwaddr (NMDevice *device, NMConnection *connection, gboolean fail_if_no_hw
|
|||
if (!priv->parent)
|
||||
return !fail_if_no_hwaddr;
|
||||
|
||||
parent_mac = nm_device_get_hw_address (priv->parent);
|
||||
|
||||
return nm_utils_hwaddr_matches (setting_mac, -1, parent_mac, -1);
|
||||
parent_mac = nm_device_get_permanent_hw_address (priv->parent, FALSE);
|
||||
return parent_mac && nm_utils_hwaddr_matches (setting_mac, -1, parent_mac, -1);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
|
|||
|
|
@ -378,21 +378,25 @@ match_parent (NMDeviceVlan *self, const char *parent)
|
|||
static gboolean
|
||||
match_hwaddr (NMDevice *device, NMConnection *connection, gboolean fail_if_no_hwaddr)
|
||||
{
|
||||
NMSettingWired *s_wired;
|
||||
const char *setting_mac;
|
||||
const char *device_mac;
|
||||
NMDeviceVlanPrivate *priv;
|
||||
NMSettingWired *s_wired;
|
||||
const char *setting_mac;
|
||||
const char *parent_mac;
|
||||
|
||||
s_wired = nm_connection_get_setting_wired (connection);
|
||||
if (!s_wired)
|
||||
return !fail_if_no_hwaddr;
|
||||
s_wired = nm_connection_get_setting_wired (connection);
|
||||
if (!s_wired)
|
||||
return !fail_if_no_hwaddr;
|
||||
|
||||
setting_mac = nm_setting_wired_get_mac_address (s_wired);
|
||||
if (!setting_mac)
|
||||
return !fail_if_no_hwaddr;
|
||||
setting_mac = nm_setting_wired_get_mac_address (s_wired);
|
||||
if (!setting_mac)
|
||||
return !fail_if_no_hwaddr;
|
||||
|
||||
device_mac = nm_device_get_hw_address (device);
|
||||
priv = NM_DEVICE_VLAN_GET_PRIVATE (device);
|
||||
if (!priv->parent)
|
||||
return !fail_if_no_hwaddr;
|
||||
|
||||
return nm_utils_hwaddr_matches (setting_mac, -1, device_mac, -1);
|
||||
parent_mac = nm_device_get_permanent_hw_address (priv->parent, FALSE);
|
||||
return parent_mac && nm_utils_hwaddr_matches (setting_mac, -1, parent_mac, -1);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
|
|||
|
|
@ -595,7 +595,7 @@ nm_manager_get_device_by_ifindex (NMManager *manager, int ifindex)
|
|||
}
|
||||
|
||||
static NMDevice *
|
||||
find_device_by_hw_addr (NMManager *manager, const char *hwaddr)
|
||||
find_device_by_permanent_hw_addr (NMManager *manager, const char *hwaddr)
|
||||
{
|
||||
GSList *iter;
|
||||
const char *device_addr;
|
||||
|
|
@ -604,7 +604,7 @@ find_device_by_hw_addr (NMManager *manager, const char *hwaddr)
|
|||
|
||||
if (nm_utils_hwaddr_valid (hwaddr, -1)) {
|
||||
for (iter = NM_MANAGER_GET_PRIVATE (manager)->devices; iter; iter = iter->next) {
|
||||
device_addr = nm_device_get_hw_address (NM_DEVICE (iter->data));
|
||||
device_addr = nm_device_get_permanent_hw_address (NM_DEVICE (iter->data), FALSE);
|
||||
if (device_addr && nm_utils_hwaddr_matches (hwaddr, -1, device_addr, -1))
|
||||
return NM_DEVICE (iter->data);
|
||||
}
|
||||
|
|
@ -1054,7 +1054,7 @@ find_parent_device_for_connection (NMManager *self, NMConnection *connection, NM
|
|||
return parent;
|
||||
|
||||
/* Maybe a hardware address */
|
||||
parent = find_device_by_hw_addr (self, parent_name);
|
||||
parent = find_device_by_permanent_hw_addr (self, parent_name);
|
||||
if (parent)
|
||||
return parent;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue