Commit graph

558 commits

Author SHA1 Message Date
Thomas Haller 105d0d56d3 build: link libnm/liblibnm.la with udev library
libnm/liblibnm.la compiles "libnm/nm-device.c" and "libnm/nm-client.c",
both include libudev.h.

Let's explicitly link this library with libudev.
2019-05-22 20:04:08 +02:00
Thomas Haller 09557fa69d build: introduce libnm/liblibnm.la as static library for libnm/libnm.la
We have "src/libNetworkManager.la" which is an intermediate static
library containing everything that ends up in "src/NetworkManager".

Likewise, add "libnm/liblibnm.la" to be the static library that contains
everything from "libnm/libnm.la".

The point of these libraries is to tie everything together that is used
by "src/NetworkManager" and "libnm/libnm.la" so that it also can be used
by unit-tests. Thereby, the unit tests will link statically against the
code of libnm. The problem is that the unit tests also want to access
internal functionality of libnm that is not accessible when dynamically
linking.

In part, this new library replaces "libnm/libnm-utils.la". The previous
name was confusing, because to us everything is an "utils", and it's
unclear what the purpose of that library was. Now the purpose should be
a bit clearer: liblibnm.la is a step before libnm.la, similar to what
libNetworkManager.la is to NetworkManager.
2019-05-22 20:04:08 +02:00
Thomas Haller 57e21dc889 build: style cleanups of Makefile.am 2019-05-22 20:04:08 +02:00
Thomas Haller 2946d07085 shared: implement _nm_utils_monotonic_timestamp_initialized() in "nm-logging-stub.c" 2019-05-22 20:04:08 +02:00
Thomas Haller 5c0dd32622 src/tests: rename core's "test-general*" to "test-core*" 2019-05-19 14:41:00 +02:00
Thomas Haller fbe2fdd167 libnm/tests: rename libnm's "test-general" to "test-libnm" 2019-05-19 14:41:00 +02:00
Thomas Haller 0c7bc1a5d9 clients/tests: rename clients/common's "test-general" to "test-clients-common" 2019-05-19 14:00:16 +02:00
Thomas Haller c99bbc99b0 wifi/tests: rename Wi-Fi's "test-general" to "test-devices-wifi"
We already have 4 other tests that are named "test-general". Rename.
2019-05-19 11:28:53 +02:00
Thomas Haller d27f6b9d0a keyfile/tests: rename core's "test-keyfile" to "test-keyfile-settings"
We already have "libnm-core/tests/test-keyfile.c" from which we build
"test-keyfile".

Our test binaries should be named the following:

- "*/tests/test-*"

- the test binary "*/tests/test-*" should be build from a source file
  "*/tests/test-*.c". Meaning: the source's and executable's name should
  correspond.

- test binaries should be named uniquely. Also, because older meson
  versions don't like having the same binary name more than once.

Rename to avoid the duplicate name.
2019-05-19 11:25:59 +02:00
Thomas Haller 041aa3d605 platform/tests: rename platform's "test-general.c"
Older versions of meson don't like building multiple artifacts
with the same name (even if they are in different directories). We
have multiple tests called "test-general.c", and it would be natural
to compile a test binary of the same name.

  Meson encountered an error in file src/tests/meson.build, line 14, column 2:
  Tried to create target "test-general", but a target of that name already exists.

It's generally a bad idea to have in our source tree multiple files with the
same name. Rename the test.

Fixes: 16cd84d346 ('build/meson: rename platform tests to use same name as autotools'):
2019-05-18 11:37:47 +02:00
Thomas Haller ad142e1945 build: remove duplicate and unused RUNDIR define 2019-05-17 21:24:18 +02:00
Thomas Haller 655e6bb1e3 shared: add "shared/nm-glib-aux/nm-dbus-aux.h" 2019-05-12 09:56:36 +02:00
Thomas Haller 8c2fda7ca0 shared: add "shared/nm-glib-aux/nm-keyfile-aux.h" 2019-05-07 16:41:21 +02:00
Lubomir Rintel e33a995db1 build: fix an out-of-tree build
make[3]: Entering directory 'NetworkManager/_build/sub'
    CC       clients/cli/nmcli-common.o
  cc1: error: ./clients/common: No such file or directory [-Werror=missing-include-dirs]
  cc1: all warnings being treated as errors

