Commit graph

19509 commits

Author SHA1 Message Date
Thomas Haller
80b95f8b5f core/trivial: add FIXME comment about uncancellable async action 2018-02-07 12:31:54 +01:00
Thomas Haller
0df3837656 manager: use cleanup functions for impl_manager_activate_connection()
Also, drop two redundant g_assert(). If we proceed, we will very soon afterwards
hit a SEGFAULT or a g_return_val_if_fail(), which is just as good.
2018-02-07 12:31:54 +01:00
Lubomir Rintel
631982a796 m4: disable -Wcast-function-type
This fixes the GCC 8 build. It disables the warning conditionally so that we
get the warning back if glib gets fixed.
2018-02-07 11:46:56 +01:00
Francesco Giudici
31d9a9de14 libnm-core: team: add support to runner "random"
https://bugzilla.redhat.com/show_bug.cgi?id=1538699
2018-02-05 15:24:36 +01:00
Thomas Haller
782578122c ovs: fix compiler error for passing NMDevice pointer to NM_DEVICE_OVS_INTERFACE_GET_PRIVATE()
NM_DEVICE_OVS_INTERFACE_GET_PRIVATE() is implemented via the _NM_GET_PRIVATE()
macro. This macro uses C11's _Generic() to provide additional compiler checks
when casting from an incompatible pointer type.

As such,

  NMDevice *device = ...;
  NMDeviceOvsInterfacePrivate *priv;

  priv = NM_DEVICE_OVS_INTERFACE_GET_PRIVATE (device);

causes a compilation error:

    error: ‘_Generic’ selector of type ‘NMDevice * {aka struct _NMDevice *}’ is not compatible with any association

One workaround would be to cast the pointer first:

  priv = NM_DEVICE_OVS_INTERFACE_GET_PRIVATE ((NMDeviceOvsInterface *) device);

A better fix is to mark NMDevice as a compatible pointer in _NM_GET_PRIVATE(),
which this patch does.

Previously, this went unnoticed, because due to bug "a43bf3388 build: fix configure
check for CC support of _Generic() and __auto_type", we failed to detect support
for _Generic() when compiling with -Werror. That essentially disables this check,
and NM_DEVICE_OVS_INTERFACE_GET_PRIVATE() would do a direct cast.

A workaround for this build failure might be to build with -Werror, which accidentally
results in not using _Generic().

https://bugzilla.gnome.org/show_bug.cgi?id=793183

Fixes: 8ad310f8e3
2018-02-05 13:59:15 +01:00
Thomas Haller
a43bf33888 build: fix configure check for CC support of _Generic() and __auto_type
autotools' AC_LANG_PROGRAM() generates a main() function which triggers
a compiler warning (for which we fail with -WError).

    conftest.c:92:1: error: function declaration isn't a prototype [-Werror=strict-prototypes]
     main ()
     ^~~~
    cc1: all warnings being treated as errors

Fixes: 557d83bf2d
2018-02-05 12:59:52 +01:00
Lubomir Rintel
8ad310f8e3 ovs-interface: avoid starting ip[46] configuration more than once
OvsInterface can postpone the stage3_ip[46]_config until the link
actually appears. It ought to restart the stage only when the link
appears, not upon further changes to it (which would trip an assertion
when starting the DHCP client while one already exists).

https://bugzilla.redhat.com/show_bug.cgi?id=1540063
2018-02-05 10:57:16 +01:00
Piotr Drąg
fa8a90a28e po: update Polish (pl) translation (bgo #792436)
https://bugzilla.gnome.org/show_bug.cgi?id=792436
2018-02-05 10:46:47 +01:00
Lubomir Rintel
edf6f826b5 nmcli: fix signal handling
Hook the signal handlers right before the main loop. Prior to that
the default handlers are good enough and our one crashes (due to
loop being instantialized).

Also, set the return value properly to indicate a termination by a
signal.
2018-01-24 09:53:38 +01:00
Lubomir Rintel
7e8a84ae10 nmcli/agent: fix handling of polkit agent failure
On "nmcli agent all", when the polkit agent fails (while the NM agent
succeeds), the failure is not communicated until the client exits.
2018-01-24 09:53:38 +01:00
Lubomir Rintel
fc4552d391 shared/utils: don't warn of unknown warning disables with clang
When pushing a warning disable with clang, always disable
-Wunknown-warning-option first -- it might be that clang wouldn't warn
of what we're trying to disable because it doesn't recognize it in the
first place. That is entierely okay.

With clang-5.0.0:

    CC       libnm/tests/libnm_tests_test_secret_agent-test-secret-agent.o
  In file included from libnm/tests/test-secret-agent.c:29:
  In file included from ./shared/nm-test-libnm-utils.h:23:
  ./shared/nm-utils/nm-test-utils.h:432:3: error: unknown warning group '-Wunused-but-set-variable', ignored [-Werror,-Wunknown-warning-option]
                  NM_PRAGMA_WARNING_DISABLE("-Wunused-but-set-variable")
                  ^
  ./shared/nm-utils/nm-macros-internal.h:223:9: note: expanded from macro 'NM_PRAGMA_WARNING_DISABLE'
          _Pragma(_NM_PRAGMA_WARNING_DO(warning))
          ^
  <scratch space>:204:25: note: expanded from here
   GCC diagnostic ignored "-Wunused-but-set-variable"
                          ^
  1 error generated.
2018-01-24 09:53:38 +01:00
Thomas Haller
c93827e404 wifi/iwd: fix compiler warning about uninitialized variable with cleanup attribute
Must always initialize cleanup variable, to be able to build with
"-fexceptions".

    make[2]: Entering directory './contrib/fedora/rpm/NetworkManager.20180124-060444.C5tHCi/BUILD/NetworkManager-1.11.1'
      CC       src/devices/wifi/src_devices_wifi_libnm_device_plugin_wifi_la-nm-device-iwd.lo
    In file included from ./shared/nm-utils/nm-glib.h:27:0,
                     from ./shared/nm-utils/nm-macros-internal.h:60,
                     from ./shared/nm-default.h:257,
                     from src/devices/wifi/nm-device-iwd.c:21:
    src/devices/wifi/nm-device-iwd.c: In function ‘deactivate_async_finish’:
    ./shared/nm-utils/gsystem-local-alloc.h:37:8: error: ‘variant’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
         if (*(Type*)v) \
            ^
    src/devices/wifi/nm-device-iwd.c:405:29: note: ‘variant’ was declared here
      gs_unref_variant GVariant *variant;
                                 ^~~~~~~

Fixes: d0c1e1a62a
2018-01-24 06:14:34 +01:00
Thomas Haller
aed6e28461 trivial: avoid XXX tag and replace by NOTE or FIXME
XXX was used to either raise attention (NOTE) or to indicate
that this is ugly code that should be fixed (FIXME). The usage
was inconsistent.

Let's avoid XXX and use either NOTE or FIXME.
2018-01-23 12:55:33 +01:00
Thomas Haller
b411b54e27 all: merge branch 'th/version-macros'
https://github.com/NetworkManager/NetworkManager/pull/61
2018-01-23 10:58:33 +01:00
Thomas Haller
c7ff37967a version: add reminder comment for adding version macros to configure.ac 2018-01-23 10:57:41 +01:00
Thomas Haller
4da1480cfd version: rename macro NM_VERSION_CUR_STABLE to NM_API_VERSION
NM_API_VERSION is a better name. It's not the current stable
version, but the version number of the API which the current
NM_VERSION provides. In practice, NM_API_VERSION is either identical
to NM_VERSION (in case of a release) or NM_VERSION is a development
version leading up the the upcoming NM_API_VERSION.

For example, with the new name the check

  #if NM_VERSION != NM_API_VERSION
  # warning this is an development version
  #endif

makes more sense.
2018-01-23 10:54:11 +01:00
Thomas Haller
165fe65eef version: calculate NM_VERSION_CUR_STABLE based on the version numbers
We have a well defined versioning scheme and a defined way how
the version number indicates a stable version. We can simply
calculate NM_VERSION_CUR_STABLE based on the version numbers.
2018-01-23 10:50:34 +01:00
Thomas Haller
9ef17869b5 version: drop NM_VERSION_MAX_ALLOWED defines for internal build
It already defaults to the right value. We only need to define
NM_VERSION_MIN_REQUIRED, so that parts of our internal build
can make use of deprecated API.
2018-01-23 10:50:34 +01:00
Thomas Haller
8a040c6883 version: combine NM_VERSION_CUR_STABLE and NM_VERSION_NEXT_STABLE
We don't need to have two version defines "CUR" and "NEXT".

The main purpose of these macros (if not their only), is to
make NM_AVAILABLE_IN_* and NM_DEPRECATED_IN_* macros work.

1) At the precise commit of a release, "CUR" and "NEXT" must be identical,
because whenever the user configures NM_VERSION_MIN_REQUIRED and
NM_VERSION_MAX_ALLOWED, then they both compare against the current
version, at which point "CUR" == "NEXT".

