Commit graph

21433 commits

Author SHA1 Message Date
Thomas Haller
a217cbebf9 release: update NEWS 2018-10-17 17:16:12 +02:00
Thomas Haller
92696036d2 cli: merge branch 'th/cli-fix-serial-properties'
https://github.com/NetworkManager/NetworkManager/pull/233
2018-10-17 16:28:26 +02:00
Thomas Haller
1b4f765c59 cli/tests: add test for adding and displaying gsm/serial settings 2018-10-17 16:22:34 +02:00
Thomas Haller
0f503efd64 tests: support UInt64 type in test-networkmanager-service.py
and also accept "gsm" connection-type. Both will be used next.
2018-10-17 16:22:34 +02:00
Thomas Haller
085105fc0e cli: minor cleanup of _set_fcn_gobject_enum()
No need to check again the gtype_class. We did it above already.
2018-10-17 16:22:34 +02:00
Thomas Haller
127ac25ef8 cli: fix setting "serial.parity" enum
The meta data type descriptor must set .get_gtype only for
GObject properties which are of type int or uint. That is, when
the enum type cannot be automatically detected.

However, NM_SETTING_SERIAL_PARITY is a g_param_spec_enum()
of type NM_TYPE_SETTING_SERIAL_PARITY, so setting the get_gtype()
hook is wrong and leads to a crash

   $ /bin/nmcli connection add type gsm autoconnect no con-name t ifname '*' apn xyz serial.parity 5

   (process:11086): libnmc-CRITICAL **: 15:04:35.180: file clients/common/nm-meta-setting-desc.c: line 1283 (_set_fcn_gobject_enum): should not be reached
   Segmentation fault (core dumped)

