Commit graph

750 commits

Author SHA1 Message Date
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
Beniamino Galvani 10ca2444b9 build: support meson builds in create-exports script
(cherry picked from commit 9b4bc0824c)
2018-09-13 14:35:25 +02:00
Beniamino Galvani fb0d36a883 build: add config-extra.h.meson to EXTRA_DIST
Reported-by: Michael Biebl <biebl@debian.org>
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/22
(cherry picked from commit 5ebe5efa7a)
2018-09-13 14:35:23 +02:00
Beniamino Galvani 4fd6623161 build: move paths of dhcp clients from config-extra.h to config.h
Some path variable like $(bindir), $(datadir), etc. are special for
autotools and must be handled separately through config-extra.h.

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

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

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

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

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

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

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

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

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

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

Advantages:

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

- previously, whenever we added tests, all .expected files shifted
  and the diff was large. Now, there is a chance that the diff is
  smaller and more accurate.
2018-07-25 17:08:37 +02:00
Lubomir Rintel 0413704470 rpm: own /etc/sysconfig/network-scripts
We don't rely on initscripts. If they're gone, we still use the
directory.
2018-07-24 19:10:15 +02:00
Thomas Haller e9d9fc3fa0 shared/gsystem-local-alloc: merge "gsystem-local-alloc.h" into "nm-macros-shared.h"
We only have a certain granularity of how our headers in "shared/nm-utils"
can be used independently.

For example, it's not supported to use "nm-macros-internal.h" without
"gsystem-local-alloc.h". Likewise, you cannot use "nm-glib.h" directly,
you always get it together with "nm-macros-internal.h".

This is, we don't support to use certain headers entirely independently,
because usually you anyway want to use them together.

As such, no longer support "gsystem-local-alloc.h", but merge the
remainder into "nm-macros-internal.h". There is really no reason
to support arbitrary flexibility of including individual bits. You
want cleanup-macros? Include "nm-macros-internal.h".

Merge the headers.
2018-07-18 10:21:27 +02:00
Thomas Haller b9bc20f4da build: pass -std=gnu99 to compiler
With --enable-more-warnings, we already used -std=gnu99, see
commit ba2b2de3ad.

Compilation may behave differently depending on the selected
C standard that we choose. It seems wrong, with more-warnings,
to build against a C standard, while otherwise leaving it undefind.

Indeed, one might argue, that our build system should not use
such compiler specific options. At least, not without detecting
support for the compiler option during ./configure.

However:

- we already did this for --enable-more-warnings.

- we should not program against a theoretical compiler. In practice,
  only gcc and clang works to build NetworkManager. Both these compilers
  support this option, so there is no reason to not use it. If we ever
  come into the situation to support another compiler, adjusting -std=gnu99
  will be the smallest problem. Until that happens (and that's far from
  imminent), don't pretend to be portable to non-existing compilers and
  use the flag that in practice is available.

See-also: https://gcc.gnu.org/onlinedocs/gcc/Standards.html
2018-07-17 17:46:39 +02:00
Thomas Haller 00a523c4f3 build: cleanup CFLAGS for Makefile.am
Reduce duplication of CFLAGS.
2018-07-17 17:46:39 +02:00
Thomas Haller a75ab799e4 build: create "config-extra.h" header instead of passing directory variables via CFLAGS
1) the command line gets shorter. I frequently run `make V=1` to see
   the command line arguments for the compiler, and there is a lot
   of noise.

2) define each of these variables at one place. This makes it easy
   to verify that for all compilation units, a particular
   define has the same value. Previously that was not obvious or
   even not the case (see commit e5d1a71396
   and commit d63cf1ef2f).
   The point is to avoid redundancy.

3) not all compilation units need all defines. In fact, most modules
   would only need a few of these defines. We aimed to pass the necessary
   minium of defines to each compilation unit, but that was non-obvious
   to get right and often we set a define that wasn't used. See for example
   "src_settings_plugins_ibft_cppflags" which needlessly had "-DSYSCONFDIR".
   This question is now entirely avoided by just defining all variables in
   a header. We don't care to find the minimum, because every component
   gets anyway all defines from the header.

