Commit graph

17518 commits

Author SHA1 Message Date
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
Thomas Haller
b2ab1f4b61 tui: use nm_streq0() in nmt_connect_connection_list_get_connection()
(cherry picked from commit 3443f25001)
2017-05-30 14:46:54 +02:00
Arnaud Lefebvre
cc36b9f6eb nmtui connect: avoid segfault when iface is not found
https://github.com/NetworkManager/NetworkManager/pull/21
(cherry picked from commit 1fcbb69ae2)
2017-05-30 14:46:53 +02:00
Thomas Haller
47ebca23e3 ifcfg-rh: merge branch 'th/ifcfg-netmask-legacy-rh1445414' (partial backport)
https://bugzilla.redhat.com/show_bug.cgi?id=1445414

(cherry picked from commit 70c0f7965d)
2017-05-30 13:44:56 +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
85aa450e94 build: sort filenames in Makefile.am alphabetically
(cherry picked from commit 371b761680)
2017-05-30 11:20:09 +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