Commit graph

21409 commits

Author SHA1 Message Date
Beniamino Galvani
89caba77cb dhcp: merge branch 'bg/dhcp-failed-rh1625901'
https://github.com/NetworkManager/NetworkManager/pull/217
2018-10-15 15:04:23 +02:00
Beniamino Galvani
567e277e64 dhcp: don't start grace period if the client is not running
We shouldn't start a grace period when the client is not running.
2018-10-15 14:05:23 +02:00
Beniamino Galvani
0a25b90813 dhcp: introduce terminated dhcp-state
When the client terminates, we really don't care if it exited cleanly,
with an error or killed by a signal. We expect the client to never
exit and so all these situations are equally bad for us. Introduce a
new TERMINATED state instead of reusing existing FAIL or DONE states,
which are set when receiving particular events from the client.
2018-10-15 14:05:23 +02:00
Beniamino Galvani
81aa1a3bb3 dhcp: reset @was_active on cleanup
The @was_active flag indicates that we started DHCP on an assumed
connection. The idea is that if DHCP succeeded before, any failure
must be treated like a renewal failure (and so it should start a grace
period) rather than a failure in getting an initial lease (which fails
the IP method).

When we clean up the DHCP instance, the flag must be reset to FALSE,
otherwise it will be potentially considered for other connections.
2018-10-15 14:05:23 +02:00
Beniamino Galvani
54064144d4 dhcp: log whether the client was active
It is useful to understand why the grace period was started.
2018-10-15 14:05:23 +02:00
Beniamino Galvani
37274a16a1 dhcp6: fix handling of failure events
The effect of a DHCPv6 failure should depend only on current IP state.
This in the analogous of commit bd63d39252 ("dhcp: fix handling of
failure events") for IPv6.
2018-10-15 14:05:23 +02:00
Thomas Haller
3baa016f89 ndisc: merge branch 'th/ndisc-addr-lifetime'
https://github.com/NetworkManager/NetworkManager/pull/228

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/57
https://bugs.launchpad.net/ubuntu/+source/network-manager/+bug/1796622
2018-10-13 17:12:38 +02:00
Thomas Haller
8c6629b356 ndisc: don't update dad_counter for addresses in router config
I am not sure, we ever call complete_address() for router-configurations.
Maybe not, so the dad-counter is never incremented and does not matter either.

If we however do, then we certainly want to preserve the DAD counter
when the address is already tracked.
2018-10-13 17:11:52 +02:00
Thomas Haller
27be3e0338 ndisc: fix updating address lifetime on Router Announcement according to RFC4862
This is a denial-of-service protection, where a malicious router
advertisement can expire the addresses.

See-also: 6554550f35
See-also: https://tools.ietf.org/search/rfc4862#section-5.5.3

https://bugs.launchpad.net/ubuntu/+source/network-manager/+bug/1796622
2018-10-13 17:11:52 +02:00
Thomas Haller
b086535cb7 ndisc: handle integer overflows better for lifetime handling
we use get_expiry() to compare two lifetimes. Note, that previously,
it would correctly truncate the calculated expiry at G_MAXINT32-1.

However, that means, that two different lifetimes that both lie
more than 68 years in the future would compare equal.

Fix that, but extending the range to int64, so that no overflow
can happen.
2018-10-13 17:11:52 +02:00
Thomas Haller
9d0a138ef0 ndisc: minor refactoring loop in nm_ndisc_add_address()
No change in behavior. Just don't do so much work inside
the deeper nesting of the loop.
2018-10-13 17:11:52 +02:00
Thomas Haller
23c417854a ndisc: only generate address interface identifer after checking existing prefix
RFC4862 5.5.3, points d) and e) make it clear, that the list of
addresses should be compared based on the prefix.

  d)  If the prefix advertised is not equal to the prefix of an
    address configured by stateless autoconfiguration already in the
    list of addresses associated with the interface (where "equal"
    means the two prefix lengths are the same and the first prefix-
    length bits of the prefixes are identical), and if the Valid
    Lifetime is not 0, form an address (and add it to the list) by
    combining the advertised prefix with an interface identifier of
    the link as follows:

That means, we should not initialize the interface identifier first
(via complete_address()) and then search for the full address.