4) this also avoids the situation, where a module that previously did
   not use a particular define gets modified to require it. Previously,
   that would have required to identify the missing define, and add
   it to the CFLAGS of the complation unit. Since every compilation
   now includes "config-extra.h", all defines are available everywhere.

5) the fact that each define is now available in all compilation units
   could be perceived as a downside. But it isn't, because these defines
   should have a unique name and one specific value. Defining the same
   name with different values, or refer to the same value by different
   names is a bug, not a desirable feature. Since these defines should
   be unique accross the entire tree, there is no problem in providing
   them to every compilation unit.

6) the reason why we generate "config-extra.h" this way, instead of using
   AC_DEFINE() in configure.ac, is due to the particular handling of
   autoconf for directory variables. See [1].
   With meson, it would be trivial to put them into "config.h.meson".
   While that is not easy with autoconf, the "config-extra.h" workaround
   seems still preferable to me.

[1] https://www.gnu.org/software/autoconf/manual/autoconf-2.63/html_node/Installation-Directory-Variables.html
2018-07-17 17:46:39 +02:00
Beniamino Galvani c02d1c488f ifcfg-rh: SR-IOV support 2018-07-11 16:16:22 +02:00
Beniamino Galvani a9b4532fa7 libnm-core: add SR-IOV setting
Add a setting containing SR-IOV parameters.
2018-07-11 16:16:22 +02:00
Lubomir Rintel cb1172ee3d docs: include missing documentation in libnm and D-Bus docs
Check that we don't repeat the omission in future.
2018-06-28 20:38:52 +02:00
Lubomir Rintel 3cd9322298 libnm: add support form 6LoWPAN devices 2018-06-26 16:21:55 +02:00
Lubomir Rintel b7173ad7a7 devices: add NMDevice6Lowpan 2018-06-26 16:21:55 +02:00
Lubomir Rintel 56a6c53de0 introspection: add o.fd.NM.Device.Lowpan interface
It's for 6LoWPAN devices. "o.fd.NM.Device.6Lowpan" wouldn't be a valid
interface name -- just skip the leading numeral, that's what kernel also
does on similiar occassions.
2018-06-26 16:21:55 +02:00
Lubomir Rintel 7c1f3650a1 core: add NMSetting6Lowpan 2018-06-26 16:21:55 +02:00
Lubomir Rintel a3baf1ca21 libnm: add support for WPAN devices 2018-06-26 16:21:55 +02:00
Lubomir Rintel 179909a4f2 devices: add NMDeviceWpan 2018-06-26 16:21:54 +02:00
Lubomir Rintel 9a92468ac2 introspection: add o.fd.NM.Device.Wpan interface 2018-06-26 16:21:54 +02:00
Lubomir Rintel 8884b2cb5e core: add NMSettingWpan 2018-06-26 16:21:54 +02:00
Lubomir Rintel 4120ad2431 platform/wpan: add WPAN utils
Modelled after wifi-utils, sans the complexity of dispatching to anything like
WEXT.
2018-06-26 16:21:54 +02:00
Lubomir Rintel dbb205d8d2 platform: import nl82154.h
This is public Linux API, yet the header is not in uapi.
2018-06-26 16:21:54 +02:00
Lubomir Rintel 91c82cc465 platform/wifi: rename wifi-utils to nm-wifi-utils 2018-06-26 16:21:54 +02:00
Thomas Haller 372c0eb3ed libnm-glib/tests: retry nm-client tests for libnm-glib
They are known to be racy and occasionally break. Especially in
cases where the system's CPU is busy, like during parallel
`make check -j`.

It's likely a bug in libnm-glib. libnm-glib is deprecated, and the
library didn't significantly change now for several releases.
Let's not invest effort into finding bugs in the deprecated library,
bugs that are known to exist. Also, at this point, larger rework
of libnm-glib is not going to happen anymore.

