Commit graph

23338 commits

Author SHA1 Message Date
Thomas Haller
dfa8ecdab8 cli: remove unnecessary workaround for clearing team link watchers and runner-tx-hash
This is fixed in libnm. Resetting the GObject property clears the list
of watchers and tx-hashes.

Since nmcli requires a libnm version >= itself, this workaround
is no longer necessary.
2019-06-04 15:48:30 +02:00
Thomas Haller
23b1f8234d libnm/team: fix handling default values and stricter validate team config
For each artifical team property we need to track whether it was
explicitly set (i.e., present in JSON/GVariant or set by the user
via NMSettingTeam/NMSettingTeamPort API).

 --

As a plus, libnm is now no longer concerned with the underling default values
that teamd uses. For example, the effective default value for "notify_peers.count"
depends on the selected runner. But libnm does not need to care, it only cares
wheher the property is set in JSON or not. This also means that the default (e.g. as
interesting to `nmcli -o con show $PROFILE`) is independent from other properties
(like the runner).

Also change the default value for the GObject properties of
NMSettingTeam and NMSettingTeamPort to indicate the "unset" value.
For most properties, the default value is a special value that is
not a valid configuration itself.
For some properties the default value is itself a valid value, namely,
"runner.active", "runner.fast_rate", "port.sticky" and "port.prio".

As far as NMTeamSetting is concerned, it distinguishes between unset
value and set value (including the default value). That means,
when it parses a JSON or GVariant, it will remember whether the property
was present or not.

When using API of NMSettingTeam/NMSettingTeamPort to set a property to the
default value, it marks the property as unset. For example, setting
NM_SETTING_TEAM_RUNNER_ACTIVE to TRUE (the default), means that the
value will not be serialized to JSON/GVariant. For the above 4
properties (where the default value is itself a valid value) this is a
limitation of libnm API, as it does not allow to explicitly set
'"runner": { "active": true }'. See SET_FIELD_MODE_SET_UNLESS_DEFAULT,

Note that changing the default value for properties of NMSetting is problematic,
because it changes behavior for how settings are parsed from keyfile/GVariant.
For team settings that's not the case, because if a JSON "config" is
present, all other properties are ignore. Also, we serialize properties
to JSON/GVariant depending on whether it's marked as present, and not
whether the value is set to the default (_nm_team_settings_property_to_dbus()).

 --

While at it, sticter validate the settings. Note that if a setting is
initialized from JSON, the strict validation is not not performed. That
means, such a setting will always validate, regardless whether the values
in JSON are invalid according to libnm. Only when using the extended
properties, strict validation is turned on.

Note that libnm serializes the properties to GVariant both as JSON "config"
and extended properties. Since when parsing a setting from GVariant will
prefer the "config" (if present), in most cases also validation is
performed.

Likewise, settings plugins (keyfile, ifcfg-rh) only persist the JSON
config to disk. When loading a setting from file, strict validation is
also not performed.

The stricter validation only happens if as last operation one of the
artificial properties was set, or if the setting was created from a
GVariant that has no "config" field.

 --

This is a (another) change in behavior.
2019-06-04 15:48:15 +02:00
Thomas Haller
efe602af2a libnm/team: reorder fields in JSON output for team link watcher
The order of the fields in the JSON object does not really matter.

Note that with the recent rework the order changed. Before it was
arbitrarily, now it still is arbitrary.

Reorder again, to follow the same order as `man teamd.conf`.
2019-06-04 15:48:15 +02:00
Thomas Haller
56f45d7ba3 libnm/team: add space in JSON output for link watcher
Generate the following:

 { "runner": { "sys_prio": 10 }, "link_watch": { "name": "ethtool" } }

instead of:

 { "runner": { "sys_prio": 10 }, "link_watch": { "name": "ethtool"} }
2019-06-04 15:46:21 +02:00
Thomas Haller
f4222aff07 build/meson: depend test-dispatcher-envp on libnm
Otherwise we can get a build failiure:

  ../libnm/NetworkManager.h:61:27: fatal error: nm-enum-types.h: No such file or directory
