Commit graph

754 commits

Author SHA1 Message Date
Thomas Haller a03a03fbe9
libnm/tests: add static helper library "src/libnm-client-test/"
This helper code is already used by several of our unit tests.
Compile it as a separate library.

Previously, the source code lingered unmotivated under "shared/",
which is confusing.
2021-02-24 12:48:42 +01:00
Thomas Haller 9bba4871f3
build: move "libnm/" to "src/" and split it
Like with "libnm-core/", split "libnm/" into different directories for
the public headers, for the implementation and for the helper "aux"
library.
2021-02-24 12:48:37 +01:00
Thomas Haller b53c50e778
shared: move "nm-test-utils.h" to "src/libnm-glib-aux/"
"nm-test-utils.h" is a header-only, helper library for our unit tests.
It was somewhat unmotivated in "shared/nm-utils", because all tests use
it, but it was not part of a "module".

Move it to "src/libnm-glib-aux/". It fits there very well. They both
have (only) a dependency on glib.
2021-02-24 12:48:33 +01:00
Thomas Haller 3906cc9cf4
build: move c-util/nettools library from "shared/" to "src/" 2021-02-24 12:48:28 +01:00
Thomas Haller a8c34b9dcf
build: move "shared/nm-std-aux" to "src/libnm-std-aux" 2021-02-24 12:48:24 +01:00
Thomas Haller 9dc84b32b0
build: move "shared/nm-{glib-aux,log-null,log-core}" to "src/libnm-{glib-aux,log-null,log-core}" 2021-02-24 12:48:20 +01:00
Thomas Haller 4d12a6ac3d
build: move "shared/nm-{base,udev-aux}" to "src/libnm-{base,udev-aux}" 2021-02-24 12:48:19 +01:00
Thomas Haller 2439374457
build: move "shared/nm-platform" to "src/libnm-platform" 2021-02-24 12:48:17 +01:00
Thomas Haller 39225258d6
build: move "shared/systemd" to "src/libnm-systemd-shared" 2021-02-24 12:48:16 +01:00
Thomas Haller b55710d6a6
shared: rename "libnm-systemd-logging-stub.la" to "libnm-log-null.la"
This is really just a different implementation of
"nm-glib-aux/nm-logging-fwd.h", that parallels libnm-log-core.

It's also not only useful to shared/systemd, but also share/nm-platform,
which also requires linking with a logging backend.
2021-02-24 12:48:16 +01:00
Thomas Haller a0c3396335
build: add missing dependencies for "libnm/nm-enum-types.h"" 2021-02-24 12:48:15 +01:00
Thomas Haller 341b6e0704
all: change G_LOG_DOMAIN to "nm"
glib requires G_LOG_DOMAIN defined so that log messages are labeled
to belong to NetworkManager or libnm.

However, we don't actually want to use glib logging. Our library libnm
MUST not log anything, because it spams the user's stdout/stderr.
Instead, a library must report notable events via its API. Note that
there is also LIBNM_CLIENT_DEBUG to explicitly enable debug logging,
but that doesn't use glib logging either.

Also, the daemon does not use glib logging instead it logs to syslog.
When run with `--debug`.

Hence, it's not useful for us to define different G_LOG_DOMAIN per
library/application, because none of our libraries/applications should
use glib logging.

It also gets slightly confusing, because we have the static library like
`src/libnm-core-impl`, which is both linked into `libnm` (the library)
and `NetworkManager` (the daemon). Which logging domain should they use?

Set the G_LOG_DOMAIN to "nm" everywhere. But no longer do it via `-D`
arguments to the compiler.

See-also: https://developer.gnome.org/glib/stable/glib-Message-Logging.html#G-LOG-DOMAIN:CAPS
2021-02-18 19:46:57 +01:00
Thomas Haller fdf9614ba7
build: move "libnm-core/" to "src/" and split it
"libnm-core/" is rather complicated. It provides a static library that
is linked into libnm.so and NetworkManager. It also contains public
headers (like "nm-setting.h") which are part of public libnm API.

Then we have helper libraries ("libnm-core/nm-libnm-core-*/") which
only rely on public API of libnm-core, but are themself static
libraries that can be used by anybody who uses libnm-core. And
"libnm-core/nm-libnm-core-intern" is used by libnm-core itself.

Move "libnm-core/" to "src/". But also split it in different
directories so that they have a clearer purpose.

