Commit graph

22450 commits

Author SHA1 Message Date
Thomas Haller
bbfb8a9b33 platform: suppress unnecessary logging in do_request_all_no_delayed_actions()
When we refresh all links, we clear all flags to refresh a specific
link. However, only log a message if there was anything to clear.
2019-03-13 09:03:59 +01:00
Thomas Haller
2c37a3fb1e platform: add NULL check in inline nmp_object_unref() function
This allows the compiler to see that this function does nothing for %NULL.
That is not so unusual, as we use nm_auto_nmpobj to free objects. Often
the compiler can see that these pointers are %NULL.
2019-03-13 09:03:59 +01:00
Thomas Haller
ac4a1deba0 platform: add NMPlatformObjWithIfindex helper structure for handling NMPObject types
Until now, all implemented NMPObject types have an ifindex field (from
links, addresses, routes, qdisc to tfilter).

The NMPObject structure contains a union of all available types, that
makes it easier to down-case from an NMPObject pointer to the actual
content.

The "object" field of NMPObject of type NMPlatformObject is the lowest
common denominator.

We will add NMPlatformRoutingRules (for policy routing rules). That type
won't have an ifindex field.

Hence, drop the "ifindex" field from NMPlatformObject type. But also add
a new type NMPlatformObjWithIfindex, that can represent all types that
have an ifindex.
2019-03-13 09:03:59 +01:00
Thomas Haller
667aa52f89 platform: move nmp_class_from_type() to header to allow inlining 2019-03-13 09:03:59 +01:00
Thomas Haller
8f3724a6bd platform: drop unnecessary casts from NMP_OBJECT_CAST_*() macros
It's wrong to cast here. The caller must always provide an
NMPObject pointer.
2019-03-13 09:03:59 +01:00
Thomas Haller
7259195a91 platform: unify IPv4 and IPv6 variables for NMPlatformVTableRoute 2019-03-13 09:03:59 +01:00
Thomas Haller
237a17237d shared: add nm_hash_obfuscate_ptr() helper 2019-03-13 09:03:58 +01:00
Thomas Haller
83fa4aaf3c shared: add c_list_length_is() helper 2019-03-13 09:03:58 +01:00
Thomas Haller
bfd6d608e2 contrib: set shift for less in NM-log 2019-03-13 09:03:58 +01:00
Lubomir Rintel
2e8f43e379 wwan/device-modem: don't enter available state until registered
Based on Ubuntu's "Modify NMDeviceModem's available logic" patch by
Tony Espy <espy@canonical.com>. The original commit message:

This patch modifies NMDeviceModem's available logic such that the device
is only considered available if the modem_state is
>= NM_MODEM_STATE_REGISTERED.  NMDevice defines 'available' as meaning the
device is in such a state that it can be activated.  This change prevents
NM from trying to activate a modem which is not yet ready to be activated.

