Commit graph

1035 commits

Author SHA1 Message Date
Francesco Giudici d607f28899 docs: fix typo in nm-settings-ifcfg-rh:dhcp-client-id doc
Fixes: 4b51f5b1a8
2018-04-06 18:53:49 +02:00
Thomas Haller ab8312a18e checkpoint: generate GIR information for NMCheckpointCreateFlags
Note that this changes API for checkpoint_create_async() in Python
via GIR. Previously it would require an integer argument, now a flags
argument. But this API is still unstable, it will be introduced with
1.12.
2018-04-04 14:02:13 +02:00
Thomas Haller 5c283356a1 checkpoint: allow overlapping checkpoints
Introduce a new flag NM_CHECKPOINT_CREATE_FLAG_ALLOW_OVERLAPPING
that allows the creation of overlapping checkpoints. Before, and
by default, checkpoints that reference a same device conflict,
and creating such a checkpoint failed.

Now, allow this. But during rollback automatically destroy all
overlapping checkpoints that were created after the checkpoint
that is about to rollback.

With this, you can create a series of checkpoints, and rollback them
individually. With the restriction, that if you once rolled back to an
older checkpoint, you no longer can roll"forward" to a younger one.

What this implies and what is new here, is that the checkpoint might be
automatically destroyed by NetworkManager before the timeout expires. When
the user later would try to manually destroy/rollback such a checkpoint, it
would fail because the checkpoint no longer exists.
2018-04-04 14:02:13 +02:00
Thomas Haller e49a32936c all: use nm_utils_hash_keys_to_array() 2018-03-27 09:58:00 +02:00
Francesco Giudici 0ed5cd5442 libnm-core: trivial: fix indentation 2018-03-26 18:03:07 +02:00
Thomas Haller fc813d1c9e libnm: don't use deprecated tags for GOobject introspection
https://bugzilla.gnome.org/show_bug.cgi?id=744250
https://bugzilla.gnome.org/show_bug.cgi?id=794658
2018-03-26 12:50:43 +02:00
Jiří Klimeš aea3593a43 libnm: don't use deprecated tags for GOobject introspection
Top level tags are deprecated in favour of identifier annotations.
https://mail.gnome.org/archives/commits-list/2013-October/msg03220.html
https://wiki.gnome.org/action/show/Projects/GObjectIntrospection/Annotations?action=show&redirect=GObjectIntrospection%2FAnnotations#Type_signature

Signed-off-by: Jiří Klimeš <jklimes@redhat.com>

https://bugzilla.gnome.org/show_bug.cgi?id=744250
2018-03-26 12:46:22 +02:00
Corentin Noël 468a019333 gobject-introspection: made several fixes to the annotations
https://bugzilla.gnome.org/show_bug.cgi?id=794658
2018-03-26 12:45:49 +02:00
Thomas Haller 39ab38a04d core/platform: add support for TUN/TAP netlink support and various cleanup
Kernel recently got support for exposing TUN/TAP information on netlink
[1], [2], [3]. Add support for it to the platform cache.

The advantage of using netlink is that querying sysctl bypasses the
order of events of the netlink socket. It is out of sync and racy. For
example, platform cache might still think that a tun device exists, but
a subsequent lookup at sysfs might fail because the device was deleted
in the meantime. Another point is, that we don't get change
notifications via sysctl and that it requires various extra syscalls
to read the device information. If the tun information is present on
netlink, put it into the cache. This bypasses checking sysctl while
we keep looking at sysctl for backward compatibility until we require
support from kernel.

Notes:

- we had two link types NM_LINK_TYPE_TAP and NM_LINK_TYPE_TUN. This
  deviates from the model of how kernel treats TUN/TAP devices, which
  makes it more complicated. The link type of a NMPlatformLink instance
  should match what kernel thinks about the device. Point in case,
  when parsing RTM_NETLINK messages, we very early need to determine
  the link type (_linktype_get_type()). However, to determine the
  type of a TUN/TAP at that point, we need to look into nested
  netlink attributes which in turn depend on the type (IFLA_INFO_KIND
  and IFLA_INFO_DATA), or even worse, we would need to look into
  sysctl for older kernel vesions. Now, the TUN/TAP type is a property
  of the link type NM_LINK_TYPE_TUN, instead of determining two
  different link types.

