mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-07 20:40:21 +01:00
core: reject existing links when trying to add a link via platform
When we decide to add a new link, we alredy checked that no such link exists (ignoring race conditions). It is wrong to accept a EXITS failure when adding the link. There is no guarantee that the existing link has all the same properties as the one we intend to add. More importantly, this link was added externally outside of NetworkManager and it should not be taken over. Just treat EXISTS as a failure as any other.
This commit is contained in:
parent
809c547b6c
commit
66438de577
9 changed files with 12 additions and 12 deletions
|
|
@ -457,7 +457,7 @@ create_and_realize (NMDevice *device,
|
|||
g_assert (iface);
|
||||
|
||||
plerr = nm_platform_link_bond_add (NM_PLATFORM_GET, iface, out_plink);
|
||||
if (plerr != NM_PLATFORM_ERROR_SUCCESS && plerr != NM_PLATFORM_ERROR_EXISTS) {
|
||||
if (plerr != NM_PLATFORM_ERROR_SUCCESS) {
|
||||
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
||||
"Failed to create bond interface '%s' for '%s': %s",
|
||||
iface,
|
||||
|
|
|
|||
|
|
@ -405,7 +405,7 @@ create_and_realize (NMDevice *device,
|
|||
hwaddr ? mac_address : NULL,
|
||||
hwaddr ? ETH_ALEN : 0,
|
||||
out_plink);
|
||||
if (plerr != NM_PLATFORM_ERROR_SUCCESS && plerr != NM_PLATFORM_ERROR_EXISTS) {
|
||||
if (plerr != NM_PLATFORM_ERROR_SUCCESS) {
|
||||
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
||||
"Failed to create bridge interface '%s' for '%s': %s",
|
||||
iface,
|
||||
|
|
|
|||
|
|
@ -272,7 +272,7 @@ create_and_realize (NMDevice *device,
|
|||
}
|
||||
|
||||
plerr = nm_platform_link_infiniband_add (NM_PLATFORM_GET, parent_ifindex, p_key, out_plink);
|
||||
if (plerr != NM_PLATFORM_ERROR_SUCCESS && plerr != NM_PLATFORM_ERROR_EXISTS) {
|
||||
if (plerr != NM_PLATFORM_ERROR_SUCCESS) {
|
||||
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
||||
"Failed to create InfiniBand P_Key interface '%s' for '%s': %s",
|
||||
nm_device_get_iface (device),
|
||||
|
|
|
|||
|
|
@ -661,7 +661,7 @@ create_and_realize (NMDevice *device,
|
|||
}
|
||||
|
||||
plerr = nm_platform_link_gre_add (NM_PLATFORM_GET, iface, &lnk_gre, out_plink);
|
||||
if (plerr != NM_PLATFORM_ERROR_SUCCESS && plerr != NM_PLATFORM_ERROR_EXISTS) {
|
||||
if (plerr != NM_PLATFORM_ERROR_SUCCESS) {
|
||||
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
||||
"Failed to create GRE interface '%s' for '%s': %s",
|
||||
iface,
|
||||
|
|
@ -687,7 +687,7 @@ create_and_realize (NMDevice *device,
|
|||
lnk_sit.path_mtu_discovery = nm_setting_ip_tunnel_get_path_mtu_discovery (s_ip_tunnel);
|
||||
|
||||
plerr = nm_platform_link_sit_add (NM_PLATFORM_GET, iface, &lnk_sit, out_plink);
|
||||
if (plerr != NM_PLATFORM_ERROR_SUCCESS && plerr != NM_PLATFORM_ERROR_EXISTS) {
|
||||
if (plerr != NM_PLATFORM_ERROR_SUCCESS) {
|
||||
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
||||
"Failed to create SIT interface '%s' for '%s': %s",
|
||||
iface,
|
||||
|
|
@ -713,7 +713,7 @@ create_and_realize (NMDevice *device,
|
|||
lnk_ipip.path_mtu_discovery = nm_setting_ip_tunnel_get_path_mtu_discovery (s_ip_tunnel);
|
||||
|
||||
plerr = nm_platform_link_ipip_add (NM_PLATFORM_GET, iface, &lnk_ipip, out_plink);
|
||||
if (plerr != NM_PLATFORM_ERROR_SUCCESS && plerr != NM_PLATFORM_ERROR_EXISTS) {
|
||||
if (plerr != NM_PLATFORM_ERROR_SUCCESS) {
|
||||
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
||||
"Failed to create IPIP interface '%s' for '%s': %s",
|
||||
iface,
|
||||
|
|
@ -742,7 +742,7 @@ create_and_realize (NMDevice *device,
|
|||
lnk_ip6tnl.proto = nm_setting_ip_tunnel_get_mode (s_ip_tunnel) == NM_IP_TUNNEL_MODE_IPIP6 ? IPPROTO_IPIP : IPPROTO_IPV6;
|
||||
|
||||
plerr = nm_platform_link_ip6tnl_add (NM_PLATFORM_GET, iface, &lnk_ip6tnl, out_plink);
|
||||
if (plerr != NM_PLATFORM_ERROR_SUCCESS && plerr != NM_PLATFORM_ERROR_EXISTS) {
|
||||
if (plerr != NM_PLATFORM_ERROR_SUCCESS) {
|
||||
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
||||
"Failed to create IPIP interface '%s' for '%s': %s",
|
||||
iface,
|
||||
|
|
|
|||
|
|
@ -238,7 +238,7 @@ create_and_realize (NMDevice *device,
|
|||
lnk.tap = nm_setting_macvlan_get_tap (s_macvlan);
|
||||
|
||||
plerr = nm_platform_link_macvlan_add (NM_PLATFORM_GET, iface, parent_ifindex, &lnk, out_plink);
|
||||
if (plerr != NM_PLATFORM_ERROR_SUCCESS && plerr != NM_PLATFORM_ERROR_EXISTS) {
|
||||
if (plerr != NM_PLATFORM_ERROR_SUCCESS) {
|
||||
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
||||
"Failed to create %s interface '%s' for '%s': %s",
|
||||
lnk.tap ? "macvtap" : "macvlan",
|
||||
|
|
|
|||
|
|
@ -222,7 +222,7 @@ create_and_realize (NMDevice *device,
|
|||
nm_setting_tun_get_vnet_hdr (s_tun),
|
||||
nm_setting_tun_get_multi_queue (s_tun),
|
||||
out_plink);
|
||||
if (plerr != NM_PLATFORM_ERROR_SUCCESS && plerr != NM_PLATFORM_ERROR_EXISTS) {
|
||||
if (plerr != NM_PLATFORM_ERROR_SUCCESS) {
|
||||
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
||||
"Failed to create TUN/TAP interface '%s' for '%s': %s",
|
||||
iface,
|
||||
|
|
|
|||
|
|
@ -237,7 +237,7 @@ create_and_realize (NMDevice *device,
|
|||
vlan_id,
|
||||
nm_setting_vlan_get_flags (s_vlan),
|
||||
out_plink);
|
||||
if (plerr != NM_PLATFORM_ERROR_SUCCESS && plerr != NM_PLATFORM_ERROR_EXISTS) {
|
||||
if (plerr != NM_PLATFORM_ERROR_SUCCESS) {
|
||||
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
||||
"Failed to create VLAN interface '%s' for '%s': %s",
|
||||
iface,
|
||||
|
|
|
|||
|
|
@ -224,7 +224,7 @@ create_and_realize (NMDevice *device,
|
|||
props.l3miss = nm_setting_vxlan_get_l3_miss (s_vxlan);
|
||||
|
||||
plerr = nm_platform_link_vxlan_add (NM_PLATFORM_GET, iface, &props, out_plink);
|
||||
if (plerr != NM_PLATFORM_ERROR_SUCCESS && plerr != NM_PLATFORM_ERROR_EXISTS) {
|
||||
if (plerr != NM_PLATFORM_ERROR_SUCCESS) {
|
||||
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
||||
"Failed to create VXLAN interface '%s' for '%s': %s",
|
||||
iface,
|
||||
|
|
|
|||
|
|
@ -673,7 +673,7 @@ create_and_realize (NMDevice *device,
|
|||
NMPlatformError plerr;
|
||||
|
||||
plerr = nm_platform_link_team_add (NM_PLATFORM_GET, iface, out_plink);
|
||||
if (plerr != NM_PLATFORM_ERROR_SUCCESS && plerr != NM_PLATFORM_ERROR_EXISTS) {
|
||||
if (plerr != NM_PLATFORM_ERROR_SUCCESS) {
|
||||
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
||||
"Failed to create team master interface '%s' for '%s': %s",
|
||||
iface,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue