NetworkManager/src/core
Lubomir Rintel 1f61f3f239 device: release slaves when an external device is going managed
When we're deactivating an externally created device that has a master
because we're activating a connection on it, actually remove the device
from the master. Otherwise unpleasant things happen:

  active-connection[0x55ed7ba78400]: constructed (NMActRequest, version-id 4, type managed)
  device[0a458361f9fed8f5] (dummy0): sys-iface-state: external -> managed
  device[0a458361f9fed8f5] (dummy0): queue activation request waiting for currently active connection to disconnect
  device (dummy0): disconnecting for new activation request.
  device (dummy0): state change: activated -> deactivating (reason 'new-activation', sys-iface-state: 'managed')
  device (br0): master: release one slave 0a458361f9fed8f5/dummy0 (enslaved)(no-config)

Note the "no-config" above. We'set priv->master = NULL, but didn't
communicate the change to the platform. I believe this is not good.
This patch changes that.

  device (br0): bridge port dummy0 was detached
  device (dummy0): released from master device br0
  active-connection[0x55ed7ba782e0]: set state deactivating (was activated)
  device (dummy0): ip4: set state none (was done, reason: ip-state-clear)
  device (dummy0): ip6: set state none (was done, reason: ip-state-clear)
  device (dummy0): state change: deactivating -> disconnected (reason 'new-activation', sys-iface-state: 'managed')

  platform: (dummy0) emit signal link-changed changed: 102: dummy0
      <NOARP,UP,LOWER_UP;broadcast,noarp,up,running,lowerup> mtu 1500 master 101 arp 1 dummy* init
       addrgenmode none addr EA:8D:DD:DF:1F:B7 brd FF:FF:FF:FF:FF:FF driver dummy rx:0,0 tx:39,4746

Now the platform sent us a new link, the "master" property is still set.

  device[0a458361f9fed8f5] (dummy0): queued link change for ifindex 102
  device[0a458361f9fed8f5] (dummy0): deactivating device (reason 'new-activation') [60]
  device (dummy0): ip: set (combined) state none (was done, reason: ip-state-clear)
  config: device-state: write #102 (/run/NetworkManager/devices/102); managed=managed, perm-hw-addr-fake=EA:8D:DD:DF:1F:B7, route-metric-default=0-0
  active-connection[0x55ed7ba782e0]: set state deactivated (was deactivating)
  active-connection[0x55ed7ba782e0]: check-master-ready: already signalled (state deactivated, master 0x55ed7ba781c0 is in state activated)
  device (dummy0): Activation: starting connection 'dummy1' (ec6fca51-84e6-4a5b-a297-f602252c9f69)
  device[0a458361f9fed8f5] (dummy0): activation-stage: schedule activate_stage1_device_prepare

  l3cfg[ae290b5c1f585d6c,ifindex=102]: emit signal (platform-change-on-idle, obj-type-flags=0x2a)
  device (br0): master: add one slave 0a458361f9fed8f5/dummy0

Amidst the new activation we're processing the netlink message we got.
We set priv->master back, effectively nullifying the release above. Sad.

  device (dummy0): state change: disconnected -> prepare (reason 'none', sys-iface-state: 'managed')
  device[0a458361f9fed8f5] (dummy0): add_pending_action (2): 'in-state-change'
  active-connection[0x55ed7ba78400]: set state activating (was unknown)
  manager: NetworkManager state is now CONNECTING
  active-connection[0x55ed7ba78400]: check-master-ready: not signalling (state activating, no master)
  device[8fff58d61c7686ce] (br0): slave dummy0 state change 30 (disconnected) -> 40 (prepare)
  device[0a458361f9fed8f5] (dummy0): remove_pending_action (1): 'in-state-change'
  device (br0): master: release one slave 0a458361f9fed8f5/dummy0 (not enslaved) (force-configure)
  platform: (dummy0) link: releasing 102 from master 'br0' (101)
  device (br0): detached bridge port dummy0