That is because the enum property setter does:

    »···if (   has_gtype
    »···    && NM_IN_SET (gtype_prop,
    »···                  G_TYPE_INT,
    »···                  G_TYPE_UINT)
    »···    && G_TYPE_IS_CLASSED (gtype)
    »···    && (gtype_class = g_type_class_ref (gtype))
    »···    && (   (is_flags = G_IS_FLAGS_CLASS (gtype_class))
    »···        || G_IS_ENUM_CLASS (gtype_class))) {
    »···»···/* valid */

meaning, it only allows "has_gtype" if the native "gtype_prop" is
G_TYPE_INT or G_TYPE_UINT.

Fixes: 9a68123827
2018-10-17 16:22:34 +02:00
Thomas Haller
a600b3a3b2 cli: fix handling uint64 connection property "serial.send-delay"
libnm currently has only one GObject property of type uint64:
"serial.send-delay". However, it's broken because uint64 handling
is not implemented.

    $ nmcli connection add type gsm autoconnect no con-name t ifname '*' apn 'xyz' serial.baud 5
    Connection 't' (4c929f17-9fda-41d6-8f90-897f6d46b078) successfully added.

    $ nmcli connection show t
    ...
    ipv6.dhcp-duid:                         --
    ipv6.dhcp-send-hostname:                yes
    ipv6.dhcp-hostname:                     --
    ipv6.token:                             --

    (process:14016): libnmc-CRITICAL **: 14:08:32.591: file clients/common/nm-meta-setting-desc.c: line 811 (_get_fcn_gobject_int): should not be reached
    serial.baud:                            5
    serial.bits:                            8
    serial.parity:                          none
    serial.stopbits:                        1
    serial.send-delay:                      --
    gsm.number:                             *99#
    ...

    $ nmcli connection add type gsm autoconnect no con-name t ifname '*' apn 'xyz' serial.baud 5 serial.send-delay 100

    (process:14852): libnmc-CRITICAL **: 14:12:24.259: file clients/common/nm-meta-setting-desc.c: line 1131 (_set_fcn_gobject_int): should not be reached
    Segmentation fault (core dumped)

Fixes: b6d9bdcee8
2018-10-17 16:22:34 +02:00
Thomas Haller
c0d292d255 shared: add _nm_utils_ascii_str_to_uint64() helper 2018-10-17 16:22:34 +02:00
Thomas Haller
9cf64e2ee2 core: merge branch 'th/device-availability'
https://bugzilla.redhat.com/show_bug.cgi?id=1639254
2018-10-17 15:26:02 +02:00
Thomas Haller
0cb8bed23c core: ignore unmanaged devices for explicit activation request depending on multi-connect
When a device is unmanaged, an explicit activation request can
still activate it. In particular, that is the case for

  $ nmcli connection up "$PROFILE" ifname "$DEVICE"

It is also the case, for plain

  $ nmcli connection up "$PROFILE"

where NetworkManager searches for a suitable device -- depending on
multi-connect setting of the profile.

The idea is, that a profile with "multi-connect=single" is expected
to sufficently and uniquely match a device, based on matching properties
like "connection.interface-name". In that case, an explicit activation
request from the user shows the intent to manage the device.
Note that it's hard to understand whether the profile really uniquely
selects a particular device. For example, if the profile doesn't specify
"connection.interface-name", it might still uniquely identify
an ethernet device, if you only have one such device.

On the other hand, with "connection.multi-connect" other than "single",
it is very much expected that the profile does not strictly match
one device.

Change the behavior here for multi-connect profiles. This allows the
user to block individual devices from activation via

  $ nmcli device set "$DEVICE" managed not

A subsequent

  $ nmcli connection up "$MULTI_PROFILE"

will not consider "$DEVICE" as suitable candidate for activation.

Likewise, in the future we may want to add a

  $ nmcli connection up --all "$MULTI_PROFILE"

command, to activate the profile on all suitable device.
In that case again, unmanaged devices probably also should be skipped
for multi-connect profiles.

https://bugzilla.redhat.com/show_bug.cgi?id=1639254
2018-10-17 15:22:56 +02:00
Thomas Haller
920346a5b9 device: add and use overrule-unmanaged flag for nm_device_check_connection_available()
This flag is more granular in whether to consider the connection
available or not. We probably should never check for the combined
flag NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST directly, but
always explicitly for the relevant parts.

Also, improve the error message, to indicate whether the device is
strictly unmanaged or whether it could be overruled.
2018-10-17 15:06:52 +02:00
Thomas Haller
5412fd389b device: cleanup checking device avilability for ignoring carrier
The flags NMDeviceCheckConAvailableFlags and NMDeviceCheckDevAvailableFlags
both control whether a device appears available (either, available in
general, or related to a particular profile).

Also, both flag types strictly increase availability. Meaning: more flags,
more available.

There is some overlap between the flags, however they still have
their own distinct parts.

Improve the mapping from NMDeviceCheckConAvailableFlags to
NMDeviceCheckDevAvailableFlags, by picking exactly the flags
that are relevant.
2018-10-17 15:06:52 +02:00
Thomas Haller
e6523fbbbc core/trivial: add code comment for NMDeviceCheckDevAvailableFlags and NMDeviceCheckConAvailableFlags 2018-10-17 15:06:52 +02:00
Thomas Haller
c37b028aba core/trivial: add code comment for nm_manager_get_best_device_for_connection() 2018-10-17 15:06:52 +02:00
Thomas Haller
45913c11df core: fix checking multi-connect flag in nm_manager_get_best_device_for_connection()
We should not check @sett_conn, but @connection.

Fixes: 09719bc479
2018-10-17 14:38:07 +02:00
Thomas Haller
fd7115eeed core: merge branch 'th/no-gasyncresult'
https://github.com/NetworkManager/NetworkManager/pull/227
2018-10-17 13:03:57 +02:00
Thomas Haller
47146b4be3 modem: cleanup nm_modem_deactivate_async()
- fix stopping ppp-manager. Previously, we would take a reference
  to priv->ppp_manager to cancel it later. However, deactivate_cleanup()
  is called first, which already issues nm_ppp_manager_stop().
  Thereby, not using a callback and not waiting for the operation
  to complete.

- get rid of this "step" state machine. There are litterally two steps
  that need to be performed asynchornously. Instead chain the calls.

- it is now obviously visible, that the async callback never completes
  synchronously upon being called (provided that all async operations
  that it calls themself have this behavior -- which they should).
2018-10-17 13:03:50 +02:00
Thomas Haller
dd4968fa16 ppp: make ppp-manager cancellable via GCancellable
Previously nm_ppp_manager_stop() would return a handle which
makes it easy to cancel the operation.

However, sometimes, we may want to cancel an operation based on
an GCancellable. So, extend nm_ppp_manager_stop() to hook it
with a cancellable.

Essentially, move the code from nm-modem.c to nm-ppp-manager-call.c,
where it belongs and where the functionality gets available to every
component.
2018-10-17 13:03:50 +02:00
Thomas Haller
9b935fad9b modem: don't use GAsyncResult pattern for disconnecting modem
We should not use GAsyncResult. At least, not for internal API.

It's more cumbersome then helpful, in my opinion. It requires
this awkward async_finish() pattern.

Instead, let the caller pass a suitable callback of the right type.
2018-10-17 13:03:50 +02:00
Thomas Haller
fadcc16b26 bluez: make connect operation (partially) cancellable and drop GAsyncResult pattern
All operations must be cancellable in a timely manner, otherwise, the objects
hang during shutdown.

Also, get rid of the GAsyncResult pattern. It is more cumbersome than
helpful.

There are still several issues, marked by FIXME comments.
2018-10-17 13:03:50 +02:00
Thomas Haller
bd21a63e2f shared: add nm_utils_invoke_on_idle() helper 2018-10-17 13:03:50 +02:00
Thomas Haller
c5c7dc59c5 libnm-core: expose internal _nm_dbus_typecheck_response() helper 2018-10-17 13:03:50 +02:00
Thomas Haller
09719bc479 core: improve selection of device when activating profile on any device
With

  $ nmcli connection up "$PROFILE" ifname "$DEVICE"

it's clear that the user means the particular device. That also
is taken as a indication to make $DEVICE as managed, in case it was
unmanaged before. So, this command implies a previous

  $ nmcli device set $DEVICE managed yes

On the other hand, if the user just issues

  $ nmcli connection up "$PROFILE"

without a particular device, then we should prefer devices which
are marked as managed instead of unmanaged once.

Likewise, we should consider the device's state when selecting
a device. This means, when activating a profile which is activatable on
multiple devices, it will now prefer devices which are not already
active. The exception to this is that if the profile itself is already
active (and multi-connect "single"), then it will prefer to re-activate
the profile on the same device. This was done previously already. What's
new is that if the the profile is not multi-connect "single", the said
exception no longer applies, and we prefer to activate the profile on a
hitherto unactivated device.

https://bugzilla.redhat.com/show_bug.cgi?id=1639254

https://github.com/NetworkManager/NetworkManager/pull/232
2018-10-17 11:10:31 +02:00
Lubomir Rintel
7b8510a7e8 po: update from Red Hat translators
https://bugzilla.redhat.com/show_bug.cgi?id=1608323
(cherry picked from commit d7d085a88d)
2018-10-16 16:48:27 +02:00
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