2) Every other commit aside the release, is a development version that leads
up the the next coming release. But as far as versioning is concerned, such
a development version should be treated like that future release. It's unstable
API and it may or may not be close to later API of the release. But
we shall treat it as that version. Hence, also in this case, we want to
set both "NM_VERSION_CUR_STABLE" and again NEXT to the future version.

This makes NM_VERSION_NEXT_STABLE redundant.

Previously, the separation between current and next version would for
example allow that NM_VERSION_CUR_STABLE is the previously release
stable API, and NM_VERSION_NEXT_STABLE is the version of the next upcoming
stable API. So, we could allow "examples" to make use of development
API, but other(?) internal code still restrict to unstable API. But it's
unclear which other code would want to avoid current development.

Also, the points 1) and 2) were badly understood. Note that for our
previousy releases, we usually didn't bump the macros at the stable
release (and if we did, we didn't set them to be the same). While using
two macros might be more powerful, it is hard to grok and easy to
forget to bump the macros a the right time. One macro shall suffice.

All this also means, that *immediately* after making a new release, we shall
bump the version number in `configure.ac` and "NM_VERSION_CUR_STABLE".
2018-01-23 10:50:34 +01:00
Thomas Haller
f67686256f config: fix using the right nm-version for the match specification
We can disable/enable configuration snippets per NetworkManager
version. But we must compare it against the current version
that we build, not the current API version.
2018-01-23 10:50:34 +01:00
Francesco Giudici
72bf38cad6 cli: merge branch 'fg/team_link_watchers_overwrite-rh1533926'
https://bugzilla.redhat.com/show_bug.cgi?id=1533926
2018-01-22 19:23:25 +01:00
Francesco Giudici
d7f3c79881 doc: fix describe message for team link watchers 2018-01-22 19:21:42 +01:00
Francesco Giudici
ff16252a71 nmcli: clear link-watchers before adding the new ones we want to set 2018-01-22 19:21:42 +01:00
Francesco Giudici
381c1a19b6 libnm-core: ensure alignment of team.config and other team properties
https://bugzilla.redhat.com/show_bug.cgi?id=1533830
2018-01-22 19:16:09 +01:00
Thomas Haller
14cfb3d373 wifi/iwd: merge branch 'pr/60'
https://github.com/NetworkManager/NetworkManager/pull/60
2018-01-22 15:58:13 +01:00
Andrew Zaborowski
c95c27a099 iwd: Wait for disconnect to finish
In a previous patch I added deactivate_async to make sure that NM
auto re-connect waits for the IWD state to changed from "disconnecting"
to "disconnected" before starting a new activation when the user wants
to switch from one profile to another.  This doesn't account for when
IWD itself goes into "disconnecting" because of a connect failure.

When IWD goes into the "disconnecting" state we call
  nm_device_state_changed (NM_DEVICE_STATE_FAILED,
                           NM_DEVICE_STATE_REASON_SUPPLICANT_DISCONNECT)
immediately to give feedback to user as soon as possible.  We will
return FALSE from get_autoconnect_allowed for the period the
"disconnecting" state.
2018-01-22 15:43:30 +01:00
Andrew Zaborowski
bcf3b10284 iwd: Initialize priv->scanning when DBus interface appears 2018-01-22 14:53:20 +01:00
Andrew Zaborowski
e6689154ae iwd: use connection.auth-retries to handle authentication retries
Repeat commit 72756994d4 for NMDeviceIwd.
2018-01-22 14:53:20 +01:00
Andrew Zaborowski
d0c1e1a62a iwd: Implement deactivate_async
Deactivating the connection translates to a Device.Disconnect dbus call
to IWD.  The dbus call normally returns immediately because the
corresponding nl80211 command returns immediately but we can't rely on
that.  Make sure that NMDevice waits for the IWD method return before
continuing with the new activation request when switching wifi networks.
2018-01-22 14:53:20 +01:00
Andrew Zaborowski
a4f9d117d5 iwd: Improve Device.State property change handling
The handler would until now check if nm_device_is_activating() was true
or the NMDevice state was "activated" to decide whether to report to
NMDevice that we'd been unexpectedly disconnected (i.e. connection
failed).  However NM's "prepare" and "need auth" states correspond to
IWD's "disconnected" state because they don't involve Wifi
authentication/association.