Retry the test up to 5 times, trying to workaround the test failures.
2018-06-25 12:31:31 +02:00
Thomas Haller dd91d0d79c build: fix make distcheck by building --with-libnm-glib
During make-distcheck we pre-generate documentation. For that
we need to build with libnm-glib enabled.

Fixes: df58895fb3
2018-06-15 17:16:18 +02:00
Thomas Haller 13f860970a systemd: merge branch systemd into master 2018-06-15 15:56:04 +02:00
Lubomir Rintel d815130468 ifcfg-rh: add nm-ifup and nm-ifdown scripts
They're intended to be used via update-alternatives(8) as compatibility
shims for Red Hat systems without the legacy network control scripts.

While they're not strictly parts of the settings plugin, they're best
just installed along with it, since they're supposed to be available on
systems that use the ifcfg files.
2018-06-11 15:09:42 +02:00
Thomas Haller b8b6100c78 all: replace systemd's siphash24 with c-siphash
Originally, we used "nm-utils/siphash24.c", which was copied
from systemd's source tree. It was both used by our own NetworkManager
code, and by our internal systemd fork.

Then, we added "shared/c-siphash" as a dependency for n-acd.

Now, drop systemd's implementation and use c-siphash also
for our internal purpose. Also, let systemd code use c-siphash,
by patching "src/systemd/src/basic/siphash24.h".
2018-05-31 15:59:38 +02:00
Thomas Haller b7426e91db build: use default NM_BUILD_* defines for tests
Use two common defines NM_BUILD_SRCDIR and NM_BUILD_BUILDDIR
for specifying the location of srcdir and builddir.

Note that this is only relevant for tests, as they expect
a certain layout of the directories, to find files that concern
them.
2018-05-31 15:59:38 +02:00
Thomas Haller 7fcf33908b build: define NM_BUILD_SRCDIR and NM_BUILD_BUILDDIR 2018-05-31 15:59:38 +02:00
Thomas Haller d63cf1ef2f build: use common locale directory for building nmtui
All other places use $(nmlocaledir) variable.
2018-05-31 15:59:38 +02:00
Thomas Haller e5d1a71396 build: unifiy specifying locale directory define 2018-05-31 15:59:38 +02:00
Thomas Haller 82b088ab5f build: don't add shared/nm-utils directory to include search path
All users are supposed to include files from nm-utils by fully specifying
the path. -I.*shared/nm-utils is wrong.

Only, systemd code likes to include "siphash24.h" directly. Instead of
adding "-Ishared/nm-utils" to the search path, add an intermediary
header to sd-adapt. Note, that in the meantime we anyway should rework
siphash24 to use shared/c-siphash instead.

This also fixes build for meson, which was broken recently.
2018-05-31 15:59:38 +02:00
Thomas Haller ee85151a4a clients/tests: generate Makefile.am for expected files
The developer can re-generate .expected files with

 $ NM_TEST_REGENERATE=1 ./clients/tests/test-client.py

Note that these files are also dist-ed, so that the tests also work
from a source-tarball. For that, we need to add them to EXTRA_DIST.

Previously, this was done manually in the base Makefile.am file. This
was cumbersome, because when adding a new test, the developer would need
to manually add the files.

Now, let the test (with NM_TEST_REGENERATE=1) also generate a makefile
part.
2018-05-27 22:25:44 +02:00
Thomas Haller 5090c1f255 cli/tests: add test for output of nmcli general permissions 2018-05-25 17:24:57 +02:00
Thomas Haller 41dbf2b9d3 clients/tests: drop duplicate tests for German translation
call_nmcli_l() would test for 3 languages: 'C', 'de', and 'pl'. There
is no fundamental difference between 'de' and 'pl', so there is no need
to test for two languages.
2018-05-24 16:40:17 +02:00
Thomas Haller 2cae37ca40 clients/tests: test nmcli output for active-connection state DEACTIVATING 2018-05-24 16:40:17 +02:00
Thomas Haller 7ae5fb7ec6 clients/tests: test nmcli output for multiple activation of same profile
Activate the same profile on two devices. Arguably, real NetworkManager
(currently) does not allow that. But the D-Bus API is fine with
having multiple ActiveConnections for one SettingsConnection.

