Commit graph

17537 commits

Author SHA1 Message Date
Thomas Haller
24f4caebec dns: don't clone DNS configs list for nm_dns_plugin_update()
No need to clone the list anymore. Unfortunately, GPtrArray is not NULL
terminated (without extra effort), so we have to pass on the GPtrArray
instance for the length.

(cherry picked from commit 19a98c6f61)
2017-06-19 15:15:49 +02:00
Thomas Haller
4c81a447cc dns: fix negative ipv4.dns-priority for systemd-resolved
A negative ipv4.dns-priority and ipv6.dns-priority has the meaning to configure
the DNS information of the connection exclusively. With systemd-resolved, that means
we must explicitly unset the configuration from other interfaces.

https://bugzilla.gnome.org/show_bug.cgi?id=783569
(cherry picked from commit 70792e51d9)
2017-06-19 15:15:49 +02:00
Thomas Haller
6ac67655be dns: make configs argument to update a const pointer
(cherry picked from commit d582176939)
2017-06-19 15:15:49 +02:00
Thomas Haller
08d8b38a81 dns/systemd: remove unused device lookup in add_interface_configuration()
(cherry picked from commit 1c9285b06e)
2017-06-19 15:15:49 +02:00
Thomas Haller
8887970713 dns: add helper method to get DNS priority from NMDnsIPConfigData
(cherry picked from commit c818e46d48)
2017-06-19 15:15:49 +02:00
Thomas Haller
c464e111a4 dns: minor refactoring in _collect_resolv_conf_data()
The code was correct previously, but it was confusing to me,
because

  - once @skip gets set to TRUE, it stays TRUE for the rest
    of the loop.
  - in each additional skipped iteration, it would still set
    plugin_confs[i] to NULL. Which is not wrong, but confusing.
  - it would set "prev_prio = prio;" in each iteration.
    After @skip is set to TRUE, that doesn't matter anymore,
    but is confusing. Before @skip is set to TRUE it also
    doesn't really matter to set it more then once, because
    we only care about the very first priority.
  - @skip sounded to me like the current iteration would
    be skipped. But really all remaining will be skipped too.

(cherry picked from commit aa347182bb)
2017-06-19 15:15:49 +02:00
Thomas Haller
b54a4cb0d6 device: merge branch 'th/device-reapply-external-rh1462223'
https://bugzilla.redhat.com/show_bug.cgi?id=1462223

(cherry picked from commit f71195b102)
2017-06-19 15:03:16 +02:00
Thomas Haller
368c7329f8 device: fix taking over device after modifying external connection
For externally managed interfaces, we create an in-memory connection
and keep the device with sys-iface-state=external.

When the user actively modifies the connection, we persist it to
storage. But we also must take over managing the device.

One problem is that nm_device_reapply() errors out if the device
is still activating. It's unclear how to reapply the connection
while the device is in the process of activation. So, if the user
modifies the created connection very quickly, reapplying the settings
will fail.

https://bugzilla.redhat.com/show_bug.cgi?id=1462223
(cherry picked from commit 10c0632df0)
2017-06-19 15:02:11 +02:00
Thomas Haller
08c58c759a core: fix registering notify-flags hook in NMActiveConnection
We react on changes to NMSettingsConnection.flags, so that we can update
from an external activation to a managed one.

However, previously we would only register the _settings_connection_notify_flags
callback during _set_settings_connection(). So, if via constructor properties
we first set PROP_SETTINGS_CONNECTION and later PROP_ACTIVATION_TYPE, we wouldn't
register the callback.

(cherry picked from commit b84da25713)
2017-06-19 15:02:11 +02:00
Thomas Haller
653ba8b759 core: log changes to NMSettingsConnection's flags
(cherry picked from commit 2656ba8d1d)
2017-06-19 15:02:11 +02:00
Thomas Haller
98d50a72be build: fix race creating "libnm-core/tests" directory for "nm-core-tests-enum-types.c"
https://bugzilla.gnome.org/show_bug.cgi?id=783783
(cherry picked from commit b55fba8fbd)
2017-06-15 12:54:20 +02:00
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