See-also: https://tools.ietf.org/search/rfc4862#section-5.5.3
2018-10-13 17:11:52 +02:00
Thomas Haller
700b04d0de ndisc: ensure we skip unspecified IPv6 address in ndisc_set_router_config()
Later, nm_ndisc_add_address() asserts that the address is not an
unspecified address. Skip it, just to be sure.
2018-10-13 17:11:52 +02:00
Thomas Haller
43c3c259c8 ndisc: ignore addresses with preferred lifetime larger than lifetime
Previously, we would coerce the value so that preferred is the same
as lifetime. However, RFC4862 5.5.3.c) says:

  c)  If the preferred lifetime is greater than the valid lifetime,
    silently ignore the Prefix Information option.  A node MAY wish to
    log a system management error in this case.

See-also: https://tools.ietf.org/search/rfc4862#section-5.5.3
2018-10-13 17:11:52 +02:00
Lubomir Rintel
02958bba80 all: remove \n endings from log calls
The extra newlines look bad when logging to the console.

https://github.com/NetworkManager/NetworkManager/pull/223
2018-10-12 14:34:58 +02:00
Lubomir Rintel
08225c5e96 devices/olpc: don't assert we're waiting for companion on device_added_cb()
We're hooking the signal on construction, but we only queue a pending
action on reaching UNAVAILABLE state. The signal could fire in between:

  <info>  [1539282167.9666] manager: (msh0): new 802.11 OLPC Mesh device (/org/freedesktop/NetworkManager/Devices/4)
  <info>  [1539282168.1440] manager: (wlan0): new 802.11 WiFi device (/org/freedesktop/NetworkManager/Devices/5)
  <info>  [1539282168.1831] device (msh0): found companion WiFi device wlan0
  <warn>  [1539282168.2110] device (msh0): remove_pending_action (1): 'waiting-for-companion' not pending
  file src/devices/nm-device.c: line 13966 (<dropped>): should not be reached

https://github.com/NetworkManager/NetworkManager/pull/229
2018-10-12 12:56:19 +02:00
Michael Biebl
90f71c0f99 systemd: don't make NetworkManager D-Bus activatable
If the NetworkManager daemon has been stopped manually we don't want it
to be autostarted by a client request.

[lkundrak@v3.sk: The auto-activation is probably more surprising than useful.
Services that need NetworkManager API should depend on NetworkManager service
directly.

I have no idea what purpose does the D-Bus service file serve nowadays,
but it looks rather hacky (really, activating /bin/false) and the comment
in it suggests that the autoactivating behavior was not intended anyway.
Debian has been shipping this for quite some time and no complains have been
heard.]

https://github.com/NetworkManager/NetworkManager/pull/230
2018-10-12 12:54:02 +02:00
Thomas Haller
cec7ade86c wwan: don't assume DNS info is always available for IPv6
See also "5df024f57a wwan: don't assume DNS info is always available"
which does the same for IPv4.
2018-10-12 00:00:43 +02:00
Beniamino Galvani
c0fc85f3c4 cli: check we have an active connection before showing hint
If the activation fails even before the active connection instance is
created, we get the following:

 $ nmcli connection up vpn1
 libnm-CRITICAL **: nm_active_connection_get_connection: assertion 'NM_IS_ACTIVE_CONNECTION (connection)' failed
 nmcli-CRITICAL **: active_connection_hint: assertion 'connection' failed
 Error: Connection activation failed: Not authorized to control networking.

Check that we have an active connection before showing the hint.

Fixes: bc6c042d54
2018-10-11 18:40:54 +02:00
Thomas Haller
c925b72e1f wifi/iwd: merge branch 'balrog-kun/iwd-ap-adhoc'
https://github.com/NetworkManager/NetworkManager/pull/221
2018-10-11 16:07:45 +02:00
Andrew Zaborowski
b3dad27a4a wifi/iwd: use KnownNetwork DBus properties on Network objects
Instead of walking through the list all known networks and comparing
name & SSIDs to judge whether a network is an IWD KnownNetwork, look at
the Network.KnownNetwork pre-IWD-0.8 property.
2018-10-11 16:07:15 +02:00
Andrew Zaborowski
2fff4e14b4 wifi/iwd: always update can_connect in state_changed
Ensure priv->can_connect is up to date on IWD state changed.  If we
exited the function early priv->can_connect would sometimes be wrongly
TRUE and we'd start a new autoconnect too early after IP configuration
had failed for example.
2018-10-11 16:07:15 +02:00
Andrew Zaborowski
979c632e11 wifi/iwd: add Ad-hoc mode support 2018-10-11 16:07:15 +02:00
Andrew Zaborowski
a6f13d3c69 wifi/iwd: add AP mode support
Handle AP mode connections by setting the Mode property on IWD's Device
interface to "ap" (which will make the Station interface go away, the
Powered property -- normally controlled by set_enabled -- to switch to
FALSE and back to TRUE, and then the AccessPoint interface to appear)
and then calling the AccessPoint.Start method.  This is all done in the
CONFIG phase in NM.  We also attempt to always set Mode back to
"station" and wait for the Station interface to reappear before going to
the NM DISCONNECTED state.  All this complicates the code a little.