The only generated header in $builddir/clients/common is settings-docs.h
and only libnmc.la needs it. Include the directory on the command line
only when we know it exists.
2019-05-03 11:04:34 +02:00
Lubomir Rintel a95b674c39 build: install dispatcher dirs in /usr
The dispatcher looks there for scripts now. This actually doesn't break
the RPM build, since it doesn't mind extra empty directories in
buildroot. Good.
2019-04-26 22:07:30 +02:00
Thomas Haller 7a25f67af7 shared/tests: add tests for libnm-core-aux
These tests cannot (easily) be under "shared/nm-libnm-core-aux/tests"
because libnm/libnm-core requires code under shared while
"nm-libnm-core-aux" requires libnm/libnm-core. With autotools that is
not problem, but with meson we include sub directories in a particular
order and there is no way to foward declare stuff (AFAIK). To avoid
the circular dependency, add the tests to "clients/common/tests", which
is always built last.
2019-04-25 07:47:37 +02:00
Thomas Haller 14b94e6adf shared: add "nm-libnm-core-aux/nm-libnm-core-aux.h" 2019-04-25 07:45:31 +02:00
Thomas Haller af07ed01c0 shared: build helper "libnm-libnm-core-{intern|aux}.la" library for libnm-core
"libnm-core" implements common functionality for "NetworkManager" and
"libnm".

Note that clients like "nmcli" cannot access the internal API provided
by "libnm-core". So, if nmcli wants to do something that is also done by
"libnm-core", , "libnm", or "NetworkManager", the code would have to be
duplicated.

Instead, such code can be in "libnm-libnm-core-{intern|aux}.la".
Note that:

  0) "libnm-libnm-core-intern.la" is used by libnm-core itsself.
     On the other hand, "libnm-libnm-core-aux.la" is not used by
     libnm-core, but provides utilities on top of it.

  1) they both extend "libnm-core" with utlities that are not public
     API of libnm itself. Maybe part of the code should one day become
     public API of libnm. On the other hand, this is code for which
     we may not want to commit to a stable interface or which we
     don't want to provide as part of the API.

  2) "libnm-libnm-core-intern.la" is statically linked by "libnm-core"
     and thus directly available to "libnm" and "NetworkManager".
     On the other hand, "libnm-libnm-core-aux.la" may be used by "libnm"
     and "NetworkManager".
     Both libraries may be statically linked by libnm clients (like
     nmcli).

  3) it must only use glib, libnm-glib-aux.la, and the public API
     of libnm-core.
     This is important: it must not use "libnm-core/nm-core-internal.h"
     nor "libnm-core/nm-utils-private.h" so the static library is usable
     by nmcli which couldn't access these.

Note that "shared/nm-meta-setting.c" is an entirely different case,
because it behaves differently depending on whether linking against
"libnm-core" or the client programs. As such, this file must be compiled
twice.
2019-04-18 18:59:09 +02:00
Thomas Haller 8183335878 shared: move "nm-dbus-compat.h" header to "nm-std-aux/nm-dbus-compat.h" 2019-04-18 18:59:09 +02:00
Thomas Haller 80db06f768 shared: move most of "shared/nm-utils" to "shared/nm-glib-aux"
From the files under "shared/nm-utils" we build an internal library
that provides glib-based helper utilities.

Move the files of that basic library to a new subdirectory
"shared/nm-glib-aux" and rename the helper library "libnm-core-base.la"
to "libnm-glib-aux.la".

Reasons:

 - the name "utils" is overused in our code-base. Everything's an
   "utils". Give this thing a more distinct name.

 - there were additional files under "shared/nm-utils", which are not
   part of this internal library "libnm-utils-base.la". All the files
   that are part of this library should be together in the same
   directory, but files that are not, should not be there.

 - the new name should better convey what this library is and what is isn't:
   it's a set of utilities and helper functions that extend glib with
   funcitonality that we commonly need.

There are still some files left under "shared/nm-utils". They have less
a unifying propose to be in their own directory, so I leave them there
for now. But at least they are separate from "shared/nm-glib-aux",
which has a very clear purpose.
2019-04-18 18:59:09 +02:00
Thomas Haller 2973d68253 shared: move udev helper to separate directory "shared/nm-udev-aux"
We built (among others) two libraries from the sources in "shared/nm-utils":
"libnm-utils-base.la" and "libnm-utils-udev.la".

It's confusing. Instead use directories so there is a direct
correspondence between these internal libraries and the source files.
2019-04-18 18:58:28 +02:00
Thomas Haller b434b9ec07 shared: split C-only helper "shared/nm-std-aux" utils out of "shared/nm-utils"
"shared/nm-utils" contains general purpose utility functions that only
depend on glib (and extend glib with some helper functions).

We will also add code that does not use glib, hence it would be good
if the part of "shared/nm-utils" that does not depend on glib, could be
used by these future projects.

