Commit Graph

22377 Commits

Author SHA1 Message Date
Thomas Haller
eea11faf9a logging: split out enum type definition for LogBackend 2019-02-05 08:18:07 +01:00
Thomas Haller
8dcc3cd51a logging: split out @level_desc and @domain_desc variables from global data
@level_desc and @domain_desc are two immutable arrays with information
about logging levels and logging domains. Since they are immutable and
intialized from the start, they are pretty trival w.r.t. tread-safety and
general maintainability (code readability).

Refactor them to be separate variables.
2019-02-05 08:18:07 +01:00
Thomas Haller
ba1bf0390d logging: make _nm_logging_clear_platform_logging_cache() a regular function
Previously, _nm_logging_clear_platform_logging_cache was an extern variable,
and NMLinuxPlatform would set it to a function pointer at certain points.

That's unnecessary complex, also when trying to make nm-logging thread-safe,
it's just more global variables that need to be considered. Don't do it
that way, but just link in a regular function.
2019-02-05 08:18:07 +01:00
Thomas Haller
40b0d7ce1e shared: define NM_THREAD_SAFE_ON_MAIN_THREAD
This will be used by nm-logging to opportunistically avoid locking.
2019-02-05 08:18:07 +01:00
Thomas Haller
61e76e97dc shared: add nm_utils_gettid() and NM_ASSERT_ON_MAIN_THREAD() 2019-02-05 08:18:07 +01:00
Thomas Haller
953dd4ac49 core: drop unused <pthread.h> include from src/main.c 2019-02-05 08:18:06 +01:00
Lubomir Rintel
ef6d461b7f platform/linux: fix setting of IFA_ADDRESS without a peer
Since commit 9ecdba316 ('platform: create netlink messages directly
without libnl-route-3') we're unconditionally setting IFA_ADDRESS to
the peer address, even if there's no peer and it's all zeroes.

The kernel actually stopped caring somewhere around commit caeaba790
('ipv6: add support of peer address') in v3.10, but Ubuntu Touch likes
to run Android's v3.4 on some poorly supported hardware.

Fixes: 9ecdba316c

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/77
2019-02-05 07:11:12 +01:00
Thomas Haller
2727c713ca libnm,core: merge branch 'th/various-for-wireguard-2'
https://github.com/NetworkManager/NetworkManager/pull/291
2019-02-04 20:15:55 +01:00
Thomas Haller
b4e9efd724 libnm-core: drop unused includes from "nm-setting.c" 2019-02-04 20:15:20 +01:00
Thomas Haller
353e619c9f libnm,core: make for-each-secret implementation virtual functions of NMSetting
We already need to special handle regular settings (with secrets as
GObject properties) and VPN secrets.

Next, we will also need to special handle WireGuard peers, which can
have secrets too.

Move the code to a virtual function, so that "nm-connection.c" and
"nm-setting.c" does not have explicit per-setting knowledge.
2019-02-04 20:15:20 +01:00
Thomas Haller
866ac505a8 libnm,core: various cleanups of _nm_connection_for_each_secret()
- use cleanup attribute to free memory

- return floating reference from _nm_connection_for_each_secret().
  It's more idiomatic that a function that constructs a variant and
  returns it, returns a floating variant.
2019-02-04 20:15:20 +01:00
Thomas Haller
79a0238c5e libnm,core: move _nm_connection_for_each_secret() from core to libnm-core
_nm_connection_for_each_secret() (formerly for_each_secret()) and
_nm_connection_find_secret() (formerly find_secret()) operate on a
GVariant of secrets. For that, they implement certain assumptions
of how to handle secrets. For example, it must special-case VPN settings,
because there is no generic abstraction to handle regular secret and VPN
secrets the same.

Such special casing should only be done in libnm-core, at one place.

Move the code to libnm-core as internal API.
2019-02-04 20:15:20 +01:00
Thomas Haller
4ea6c83e9b settings: fix handling of VPN secrets in for_each_secret()
nm_setting_get_secret_flags() looks whether we have a suitable "-flags"
data value, or whether we have a secret with that name.

In fact, we know this is a valid secret-name. Even if there are no secret-flags
and the secret (currently) does not exists. We shall not care about the
return value.

Note that nm_setting_get_secret_flags() also for non-secrets will set
the flags to "NONE", which is just what we need.
2019-02-04 20:15:20 +01:00
Thomas Haller
5eac241578 settings: fix for_each_secret() to check variant type of VPN secrets
We cannot just blindly assume that the variant is of the right type
to iterate over it.
2019-02-04 20:15:20 +01:00
Thomas Haller
cabc1ddca5 settings: fix leaking variant in for_each_secret()
Fixes: df6706813a
2019-02-04 20:15:20 +01:00
Thomas Haller
b64e24dcd7 libnm: rework _nm_setting_aggregate() to delegate to setting class
Instead of special-casing the aggregate implementation for NMSettingVpn,
delegate to a virtual function.

This will also work with other settings, that have properties/secrets
that are not GObject based properties.
2019-02-04 20:15:20 +01:00
Thomas Haller
52368678d6 libnm: extend nm_setting_enumerate_values() to support non-GObject base properties
While nm_setting_enumerate_values() should not be used anymore, still
extend it to make it workable also for properties that are not based on
GObject properties.
2019-02-04 20:15:20 +01:00
Thomas Haller
879820ccd5 libnm: emit "notify:name" signal when changing gendata property (NMSettingEthtool)
We want to emit a change notification when gendata-based settings (like
NMSettingEthtool) change. But instead of adding a separate signal, just
emit a fake "notify:name" notification.
2019-02-04 20:15:20 +01:00
Thomas Haller
0b20b44c99 libnm: add _nm_setting_emit_property_changed() function
Will be used next.
2019-02-04 20:15:20 +01:00
Thomas Haller
c7b3c23af2 ifcfg-rh/tests: avoid duplicate const warning for NO_EXPECTED
../src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c:126:19: warning: duplicate 'const' declaration specifier [-Wduplicate-decl-specifier]
     static const char const NO_EXPECTED[1];
                       ^~~~~

Fixes: f04bf45e84
2019-02-04 16:55:43 +01:00
Beniamino Galvani
797eab2f6b vpn: add route to vpn gw when parent has a default device route
When the parent device has a device default route (i.e. without
gateway) and we establish a VPN on top of it, 'ip route get' for the
VPN gateway returns a device route, which is the same result we get
for an unreachable VPN gateway. However it is necessary to add the
route to the gateway or otherwise it will possibly become unreachable
once the VPN gets activated.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/93
2019-02-04 11:07:02 +01:00
Beniamino Galvani
483dc40047 build: merge branch 'bg/lto'
Fix LTO builds.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/76
https://bugzilla.gnome.org/show_bug.cgi?id=782525#c4
2019-02-04 10:56:25 +01:00
Thomas Haller
9891217a78 contrib/rpm: add option to enable LTO for RPM build 2019-02-04 10:55:25 +01:00
Thomas Haller
c77871e5e9 all: avoid bogus compiler warning about uninitialized variable
With LTO and optimizations, gcc issues several bogus
"maybe-uninitialized" warnings.

Work-around them by initializing the variables.
2019-02-04 10:55:25 +01:00
Thomas Haller
14957e914a tests: use NM_CONST_MAX() macro where a constant expression is required
Otherwise, "nm-utils/nm-test-utils.h" won't work after we
include systemd headers.
2019-02-04 10:55:25 +01:00
Thomas Haller
b52d3e2ad3 shared: add NM_CONST_MAX() macro
There is:

 1) glib's MAX() macro, which evaluates arguments multiple times,
    but yields a constant expression, if the arguments are constant.

 2) NM's NM_MAX() macro, which evaluates arguments exactly once,
    but never yields a constant expression.

 3) systemd's MAX() which is like NM_MAX().

