Commit graph

9281 commits

Author SHA1 Message Date
Thomas Haller
b87327a5fe ppp: cleanup logging pppd exit reason in ppp_watch_cb
- don't use assert but be more graceful with g_return_if_fail().
- in case of failure, don't log a debug message after the warning.
  One message is sufficient, drop "pppd pid %d cleaned up".
- print GPid type as long long.
- increase log level to warning. pppd dying unexpectedly warrants a
  warning.

(cherry picked from commit 250e723951)
2017-06-09 16:16:42 +02:00
Thomas Haller
38b5d356de ppp: don't log newlines
(cherry picked from commit a814b96ebf)
2017-06-09 16:16:42 +02:00
Thomas Haller
ccda61b6fc ppp: refactor ppp_exit_code() to split out error to string conversion
ppp_exit_code() does too much or too little. Either it should log
about all reasons why pppd exited, including signals, or it should
just do the status to string conversion. Split it.

(cherry picked from commit 3f64910b52)
2017-06-09 16:16:42 +02:00
Thomas Haller
105ef99cbf ppp/trivial: fix whitespace
(cherry picked from commit 5c5fbe0a9f)
2017-06-09 16:16:42 +02:00
Thomas Haller
620adbcc7b ppp: inline and drop trivial function remove_timeout_handler()
(cherry picked from commit 0f16649ba2)
2017-06-09 16:16:42 +02:00
Thomas Haller
5e656b5872 ppp: unexport NMPPPManager instance on dispose()
Let's explicitly unexports on dispose(). Probably that already
happened, because NMExportedObject asserts that it is unexported
during !quitting.

During quitting, we probably don't tear down the manager.

Anyway, we should always unexport.

(cherry picked from commit f07dca941d)
2017-06-09 16:16:39 +02:00
Thomas Haller
2aa4239cba ppp: cast int argument for variadic g_signal_emit(NM_PPP_MANAGER_STATE_CHANGE) call
(cherry picked from commit 7b5251b35c)
2017-06-09 16:16:39 +02:00
Beniamino Galvani
6a4774b1a8 device: apply route metric penality only when the default route exists
It's useless (and in some cases also harmful) to commit the
configuration to update the default route metric when the device has
no default route. Also, don't commit configuration for externally
activated devices.

https://bugzilla.redhat.com/show_bug.cgi?id=1459604
(cherry picked from commit aa099906f9)
2017-06-09 13:54:04 +02:00
Thomas Haller
78ff06c539 device: suppress logging and return error reason from nm_device_generate_connection()
Don't log in a function that basically just inspects state, without
mutating it. Instead, pass the reason why a connection could not be
generated to the caller so that we have one sensible log message.

(cherry picked from commit 0c26ffd638)
2017-06-08 22:02:13 +02:00
Thomas Haller
70b4684d7e manager: cleanup logging message during recheck_assume_connection()/get_existing_connection()
recheck_assume_connection() calls get_existing_connection(). We want *one* logging
message telling what's happening. Let get_existing_connection() log "assume:"
messages and remove duplicate messages from recheck_assume_connection().

(cherry picked from commit 962f8f42d9)
2017-06-08 22:01:19 +02:00
Thomas Haller
c254277f40 device: remove logging for emitting RECHECK_ASSUME signal
The device's RECHECK_ASSUME signal has only NMManager as subscriber
and it immediately calls recheck_assume_connection().

With the previous commit, recheck_assume_connection() always logs
a debug message, so we don't need this duplicate message anymore.

(cherry picked from commit cc47a6a8b2)
2017-06-08 22:01:19 +02:00
Thomas Haller
7e2d64a8b2 manager: add more logging to recheck_assume_connection()
and give all lines a logging prefix.