Also, we use the term "utils" everywhere. While that covers the purpose
and content well, having everything called "nm-something-utils" is not
great. Instead, call this "nm-std-aux", inspired by "c-util/c-stdaux".
2019-04-18 18:57:24 +02:00
Lubomir Rintel 5801f89f4d all: goodbye libnm-glib
This removes libnm-glib, libnm-glib-vpn, and libnm-util for good.
The it has been replaced with libnm since NetworkManager 1.0, disabled
by default since 1.12 and no up-to-date distributions ship it for years
now.

Removing the libraries allows us to:

* Remove the horrible hacks that were in place to deal with accidental use
  of both the new and old library in a single process.
* Relief the translators of maintenance burden of similar yet different
  strings.
* Get rid of known bad code without chances of ever getting fixed
  (libnm-glib/nm-object.c and libnm-glib/nm-object-cache.c)
* Generally lower the footprint of the releases and our workspace

If there are some really really legacy users; they can just build
libnm-glib and friends from the NetworkManager-1.16 distribution. The
D-Bus API is stable and old libnm-glib will keep working forever.

https://github.com/NetworkManager/NetworkManager/pull/308
2019-04-16 15:52:27 +02:00
Thomas Haller 8d911088ab build: include c-stdaux in c-util and nettools tools
This is now a dependency for the internal tools. Add the
include directive first, before upgrading the libraries.
2019-04-14 12:59:48 +02:00
Beniamino Galvani 366f9867eb build: fix build with sanitizers
Add missing linker flags.
2019-04-12 11:19:58 +02:00
Thomas Haller 0d3bf9729a dispatcher/tests: cleanup tests
- use cleanup macros everywhere.

- In particular use nm_auto_clear_variant_builder to free the
  GVariantBuilder in the error cases. Note that the error cases
  anyway are asserted against, so during a normal test run there
  was no leak. But we should not write software like that.

- use nm_utils_strsplit_set_with_empty() instead of g_strsplit_set().
  We should use our variant also in unit-tests, because that way the
  function gets more test coverage. And it likely performs better
  anyway.