- various parts of the API (both kernel's sysctl vs. netlink) and
  NMDeviceTun vs. NMSettingTun disagree whether the PI is positive
  (NM_SETTING_TUN_PI, IFLA_TUN_PI, NMPlatformLnkTun.pi) or inverted
  (NM_DEVICE_TUN_NO_PI, IFF_NO_PI). There is no consistent way,
  but prefer the positive form for internal API at NMPlatformLnkTun.pi.

- previously NMDeviceTun.mode could not change after initializing
  the object. Allow for that to happen, because forcing some properties
  that are reported by kernel to not change is wrong, in case they
  might change. Of course, in practice kernel doesn't allow the device
  to ever change its type, but the type property of the NMDeviceTun
  should not make that assumption, because, if it actually changes, what
  would it mean?

- note that as of now, new netlink API is not yet merged to mainline Linus
  tree. Shortcut _parse_lnk_tun() to not accidentally use unstable API
  for now.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1277457
[2] https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git/commit/?id=1ec010e705934c8acbe7dbf31afc81e60e3d828b
[3] https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=118eda77d6602616bc523a17ee45171e879d1818

https://bugzilla.redhat.com/show_bug.cgi?id=1547213
https://github.com/NetworkManager/NetworkManager/pull/77
2018-03-20 11:59:52 +01:00
Thomas Haller 062f86d88e secret-agent: don't use generated NMDBusSecretAgent proxy
The generated code is really just a thin wrapper around direct
GDBusProxy calls. GDBusProxy is reasonably convenient to use directly,
drop this wrapper.

We also don't use a generated wrapper for other cases where
NetworkManager acts as a D-Bus client. There is no reason to
do it in this case.

While the nmdbus_*() functions that we were using are small wrappers,
we also created a NMDBusSecretAgent instance, and hence several other
functions and symbols are used as well. It's unnecessary.

This saves 8552 bytes for NetworkManager binary (2817944 vs. 2809392
bytes for contrib/rpm on x86_64).
2018-03-12 18:02:20 +01:00
Francesco Giudici 39fde61a5a man: drop duplicate text from dhcp-client-id description
Fixes: 62a7863979
2018-03-06 15:25:48 +01:00
Thomas Haller 2aebb343d9 libnm/keyfile: refactor cert_parser() by merge helper functions
The parsing of the certificate consists of a series of checks, and if a
check matches, we determine the type and are done.

Moving these checks to different functions (that are only called once)
makes it more complicated to understand what really happens. Merge them
all together.
2018-03-03 16:57:42 +01:00
Thomas Haller cf774a1bfc libnm/keyfile: refactor error paths for cert_parser()
Refactor cert_parser() to return early.

Also, rework handle_as_scheme() and handle_as_path() to check for
success first and return early. This in the next step will allow
to merge the functions.
2018-03-03 16:57:42 +01:00
Thomas Haller 3d6a2b8d6b libnm/keyfile/trivial: rename local variables in preparation of refactoring 2018-03-03 16:57:42 +01:00
Lubomir Rintel 66ae0cc306 core/connection: don't emit Updated on Connection.GetSecrets
The secrets are transient -- when they are loaded into the connections and
subsequently cleared the connection itself doesn't change. The Update
signal is to be emmited only on explicit Update()/Update2() or
ClearSecrets() which is already the case.

Apart from Update being wrong, it has the ill effect of causing libnm to
drop secrets from the cached connection.
2018-02-20 12:16:21 +01:00
Thomas Haller 62a7863979 dhcp: add support for special ipv4.dhcp-client-id types "mac", "perm-mac", and "stable" 2018-02-15 16:24:28 +01:00
Thomas Haller f5bedd3655 device: make ipv4.dhcp-client-id configurable via a global default 2018-02-15 16:23:20 +01:00
Beniamino Galvani 936e0a51fe libnm-core: don't use RTLD_DEEPBIND when building with asan
The address sanitizer is not compatible [1] with libraries dynamically
opened using RTLD_DEEPBIND: disable the flag when building with asan.

[1] https://github.com/google/sanitizers/issues/611
2018-02-15 15:34:03 +01:00
Thomas Haller 28da0154fc all: drop trailing spaces 2018-02-07 13:32:04 +01:00
Thomas Haller e4839accf5 all: replace non-leading tabs with spaces
We commonly only allow tabs at the beginning of a line, not
afterwards. The reason for this style is so that the code
looks formated right with tabstop=4 and tabstop=8.
2018-02-07 13:32:04 +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 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 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 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
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
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 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
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
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
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
Thomas Haller e5f3c0fc8a libnm: only include "nm-jansson.h" from "nm-json.h"
"nm-utils/nm-jansson.h" and thus <jansson.h> must be included only
after "nm-json.h". Enforce that by never including them directly,
except from "nm-json.h" itself.
2018-01-16 14:47:24 +01:00
Thomas Haller ee56c9250f libnm: add include guard to nm-json.h 2018-01-16 14:47:24 +01:00
Thomas Haller 2888778480 libnm: fix spelling for NM_JAONSSON_C define 2018-01-16 14:47:24 +01:00
Thomas Haller b6b6baa773 libnm: rename "libnm-core/nm-jansson.h" to "libnm-core/nm-json.h"
We already have "shared/nm-utils/nm-jansson.h". Avoid reusing the same file name.
2018-01-16 14:47:24 +01:00
Thomas Haller 950a14128b libnm/trivial: don't use non-leading tabs 2018-01-16 14:47:24 +01:00
Francesco Giudici 2c99eba42f libnm-core: team: fix runner sys_prio default value 2018-01-15 18:27:10 +01:00
Francesco Giudici c6448f724b cli: get team defaults from setting header files
this allows centralizing default values definition and allows quicker
and safer update of default values.
2018-01-15 18:27:10 +01:00
Francesco Giudici 112f8bd5af libnm-core: update team.runner description
https://bugzilla.redhat.com/show_bug.cgi?id=1533799
2018-01-12 14:22:43 +01:00
Beniamino Galvani e91f1a7d2a dns: introduce routing domains
Similarly to what systemd-resolved does, introduce the concept of
"routing" domain, which is a domain in the search list that is used
only to decide the interface over which a query must be forwarded, but
is not used to complete unqualified host names. Routing domains are
those starting with a tilde ('~') before the actual domain name.

Domains without the initial tilde are used both for completing
unqualified names and for the routing decision.
2018-01-12 13:42:08 +01:00
Iñigo Martínez 50930ed19a meson: Use string variables extensively
The strings holding the names used for libraries have also been
moved to different variables. This way they would be less error
as these variables can be reused easily and any typing error
would be quickly detected.
2018-01-10 12:22:55 +01:00
Iñigo Martínez 5e16bcf268 meson: Improve dependency system
Some targets are missing dependencies on some generated sources in
the meson port. These makes the build to fail due to missing source
files on a highly parallelized build.

These dependencies have been resolved by taking advantage of meson's
internal dependencies which can be used to pass source files,
include directories, libraries and compiler flags.

One of such internal dependencies called `core_dep` was already in
use. However, in order to avoid any confusion with another new
internal dependency called `nm_core_dep`, which is used to include
directories and source files from the `libnm-core` directory, the
`core_dep` dependency has been renamed to `nm_dep`.

These changes have allowed minimizing the build details which are
inherited by using those dependencies. The parallelized build has
also been improved.
2018-01-10 12:20:17 +01:00
Thomas Haller 9d92848ada libnm: rename MDns flag UNKNOWN to DEFAULT
"UNKNOWN" is not a good name. If you don't set the property
in the connection explicitly, it should be "DEFAULT".

Also, make "DEFAULT" -1. For one, that ensures that the enum's
underlying integer type is signed. Otherwise, it's cumbersome
to test "if (mdns >= DEFAULT)" because in case of unsigned types,
the compiler will warn about the check always being true.
Also, it allows for "NO" to be zero. These are no strong reasons,
but I tend to think this is better.

Also, don't make the property of NMSettingConnection a CONSTRUCT property.
Initialize the default manually in the init function.

Also, order the numeric values so that DEFAULT < NO < RESOLVE < YES with
YES being largest because it enables *the most*.
2018-01-09 14:24:53 +01:00
Thomas Haller eec907b35a libnm: verify value for connection.mdns
Also, keep the internal variable of type int. The only way to set the
field is via the GObject property setter. At that point, don't yet
cast the integer type to enum.
2018-01-09 14:24:53 +01:00
Ismo Puustinen 2e2ff6f27a mdns: add new connection property.
Add support for mDNS as a connection-level property. Update ifcfg-rh and
keyfile plugins to support it.
2018-01-09 14:24:53 +01:00
Thomas Haller 25ade39752 tests: use NMTST_EXPECT*() macros
Tests are commonly created via copy&paste. Hence, it's
better to express a certain concept explicitly via a function
or macro. This way, the implementation of the concept can be
adjusted at one place, without requiring to change all the callers.

Also, the macro is shorter, and brevity is better for tests
so it's easier to understand what the test does. Without being
bothered by noise from the redundant information.

Also, the macro knows better which message to expect. For example,
messages inside "src" are prepended by nm-logging.c with a level
and a timestamp. The expect macro is aware of that and tests for it

  #define NMTST_EXPECT_NM_ERROR(msg)      NMTST_EXPECT_NM (G_LOG_LEVEL_MESSAGE, "*<error> [*] "msg)

This again allows the caller to ignore this prefix, but still assert
more strictly.
2018-01-08 12:38:54 +01:00
Thomas Haller 22ef6a507a build: refine the NETWORKMANAGER_COMPILATION define
Note that:

 - we compile some source files multiple times. Most notably those
   under "shared/".

 - we include a default header "shared/nm-default.h" in every source
   file. This header is supposed to setup a common environment by defining
   and including parts that are commonly used. As we always include the
   same header, the header must behave differently depending
   one whether the compilation is for libnm-core, NetworkManager or
   libnm-glib. E.g. it must include <glib/gi18n.h> or <glib/gi18n-lib.h>
   depending on whether we compile a library or an application.

For that, the source files need the NETWORKMANAGER_COMPILATION #define
to behave accordingly.

Extend the define to be composed of flags. These flags are all named
NM_NETWORKMANAGER_COMPILATION_WITH_*, they indicate which part of the
build are available. E.g. when building libnm-core.la itself, then
WITH_LIBNM_CORE, WITH_LIBNM_CORE_INTERNAL, and WITH_LIBNM_CORE_PRIVATE
are available. When building NetworkManager, WITH_LIBNM_CORE_PRIVATE
is not available but the internal parts are still accessible. When
building nmcli, only WITH_LIBNM_CORE (the public part) is available.
This granularily controls the build.
2018-01-08 12:38:53 +01:00
Lubomir Rintel cd476e4dc9 core: load jansson on demand
Avoid using it if the symbols clash is detected.
2018-01-08 10:15:29 +01:00
Beniamino Galvani da4c9e51a0 ip-tunnel: add support for tunnel flags
Implement support for IP tunnel flags. Currently only some IPv6 tunnel
flags are supported. Example:

 # nmcli connection add type ip-tunnel mode ip6ip6 \
   ip-tunnel.flags ip6-ign-encap-limit,ip6-use-orig-tclass \
   ifname abc ip-tunnel.parent ens8 ipv4.method disabled \
   ipv6.method manual ipv6.address ::8888 remote ::42

 # ip -d l
  61: abc@ens8: <NOARP,UP,LOWER_UP> mtu 1460 qdisc noqueue ...
    link/tunnel6 :: brd ::42 promiscuity 0
    ip6tnl ip6ip6 remote ::42 local :: dev ens8 encaplimit none
    hoplimit 0 tclass inherit ...

https://bugzilla.gnome.org/show_bug.cgi?id=791846
2018-01-05 18:25:08 +01:00
Thomas Haller 686afe531a dhcp: cleanup handling of ipv4.dhcp-client-id and avoid assertion failure
The internal client asserts that the length of the client ID is not more
than MAX_CLIENT_ID_LEN. Avoid that assert by truncating the string.

Also add new nm_dhcp_client_set_client_id_*() setters, that either
set the ID based on a string (in our common dhclient specific
format), or based on the binary data (as obtained from systemd client).

Also, add checks and assertions that the client ID which is
set via nm_dhcp_client_set_client_id() is always of length
of at least 2 (as required by rfc2132, section-9.14).
2018-01-04 18:53:05 +01:00
Thomas Haller 3a73a15863 shared/tests: improve tests for c_list_sort()
Refactor the tests. Especially, test sorting lists with a
length of up to 10000 elements (the actual length is determined
randomly on each run).
2018-01-03 16:02:13 +01:00