2019-06-02 08:34:34 +02:00
Thomas Haller
403f207fe5 cli: fix resetting default value for GObject property
This matters for properties that don't have 0/NULL/FALSE as
default value and when setting an empty property with

  $ nmcli connection modify "$PROFILE" setting.property ''

Fixes: 3c82db710f ('cli: reset default value of properties via set_fcn()')
2019-05-31 15:52:29 +02:00
Lubomir Rintel
5cf6cfd999 config: also save next-server in the state file
The early boot tooling gets the root-path from our state file due to a
lack of a better way to do that. However, when booting with NFS root,
the root path alone is not sufficient; the server address is communicated
via the next-server option. Save that one in the state file as well.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/168
2019-05-30 17:02:50 +02:00
Thomas Haller
9a7929bdb1 dhcp/trivial: add fixme comment about stopping clients 2019-05-29 14:48:03 +02:00
Francesco Giudici
58eee5896d cli: enforce int type in for loops 2019-05-29 11:37:42 +02:00
Thomas Haller
94ccc22d66 gitlab-ci: merge branch 'th/gitlab-ci-centos'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/170
2019-05-29 11:21:18 +02:00
Thomas Haller
896dc7d4d9 gitlab-ci: also build on CentOS 7.5 and 7.6 2019-05-29 09:42:40 +02:00
Thomas Haller
c9873d4273 gitlab-ci: run "checkpatch" test on Fedora 29 image
Fedora 28 is no longer supported at this point. Run the "checkpatch"
test on a Fedora 29 image instead.
2019-05-29 09:42:40 +02:00
Thomas Haller
a307bd6ec4 build: disable "-Wunknown-pragmas" warning
clang on CentOS 7.6 (3.4.2-9.el7) warns:

      CC       clients/tui/newt/clients_tui_newt_libnmt_newt_a-nmt-newt-button.o
    In file included from ../clients/tui/newt/nmt-newt-button.c:26:
    In file included from ../shared/nm-default.h:280:
    ../shared/nm-glib-aux/nm-macros-internal.h:1617:2: error: unknown warning group -Wstringop-truncation, ignored [-Werror,-Wunknown-pragmas]
            NM_PRAGMA_WARNING_DISABLE ("-Wstringop-truncation");
            ^
    ../shared/nm-glib-aux/nm-macros-internal.h:419:9: note: expanded from macro NM_PRAGMA_WARNING_DISABLE
            _Pragma(_NM_PRAGMA_WARNING_DO(warning))
            ^
    <scratch space>:109:25: note: expanded from here
     GCC diagnostic ignored "-Wstringop-truncation"
                            ^

This warning totally defeats the purpose of why we use the pragma in the
first place.
2019-05-29 09:42:40 +02:00
Thomas Haller
7af1fc803e clients/tests: increase timeout waiting for stub D-Bus service
I saw this timeout reached in our gitlab-ci. I think it was due to the machine
being busy and taking more than 2 seconds. Assuming the timeout was just too short,
increase it to 4 seconds.
2019-05-29 09:42:40 +02:00
Thomas Haller
5113c5bd00 platform: avoid compiler error passing NMP_OBJECT_CAST_OBJ_WITH_IFINDEX() to nm_hash_update_vals()
Clang (3.4.2-9.el7) on CentOS 7.6 fails related to nm_hash_update_vals().

Clang seems to dislike passing certain complex arguments to typeof().
I'd prefer to fix nm_hash_update_vals() to not have this problem,
but I don't know how.

This works around the issue.
2019-05-29 09:42:40 +02:00
Thomas Haller
ad06cc78dc platform: make nm_platform_kernel_support_get() macro an inline function
clang (3.4.2-9.el7) on CentOS 7.6 fails related to nm_hash_update_vals().

I am not even quoting the error message, it's totally non-understandable.

nm_hash_update_vals() uses typeof(), and in some obscure cases, clang dislikes
when the argument itself is some complex macro. I didn't fully understand why,
but this works around it.

I would prefer to fix nm_hash_update_vals() to not have this limitation.
But I don't know how.

There is probably no downside to have this an inline function instead of
a macro.
2019-05-29 09:42:40 +02:00
Thomas Haller
3d42b2f1fa shared: fix _NM_ENSURE_TYPE_CONST() for const pointers with clang
Clang 3.4.2-9.el7 on CentOS7.6 complains about missing generic type match:

    ../dispatcher/nm-dispatcher.c:243:2: error: controlling expression type 'const Request *const' (aka 'const struct Request *const') not compatible with any generic association type
            _LOG_R_D (request, "start running ordered scripts...");
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Fixes: 17dc6a9da6 ('shared: add _NM_ENSURE_TYPE_CONST()')
2019-05-29 09:42:40 +02:00
Thomas Haller
3a1dc8b2f3 settings: merge branch 'th/drop-monitor-connection-files'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/160
2019-05-29 09:31:37 +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
Thomas Haller
1ae5e6465f settings: drop deprecated NetworkManager.conf option "main.monitor-connection-files"
It's deprecated and off by default for a long time.

It is bad to automatically reload connection profiles. For example, ifcfg
files may consist of multiple files, there is no guarantee that we
pick up the connection when it's fully written.

Just don't do this anymore.

Users should use D-Bus API or `nmcli connection reload` or `nmcli
connection load $FILENAME` to reload profiles from disk.
2019-05-28 17:51:24 +02:00
Lubomir Rintel
48b3a3e311 merge: branch 'lr/complete-conn'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/136
2019-05-28 15:03:24 +02:00
Lubomir Rintel
e05a256724 modem: use set conn.interface upon completing the CDMA connections
There doesn't seem to be a better way to pinpoint a CDMA connection to a
device. This will have to do for now.
2019-05-28 15:03:20 +02:00
Lubomir Rintel
26aefe4660 infiniband: complete an interface name in complete_connection()
If the AddAndActivate() caller didn't explicitely a MAC address, default
to pinpointing the connection to the device by the means of an interface
name. This makes more sense than a MAC address with stable device names.
2019-05-28 15:03:20 +02:00
Lubomir Rintel
dbdc34b99c ethernet: complete an interface name in complete_connection()
If the AddAndActivate() caller didn't explicitely a MAC address, default
to pinpointing the connection to the device by the means of an interface
name. This makes more sense than a MAC address with stable device names.
2019-05-28 15:03:20 +02:00
Lubomir Rintel
e9c6b55b16 wifi: complete an interface name in complete_connection()
If the AddAndActivate() caller didn't explicitely a MAC address, default
to pinpointing the connection to the device by the means of an interface
name. This makes more sense than a MAC address with stable device names.
2019-05-28 15:03:20 +02:00
Lubomir Rintel
28a39eda44 utils: add ifname argument to nm_utils_complete_generic()
It's a common thing to complete a connection with an interface name;
adding it to the common path is goint to save as a few tens of lines
later on.
2019-05-28 15:03:20 +02:00
Lubomir Rintel
27eb2b2f97 infiniband: remove the MAC address check from complete_connection()
nm_device_complete_connection() now calls check_connection_compatible()
which has a redundant check.
2019-05-28 15:03:20 +02:00
Lubomir Rintel
77471b1d77 ethernet: remove the MAC address check from complete_connection()
nm_device_complete_connection() now calls check_connection_compatible()
which has a redundant check.
2019-05-28 15:03:20 +02:00
Lubomir Rintel
3f5064371a wifi: remove the MAC address check from complete_connection()
nm_device_complete_connection() now calls check_connection_compatible()
which has a redundant check.
2019-05-28 15:03:20 +02:00
Lubomir Rintel
48710fbf8d device: after completing a connection, check it's compatible 2019-05-28 15:03:20 +02:00
Lubomir Rintel
9c24c81ad0 cli: don't force interface name on add_and_activate
The daemon is already responsible for pinning the connection to a
particular device. In fact, it may choose to use a different means than
an interface name, such as a MAC address or a gsm.device-id. Remove it
from the client.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/140
2019-05-28 14:40:18 +02:00
Ludek Janda
f307034b91 po: RHEL 7.7 translations - fr,ja,zh-CN
[lkundrak@v3.sk: make update-po]

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/164