(cherry picked from commit 94534e0327)
2017-06-08 22:01:19 +02:00
Thomas Haller
01fd9df6e5 manager: add "rfkill" prefix to related logging messages
(cherry picked from commit dd53c879d2)
2017-06-08 22:01:19 +02:00
Thomas Haller
36b99ccf5f manager: add logging macro _NMLOG3() for logging connection messages
It unifies the way how we print the logging prefix, but also it
passes the con_uuid down for structured logging.

(cherry picked from commit 6962f14d4a)
2017-06-08 22:01:19 +02:00
Thomas Haller
22bf75162d manager: add logging macro _NMLOG2() for logging device messages
It unifies the way how we print the logging prefix, but also it
passes the ifname down for structured logging.

(cherry picked from commit 1f6078bcf5)
2017-06-08 22:01:19 +02:00
Thomas Haller
c5812a5fb9 logging: add LOG3 macros
(cherry picked from commit 2ae891b592)
2017-06-08 22:01:19 +02:00
Thomas Haller
e0b7a44062 device: expose nm_device_state_to_str() function for NMDeviceState
(cherry picked from commit 4b15df2656)
2017-06-08 22:01:16 +02:00
Thomas Haller
60ce882419 device: rework device's _NMLOG() logging macro
- if the interface-name is NULL, print [null], to distinguish
  it from (ifname).
- evaluate the ifname only once.

(cherry picked from commit f10b958806)
2017-06-08 22:00:56 +02:00
Thomas Haller
06db38b91d manager: fix preserving assume state during activation
Originally 850c977 "device: track system interface state in NMDevice",
intended that a connection can only be assumed initially when seeing
a device for the first time. Assuming a connection later was to be
prevented by setting device's sys-iface-state to MANAGED.

That changed too much in behavior, because we used to assume external
connections also when they are activated later on. So this was attempted
to get fixed by
  - acf1067 nm-manager: try assuming connections on managed devices
  - b6b7d90 manager: avoid generating in memory connections during startup for managed devices

It's probably just wrong to prevent assuming connections based on the
sys-iface-state. So drop the check for sys-iface-state from
recheck_assume_connection(). Now, we can assume anytime on managed,
disconnected interfaces, like previously.
Btw, note that priv->startup is totally wrong to check there, because
priv->startup has the sole purpose of tracking startup-complete property.
Startup, as far as NMManager is concerned, is platform_query_devices().

However, the problem is that we only assume connections (contrary to
doing external activation) when we have a connection-uuid from the state
file or with guess-assume during startup.

When assuming a master device, it can fail with

  (nm-bond): ignoring generated connection (IPv6LL-only and not in master-slave relationship)

thus, for internal reason the device cannot be assumed yet.

Fix that by attatching the assume-state to the device, so that on multiple
recheck_assume_connection() calls we still try to assume. Whenever we try
to assume the connection and it fails due to external reasons (like, the connection
no longer matching), we clear the assume state, so that we only try as
long as there are internal reasons why assuming fails.

https://bugzilla.redhat.com/show_bug.cgi?id=1452062
(cherry picked from commit 729de7d7f0)
2017-06-08 22:00:56 +02:00
Thomas Haller
122be86c58 core: allow assuming connections on "nm-owned" software devices
Especially now we load the nm-owned flag from run-state. We very much want to
assume connections on such devices.

(cherry picked from commit 6a7b51f79b)
2017-06-08 22:00:56 +02:00
Thomas Haller
8e25de8ab3 device: only set nm-owned from statefile during initial setup
The state file should only be read initially when NM starts, that is:
during NMManager's platform_query_devices().

At all later points, for example when a software device gets destroyed
and re-realized, the state file is clearly no longer relevant.

Hence, pass the set-nm-owned flag from NMManager to realize_start_setup().

This is very much the same as with the NM_UNMANAGED_FLAG_USER_EXPLICT flag,
which we also read from the state-file.