The goal is to have a flat directory hierarchy. The "src/libnm-core*/"
directories correspond to the different modules (static libraries and set
of headers that we have). We have different kinds of such modules because
of how we combine various code together. The directory layout now reflects
this.
2021-02-18 19:46:51 +01:00
Wen Liang 6b78406460
docs: improve manual page about ipv4.addresses
Signed-off-by: Wen Liang <liangwen12year@gmail.com>

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/738
2021-02-17 17:55:56 +01:00
Thomas Haller b941686b5a
build: dist "libnm/nm-enum-types.[ch].template" files 2021-02-17 14:24:11 +01:00
Thomas Haller 7e8809a9c5
cloud-setup/tests: add unit test for nm-cloud-setup 2021-02-10 18:23:44 +01:00
Thomas Haller 94a75c8cd6
cloud-setup: build intermediate library "libnm-cloud-setup-core.a"
Next we'll add unit tests, hence we need to link against the code
but we don't want to compile it twice.
2021-02-10 18:23:44 +01:00
Thomas Haller 318824cb41
libnm: move "nm-version-macros.h" from shared/ to libnm-core/
"nm-version-macros.h" is used directly by libnm-core and indirectly by
libnm and core.

Let's not have it randomly under shared/. Move it closer to where it's
used.
2021-02-09 12:38:19 +01:00
Thomas Haller a2ef576905
shared: move "nm-gassert-patch.h" to "nm-glib-aux" 2021-02-09 12:38:19 +01:00
Thomas Haller c971ee2267
libnm: merge libnm-keyfile into libnm-core
Before there was a licensing conflict between the keyfile code
(libnm-keyfile) and libnm. The latter would require LGPL-2.1+ while
keyfile code was GPL-2.0+.

Consequently we were linking libnm-keyfile into the daemon, but not in
libnm.so.

This conflict has been resolved and keyfile API is part of libnm.so.
There is no more need to build a separate (intermediary) library. Merge
them.

This also makes sense because keyfile code needs access to private code
from libnm-core. It is closely tied to libnm-core, so that building them
separate makes no sense (anymore).
2021-02-09 12:38:19 +01:00
Thomas Haller b13a2b27e9
all: move shared/nm-meta-setting.[hc] to libnm-core and clients
"shared/nm-meta-setting.[hc]" contains meta data about settings.
As such it is similarly used by libnm-core (as internal API) and
by clients (as extension of public API of libnm). However, it must
be compiled twice, because while it defines in both cases a
NMMetaSettingInfo type, these types are different between internal and
public API.
Hence, the files must also be compiled twice (and differently), once
against libnm-core and once against the client helper library.

Previously, the file was under "shared/", but there it's a bit odd
it doesn't clearly belong anywhere.

There are two goals here:

 - copy the file to the two places where it is used. We also have
   a "check-tree" unit test that ensures those files don't diverge in
   the future.

 - we no longer require CFLAGS set during built. Instead, the sources
   should control the build. For that we have new (simple) headers
   "nm-meta-setting-base.h" that define the right behavior for the
   impl files.

There is still an ugliness (among several): the files must be named the
same for libnm-core and clients/common. Preferably, all our sources have
unique names, but that is not possible with this scheme (without
introducing other ugliness). To mitigate that, include the files only at
one exact place.
2021-02-09 12:38:19 +01:00
Thomas Haller 83a97f887b
tests: add "tools/check-tree.sh" script for checking consistency of sources
Our source tree also has certain consistency requirements. Since the
source is in git, this is a rather static check. However, we want to
ensure that future changes don't break it by adding a test.
2021-02-09 12:38:18 +01:00
Thomas Haller fa3ac35031
shared: remove unused "shared/nm-default.h" 2021-02-09 12:38:18 +01:00
Thomas Haller 66eccf7ad7
all: add "nm-default-systemd{,-shared}.h" as replacement for "nm-default.h" 2021-02-09 12:38:18 +01:00
Thomas Haller dc2afc9b77
all: add "src/core/nm-default-daemon.h" as replacement for "nm-default.h" 2021-02-09 12:38:18 +01:00
Thomas Haller 78629830c8
all: add "libnm-core/nm-default-libnm-core.h" as replacement for "nm-default.h" 2021-02-09 12:38:18 +01:00
Thomas Haller a38afcb1d9
all: add "libnm/nm-default-libnm.h" as replacement for "nm-default.h" 2021-02-09 12:38:18 +01:00
Thomas Haller 606612ea59
all: add "libnm/nm-default-client.h" as replacement for "nm-default.h" 2021-02-09 12:38:17 +01:00
Thomas Haller 8f4f91b667
all: add "nm-glib-aux/nm-default-glib-i18n-prog.h" as replacement for "nm-default.h" 2021-02-09 12:38:17 +01:00
Thomas Haller bbb86cc11a
all: add "nm-glib-aux/nm-default-glib-i18n-lib.h" as replacement for "nm-default.h" 2021-02-09 12:38:17 +01:00
Thomas Haller d69f12f9e7
all: add "nm-glib-aux/nm-default-glib.h" as replacement for "nm-default.h" 2021-02-09 12:38:17 +01:00
Thomas Haller dbdac49b81
all: add "nm-std-aux/nm-default-std.h" as replacement for "nm-default.h"
autotools projects commonly should include "config.h" as first header.
Also, commonly we need more headers, like glib.h or our nm_auto macros.
Hence, almost all our sources should as first include "nm-default.h".

However, as we build different parts, "nm-default.h" gets controlled
by the NETWORKMANAGER_COMPILATION define which autotools/meson needs
to specify in the build options.

That is confusing.

One advantage of that was, that theoretically the same sources can
be built twice, with different behavior. However, we should avoid doing
that altogether and build static libraries (once) that we link multiple
times.

Another advantage was that if NETWORKMANAGER_COMPILATION is for example
set to build a DAEMON source, there is a check that we don't include
private headers from libnm-core. However, that should be better solved
by not having public, internal and private headers in the same
directory.

Instead, introduce different "nm-default-*.h" headers that don't require
special defines and behave in a consistent way. This way, we require
fewer CFLAGS and it's immediately clear by looking at the source alone
which headers are included. Also, you will be easier see when a wrong
nm-default-*.h header gets included.

Introduce the first replacement. The others will follow.
2021-02-09 12:38:17 +01:00
Thomas Haller 021e87c084
shared: add "shared/nm-std-aux/nm-networkmanager-compilation.h" header 2021-02-09 12:38:17 +01:00
Thomas Haller 37075878a7
libnm: compile keyfile code like libnm-core
By now, keyfile code got relicensed as LGPL-2.1+ and is just a regular part
of libnm-core (in particular, because it uses private API of libnm-core).

It should no longer be in a separate directory, but for now, at lead compile
it the same as libnm-core.
2021-02-09 12:38:17 +01:00
Thomas Haller ed9ff9c3df
build: remove unused "nm-core-enum-types.[hc].template" files 2021-02-09 12:38:16 +01:00
Thomas Haller 0bcd453e8c
initrd/tests: drop special define for test directory
We got rid of all these redundant defines. All we need, is the base
source directory, which we already define in config.h as
NM_BUILD_SRCDIR. Use that.
2021-02-09 12:38:16 +01:00
Thomas Haller a4ca3acb6b
build: drop duplicate line from Makefile.am 2021-02-09 12:38:16 +01:00
Thomas Haller cbb59e3308
autotools: add check-progs target
If you configure with "--enable-tests=no", then the tests
are not build during `make all`, but only during `make check`.
That is convenient for development, so if you don't work on tests,
they usually don't get build and the (partial) compilation is faster.

However, there is no target to build the tests without running them.

Add `make check-progs` for that.
2021-02-04 10:05:28 +01:00
Thomas Haller ac1a9e03e4
all: move "src/" directory to "src/core/"
Currently "src/" mostly contains the source code of the daemon.
I say mostly, because that is not true, there are also the device,
settings, wwan, ppp plugins, the initrd generator, the pppd and dhcp
helper, and probably more.

Also we have source code under libnm-core/, libnm/, clients/, and
shared/ directories. That is all confusing.

We should have one "src" directory, that contains subdirectories. Those
subdirectories should contain individual parts (libraries or
applications), that possibly have dependencies on other subdirectories.
There should be a flat hierarchy of directories under src/, which
contains individual modules.

As the name "src/" is already taken, that prevents any sensible
restructuring of the code.

As a first step, move "src/" to "src/core/". This gives space to
reorganize the code better by moving individual components into "src/".

