Commit graph

513 commits

Author SHA1 Message Date
Benjamin Berg 42e60e327f core: Add basic P2P Wi-Fi Settings
The support is rather basic and only allows connecting to a specific
peer. However, this is actually already enough for many usecases.
2019-01-27 23:45:11 +01:00
Thomas Haller c4512f839f libnm: use "libnm-systemd-shared.a" in "libnm-core.la" (and "libnm.so")
It's not yet used, but it will be. We will need nm_sd_utils_unbase64mem()
to strictly validate WireGuard settings, which contain keys in base64 encoding.

Note that we also need a stub implementation for logging. This will do
nothing for all logging from "libnm-systemd-shared.a". This makes
sense because "libnm.so" as a library should not log directly. Also,
"libnm.so" will only use a small portion of "libnm-systemd-shared.a" which
doesn't log anything. Thus this code is unused and dropped by the linker
with "--gc-sections".
2019-01-02 17:08:41 +01:00
Thomas Haller 2c537b9d21 systemd: move basic systemd library to shared/nm-utils
For better or worse, we already pull in large parts of systemd sources.

I need a base64 decode implementation (because glib's g_base64_decode()
cannot reject invalid encodings). Instead of coming up with my own or
copy-paste if from somewhere, reuse systemd's unbase64mem().

But for that, make systemd's basic bits an independent static library
first because I will need it in libnm-core.

