diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index e649d267f..f70791947 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -7969,6 +7969,7 @@ dhcp4_start (NMDevice *self) gs_unref_bytes GBytes *client_id = NULL; NMConnection *connection; GError *error = NULL; + const NMPlatformLink *pllink; connection = nm_device_get_applied_connection (self); g_return_val_if_fail (connection, FALSE); @@ -7979,8 +7980,9 @@ dhcp4_start (NMDevice *self) nm_dbus_object_clear_and_unexport (&priv->dhcp4.config); priv->dhcp4.config = nm_dhcp4_config_new (); - hwaddr = nm_platform_link_get_address_as_bytes (nm_device_get_platform (self), - nm_device_get_ip_ifindex (self)); + pllink = nm_platform_link_get (nm_device_get_platform (self), nm_device_get_ip_ifindex (self)); + if (pllink) + hwaddr = nmp_link_address_get_as_bytes (&pllink->l_address); client_id = dhcp4_get_client_id (self, connection, hwaddr); @@ -8769,6 +8771,7 @@ dhcp6_start_with_link_ready (NMDevice *self, NMConnection *connection) gs_unref_bytes GBytes *hwaddr = NULL; gs_unref_bytes GBytes *duid = NULL; gboolean enforce_duid = FALSE; + const NMPlatformLink *pllink; GError *error = NULL; const NMPlatformIP6Address *ll_addr = NULL; @@ -8788,8 +8791,9 @@ dhcp6_start_with_link_ready (NMDevice *self, NMConnection *connection) return FALSE; } - hwaddr = nm_platform_link_get_address_as_bytes (nm_device_get_platform (self), - nm_device_get_ip_ifindex (self)); + pllink = nm_platform_link_get (nm_device_get_platform (self), nm_device_get_ip_ifindex (self)); + if (pllink) + hwaddr = nmp_link_address_get_as_bytes (&pllink->l_address); duid = dhcp6_get_duid (self, connection, hwaddr, &enforce_duid); priv->dhcp6.client = nm_dhcp_manager_start_ip6 (nm_dhcp_manager_get (), diff --git a/src/nm-iface-helper.c b/src/nm-iface-helper.c index adf64c751..c8f7d5ccc 100644 --- a/src/nm-iface-helper.c +++ b/src/nm-iface-helper.c @@ -383,6 +383,7 @@ main (int argc, char *argv[]) gs_unref_bytes GBytes *hwaddr = NULL; gs_unref_bytes GBytes *client_id = NULL; gs_free NMUtilsIPv6IfaceId *iid = NULL; + const NMPlatformLink *pllink; guint sd_id; int errsv; @@ -469,7 +470,9 @@ main (int argc, char *argv[]) /* Set up platform interaction layer */ nm_linux_platform_setup (); - hwaddr = nm_platform_link_get_address_as_bytes (NM_PLATFORM_GET, gl.ifindex); + pllink = nm_platform_link_get (NM_PLATFORM_GET, gl.ifindex); + if (pllink) + hwaddr = nmp_link_address_get_as_bytes (&pllink->l_address); if (global_opt.iid_str) { GBytes *bytes; diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c index 2ed46fe44..6ead15ed3 100644 --- a/src/platform/nm-platform.c +++ b/src/platform/nm-platform.c @@ -100,6 +100,19 @@ nmp_link_address_get (const NMPLinkAddress *addr, size_t *length) return addr->data; } +GBytes * +nmp_link_address_get_as_bytes (const NMPLinkAddress *addr) +{ + gconstpointer data; + size_t length; + + data = nmp_link_address_get (addr, &length); + + return length > 0 + ? g_bytes_new (data, length) + : NULL; +} + /*****************************************************************************/ #define _NMLOG_DOMAIN LOGD_PLATFORM diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h index 1e6007e1f..248eca44f 100644 --- a/src/platform/nm-platform.h +++ b/src/platform/nm-platform.h @@ -164,6 +164,7 @@ typedef struct { } NMPLinkAddress; gconstpointer nmp_link_address_get (const NMPLinkAddress *addr, size_t *length); +GBytes *nmp_link_address_get_as_bytes (const NMPLinkAddress *addr); typedef enum { @@ -1407,18 +1408,6 @@ gboolean nm_platform_link_get_user_ipv6ll_enabled (NMPlatform *self, int ifindex gconstpointer nm_platform_link_get_address (NMPlatform *self, int ifindex, size_t *length); -static inline GBytes * -nm_platform_link_get_address_as_bytes (NMPlatform *self, int ifindex) -{ - gconstpointer p; - gsize l; - - p = nm_platform_link_get_address (self, ifindex, &l); - return p - ? g_bytes_new (p, l) - : NULL; -} - int nm_platform_link_get_master (NMPlatform *self, int slave); gboolean nm_platform_link_can_assume (NMPlatform *self, int ifindex);