Commit graph

17526 commits

Author SHA1 Message Date
Beniamino Galvani
2e181f9c4d cli: fix failed assertion in readline helper
The INT signal can arrive after a new line has been processed in
nmc_readline_helper(). In such case, the handler gets uninstalled by
readline_cb() and nmc_seen_sigint() returns TRUE. However it's an
error to call rl_callback_read_char() without handler, don't do it.

Fixes the following:
 "readline: readline_callback_read_char() called with no handler!"
 #0 __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
 #1 __GI_abort () at abort.c:90
 #2 rl_callback_read_char () at ../callback.c:116
 #3 nmc_readline_helper (prompt=prompt@entry=0x2aa0d229080 "nmcli> ") at clients/cli/common.c:1387
 #4 nmc_readline (prompt_fmt=prompt_fmt@entry=0x2aa0036ac9e "%s") at clients/cli/common.c:1448
 #5 do_connection_edit (connection=0x2aa0d215440, nmc=0x2aa00391298 <nm_cli>) at clients/cli/connections.c:7072

Fixes: 995229181c

https://bugzilla.redhat.com/show_bug.cgi?id=1458311
(cherry picked from commit cd3a561251)
2017-06-15 10:05:57 +02:00
Beniamino Galvani
9819ffe7d4 core: sort addresses in captured IPv4 configuration
When IPv4 addresses are synchronized to platform, the order of IPv4
addresses matters because the first address is considered the primary
one. Thus, nm_ip4_config_capture() should put the primary address as
first, otherwise during synchronization addresses will be removed and
added back with a different primary/secondary role.

https://bugzilla.redhat.com/show_bug.cgi?id=1459813
(cherry picked from commit b6fa87a4c0)
2017-06-13 23:36:07 +02:00
Thomas Haller
588841f2e0 device: don't set MTU of device unless explicitly configured
Since commit 2b51d3967 "device: merge branch 'th/device-mtu-bgo777251'",
we always set the MTU for certain device types during activation. Even
if the MTU is neither specified via the connection nor other means, like
DHCP.

Revert that change. On activation, if nothing explicitly configures the
MTU, leave it unchanged. This is like what we do with ethernet's
cloned-mac-address, which has a default value "preserve".
So, as last resort the default value for MTU is now 0 (don't change),
instead of depending on the device type.

Note that you also can override the default value in global
configuration via NetworkManager.conf.

This behavior makes sense, because whenever NM actively resets the MTU,
it remembers the previous value and restores it when deactivating
the connection. That wasn't implemented before 2b51d3967, and the
MTU would depend on which connection was previously active. That
is no longer an issue as the MTU gets reset when deactivating.

https://bugzilla.redhat.com/show_bug.cgi?id=1460760
(cherry picked from commit 4ca3002b86)
2017-06-13 15:27:21 +02:00
Beniamino Galvani
73e664e3b1 cli: remove spurious device names from output
When running one of:

 nmcli device wifi list ifname wlan0
 nmcli device wifi connect ... ifname wlan0

nmcli wrongly adds the device name to the output.

Do the completion only when requested.

Fixes: 8679793f6b
Fixes: 1a0dfd31c4
(cherry picked from commit d2b4332b36)
2017-06-11 22:43:50 +02:00
Thomas Haller
3cca3b50e2 ppp: merge branch 'th/ppp-cleanup'
(cherry picked from commit 17e7054d73)
2017-06-09 16:17:05 +02:00
Thomas Haller
1b954fe09b ppp: fix cancelling timeout when pppd process exits
Otherwise, we get pppd_timed_out() later, which will
emit a DEAD state change at unexpected times.

(cherry picked from commit b9af32b056)
2017-06-09 16:16:42 +02:00
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
Thomas Haller
31aa178920 cli: fix output of iface in overview output (rh#1460219)
https://bugzilla.redhat.com/show_bug.cgi?id=1460219

(cherry picked from commit 58c8140acb)
2017-06-09 15:37:59 +02:00
Thomas Haller
c9c0a13829 cli: minor refactoring of if-condition in device_overview
Note that nm_device_get_ip_iface() never returns an emptry string "".

(cherry picked from commit ee5fdcbfb5)
2017-06-09 15:37:29 +02:00
Thomas Haller
be4e1000e8 cli: fix output of iface in overview output
Fixes: f14845cc20

https://bugzilla.redhat.com/show_bug.cgi?id=1460219
(cherry picked from commit 126b0874f1)
2017-06-09 15:37:25 +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
da94f8a939 core: merge branch 'th/assume-master-rh1452062'
https://bugzilla.redhat.com/show_bug.cgi?id=1452062

(cherry picked from commit 5b55c01848)
2017-06-08 22:02:44 +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
de1c460e58 core: merge branch 'bg/nm-owned-persist-rh1376199'
https://bugzilla.redhat.com/show_bug.cgi?id=1376199

(cherry picked from commit 3223d92eea)
2017-06-08 21:57: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
Beniamino Galvani
58e4257e22 libnm-core: fix typo in 802.1x doc comment
(cherry picked from commit 7415ad778e)
2017-06-06 09:29:45 +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
3edfb6ac24 bond: merge branch 'bg/bond-option-normalize-rh1457909'
Normalize bond options to ensure a correct connection matching upon
daemon restart.

https://bugzilla.redhat.com/show_bug.cgi?id=1457909
(cherry picked from commit 4be0cdd358)
2017-06-05 17:55:01 +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
Beniamino Galvani
ac7a5c074c libnm-core: remove unsupported bond options during normalization
In an ideal world, we should not validate connections containing
options not valid for the current bond mode. However adding such
restriction now means that during an upgrade to the new NM version
some connections that were valid before become invalid, possibly
disrupting connectivity.

Instead, consider invalid options as a normalizable error and remove
them during normalization.

Converting the setting to a "canonical" form without invalid options
is important for the connection matching logic, where such invalid
options can cause false mismatches.

(cherry picked from commit f25e008e2f)
2017-06-05 17:54:09 +02:00
Lubomir Rintel
1dc440e13e build: add a missing test artifact to dist
Fixes: ba05819c89
(cherry picked from commit afebdc795d)
2017-06-05 15:16:56 +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
8db2ca661f libnm: fix rejecting NMSettingVlan with id >= 4095
Without it, clients can wrongly create VLan settings with
ID 4095, which triggers assertions in NetworkManager.

Fixes: 8715d61437
(cherry picked from commit 159cd4836f)
2017-05-30 18:17:08 +02:00