(cherry picked from commit d83848be9d)
2017-06-08 22:00:56 +02:00
Beniamino Galvani
333ed6ee2a manager: restore the previous persistent nm-owned state of devices
After a daemon restart, any software device is considered !nm-owned,
even if it was created by NM. Therefore, a device stays around even if
the connection which created it gets deactivated or deleted.

Fix this by remembering the previous nm-owned state in the device
state file.

https://bugzilla.redhat.com/show_bug.cgi?id=1376199
(cherry picked from commit cf9ba271e6)
2017-06-08 21:57:36 +02:00
Beniamino Galvani
a42f3b92b7 config: allow persisting the device nm-owned state
(cherry picked from commit 3fbbbb62f0)
2017-06-08 21:57:36 +02:00
Beniamino Galvani
84273a3516 device: rename priv->is_nm_owned to priv->nm_owned
Only a matter of taste, but nm_device_get_is_nm_owned() sounds
strange.

(cherry picked from commit 8cce037bf8)
2017-06-08 21:57:36 +02:00
Beniamino Galvani
dc1c8c22cc device: check connectivity on the IP interface
curl must bind to the interface that has IP configuration, not the
underlying device. Without this commit, connectivity check fails on
certain connection types (PPPoE, WWAN).

Fixes: 9d43869e47
(cherry picked from commit c66995ad4d)
2017-06-08 11:23:07 +02:00
Beniamino Galvani
a3a792dd22 bond: check for NULL bond mode value in update_connection()
Don't crash if the bond mode can't be read from sysfs - for example
when the interface disappears. The generated connection will be bogus,
but at that point it doesn't matter because the in-memory connection
will be destroyed.

Fixes: 056a973a4f

https://bugzilla.redhat.com/show_bug.cgi?id=1459580
(cherry picked from commit 5600a27c2a)
2017-06-08 09:45:50 +02:00
Thomas Haller
fcbcd1aa87 device: mark device as sys-iface-state=external when assuming connection
Since commit 74dac5f (nm-manager: try assuming connections on managed devices),
and commit f4226e7 (manager: avoid generating in memory connections
during startup for managed devices), recheck_assume_connection() also
assumes connections on devices that are currently not in sys-iface-state
"external".

That is correct, as also for fully managed devices (which are currently
in disconnected state), we want to assume external connections. However,
when doing that, we must reset the sys-iface-state to external.

https://bugzilla.redhat.com/show_bug.cgi?id=1457242
(cherry picked from commit 02e7476e9f)
2017-06-05 18:31:31 +02:00
Beniamino Galvani
61817661c8 bond: add only supported options to the generated connection
Upstream commit [1] changed in the kernel the default value of
tlb_dynamic_lb bond from 1 to 0 when the mode is not tlb. This is not
wrong, as the option value doesn't really matter for other modes, but
it breaks the connection matching because we read back a 0 value when
we expect a default of 1.

Fix this in a generic way by ignoring altogether options that are not
relevant for the current bond mode, because they are removed from the
connection during normalization.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=8b426dc54cf4056984bab7dfa48c92ee79a46434

https://bugzilla.redhat.com/show_bug.cgi?id=1457909
(cherry picked from commit 056a973a4f)
2017-06-05 17:54:11 +02:00
Thomas Haller
fb9411ff76 settings: refactor nm_settings_connection_read_and_fill_timestamp()
Coverity complains about not checking the return value:

  src/settings/nm-settings-connection.c:2329: check_return: Calling "g_key_file_load_from_file" without checking return value (as is done elsewhere 6 out of 7 times).

While at it, refactor the code and check whether the timestamp
is valid.

(cherry picked from commit 238efbbb12)
2017-06-02 20:21:11 +02:00
Thomas Haller
cd8f3cf09f tests: work around coverity false-positives
(cherry picked from commit c7c47575ce)
2017-06-02 20:21:11 +02:00
Thomas Haller
38fbdc8118 supplicant: work-around coverify false-positive for check_return: g_async_initable_init_finish()
NetworkManager-1.8.0/src/supplicant/nm-supplicant-interface.c:232: check_return: Calling "g_async_initable_init_finish" without checking return value (as is done elsewhere 7 out of 8 times).