So, also the client should do something sensible.

Also, later we will add wildcard support to NetworkManager, which means
that a profile can be active multiple times (simultaneously).
2018-05-24 16:40:17 +02:00
Thomas Haller d5e25a4324 clients/tests: print active fields during nmcli con show 2018-05-24 16:40:17 +02:00
Lubomir Rintel 347e3e3689 tests: run the nmcli test with $PYTHON we autoconf'd
Avoids an annoying warning in Fedora:

  |DEPRECATION WARNING: python2 invoked with /usr/bin/python.
      Use /usr/bin/python3 or /usr/bin/python2
      /usr/bin/python will be removed or switched to Python 3 in the future.

Also allows the user to override the Python version that's actually
used.
2018-05-21 10:14:04 +02:00
Thomas Haller d577888d8f systemd: merge branch systemd into master 2018-05-18 17:03:35 +02:00
Thomas Haller 15071e4741 clients/tests: add nmcli test for activating connection
Add a test to call `nmcli con up`, and also how the activated
state looks afterwards.
2018-05-14 17:53:03 +02:00
Thomas Haller 7224461069 clients/tests: add more checks for output of nmcli by language
Let the computer do the hard stuff. Since we already call the tests,
why only check for one language?
2018-05-14 17:53:03 +02:00
Thomas Haller beca21be80 clients/tests: add test for nmcli device wifi output
Thereby, drop unneeded NM_TEST_CLIENT_IN_DBUS_SESSION=0 environment
variable from Makefile.am.
2018-05-14 17:53:03 +02:00
Lubomir Rintel 320422e4cf build: qualify plugin dir name with a version string
This makes package updates more robust, avoiding in-place replaces of
the plugins.

Previously, if an upgrade transaction was terminated, NetworkManager
library could end up being of a different version than the plugins.
If the user was unfortunate enough to connect using a connection that
required a plugin (say, Wi-Fi), he would be left without a network
connection making it somewhat inconvenient to recover from the botched
upgrade.

This makes the whole situation a little bit less sad.

The VPN plugins are kept where they always have been -- the path is not
qualified with a version number.
2018-05-14 16:05:12 +02:00
Thomas Haller d4093a3a2c clients/tests: add python test script for nmcli tests
Add a test which runs nmcli against our stub NetworkManager
service and compares the output.

The output formats of nmcli are complicated and not easily understood.
For example how --mode tabular|multiline interacts with selecting
output-fields (--fields) and output modes ([default]|--terse|--pretty).
Also, there are things like `nmcli connection show --order $FIELD_SPEC`.

We need unit tests to ensure that we don't change the output
accidentally.
2018-05-11 16:51:20 +02:00
Thomas Haller 5e6b0382ad build: let make check re-generate clients/common/settings-doc.h.in with NM_TEST_REGENERATE=1
When building with --disable-introspection, we re-use the pre-generated
clients/common/settings-doc.h.in file.

When building with --enable-introspection, we generate
clients/common/settings-doc.h, and let `make check` verify that the
generated file is identical to what we would generate.

The common case where the generated file differ, is when code changed,
in this case, the developer is advised to update settings-doc.h.in.

Interpret environment variable NM_TEST_REGENERATE=1 to do this
automatically during `make check`.

This will be useful, as there might be several tests that compare a
generated file with a file from version control. NM_TEST_REGENERATE=1
will be the general way to re-generate all these files.

  $ NM_TEST_REGENERATE=1 make check
2018-05-11 16:51:20 +02:00
Thomas Haller 9628aabc2f tests: use libnm via pygobject in tools/test-networkmanager-service.py
tools/test-networkmanager-service.py is our NetworkManager stub server.

NetworkManager uses libnm(-core) heavily, for example to decide whether
a connection verifies (nm_connection_verify()) and for normalizing
connections (nm_connection_normalize()).

If the stub server wants to mimic NetworkManager, it also must use these
function. Luckily, we already can do so, by loading libnm using python
GObject introspection.

We already correctly set GI_TYPELIB_PATH search path, so that the
correct libnm is loaded -- provided that we build with introspection
enabled.

We still need to gracefully fail, if starting the stub server fails.
That requries some extra effort. If the stub server notices that
something is missing, it shall exit with status 77. That will cause
the tests to g_test_skip().
2018-05-11 16:51:20 +02:00
Lubomir Rintel 62363ebc8f Revert "build: qualify plugin dir name with a version string"
This is broken -- looks for VPN plugins in a version-qualified path,
which is wrong and break installed VPN plugins.

This reverts commit 6384ad4ee1.
2018-05-11 10:41:50 +02:00
Lubomir Rintel bcc9e58bfe cli: allow setting the colors with terminal-colors.d(5)
The present version of the specification is somewhat unclear at times,
Unclear points were discussed with the maintainers [1] and probably
some new version will address those.

https://www.spinics.net/lists/util-linux-ng/msg15222.html

Until then here's how the implementation copes with ambiguities
(after the discussion with util-linux maintainers):

1.) It is unclear whether multiple .schem files should override each
    other or be merged. We use the overriding behavior -- take the
    highest priority one and ignore the rest.

2.) We assume "name.schem" is more specific than "@term.schem".

3.) We assume the "Color name" are to be used as aliases for the color
    sequences and translate them to ANSI escape sequences.

4.) The "Escape sequences" are of no use since the specification
    pretty much assumes an ANSI terminal and none of the sequences make
    any sense in ANSI color codes. We don't support them.
    accept that.

5.) We don't implement TERMINAL_COLORS_DEBUG because it's unspecified
    what should it do.
2018-05-10 14:36:58 +02:00
Lubomir Rintel 6384ad4ee1 build: qualify plugin dir name with a version string
This makes package updates more robust, avoiding in-place replaces of
the plugins.

Previously, if an upgrade transaction was terminated, NetworkManager
library could end up being of a different version than the plugins.
If the user was unfortunate enough to connect using a connection that
required a plugin (say, Wi-Fi), he would be left without a network
connection making it somewhat inconvenient to recover from the botched
upgrade.

This makes the whole situation a little bit less sad.
2018-05-09 12:59:39 +02:00
Thomas Haller 896ea5252b build: add missing dependencies for building nmcli 2018-05-05 15:28:24 +02:00
Lubomir Rintel 43e3ebfaa2 build: add a missing dependency
Parallel make failed for me:

  /usr/bin/xsltproc --output man/nm-settings-keyfile.xml ...
    ... man/nm-settings-keyfile.xsl libnm/nm-settings-keyfile-docs.xml
  man/nm-settings-keyfile.xsl:4: warning: failed to load external entity "man/common.ent"
  %entities;
            ^
  man/nm-settings-keyfile.xsl:26: parser error : Entity 'NM_VERSION' not defined
          <refmiscinfo class="version">&NM_VERSION;</refmiscinfo>
                                                   ^
  cannot parse man/nm-settings-keyfile.xsl
  make[2]: *** [Makefile:18130: man/nm-settings-keyfile.xml] Error 4
2018-05-02 14:55:01 +02:00
Thomas Haller b3880b3142 build: fix missing dependency when building clients/tui/newt/libnmt-newt.a
We need to declare explicit dependencies, otherwise, the required header
files may not yet be created when building nmtui helper library.
2018-05-02 13:03:59 +02:00
Beniamino Galvani fa7af768a9 ifcfg-rh: add tests for tc config 2018-04-21 22:09:05 +02:00
Christian Kellner 89af7fbfa6 all: add support for thunderbolt networking
Load the thunderbolt-net module if we see a host-to-host connection
and configure the resulting ethernet connection automatically to be
a link-local only one. The latter is done by setting a new udev
property "NM_AUTO_DEFAULT_LINK_LOCAL_ONLY" which is picked up when
we configure the connection for the device.

https://github.com/NetworkManager/NetworkManager/pull/97
2018-04-19 14:20:04 +02:00
Thomas Haller 21f6058cfe libnm/keyfile: merge keyfile sources (pt2, merge nm-keyfile-writer.c)
Splitting keyfile handling in two "reader.c" and "writer.c" files
is not helpful. What is most interesting, is to see how property XYZ
is serialized to keyfile, and to verify that the parser does the
inverse. For that, it's easier if both the write_xzy() and parse_xyz()
function are beside each other, and not split accross files.

The more important reason is, that both reader and writer have their
separate handler arrays, for special handling of certain properties:
@key_parsers and @key_writers. These two should not be separate but will
be merged. Since they reference static functions, these functions must
all be in the same source file (unless, we put them into headers, which
would be unnecessary complex).

No code was changed, only moved.
2018-04-19 09:36:41 +02:00
Thomas Haller f99dc6b936 libnm/keyfile: merge keyfile sources (pt1, rename nm-keyfile-reader.c)
I am going to merge the files for keyfile handling in libnm-core.
There is a reason for that, I'll tell you next.
2018-04-19 09:36:41 +02:00
Beniamino Galvani 3886cc8e0c core: rename 'arping' to 'acd'
Now that the ACD functionality is no longer using arping, rename
nm-arping-manager to nm-acd-manager and other occurences of arping as
well.
2018-04-18 15:22:34 +02:00
Beniamino Galvani 29a04f54a6 build: autotools: link NM against n-acd 2018-04-18 15:22:16 +02:00
Beniamino Galvani 19876b4cfe shared: drop duplicate c-list.h header
Use the one from the project just imported.
2018-04-18 15:22:14 +02:00
Thomas Haller ffb492678e checkpoint: embed CList in NMCheckpoint instance
We don't need an external CheckpointItem, just to wrap the
CList instance. Embed it directly in NMCheckpoint.

Sure, that exposes the checkpoints_lst field in the (internal)
header file, hiding the private member less.
2018-04-04 14:02:13 +02:00
Thomas Haller ff8e563365 libnm: add nm-autoptr.h header
"nm-autoptr.h" is done in a way that allows you to copy the header
in your source tree to support older versions of libnm, that didn't
contain the header yet. For example, we might want to use it in
network-manager-applet, but we don't want to bump the libnm dependency
to 1.11.2+ only to get this functionality.

Note that G_DEFINE_AUTOPTR_CLEANUP_FUNC() was added in glib 2.43.4,
and requires compiler support for the cleanup attribute. The compiler
support is taken as given, because we rely on it already. However,
NetworkManager and network-manager-applet still don't depend on a glib
version recent enough to provide these macros. To actually use them
(*inside*) NetworkManager/network-manager-applet, we either would have
to bump the glib minimal dependency, or reimplement g_autoptr in
/shared/nm-utils/nm-glib.h compat header.

https://bugzilla.gnome.org/show_bug.cgi?id=794294
2018-03-27 10:36:12 +02:00
Thomas Haller 868c3cedfd dhcp: remove unused nm_utils_resolve_conf_parse() function 2018-03-20 21:03:20 +01:00
Thomas Haller c77784b5ea dhcp: remove unused nm_dhcp_dhclient_read_lease_ip_configs() function 2018-03-20 21:03:20 +01:00
Thomas Haller c1054ec8ff connectivity: always build nm-connectivity.c source
We already do conditional build with "#if WITH_CONCHECK".
Get rid of the conditional in the makefile and instead do
conditional compilating inside the source file "nm-connectivity.c".

The advantage is, now if you want to know which parts are build,
you only need to grep for the WITH_CONCHECK preprocessor define
instead of also caring about the conditional in Makefile.am and
meson.build.

It doesn't change the fact of conditional compilation. But it
consistently uses one mechanism to achieve it.
2018-03-19 14:46:55 +01:00
Thomas Haller 297d4985ab core/dbus: rework D-Bus implementation to use lower layer GDBusConnection API
Previously, we used the generated GDBusInterfaceSkeleton types and glued
them via the NMExportedObject base class to our NM types. We also used
GDBusObjectManagerServer.

Don't do that anymore. The resulting code was more complicated despite (or
because?) using generated classes. It was hard to understand, complex, had
ordering-issues, and had a runtime and memory overhead.

This patch refactors this entirely and uses the lower layer API GDBusConnection
directly. It replaces the generated code, GDBusInterfaceSkeleton, and
GDBusObjectManagerServer. All this is now done by NMDbusObject and NMDBusManager
and static descriptor instances of type GDBusInterfaceInfo.

This adds a net plus of more then 1300 lines of hand written code. I claim
that this implementation is easier to understand. Note that previously we
also required extensive and complex glue code to bind our objects to the
generated skeleton objects. Instead, now glue our objects directly to
GDBusConnection. The result is more immediate and gets rid of layers of
code in between.
Now that the D-Bus glue us more under our control, we can address issus and
bottlenecks better, instead of adding code to bend the generated skeletons
to our needs.

Note that the current implementation now only supports one D-Bus connection.
That was effectively the case already, although there were places (and still are)
where the code pretends it could also support connections from a private socket.
We dropped private socket support mainly because it was unused, untested and
buggy, but also because GDBusObjectManagerServer could not export the same
objects on multiple connections. Now, it would be rather straight forward to
fix that and re-introduce ObjectManager on each private connection. But this
commit doesn't do that yet, and the new code intentionally supports only one
D-Bus connection.
Also, the D-Bus startup was simplified. There is no retry, either nm_dbus_manager_start()
succeeds, or it detects the initrd case. In the initrd case, bus manager never tries to
connect to D-Bus. Since the initrd scenario is not yet used/tested, this is good enough
for the moment. It could be easily extended later, for example with polling whether the
system bus appears (like was done previously). Also, restart of D-Bus daemon isn't
supported either -- just like before.

Note how NMDBusManager now implements the ObjectManager D-Bus interface
directly.

Also, this fixes race issues in the server, by no longer delaying
PropertiesChanged signals. NMExportedObject would collect changed
properties and send the signal out in idle_emit_properties_changed()
on idle. This messes up the ordering of change events w.r.t. other
signals and events on the bus. Note that not only NMExportedObject
messed up the ordering. Also the generated code would hook into
notify() and process change events in and idle handle, exhibiting the
same ordering issue too.
No longer do that. PropertiesChanged signals will be sent right away
by hooking into dispatch_properties_changed(). This means, changing
a property in quick succession will no longer be combined and is
guaranteed to emit signals for each individual state. Quite possibly
we emit now more PropertiesChanged signals then before.
However, we are now able to group a set of changes by using standard
g_object_freeze_notify()/g_object_thaw_notify(). We probably should
make more use of that.

Also, now that our signals are all handled in the right order, we
might find places where we still emit them in the wrong order. But that
is then due to the order in which our GObjects emit signals, not due
to an ill behavior of the D-Bus glue. Possibly we need to identify
such ordering issues and fix them.

Numbers (for contrib/rpm --without debug on x86_64):

- the patch changes the code size of NetworkManager by
  - 2809360 bytes
  + 2537528 bytes (-9.7%)

- Runtime measurements are harder because there is a large variance
  during testing. In other words, the numbers are not reproducible.
  Currently, the implementation performs no caching of GVariants at all,
  but it would be rather simple to add it, if that turns out to be
  useful.
  Anyway, without strong claim, it seems that the new form tends to
  perform slightly better. That would be no surprise.

  $ time (for i in {1..1000}; do nmcli >/dev/null || break; echo -n .;  done)
  - real    1m39.355s
  + real    1m37.432s

  $ time (for i in {1..2000}; do busctl call org.freedesktop.NetworkManager /org/freedesktop org.freedesktop.DBus.ObjectManager GetManagedObjects > /dev/null || break; echo -n .; done)
  - real    0m26.843s
  + real    0m25.281s

- Regarding RSS size, just looking at the processes in similar
  conditions, doesn't give a large difference. On my system they
  consume about 19MB RSS. It seems that the new version has a
  slightly smaller RSS size.
  - 19356 RSS
  + 18660 RSS
2018-03-12 18:37:08 +01:00