Bug-Ubuntu: https://bugs.launchpad.net/bugs/1445080
https://github.com/NetworkManager/NetworkManager/pull/312
2019-03-12 16:02:04 +01:00
Thomas Haller
10276322bd shared/systemd: fix gettid() compat implementation shadowing function from glibc
On Fedora rawhide we get the following build failure:

    In file included from shared/systemd/src/basic/alloc-util.c:3:
    ./shared/systemd/sd-adapt-shared/nm-sd-adapt-shared.h:114:21: error: static declaration of 'gettid' follows non-static declaration
      114 | static inline pid_t gettid(void) {
          |                     ^~~~~~
    In file included from /usr/include/unistd.h:1170,
                     from /usr/include/glib-2.0/gio/gcredentials.h:32,
                     from /usr/include/glib-2.0/gio/gio.h:46,
                     from ./shared/nm-utils/nm-macros-internal.h:31,
                     from ./shared/nm-default.h:293,
                     from ./shared/systemd/sd-adapt-shared/nm-sd-adapt-shared.h:22,
                     from shared/systemd/src/basic/alloc-util.c:3:
    /usr/include/bits/unistd_ext.h:34:16: note: previous declaration of 'gettid' was here
       34 | extern __pid_t gettid (void) __THROW;
          |                ^~~~~~

glibc supports now gettid() call ([1]) which conflicts with our compat
implementation. Rename it.

[1] https://sourceware.org/git/?p=glibc.git;a=commit;h=1d0fc213824eaa2a8f8c4385daaa698ee8fb7c92
2019-03-11 18:17:12 +01:00
Lubomir Rintel
bf0c4e6ac2 all: codespell fixes
Codespel run with the same arguments as described in
commit 58510ed566 ('docs: misc. typos pt2').
2019-03-11 12:01:44 +01:00
Beniamino Galvani
766864c5de merge: branch 'bg/restore-ipv6-on-up-rh1548237'
https://bugzilla.redhat.com/show_bug.cgi?id=1548237
2019-03-11 10:18:50 +01:00
Beniamino Galvani
505d2adbc2 device: restore IPv6 addresses when the link comes up
When the link goes down the kernel removes IPv6 addresses from the
interface. In update_ext_ip_config() we detect that addresses were
removed externally and drop them from various internal
configurations. Don't do that if the link is down so that those
addresses will be restored again on link up.
2019-03-09 15:31:46 +01:00
Beniamino Galvani
39b7257208 core: allow ignoring addresses when intersecting ip configs
Add a new argument to nm_ip_config_* helpers to also ignore addresses
similarly to what we already do for routes. This will be used in the
next commit; no change in behavior here.
2019-03-09 15:30:22 +01:00
Beniamino Galvani
056470a4ba device: reset the ipv6 DAD counter when the link comes up
We can detect false DAD failures if the link goes down. Don't try to
prevent them, but just reset the counter if the link goes down.
2019-03-09 15:27:54 +01:00
Beniamino Galvani
72385f363c device: don't try to add IPv6LL address to a down interface
When the interface is down DAD failures becomes irrelevant and we
shouldn't try to add a link-local address even if the configuration
contains other IPv6 addresses.
2019-03-09 15:25:47 +01:00
Beniamino Galvani
d86dd9a0fe core: fix _nm_ip4_config_intersect_helper()
Fixes: 8f07b3ac4f ('ip-config: add @intersect_routes argument to intersect functions')
2019-03-09 15:25:43 +01:00
Lubomir Rintel
90fe78eb7f wwan/ofono: pass the right argument to manager proxy callback
Otherwise it will be dereferencing NULL when invoked.

Fixes: 58712c9546 ('ofono: take D-Bus proxy for ConnectionManager asynchronously')

https://github.com/NetworkManager/NetworkManager/pull/313
2019-03-08 13:40:18 +01:00
Frédéric Danis
9a71d7d273 tests: Fix variant_from_dbus() for arrays of UInt32
Using test-networkmanager-servic.py, I get the following error when
trying to add manual config with a dns address:

    Error: g-io-error-quark: Traceback (most recent call last):
      File "/usr/lib/python2.7/dist-packages/dbus/service.py", line 707, in _message_cb
        retval = candidate_method(self, *args, **keywords)
      File "tools/test-networkmanager-service.py", line 1727, in AddConnection
        return self.add_connection(con_hash)
      File "tools/test-networkmanager-service.py", line 1731, in add_connection
        con_inst = Connection(self.c_counter, con_hash, do_verify_strict)
      File "tools/test-networkmanager-service.py", line 1601, in __init__
        NmUtil.con_hash_verify(con_hash, do_verify_strict=do_verify_strict)
      File "tools/test-networkmanager-service.py", line 497, in con_hash_verify
        BusErr.raise_nmerror(e)
      File "tools/test-networkmanager-service.py", line 419, in raise_nmerror
        raise e
    Exception: Unsupported value ipv4.dns = dbus.Array([dbus.UInt32(168430090L), dbus.UInt32(218893066L)], signature=dbus.Signature('u'), variant_level=1) (Cannot convert array element to type 'u': Must be number, not Variant)

https://mail.gnome.org/archives/networkmanager-list/2019-March/msg00013.html
2019-03-07 22:48:14 +01:00
Thomas Haller
7dd44d6dc8 core: assert for valid NM_DEVICE_DEVICE_TYPE setting 2019-03-07 22:40:13 +01:00
Thomas Haller
e46e5879ea libnm,core: merge branch 'benzea/fix-wifi-p2p-device-type'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/134

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/95
2019-03-07 22:18:17 +01:00
Benjamin Berg
a6a185ba00 libnm: Fix reporting of unknown device types
nm_device_get_device_type would report the device type as it was send on
DBus, while fetching the property would mean that only a known device
types is reported.

Make both results consistent by coercing in nm_device_get_device_type
rather than when setting the property.
2019-03-07 22:17:40 +01:00
Benjamin Berg
8d9365a973 core,wifi-p2p: Fix Wi-Fi P2P device type
The device type was set to the GType rather than a new value in the
NMDeviceType enum.

Add the corresponding enum entry, fix the device type and set the
routing priority to the same value as generic devices.
2019-03-07 22:17:09 +01:00
Thomas Haller
bb25a1c805 wireguard: merge branch 'th/wireguard-import'
https://github.com/NetworkManager/NetworkManager/pull/304
2019-03-07 17:54:38 +01:00
Thomas Haller
3990c92fbf wireguard: update TODO list for WireGuard devices 2019-03-07 17:54:25 +01:00
Lubomir Rintel
c152ca37ef clients/tests: add wireguard import tests 2019-03-07 17:54:25 +01:00
Thomas Haller
a3a8583c31 cli/wireguard: add import functionality for WireGuard
Support importing ".conf" files as `wg-quick up` supports it.

`wg-quick` parses several options under "[Interface]" and
passes the remainder to `wg setconf`.

The PreUp/PreDown/PostUp/PostDown options are of course not supported.

"Table" for the moment behaves different.
2019-03-07 17:54:25 +01:00
Thomas Haller
e46ba01867 libnm: rename and expose nm_utils_base64secret_decode() in libnm
A NetworkManager client requires an API to validate and decode
a base64 secret -- like it is used by WireGuard. If we don't have
this as part of the API, it's inconvenient. Expose it.

Rename it from _nm_utils_wireguard_decode_key(), to give it a more
general name.

Also, rename _nm_utils_wireguard_normalize_key() to
nm_utils_base64secret_normalize(). But this one we keep as internal
API. The user will care more about validating and decoding the base64
key. To convert the key back to base64, we don't need a public API in
libnm.

This is another ABI change since 1.16-rc1.
2019-03-07 17:54:25 +01:00
Thomas Haller
f3ac8c6fe8 libnm: fix return value for nm_wireguard_peer_append_allowed_ip()
According to documentation, this returns a boolean indicating whether
the value is valid. Previously, it was indicating whether the instance
was modified.

Together with the @accept_invalid argument, both behaviors make some
sense. Change it, because that is also how the other setters behave.
2019-03-07 17:54:25 +01:00
Thomas Haller
8ae9aa2428 libnm: change nm_wireguard_peer_set_endpoint() API to allow validation
This is an API break since 1.16-rc1.

Similar to previous commit.
2019-03-07 17:54:25 +01:00
Thomas Haller
7962653918 libnm: change nm_wireguard_peer_set_public_key() API to allow validation
This is an API break since 1.16-rc1.

Similar to previous commit.
2019-03-07 17:54:25 +01:00
Thomas Haller
d7bc1750c1 libnm: change nm_wireguard_peer_set_preshared_key() API to allow validation
This is an API break since 1.16-rc1.

The functions like _nm_utils_wireguard_decode_key() are internal API
and not accessible to a libnm user. Maybe this should be public API,
but for now it is not.

That makes it cumbersome for a client to validate the setting. The client
could only reimplement the validation (bad) or go ahead and set invalid
value.

When setting an invalid value, the user can afterwards detect it via
nm_wireguard_peer_is_valid(), but at that point, it's not clear which
exact property is invalid.

First I wanted to keep the API conservative and not promissing too much.
For example, not promising to do any validation when setting the key.
However, libnm indeed validates the key at the time of setting it
instead of doing lazy validation later. This makes sense, so we can
keep this promise and just expose the validation result to the caller.

Another downside of this is that the API just got more complicated.
But it not provides a validation API, that we previously did not have.
2019-03-07 17:54:25 +01:00
Thomas Haller
fea0f4a5ea cli: fix completion for nmcli connection import
If we already specified "type" or "file", don't offer it for
completion again.

  $ nmcli connection import type openvpn <TAB>
  file  type
2019-03-07 17:54:25 +01:00
Thomas Haller
62b939de4e cli: add nmc_complete_strv() which takes a string array for completion that may contain NULL
This will allow for a convenient calling pattern when some elements
should be printed optionally.
2019-03-07 17:54:25 +01:00
Thomas Haller
4e399d82ac platform/wireguard: fix WGPEER_A_LAST_HANDSHAKE_TIME to use int64 typed timespec structure
The netlink API changed for WireGuard. Adjust for that.

https://git.zx2c4.com/WireGuard/commit/?id=c870c7af53f44a37814dfc76ceb8ad88e290fcd8
2019-03-07 17:54:25 +01:00
Thomas Haller
7451a6a649 core: use nm_utils_memeqzero_secret() for printing WireGuard key 2019-03-07 17:54:25 +01:00
Jason A. Donenfeld
6234e41153 shared: add nm_utils_memeqzero_secret()
[thaller@redhat.com: the code is effectively key_is_zero() by
  <Jason@zx2c4.com> (LGPL2.1+). I took it into our source tree
  and adjusted it to our style]
2019-03-07 17:54:25 +01:00
Thomas Haller
78dccb8bb9 wireguard: accept all-zero private-key, public-key and preshared-key
- For PSK, an all-zero PSK means to don't do symmetric encryption. As such,
  at first it seems a bit odd when the user sets

      - preshared-key-flags != "4 (not-required)"

      - preshared-key = AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=

  Here the user indicates that a PSK is required, but then provides an
  all-zero PSK that effectively disables it. Still, we should not reject
  such a configuration. This has the benefit that it allos the user for
  being prompted for a PSK, only to disable it by entering the all-zero key.

- For the private-key (and consequently the public-key), "public-key-flags=4"
  is rejected by libnm. A private key is always required for NetworkManager to
  configure the link. However, let's not care for all-zero keys either. If the user
  configures that, we just set that key. It's a valid setting as far as WireGuard
  (the kernel module) is concerned, so we shouldn't reject it.
2019-03-07 17:54:25 +01:00
Lubomir Rintel
9bcd634cbf utils: obey modprobe blacklist
If the user blacklisted a module we should not override their choice.

https://github.com/NetworkManager/NetworkManager/pull/311
2019-03-07 15:49:40 +01:00
Lubomir Rintel
3f75d6a9a6 merge: branch 'lr/rpm-madness'
https://github.com/NetworkManager/NetworkManager/pull/310
2019-03-07 15:29:09 +01:00
Lubomir Rintel
a1e6afc0b2 contrib/rpm: drop ldconfig scriptlets from Fedora 28+
In newer RPM file triggers in glibc package take care of this. While
these scriptlets whould do no harm there, removing them yields a tiny
theoretical performance improvement.
2019-03-07 15:28:56 +01:00
Lubomir Rintel
3326a87953 Revert "contrib/rpm: use "%ldconfig_scriptlets" for Fedora 30+"
This is utterly pointless. %ldconfig_scriptlets expand to an empty
string on Fedora 28+.

This reverts commit ad836541cb.
2019-03-07 15:28:56 +01:00
Lubomir Rintel
c10e61e21d contrib/rpm: drag in vala tools by the binary
The package's called either "vala" or "vala-tools". Sigh.
2019-03-07 15:28:56 +01:00
Lubomir Rintel
f8dde7014b Revert "contrib/rpm: require "vala" instead of "vala-tools" for Fedora 30+"
This is just plain ugly.

This reverts commit 0024485b5a.
2019-03-07 15:28:56 +01:00
Lubomir Rintel
27418b1851 Revert "contrib/rpm: remove Group tag for Fedora 30+"
Group tag is not required, though is harmless. We could either remove it,
or keep it, but there's absolutely no excuse for conditionalizing it.

Let's keep it for now, because rpm -i still prints it.

This reverts commit 1feeba6f1a.
2019-03-07 15:28:56 +01:00
Lubomir Rintel
f8578ddc2e contrib/checkpatch: check that we refer to commits properly 2019-03-07 10:55:30 +01:00
Lubomir Rintel
d551a0893e platform/linux: fix detection of IFA_FLAGS support
The condition got accidentally reversed, which means we're always
undecided and thus wrongly assuming support and never being able to set
any addresses.

This would bother the few that are struck with 3.4 android kernels. Very
few indeed, given this got unnoticed since 1.10.

Fixes: 8670aacc7c ('platform: cleanup detecting kernel support for IFA_FLAGS and IPv6LL')
2019-03-07 10:17:42 +01:00
Marco Trevisan (Treviño)
73005fcf5b nm: Fix syntax on introspection annotations
Various annotations were added using multiple colons, while only one has
to be added or g-ir-introspect will consider them part of the description

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/94
2019-03-07 10:04:41 +01:00
Thomas Haller
d804ad8119 contrib/rpm: merge branch 'th/contrib-rpm-f30'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/93
2019-03-07 09:55:08 +01:00