Now, it's sensible to use

    char buf[MAX (A_CONSTANT, ANOTHER_CONSTANT)];

and this works with glib's variant (1).

However, when we include systemd headers, 1) gets redefined to 3), and
above no longer works. That is because we we don't allow VLA and systemd's
macro gives not a constant expression.

Add NM_CONST_MAX() macro which is like systemd's CONST_MAX(). It can
only operate on constant arguments.
2019-02-04 10:55:25 +01:00
Beniamino Galvani
e6cf4213a7 build: fix building with LTO
Building with link-time optimization requires some tricks explained
in [1].

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48200#c28
2019-02-04 10:55:25 +01:00
Beniamino Galvani
b114b00f0a shared: convert macro argument to lowercase 2019-02-04 10:55:25 +01:00
Thomas Haller
43a12462e0 platform/tests: increase timeout for platform tests
Seems 180 seconds is still not enough for "/link/create-many-links/1000"
tests on gitlab-CI.
2019-02-04 10:52:19 +01:00
Thomas Haller
027ef98cd4 wifi-p2p: merge branch 'th/wifi-p2p-various' (pt1)
https://github.com/NetworkManager/NetworkManager/pull/290
2019-02-01 17:34:07 +01:00
Thomas Haller
0ec30f8904 clients/trivial: move code in nm-meta-setting-desc around
Sort by name.
2019-02-01 17:02:57 +01:00
Thomas Haller
09090f2669 wifi-p2p: rename Wi-Fi P2P
After renaming the files, also rename all the content
to follow the "Wi-Fi P2P" naming scheme.
2019-02-01 17:02:57 +01:00
Thomas Haller
0420fa1f2c wifi-p2p: rename files for consistent Wi-Fi P2P naming
We named the types inconsistently:

  - "p2p-wireless" ("libnm-core/nm-setting-p2p-wireless.h")

  - "p2p" ("libnm/nm-p2p-peer.h")

  - "p2p-wifi" ("src/devices/wifi/nm-device-p2p-wifi.h")

It seems to me, "libnm/nm-p2p-peer.h" should be qualified with a "Wi-Fi"
specific name. It's not just peer-to-peer, it's Wi-Fi P2P.
Yes, there is an inconsistency now, because there is already
"libnm/nm-access-point.h".