(cherry picked from commit 548bacd24e)
2019-05-28 14:37:30 +02:00
Lubomir Rintel
a9da4f5180 po: update-po
(cherry picked from commit 9de7c0542c)
2019-05-28 14:37:14 +02:00
Lubomir Rintel
04621c6c0f initrd/cmdline: add support for rd.neednet option
This is used to indicate the network dracut module should fall back to
configure network automatically (as with ip=dhcp was specified) if
there's no other network configuration present on the command line.

The option is documented in dracut.cmdline(7).

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/167
2019-05-28 11:26:17 +02:00
Beniamino Galvani
7502fb0f5e ifcfg-rh: merge branch 'bg/802-1x-client-cert-rh1705054'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/148
https://bugzilla.redhat.com/show_bug.cgi?id=1705054
2019-05-28 10:57:37 +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
Beniamino Galvani
d9b3b2b8ce ifcfg-rh: don't check for 802.1x private key or client cert in reader
Let the setting check it in verify().
2019-05-28 10:42:30 +02:00
Beniamino Galvani
a995244e9b ifcfg-rh: write client certificate even if it is pkcs12
The writer should only persist properties without too much additional
logic, which should be instead embedded in the setting itself.
2019-05-28 10:42:30 +02:00
Beniamino Galvani
3a4a09b669 core: merge branch 'bg/sriov-async'
https://github.com/NetworkManager/NetworkManager/pull/268
2019-05-28 10:35:57 +02:00
Beniamino Galvani
121c58f0c4 core: set number of SR-IOV VFs asynchronously
When changing the number of VFs the kernel can block for very long
time in the write() to sysfs, especially if autoprobe-drivers is
enabled. Turn the nm_platform_link_set_sriov_params() into an
asynchronous function.
2019-05-28 10:35:04 +02:00
Beniamino Galvani
abec66762a platform: add async sysctl set function
Add a function to asynchronously set sysctl values.
2019-05-28 10:34:53 +02:00
Beniamino Galvani
b5009ccd29 platform: print sysctl absolute path when pathid is NULL
@pathid can be NULL, in such case print the absolute path.
2019-05-28 10:34:53 +02:00
Beniamino Galvani
3ed23d405e platform: use 'self' argument name for platform functions
Uniform all functions to use 'self' as first argument.
2019-05-28 10:34:53 +02:00
Beniamino Galvani
d6a51ced40 ifcfg-rh: preserve existence of wired setting
Currently the plugin doesn't preserve the existence of a wired setting
because the writer saves only variables with non-default values and,
especially, the reader always creates the setting.

Fix this; now the writer writes HWADDR even if empty when the setting
is present; the reader creates the setting when at least one property
is found.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/166
https://bugzilla.redhat.com/show_bug.cgi?id=1703960
2019-05-28 09:53:00 +02:00
Thomas Haller
e1b824b871 shared: fix return in nm_value_type_to_variant()/nm_value_type_get_variant_type()
Fixes: 75703a2425 ('shared: add accessor functions for NMValueType')
2019-05-27 13:27:13 +02:00
Thomas Haller
51793569e1 dispatcher: merge branch 'th/dispatcher-cleanup'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/162
2019-05-27 12:44:25 +02:00
Thomas Haller
7ea76c07e5 dispatcher: log warning when nm-dispatcher quits with requests pending 2019-05-27 12:43:06 +02:00
Thomas Haller
acc335aad4 dispatcher/systemd: order NetworkManager-dispatcher.service Before=NetworkManager.service
During shutdown, systemd should first stop NetworkManager and then
the dispatcher service. Note that dispatcher service is D-Bus activated,
so the two services don't Want/Require each other. But the ordering
still matters.
2019-05-27 12:43:06 +02:00
Thomas Haller
947f979f26 dispatcher/trivial: add FIXME comment about how to fix shutdown of NtworkManager 2019-05-27 12:43:06 +02:00
Thomas Haller
aafeaeab18 dispatcher: log ifname/con_uuid as structured logging for dispatcher requests 2019-05-27 12:43:06 +02:00