(cherry picked from commit 6f1ea8b8ee)
2017-06-02 20:21:11 +02:00
Thomas Haller
2574393f08 supplicant/tests: work-around coverify false-positive in test
NetworkManager-1.8.0/src/supplicant/tests/test-supplicant-config.c:528: check_return: Calling "nm_setting_802_1x_set_ca_cert" without checking return value (as is done elsewhere 13 out of 16 times).

(cherry picked from commit 7087956870)
2017-06-02 20:21:11 +02:00
Thomas Haller
e984d9eb36 connectivity: fix scheduling periodic connectivity checks
commit a955639 (connectivity: don't do periodic checks on interval=0)
broke scheduling connectivity checks.

That is because the timer is on only scheduled if
nm_connectivity_check_enabled(), which in turn only returns TRUE
if curl_mhandle is set. However, nm_connectivity_init() would only
initialize curl_mhandle after update_config(), missing to schedule
the periodic task.

https://mail.gnome.org/archives/networkmanager-list/2017-May/msg00076.html

Fixes: a95563996f
(cherry picked from commit f1eb1619f1)
2017-06-02 19:42:44 +02:00
Francesco Giudici
1618717170 connectivity: fix typo in error message
(cherry picked from commit 7a2c31a54a)
2017-06-02 19:42:40 +02:00
Thomas Haller
92a277dc6f ifcfg-rh: fix preserving NETMASK key in write_ip4_setting()
To support legacy scripts, we want to write out the NETMASK
key whenever the ifcfg file has a NETMASK key previously.
Note, that we anyway always write the relevant PREFIX key.
The NETMASK is redundant, only there to help legacy scripts.

That was broken, because we would svUnsetValue("NETMASK") before
checking whether the NETMASK key is present.

Also, when saving a connection to ifcfg-rh file that was created
by other tools, we might mix up the numbering. E.g. we never
write out IPADDR0. Hence, turn on legacy mode whenever the ifcfg-rh
file has any key starting with "NETMASK".

(cherry picked from commit 844bf3d1a2)
2017-05-30 13:44:04 +02:00
Thomas Haller
7ebc132864 ifcfg-rh/tests: add test for reading NETMASK property
(cherry picked from commit ba05819c89)
2017-05-30 11:20:23 +02:00
Thomas Haller
3dfddc18a5 ifcfg-rh: add svFindFirstKeyWithPrefix() function
During backporting manually patched to use GList instead of CList.

(cherry picked from commit e9d960740a)
2017-05-30 11:17:44 +02:00
Thomas Haller
2bf3d590ce ifcfg-rh: fix writing NETMASK in write_ip4_setting()
(cherry picked from commit efd462d946)
2017-05-30 11:12:35 +02:00
Francesco Giudici
2c0865db25 device: when setting back a device to managed, update internal sys state
Otherwise a device which was set as unmanaged (updated to the REMOVED
internal sys-state) will never update its own sys-state if later set
back as managed.
Manage either when setting explictly the device to managed either when
just upping a connection on an unmanaged device.

(cherry picked from commit adbf383628)
2017-05-26 16:10:26 +02:00
Francesco Giudici
3c7c273836 device: add the internal interface state to the state change log message
(cherry picked from commit 55b8ba4ddc)
2017-05-26 16:10:18 +02:00
Beniamino Galvani
3fefef8594 core: add configuration flag to choose slaves activation order
Commits 39d0559d9a ("platform: sort links by name instead of
ifindex") and 529a0a1a7f ("manager: sort slaves to be autoconnected
by device name") changed the order of activation of slaves. Introduce
a system-wide configuration property to preserve the old behavior.

https://bugzilla.redhat.com/show_bug.cgi?id=1452585
(cherry picked from commit 31656a066b)
2017-05-24 15:59:58 +02:00
Beniamino Galvani
6110b11235 device: release removed devices from master on cleanup
On cleanup, unconditionally release a device from its master if the
link is missing or it doesn't have a master, otherwise the master
would later try to release the slave, hitting the following assertion:

 "nm_platform_link_release: assertion 'slave > 0' failed"
  #0  g_logv
  #1  g_log
  #2  g_return_if_fail_warning
  #3  nm_platform_link_release
  #4  release_slave
  #5  nm_device_master_release_one_slave
  #6  slave_state_changed
  #7  ffi_call_unix64
  #8  ffi_call
  #9  g_cclosure_marshal_generic
  #10 g_closure_invoke
  #11 signal_emit_unlocked_R
  #12 g_signal_emit_valist
  #14 _set_state_full
  #15 nm_device_state_changed
  #16 nm_device_unrealize
  #17 _platform_link_cb_idle
  #18 g_main_context_dispatch
  #19 g_main_context_dispatch
  #20 g_main_context_iterate
  #21 g_main_loop_run
  #22 main

Fixes: 9e8218f99a

https://bugzilla.redhat.com/show_bug.cgi?id=1448907
(cherry picked from commit 3355a2823b)
2017-05-24 13:44:46 +02:00
Lubomir Rintel
7851f1c595 bluetooth: unhook adapter properties callback when the adapter vanishes
https://bugzilla.redhat.com/show_bug.cgi?id=1454654
(cherry picked from commit 0aa2e0bad3)
2017-05-23 11:39:21 +02:00
Lubomir Rintel
390cfec792 device: capture the IP6 configuration on the IP interface
Fixes a crash with Bluetooth devices where the device is the BlueZ
device and iface stays 0 while the IP interface is the actual BNEP link.

https://bugzilla.gnome.org/show_bug.cgi?id=782545
(cherry picked from commit 30d06b2253)
2017-05-22 17:14:43 +02:00
Beniamino Galvani
4b6955095b device: fix capture of device config in ipX_config_merge_and_apply()
Use nm_device_get_ip_ifindex() to obtain the right ifindex for the
device. Fixes the following:

 nm_platform_ip4_address_get_all: assertion 'ifindex > 0' failed
 #0  _g_log_abort () from target:/lib64/libglib-2.0.so.0
 #1  g_logv () from target:/lib64/libglib-2.0.so.0
 #2  g_log () from target:/lib64/libglib-2.0.so.0
 #3  nm_platform_ip4_address_get_all (self=self@entry=0x1181020, ifindex=ifindex@entry=0) at src/platform/nm-platform.c:2640
 #4  nm_ip4_config_capture (platform=0x1181020, ifindex=ifindex@entry=0, capture_resolv_conf=capture_resolv_conf@entry=0) at src/nm-ip4-config.c:271
 #5  ip4_config_merge_and_apply (self=self@entry=0x1254a70, config=config@entry=0x0, commit=commit@entry=1) at src/devices/nm-device.c:5447
 #6  activate_stage5_ip4_config_commit (self=0x1254a70) at src/devices/nm-device.c:8299
 #7  activation_source_handle_cb (self=0x1254a70, family=family@entry=2) at src/devices/nm-device.c:4421
 #8  activation_source_handle_cb4 (user_data=<optimized out>) at src/devices/nm-device.c:4358
 #9  g_idle_dispatch () from target:/lib64/libglib-2.0.so.0
 #10 g_main_context_dispatch () from target:/lib64/libglib-2.0.so.0
 #11 g_main_context_iterate.isra () from target:/lib64/libglib-2.0.so.0
 #12 g_main_loop_run () from target:/lib64/libglib-2.0.so.0
 #13  main (argc=<optimized out>, argv=<optimized out>) at src/main.c:435

Fixes: a21b8882cc
(cherry picked from commit 6389d637a7)
2017-05-21 15:59:25 +02:00
Beniamino Galvani
cb5ba08f00 ifcfg-rh: omit empty next hop for routes in legacy format
Don't add "via (null)" if the next hop is missing.

https://bugzilla.redhat.com/show_bug.cgi?id=1452648
(cherry picked from commit af8aac9b54)
2017-05-19 17:45:46 +02:00
Thomas Haller
3a96772918 device: sanitze UTF-8 values for D-Bus
ip link add name $'d\xccf\\c' type dummy

Use nm_utils_str_utf8safe_escape() to sanitize non UTF-8 sequences
before exposing them on D-Bus. The operation can be reverted client
side via nm_utils_str_utf8safe_unescape() or simply g_strcompress().

Note that this preserves all valid UTF-8 sequences as-is, with exception
of the backslash escape character and ASCII control characters. Thus, this
is a change in behavior for strings that contain such characters.

Note that nmcli is not changed to somehow unescape the string before
printing. As the string is not valid UTF-8 (or contains ASCII characters
that need escaping), they are not printable as-is, so unescaping before
printing makes little sense.

(cherry picked from commit 0870906540)
2017-05-19 10:07:14 +02:00
Thomas Haller
c3b180198f device: make UDI property construct-only
(cherry picked from commit e216d5eac0)
2017-05-19 10:07:14 +02:00
Thomas Haller
4ae14d3677 device: fix setting device's UDI property
Fixes: e8139f56c2
(cherry picked from commit 5eac18b58d)
2017-05-19 10:07:14 +02:00
Beniamino Galvani
bf28e0845f device: fix crash in ip6_config_merge_and_apply()
nm_ip6_config_capture() returns NULL for slaves. Fixes the following:

 nm_ip6_config_new_cloned: assertion 'NM_IS_IP6_CONFIG (src)' failed

 #0 g_logv () at /lib64/libglib-2.0.so.0
 #1 g_log () at /lib64/libglib-2.0.so.0
 #2 nm_ip6_config_new_cloned (src=0x0) at src/nm-ip6-config.c:2272
 #3 ip6_config_merge_and_apply (self=self@entry=0x200d8f0, commit=commit@entry=1) at src/devices/nm-device.c:6192
 #4 nm_device_bring_up (self=self@entry=0x200d8f0, block=block@entry=1, no_firmware=no_firmware@entry=0x0) at src/devices/nm-device.c:10369
 #5 _hw_addr_set (self=self@entry=0x200d8f0, addr=addr@entry=0x2095ea0 "6A:1C:00:2A:68:7C", operation=operation@entry=0x64f8ba "set", detail=detail@entry=0x67369d "restore") at src/devices/nm-device.c:13225
 #6 nm_device_hw_addr_set (self=self@entry=0x200d8f0, addr=addr@entry=0x2095ea0 "6A:1C:00:2A:68:7C", detail=detail@entry=0x67369d "restore", set_permanent=set_permanent@entry=0) at src/devices/nm-device.c:13255
 #7 release_slave (device=0x200d8f0, slave=0x1ef2990, configure=<optimized out>) at src/devices/nm-device-bond.c:463
 #8 nm_device_master_release_one_slave (self=self@entry=0x200d8f0, slave=slave@entry=0x1ef2990, configure=1, reason=reason@entry=NM_DEVICE_STATE_REASON_CONNECTION_REMOVED) at src/devices/nm-device.c:2041
 #9 slave_state_changed (slave=0x1ef2990, slave_new_state=NM_DEVICE_STATE_DEACTIVATING, slave_old_state=NM_DEVICE_STATE_ACTIVATED, reason=NM_DEVICE_STATE_REASON_CONNECTION_REMOVED, self=0x200d8f0)
     at src/devices/nm-device.c:3366
 ...

Fixes: a21b8882cc
(cherry picked from commit 1e78f50b8e)
2017-05-17 09:52:53 +02:00