Commit graph

889 commits

Author SHA1 Message Date
Lubomir Rintel ad6878d50a tests/client: split out nmcli specific bits into a separate cass
The mock service is more widely useful -- in particular for testing
nm-cloud-setup in a following commit.

Split the commonly useful parts into TestNmClient class.
2023-03-21 23:35:42 +01:00
Lubomir Rintel 1e114c804b tools/test-cloud-meta-mock: add a mock metadata server for cloud-setup
Useful for testing/development.
2023-03-21 23:35:42 +01:00
Beniamino Galvani 39bfcf7aab all: add "link" setting
Introduce a new "link" setting that holds properties that are related
to the kernel link.
2023-03-02 16:51:16 +01:00
Thomas Haller dd5e769f24
build: add test for checking consistency of "nm-autoptr.h" 2023-02-28 16:33:07 +01:00
Thomas Haller fdec6a97e8
vapi: add test for consistency of "vapi/NM-1.0.metadata" 2023-02-28 13:05:47 +01:00
Corentin Noël 169f8748ba
libnm: Specify the main header in the .gir file
Bindings compiling to C need to know which main header to include.
2023-02-28 13:05:47 +01:00
Thomas Haller 5973e83160
systemd: merge branch systemd into main
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1529
2023-02-13 15:33:02 +01:00
Thomas Haller ba5cbedd2c
test-client: add valgrind support for call_nmcli_pexpect() tests
This will allow to find some memory leaks and memory corruptions.

The bulk of the nmcli calls are still not hooked up with valgrind.
Since we call nmcli a thousand time, we could not just run valgrind with
all of them. We would have instead to enable it randomly. This is
more work.

(cherry picked from commit debf78dbed)
2023-02-08 10:53:05 +01:00
Thomas Haller ec454f924c
test-client: pass extra argument in "test-client.sh" to python test
For example:

  $ src/tests/client/test-client.sh -- TestNmcli.test_004
  $ src/tests/client/test-client.sh -- -k monitor

(cherry picked from commit b76bb7333e)
2023-02-08 10:53:05 +01:00
Lubomir Rintel 4d75c43f1a dns-manager: always apply options from [global-dns]
Currently, the use of [global-dns] section for setting DNS options is
conditioned on presence of a nameserver in a [global-dns-domain-*] section.
Attempt to use the section for options alone results in an error:

  [global-dns]
  options=timeout:1

Or via D-Bus API:

  # busctl set-property org.freedesktop.NetworkManager \
      /org/freedesktop/NetworkManager org.freedesktop.NetworkManager \
      GlobalDnsConfiguration 'a{sv}' 2 \
          "options" as 1 "timeout:1" \
          "domains" a{sv} 0
  ...
  Nov 24 13:15:21 zmok.local NetworkManager[501184]: <debug> [1669292121.3904]
      manager: set global DNS failed with error: Global
      DNS configuration is missing the default domain

The insistence on existence of [global-dns-domain-*] would make sense if
other [global-dns-domain-...] sections were present.

However, the user might only want to set the options in resolv.conf and
still use connection-provide nameservers for the actual resolving.

Lift the limitation by allowing the [global-dns] to be used alone, while
still insist on [global-dns-domain-*] being there in presence of other
domain-specific options.

https://bugzilla.redhat.com/show_bug.cgi?id=2019306
(cherry picked from commit 1f0d1d78d2)
2023-01-26 10:11:45 +01:00
Thomas Haller 8f13cb490b
build: fix make cscope step for removed directories 2023-01-17 16:29:05 +01:00
Thomas Haller a259303e1d
ovs: add support for "other_config" settings
See `man ovs-vswitchd.conf.db` for documentation of "other_config" keys.

https://bugzilla.redhat.com/show_bug.cgi?id=2151455
2023-01-11 21:49:36 +01:00
Wen Liang e8618f03d7
support loopback interface
Support managing the loopback interface through NM as the users want to
set the proper mtu for loopback interface when forwarding the packets.
Additionally, the IP addresses, DNS, route and routing rules are also
allowed to configure for the loopback connection profiles.

https://bugzilla.redhat.com/show_bug.cgi?id=2060905
2022-11-23 20:51:22 +01:00
Thomas Haller e292c80da4
c-stdaux: re-import git-subtree for 'src/c-stdaux'
git subtree pull --prefix src/c-stdaux git@github.com:c-util/c-stdaux.git main --squash
2022-11-23 18:01:57 +01:00
Thomas Haller b2931c9621
build: fix dist-ing "src/libnm-lldp/meson.build" in release tarball
Fixes: 630de288d2 ('lldp: add libnm-lldp as fork of systemd's sd_lldp_rx')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1142
2022-11-18 16:16:40 +01:00
Thomas Haller a7fea45adf
libnm: move "nm-dbus-utils.c" from libnm-core to libnm-glib-aux
These are just general purpose D-Bus utils, based on glib and GDBus.
They fit perfectly to libnm-glib-aux. Move the code.

Also, there is already the file "src/core/nm-dbus-utils.c", having two
files with the same name on our source tree is just confusing.
2022-11-14 08:04:06 +01:00
Lubomir Rintel 777f31436c merge: branch 'lr/unbreak-gir'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1451
2022-11-11 16:08:17 +01:00
Thomas Haller 3755e6b175
ifcfg-rh/tests: add test checking persisting ethtool settings to ifcfg-rh
There are still various failures. That will be fixed next.
2022-11-10 13:44:58 +01:00
Lubomir Rintel 133540763c libnm: test that Gir data matches actual exports
This verifies that what's in our public headers has version nodes, and
that they match Since: tags.

Not pretty (because python) but discovered a *lot* of issues.
2022-11-08 13:14:56 +01:00
Lubomir Rintel e13eb9010c Makefile.am: tidy up the introspection conditional part
Use of conditionals in makefiles needs to be kept to a necessary minimum
otherwise they get out of hand quickly. There's no indentation to aid
reading and conditional chunks longer than a screen and nested ones are
almost impossible to comprehend.

The "if HAVE_INTROSPECTION" part does both.

Let's make it a little less horrible. There's generally no point in
making unused targets or variable assignment unless they collide with
pre-built stuff or have multiple variants.
2022-11-08 11:43:06 +01:00
Thomas Haller d699f76855
libnm: generate "gen-metadata-nm-settings-libnm-core.xml" with meta data
libnm-core-impl has lots of internal meta data about the properties.
In particular, which properties exist (their names), and their D-Bus
type.

We should use this information for our manual pages. For example,
currently `man nm-settings-dbus` has nonsense like: "Value Type: array
of string", when it should be reall "as".

In a first step, generate an XML with that meta data for later use.
2022-10-31 09:11:30 +01:00
Thomas Haller 1bfe908c2e
nmcli: rename "generate-docs-nm-settings-nmcli" to "gen-metadata-nm-settings-nmcli"
This is the better name, becuse this is not in particular about "docs".
It's about generating an XML with the information from the settings
meta data for nmcli.

We will do something similar with the libnm-core meta data.
2022-10-31 09:11:30 +01:00
Thomas Haller 139f4b4b2e
build: pass both filenames to "tools/check-compare-generated.sh" script
It just feels nicer to be explicit about the filenames and
not rely on a specific naming.

Also, in meson we can directly pass the target as argument, which
expands to the filename but also adds a dependency.
2022-10-31 09:11:30 +01:00
Thomas Haller b2d1d14772
build/autotools: adjust hack for gettext() for other Makefile versions
On rhel-8.7, we use a different gettext version, so the Makefile
looks different. Adjust patch the source.

Fixes: 7ee0da3eaf ('build: don't "update-po" during make dist')
2022-10-28 12:23:04 +02:00
Thomas Haller c416c066cf
lldp/systemd: remove systemd LLDP sources
They are no longer used. We use now libnm-llpd instead.
2022-10-25 10:59:01 +02:00
Thomas Haller 04e72b6b4d
lldp: use new libnm-lldp instead of systemd's sd_lldp_rx 2022-10-25 10:59:01 +02:00
Thomas Haller 630de288d2
lldp: add libnm-lldp as fork of systemd's sd_lldp_rx
We currently use the systemd LLDP client, which we consume by forking
systemd code. That is a maintenance burden, because it's not a
self-contained, stable library that we use. Hence there is a need for an
individual library or properly integrating the fork in our tree.

Optimally, we would create a new nettools project with an LLDP library.
That was not done because:

- nettools may want to be dual licensed with LGPL-2.1+ and Apache.
  Systemd code is LGPL-2.1+ so it is fine for NetworkManager but
  possibly not for nettools.

- nettools provides independent librares, as such they don't have an
  event loop, instead they expose an epoll file descriptor and the user
  needs to integrate it. Systemd and NetworkManager on the other hand
  have their established event loop (sd_event and GMainContext,
  respectively). It's simpler to implement the library on those terms,
  in particular porting the systemd library from sd_event to
  GMainContext.

- NetworkManager uses glib and has various helper utils. While it's
  possible to do without them, it's more work.

The main reason to not write a new NetworkManager-agnostic library from
scratch, is that it's much simpler to fork the systemd library and make
it part of NetworkManager, than making it a nettools library.

Do it.
2022-10-25 10:59:00 +02:00
Thomas Haller 996b679bd0
glib-aux: add NMPrioq priority queue (heap)
Taken from systemd's "Prioq".

Differences from Prioq:

- It is glib-ized, so certain operations cannot fail since g_malloc()
  never fails.

- Unlike Prioq, this structure is stack allocated. I think that makes
  sense, because we basically always want to embed the data structure
  in another object. There is never a need for passing this around as a
  pointer. And if you really want, you can box it yourself.

- The queue either accepts a GCompareFunc or a GComareDataFunc. This
  is for convenience. The prioq_ensure_allocated() and
  prioq_ensure_put() consequently are dropped, as they would be
  cumbersome with this pattern and don't seem useful.
2022-10-25 10:58:56 +02:00
Thomas Haller 46b36083ce
systemd: drop invalid "user-util.h" compat header
We included the original "user-util.h" header. There must
be no compat header.
2022-10-04 16:10:14 +02:00
Thomas Haller 5450be31d9
core: add NMBondManager to handle NTF rules for balance-slb (MLAG) 2022-10-04 12:37:41 +02:00
Thomas Haller 7ee0da3eaf
build: don't "update-po" during make dist
Instead, hack gettext's Makefile.

gettext has an issue with parallel make. See [1] and [2].
Reproduce with:

  git reset --hard &&
    git clean -fdx &&
    NOCONFIGURE=yes ./autogen.sh &&
    ./configure --enable-gtk-doc --enable-introspection &&
    make -j distcheck V=1

We worked around this by setting "DIST_DEPENDS_ON_UPDATE_PO = yes",
however that (obviously) results in regenerating source files during
dist. "Source files" in the sense that the po files are commited to git
and get distributed in the release. Doing this is very ugly.

In particular it's ugly, because `make -C po update-po` is not reproducible
and the output depends on the current time (*had one job*).
Otherwise, we could just regenerate the files before doing a release.

This means, running "release.sh" script ends up with a dirty tree
afterwards. Also, the distributed po files are not the ones from the source
tree when we did the release. Also, since "release.sh rc1" does two distributions
(once for the rc1 and once for the next devel snapshot), the commit for the
second distribution will have a large diff for the po files.

This reverts commit 978d8eb699 ('po: make dist depend on update-po')
and hacks around the problem.

[1] https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1094#note_1435313
[2] https://lists.gnu.org/archive/html/bug-gettext/2022-06/msg00022.html

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1405
2022-10-03 17:50:09 +02:00
Beniamino Galvani 9b396f7cc8 nmtui: add MACsec support 2022-09-28 09:09:09 +02:00
Beniamino Galvani 7b067be580 nmtui: introduce Nmt8021xFields
Introduce a new widget to edit 802.1X settings.
2022-09-28 09:09:09 +02:00
Thomas Haller 4366dc6582
platform: add "nmp-base.c" source
"nmp-base.h" really should only contain simple defines like enum types
or #define. As such, it almost does not need a source file.

However, the enum-to-string methods for the enums of "nmp-base.h" need a
place. Add "nmp-base.c" for that.
2022-09-23 11:43:35 +02:00
Thomas Haller aea053db38
platform: add "nmp-plobj.[hc]"
Our naming in libnm-platform is bad.

We have NMPlatform, which is a cache of objects. Consequently we have
platform methods like nm_platform_get_link().

We also have various other types that share the NMPlatform prefix, like
NMPlatformIP4Address. For those we have nm_platform_ip4_address_to_string().

"methods" of a type should have the same prefix as the type,
and we should not have types that share the same prefix.

Also, "NMPlatformIP4Address" is a long name, and inconsistent with the
strongly related NMPObjectIP4Address.

Add new files to move and rename parts of the platform API.
2022-09-23 11:43:34 +02:00
Thomas Haller 231671fd02
all: add src/nm-compat-headers for patching included system headers
We already have src/linux-headers, where we have complete copies of linux
user space headers. Of course that exists, because we want to use certain
features and don't depend on the installed kernel headers. Which works
well, because kernel user space API is stable, and we anyway want to
support compiling against a newer kernel and run against an older (e.g.
in a container). So having our copy of newer kernel headers is merely
as if we compiled against as newer kernel.

Add "src/nm-compat-headers" which has a similar purpose, but a different
approach. Instead of replacing the included header entirely, include
the system header and patch it with #define.

Use this for "linux/if_addr.h". Of course, the approach here is that we
no longer include <linux/if_addr.h> directly, but instead include
"nm-compat-headers/linux/if_addr.h".
2022-09-23 11:43:33 +02:00
Thomas Haller e7f76d025f
build: fix regenerating "nm-property-infos-%.xml" files on changes
Imagine checking out the loopback feature branch and building. Thereby the
"src/libnm-client-impl/nm-property-infos-%.xml" files get generated
and contains a `<setting name="loopback"/>`.

Then switch back to `main` branch and type make again. Note that none
of the "src/libnm-core-impl/nm-setting-*.c" files changed, except that
"nm-setting-loopback.c" got removed.

Consequently, the XML won't be regenerated and the followup steps will
fail due to the leftover reference to the non-existing setting.

Fix that by regenerating "nm-property-infos-%.xml" if "libnm-core-impl.la"
changes.
2022-09-09 15:43:45 +02:00
Wen Liang 4c32dd9d25 ipoib: skip validating the DEVICE when reading the ifcfg file
For the ipoib connection, it is still considered as valid if the
profile does not set the device name. Also, the ifcfg reader should not
duplicate the checks that `nm_connection_verify()` performs (especially
not wrongly). Therefore, NM should skip validating the DEVICE when
reading the ifcfg file for the ipoib connection.

https://bugzilla.redhat.com/show_bug.cgi?id=2122703
2022-09-07 10:47:35 -04:00
Thomas Haller f23e43b18a
glib-aux: add "libnm-glib-aux/nm-inet-utils.h" 2022-08-25 19:05:46 +02:00
Thomas Haller c14e61ac96
build: wrap lines in Makefile.am for "vapi/libnm.vapi" 2022-08-08 09:30:53 +02:00
Georg Müller 1d614dbded
crypto: support EC private keys
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1324
2022-08-04 09:46:06 +02:00
Thomas Haller d3c9bb4666
platform: rename file "nmp-route-manager.[hc]" to "nmp-global-tracker.[hc]" 2022-07-26 12:45:55 +02:00
Christian Glombek f00e747beb
libnm-client: Add public nm_conn_wireguard_import() func
This commit moves the `nm_vpn_wireguard_import()` function
implementation from `libnmc-base` to `libnm-client-impl`, renaming it to
`nm_conn_wireguard_import()`.

A new `nm_conn_utils` header file is added in `libnm-client-public`.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1031

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1299
2022-07-21 14:53:26 +02:00
Thomas Haller 8d0b30b243
linux-headers: include "mptcp.h" kernel header
Taken from v5.18, 4b0986a3613c ('Linux 5.18') from 20220522.
2022-07-20 10:23:04 +02:00
Vojtech Bubela 5e4632f021
doc: preserve paraghraphs in nmcli man pages
Improve documentation by preserving paragraphs in the
nm-settings-nmcli man pages.

To do that structure of src/libnm-client-impl/nm-settings-docs-gir.xml
was changed to have "description" as subnode to property node instead
of attribute of property node. Another subnode "description-docbook"
was added - this node is then used when generating man pages.

tools/generate-docs-nm-settings-docs-gir.py and man/nm-settings-dbus.xsl
were also changed to accomodate for changes mentioned above.

Replace xsltproc tool with python script when generating
./src/libnmc-setting/settings-docs.h.

Deleted settings-docs.xsl since it was replaced by python script.

Change src/libnmc-setting/settings-docs.h.in accodring to newly
generated src/libnmc-setting/settings-docs.h

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/661

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1260
2022-07-15 17:25:15 +02:00
Thomas Haller 556bff1767
systemd: merge branch systemd into main
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1291
2022-07-07 00:50:46 +02:00
Martin Blanchard 19a6affd3a build: stop relying on intltool for i18n
Recent gettext version can extract and merge back strings from and to
various file formats, no need for intltool anymore.

https://wiki.gnome.org/Initiatives/GnomeGoals/GettextMigration

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/133

https://github.com/NetworkManager/NetworkManager/pull/303
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/96

Clarification about the use of AM_GNU_GETTEXT_REQUIRE_VERSION:

In configure.ac, specify the minimum gettext version we require, rather
than the exact one. This fixes a situation where the autoconf macros
used for gettext will be the latest available on the system (for
example, 0.20); but the copied-in Makefile.in.in will be for the exact
version specified in configure.ac (in this case, 0.19).

In that situation, the gettext build rules will error out at `make` time
with the message:
   *** error: gettext infrastructure mismatch: using a Makefile.in.in
   from gettext version 0.19 but the autoconf macros are from gettext
   version 0.20

Avoid that by specifying a minimum version dependency rather than an
exact one. This should not cause problems as we haven’t committed any
generated or external gettext files into git, so each developer will end
up regenerating the build system for their system’s version of gettext,
as expected.

See the subsection of
https://www.gnu.org/software/gettext/manual/html_node/Version-Control-Issues.html
for more information.

Note that autoreconf currently doesn’t recognise
AM_GNU_GETTEXT_REQUIRE_VERSION, so we must continue also using
AM_GNU_GETTEXT_VERSION. autopoint will ignore the latter if the former
is present. See
https://lists.gnu.org/archive/html/autoconf-patches/2015-10/msg00000.html.

[lkundrak@v3.sk: Fixed the meson build, adjusted autogen.sh:
droped "|| exit 1", dropped call to aclocal,
dropped --copy from gtkdocize.]
2022-06-27 13:40:09 +02:00
Adrian Freihofer cdaa99cd35
ifcfg-rh: add support for ipv4.link-local 2022-05-27 08:24:40 +02:00
Lubomir Rintel 649314ddaa libnm: replace nm-types.h by defining the types in respective headers
The typedefs in nm-types.h confuse gtkdoc-scan. It generates a
libnm-sections.txt file like this:

  <SECTION>
  <FILE>nm-types</FILE>
  <TITLE>NMDeviceOvs</TITLE>
  NMAccessPoint
  NMActiveConnection
  NMCheckpoint
  NMClient
  NMDevice
  ...

Note the wrongly picked title and, more importantly, the object types in
a bogus section. This in turn makes gtkdoc-mkdb fail to include the
property and signal documentation in appropriate sections.

Without nm-types.h, we need to mind the header dependencies. This means
that we need to order the headers that define types before the ones that
use them. Also, we need to break the depencency loops in few palces.
2022-05-06 18:33:27 +02:00
Thomas Haller 747d7dcfe3
systemd: drop "nm-sd-utils-core.h" and nm_sd_utils_id128_get_machine()
This was only for unit testing, to check whether our reader
for "/etc/machine-id" agrees with systemd's.

That unit test was anyway flawed, because it actually accesses
the machine-id on the test system.

Anyway. Drop this. Most likely our parser is good enough, and
if we get a bug report with a defect, we can unit test against
that.
2022-04-20 12:07:04 +02:00