2019-04-12 11:10:07 +02:00
Thomas Haller 917cd3eb03 systemd: merge branch systemd into master 2019-04-04 09:49:37 +02:00
Lubomir Rintel b027723e00 Revert "all: goodbye libnm-glib"
We need this for a little little longer :(

This reverts commit 1de8383ad9.
2019-04-03 08:52:38 +02:00
Beniamino Galvani 5b5a768b69 clients: only ask secrets for settings that require them
When nmcli needs secrets for a connection it asks them for every known
setting. nmtui is a bit smarter and asks them only for settings that
actually exist in the connection. Make a step further and let clients
ask secrets only for setting that exist *and* have any secret
property. This decreases the number of D-Bus calls when editing or
showing a connection with secrets.

https://bugzilla.redhat.com/show_bug.cgi?id=1506536
https://github.com/NetworkManager/NetworkManager/pull/327
2019-04-02 11:20:28 +02:00
Thomas Haller 4d46804437 ifcfg-rh: add support for routing rules as "ROUTING_RULE_#" keys
initscripts support rule-* and rule6-* files for that.

Up until now, we ignored these files for the most part, except if
a user configured such files, the profile could not contain any static
routes (or specify a route-table setting). This also worked together
with the dispatcher script "examples/dispatcher/10-ifcfg-rh-routes.sh".

We cannot now start taking over that file format for rules. It might
break existing setups, because we can never fully understand all rules as
they are understood by iproute2. Also, if a user has a rule/rule6 file and
uses NetworkManager successfully today, then clearly there is a script
in place to make that work. We must not break that when adding rules
support.

Hence, store routing rules as numbered "ROUTING_RULE_#" and
"ROUTING_RULE6_#" keys.

Note that we use different keys for IPv4 and IPv6. The main reason is
that the string format is mostly compatible with iproute2. That means,
you can take the value and pass it to `ip rule add`.
However, `ip rule add` only accepts IPv4 rules. For IPv6 rules, the user
needs to call `ip -6 rule add`. If we would use the same key for IPv4
and IPv6, then it would be hard to write a script to do this.
Also, nm_ip_routing_rule_from_string() does take the address family as
hint in this case. This makes

  ROUTING_RULE_1="pref 1"
  ROUTING_RULE6_1="pref 1"

automatically determine that address families. Otherwise, such
abbreviated forms would be not valid.
2019-03-27 16:23:30 +01:00
Thomas Haller d0f1e68b3e shared: add "shared/nm-libnm-core-utils.h" utils
We have code in "shared/nm-utils" which are general purpose
helpers, independent of "libnm", "libnm-core", "clients" and "src".

We have shared code like "shared/nm-ethtool-utils.h" and
"shared/nm-meta-setting.h", which is statically linked, shared
code that contains libnm related helpers. But these helpers already
have a specific use (e.g. they are related to ethtool or NMSetting
metadata).

Add a general purpose helper that:

 - depends (and extends) libnm-core

 - contains unrelated helpers

 - can be shared (meaning it will be statically linked).

 - this code can be used by any library user of "libnm.so"
   (nmcli, nm-applet) and by "libnm-core" itself. Thus, "src/"
   and "libnm/" may also use this code indirectly, via "libnm-core/".
2019-03-25 09:12:32 +01:00
Lubomir Rintel cfcd746260 settings: remove README
It is out of date and doesn't seem to serve any real purpose.
2019-03-20 08:53:10 +01:00
Lubomir Rintel 1de8383ad9 all: goodbye libnm-glib
This removes libnm-glib, libnm-glib-vpn, and libnm-util for good.
The it has been replaced with libnm since NetworkManager 1.0, disabled
by default since 1.12 and no up-to-date distributions ship it for years
now.

Removing the libraries allows us to:

* Remove the horrible hacks that were in place to deal with accidental use
  of both the new and old library in a single process.
* Relief the translators of maintenance burden of similar yet different
  strings.
* Get rid of known bad code without chances of ever getting fixed
  (libnm-glib/nm-object.c and libnm-glib/nm-object-cache.c)
* Generally lower the footprint of the releases and our workspace

If there are some really really legacy users; they can just build
libnm-glib and friends from the NetworkManager-1.16 distribution. The
D-Bus API is stable and old libnm-glib will keep working forever.

https://github.com/NetworkManager/NetworkManager/pull/308
2019-03-19 17:15:15 +01:00
Thomas Haller b8398b9e79 platform: add NMPRulesManager for syncing routing rules
Routing rules are unlike addresses or routes not tied to an interface.
NetworkManager thinks in terms of connection profiles. That works well
for addresses and routes, as one profile configures addresses and routes
for one device. For example, when activating a profile on a device, the
configuration does not interfere with the addresses/routes of other
devices. That is not the case for routing rules, which are global, netns-wide
entities.

When one connection profile specifies rules, then this per-device configuration
must be merged with the global configuration. And when a device disconnects later,
the rules must be removed.

Add a new NMPRulesManager API to track/untrack routing rules. Devices can
register/add there the routing rules they require. And the sync method will
apply the configuration. This is be implemented on top of NMPlatform's
caching API.
2019-03-13 09:47:37 +01:00
Lubomir Rintel c152ca37ef clients/tests: add wireguard import tests 2019-03-07 17:54:25 +01:00
Thomas Haller d8070c7a14 build: fix build dependency for generating libnm enum headers before building nm-online
CC       clients/nm_online-nm-online.o
    In file included from ./shared/nm-default.h:311:0,
                     from clients/nm-online.c:34:
    ./libnm/NetworkManager.h:60:10: fatal error: nm-enum-types.h: No such file or directory
     #include "nm-enum-types.h"
              ^~~~~~~~~~~~~~~~~
2019-03-05 10:18:42 +01:00
Thomas Haller b521f426ab libnm,cli: add NMSettingWireGuard
For now only add the core settings, no peers' data.

To support peers and the allowed-ips of the peers is more complicated
and will be done later. It's more complicated because these are nested
lists (allowed-ips) inside a list (peers). That is quite unusual and to
conveniently support that in D-Bus API, in keyfile format, in libnm,
and nmcli, is a effort.
Also, it's further complicated by the fact that each peer has a secret (the
preshared-key). Thus we probably need secret flags for each peer, which
is a novelty as well (until now we require a fixed set of secrets per
profile that is well known).
2019-02-22 11:00:10 +01:00
Beniamino Galvani 787a18c467 systemd: merge branch systemd into master 2019-02-20 19:18:52 +01:00
Thomas Haller de1741e2d0 systemd: merge branch systemd into master 2019-02-06 09:28:36 +01:00
Thomas Haller 8cb2d193e4 build/autotools: dist test files for ifcfg-rh tests
Fixes: 386e75ee04
2019-02-05 12:54:03 +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
Benjamin Berg 6420a2c1fd libnm: Add NMDeviceP2PWifi 2019-01-27 23:45:12 +01:00
Benjamin Berg adb8338408 libnm: Add class to handle P2P peers
This adds the introspection data and P2P peer handling to libnm. To be
usable the P2P device handling is also needed.
2019-01-27 23:45:12 +01:00
Benjamin Berg 00e64d1332 core/devices: Add P2P Wifi device and peer tracking
This only adds the new device type and simple peer list handling.
2019-01-27 23:45:12 +01:00
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