This doesn't really change anything except making "libnm-systemd-core.la"
an indpendent static library that could be used from "libnm-core". We
shall still be mindful about which internal code of systemd we use, and only
access functionality that is exposed via "systemd/nm-sd-utils-shared.h".
2019-01-02 17:07:13 +01:00
Thomas Haller 5f945adfaf systemd: drop workaround for missing C11 header <uchar.h>
Now as we build as C11, we can us it.
2019-01-02 11:51:42 +01:00
Thomas Haller 066357aa47 build: bump C standard to (gcc's) C11
We already import systemd code which is C11. To get this even
to build, we need workaround like patching import of <uchar.h>.

Also, the libraries from c-util and nettools are C11. We cannot even
compile them in C99 mode (and didn't do that either).

It's time to bump the version. We need C11 from now on (or better: gcc's
dialect of it).

Also, note that since nettools/nacd is not optional, we could not even
build NetworkManager without a C11 compiler. So, just use it everywhere.
2019-01-02 11:51:42 +01:00
Thomas Haller ef53b47e7c shared,core: move logging enums to header "shared/nm-utils/nm-logging-fwd.h"
In core ("src/"), we use "nm-logging.h" for all logging. This dispatches
for logging to syslog, glog or systemd-journald.

If we want to log from a shared component under "shared/", we need to
use a common logging function. Add "nm-utils/nm-logging-fwd.h" for
forward declaring the used logging mechaism.

The shared library will still need to link with "src/nm-logging.c"
or an alternative implementation, depending on whether it is used
inside core or not.
2019-01-02 11:51:42 +01:00
Thomas Haller 943dcba531 shared,core: add "nm-errno.h"
This will be our extension on top of <errno.h>.

We want to use (integer) error numbers, that can both
contain native errors from <errno.h> and our own defines,
both merge in one domain. That is, we will reserve a small
range of integers for our own defines (that hopefully won't
clash with errors from <errno.h>).

We can use this at places where GError is too cumbersome to use.

The advantage is, that our error numbers extend <errno.h> and can
be mixed.

This is what "src/platform/nm-netlink.h" already does with nl_errno(). Next,
the netlink errors from there will be merged into "nm-errno.h".

Also, platform has NMPlatformError, which are a distinct set of error
numbers. But these work differently in the sense that negative values
represent codes from <errno.h> and positive numbers are our own platform
specific defines. NMPlatformError will also be merged into "nm-errno.h".

"nm-errno.h" will unify the error handling of platform and netlink,
making it more similar to what we are used to from systemd, and give
room to extend it for our own purpose.
2018-12-27 21:30:22 +01:00
Thomas Haller 9e9320cc0f systemd: merge branch systemd into master 2018-12-23 11:42:32 +01:00
Beniamino Galvani 81bc218e6d meson: add check on settings docs
Move the autotools check on settings docs to a shell script and call
it from meson too.
2018-12-12 14:38:18 +01:00
Beniamino Galvani 2e45d4ada6 build: check that the list of supported config options is up to date
Add a script run during 'make check' to verify that all config options
are in the list of supported ones.
2018-12-01 15:16:48 +01:00
Beniamino Galvani 32f4abe90b config: warn about unknown keys in config files
Emit a warning when we find an unsupported option in a configuration
file.
2018-12-01 15:16:48 +01:00
Thomas Haller 9d122e7b80 systemd: merge branch systemd into master 2018-11-23 11:38:02 +01:00
Benjamin Berg 37e8c53eee core: Introduce helper class to track connection keep alive
For P2P connections it makes sense to bind the connection to the status
of the operation that is being done. One example is that a wifi display
(miracast) P2P connection should be shut down when streaming fails for
some reason.

This new helper class allows binding a connection to the presence of a
DBus path meaning that it will be torn down if the process disappears.
2018-11-17 12:15:40 +01:00
Beniamino Galvani ca0c025486 build: dist initrd meson.build files
Fixes: b544f7243d

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/77
2018-11-15 09:25:11 +01:00
Thomas Haller 70c4e49cf6 build: create intermediate libraries of shared/nm-utils
Previously we would compile source files from shared/nm-utils
multiple times. That not only slows down compilation, but it makes it
confusing which project require exactly what.

Most of the files in shared/nm-utils are a mixed bag of utility
functions. Just build one libnm-utils-base library. Since the linker
will throw away unused parts, there is no problem that not every user
of libnm-utils-base needs everything.

Also add libnm-utils-udev, which cannot be part of libnm-utils-base as
it has an additional dependency on libudev.
2018-11-12 13:13:40 +01:00
Thomas Haller 06ccf3a64d build: move code for shared libs in Makefile.am around
Let's sort the code by the dependencies. The shared/ projects
have the least dependencies. Move to the beginning.
2018-11-12 13:12:15 +01:00
Thomas Haller 3648c58bc5 systemd: merge branch systemd into master 2018-10-28 09:31:31 +01:00
Thomas Haller ac90593cc2 man: fix "no-auto-default" state dir in NetworkManager.conf manual
Quote from `man NetworkManager.conf`:

  When the default wired connection is deleted or saved to a new
  persistent connection by a plugin, the device is added to a list in the
  file /run/NetworkManager/no-auto-default.state to prevent creating
  the default connection for that device again.

"/run" is obviously wrong. Fix it.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/33
2018-10-25 15:24:38 +02:00
Thomas Haller 168e8b9b6f build: fix check-docs.sh for out-of-tree builds
Fixes: 7a59cd2744
2018-10-25 11:08:39 +02:00
Thomas Haller 0677b51549 build: enable ibft plugin for make dist-check 2018-10-24 21:43:17 +02:00
Beniamino Galvani bc6071aed6 build: unconditionally dist ibft test files
Even if ibft support is disabled, test files should be included in
distribution.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/65
2018-10-24 21:05:29 +02:00
Thomas Haller eece5aff09 core: add "nm-sd-utils.h" to access system internal helper
We have a fork of a lot of useful systemd helper code.
However, until now we shyed away from using it aside from
the bits that we really need.

That means, although we have some really nice implementations
in our source-tree, we didn't use them. Either we were missing
them, or we had to re-implement them.

Add "nm-sd-utils.h" header to very carefully make internal
systemd API accessible to the rest of core.

This is not intended as a vehicle to access all of internal
API. Instead, this must be used with care, and only a hand picked
selection of functions must be exposed. Use with caution, but where it
makes sense.
2018-10-23 10:32:53 +02:00
Thomas Haller dfdbd1b385 shared/tests: add test for "shared/nm-utils"
"shared/nm-utils" is a loose collection of utility functions.
There is a certain aim that they can be used independently.
However, they also rely on each other.

Add a test that we can build a minimal shared library with
these tools, independent of libnm-core.
2018-10-18 12:16:55 +02:00
Thomas Haller a6add8175a shared: move nm_utils_get_monotonic_timestamp*() to shared/nm-utils.
This is independent functionality that only depends on linux API
and glib.

Note how "nm-logging" uses this for getting the timestamps. This
makes "nm-logging.c" itself dependen on "src/nm-core-utils.c",
for little reason.
2018-10-18 12:16:55 +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 7729555a59 acd: make NMAcdManager no GObject
NMAcdManager is a rather simple instance.

It does not need (thread-safe) ref-counting, in fact, having
it ref-counted makes it slighly ugly that we connect a signal,
but never bother to disconnect it (while the ref-counted instance
could outlife the signal subscriber).

We also don't need GObject signals. They have more overhead
and are less type-safe than a regular function pointers. Signals
would make sense, if there could be multiple independent listeners,
but that just doesn't make sense.

Implementing it as a plain struct is less lines of code, and less
runtime over head.

Also drop the possiblitiy to reset the NMAcdManager instance.
It wasn't needed and I think it was buggy because it wouldn't
reset the n-acd instance.

https://github.com/NetworkManager/NetworkManager/pull/213
2018-09-27 17:36:42 +02:00
Beniamino Galvani 98b4a19a53 build: meson: support $DESTDIR in installation script
Adapt the meson post-installation script to handle the $DESTDIR
variable supplied by user to specify the installation target
directory. While at it, convert the script to shell because it seems
simpler to me.
2018-09-19 16:03:32 +02:00
Lubomir Rintel 9f9609555d initrd: add configuration generator
nm-initrd-generator scans the command line for options relevant to network
configuration and creates configuration files for an early instance of
NetworkManager run from the initial ramdisk during early boot.
2018-09-18 17:40:47 +02:00
Lubomir Rintel ecc074b2f8 initrd: add command line parser 2018-09-18 17:40:47 +02:00
Lubomir Rintel b544f7243d initrd: add iBFT reader
This is loosely based on nms-ibft-reader, but with some significant
changes. Notably, it parses /sys/firmware/ibft directly instead of
iscsiadm output.

iscsiadm is not available on early boot (perhaps it's too large) and
turns out that parsing sysfs directly is easier and more
straightforwared anyways. A win-win situation.

It is not useful alone, it's in a separate commit just for the sake of
easier review.
2018-09-18 17:40:47 +02:00
Beniamino Galvani 691c71a7f2 build: allow disabling eBPF support in n-acd
Add a configure option to disable eBPF support in n-acd.

Note that, even if eBPF is not supported, n-acd requires a kernel >
3.19, which means that the setsockopt(..., SO_ATTACH_BPF) option must
be defined. To allow building on older kernels without modifying the
n-acd code, we inject the SO_ATTACH_BPF value as a preprocessor define
in the compiler the command line.
2018-09-18 15:32:36 +02:00
Beniamino Galvani d9a4b59c18 acd: adapt NM code and build options
Adapt the nm-acd-manager.c code to the new API and also tweak build
options to the new project structure.
2018-09-18 15:32:36 +02:00
Beniamino Galvani 88072c6621 build: compile the c-rbtree library 2018-09-18 15:15:34 +02:00
Beniamino Galvani 10ca2444b9 build: support meson builds in create-exports script
(cherry picked from commit 9b4bc0824c)
2018-09-13 14:35:25 +02:00
Beniamino Galvani fb0d36a883 build: add config-extra.h.meson to EXTRA_DIST
Reported-by: Michael Biebl <biebl@debian.org>
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/22
(cherry picked from commit 5ebe5efa7a)
2018-09-13 14:35:23 +02:00
Beniamino Galvani 4fd6623161 build: move paths of dhcp clients from config-extra.h to config.h
Some path variable like $(bindir), $(datadir), etc. are special for
autotools and must be handled separately through config-extra.h.

But dhcp path variables are just normal variables defined through
the configure script and should go into config.h.

(cherry picked from commit 087c367d62)
2018-09-13 14:35:15 +02:00
Thomas Haller e01f7f2c6d build: enable building both crypto backends for tests
If the library is available, let's at least compile both
crypto backends.

That is helpful when developing on crypto backends, so that
one does not have to configure the build twice.

With autotools, the build is only run during `make check`.
Not for meson, but that is generally the case with our meson
setup, that it also builds tests during the regular build step.
2018-09-04 07:38:30 +02:00
Thomas Haller 6435040881 libnm/crypto: add header "nm-crypto-impl.h" for crypto implementation
There are two aspects: the public crypto API that is provided by
"nm-crypto.h" header, and the internal header which crypto backends
need to implement. Split them.
2018-09-04 07:38:30 +02:00
Thomas Haller 4106f2968d libnm/crypto: rename libnm's crypto files
"crypto.h" did not follow our common NM style naming. Rename
the files.
2018-09-04 07:38:30 +02:00
Thomas Haller 6ee7453bc1 shared: add "nm-io-utils.h" 2018-09-04 07:38:30 +02:00
Thomas Haller b232508707 shared: add nm-secret-utils.h helper
We already had nm_free_secret() to clear the secret out
of a NUL terminated string. That works well for secrets
which are strings, it can be used with a cleanup attribute
(nm_auto_free_secret) and as a cleanup function for a
GBytes.

However, it does not work for secrets which are binary.
For those, we must also track the length of the allocated
data and clear it.

Add two new structs NMSecretPtr and NMSecretBuf to help
with that.
2018-09-04 07:38:30 +02:00
Beniamino Galvani 93f85edcce libnm-core: support private keys encrypted with AES-{192,256}-CBC
https://github.com/NetworkManager/NetworkManager/pull/189
2018-08-28 11:05:01 +02:00
Thomas Haller e3c944d565 systemd: merge branch systemd into master
https://github.com/NetworkManager/NetworkManager/pull/186
2018-08-27 10:40:34 +02:00
Beniamino Galvani d47e0beb7d ifcfg-rh: add support for 'match' setting 2018-08-11 09:41:07 +02:00
Beniamino Galvani 9b9dce9486 all: add 'match' setting
Add a new 'match' setting containing properties to match a connection
to devices. At the moment only the interface-name property is present
and, contrary to connection.interface-name, it allows the use of
wildcards.
2018-08-11 09:41:07 +02:00
Thomas Haller df30651b89 libnm, cli, ifcfg-rh: add NMSettingEthtool setting
Note that in NetworkManager API (D-Bus, libnm, and nmcli),
the features are called "feature-xyz". The "feature-" prefix
is used, because NMSettingEthtool possibly will gain support
for options that are not only -K|--offload|--features, for
example -C|--coalesce.

The "xzy" suffix is either how ethtool utility calls the feature
("tso", "rx"). Or, if ethtool utility specifies no alias for that
feature, it's the name from kernel's ETH_SS_FEATURES ("tx-tcp6-segmentation").
If possible, we prefer ethtool utility's naming.

Also note, how the features "feature-sg", "feature-tso", and
"feature-tx" actually refer to multiple underlying kernel features
at once. This too follows what ethtool utility does.

The functionality is not yet implemented server-side.
2018-08-10 10:38:19 +02:00
Javier Arteaga 1427719116 libnm: introduce NMDeviceWireGuard 2018-08-06 08:34:27 +02:00
Javier Arteaga 54df43ed52 core: introduce NMDeviceWireGuard
For now, the device only exposes partial link status (not including
peers). It cannot create new links.
2018-08-06 08:34:27 +02:00
Lubomir Rintel 457a233857 build: add a some missing dependencies
CC       src/devices/ovs/src_devices_ovs_libnm_device_plugin_ovs_la-nm-device-ovs-bridge.lo
  In file included from src/devices/ovs/nm-device-ovs-bridge.c:20:
  In file included from ./shared/nm-default.h:307:
  In file included from ./src/nm-logging.h:25:
  ./libnm-core/nm-core-types.h:28:10: fatal error: 'nm-core-enum-types.h' file not found
  #include "nm-core-enum-types.h"
           ^~~~~~~~~~~~~~~~~~~~~~
  1 error generated.

  CC       src/settings/plugins/ifupdown/src_settings_plugins_ifupdown_libnms_ifupdown_core_la-nms-ifupdown-interface-parser.lo
  In file included from src/settings/plugins/ifupdown/nms-ifupdown-interface-parser.c:23:
  In file included from ./shared/nm-default.h:307:
  In file included from ./src/nm-logging.h:25:
  ./libnm-core/nm-core-types.h:28:10: fatal error: 'nm-core-enum-types.h' file not found
  #include "nm-core-enum-types.h"
           ^~~~~~~~~~~~~~~~~~~~~~
  1 error generated.
  make: *** [Makefile:13904: src/settings/plugins/ifupdown/src_settings_plugins_ifupdown_libnms_ifupdown_core_la-nms-ifupdown-interface-parser.lo] Error 1
2018-07-26 12:49:00 +02:00
Thomas Haller 795ec17a7e cli/tests: rework clients-tests.py to combine .expected output
Instead of letting each nmcli run write an individual .expected file,
combine the output of multiple runs in one file (per test).

Advantages:

- since there is a very large number of tests, having a file for each
  tests is cumbersome. For example, since they are all added to
  $(EXTRA_DIST) (and since we use non-recursive make), autoconf can
  easily hit a length limit when processing all the file names.

- previously, whenever we added tests, all .expected files shifted
  and the diff was large. Now, there is a chance that the diff is
  smaller and more accurate.
2018-07-25 17:08:37 +02:00