core: merge branch 'bg/rh1956793'

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/917

(cherry picked from commit ec643237cd)
This commit is contained in:
Beniamino Galvani 2021-07-13 09:27:59 +02:00
commit a12c7f7839
2 changed files with 19 additions and 33 deletions

View file

@ -188,6 +188,7 @@ acd_event(int fd, GIOCondition condition, gpointer data)
char to_string_buffer[ACD_EVENT_TO_STRING_BUF_SIZE]; char to_string_buffer[ACD_EVENT_TO_STRING_BUF_SIZE];
gs_free char *hwaddr_str = NULL; gs_free char *hwaddr_str = NULL;
gboolean check_probing_done = FALSE; gboolean check_probing_done = FALSE;
char buf[ETH_ALEN * 3];
switch (event->event) { switch (event->event) {
case N_ACD_EVENT_READY: case N_ACD_EVENT_READY:
@ -202,8 +203,9 @@ acd_event(int fd, GIOCondition condition, gpointer data)
nm_platform_link_get_name(NM_PLATFORM_GET, self->ifindex), nm_platform_link_get_name(NM_PLATFORM_GET, self->ifindex),
acd_error_to_string(r)); acd_error_to_string(r));
} else { } else {
_LOGD("announcing address %s", _LOGD("announcing address %s (hw-addr %s)",
_nm_utils_inet4_ntop(info->address, address_str)); _nm_utils_inet4_ntop(info->address, address_str),
_nm_utils_hwaddr_ntoa(self->hwaddr, ETH_ALEN, TRUE, buf, sizeof(buf)));
} }
} }
check_probing_done = TRUE; check_probing_done = TRUE;
@ -394,6 +396,7 @@ nm_acd_manager_announce_addresses(NMAcdManager *self)
int r; int r;
int fd; int fd;
gboolean success = TRUE; gboolean success = TRUE;
char buf[ETH_ALEN * 3];
r = acd_init(self); r = acd_init(self);
if (r) { if (r) {
@ -428,7 +431,9 @@ nm_acd_manager_announce_addresses(NMAcdManager *self)
acd_error_to_string(r)); acd_error_to_string(r));
success = FALSE; success = FALSE;
} else } else
_LOGD("announcing address %s", _nm_utils_inet4_ntop(info->address, sbuf)); _LOGD("announcing address %s (hw-addr %s)",
_nm_utils_inet4_ntop(info->address, sbuf),
_nm_utils_hwaddr_ntoa(self->hwaddr, ETH_ALEN, TRUE, buf, sizeof(buf)));
} }
} }

View file

@ -4774,10 +4774,6 @@ nm_device_master_enslave_slave(NMDevice *self, NMDevice *slave, NMConnection *co
*/ */
nm_device_update_hw_address(self); nm_device_update_hw_address(self);
/* Send ARP announcements if did not yet and have addresses. */
if (priv->ip_state_4 == NM_DEVICE_IP_STATE_DONE && !priv->acd.announcing)
nm_device_arp_announce(self);
/* Restart IP configuration if we're waiting for slaves. Do this /* Restart IP configuration if we're waiting for slaves. Do this
* after updating the hardware address as IP config may need the * after updating the hardware address as IP config may need the
* new address. * new address.
@ -5106,6 +5102,10 @@ nm_device_set_carrier(NMDevice *self, gboolean carrier)
nm_device_remove_pending_action(self, NM_PENDING_ACTION_CARRIER_WAIT, FALSE); nm_device_remove_pending_action(self, NM_PENDING_ACTION_CARRIER_WAIT, FALSE);
_carrier_wait_check_queued_act_request(self); _carrier_wait_check_queued_act_request(self);
} }
/* Send ARP announcements if did not yet and have carrier. */
if (priv->ip_state_4 == NM_DEVICE_IP_STATE_DONE && !priv->acd.announcing)
nm_device_arp_announce(self);
} else { } else {
if (priv->carrier_wait_id) if (priv->carrier_wait_id)
nm_device_add_pending_action(self, NM_PENDING_ACTION_CARRIER_WAIT, FALSE); nm_device_add_pending_action(self, NM_PENDING_ACTION_CARRIER_WAIT, FALSE);
@ -11916,7 +11916,6 @@ activate_stage5_ip_config_result_x(NMDevice *self, int addr_family)
const char * method; const char * method;
int ip_ifindex; int ip_ifindex;
int errsv; int errsv;
gboolean do_announce = FALSE;
req = nm_device_get_act_request(self); req = nm_device_get_act_request(self);
g_assert(req); g_assert(req);
@ -12044,31 +12043,13 @@ activate_stage5_ip_config_result_x(NMDevice *self, int addr_family)
} }
} }
if (IS_IPv4) { if (IS_IPv4 && priv->carrier) {
/* Send ARP announcements */ /* We send ARP announcements only when the link gets carrier,
* otherwise the announcements would be lost. Furthermore, for
if (nm_device_is_master(self)) { * controllers having carrier implies that there is at least one
CList * iter; * port and therefore the MAC address is the correct one.
SlaveInfo *info; */
nm_device_arp_announce(self);
/* Skip announcement if there are no device enslaved, for two reasons:
* 1) the master has a temporary MAC address until the first slave comes
* 2) announcements are going to be dropped anyway without slaves
*/
do_announce = FALSE;
c_list_for_each (iter, &priv->slaves) {
info = c_list_entry(iter, SlaveInfo, lst_slave);
if (info->slave_is_enslaved) {
do_announce = TRUE;
break;
}
}
} else
do_announce = TRUE;
if (do_announce)
nm_device_arp_announce(self);
} }
if (IS_IPv4) { if (IS_IPv4) {