mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-07 07:18:03 +02:00
platform: merge branch 'th/platform-set-address-enfile-bgo770456'
https://bugzilla.gnome.org/show_bug.cgi?id=770456
(cherry picked from commit 091620e765)
This commit is contained in:
commit
a3fd48545c
1 changed files with 53 additions and 9 deletions
|
|
@ -4060,18 +4060,14 @@ out:
|
||||||
return !!nmp_cache_lookup_obj (priv->cache, obj_id);
|
return !!nmp_cache_lookup_obj (priv->cache, obj_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static NMPlatformError
|
static WaitForNlResponseResult
|
||||||
do_change_link (NMPlatform *platform,
|
do_change_link_request (NMPlatform *platform,
|
||||||
int ifindex,
|
int ifindex,
|
||||||
struct nl_msg *nlmsg)
|
struct nl_msg *nlmsg)
|
||||||
{
|
{
|
||||||
nm_auto_pop_netns NMPNetns *netns = NULL;
|
nm_auto_pop_netns NMPNetns *netns = NULL;
|
||||||
WaitForNlResponseResult seq_result = WAIT_FOR_NL_RESPONSE_RESULT_UNKNOWN;
|
WaitForNlResponseResult seq_result = WAIT_FOR_NL_RESPONSE_RESULT_UNKNOWN;
|
||||||
int nle;
|
int nle;
|
||||||
char s_buf[256];
|
|
||||||
NMPlatformError result = NM_PLATFORM_ERROR_SUCCESS;
|
|
||||||
NMLogLevel log_level = LOGL_DEBUG;
|
|
||||||
const char *log_result = "failure", *log_detail = "";
|
|
||||||
|
|
||||||
if (!nm_platform_netns_push (platform, &netns))
|
if (!nm_platform_netns_push (platform, &netns))
|
||||||
return NM_PLATFORM_ERROR_UNSPECIFIED;
|
return NM_PLATFORM_ERROR_UNSPECIFIED;
|
||||||
|
|
@ -4098,6 +4094,18 @@ retry:
|
||||||
nlmsg_hdr (nlmsg)->nlmsg_type = RTM_SETLINK;
|
nlmsg_hdr (nlmsg)->nlmsg_type = RTM_SETLINK;
|
||||||
goto retry;
|
goto retry;
|
||||||
}
|
}
|
||||||
|
return seq_result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static NMPlatformError
|
||||||
|
do_change_link_result (NMPlatform *platform,
|
||||||
|
int ifindex,
|
||||||
|
WaitForNlResponseResult seq_result)
|
||||||
|
{
|
||||||
|
char s_buf[256];
|
||||||
|
NMPlatformError result = NM_PLATFORM_ERROR_SUCCESS;
|
||||||
|
NMLogLevel log_level = LOGL_DEBUG;
|
||||||
|
const char *log_result = "failure", *log_detail = "";
|
||||||
|
|
||||||
if (seq_result == WAIT_FOR_NL_RESPONSE_RESULT_RESPONSE_OK) {
|
if (seq_result == WAIT_FOR_NL_RESPONSE_RESULT_RESPONSE_OK) {
|
||||||
log_result = "success";
|
log_result = "success";
|
||||||
|
|
@ -4123,6 +4131,17 @@ retry:
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static NMPlatformError
|
||||||
|
do_change_link (NMPlatform *platform,
|
||||||
|
int ifindex,
|
||||||
|
struct nl_msg *nlmsg)
|
||||||
|
{
|
||||||
|
WaitForNlResponseResult seq_result;
|
||||||
|
|
||||||
|
seq_result = do_change_link_request (platform, ifindex, nlmsg);
|
||||||
|
return do_change_link_result (platform, ifindex, seq_result);
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
link_add (NMPlatform *platform,
|
link_add (NMPlatform *platform,
|
||||||
const char *name,
|
const char *name,
|
||||||
|
|
@ -4430,6 +4449,8 @@ link_set_address (NMPlatform *platform, int ifindex, gconstpointer address, size
|
||||||
{
|
{
|
||||||
nm_auto_nlmsg struct nl_msg *nlmsg = NULL;
|
nm_auto_nlmsg struct nl_msg *nlmsg = NULL;
|
||||||
gs_free char *mac = NULL;
|
gs_free char *mac = NULL;
|
||||||
|
WaitForNlResponseResult seq_result;
|
||||||
|
char s_buf[256];
|
||||||
|
|
||||||
if (!address || !length)
|
if (!address || !length)
|
||||||
g_return_val_if_reached (NM_PLATFORM_ERROR_BUG);
|
g_return_val_if_reached (NM_PLATFORM_ERROR_BUG);
|
||||||
|
|
@ -4449,7 +4470,30 @@ link_set_address (NMPlatform *platform, int ifindex, gconstpointer address, size
|
||||||
|
|
||||||
NLA_PUT (nlmsg, IFLA_ADDRESS, length, address);
|
NLA_PUT (nlmsg, IFLA_ADDRESS, length, address);
|
||||||
|
|
||||||
return do_change_link (platform, ifindex, nlmsg);
|
seq_result = do_change_link_request (platform, ifindex, nlmsg);
|
||||||
|
|
||||||
|
if (NM_IN_SET (-((int) seq_result), ENFILE)) {
|
||||||
|
const NMPObject *obj_cache;
|
||||||
|
|
||||||
|
/* workaround ENFILE which may be wrongly returned (bgo #770456).
|
||||||
|
* If the MAC address is as expected, assume success? */
|
||||||
|
|
||||||
|
obj_cache = nmp_cache_lookup_link (NM_LINUX_PLATFORM_GET_PRIVATE (platform)->cache, ifindex);
|
||||||
|
if ( obj_cache
|
||||||
|
&& obj_cache->link.addr.len == length
|
||||||
|
&& memcmp (obj_cache->link.addr.data, address, length) == 0) {
|
||||||
|
_NMLOG (LOGL_DEBUG,
|
||||||
|
"do-change-link[%d]: %s changing link: %s%s",
|
||||||
|
ifindex,
|
||||||
|
"success",
|
||||||
|
wait_for_nl_response_to_string (seq_result, s_buf, sizeof (s_buf)),
|
||||||
|
" (assume success changing address)");
|
||||||
|
return NM_PLATFORM_ERROR_SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return do_change_link_result (platform, ifindex, seq_result);
|
||||||
|
|
||||||
nla_put_failure:
|
nla_put_failure:
|
||||||
g_return_val_if_reached (NM_PLATFORM_ERROR_UNSPECIFIED);
|
g_return_val_if_reached (NM_PLATFORM_ERROR_UNSPECIFIED);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue