Commit graph

830 commits

Author SHA1 Message Date
Thomas Haller e4f04267bb
l3cfg: implement IPv4 DAD/ACD (address collision detection) in NML3Cfg
Currently, NMDevice does ACD. It intercepts certain NMIP4Config
instances, and tries to perform ACD on the addresses. I think this
functionality should be handled by NML3Cfg instead.

For one, NML3Cfg sees all configurations, and can perform ACD for all
(relevant) addresses. Also, it moves logic away from NMDevice and makes
the functionality available without an NMDevice. As such, it also will
allow that independent "controllers" contribute NML3ConfigData instances
and ACD will performed for all of them (as requested).

This will be our implementation for IPv4 ACD (https://tools.ietf.org/html/rfc5227)
based on nettools' n-acd library.

The code is not actually tested yes, because NMDevice did not yet switch
over to use NML3Cfg. Once that happens, surely issues with this patch
will be found that will need fixing.
2020-09-03 11:52:39 +02:00
Thomas Haller 00e3fc036a
clients/tests: ensure that we run nmcli before client tests for LTO
nmcli is build with libtool, so "clients/cli/nmcli" is really a shell script
that invokes the real nmcli (at "clients/cli/.libs/nmcli").

When building with LTO for some reasons "clients/cli/nmcli" still
does some build steps during the first invocation.

That means, if we run `make check-local-clients-tests-test-client` it
would first do the final build step. This takes a while, and the test
times out (worse, we do that build step many times in parallel).

Avoid that by invoking "clients/cli/nmcli" first.
2020-08-17 15:18:06 +02:00
Thomas Haller c92a3ca5c2
build: fix generating "NetworkManager.ver" with LTO
We use a linker version script "NetworkManager.ver", to hide
symbols from NetworkManager that are not used. That is important
due to our habit of using internal helper libraries that we link
statically everywhere, without handpicking the symbols we actually
need. We want the tooling to get rid of unnecessary symbols.

However, NetworkManager loads shared libraries for settings and device
plugins. These libraries require symbols from the NetworkManager binary,
but which one depends on build options. Hence, we also generate
"NetworkManager.ver" by the "tools/create-exports-NetworkManager.sh"
script.

For that the script uses "nm" to find symbols that are undefined in the
plugin libraries but defined in NetworkManager. With autotools the
script looked at "./src/.libs/libNetworkManager.a" to find the present
symbols. Note that for meson that already didn't work, and we build
instead an intermediate NetworkManager binary first (with all symbols
exposed). With LTO, "nm" doesn't find all symbols in
"./src/.libs/libNetworkManager.a", and consequently they are not
exported and dropped/hidden.

This also causes unit tests to fail with LTO, because our test script
"tools/check-exports.sh" catches such bugs.

Fix that by also with autotools generate a complete "NetworkManager-all-sym"
binary that is used to generate "NetworkManager.ver", before rebuilding
"NetworkManager" again.
2020-08-17 15:18:05 +02:00
Thomas Haller c9409f8692
core: add NMIPConfig as base class for NMIP[46]Config
NMIP[46]Config will become much simpler than it is today.
It's sole responsibility will be to expose current settings
on D-Bus, in it's function as a NMDBusObject subtype.

However, it still make sense to let them share a common base class.
Add it.
2020-08-05 12:47:55 +02:00
Sayed Shah e7ac7290bd
cloud-setup: add tool for automatic IP configuration in cloud
This is a tool for automatically configuring networking in azure
cloud environment.

This add a provider implementation for Azure that when detected fetches
the private ip addressess and the subnet prefix of configured internal
load balancers.

Once this information is fetched from the metadata server, it instructs
NetworkManager to add private ip addressess and subnet prefix for each
interface detected.

It is inspired by SuSE's cloud-netconfig ([1], [2]) and Azure Instance Metadata service [3].

[1] https://www.suse.com/c/multi-nic-cloud-netconfig-ec2-azure/
[2] https://github.com/SUSE-Enceladus/cloud-netconfig
[3] https://docs.microsoft.com/en-us/azure/virtual-machines/linux/instance-metadata-service

It is also intended to work without configuration. The main point is
that you boot an image with NetworkManager and nm-cloud-setup enabled,
and it just works.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/572
2020-07-29 15:56:15 +02:00
Thomas Haller a1dbaf5799
l3cfg: add NML3ConfigData
Currently NMIP4Config and NMIP6Config both track the data to be
configured, they expose properties on D-Bus, and they have logic for
capturing and applying settings to platform.

We will split that.

- NMIP4Config and NMIP6Config will expose data on D-Bus.

- NML3Cfg will have the logic for handling IP configuration.

- NML3ConfigData will track data to be configured.

NML3ConfigData mirrors NMIP4Config/NMIP6Config in many aspects. For now,
this duplicates a lot of code. More will be done later. Eventually,
NMIP4Config/NMIP6Config will drop the duplicated functionality.
2020-07-23 15:29:25 +02:00
Thomas Haller 88d057978d
core: add "nm-l3cfg.[hc]" 2020-07-23 15:29:24 +02:00
Thomas Haller ae5e8fc26b
shared/tests: add test for checking "nm-json-aux.h"
Our "nm-json-aux.h" redefines various things from <jansson.h> header.

Add a unit test that checks that what we redefine exactly matches what
libjansson would provide, so that they are compatible.
2020-07-09 12:57:15 +02:00
Thomas Haller 4a7da1ca4b
shared: merge nm-glib-aux/nm-json.[hc] into nm-json-aux.[hc]
They serve a similar purpose.

Previously, nm-json-aux.h contained the virtual function table for accessing
the dynamically loaded libjansson. But there is no reason why our own
helper functions from nm-json.h cannot be there too.
2020-07-09 11:47:06 +02:00
Thomas Haller 3814467b88
libnm,shared: move nm-json.[hc] to shared/nm-glib-aux
nm-json.[hc] uses libjansson, but only loads it at runtime with dlopen. There
is no more run compile time dependency. Move it to shared, so that it can be
(theoretically) used by other components.

Also, drop the conditional compilation. Granted, if you don't build with
libjansson enabled, then the JANSSON_SONAME define is unset and the code
will fail to load at runtime (which is fine). However, we can still build
against our JSON wrappers. The code savings of conditional build are minimal
so drop it.
2020-07-09 11:47:05 +02:00
Thomas Haller 19613016e2
shared: add "nm-std-aux/nm-std-utils.[hc]"
General purpose utilities for nm-std-aux. Contrary to
"nm-std-aux.h", this is not header only.
2020-07-06 14:11:22 +02:00
Thomas Haller 5dd923cd86
shared: add "nm-std-aux/nm-std-aux.h" header
"nm-std-aux" is an utility library that has no glib depdencency. That
is the difference to "nm-glib-aux".
2020-07-06 11:10:43 +02:00
Thomas Haller 38b7556c65
build: check "examples/python/gi/nm-wg-set" with black 2020-07-02 17:44:21 +02:00
Beniamino Galvani dbfe219d5b all: add ap-isolation property to wifi setting
Add a new 'ap-isolation' property to the wifi setting, useful to
prevent communication between wireless clients.
2020-07-01 17:36:20 +02:00
Antonio Cardace a2b699f40f
nmcs-gcp: add support for Google Cloud Platform load balancers
This add a provider implementation for GCP that when detected fetches
the ip addresses of configured internal load balancers.

Once this information is fetched from the metadata server it instructs
NetworkManager to add local routes for each found forwarded-ip.

https://bugzilla.redhat.com/show_bug.cgi?id=1821787
2020-06-26 16:47:56 +02:00
Thomas Haller c537852231
build: optionally skip python black check by setting NMTST_SKIP_PYTHON_BLACK=1 2020-06-19 12:46:20 +02:00
Sayed Shah 9f77d26ad0
build: create check for python black
If python black is install then it would check the
formating of all of the python files and test the for it.
Otherwise, it would just simply ignore the python black
if python black is not installed.
2020-06-19 12:34:40 +02:00
Thomas Haller c56c6e8faa
build: ensure man directory exists for "man/nm-settings-docs-*.xml"
It would seem that the proper dependency is "man/.dirstamp". But that just
doesn't work. Use "man/common.ent" instead. If you figure out how to
convince autotools to make .dirstamp working, send a patch.
2020-06-15 15:34:16 +02:00
Thomas Haller ecf32c2c8f
systemd: merge branch systemd into master 2020-06-13 17:08:22 +02:00
Thomas Haller 3c11116c48
docs: in "generate-docs-nm-settings-docs-merge.py" only take properties from first setting
Especially for "nm-settings-docs-nmcli.xml", the first XML to merge is
"clients/cli/generate-docs-nm-settings-nmcli.xml". That file is
generated with the meta data from nmcli, and it contains all the
properties that are supported. Properties from other XML files,
that are passed as additional arguments should not be merged.

In most cases, there is no difference. It only matters for
"ipv6.dad-timeout" and "user.data". For example, "ipv6.dad-timeout"
is supported by GObject (part of "libnm/nm-settings-docs-gir.xml"),
but not by nmcli. Don't include it in the manual.

This also drops the now empty settings "dummy", "user", and "generic".
2020-06-12 10:26:27 +02:00
Thomas Haller 10020a9466
docs: generate nm-settings-docs-nmcli.xml based on nmcli meta data
We have the correct meta-data of supported properties for nmcli. It is
in clients/common. Use that for generating the manual page instead of
the properties that are part of libnm (some properties may be in libnm
but not supported by nmcli, or some properties may not be GObject
properties, and not detected as by GObject introspection).
2020-06-11 10:53:50 +02:00
Thomas Haller 87edf2f298
docs: move generate-docs scripts from "libnm/" to "tools/"
They are not only used in "libnm/" directory. Move to "tools/".
2020-06-11 10:53:50 +02:00
Thomas Haller d2f8d5a4fa
docs: move "nm-settings-docs-{dbus,nmcli}.xml" from "libnm/" to "man/"
"nm-settings-docs-nmcli.xml" will be generated by a tool that depends on
"clients/common/". The file should thus not be in libnm directory, otherwise
there is a circular dependency.

Move the file to "man/" directory.

For consistency, also move "nm-settings-docs-dbus.xml". Note that we
cannot move "nm-settings-docs-gir.xml" to "man/", because that one is
needed for building clients.
2020-06-11 10:53:50 +02:00
Thomas Haller caa70a50d7
all: move "shared/nm-libnm-aux" to "libnm/nm-libnm-aux"
Like the previous commit. Move code that depends on libnm out
of shared to avoid circular dependency.

Also add a readme file explaining the reason for existence of
the helper library.
2020-06-11 10:53:50 +02:00
Thomas Haller a9408e3497
all: move "shared/nm-libnm-core-aux" to "libnm-core/nm-libnm-core-aux"
Like the previous commit. Move code that depends on libnm-core out
of shared to avoid circular dependency.

Also add a readme file explaining the reason for existence of
the helper libraries nm-libnm-core-intern and nm-libnm-core-aux.
2020-06-11 10:53:50 +02:00
Thomas Haller e17a067e68
all: move "shared/nm-libnm-core-intern" to "libnm-core/nm-libnm-core-intern"
The "shared" directory is used by libnm-core, it should thus only depend on
code that is in the "shared" directory. Otherwise there is a circular
dependency, and meson's subdir() does not work nicely.

Also, libnm-core is really part of (and also an extension of) libnm-core,
so it belongs there.

I guess, the original idea was that this is also an extension for libnm,
so another project could take these utility functions (by copying them
into their source tree) and use them. That is still possible, it's
just that the sources are no longer under the shared directory.

Also add a readme to explain the non-obvious meaning of these files.
2020-06-11 10:53:50 +02:00
Thomas Haller b760dee8c8
all: move "shared/nm-keyfile" to "libnm-core/nm-keyfile"
Originally, these files were part of libnm-core and linked together.
However, that is a licensing violation, because the code is GPL-2.0+
licensed, while libnm-core also gets linked with libnm (it must thus
be LGPL-2.1+). The original intent behind moving the code to "shared/"
was to avoid the licensing issue, but also to prepare when we would add
a separate, GPL licensed libnm-keyfile. However, currently we hope to
be able to relicense the code, so that it actually could be exposed as
part of libnm. This is work in progress at ([1]).

[1] https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/ ## 517

Anyway, the current directory layout is problematic. libnm-keyfile
depends on libnm-core, while libnm-core depends on code under shared.
That means, there is a circular dependency and meson's subdir() does
not work well.

Move the code.
2020-06-11 10:53:50 +02:00
Thomas Haller 47d39a7fb7
docs: add more nm-settings manpages (dbus,nmcli,keyfile,ifcfg-rh)
A significant part of NetworkManager's API are the connection profiles, documented
in `man nm-settings*`. But there are different aspects about profiles, depending
on what you are interested. There is the D-Bus API, nmcli options, keyfile format,
and ifcfg-rh format. Additionally, there is also libnm API.

Add distinct manual pages for the four aspects. Currently the two new manual
pages "nm-settings-dbus" and "nm-settings-nmcli" are still identical to the
former "nm-settings.5" manual. In the future, they will diverge to
account for the differences.

There are the following aspects:

 - "dbus"
 - "keyfile"
 - "ifcfg-rh"
 - "nmcli"

For "libnm" we don't generate a separate "nm-settings-libnm" manual
page. That is instead documented via gtk-doc.

Currently the keyfile and ifcfg-rh manual pages only detail settings
which differ. But later I think also these manual pages should contain
all settings that apply.
2020-06-11 10:53:49 +02:00
Thomas Haller d8992ce931
docs: rename "nm-settings-docs.xml" to "nm-settings-docs-dbus.xml"
"nm-settings-docs-dbus.xml" is "nm-settings-docs-gir.xml" merged with
"nm-property-infos-dbus.xml". The name should reflect that, also because
we will get more files with this naming scheme.
2020-06-11 10:53:49 +02:00
Thomas Haller 960ab39739
docs: rename "nm-property-docs.xml" to "nm-settings-docs-gir.xml"
The name is bad. For one, we will have more files of the same format
("nm-settings-docs-nmcli.xml").

Also, "libnm/nm-settings-docs.xml" and "libnm/nm-property-docs.xml" had
basically the same file format. Their name should be similar.

Also the tool to generate the file should have a name that reminds to
the file that it creates.
2020-06-11 10:53:49 +02:00
Thomas Haller a9001261fb
docs: rename "nm-property-infos" doc files
The naming was inconsistent. Rename.

- all the property infos of this kind a now consistently called
  "libnm/nm-property-infos-$TAG.xml".

- the script to generate files "libnm/nm-property-infos-$TAG.xml" is
  now called "libnm/generate-docs-nm-property-infos.pl".
2020-06-11 10:53:49 +02:00
Thomas Haller 7682e76de5
docs: fix dependency of "nm-settings*xml" to "common.ent"
"man/nm-settings%.xml" really should depend on "common.ent".
The reason is that XSL files like "man/nm-settings.xsl" include
"common.ent".
The previous code already tried to express that, but for some
reasons this dependency was not honored. Fix that.

However, that uncovers another problem with gtk-doc.make. If we do
that without the workaround for "docs/api/Makefile.am", then

  $ ./autogen.sh && make V=1 SHELL='sh -x' distcheck

breaks.

The reason is not clear to me. The new dependency leads to rebuild
"man/nm-settings-keyfile.xml". But that is worse, somehow the file
"$(top_srcdir)/man/nm-settings-keyfile.xml" ends up being read-only.
Afterwards, gtk-doc.make does

    setup-build.stamp:
        -$(GTK_DOC_V_SETUP)if test "$(abs_srcdir)" != "$(abs_builddir)" ;
        then \
          files=`echo $(SETUP_FILES) $(DOC_MODULE).types`; \
          if test "x$$files" != "x" ; then \
            for file in $$files ; do \
              destdir=`dirname $(abs_builddir)/$$file`; \
              test -d "$$destdir" || mkdir -p "$$destdir"; \
              test -f $(abs_srcdir)/$$file && \
                cp -pf $(abs_srcdir)/$$file $(abs_builddir)/$$file || true;
                \
            done; \
          fi; \
        fi
        $(AM_V_at)touch setup-build.stamp

so that the files in build dir are also read-only. Then, make distcheck
goes ahead and builds the files once again, which fails.

You are welcome to understand why this workaround is necessary. Please
then create a better fix.
2020-06-11 10:53:49 +02:00
Thomas Haller 2f78a824d8
docs: merge settings docs in a separate step
The script "libnm/generate-setting-docs.py" generates property info based
on GObject introspection data.

Optionally, when creating the manual for D-Bus documentation, it would accept
an argument "--override" to merge the generated information with the information
from an XML generated by "libnm/generate-plugin-docs.xml". Change this.
Instead, let "libnm/generate-setting-docs.py" just do one thing: generate
the XML based on GObject introspection data. Then, a second script
"libnm/generate-docs-nm-settings-docs-merge.py" can merge the XMLs.

Note that currently the manual for "nm-settings-keyfile" only contains
information about properties that are explicitly mentioned for keyfile.
It think that is not right. In NetworkManager there are multiple "aspects"
about connection profiles: D-Bus, libnm, nmcli, keyfile and ifcfg-rh.
When we generate a manual page for any of these aspects, we should always
detail all properties. At least for nmcli and D-Bus. That means, we will
do the merging multiple times. Hence, keep the steps for parsing GObject
introspection data and the merging separate.

Also, "generate-setting-docs.py" and "generate-plugin-docs.pl" should
generate the same XML scheme, so that merge doesn't need special hacks.
That is currently not the case, for example, the override XML contains a
"format" attribute, while the other one contains a "type". Merging these
is a special hack. This should be unified.
2020-06-11 10:53:49 +02:00
Thomas Haller 655fd1ebd8
ifcfg-rh: support persisting 802-1x.pin and pin-flags property 2020-05-28 18:05:15 +02:00
Beniamino Galvani 53aa5bd207 platform: add tc tests 2020-05-28 17:25:31 +02:00
Beniamino Galvani c8b5bf402d build: install a firewalld zone for shared mode
Install a NM-specific firewalld zone to be used for interfaces that
are used for connection sharing. The zone blocks all traffic to the
local machine except some protocols (DHCP, DNS and ICMP) and allows
all forwarded traffic.
2020-05-15 19:06:24 +02:00
Thomas Haller 9119e5b618
build/autotools: fix linking nm-online,nm-dispatcher,nm-bt-test with sanitizer flags 2020-05-14 12:19:34 +02:00
Thomas Haller 42d45299f9
tests/sanitizer: make ASAN/LSAN/UBSAN options configurable in "tools/run-nm-test.sh"
Also add a suppressions file for LSAN.
2020-05-14 12:03:24 +02:00
Thomas Haller 53476d821d
nm-online: fix build of nm-online for missing libcsiphash.la
Fixes: e468b48ab7 ('nm-online: allow configuring timeout via NM_ONLINE_TIMEOUT environment')
(cherry picked from commit 69798fa6cd)
2020-05-02 23:00:08 +02:00
Thomas Haller 02513e4b5d
nm-online: allow configuring timeout via NM_ONLINE_TIMEOUT environment
https://bugzilla.redhat.com/show_bug.cgi?id=1828458

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/484
(cherry picked from commit e468b48ab7)
2020-04-30 21:47:30 +02:00
Gilles Dartiguelongue 7b0130d5d7 build: remove subshells and fix invalid test syntax
Signed-off-by: Gilles Dartiguelongue <eva@gentoo.org>

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/472
(cherry picked from commit e073491b9c)
2020-04-20 08:54:38 +02:00
Thomas Haller e05f35f9f1 cli: cleanup NMCCommand and declarations of func implementations
- move the main func declarations to nmcli.h and give them a common
prefix "nmc_command_func_" prefix.

- remove some of the header files that are now empty. In fact, these
headers did not really declare some well separated module. While we
probably should structure the code in nmcli better with better layering,
it was not and still is not. Having these dummy headers don't mean that
the code is well structured and they serve little purpose.

- move the static NMCommand lists variables into the function scope
where they are used.
2020-04-10 10:27:27 +02:00
Thomas Haller c3969425ec systemd: merge branch systemd into master 2020-04-08 09:08:49 +02:00
Thomas Haller eda47170ed shared: add NMStrBuf util
Our own implementation of a string buffer like GString.

Advantages (in decreasing relevance):

- Since we are in control, we can easily let it nm_explicit_bzero()
  the memory. The regular GString API cannot be used in such a case.
  While nm_explicit_bzero() may or may not be of questionable benefit,
  the problem is that if the underlying API counteracts the aim of
  clearing memory, it gets impossible. As API like NMStrBuf supports
  it, clearing memory is a easy as enable the right flag.
  This would for example be useful for example when we read passwords
  from a file or file descriptor (e.g. try_spawn_vpn_auth_helper()).

- We have API like

    nmp_object_to_string (const NMPObject *obj,
                          NMPObjectToStringMode to_string_mode,
                          char *buf,
                          gsize buf_size);

  which accept a fixed size output buffer. This has the problem of
  how choosing the right sized buffer. With NMStrBuf such API could
  be instead

    nmp_object_to_string (const NMPObject *obj,
                          NMPObjectToStringMode to_string_mode,
                          NMStrBuf *buf);

  which can automatically grow (using heap allocation). It would be
  easy to extend NMStrBuf to use a fixed buffer or limiting the
  maximum string length. The point is, that the to-string API wouldn't
  have to change. Depending on the NMStrBuf passed in, you can fill
  an unbounded heap allocated string, a heap allocated string up to
  a fixed length, or a static string of fixed length. NMStrBuf currently
  only implements the unbounded heap allocate string case, but it would
  be simple to extend.

  Note that we already have API like nm_utils_strbuf_*() to fill a buffer
  of fixed size. GString is not useable for that (efficiently), hence
  this API exists. NMStrBuf could be easily extended to replace this API
  without usability or performance penalty. So, while this adds one new
  API, it could replace other APIs.

- GString always requires a heap allocation for the container. In by far
  most of the cases where we use GString, we use it to simply construct
  a string dynamically. There is zero use for this overhead. If one
  really needs a heap allocated buffer, NMStrBuf can easily embedded
  in a malloc'ed memory and boxed that way.

- GString API supports inserting and removing range. We almost never
  make use of that. We only require append-only, which is simple to
  implement.

- GString needs to NUL terminate the buffer on every append. It
  has unnecessary overhead for allowing a usage of where intermediate
  buffer contents are valid strings too. That is not the case with
  NMStrBuf: the API requires the user to call nm_str_buf_get_str() or
  nm_str_buf_finalize(). In most cases, you would only access the string
  once at the end, and not while constructing it.

- GString always grows the buffer size by doubling it. I don't think
  that is optimal. I don't think there is one optimal approach for how
  to grow the buffer, it depends on the usage patterns. However, trying
  to make an optimal choice here makes a difference. QT also thinks so,
  and I adopted their approach in nm_utils_get_next_realloc_size().
2020-04-03 11:31:12 +02:00
Thomas Haller a34b1f793e build: link nm-dispatcher with libnm-glib-aux.la
Our glib based code should also include our static utility library
libnm-glib-aux. This is our basic utility library that we want to
have around everywhere. Since we link statically, the linker will weed
out the unused stuff at compile time. So, there is no overhead, except
for the things that we actually use.
2020-03-25 16:14:52 +01:00
Thomas Haller e75d62ce76 systemd: merge branch systemd into master 2020-03-23 17:50:12 +01:00
Thomas Haller 26f208aec3 core: add common base class NMDhcpConfig for NMDhcp[46]Config and merge them
The advantage is that the API is now the same for IPv4 and IPv6: it's
all nm_dhcp_config_*() and we can (easier) treat the address family
generically.

We still need two distinct GObject types, mainly because of the
glue code for exposing the object on D-Bus as NMDBusObject. Of course,
that could be solved differently, but as it is, it's quite nice.
2020-02-21 15:59:44 +01:00
Thomas Haller cd03d39a6d core: rename "nm-dhcp4-config.[ch]" to "nm-dhcp-config.[hc]" before merge
NMDhcp4Config and NMDhcp6Config will get a common base type NMDhcpConfig
and be merged. In preparation, rename the file.
2020-02-21 15:59:44 +01:00
Thomas Haller 16df1c179d build/autotools: fix passing AM_CFLAGS when building libnm-core
With `./configure --enable-more-asserts`, we add extra -W flags to
AM_CFLAGS. This variable is only used, if the per-library override
libnm_core_libnm_core_la_CFLAGS is unspecified ([1]).

Usually we avoid this problem be never specifying library_CFLAGS, but
placing all our per-library flags to library_CPPFLAGS. While that is a
bit of a hack and misuse of CPPFLAGS, it works well (enough).

This was broken recently. The effect was, that libnm-core was not
build with AM_CFLAGS flags. Fix it.

[1] https://www.gnu.org/software/automake/manual/html_node/Flag-Variables-Ordering.html

Fixes: d2d6a68697 ('build: use -fcommon when building libnm-core')
2020-02-21 10:07:54 +01:00
Beniamino Galvani 207e971863 build: remove duplicate definition in Makefile
Fix the following warning:

 Makefile.am:3671: warning: $(src_devices_wifi_libnm_device_plugin_wifi_la_OBJECTS) was already defined in condition TRUE, which includes condition WITH_WIFI ...
 Makefile.am:1075: ... '$(src_devices_wifi_libnm_device_plugin_wifi_la_OBJECTS)' previously defined here
2020-02-03 11:00:34 +01:00
Beniamino Galvani d2d6a68697 build: use -fcommon when building libnm-core
Building with GCC 10 gives the following error:

 multiple definition of_nm_jansson_json_object_iter_key';
 libnm/.libs/liblibnm.a(libnm_core_la-nm-json.o):/builddir/build/BUILD/NetworkManager-1.23.1/libnm-core/nm-json.c:24: first defined here /usr/bin/ld:
 libnm/.libs/liblibnm.a(libnm_core_la-nm-team-utils.o):/usr/include/jansson.h:202: multiple definition of _nm_jansson_json_object_iter';

This happens because GCC 10 defaults to -fno-common and so multiple
definitions of the same global variable are not merged together.

_nm_jansson_json_* symbols are defined in nm-json.c as void pointers
and, due to the following macros in nm-json.h:

 #define json_object_iter_next   (*_nm_jansson_json_object_iter_next)
 ...

the function declaration in jansson.h:

 void *json_object_iter_next(json_t *object, void *iter);

becomes a global variable as well:

 void *(*_nm_jansson_json_object_iter_next)(json_t *object, void *iter);

So, the symbol is present in nm-json.o and all other object files that
include nm-json.h, and -fcommon is required. Without it, it would be
necessary to define the symbols only in one place (for example,
nm-json.c), but then static inline functions from the jannson.h header
would still refer to the original (missing) jansson functions.

For the moment, just use -fcommon.
2020-02-03 10:53:33 +01:00
Thomas Haller a6b6f33f01 build: fix linking of "src/devices/wifi/tests/test-devices-wifi"
On ppc64le, the linking fails due to unresolved symbols.

Fixes: 7d8da6c9c1 ('build: build intermediate library with core wifi for device-plugin and tests')
2020-01-15 17:43:07 +01:00
Beniamino Galvani 667568d1b2 core,libnm: add VRF support
Add VRF support to the daemon. When the device we are activating is a
VRF or a VRF's slave, put routes in the table specified by the VRF
connection.

Also, introduce a VRF device type in libnm.
2020-01-14 09:51:56 +01:00
Beniamino Galvani f4ced16791 libnm-core,cli: add VRF setting
Add new VRF setting and connection types to libnm-core and support
them in nmcli.
2020-01-14 09:49:01 +01:00
Thomas Haller 7d8da6c9c1 build: build intermediate library with core wifi for device-plugin and tests
Don't build the same sources multiple times. The test code should
statically link against the tested code, just like the device plugin
that uses the code in production.
2020-01-08 11:23:24 +01:00
Thomas Haller d964decbbd libnm/keyfile: build keyfile code as separate GPL licensed internal library
Keyfile support was initially added under GPL-2.0+ license as part of
core. It was moved to "libnm-core" in commit 59eb5312a5 ('keyfile: merge
branch 'th/libnm-keyfile-bgo744699'').

"libnm-core" is statically linked with by core and "libnm". In
the former case under terms of GPL-2.0+ (good) and in the latter case
under terms of LGPL-2.1+ (bad).

In fact, to this day, "libnm" doesn't actually use the code. The linker
will probably remove all the GPL-2.0+ symbols when compiled with
gc-sections or LTO. Still, linking them together in the first place
makes "libnm" only available under GPL code (despite the code
not actually being used).

Instead, move the GPL code to a separate static library
"shared/nm-keyfile/libnm-keyfile.la" and only link it to the part
that actually uses the code (and which is GPL licensed too).

This fixes the license violation.

Eventually, it would be very useful to be able to expose keyfile
handling via "libnm". However that is not straight forward due to the
licensing conflict.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/381
2020-01-07 13:17:47 +01:00
Antonio Cardace df1d214b2e clients: polkit-agent: implement polkit agent without using libpolkit 2019-12-24 10:13:51 +01:00
Antonio Cardace 0f7994328d shared: move nm-dbus-auth-subject to shared/nm-libnm-core-intern
Move it to shared as it's useful for clients as well.

Move and rename nm_dbus_manager_new_auth_subject_from_context() and
nm_dbus_manager_new_auth_subject_from_message() in nm-dbus-manager.c
as they're needed there.
2019-12-24 10:13:51 +01:00
Thomas Haller 9e02a67619 systemd: merge branch systemd into master 2019-12-16 10:22:09 +01:00
Thomas Haller 3035837aa8 cli: use nmc_client_new_async() instead of nm_client_new_async()
This will allow us to set construct parameters to the instance, like
NM_CLIENT_INSTANCE_FLAGS.
2019-12-10 09:17:17 +01:00
Thomas Haller 0b5e72b90d nm-online: use nmc_client_new_async() instead of nm_client_new_async()
This will allow us to set construct parameters to the instance, like
NM_CLIENT_INSTANCE_FLAGS.
2019-12-10 09:17:17 +01:00
Thomas Haller c5c7fffda8 cloud-setup: reuse nmc_client_new_waitsync() to create NMClient instance 2019-12-10 09:17:17 +01:00
Thomas Haller 5859e9a53d tui: create NMClient instance via async init
Using sync init (nm_client_new()) has an overhead as it requires an internal
GMainContext to ensure preserving the order of D-Bus messages. Let's avoid
that by using the async init. Note that the difference here is that we will
iterate the caller's GMainContext while creating the instance. But that
is no problem for nmtui at that point.
2019-12-10 09:17:17 +01:00
Thomas Haller 3843e0c87d shared: add "shared/nm-libnm-aux" static library
We have "shared/nm-libnm-core-aux", which is shared code that can be used
by anybody (including libnm-core, src, libnm and clients).

We have "clients/common", which are helper function for clients. But
that implies that the code is inside "clients". I think it would be
useful to have auxiliary code that extends libnm, but is not only
usable by code in "clients". In other words, "shared/nm-libnm-aux"
is a better place than "clients/common", and I think most of the
functionality form "clients/common" should move there.
2019-12-10 09:17:17 +01:00
Thomas Haller 44c5331e29 shared: move "shared/nm-utils/tests/test-shared-general" to "shared/nm-glib-aux/tests"
"shared/nm-utils" got long renamed and split into separate parts. The remaining
tests are really to test nm-std-aux and nm-glib-aux (no libnm dependencies). Move
the tests to the appropriate place.
2019-12-10 09:17:17 +01:00
David Bauer 235cb4a5d3 settings/ifcfg: add support for KEY_MGMT=OWE 2019-12-05 14:00:10 +01:00
Thomas Haller 69f048bf0c cloud-setup: add tool for automatic IP configuration in cloud
This is a tool for automatically configuring networking in a cloud
environment.

Currently it only supports IPv4 on EC2, but it's intended for extending
to other cloud providers (Azure). See [1] and [2] for how to configure
secondary IP addresses on EC2. This is what the tool currently aims to
do (but in the future it might do more).

[1] https://aws.amazon.com/premiumsupport/knowledge-center/ec2-ubuntu-secondary-network-interface/

It is inspired by SuSE's cloud-netconfig ([1], [2]) and ec2-net-utils
package on Amazon Linux ([3], [4]).

[1] https://www.suse.com/c/multi-nic-cloud-netconfig-ec2-azure/
[2] https://github.com/SUSE-Enceladus/cloud-netconfig
[3] https://github.com/aws/ec2-net-utils
[4] https://github.com/lorengordon/ec2-net-utils.git

It is also intended to work without configuration. The main point is
that you boot an image with NetworkManager and nm-cloud-setup enabled,
and it just works.
2019-11-28 19:52:18 +01:00
Thomas Haller 41d81e6893 shared/logging: add "nm-logging-base.h"
We have "nm-logging-fwd.h", which (as the name implies) is header-only.
Add instead a "nm-logging-base.c", which also contains implementation for
logging functions that are not only useful under "src/nm-logging.c"
2019-11-28 19:20:33 +01:00
Thomas Haller ce0e898fb4 libnm: refactor caching of D-Bus objects in NMClient
No longer use GDBusObjectMangaerClient and gdbus-codegen generated classes
for the NMClient cache. Instead, use GDBusConnection directly and a
custom implementation (NMLDBusObject) for caching D-Bus' ObjectManager
data.

CHANGES
-------

- This is a complete rework. I think the previous implementation was
difficult to understand. There were unfixed bugs and nobody understood
the code well enough to fix them. Maybe somebody out there understood the
code, but I certainly did not. At least nobody provided patches to fix those
issues. I do believe that this implementation is more straightforward and
easier to understand. It removes a lot of layers of code. Whether this claim
of simplicity is true, each reader must decide for himself/herself. Note
that it is still fairly complex.

- There was a lingering performance issue with large number of D-Bus
objects. The patch tries hard that the implementation scales well. Of
course, when we cache N objects that have N-to-M references to other,
we still are fundamentally O(N*M) for runtime and memory consumption (with
M being the number of references between objects). But each part should behave
efficiently and well.

- Play well with GMainContext. libnm code (NMClient) is generally not
thread safe. However, it should work to use multiple instances in
parallel, as long as each access to a NMClient is through the caller's
GMainContext. This follows glib's style and effectively allows to use NMClient
in a multi threaded scenario. This implies to stick to a main context
upon construction and ensure that callbacks are only invoked when
iterating that context. Also, NMClient itself shall never iterate the
caller's context. This also means, libnm must never use g_idle_add() or
g_timeout_add(), as those enqueue sources in the g_main_context_default()
context.

- Get ordering of messages right. All events are consistently enqueued
in a GMainContext and processed strictly in order. For example,
previously "nm-object.c" tried to combine signals and emit them on an
idle handler. That is wrong, signals must be emitted in the right order
and when they happen. Note that when using GInitable's synchronous initialization
to initialize the NMClient instance, NMClient internally still operates fully
asynchronously. In that case NMClient has an internal main context.

- NMClient takes over most of the functionality. When using D-Bus'
ObjectManager interface, one needs to handle basically the entire state
of the D-Bus interface. That cannot be separated well into distinct
parts, and even if you try, you just end up having closely related code
in different source files. Spreading related code does not make it
easier to understand, on the contrary. That means, NMClient is
inherently complex as it contains most of the logic. I think that is
not avoidable, but it's not as bad as it sounds.

- NMClient processes D-Bus messages and state changes in separate steps.
First NMClient unpacks the message (e.g. _dbus_handle_properties_changed()) and
keeps track of the changed data. Then we update the GObject instances
(_dbus_handle_obj_changed_dbus()) without emitting any signals yet. Finally,
we emit all signals and notifications that were collected
(_dbus_handle_changes_commit()). Note that for example during the initial
GetManagedObjects() reply, NMClient receive a large amount of state at once.
But we first apply all the changes to our GObject instances before
emitting any signals. The result is that signals are always emitted in a moment
when the cache is consistent. The unavoidable downside is that when you receive
a property changed signal, possibly many other properties changed
already and more signals are about to be emitted.

- NMDeviceWifi no longer modifies the content of the cache from client side
during poke_wireless_devices_with_rf_status(). The content of the cache
should be determined by D-Bus alone and follow what NetworkManager
service exposes. Local modifications should be avoided.

- This aims to bring no API/ABI change, though it does of course bring
various subtle changes in behavior. Those should be all for the better, but the
goal is not to break any existing clients. This does change internal
(albeit externally visible) API, like dropping NM_OBJECT_DBUS_OBJECT_MANAGER
property and NMObject no longer implementing GInitableIface and GAsyncInitableIface.

- Some uses of gdbus-codegen classes remain in NMVpnPluginOld, NMVpnServicePlugin
and NMSecretAgentOld. These are independent of NMClient/NMObject and
should be reworked separately.

- While we no longer use generated classes from gdbus-codegen, we don't
need more glue code than before. Also before we constructed NMPropertiesInfo and
a had large amount of code to propagate properties from NMDBus* to NMObject.
That got completely reworked, but did not fundamentally change. You still need
about the same effort to create the NMLDBusMetaIface. Not using
generated bindings did not make anything worse (which tells about the
usefulness of generated code, at least in the way it was used).

- NMLDBusMetaIface and other meta data is static and immutable. This
avoids copying them around. Also, macros like NML_DBUS_META_PROPERTY_INIT_U()
have compile time checks to ensure the property types matches. It's pretty hard
to misuse them because it won't compile.

- The meta data now explicitly encodes the expected D-Bus types and
makes sure never to accept wrong data. That would only matter when the
server (accidentally or intentionally) exposes unexpected types on
D-Bus. I don't think that was previously ensured in all cases.
For example, demarshal_generic() only cared about the GObject property
type, it didn't know the expected D-Bus type.

- Previously GDBusObjectManager would sometimes emit warnings (g_log()). Those
probably indicated real bugs. In any case, it prevented us from running CI
with G_DEBUG=fatal-warnings, because there would be just too many
unrelated crashes. Now we log debug messages that can be enabled with
"LIBNM_CLIENT_DEBUG=trace". Some of these messages can also be turned
into g_warning()/g_critical() by setting LIBNM_CLIENT_DEBUG=warning,error.
Together with G_DEBUG=fatal-warnings, this turns them into assertions.
Note that such "assertion failures" might also happen because of a server
bug (or change). Thus these are not common assertions that indicate a bug
in libnm and are thus not armed unless explicitly requested. In our CI we
should now always run with LIBNM_CLIENT_DEBUG=warning,error and
G_DEBUG=fatal-warnings and to catch bugs. Note that currently
NetworkManager has bugs in this regard, so enabling this will result in
assertion failures. That should be fixed first.

- Note that this changes the order in which we emit "notify:devices" and
"device-added" signals. I think it makes the most sense to emit first
"device-removed", then "notify:devices", and finally "device-added"
signals.
This changes behavior for commit 52ae28f6e5 ('libnm: queue
added/removed signals and suppress uninitialized notifications'),
but I don't think that users should actually rely on the order. Still,
the new order makes the most sense to me.

- In NetworkManager, profiles can be invisible to the user by setting
"connection.permissions". Such profiles would be hidden by NMClient's
nm_client_get_connections() and their "connection-added"/"connection-removed"
signals.
Note that NMActiveConnection's nm_active_connection_get_connection()
and NMDevice's nm_device_get_available_connections() still exposes such
hidden NMRemoteConnection instances. This behavior was preserved.

NUMBERS
-------

I compared 3 versions of libnm.

  [1] 962297f908, current tip of nm-1-20 branch
  [2] 4fad8c7c64, current master, immediate parent of this patch
  [3] this patch

All tests were done on Fedora 31, x86_64, gcc 9.2.1-1.fc31.
The libraries were build with

  $ ./contrib/fedora/rpm/build_clean.sh -g -w test -W debug

Note that RPM build already stripped the library.

---

N1) File size of libnm.so.0.1.0 in bytes. There currently seems to be a issue
  on Fedora 31 generating wrong ELF notes. Usually, libnm is smaller but
  in these tests it had large (and bogus) ELF notes. Anyway, the point
  is to show the relative sizes, so it doesn't matter).

  [1] 4075552 (102.7%)
  [2] 3969624 (100.0%)
  [3] 3705208 ( 93.3%)

---

N2) `size /usr/lib64/libnm.so.0.1.0`:

          text             data              bss                dec               hex   filename
  [1]  1314569 (102.0%)   69980 ( 94.8%)   10632 ( 80.4%)   1395181 (101.4%)   1549ed   /usr/lib64/libnm.so.0.1.0
  [2]  1288410 (100.0%)   73796 (100.0%)   13224 (100.0%)   1375430 (100.0%)   14fcc6   /usr/lib64/libnm.so.0.1.0
  [3]  1229066 ( 95.4%)   65248 ( 88.4%)   13400 (101.3%)   1307714 ( 95.1%)   13f442   /usr/lib64/libnm.so.0.1.0

---

N3) Performance test with test-client.py. With checkout of [2], run

```
prepare_checkout() {
    rm -rf /tmp/nm-test && \
    git checkout -B test 4fad8c7c64 && \
    git clean -fdx && \
    ./autogen.sh --prefix=/tmp/nm-test && \
    make -j 5 install && \
    make -j 5 check-local-clients-tests-test-client
}
prepare_test() {
    NM_TEST_REGENERATE=1 NM_TEST_CLIENT_BUILDDIR="/data/src/NetworkManager" NM_TEST_CLIENT_NMCLI_PATH=/usr/bin/nmcli python3 ./clients/tests/test-client.py -v
}
do_test() {
  for i in {1..10}; do
      NM_TEST_CLIENT_BUILDDIR="/data/src/NetworkManager" NM_TEST_CLIENT_NMCLI_PATH=/usr/bin/nmcli python3 ./clients/tests/test-client.py -v || return -1
  done
  echo "done!"
}
prepare_checkout
prepare_test
time do_test
```

  [1]  real 2m14.497s (101.3%)     user 5m26.651s (100.3%)     sys  1m40.453s (101.4%)
  [2]  real 2m12.800s (100.0%)     user 5m25.619s (100.0%)     sys  1m39.065s (100.0%)
  [3]  real 1m54.915s ( 86.5%)     user 4m18.585s ( 79.4%)     sys  1m32.066s ( 92.9%)

---

N4) Performance. Run NetworkManager from build [2] and setup a large number
of profiles (551 profiles and 515 devices, mostly unrealized). This
setup is already at the edge of what NetworkManager currently can
handle. Of course, that is a different issue. Here we just check how
long plain `nmcli` takes on the system.

```
do_cleanup() {
    for UUID in $(nmcli -g NAME,UUID connection show | sed -n 's/^xx-c-.*:\([^:]\+\)$/\1/p'); do
        nmcli connection delete uuid "$UUID"
    done
    for DEVICE in $(nmcli -g DEVICE device status | grep '^xx-i-'); do
        nmcli device delete "$DEVICE"
    done
}

do_setup() {
    do_cleanup
    for i in {1..30}; do
        nmcli connection add type bond autoconnect no con-name xx-c-bond-$i ifname xx-i-bond-$i ipv4.method disabled ipv6.method ignore
        for j in $(seq $i 30); do
            nmcli connection add type vlan autoconnect no con-name xx-c-vlan-$i-$j vlan.id $j ifname xx-i-vlan-$i-$j vlan.parent xx-i-bond-$i  ipv4.method disabled ipv6.method ignore
        done
    done
    systemctl restart NetworkManager.service
    sleep 5
}

do_test() {
    perf stat -r 50 -B nmcli 1>/dev/null
}

do_test
```

  [1]

   Performance counter stats for 'nmcli' (50 runs):

              456.33 msec task-clock:u              #    1.093 CPUs utilized            ( +-  0.44% )
                   0      context-switches:u        #    0.000 K/sec
                   0      cpu-migrations:u          #    0.000 K/sec
               5,900      page-faults:u             #    0.013 M/sec                    ( +-  0.02% )
       1,408,675,453      cycles:u                  #    3.087 GHz                      ( +-  0.48% )
       1,594,741,060      instructions:u            #    1.13  insn per cycle           ( +-  0.02% )
         368,744,018      branches:u                #  808.061 M/sec                    ( +-  0.02% )
           4,566,058      branch-misses:u           #    1.24% of all branches          ( +-  0.76% )

             0.41761 +- 0.00282 seconds time elapsed  ( +-  0.68% )

  [2]

   Performance counter stats for 'nmcli' (50 runs):

              477.99 msec task-clock:u              #    1.088 CPUs utilized            ( +-  0.36% )
                   0      context-switches:u        #    0.000 K/sec
                   0      cpu-migrations:u          #    0.000 K/sec
               5,948      page-faults:u             #    0.012 M/sec                    ( +-  0.03% )
       1,471,133,482      cycles:u                  #    3.078 GHz                      ( +-  0.36% )
       1,655,275,369      instructions:u            #    1.13  insn per cycle           ( +-  0.02% )
         382,595,152      branches:u                #  800.433 M/sec                    ( +-  0.02% )
           4,746,070      branch-misses:u           #    1.24% of all branches          ( +-  0.49% )

             0.43923 +- 0.00242 seconds time elapsed  ( +-  0.55% )

  [3]

   Performance counter stats for 'nmcli' (50 runs):

              352.36 msec task-clock:u              #    1.027 CPUs utilized            ( +-  0.32% )
                   0      context-switches:u        #    0.000 K/sec
                   0      cpu-migrations:u          #    0.000 K/sec
               4,790      page-faults:u             #    0.014 M/sec                    ( +-  0.26% )
       1,092,341,186      cycles:u                  #    3.100 GHz                      ( +-  0.26% )
       1,209,045,283      instructions:u            #    1.11  insn per cycle           ( +-  0.02% )
         281,708,462      branches:u                #  799.499 M/sec                    ( +-  0.01% )
           3,101,031      branch-misses:u           #    1.10% of all branches          ( +-  0.61% )

             0.34296 +- 0.00120 seconds time elapsed  ( +-  0.35% )

---

N5) same setup as N4), but run `PAGER= /bin/time -v nmcli`:

  [1]

        Command being timed: "nmcli"
        User time (seconds): 0.42
        System time (seconds): 0.04
        Percent of CPU this job got: 107%
        Elapsed (wall clock) time (h:mm:ss or m:ss): 0:00.43
        Average shared text size (kbytes): 0
        Average unshared data size (kbytes): 0
        Average stack size (kbytes): 0
        Average total size (kbytes): 0
        Maximum resident set size (kbytes): 34456
        Average resident set size (kbytes): 0
        Major (requiring I/O) page faults: 0
        Minor (reclaiming a frame) page faults: 6128
        Voluntary context switches: 1298
        Involuntary context switches: 1106
        Swaps: 0
        File system inputs: 0
        File system outputs: 0
        Socket messages sent: 0
        Socket messages received: 0
        Signals delivered: 0
        Page size (bytes): 4096
        Exit status: 0

  [2]
        Command being timed: "nmcli"
        User time (seconds): 0.44
        System time (seconds): 0.04
        Percent of CPU this job got: 108%
        Elapsed (wall clock) time (h:mm:ss or m:ss): 0:00.44
        Average shared text size (kbytes): 0
        Average unshared data size (kbytes): 0
        Average stack size (kbytes): 0
        Average total size (kbytes): 0
        Maximum resident set size (kbytes): 34452
        Average resident set size (kbytes): 0
        Major (requiring I/O) page faults: 0
        Minor (reclaiming a frame) page faults: 6169
        Voluntary context switches: 1849
        Involuntary context switches: 142
        Swaps: 0
        File system inputs: 0
        File system outputs: 0
        Socket messages sent: 0
        Socket messages received: 0
        Signals delivered: 0
        Page size (bytes): 4096
        Exit status: 0

  [3]

        Command being timed: "nmcli"
        User time (seconds): 0.32
        System time (seconds): 0.02
        Percent of CPU this job got: 102%
        Elapsed (wall clock) time (h:mm:ss or m:ss): 0:00.34
        Average shared text size (kbytes): 0
        Average unshared data size (kbytes): 0
        Average stack size (kbytes): 0
        Average total size (kbytes): 0
        Maximum resident set size (kbytes): 29196
        Average resident set size (kbytes): 0
        Major (requiring I/O) page faults: 0
        Minor (reclaiming a frame) page faults: 5059
        Voluntary context switches: 919
        Involuntary context switches: 685
        Swaps: 0
        File system inputs: 0
        File system outputs: 0
        Socket messages sent: 0
        Socket messages received: 0
        Signals delivered: 0
        Page size (bytes): 4096
        Exit status: 0

---

N6) same setup as N4), but run `nmcli monitor` and look at `ps aux` for
  the RSS size.

      USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
  [1] me     1492900 21.0  0.2 461348 33248 pts/10   Sl+  15:02   0:00 nmcli monitor
  [2] me     1490721  5.0  0.2 461496 33548 pts/10   Sl+  15:00   0:00 nmcli monitor
  [3] me     1495801 16.5  0.1 459476 28692 pts/10   Sl+  15:04   0:00 nmcli monitor
2019-11-25 15:08:00 +01:00
Thomas Haller 18c5ce50fb build: create base directories for install-data-hook first
The dependencies of make are exectured in the order as they appear.
We probably should start by creating the directories, before invoking
other install hooks. Currently there is no difference, because none of
the other hooks depend on the base directories. Still split it to
a special target.
2019-11-22 15:59:31 +01:00
Thomas Haller d1eb52f8ce build: cleanup Makefile.am by moving "data_edit" first
$(data_edit) will be used later at an earlier place in the
makefile (to edit "clients/cloud-setup/nm-cloud-setup.service",
which will be handled earlier). Move it.

Also minor cleanups, like allowing to incrementally build
systemdsystemunit_DATA variable.
2019-11-22 15:59:31 +01:00
Thomas Haller c016165e1b systemd: merge branch systemd into master 2019-11-20 09:22:53 +01:00
Thomas Haller 8f37a0ae0a build: link "nm-enum-types.c" with the base "liblibnm" instead of "libnm"
This way the symbols are also available to the unit tests.
2019-10-18 22:09:18 +02:00
Lubomir Rintel 7061341a41 cli: add "nmcli d wifi show"
A quick overview of the currently connected Wi-Fi network, including
credentials. Comes handy if someone wants to connect more devices to
their Hotspot or the same network as they are connected to.
2019-10-18 17:38:57 +02:00
Iñigo Martínez 42a8533d5f meson: Remove devices tests' meson build files
The devices tests' meson build files include only the build of a
single executable file and its execution as a test unit.

This has been moved to the devices' main meson build files so this
files can be removed.
2019-10-01 09:49:33 +02:00
Iñigo Martínez 05c7a77022 meson: Add missing "nm-bt-test" helper program
In 878d4963e a new `nm-bt-test` helper program was added. However,
although `autotools` build steps were included, meson build steps
were not.

This add meson's build steps.
2019-10-01 09:49:33 +02:00
Beniamino Galvani a79572c261 build: avoid target redefinition
Makefile.am:3462: warning: $(src_devices_bluetooth_libnm_device_plugin_bluetooth_la_OBJECTS) was already defined in condition TRUE, which includes condition WITH_MODEM_MANAGER_1 ...
 Makefile.am:960: ... '$(src_devices_bluetooth_libnm_device_plugin_bluetooth_la_OBJECTS)' previously defined here

Fixes: 878d4963ed ('bluetooth/tests: add "nm-bt-test helper" program for manual testing of bluetooth code')
2019-09-24 15:39:26 +02:00
Thomas Haller 4154d9618c bluetooth: refactor BlueZ handling and let NMBluezManager cache ObjectManager data
This is a complete refactoring of the bluetooth code.

Now that BlueZ 4 support was dropped, the separation of NMBluezManager
and NMBluez5Manager makes no sense. They should be merged.

At that point, notice that BlueZ 5's D-Bus API is fully centered around
D-Bus's ObjectManager interface. Using that interface, we basically only
call GetManagedObjects() once and register to InterfacesAdded,
InterfacesRemoved and PropertiesChanged signals. There is no need to
fetch individual properties ever.

Note how NMBluezDevice used to query the D-Bus properties itself by
creating a GDBusProxy. This is redundant, because when using the ObjectManager
interfaces, we have all information already.

Instead, let NMBluezManager basically become the client-side cache of
all of BlueZ's ObjectManager interface. NMBluezDevice was mostly concerned
about caching the D-Bus interface's state, tracking suitable profiles
(pan_connection), and moderate between bluez and NMDeviceBt.
These tasks don't get simpler by moving them to a seprate file. Let them
also be handled by NMBluezManager.

I mean, just look how it was previously: NMBluez5Manager registers to
ObjectManager interface and sees a device appearing. It creates a
NMBluezDevice object and registers to its "initialized" and
"notify:usable" signal. In the meantime, NMBluezDevice fetches the
relevant information from D-Bus (although it was already present in the
data provided by the ObjectManager) and eventually emits these usable
and initialized signals.
Then, NMBlue5Manager emits a "bdaddr-added" signal, for which NMBluezManager
creates the NMDeviceBt instance. NMBluezManager, NMBluez5Manager and
NMBluezDevice are strongly cooperating to the point that it is simpler
to merge them.

This is not mere refactoring. This patch aims to make everything
asynchronously and always cancellable. Also, it aims to fix races
and inconsistencies of the state.

- Registering to a NAP server now waits for the response and delays
  activation of the NMDeviceBridge accordingly.

- For NAP connections we now watch the bnep0 interface in platform, and tear
  down the device when it goes away. Bluez doesn't send us a notification
  on D-Bus in that case.

- Rework establishing a DUN connection. It no longer uses blocking
  connect() and does not block until rfcomm device appears. It's
  all async now. It also watches the rfcomm file descriptor for
  POLLERR/POLLHUP to notice disconnect.

- drop nm_device_factory_emit_component_added() and instead let
  NMDeviceBt directly register to the WWan factory's "added" signal.
2019-09-23 12:47:37 +02:00
Thomas Haller 878d4963ed bluetooth/tests: add "nm-bt-test helper" program for manual testing of bluetooth code
Just add a stub implementation and let it build. More will be added
later.
2019-09-22 16:05:50 +02:00
Thomas Haller 908fadec96 shared: add NMRefString
I'd like to refactor libnm's caching. Note that cached D-Bus objects
have repeated strings all over the place. For example every object will
have a set of D-Bus interfaces (strings) and properties (strings) and an
object path (which is referenced by other objects). We can save a lot of
redundant strings by deduplicating/interning them. Also, by interning
them, we can compare them using pointer equality.

Add a NMRefString implementation for this.

Maybe an alternative name would be NMInternedString or NMDedupString, because
this string gets always interned. There is no way to create a NMRefString
that is not interned. Still, NMRefString name sounds better. It is ref-counted
after all.

Notes:

 - glib has GQuark and g_intern_string(). However, such strings cannot
   be unrefered and are leaked indefinitely. It is thus unsuited for
   anything but a fixed set of well-known strings.

 - glib 2.58 adds GRefString, but we cannot use that because we
   currently still use glib 2.40.
   There are some differences:

     - GRefString is just a typedef to char. That means, the glib API
       exposes GRefString like regular character strings.
       NMRefString intentionally does that not. This makes it slightly
       less convenient to pass it to API that expects "const char *".
       But it makes it clear to the reader, that an instance is in fact
       a NMRefString, which means it indicates that the string is
       interned and can be referenced without additional copy.

     - GRefString can be optionally interned. That means you can
       only use pointer equality for comparing values if you know
       that the GRefString was created with g_ref_string_new_intern().
       So, GRefString looks like a "const char *" pointer and even if
       you know it's a GRefString, you might not know whether it is
       interned. NMRefString is always interned, and you can always
       compare it using pointer equality.

  - In the past I already proposed a different implementation for a
    ref-string. That made different choices. For example NMRefString
    then was a typedef to "const char *", it did not support interning
    but deduplication (without a global cache), ref/unref was not
    thread safe (but then there was no global cache so that two threads
    could still use the API independently).

The point is, there are various choices to make. GRefString, the
previous NMRefString implementation and the one here, all have pros and
cons. I think for the purpose where I intend NMRefString (dedup and
efficient comparison), it is a preferable implementation.

Ah, and of course NMRefString is an immutable string, which is a nice
property.
2019-09-21 14:58:26 +02:00
Francesco Giudici 15035e2b0d meson: fix build_clean.sh -w meson -w test
Fixes: 6e5385a4eb ('wwan/tests: test service-providers.xml parser')
2019-09-13 12:59:03 +02:00
Lubomir Rintel 4af856a71b build: make test-service-providers depend on nm-core-enum-types.h
Fixes build:

  In file included from ../src/devices/wwan/nm-service-providers.c:10:
  In file included from ../shared/nm-default.h:279:
  ../libnm-core/nm-core-types.h:14:10: fatal error: 'nm-core-enum-types.h' file not found
  #include "nm-core-enum-types.h"
           ^
  1 error generated.
  make[2]: *** [src/devices/wwan/src_devices_wwan_tests_test_service_providers-nm-service-providers.o] Error 1
2019-09-11 16:42:59 +02:00
Lubomir Rintel 6e5385a4eb wwan/tests: test service-providers.xml parser
Just a handful of unit tests.
2019-09-11 14:32:05 +02:00
Lubomir Rintel 6632c77094 wwan: add service-providers.xml parser
This allows up to look up a default APN if the user doesn't pick one.
2019-09-11 14:32:05 +02:00
Lubomir Rintel 986947dbf5 initrd: fix dt test 2019-09-10 14:11:16 +02:00
Lubomir Rintel e9f2ea6c22 COPYING: make sure we ship the relevant license texts
This adds LGPL and GFDL texts from the GNU web site and updates the GPL
one:

  COPYING: https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
  COPYING.LGPL: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
  COPYING.GFDL: https://www.gnu.org/licenses/old-licenses/fdl-1.1.txt

The update to the GPL text is purely cosmetic. However, shipping the
exact same file as GNU publishes may help distros that deduplicate the
license texts or hardlink duplicates.
2019-09-10 11:10:52 +02:00
Lubomir Rintel 7a72c705ac initrd: add devicetree support
This adds capability to hand over the network configuration from
OpenFirmware (and potentially other boot loaders with openfirmware
support such as U-Boot) to NetworkManager.

It's done analogously to ACPI/iBFT. In fact, the same ip=ibft command
line option is used, adding a more general ip=fw alias. This probably
deserves some documentation, but I'm not adding any at this time.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/257
2019-09-10 11:04:51 +02:00
Beniamino Galvani 11cf082a62 build: use regexp in gtkdoc --ignore-decorators option
gtkdoc-scan supports regular expressions in the --ignore-decorators
command-line option. Since it is easier to use a regexp than grepping
macros from a source file, revert the ugly solution from commit
2d941dc95a ('build: fix errors when building with gtk-doc 1.32').
2019-09-06 14:18:24 +02:00
Francesco Giudici a0498e0829 meson: fix build_clean.sh -w meson -w test
Fixes: 2d941dc95a ('build: fix errors when building with gtk-doc 1.32')
2019-09-05 13:07:41 +02:00
Thomas Haller a49027ab22 ifupdown/tests: add test with duplicate interfaces
This file causes a crash [1], add it to the tests.
Note that the test only check parsing the file and the
crash happens in the "upper" layers. So, it's not really
a test for the crash. But at least have such a file in
our repository.

[1] https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/235
2019-08-24 13:38:33 +02:00
Francesco Giudici ed5cd288c4 meson: fix build_clean.sh -w meson -w test
Fixes: 00bb6cdb4f ('build: fix meson warning about path separator in target')
2019-08-22 11:16:31 +02:00
Thomas Haller 907ea97088 bluetooth: drop BlueZ 4 support (1)
BlueZ 5.0 was released in December 2012 and broke API with
BlueZ 4. NetworkManager supports Bluez 5 for years already.

Of course, version 4 is long gone by now, so remove it.
2019-08-12 16:05:30 +02:00
Thomas Haller f6d7af9ca6 systemd: merge branch systemd into master 2019-07-26 15:00:08 +02:00
Thomas Haller d35d3c468a settings: rework tracking settings connections and settings plugins
Completely rework how settings plugin handle connections and how
NMSettings tracks the list of connections.

Previously, settings plugins would return objects of (a subtype of) type
NMSettingsConnection. The NMSettingsConnection was tightly coupled with
the settings plugin. That has a lot of downsides.

Change that. When changing this basic relation how settings connections
are tracked, everything falls appart. That's why this is a huge change.
Also, since I have to largely rewrite the settings plugins, I also
added support for multiple keyfile directories, handle in-memory
connections only by keyfile plugin and (partly) use copy-on-write NMConnection
instances. I don't want to spend effort rewriting large parts while
preserving the old way, that anyway should change. E.g. while rewriting ifcfg-rh,
I don't want to let it handle in-memory connections because that's not right
long-term.

--

If the settings plugins themself create subtypes of NMSettingsConnection
instances, then a lot of knowledge about tracking connections moves
to the plugins.
Just try to follow the code what happend during nm_settings_add_connection().
Note how the logic is spread out:
 - nm_settings_add_connection() calls plugin's add_connection()
 - add_connection() creates a NMSettingsConnection subtype
 - the plugin has to know that it's called during add-connection and
   not emit NM_SETTINGS_PLUGIN_CONNECTION_ADDED signal
 - NMSettings calls claim_connection() which hocks up the new
   NMSettingsConnection instance and configures the instance
   (like calling nm_settings_connection_added()).
This summary does not sound like a lot, but try to follow that code. The logic
is all over the place.

Instead, settings plugins should have a very simple API for adding, modifying,
deleting, loading and reloading connections. All the plugin does is to return a
NMSettingsStorage handle. The storage instance is a handle to identify a profile
in storage (e.g. a particular file). The settings plugin is free to subtype
NMSettingsStorage, but it's not necessary.
There are no more events raised, and the settings plugin implements the small
API in a straightforward manner.
NMSettings now drives all of this. Even NMSettingsConnection has now
very little concern about how it's tracked and delegates only to NMSettings.

This should make settings plugins simpler. Currently settings plugins
are so cumbersome to implement, that we avoid having them. It should not be
like that and it should be easy, beneficial and lightweight to create a new
settings plugin.

Note also how the settings plugins no longer care about duplicate UUIDs.
Duplicated UUIDs are a fact of life and NMSettings must handle them. No
need to overly concern settings plugins with that.

--

NMSettingsConnection is exposed directly on D-Bus (being a subtype of
NMDBusObject) but it was also a GObject type provided by the settings
plugin. Hence, it was not possible to migrate a profile from one plugin to
another.
However that would be useful when one profile does not support a
connection type (like ifcfg-rh not supporting VPN). Currently such
migration is not implemented except for migrating them to/from keyfile's
run directory. The problem is that migrating profiles in general is
complicated but in some cases it is important to do.

For example checkpoint rollback should recreate the profile in the right
settings plugin, not just add it to persistent storage. This is not yet
properly implemented.

--

Previously, both keyfile and ifcfg-rh plugin implemented in-memory (unsaved)
profiles, while ifupdown plugin cannot handle them. That meant duplication of code
and a ifupdown profile could not be modified or made unsaved.
This is now unified and only keyfile plugin handles in-memory profiles (bgo #744711).
Also, NMSettings is aware of such profiles and treats them specially.
In particular, NMSettings drives the migration between persistent and non-persistent
storage.

Note that a settings plugins may create truly generated, in-memory profiles.
The settings plugin is free to generate and persist the profiles in any way it
wishes. But the concept of "unsaved" profiles is now something explicitly handled
by keyfile plugin. Also, these "unsaved" keyfile profiles are persisted to file system
too, to the /run directory. This is great for two reasons: first of all, all
profiles from keyfile storage in fact have a backing file -- even the
unsaved ones. It also means you can create "unsaved" profiles in /run
and load them with `nmcli connection load`, meaning there is a file
based API for creating unsaved profiles.
The other advantage is that these profiles now survive restarting
NetworkManager. It's paramount that restarting the daemon is as
non-disruptive as possible. Persisting unsaved files to /run improves
here significantly.

--

In the past, NMSettingsConnection also implemented NMConnection interface.
That was already changed a while ago and instead users call now
nm_settings_connection_get_connection() to delegate to a
NMSimpleConnection. What however still happened was that the NMConnection
instance gets never swapped but instead the instance was modified with
nm_connection_replace_settings_from_connection(), clear-secrets, etc.
Change that and treat the NMConnection instance immutable. Instead of modifying
it, reference/clone a new instance. This changes that previously when somebody
wanted to keep a reference to an NMConnection, then the profile would be cloned.
Now, it is supposed to be safe to reference the instance directly and everybody
must ensure not to modify the instance. nmtst_connection_assert_unchanging()
should help with that.
The point is that the settings plugins may keep references to the
NMConnection instance, and so does the NMSettingsConnection. We want
to avoid cloning the instances as long as they are the same.
Likewise, the device's applied connection can now also be referenced
instead of cloning it. This is not yet done, and possibly there are
further improvements possible.

--

Also implement multiple keyfile directores /usr/lib, /etc, /run (rh #1674545,
bgo #772414).

It was always the case that multiple files could provide the same UUID
(both in case of keyfile and ifcfg-rh). For keyfile plugin, if a profile in
read-only storage in /usr/lib gets modified, then it gets actually stored in
/etc (or /run, if the profile is unsaved).

--

While at it, make /etc/network/interfaces profiles for ifupdown plugin reloadable.

--

https://bugzilla.gnome.org/show_bug.cgi?id=772414
https://bugzilla.gnome.org/show_bug.cgi?id=744711
https://bugzilla.redhat.com/show_bug.cgi?id=1674545
2019-07-16 19:09:08 +02:00
Thomas Haller ec77d477a8 build: dist test file "test-tpm2wrapped-key.pem"
Fixes: 107ba8e00c ('libnm/crypto: accept TPM2-wrapped PEM keys')
2019-07-11 09:48:56 +02:00
Beniamino Galvani deba9c4b86 build: add missing dependency for shared/systemd/src/shared
In file included from ./shared/systemd/sd-adapt-shared/nm-sd-adapt-shared.h:21,
                  from shared/systemd/src/shared/dns-domain.c:3:
 ./shared/nm-default.h:106:10: fatal error: config-extra.h: No such file or directory
  #include "config-extra.h"
          ^~~~~~~~~~~~~~~~
 compilation terminated.
 make[1]: *** [Makefile:12933: shared/systemd/src/shared/libnm_systemd_shared_la-dns-domain.lo] Error 1

Fixes: 7d3098ff90 ('systemd: add dns-domain utils to systemd static library')
2019-07-08 15:03:54 +02:00
Francesco Giudici eed205bff3 dhcp/internal: move dhcp options management to shared dhcp codebase 2019-07-05 15:13:09 +02:00
Francesco Giudici a6036b2352 dhcp: access internal systemd structure to retrieve dhcp private options 2019-07-05 14:12:21 +02:00
Beniamino Galvani 7d3098ff90 systemd: add dns-domain utils to systemd static library
dns-domain.c contains useful functions for manipulating DNS names.
Add it to the systemd static library we build in shared/, similarly to
what we already do for other utility files that were originally in
src/systemd/src/basic/.
2019-07-05 11:04:32 +02:00
Tom Gundersen 6adade6f21 dhcp: add nettools dhcp4 client
This is inspired by the existing systemd integration, with a few differences:

* This parses the WPAD option, which systemd requested, but did not use.
* We hook into the DAD handling, only making use of the configured address
  once DAD has completed successfully, and declining the lease if it fails.

There are still many areas of possible improvement. In particular, we need
to ensure the parsing of all options are compliant, as n-dhcp4 treats all
options as opaque, unlike sd-dhcp4. We probably also need to look at how
to handle failures and retries (in particular if we decline a lease).

We need to query the current MTU at client startu, as well as the hardware
broadcast address. Both these are provided by the kernel over netlink, so
it should simply be a matter of hooking that up with NM's netlink layer.

Contribution under LGPL2.0+, in addition to stated licenses.
2019-07-05 11:04:32 +02:00
Beniamino Galvani be8f7b5a5d systemd: merge branch systemd into master 2019-07-05 09:13:53 +02:00
Thomas Haller 74641be816 settings: drop ibft settings plugin
The functionality of the ibft settings plugin is now handled by
nm-initrd-generator. There is no need for it anymore, drop it.

Note that ibft called iscsiadm, which requires CAP_SYS_ADMIN to work
([1]). We really want to drop this capability, so the current solution
of a settings plugin (as it is implemented) is wrong. The solution
instead is nm-initrd-generator.

Also, on Fedora the ibft was disabled and probably on most other
distributions as well. This was only used on RHEL.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1371201#c7
2019-06-20 16:06:44 +02:00
Lubomir Rintel 11d59de600 build/autotools: generate "config-extra.h" via makefile "config-extra.h.mk"
When the code that generates "config-extra.h" changes, we want to regenerate
the file. Move that code to a separate makefile so we can add a
dependency.

Otherwise, we'd had to depend on "Makefile", which itself is generated by
Makefile.am.

Also, depend on "config.h" to regenerate it when ./configure runs and
touches that header. This may not cover all cases where ./configure's
configuration changes and a regeneration would be due. But such is life.

Also, most components depend on this header, so let various .dirstamp
files depend on it, so we are sure to build this first. That because,
autotools generates dependencies for header files automatically, but
that requires that the header file exist. Such automatic dependencies
don't work out-of-the-box for generated headers.

Co-authored-by: Thomas Haller <thaller@redhat.com>
2019-06-17 17:42:09 +02:00
Thomas Haller 721f238946 build/autotools: depend "config-extra.h" on "config.h"
"config-extra.h" is really just like "config.h", except it works around some
limitations of autoconf.

If we depend on "Makefile", any changes to "Makefile.am" will cause a full
rebuild. We want to avoid that.

Instead, depend on "config.h". That one only changes when configure runs
again. And that's the better dependancy, because "config-extra.h" is
generated based on informations generated by configure (despite being
generated by "Makefile").
2019-06-17 13:00:37 +02:00
Thomas Haller 7ed1fc817f Revert "build: only update config-extra.h if it changes"
Not touching "config-extra.h" means that the target is rebuild every
time (because the timestampt does not get updated). On the other hand,
touching it will cause a full rebuild (which we often want to avoid).

The right solution is instead to depend on "config.h", which will be
done next.

This reverts commit 14271d84a0.
2019-06-17 12:54:04 +02:00
Lubomir Rintel a26abc797c libnm-core: add ovs-dpdk setting 2019-06-14 12:10:20 +02:00
Lubomir Rintel 14271d84a0 build: only update config-extra.h if it changes
This is to avoid updating config-extra.h timestamp very time one touches
Makefile.am, because it has a large dependency chain and makes
debugging of the Makefile inconvenient.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/180
2019-06-14 09:21:24 +02:00
Beniamino Galvani e6628fa27c ipv6: add 'disabled' method
Add a new ipv6.method value 'disabled' that completely disables IPv6
for the interface.

https://bugzilla.redhat.com/show_bug.cgi?id=1643841
2019-06-11 16:22:04 +02:00
Thomas Haller 15d87f2da0 ifcfg-rh: drop unused "nm-inotify-helper.h"
This code is now unused.

Also, it does not seem state of the art to me
anymore.

Drop it, it could always be resurrected if need by, but maybe
GFileMonitor could be used instead.
2019-05-29 09:31:03 +02:00
Beniamino Galvani 9a410fc312 ifcfg-rh: use PKCS #12 private key also as client cert in reader
Before commit e3ac45c026 the reader set the private key in the
setting using the libnm function, which also set the key as client
certificate if it was in PKCS #12 format.

After the commit, existing connections with a PKCS #12 private key but
without a client certificate became invalid. Restore the old behavior.

Fixes: e3ac45c026 ('ifcfg-rh: don't use 802-1x certifcate setter functions')
2019-05-28 10:51:47 +02:00
Thomas Haller f809644866 build: don't link dispatcher with generated nmdbus-dispatcher bindings
We don't need it anymore.

Still, for tests let gdbus-codegen run and generate the sources and
compile them. We want to keep "dispatcher/nm-dispatcher.xml" and ensure
that it is still valid.
2019-05-27 12:39:25 +02:00
Thomas Haller 539dfbcc42 libnm: add "libnm-core/nm-team-utils.h" 2019-05-23 18:09:49 +02:00
Thomas Haller e64fdeeaf6 shared: add "shared/nm-glib-aux/nm-value-type.h"
Glib has GValue which used for boxing value.

Add NMValueType enum, which has a similar purpose, but it's much more
limited.

- contrary to GValue, the type must be tracked separately from the
  user-data. That is, the "user-data" is only a pointer of appropriate
  type, and the knowledge of the actual NMValueType is kept separately.
  This will be used to have a static list of meta-data that knows the
  value types, but keeping the values independent of this type
  information. With GValue this would not be possible.

- the use case is much more limited. Just support basic integers,
  boolean and strings. Nothing fancy.

Note that we already do something similar at muliple places. See for
example NMVariantAttributeSpec and nm_utils_team_link_watcher_to_string().
These could/should instead use NMValueType.
2019-05-23 18:09:49 +02:00
Thomas Haller f84e623732 shared: add "shared/nm-glib-aux/nm-json-aux.h"
This will be a set of JSON related utilities, that are independent of
libjansson.
2019-05-23 18:09:49 +02:00
Thomas Haller e7056d4efd build: don't statically link static libraries with other static libraries (6) 2019-05-22 20:04:08 +02:00
Thomas Haller 15e224fd59 build: don't statically link static libraries with other static libraries (5) 2019-05-22 20:04:08 +02:00
Thomas Haller 0a510ed1cf build: don't statically link static libraries with other static libraries (4) 2019-05-22 20:04:08 +02:00
Thomas Haller 53168b0d2c build: drop trivial variables from Makefile.am
It just hides what we link. Link against GLIB explicitly
instead of indirectly via another variable.
2019-05-22 20:04:08 +02:00
Thomas Haller c808191846 build: don't statically link static libraries with other static libraries (3) 2019-05-22 20:04:08 +02:00
Thomas Haller b5850cb4d4 build: don't statically link static libraries with other static libraries (2) 2019-05-22 20:04:08 +02:00
Thomas Haller 1a24f3ae8d build: don't statically link static libraries with other static libraries (1)
When we link static libraries together, there must be no duplicate
symbols.

Since we have a lot of static/intermediate libraries, getting this right
is complicated and sometimes leads to ugly solutions.

As a new rule: don't let static libraries link with other static
libraries. Only binaries and libnm/libnm.la should explicitly link
with all the static libraries that they require.

There are exceptions: "src/libNetworkManager.la" and "libnm/liblibnm.la".
These are static, internal libraries, but they are basically *everything*
that ends up in "src/NetworkManager" and "libnm/libnm.la", respecitively.
Hence, these static libraries also link against other static libraries.
Another exception to this rule is "src/libNetworkManagerTest.la", for
similar reasons.
2019-05-22 20:04:08 +02:00
Thomas Haller d8eb9e7515 build: link src/NetworkManager explicitly with glib
We compile src/main.c as part of src/NetworkManager. Explicitly link with
glib, because that is required by the source code. Apparently, it also
works without this, but still do it for correctness.
2019-05-22 20:04:08 +02:00
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
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