While making the necessary changes simplify a lot of the checks which
are implied by other things we've checked already, for example
priv->can_scan and priv->can_connect can now only be TRUE when device is
powered up and in station mode (Station interface is present) so we can
skip other checks.  Also assume that check_connection_compatible has
been called before other methods are called so we can skip multiple
connection mode checks and checks that a IWD KnownNetwork exsists for
EAP connections.

act_stage1_prepare and act_stage2_config now borrow more code from
nm-device-wifi.c because both backend now handle multiple modes.
2018-10-11 16:07:15 +02:00
Andrew Zaborowski
6e95029b09 wifi/iwd: use nm_utils_error_is_cancelled consistently
Use nm_utils_error_is_cancelled instead of checking
g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED), set
consider_is_disposing false.  Also use the DBUS_INTERFACE_PROPERTIES
macro.
2018-10-11 16:07:15 +02:00
Andrew Zaborowski
6e1935eb21 wifi/iwd: free variants returned by g_dbus_proxy_call_finish
Make sure we g_variant_unref() the values returned from
g_dbus_proxy_call_finish.  In get_ordered_networks_cb also make sure we
don't access the NMDeviceIwd data until after we know the call has not
been cancelled.  Switch from _nm_dbus_proxy_call_finish to
g_dbus_proxy_call_finish where we don't care about the variant type
returned.
2018-10-11 16:07:15 +02:00
Andrew Zaborowski
178af02678 wifi: skip nm_platform_wifi_get_capabilities/get_mode for IWD backend
Only call nm_platform_wifi_get_capabilities and
nm_platform_wifi_get_mode with the wpa_supplicant backend.  They're used
to initialize the wireless-capabilities property and to skip creating
NMDevices for interfaces in unknown wifi mode which IWD handles already.
2018-10-11 16:07:15 +02:00
Andrew Zaborowski
7a6d5ab5a2 wifi/iwd: set capabilities property based on IWD support
Parse the Adapter.SupportedModes dbus property and set the
gobject property wireless-capabilities based on that.
2018-10-11 16:07:15 +02:00
Thomas Haller
6e41d79067 ndisc: merge branch 'th/ndisc-fixes'
https://github.com/NetworkManager/NetworkManager/pull/219
2018-10-11 14:51:08 +02:00
Thomas Haller
98ec56c670 ndisc: always emit changed signal if an ndisc parameter changes
Note how the nm_ndisc_add_*() return a boolean to indicate whether
anything changes. That is taken to decide whether to emit a changed
signal.

Previously, we would not consider all fields which are exposed
as public API.

Note that nm-ip6-config.c would care about the lifetime of NMNDiscAddress.
For that, nm_ndisc_add_address() would correctly consider a change of
the lifetime as relevant. So, this was for the most part not broken.
However, for example nm_ndisc_add_route() would ignore changes to the
gateway.

Always signal changes if anything changes at all. It's more correct
and robust.
2018-10-11 05:56:18 +02:00
Thomas Haller
4f78d82fcd ndisc/trivial: move code 2018-10-11 05:56:18 +02:00
Thomas Haller
d444fcde34 ndisc: abort handling IO in event_ready() if we are unable to switch namespace
It should never happen that we are unable to switch the namespace.
However, in case it does, we cannot just return G_SOURCE_CONTINUE,
because we will just endlessly trying to process IO without actually
reading from the socket.

