mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-06 10:18:03 +02:00
core: don't warn when setting address of non-existing link
Trying to set a property on a device that does not exist is not something
necessarily wrong. Don't print error/warning messages.
<trace> [1467707267.2887] device[0x55a74adbdaf0] (enp0s25): set-hw-addr: setting MAC address to 'AA:BB:CC:DD:EE:FF' (reset, unmanage)...
<debug> [1467707267.2887] platform: link: setting '(null)' (2) hardware address
<debug> [1467707267.2887] platform-linux: link: change 2: address: 68:F7:28:61:68:F7 (6 bytes)
<debug> [1467707267.2887] platform-linux: do-request-link: 2
<debug> [1467707267.2888] platform-linux: netlink: recvmsg: error message from kernel: No such device (19) for request 226
<debug> [1467707267.2888] platform-linux: netlink: recvmsg: error message from kernel: No such device (19) for request 227
<error> [1467707267.2888] platform-linux: do-change-link[2]: failure changing link: failure 19 (No such device)
<warn> [1467707267.2888] device (enp0s25): set-hw-addr: failed to reset MAC address to 68:F7:28:61:68:F7 (unmanage)
This commit is contained in:
parent
4041bf966f
commit
f9852821e3
6 changed files with 29 additions and 20 deletions
|
|
@ -11657,6 +11657,7 @@ _hw_addr_set (NMDevice *self,
|
|||
{
|
||||
NMDevicePrivate *priv;
|
||||
gboolean success = FALSE;
|
||||
NMPlatformError plerr;
|
||||
const char *cur_addr;
|
||||
guint8 addr_bytes[NM_UTILS_HWADDR_LEN_MAX];
|
||||
guint hw_addr_len;
|
||||
|
|
@ -11691,7 +11692,8 @@ _hw_addr_set (NMDevice *self,
|
|||
nm_device_take_down (self, FALSE);
|
||||
}
|
||||
|
||||
success = nm_platform_link_set_address (NM_PLATFORM_GET, nm_device_get_ip_ifindex (self), addr_bytes, hw_addr_len);
|
||||
plerr = nm_platform_link_set_address (NM_PLATFORM_GET, nm_device_get_ip_ifindex (self), addr_bytes, hw_addr_len);
|
||||
success = (plerr == NM_PLATFORM_ERROR_SUCCESS);
|
||||
if (success) {
|
||||
/* MAC address succesfully changed; update the current MAC to match */
|
||||
nm_device_update_hw_address (self);
|
||||
|
|
@ -11706,8 +11708,10 @@ _hw_addr_set (NMDevice *self,
|
|||
success = FALSE;
|
||||
}
|
||||
} else {
|
||||
_LOGW (LOGD_DEVICE, "set-hw-addr: failed to %s MAC address to %s (%s)",
|
||||
operation, addr, detail);
|
||||
_NMLOG (plerr == NM_PLATFORM_ERROR_NOT_FOUND ? LOGL_DEBUG : LOGL_WARN,
|
||||
LOGD_DEVICE, "set-hw-addr: failed to %s MAC address to %s (%s) (%s)",
|
||||
operation, addr, detail,
|
||||
nm_platform_error_to_string (plerr));
|
||||
}
|
||||
|
||||
if (was_up) {
|
||||
|
|
|
|||
|
|
@ -506,7 +506,7 @@ link_set_noarp (NMPlatform *platform, int ifindex)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
static NMPlatformError
|
||||
link_set_address (NMPlatform *platform, int ifindex, gconstpointer addr, size_t len)
|
||||
{
|
||||
NMFakePlatformLink *device = link_get (platform, ifindex);
|
||||
|
|
@ -515,7 +515,7 @@ link_set_address (NMPlatform *platform, int ifindex, gconstpointer addr, size_t
|
|||
|| len == 0
|
||||
|| len > NM_UTILS_HWADDR_LEN_MAX
|
||||
|| !addr)
|
||||
g_return_val_if_reached (FALSE);
|
||||
g_return_val_if_reached (NM_PLATFORM_ERROR_BUG);
|
||||
|
||||
if ( device->link.addr.len != len
|
||||
|| ( len > 0
|
||||
|
|
@ -525,7 +525,7 @@ link_set_address (NMPlatform *platform, int ifindex, gconstpointer addr, size_t
|
|||
link_changed (platform, link_get (platform, ifindex), TRUE);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
return NM_PLATFORM_ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
|
|||
|
|
@ -4089,6 +4089,9 @@ retry:
|
|||
} else if (NM_IN_SET (-((int) seq_result), ESRCH, ENOENT)) {
|
||||
log_detail = ", firmware not found";
|
||||
result = NM_PLATFORM_ERROR_NO_FIRMWARE;
|
||||
} else if (NM_IN_SET (-((int) seq_result), ENODEV)) {
|
||||
log_level = LOGL_DEBUG;
|
||||
result = NM_PLATFORM_ERROR_NOT_FOUND;
|
||||
} else {
|
||||
log_level = LOGL_ERR;
|
||||
result = NM_PLATFORM_ERROR_UNSPECIFIED;
|
||||
|
|
@ -4405,14 +4408,14 @@ link_supports_vlans (NMPlatform *platform, int ifindex)
|
|||
return nmp_utils_ethtool_supports_vlans (obj->link.name);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
static NMPlatformError
|
||||
link_set_address (NMPlatform *platform, int ifindex, gconstpointer address, size_t length)
|
||||
{
|
||||
nm_auto_nlmsg struct nl_msg *nlmsg = NULL;
|
||||
gs_free char *mac = NULL;
|
||||
|
||||
if (!address || !length)
|
||||
g_return_val_if_reached (FALSE);
|
||||
g_return_val_if_reached (NM_PLATFORM_ERROR_BUG);
|
||||
|
||||
_LOGD ("link: change %d: address: %s (%lu bytes)", ifindex,
|
||||
(mac = nm_utils_hwaddr_ntoa (address, length)),
|
||||
|
|
@ -4425,13 +4428,13 @@ link_set_address (NMPlatform *platform, int ifindex, gconstpointer address, size
|
|||
0,
|
||||
0);
|
||||
if (!nlmsg)
|
||||
return FALSE;
|
||||
g_return_val_if_reached (NM_PLATFORM_ERROR_UNSPECIFIED);
|
||||
|
||||
NLA_PUT (nlmsg, IFLA_ADDRESS, length, address);
|
||||
|
||||
return do_change_link (platform, ifindex, nlmsg) == NM_PLATFORM_ERROR_SUCCESS;
|
||||
return do_change_link (platform, ifindex, nlmsg);
|
||||
nla_put_failure:
|
||||
g_return_val_if_reached (FALSE);
|
||||
g_return_val_if_reached (NM_PLATFORM_ERROR_UNSPECIFIED);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
|
|||
|
|
@ -1003,16 +1003,18 @@ nm_platform_link_set_user_ipv6ll_enabled (NMPlatform *self, int ifindex, gboolea
|
|||
*
|
||||
* Set interface MAC address.
|
||||
*/
|
||||
gboolean
|
||||
NMPlatformError
|
||||
nm_platform_link_set_address (NMPlatform *self, int ifindex, gconstpointer address, size_t length)
|
||||
{
|
||||
_CHECK_SELF (self, klass, FALSE);
|
||||
_CHECK_SELF (self, klass, NM_PLATFORM_ERROR_BUG);
|
||||
|
||||
g_return_val_if_fail (ifindex > 0, FALSE);
|
||||
g_return_val_if_fail (address, FALSE);
|
||||
g_return_val_if_fail (length > 0, FALSE);
|
||||
g_return_val_if_fail (ifindex > 0, NM_PLATFORM_ERROR_BUG);
|
||||
g_return_val_if_fail (address, NM_PLATFORM_ERROR_BUG);
|
||||
g_return_val_if_fail (length > 0, NM_PLATFORM_ERROR_BUG);
|
||||
|
||||
_LOGD ("link: setting '%s' (%d) hardware address", nm_platform_link_get_name (self, ifindex), ifindex);
|
||||
_LOGD ("link: setting %s (%d) hardware address",
|
||||
nm_strquote_a (20, nm_platform_link_get_name (self, ifindex)),
|
||||
ifindex);
|
||||
return klass->link_set_address (self, ifindex, address, length);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -526,7 +526,7 @@ typedef struct {
|
|||
int ifindex,
|
||||
guint8 *buf,
|
||||
size_t *length);
|
||||
gboolean (*link_set_address) (NMPlatform *, int ifindex, gconstpointer address, size_t length);
|
||||
NMPlatformError (*link_set_address) (NMPlatform *, int ifindex, gconstpointer address, size_t length);
|
||||
gboolean (*link_set_mtu) (NMPlatform *, int ifindex, guint32 mtu);
|
||||
|
||||
char * (*link_get_physical_port_id) (NMPlatform *, int ifindex);
|
||||
|
|
@ -757,7 +757,7 @@ gboolean nm_platform_link_set_user_ipv6ll_enabled (NMPlatform *self, int ifindex
|
|||
gboolean nm_platform_link_set_ipv6_token (NMPlatform *self, int ifindex, NMUtilsIPv6IfaceId iid);
|
||||
|
||||
gboolean nm_platform_link_get_permanent_address (NMPlatform *self, int ifindex, guint8 *buf, size_t *length);
|
||||
gboolean nm_platform_link_set_address (NMPlatform *self, int ifindex, const void *address, size_t length);
|
||||
NMPlatformError nm_platform_link_set_address (NMPlatform *self, int ifindex, const void *address, size_t length);
|
||||
gboolean nm_platform_link_set_mtu (NMPlatform *self, int ifindex, guint32 mtu);
|
||||
|
||||
char *nm_platform_link_get_physical_port_id (NMPlatform *self, int ifindex);
|
||||
|
|
|
|||
|
|
@ -592,7 +592,7 @@ test_internal (void)
|
|||
g_assert (nm_platform_link_supports_vlans (NM_PLATFORM_GET, ifindex));
|
||||
|
||||
/* Set MAC address */
|
||||
g_assert (nm_platform_link_set_address (NM_PLATFORM_GET, ifindex, mac, sizeof (mac)));
|
||||
g_assert (nm_platform_link_set_address (NM_PLATFORM_GET, ifindex, mac, sizeof (mac)) == NM_PLATFORM_ERROR_SUCCESS);
|
||||
address = nm_platform_link_get_address (NM_PLATFORM_GET, ifindex, &addrlen);
|
||||
g_assert (addrlen == sizeof(mac));
|
||||
g_assert (!memcmp (address, mac, addrlen));
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue