389 Commits

Author SHA1 Message Date
Beniamino Galvani
165e5df6e0 nmcli: accept certain IP settings on port connections
Commit bb850fda0e ('nmcli: connection: process port-type, type
and controller first') started correctly rejecting IP configuration
on port connections.

However, previously nmcli would accept IP parameters for ports when
using a specific parameters order. To avoid breaking user scripts that
may have relied on this behavior, introduce a backward compatibility
quirk.

Specifically, nmcli accepts a disabled/ignore IP method on a port
connection. For any other IP setting on a port connection, a specific
error message is now shown.

https://issues.redhat.com/browse/RHEL-90756
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2227
2025-07-01 14:21:23 +02:00
Jan Vaclav
eac9f828e8 tools/nm-in-container: add --skip-unavailable flag for installing debuginfo 2025-06-02 11:08:19 +00:00
Jan Vaclav
4be97207ed tools/nm-in-container: update package install list for fedora 42
- ausearch is part of audit package
- mlocate is not available anymore
- "openvswitch2*" packages are not available anymore
- ipsec-tools is not available anymore
2025-06-02 11:08:19 +00:00
Eli Schwartz
a11760ef39 build: make manpages a mandatory part of the build by default
Currently, both man pages and gtk-doc HTML documentation are enabled by
the same build option. It is common for users to want to choose whether
to build HTML docs, as not everyone cares about HTML developer docs, but
manpages are intended directly for end-user consumption and should
always be available. At the very least, there should be a separate
option to disable them to avoid accidentally disabling them while trying
to disable HTML developer docs.

Resolves: https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1653
2025-05-30 09:42:55 +00:00
Tomas Bzatek
ec917dc670 ci: add libnvme dependency
Required for the nm-initrd-generator NBFT support.

Signed-off-by: Tomas Bzatek <tbzatek@redhat.com>
2025-04-28 16:09:54 +00:00
Lubomir Rintel
79b1877c02 test/nm-service: default the devices to DISCONNETED not UNAVAILABLE
It is a little odd that client tests connect "UNAVAILABLE" devices, and
the devices return to "DISCONNECTED" after deactivation.

It differs from what happens in reality, and some client tools
(hey nm-cloud-setup) can break when they rightly assume that the
device is not ready for activation when it's "UNAVAILABLE" not
"DISCONNECTED".
2025-04-11 11:44:05 +02:00
Jan Tojnar
12eff9a7fd meson: Fix docs generation with PyGObject 3.52
PyGObject 3.52 switched from gobject-introspection’s libgirepository 1.0
to glib’s libgirepository 2.0. As a result, the Python script would
no longer be able to find the `GIRepository` 2.0 typelib:

    (process:1944): GLib-GIRepository-DEBUG: 15:25:14.521: Ignoring GIRepository-2.0.typelib because this libgirepository corresponds to GIRepository-3.0.typelib

We could update the script to support both versions of the typelib
but it is not really necessary. It was only used to add extra directories
from `$LD_LIBRARY_PATH` and the CLI argument to repository’s library path
but libgirepository already supports using `LD_LIBRARY_PATH` directly:
https://docs.gtk.org/girepository/method.Repository.prepend_library_path.html
2025-03-31 12:04:43 +00:00
Michael Biebl
10e58f7c3c typo fix: allows to -> allows one to
Detected by lintian:

Example:
I: network-manager: typo-in-manual-page "allows to" "allows one to" [usr/share/man/man5/NetworkManager.conf.5.gz:1266]
2025-03-26 19:22:01 +01:00
Lubomir Rintel
fadfb7bba1 test/nm-service: add support for creating a MACVLAN
...via AddAndActivate. nm-cloud-setup will do that.
2025-01-20 14:08:12 +01:00
Lubomir Rintel
91524b8419 test/nm-service: create Vlan devices matching the parent by hwaddr
This is how OCI VLANS will be looking up their parents. Make sure the
mock is able to deal with this.
2025-01-20 14:08:12 +01:00
Lubomir Rintel
158adac3a6 test/nm-service: create software devices on AddAndActivate()
This will be useful for testing VLAN bringup.
2025-01-20 14:08:12 +01:00
Lubomir Rintel
93983155bf test/nm-service: add MacvlanDevice class
We'll need to test the nm-cloud-setup OCI multiple VNIC support.
2025-01-20 14:08:12 +01:00
Lubomir Rintel
392f76a23b test/nm-service: add Device.HwAddress property
nm-cloud-setup finds devices by hwaddr. Let's expose it for all device
types, so that we're be able to test once we add VLANs and MACVLANs.
2025-01-20 14:08:12 +01:00
Lubomir Rintel
f7c8597835 test/cloud-meta-mock: do not print what we listen on if we got a FD
This message is useless for non-interactive use and clobbers over
otherwise very appealing test output.

The callers knows what we're going to listen on, it passed us the file
descriptor.
2025-01-20 14:08:12 +01:00
Íñigo Huguet
380458b0ee ip-config: Fix the nmcli docs for the renamed dhcp-send-hostname
In nmcli we have renamed dhcp-send-hostname and dhcp-send-hostname-v2 to
dhcp-send-hostname-deprecated and dhcp-send-hostname so users don't need
to worry about the details of the weird workarounds that we sometimes
need to do to expand and/or deprecate some properties.

However, the autogenerated documentation didn't include this names. Add
---nmcli--- specific documentation, adding a new property-infos field
called "rename" with the new name used in nmcli. This field can be used
for more properties if we use the same strategy in the future.
2024-10-24 17:03:10 -04:00
Fernando Fernandez Mancera
d238ff487b ipvlan: add support to IPVLAN interface
This patch add support to IPVLAN interface. IPVLAN is a driver for a
virtual network device that can be used in container environment to
access the host network. IPVLAN exposes a single MAC address to the
external network regardless the number of IPVLAN device created inside
the host network. This means that a user can have multiple IPVLAN
devices in multiple containers and the corresponding switch reads a
single MAC address. IPVLAN driver is useful when the local switch
imposes constraints on the total number of MAC addresses that it can
manage.
2024-09-18 13:19:42 +02:00
Fernando Fernandez Mancera
a0696e27b8 hsr: add hsr setting to docs generate script
The setting was missing from the script. The patch is adding it and also
regenerates the docs.

Fixes: 5426bdf4a1 ('HSR: add support to HSR/PRP interface')
2024-09-16 17:04:02 +02:00
Jan Vaclav
4db1829bc7 all: remove misc mentions of autotools in docs 2024-09-11 12:18:15 +00:00
Jan Vaclav
12b5b8317b build: remove autotools configuration from scripts 2024-09-11 12:18:15 +00:00
Fernando Fernandez Mancera
4f7c04eaf9 tools: add nm-to-rhcos script to our toolset
Script to create a RHCOS custom image containing a NetworkManager rpm from
a copr repository.

In order to have a custom RHCOS image, we cannot modify the image itself but
we can add a custom layered image that includes all RHCOS functionality and
adds additional functionality to it.

Requirements:
- A quay.io registry where you have push access.
- You must have your pull-secret in the same directory where the script is
being run. You can download your pull-secret from:
https://console.redhat.com/openshift/install/pull-secret

In order to install this on nodes from a cluster that already exists it must
be done using MachineConfig operator. In essence the following YAML file
must be created.

```
apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfig
metadata:
  labels:
    machineconfiguration.openshift.io/role: <role>
  name: os-layer-custom-nm
spec:
  osImageURL: <registry>
```

Please, notice that the role and registry need to be set to your needs.

Then, it can be applied by:

$ oc create -f <yaml file>

Finally, the machines will be ready once the field UPDATED has the True value
in the output of this command.

$ oc get mcp
2024-07-08 13:50:52 +02:00
Jan Vaclav
a5333f14b5 nm-in-container: create conf.d file instead of modifying journald.conf
Currently, the Dockerfile expects /etc/systemd/journald.conf to exist on the base container,
but sometimes this may not be the case, for example on Fedora 40, which causes
the build process to fail if the host machine is also running Fedora 40.

Update the dockerfile to create a conf.d file instead, which has higher precedence.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1972
2024-06-19 11:47:51 +00:00
Jan Vaclav
7b4acf938c contrib/fedora: update scripts to expect autotools deprecation 2024-05-06 16:39:08 +02:00
Tomasz Kłoczko
20677c175d update DocBook DTD version to latest stable 4.5
Signed-off-by: Tomasz Kłoczko <kloczek@github.com>
2024-04-22 12:06:16 +00:00
Íñigo Huguet
67eb8c5c2b CI: fix meson tarball testing with old meson version
The test "tarball+meson" fails on systems with old meson version with
the message "ERROR: Neither directory contains a build file
meson.build". This message is raised when calling `meson dist` from the
build directory.

According to meson documentation, `meson dist` is supported since 0.52,
and older vesions need to execute `ninja dist`.
https://mesonbuild.com/Creating-releases.html

Also, when using meson.add_dist_script, the env variable MESON_SOURCE_ROOT
is not passed in versions < 0.54. As we don't use it in the script,
don't assert for it.

We claim to support down to meson 0.47.3 (we need to raise it because we
are actually using a bit newer features, but that's another topic). Use
`ninja dist` that will work fine on old and new meson.

Fixes: 61f0531509 ('gitlab-ci: test re-buildability of distribution tarballs')
2024-04-04 08:17:26 +02:00
Íñigo Huguet
723ad4c0ad meson: exclude intermediate files of docs generation from tarball
We want to distribute the generated documentation when we generate the
tarball because we normally do it when we do a release, but `meson dist`
only includes files that are commited to the repository, so a script
meson-dist-data.sh was added with meson.add_dist_script in commit
1c41066a40 ('build: include documentation in meson dist').

This script was copying the whole documentation folders, including some
intermediate files that are not useful for users that wants to read the
docs. Get rid of them and copy only the files that are useful for users:
the generated html pages in docs/api and docs/libnm and the final man
pages.

Also, including these intermediate files caused at least one build
failure, although quite difficult to reproduce:
- Generate tarball with meson
- Untar the generated tarball
- Using the sources from the tarball, configure the project with
  autotools, but building to an out-of-tree folder, not building in
  the source dir (i.e. using a 'build' subfolder). This is called
  a "VPATH build" by autotools and Make. See:
  - https://www.gnu.org/software/make/manual/html_node/General-Search.html
  - https://www.gnu.org/software/automake/manual/html_node/VPATH-Builds.html
- Build

In that scenario, we get an error trying to generate any file under man/
because the man/ subdirectory has not been created. The reason of this
was that the man/ subdirectory is created by the Makefile when
generating the file man/common.ent. However, this file was present in
the source directory because it has been included in the tarball, so
Make detects it and doesn't run the rules to generate it. The result is
that out-of-tree-dir/man folder is not created.

Not including the intermediate files solves this problem.

Fixes: 1c41066a40 ('build: include documentation in meson dist')
2024-04-04 08:16:25 +02:00
Jan Vaclav
f2d91b4a68 wired: deprecate NMSettingWired mac-address-blacklist property
To embrace inclusive language, deprecate the NMSettingWired
mac-address-blacklist property and introduce mac-address-denylist property.
2024-03-20 15:32:00 +01:00
Jan Vaclav
5672757ac4 test/networkmanager-service: simulate behavior of aliased/deprecated properties
Previously, the mock server did not behave as expected when given an aliased property
and the test results were not matching that of actual NM daemon behavior.
2024-03-11 11:42:19 +01:00
Jan Vaclav
47f01c805d python: reformat with black-24.1.1-1.fc39.noarch 2024-03-01 07:51:21 +00:00
Jan Vaclav
1c41066a40 build: include documentation in meson dist
Previously, the tarball generated by `meson dist` did not contain the
autogenerated documentation due to the way meson works (packaging the
latest revision control commit). This introduces a dist script which
builds & copies the generated documentation into the distribution
tarball.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1811
2024-01-17 12:39:46 +00:00
Thomas Haller
28a1afca63 python: reformat with black-23.7.0-2.fc39.noarch
The base image for the "check-tree" test got bumped to Fedora 39.  This
brings a new python-black version (23.7.0 vs. 22.8.0) and requires
reformatting.

Maybe we should stick to 22.8.0, via `pip install`. But it seems better
to just follow the latest black version (the one from current Fedora).

So do the reformatting instead.

https://black.readthedocs.io/en/stable/change_log.html#id38
2023-12-06 11:56:11 +01:00
Thomas Haller
41e3fed381 tests: improve detection of libtool in "run-nm-test.sh"
The user can set "$NMTST_LIBTOOL" to empty or the path to libtool.

If unset, we want to detect it. However, previously we would always
use "$SCRIPT_PATH/../libtool", even if that file doesn't exit. Improve
that.

For example, when running on Ubuntu with the ".gitlab-ci/debian-install.sh"
script, we don't have libtool. Entering such a container and running the
"run-nm-test.sh" script will fail as "$SCRIPT_PATH/../libtool" doesn't
exist.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1800
2023-11-30 15:36:20 +01:00
Thomas Haller
1054d3bce0 nm-in-container: set TERM=xterm in bashrc
Otherwise, TERM is set to "dump", which breaks a lot of uses of the
pager.
2023-11-20 16:40:10 +01:00
Thomas Haller
84ede1c380 nm-in-container: bind mount additional directories
- If ".git/nm-in-container-host" exists, bind mount all of "/" to
  "/Host".

- also honor all ".git/nm-data-link-*" files for additional
  directories to bind mount.

- as before, honor ".git/NetworkManager-ci" symlink.

Note that directories also get symlinked from "/". Like
"/NetworkManager-ci" which symlinks links to the bind mount location.
2023-11-20 16:00:14 +01:00
Thomas Haller
1c187166c2 nm-in-container: install ausearch/audit package
This is now required by NM-ci. Install it.
2023-11-15 10:41:11 +01:00
Thomas Haller
c04c955407 nm-in-container: fix mount command in "_nm-in-container-setup.sh"
On Fedora 39, mount now requires the dummy device argument.
It was wrong to omit it, altough it worked previously.

Fix the mount command line.
2023-11-15 09:28:58 +01:00
Íñigo Huguet
f4fbc59a16 man nm-setting-*: proper format for gtkdoc constants
Gtkdoc comments are used, among other things, to generate the various
nm-setting-* manual pages. When a constant is referenced in a gtkdoc
comment (i.e. `%NM_IP_TUNNEL_MODE_IPIP`) it is expanded to show the C name
and the value (i.e. `NM_IP_TUNNEL_MODE_IPIP (1)`). To generate the
nm-setting-* manual pages, we don't use gtkdoc, but we process this data
with the custom script tools/generate-docs-nm-settings-docs-gir.py.
This script was expanding the constants in the same way than gtkdoc.

Showing the constants in that way in nm-setting-* manual pages makes
little sense, because users are not going to use the C identifiers.
Let's show them with a more appropriate format.

Additionally, the different nm-setting-* pages might require different
formats than the other. For example, for nm-setting-nmcli a format like
`"ipip" (1)` is prefered, but for nm-setting-dbus it's better
`1 (ipip)`. Let's generate different nm-settings-docs-gir-*.xml files for
nmcli, dbus, keyfile and ifcfg-rh, using the right format for each one.
2023-09-21 15:57:35 +02:00
Íñigo Huguet
c9ced304d2 man nm-setting-*: add "expand enumvals" capability to property-infos
In some cases, properties documentation might require to provide an
explanation of each of the possible values that the property accepts.
If the possible values are the variants of an enum, we can use the
introspection data to get all the possible values for that enum and
their descriptions. With that info, we can automatically generate the
documentation with an always up to date list of accepted values.

Add a new "expand enumvals" feature: it will convert a token with the
format `#EnumName:*` to a list of all the possible values. For the
docbook (description-docbook field in the XML), it is expanded to a
bulleted list of all the values and their respective documentations.

This feature is limited to the "property-infos" comments (those like
---nmcli---, ---dbus---, etc). This comments are used only to generate
the nm-settings-* manual pages. For the documentation under the doc/
folder this is not needed: it's not supported by gtkdoc and, anyway,
it's better to use just `#EnumName` that will generate an HTML link.

Additionally, expansion of `%ENUM_VALUE` is now supported in the
property-infos comments. Instead of expanding them in the same style
than gtkdoc "ENUM_VALUE (num)", it is expanded in a format more suitable
for the nm-setting-* manual pages:
- for nmcli: value_nick (num)
- others: num (value_nick)

Also, fix typo in meson build file propery -> property.
2023-09-21 15:57:35 +02:00
Íñigo Huguet
5c6ae44e00 man nm-settings-nmcli: add "Special values" field
If there are properties that accept special values apart from the
normally accepted values, or any of those values has an special meaning,
it can be shown as "Special value", indicating the nicknames and numbers
that can be used to select it.
2023-09-21 15:57:35 +02:00
Íñigo Huguet
925d4df801 man nm-settings-nmcli: add "Valid values" field
Show a new field called "Valid values" in those properties that only
accept a limited set of values, like enums, ints with a valid range of
values, etc.

As there is some complex logic behind getting this information, this
logic has been put in nm-meta-setting-desc and nm-enum-utils so they can
be re-used, avoiding duplicity and errors. Some refactor has been done
in nm-meta-setting-desc in this direction, too.
2023-09-21 15:57:35 +02:00
Íñigo Huguet
52c347677f tools: nm-in-vm: fix error if pool folder doesn't exist yet
If libvirt's default pool folder doesn't exist yet (i.e. the user has
never installed a VM there), create it to avoid error and script exit.
2023-09-21 15:53:03 +02:00
Íñigo Huguet
0ec71289ed tools: nm-in-vm: fix motd
Message of the day was shown twice because the same bashrc.my file than
for containers was used. That file contained some code to show motd in
the container, where it is not shown by default. But in the VM, the motd
is shown by default, so it was shown twice.

Move the code to show motd to a file used only by nm-in-container and
not by nm-in-vm.

Also, modify the explanation about using prepare-for-system.sh because
it's only valid for Fedora but nm-in-vm can be used with other SOs too.
2023-09-21 15:53:03 +02:00
Íñigo Huguet
c8a329bc12 tools: nm-in-vm: don't allow invalid hostnames, fix regex
The $VM name is used also as hostname in the guest so ssh connection can
be made to root@$VM. However, valid hostnames can only contain letters,
numbers and '-'. If other characters are used, they are removed from the
hostname so you cannot connect to root@$VM. Fix it by not allowing
invalid hostnames in $VM at VM creation.

Also, fix some incorrect bash regexes.
2023-09-21 15:53:03 +02:00
Íñigo Huguet
25e6218e94 tools: nm-in-vm: fix CentOS Stream guest
Install missing repositories required to install all the packages.

Unluckily, it doesn't support 9P filesystem shares, and virtiofs is not
supported for non-root hosts. Emit a warning about that.
2023-09-21 15:53:03 +02:00
Íñigo Huguet
f9cfe80b56 tools: nm-in-vm: change default image size
Images of qcow2 format dynamically grow up to the maximum size that they
have been configured at creation time. Because of this, higher size can
be selected without wasting unnecesary space in the host. Rise image
size to 20G.

Also, allow to set an empty value to IMAGE_SIZE, and don't resize in
that case. This is useful because virt-resize fails with some guest
partition layouts (like with ubuntu-20.04).
2023-09-21 15:53:03 +02:00
Íñigo Huguet
28cb8024e3 tools: nm-in-vm add convenience options --vm and os_version
Using more than one VM can be a quite common use case. Insteado of
having to do VM=vm_name ./nm-in-vm, allow the more common way of passing
options ./nm-in-vm --vm vm_name.

Also, in build command, accept one positional argument to set OS_VERSION.
2023-09-21 15:53:03 +02:00
Íñigo Huguet
49175cb2cb tools: nm-in-vm: Debian/Ubuntu with extra pkgs and fixed installation 2023-09-21 15:53:03 +02:00
Íñigo Huguet
2b44baf137 tools: nm-in-vm: fix connectivity with host
The connectivity with the host depends on getting a DHCP lease from the
host. With the latest commit's customizations, the virtual NIC is not
managed by NM so it is not configured.

Keep it unmanaged so debuging NetworkManager doesn't affect to this
virtual NIC. Use dhclient to get a DHCP lease from the host. Assign a
fixed interface name (host_net) to match it from NM and dhclient config
files.
2023-09-21 15:53:03 +02:00
Íñigo Huguet
db78d7b1b0 tools: nm-in-vm: add NM custom files, packages and configs
Same packages and customizations than in nm-in-container. Packages for
Debian/Ubuntu pending of being added because they have different names.
2023-09-21 15:53:03 +02:00
Íñigo Huguet
d00a5d2a8b tools: nm-in-container: don't generate files from the script
The script was generating the data-* files that later copies to the
container.

In order to the files being reusable for nm-in-vm, put them as separate
files inside the data directory.

However, some of the files need the full path to NetworkManager project,
which varies for each user. Instead, make a sed replacement on them and
generate the actual files that will be copied. Replacement:
{{BASEDIR_NM}} -> $BASEDIR_NM

Also, rename the files to more descriptive names, using some prefixes
that give a hint of where those files will be put, and the .in extension
to indicate that they will be processed.
2023-09-21 15:53:03 +02:00
Íñigo Huguet
3100e4b6e2 tools: nm-in-container: move data to a common path for nm-in-vm
nm-in-vm can use the same generated files than nm-in-container, so let's
move them to a place common for both: tools/nm-guest-data.

With this change, it is not worth it to have the nm-in-container
directory, so move the script to tools and delete the subdirectory.
2023-09-21 15:53:03 +02:00