For inspiration, look at systemd's "src/" directory.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/743
2021-02-04 09:45:55 +01:00
Thomas Haller 5d85d7c849
shared: split redefining g_return* warning out of "nm-default.h"
It's confusing enough. Let's keep "nm-default.h" simpler.
Especially due to the nesting of #if, which clang-format wants
to indent.
2021-01-27 21:30:20 +01:00
Thomas Haller beb29ffb3c
build: rename static "liblibnm" to "libnm-static"
This is basically all of libnm as a static-library. The name
liblibnm isn't great. Arguably, we do have quite a lot of
libnmxyz, so finding a good name is hard. But libnm-static seems
a better name. Rename.
2021-01-27 21:25:46 +01:00
Beniamino Galvani c243e003d6 build: add missing dependency of nm-base for config-extra.h in Makefile.am
Fix the following build error:

 In file included from shared/nm-base/nm-ethtool-base.c:6:
 ./shared/nm-default.h:87:10: fatal error: config-extra.h: No such file or directory
    87 | #include "config-extra.h"
       |          ^~~~~~~~~~~~~~~~

Fixes: e5d2a05ad5 ('libnm: add "shared/nm-base/nm-base.h"')
2021-01-18 09:57:18 +01:00
Thomas Haller a288de4b3d
shared: add "shared/README.md" 2021-01-15 12:17:15 +01:00
Thomas Haller 9901aeef2c
platform: move "nm-platform-utils.[hc]" to "shared/nm-platform" library
By now it has no further dependencies on libnm-core or NetworkManager core.
Make it part of "shared/nm-platform" library.
2021-01-15 11:32:53 +01:00
Thomas Haller 874bd8994e
libnm,shared: move nm-ethtool helper to "libnm-base"
We want to use this by "shared/nm-platform", which should have
no dependency on "libnm-core".

Move "libnm-core/nm-ethtool-utils.h" to "libnm/nm-ethtool-utils.h" so
that it is only used by libnm. This file contains the defines for
the option names.

Also, symlink "libnm/nm-ethtool-utils.h" as "shared/nm-base/nm-ethtool-utils-base.h".
We want to use the same defines also internally. Since they are both
public API (must be in libnm) and should be in "shared/nm-base", this
is the way.
2021-01-15 11:32:41 +01:00
Thomas Haller 19242f56d7
libnm: split ethtool option names to a new header "libnm-core/nm-ethtool-utils.h"
We want to use these defines for option names also in "shared/nm-base"
(and in turn in "shared/nm-platform), which cannot include "libnm-core".

However, they are also public API of libnm.

To get this done, in a first step, move these defines to a new header
"libnm-core/nm-ethtool-utils.h".

Since now the name "nm-ethtool-utils.h" is taken, also rename
nm-libnm-core-intern files.
2021-01-15 11:32:39 +01:00
Thomas Haller e5d2a05ad5
libnm: add "shared/nm-base/nm-base.h"
Our dependencies are complicated.

Currently "src/platform" uses parts of libnm-core and is relatively
strongly entangled with core. It would be nice to have that part
clearly independent from "src" and from "libnm-core".

Also, "src/platform/nm-platform-utils.h" uses NMEthtoolID enum, which
previously was defined in "libnm-core/nm-libnm-core-intern/nm-ethtool-utils.h".

Move that to a new place "shared/nm-base/nm-base.h".

Note that we have "libnm-core/nm-libnm-core-intern", which is
libnm/core related code which uses and is used by libnm-core.
There is a need for a library which is used by libnm-core, but
does not depend on libnm-core itself. Here comes "shared/nm-base".

Yes, many libraries. But the goal is to entangle the dependencies
and have a clear hierarchy of includes. And to have "shared/nm-platform"
independent of libnm-core.
2021-01-15 11:32:32 +01:00
Thomas Haller 31dca65e04
shared,platform: move "nmp-netns.[hc]" to shared/nm-platform 2021-01-15 11:32:31 +01:00
Thomas Haller 24c634bf57
core/logging: move "nm-logging.c" to shared/nm-log-core/libnm-log-core library
We want to move platform code to "shared/nm-platform". However, platform
code uses the logging infrastructure from the daemon, there is thus
an odd circular dependency.

Solve that by moving the "src/nm-logging.[hc]" to a new helper library
in "shared/nm-log-core".
2021-01-15 11:32:31 +01:00
Thomas Haller 186f2da2fc
shared,platform: add "shared/nm-platform" library
NetworkManager core is huge. We should try to split out
parts that are independent.

Platform code is already mostly independent. But due to having it
under "src/", there is no strict separation/layering which determines
the parts that can work independently. So, while the code is mostly
independent (in practice), that is not obvious from looking at the
source tree. It thus still contributes to cognitive load.

Add a shared library "shared/nm-platform", which should have no
dependencies on libnm-core or NetworkManager core.

In a first step, move the netlink code there. More should follow.
2021-01-15 11:32:30 +01:00