This shouldn't happen, but the instance is hosed and something is
very wrong. No longer handle the socket to avoid an endless loop.
2018-10-11 05:56:18 +02:00
Thomas Haller
9aa628cedb ndisc: keep NMNDisc instance alive while processing IO in event_ready()
event_ready() calls ndp_callall_eventfd_handler(), which invokes
our own callback, which may invoke change notification.

At that point, it's not guaranteed that the signal handler won't
destroy the ndisc instance, which means, the "struct ndp" gets destroyed
while invoking callbacks. That's bad, because libndp is not robust
against that.

Ensure the object stays alive long enough.
2018-10-11 05:56:18 +02:00
Thomas Haller
1f856b7cb3 ndisc: first reschedule timeout before invoking change event in check_timestamps()
It's just ugly to invoke external code in the middel of an operation.
You never know, whether the handler won' unref the ndisc instance.
2018-10-11 05:56:18 +02:00
Thomas Haller
8de09bb119 keyfile/tests: drop unused variables
Fixes: e886e5364e
2018-10-10 12:38:33 +02:00
Thomas Haller
c295d45a3b platform/netlink: fix overrun in attribute iteration in nla_ok()
See-also: 123dc07bcc
See-also: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=1045b03e07d85f3545118510a587035536030c1c
2018-10-10 12:04:27 +02:00
Thomas Haller
82652c1415 cli: merge branch 'th/cli-drop-some-global'
https://github.com/NetworkManager/NetworkManager/pull/225
2018-10-10 09:57:17 +02:00
Thomas Haller
86502bef9c cli: don't needlessly cast function pointer for rl_attempted_completion_function 2018-10-10 09:55:45 +02:00
Thomas Haller
5d684597c4 cli: don't access global nm_cli variable from nmc_setting_set_property() 2018-10-10 09:55:45 +02:00
Thomas Haller
99d3b6930b cli: don't use global variable nm_cli in nmc_terminal_spawn_pager()
print_required_fields() still accesses the global variable.
We can only move the uses of globals up the call-stack, one
bit at a time.
2018-10-10 09:55:45 +02:00
Thomas Haller
411243c654 cli: don't use global nm_cli in nmc_readline_*()
Globals are bad. Don't let nmc_readline_helper() access
nm_cli.

Instead, pass nmc_config along. nmc_config albeit being
a complex struct, is much more begning:

  - the configuration nmc_config is initialized early on
    and afterwards immutable.
  - it only contains simple fields, which affect the behavior.
  - it's not a global. While passing around the complex configuration
    struct, it is clear that all callpaths don't access additional
    global information.
2018-10-10 09:55:45 +02:00
Thomas Haller
0be65a4b78 cli: don't pass complex info argument to active_connection_hint()
Untangle the amount or agruments passed to active_connection_hint().
2018-10-10 09:55:45 +02:00
Lubomir Rintel
aa0e395530 devices/olpc: correct the signal handler arguments
Commit 631ca806 ("devices/wifi: flip meaning of scanning allowed
signal") added a "periodic" argument, but the OLPC companion handler was
not adjusted. Fix it now.

https://github.com/NetworkManager/NetworkManager/pull/222

Fixes: 631ca80692
2018-10-09 20:07:02 +02:00
Beniamino Galvani
09d0e5590c cli: fix memory leak
activate_connection_editor_cb() must free @info and unref the device.
2018-10-09 09:58:27 +02:00
Beniamino Galvani
d091cbdc2f cli: fix cleanup after activation from editor
progress_activation_editor_cb() is called multiple times every 120
milliseconds and it must free resources only the last time.

Fixes: f0a2686545

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/51
2018-10-09 09:58:27 +02:00
Beniamino Galvani
17a942b458 libnm-core: fix other int comparisons in team setting
I forgot to update them when applying commit 72b4541771.

Fixes: 72b4541771
2018-10-08 11:28:14 +02:00
Lubomir Rintel
fb2ae67da6 merge: branch 'lr/wpan-channel'
https://github.com/NetworkManager/NetworkManager/pull/209
2018-10-07 15:46:51 +02:00
Lubomir Rintel
c21b4c3d0a cli: add support for wpan.page and wpan.channel properties 2018-10-07 15:46:02 +02:00
Lubomir Rintel
bd6074095d devices/wpan: set channel on activation 2018-10-07 15:46:02 +02:00
Lubomir Rintel
0573656eeb platform/wpan: allow setting channel 2018-10-07 15:46:02 +02:00