Now things go south. The stage1 cleans the device up, removing it from
the master and the device itself decides it should deactivate itself
because it lots its master regardless of the fact that it should not
have one and it's in fact an unwanted carryover from previous activation.
I believe this is also wrong.

  device[0a458361f9fed8f5] (dummy0): Activation: connection 'dummy1' master deactivated
  device (dummy0): ip4: set state none (was pending, reason: ip-state-clear)
  device (dummy0): ip6: set state none (was pending, reason: ip-state-clear)
  device[0a458361f9fed8f5] (dummy0): add_pending_action (2): 'queued-state-change-deactivating'
  device[0a458361f9fed8f5] (dummy0): queue-state[deactivating, reason:connection-assumed, id:298]: queue state change
  device[0a458361f9fed8f5] (dummy0): activation-stage: synchronously invoke activate_stage2_device_config
  device (dummy0): state change: prepare -> config (reason 'none', sys-iface-state: 'managed')

Now things are really weird. We synchronously go to config, effectively
overriding the queued deactivation. We've really messed up.
2022-06-14 14:21:53 +02:00
..
devices device: release slaves when an external device is going managed 2022-06-14 14:21:53 +02:00
dhcp dhcp: implement ACD (address collision detection) for DHCPv4 2022-06-01 10:37:44 +02:00
dns dns: detect more quickly when systemd-resolved can't be D-Bus activated 2022-05-25 16:03:12 +02:00
dnsmasq all: avoid using global string buffer for to-string methods 2022-04-08 15:59:49 +02:00
ndisc ndisc/tests: relex check in test_dns_solicit_loop() 2022-04-12 18:45:29 +02:00
platform platform: avoid struct alignment issue for NMPlatformIP4Address 2022-05-19 16:11:34 +02:00
ppp ppp-manager: ip6: set interface mtu based on ppp config 2022-06-09 14:21:10 +00:00
settings ifcfg: set errno for svGetValueEnum() to detect unset values 2022-06-07 09:55:39 +02:00
supplicant wifi: support "802-1x.phase1-auth-flags=tls-allow-unsafe-renegotiation" flag 2022-05-16 12:09:11 +02:00
tests l3cfg: drop NM_L3_CFG_COMMIT_TYPE_ASSUME and assume_config_once 2022-04-28 10:48:56 +02:00
vpn core: increase l3cfg merge priority for VPN config 2022-02-01 19:22:02 +01:00
main-utils.c core: move nm_main_utils_get_nm_[ug]id() to "nm-core-utils.h" 2022-01-18 18:10:55 +01:00
main-utils.h core: move nm_main_utils_get_nm_[ug]id() to "nm-core-utils.h" 2022-01-18 18:10:55 +01:00
main.c core: create GMainLoop after daemonizing 2022-03-22 13:43:41 +01:00
meson.build dns/unbound: drop deprecated "unbound" DNS plugin 2022-04-15 09:04:30 +02:00
NetworkManagerUtils.c all: avoid using systemd path utils 2022-04-20 12:07:03 +02:00
NetworkManagerUtils.h core: increase NM_SHUTDOWN_TIMEOUT_MAX_MSEC to 5 sec to cover pppd 2022-02-24 09:38:53 +01:00
nm-act-request.c format: reformat source tree with clang-format 13.0 2021-11-29 09:31:09 +00:00
nm-act-request.h format: reformat source tree with clang-format 13.0 2021-11-29 09:31:09 +00:00
nm-active-connection.c format: reformat source tree with clang-format 13.0 2021-11-29 09:31:09 +00:00
nm-active-connection.h format: reformat source tree with clang-format 13.0 2021-11-29 09:31:09 +00:00
nm-audit-manager.c audit: handle error from audit_encode_nv_string() 2022-05-11 17:06:12 +02:00
nm-audit-manager.h format: reformat source tree with clang-format 13.0 2021-11-29 09:31:09 +00:00
nm-auth-manager.c format: reformat source tree with clang-format 13.0 2021-11-29 09:31:09 +00:00
nm-auth-manager.h format: reformat source tree with clang-format 13.0 2021-11-29 09:31:09 +00:00
nm-auth-utils.c format: reformat source tree with clang-format 13.0 2021-11-29 09:31:09 +00:00
nm-auth-utils.h format: reformat source tree with clang-format 13.0 2021-11-29 09:31:09 +00:00
nm-checkpoint-manager.c core: use nm_dbus_manager_lookup_object_with_type() 2022-03-13 12:02:08 +01:00
nm-checkpoint-manager.h format: reformat source tree with clang-format 13.0 2021-11-29 09:31:09 +00:00
nm-checkpoint.c settings-connection: add a "plugin" argument to Update2() 2022-03-28 13:29:28 +02:00
nm-checkpoint.h format: reformat source tree with clang-format 13.0 2021-11-29 09:31:09 +00:00
nm-config-data.c build: allow configuring default for wifi.backend setting 2022-01-04 06:41:37 +01:00
nm-config-data.h format: reformat source tree with clang-format 13.0 2021-11-29 09:31:09 +00:00
nm-config.c core: save DHCP lease information in state file in /run 2022-05-03 09:12:12 +02:00
nm-config.h core: save DHCP lease information in state file in /run 2022-05-03 09:12:12 +02:00
nm-connectivity.c connectivity: handle "NoNameServers" resolved error and don't callback to system resolver 2022-04-08 15:49:29 +02:00
nm-connectivity.h format: reformat source tree with clang-format 13.0 2021-11-29 09:31:09 +00:00
nm-core-utils.c glib-aux: drop nm_str_buf_init() for NM_STR_BUF_INIT() 2022-05-09 19:18:30 +02:00
nm-core-utils.h core: rename nm_utils_host_id_get_timestamp_ns() to "nsec" 2022-03-11 09:43:02 +01:00
nm-dbus-manager.c core: add nm_dbus_manager_lookup_object_with_type() helper 2022-03-13 12:02:07 +01:00
nm-dbus-manager.h core: add nm_dbus_manager_lookup_object_with_type() helper 2022-03-13 12:02:07 +01:00
nm-dbus-object.c format: reformat source tree with clang-format 13.0 2021-11-29 09:31:09 +00:00
nm-dbus-object.h format: reformat source tree with clang-format 13.0 2021-11-29 09:31:09 +00:00
nm-dbus-utils.c format: reformat source tree with clang-format 13.0 2021-11-29 09:31:09 +00:00
nm-dbus-utils.h format: reformat source tree with clang-format 13.0 2021-11-29 09:31:09 +00:00
nm-dcb.c format: reformat source tree with clang-format 13.0 2021-11-29 09:31:09 +00:00
nm-dcb.h format: reformat source tree with clang-format 13.0 2021-11-29 09:31:09 +00:00
nm-default-daemon.h build: move "shared/nm-{glib-aux,log-null,log-core}" to "src/libnm-{glib-aux,log-null,log-core}" 2021-02-24 12:48:20 +01:00
nm-dhcp-config.c core: add nm_dhcp_config_get_option_values() 2022-05-03 09:08:16 +02:00
nm-dhcp-config.h core: add nm_dhcp_config_get_option_values() 2022-05-03 09:08:16 +02:00
nm-dispatcher.c dispatcher: log duration of dispatcher call 2022-06-09 13:23:35 +02:00
nm-dispatcher.h format: reformat source tree with clang-format 13.0 2021-11-29 09:31:09 +00:00
nm-firewall-utils.c core: transfer ownership of strbuf data in _fw_nft_set() 2022-05-02 16:43:42 +02:00
nm-firewall-utils.h firewall: add special firewall-backend "none" 2021-05-14 11:41:33 +02:00
nm-firewalld-manager.c format: reformat source tree with clang-format 13.0 2021-11-29 09:31:09 +00:00
nm-firewalld-manager.h format: reformat source tree with clang-format 13.0 2021-11-29 09:31:09 +00:00
nm-hostname-manager.c core: fix unused variable in _write_hostname_on_idle_cb() 2022-05-30 18:46:40 +02:00
nm-hostname-manager.h core/hostname: avoid blocking calls in NMHostnameManager setting static hostname 2022-05-30 16:56:38 +02:00
nm-ip-config.c format: reformat source tree with clang-format 13.0 2021-11-29 09:31:09 +00:00
nm-ip-config.h format: reformat source tree with clang-format 13.0 2021-11-29 09:31:09 +00:00
nm-keep-alive.c format: reformat source tree with clang-format 13.0 2021-11-29 09:31:09 +00:00
nm-keep-alive.h format: reformat source tree with clang-format 13.0 2021-11-29 09:31:09 +00:00
nm-l3-config-data.c l3cfg: fix comparing "has-dns-priority" flag in nm_l3_config_data_cmp_full() 2022-06-09 08:53:34 +02:00
nm-l3-config-data.h l3cfg: drop NM_L3_CFG_COMMIT_TYPE_ASSUME and assume_config_once 2022-04-28 10:48:56 +02:00
nm-l3-ipv4ll.c l3cfg: drop NM_L3_CFG_COMMIT_TYPE_ASSUME and assume_config_once 2022-04-28 10:48:56 +02:00
nm-l3-ipv4ll.h all: move "src/" directory to "src/core/" 2021-02-08 09:56:41 +01:00
nm-l3-ipv6ll.c l3cfg: drop NM_L3_CFG_COMMIT_TYPE_ASSUME and assume_config_once 2022-04-28 10:48:56 +02:00
nm-l3-ipv6ll.h format: reformat source tree with clang-format 13.0 2021-11-29 09:31:09 +00:00
nm-l3cfg.c core: add nm_l3cfg_block_obj_pruning() 2022-06-14 12:26:21 +02:00
nm-l3cfg.h core: add nm_l3cfg_block_obj_pruning() 2022-06-14 12:26:21 +02:00
nm-manager.c core: save DHCP lease information in state file in /run 2022-05-03 09:12:12 +02:00
nm-manager.h core: add nm_manager_get_dns_manager() getter 2022-04-15 09:04:30 +02:00
nm-netns.c platform: rename "nmp-route-manager.h" to "nmp-rules-manager.h" 2022-02-09 19:13:03 +01:00
nm-netns.h platform: rename NMPRulesManager API to NMPRouteManager 2022-02-09 19:13:03 +01:00
nm-pacrunner-manager.c core: use NM_SHUTDOWN_TIMEOUT_1500_MSEC 2022-02-24 09:38:53 +01:00
nm-pacrunner-manager.h core: rework IP configuration in NetworkManager using layer 3 configuration 2021-11-18 16:21:29 +01:00
nm-policy.c core: preserve the domain when system hostname is truncated 2022-03-09 08:34:26 +01:00
nm-policy.h all: move "src/" directory to "src/core/" 2021-02-08 09:56:41 +01:00
nm-priv-helper-call.c nm-sudo: rename to nm-priv-helper 2022-01-11 21:46:55 +01:00
nm-priv-helper-call.h nm-sudo: rename to nm-priv-helper 2022-01-11 21:46:55 +01:00
nm-rfkill-manager.c core: export radio flags 2022-03-29 09:34:07 +02:00
nm-rfkill-manager.h core: export radio flags 2022-03-29 09:34:07 +02:00
nm-session-monitor.c all: prefer nm wrappers to automatically attach GSource to default context 2022-03-13 11:59:42 +01:00
nm-session-monitor.h all: move "src/" directory to "src/core/" 2021-02-08 09:56:41 +01:00
nm-sleep-monitor.c format: reformat source tree with clang-format 13.0 2021-11-29 09:31:09 +00:00
nm-sleep-monitor.h all: move "src/" directory to "src/core/" 2021-02-08 09:56:41 +01:00
nm-test-utils-core.h all: avoid using global string buffer for to-string methods 2022-04-08 15:59:49 +02:00
nm-types.h format: reformat source tree with clang-format 13.0 2021-11-29 09:31:09 +00:00
org.freedesktop.NetworkManager.conf all: move "src/" directory to "src/core/" 2021-02-08 09:56:41 +01:00
README.l3cfg.md core: rework IP configuration in NetworkManager using layer 3 configuration 2021-11-18 16:21:29 +01:00
README.md all: add some README.md files describing the purpose of our sources 2021-08-19 17:51:11 +02:00
README.next.ip-config.md core: rework IP configuration in NetworkManager using layer 3 configuration 2021-11-18 16:21:29 +01:00

core

The source code of the NetworkManager daemon.

NetworkManager is a daemon that provides a D-Bus API and a file-based API for configuring the network on a Linux host.

This is the daemon source code.