Additionally nm_device_is_activating() returns TRUE even when NMDevice
state is "disconnected" but an activation request is pending.  As a
result when switching networks, NMDevice would first save the activation
request and go into the "disconnected" state, we'd then call the IWD's
Disconnect method and when we received the IWD state change notification
to "disconnected", we'd cause the pending activation request to be
considered a failure.  The handler shouldn't report a failed
connection when the NMDevice state is "disconnected".
2018-01-22 14:53:20 +01:00
Beniamino Galvani
a0cf466482 wifi: enable WPA-*-SHA256 AKMs only when the supplicant supports them
Commit 87ec5e90fe ("supplicant: set key_mgmt independent of pmf
value") enabled WPA-PSK-SHA256 or WPA-EAP-SHA256 even when the
supplicant didn't support them, potentially causing connection
failures.  Instead, use the 'pmf' capability to detect when they can
be enabled.

Fixes: 87ec5e90fe

https://mail.gnome.org/archives/networkmanager-list/2018-January/msg00096.html
2018-01-22 08:38:28 +01:00
Thomas Haller
dd2d55ca57 tests: fix test setup after requiring glib 2.40
Also, g_test_expect_message() no longer needs to suppress
deprecation warnings.

Fixes: 8a46b25cfa
2018-01-22 08:31:00 +01:00
Beniamino Galvani
22f32a16f5 device: skip IP configuration phase for external devices
We already avoid committing the IP configuration for external devices
(see commit 60334a2893). However, we still start DHCP/IPv6-autoconf
and, especially, we change sysctl values of the device.

To be sure that no action is taken on the device, return early from
the IP configuration phase, as in the method=disabled/ignore case.

https://bugzilla.redhat.com/show_bug.cgi?id=1530288
2018-01-19 14:10:01 +01:00
Beniamino Galvani
156344b8be device: increase carrier wait time to 6 seconds
Some NICs need longer to establish the link, increase the timeout from
5 to 6 seconds.

https://bugzilla.redhat.com/show_bug.cgi?id=1520826
2018-01-18 15:26:34 +01:00
Lubomir Rintel
d50e8d3ec1 connection: treat connection type's ability to have slaves uniformly
This also adds OVS_BRIDGE and OVS_PORT to places that didn't consider
them to be master types
2018-01-18 13:28:12 +01:00
Lubomir Rintel
1440fe6a88 ifcfg: don't forget master of ovs interfaces
https://bugzilla.redhat.com/show_bug.cgi?id=1519179
2018-01-18 13:28:12 +01:00
Lubomir Rintel
f70c1f717a ifcfg-rh/trivial: fix cosmetic issues
A typo and bad whitespace while at it.
2018-01-18 13:28:12 +01:00
Lubomir Rintel
8a46b25cfa all: require glib 2.40
RHEL 7.1 and Ubuntu 14.04 LTS both have this.

https://bugzilla.gnome.org/show_bug.cgi?id=792323
2018-01-18 11:45:36 +01:00
Lubomir Rintel
1443bf77e8 all: require jansson 2.5
It was released Sep 19 2013 and Ubuntu 14.04 LTS (trusty) ships it.

https://bugzilla.gnome.org/show_bug.cgi?id=792323
2018-01-18 11:45:24 +01:00
Pavel Šimerda
c4f655579c libnm: fix empty statements that were supposed to return NULL
Discovered thanks to `-Wunused-value` when building on openSUSE Leap 42.3.
2018-01-17 19:20:03 +01:00
Thomas Haller
f2aa286fa9 libnm: cast guint32 argument to guint in variadic g_object_set()
yes, this is not an issue in practice. Variadic arguments are always
propagated to at least int/unsigned type. And kernel and glib both require
sizeof(guint32) <= sizeof(guint). Hence, this was safe on any supported
architecture. Still, let's be explicit about the types.
2018-01-17 10:17:31 +01:00
Thomas Haller
3c6cc7c2e0 wifi: merge branch 'wifi-fils'
https://mail.gnome.org/archives/networkmanager-list/2017-December/msg00073.html
https://mail.gnome.org/archives/networkmanager-list/2018-January/msg00065.html
https://mail.gnome.org/archives/networkmanager-list/2018-January/msg00083.html
2018-01-16 15:04:28 +01:00
Masashi Honma
0109615c4e supplicant: enable FILS only when wpa_supplicant supports it
Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
2018-01-16 15:01:59 +01:00
Masashi Honma
7711d7c87b cli: add support for FILS
Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
2018-01-16 15:01:59 +01:00
Masashi Honma
c7d490cfba ifcfg-rh/tests: add Wi-Fi FILS test
Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
2018-01-16 15:01:59 +01:00
Masashi Honma
6e742693ee supplicant/tests: add FILS test
Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
2018-01-16 15:01:59 +01:00
Masashi Honma
b4bbe5179f wifi: add support for FILS
The FILS(Fast Initial Link Setup) is a specification defined by IEEE 802.11ai to
speed up roaming. This patch adds support of it.

I have tested with these cases.
+-----+-------------------------+----------------+
| STA |            AP           |                |
|FILS |         key-mgmt        |     result     |
+-----+-------------------------+----------------+
|  1  | WPA-EAP                 |       O        |
+-----+-------------------------+----------------+
|  1  | WPA-EAP-SHA256          |       O        |
+-----+-------------------------+----------------+
|  1  | FILS-SHA256             |       X        |
+-----+-------------------------+----------------+
|  1  | FILS-SHA384             |       X        |
+-----+-------------------------+----------------+
|  1  | WPA-EAP WPA-EAP-SHA256  |       O        |
|     | FILS-SHA256 FILS-SHA384 | WPA-EAP-SHA256 |
+-----+-------------------------+----------------+
|  2  | WPA-EAP                 |       O        |
+-----+-------------------------+----------------+
|  2  | WPA-EAP-SHA256          |       O        |
+-----+-------------------------+----------------+
|  2  | FILS-SHA256             |       O        |
+-----+-------------------------+----------------+
|  2  | FILS-SHA384             |       O        |
+-----+-------------------------+----------------+
|  2  | WPA-EAP WPA-EAP-SHA256  |       O        |
|     | FILS-SHA256 FILS-SHA384 | FILS-SHA384    |
+-----+-------------------------+----------------+
|  3  | WPA-EAP                 |       X        |
+-----+-------------------------+----------------+
|  3  | WPA-EAP-SHA256          |       X        |
+-----+-------------------------+----------------+
|  3  | FILS-SHA256             |       O        |
+-----+-------------------------+----------------+
|  3  | FILS-SHA384             |       O        |
+-----+-------------------------+----------------+
|  3  | WPA-EAP WPA-EAP-SHA256  |       O        |
|     | FILS-SHA256 FILS-SHA384 | FILS-SHA384    |
+-----+-------------------------+----------------+

Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
2018-01-16 15:01:59 +01:00
Masashi Honma
87ec5e90fe supplicant: set key_mgmt independent of pmf value
Previouslly, the value of ieee80211w and key_mgmt field in
wpa_supplicant.conf was defined by the value of pmf.

NM_SETTING_WIRELESS_SECURITY_PMF_DISABLE
  ieee80211w=0
  key_mgmt=wpa-eap
NM_SETTING_WIRELESS_SECURITY_PMF_OPTIONAL
  ieee80211w=1
  key_mgmt=wpa-eap wpa-eap-sha256
NM_SETTING_WIRELESS_SECURITY_PMF_REQUIRED
  ieee80211w=2
  key_mgmt=wpa-eap-sha256

Though these works, these does not include whole combinations.
The key_mgmt could be set independent of ieee80211w value.
For example, management frame protection could be used with
wpa-eap.
  ieee80211w=2
  key_mgmt=wpa-eap

And wpa-eap-sha256 could be used without management frame
protection.
  ieee80211w=0
  key_mgmt=wpa-eap-sha256

So this patch uses always key_mgmt=wpa-psk wpa-psk-sha256 or
key_mgmt=wpa-eap wpa-eap-sha256. By this setting, when AP
supports both, stronger algorithm will be chosen (ex. when AP
supports both wpa-eap and wpa-eap-sha256, wpa-eap-sha256 will be
chosen).

Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
2018-01-16 15:01:35 +01:00
Thomas Haller
0839adc7d7 libnm: merge branch 'th/libnm-jansson' (part 1)
https://github.com/NetworkManager/NetworkManager/pull/56
2018-01-16 14:48:47 +01:00
Thomas Haller
84576ce861 libnm: cleanup include in "libnm-core/nm-json.c"
We already define _GNU_SOURCE in "config.h", depending
on configure checks.

Also, we always should first include "config.h" (which means
to first include "nm-default.h").

Also, we don't need the entire <link.h>, <dlfcn.h> suffices.
2018-01-16 14:47:24 +01:00