It seems to me (from looking at the internet), that the name "Wi-Fi P2P"
is more common than "P2P Wi-Fi" -- although both are used. There is also
the name "Wi-Fi Direct". But it's not clear which name should be
preferred here, so stick to "Wi-Fi P2P".

In this first commit only rename the files. The following commit will
rename the content.
2019-02-01 17:02:57 +01:00
Thomas Haller
c8204377d6 core/device-p2p-wifi: drop unused code
If this is going to be implemented, revert the patch.
2019-02-01 17:02:57 +01:00
Thomas Haller
37da2d8a06 core/device-p2p-wifi/trival: move code
Have the class_init() function at the bottom.
2019-02-01 17:02:57 +01:00
Thomas Haller
43aa288fd8 core/p2p-wifi: various minor cleanups 2019-02-01 17:02:57 +01:00
Thomas Haller
6e45cd900c libnm/device-p2p-wifi: drop API that still needs consideration
Having synchronous API is wrong, or at least questionable.
Granted, libnm isn't currently very good about the exact order
of things to happen. However synchronous API by design delays events
while waiting for the response and hence messes up the ordering.

Maybe synchronous API should not be added to libnm.

Or at least, if we have synchronous API, we certainly need an asynchrnous
variant as well (which is still missing).

As synchronous API is not preferred, it should also be named
nm_some_thing_sync(), accompanied by nm_some_thing() and
nm_some_thing_finish(). The name for the synchronous method should be the
odd one and we shouldn't have an nm_some_thing_async(). Yes, libnm is not
consistend about that.

I am going to drop this API for the moment.
2019-02-01 17:02:57 +01:00
Thomas Haller
65c4af50c4 libnm-core/setting-p2p-wifi: drop unused code
If this is going to be implemented, revert the patch.
2019-02-01 17:02:57 +01:00
Thomas Haller
4f8852b2f2 libnm/device-p2p-wifi: drop unused code
If this is going to be implemented, revert the patch.
2019-02-01 17:02:57 +01:00
Thomas Haller
c6c41eb17a libnm: various cleanup of NMP2PPeer and NMDeviceP2PWifi
- fix leaking hw_address in finalize().

- reorder code.

- avoid double tabs in GObject property definitions.

- hide struct definitions from header.

- don't use signal slots in class structure.

- use NM_GOBJECT_PROPERTIES_DEFINE_BASE().

- add missing NM_AVAILABLE_IN_1_16 annotations.
2019-02-01 17:02:57 +01:00
Thomas Haller
41b2d8c6c9 libnm/device-p2p-wifi: cleanup peers handling
Don't reallocate peers-array nor set it to %NULL. Instead,
just emit the signal for the peers and take them out one-by-one.

I am slightly surprised, that the peers array does not need to hold
a reference on the NMP2PPeer instances. But that seems intentional.
I think, the libnm code here should be significantly reworked, but
that is for another time.

Also, delay clearing the pointers until finalize() method. For
the most part, it shouldn't make a difference. Still avoid having
the instance in a badly defined state during dispose() (which
theoretically could be called multiple times).
2019-02-01 17:02:57 +01:00
Thomas Haller
efbcac25b8 libnm-core: fix and cleanup validation of WPS-method for Wi-Fi P2P setting
The check for Wi-Fi P2P's wps-method was not correct.

While at it, move the logic to validate WPS-method flags in an utility
function.
2019-02-01 17:02:57 +01:00
Thomas Haller
ab5b6f6f81 libnm-core: minor cleanup of NMSettingP2PWireless 2019-02-01 17:02:57 +01:00
Thomas Haller
4ac6c7fdf1 all/trivial: whitespace 2019-02-01 17:02:57 +01:00
Thomas Haller
2d649305f8 cli/trivial: order code in "nm-meta-setting-desc.c" alphabetically 2019-02-01 17:02:57 +01:00
Thomas Haller
c5c509634a introspection/docs: add missing "Since" comments to Wi-Fi P2P D-Bus API 2019-02-01 17:02:57 +01:00
Thomas Haller
e491cdcf57 connectivity: merge branch 'th/connectivity-empty-response'
https://github.com/NetworkManager/NetworkManager/pull/285
2019-01-31 11:33:45 +01:00
Thomas Haller
930c7d2d22 man: better explain "connectivity.response" in "NetworkManager.conf" manual 2019-01-31 11:33:45 +01:00
Thomas Haller
477e91d753 connectivity: don't cache HTTP response for comparing connectivity response
We don't need to remember (and compare) all the bytes that we received.
We can just compare them right away, and remember how many good bytes
we received.
2019-01-31 11:33:44 +01:00
Thomas Haller
7807ffff83 connectivity: fix handling of no-response for captive portal detection
Since we only compare that the HTTP response starts with the expected
response, we need to handle the empty expected response specially
(because, every response has "" as prefix).

So now if connectivity.response is set to "" (empty) we accept:

- HTTP status code 204. We ignore and accept any extra data that we
  might receive.

- HTTP status code 200 and an empty (or no) body.
2019-01-31 11:33:44 +01:00