Commit graph

11982 commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
Thomas Haller
55be5166f0 dispatcher: cleanup nm_dispatcher_call_cancel()
Remove the call-id from the requests hash before invoking the callback.
This prevents the user to cancel the request from within the callback.
Supporting such a use case is not necessary so prevent it and tighten
the callers up.
2019-05-27 12:42:51 +02:00
Thomas Haller
3dbda5addc dispatcher: use GDBusConnection instead of GDBusProxy in "nm-dispatcher.c"
- drops nm_dispatcher_init(), which was called early in the main loop
  and created a proxy synchronously. Instead, the GDBusConnection is
  always ready.

- reuse the GDBusConnection of NMDBusManager. This means, we won't even
  try from in "initrd" configure-and-quit mode.

- as before, there is no "manager" instance. Instead, the data is stored
  in a global variable. That's ok. What is not OK is how the entire
  shutdown is handled (calling dispatcher blockingly, not waiting for
  requests to complete). That is fixable, but a lot of work. It is
  independent of whether we use a manager object or not.
2019-05-27 12:39:37 +02:00
Thomas Haller
c3e2959a5a dispatcher: replace guint call-id by opaque NMDispatcherCallId
A guint value can wrap, so we would need to check that we don't allocate duplicate
IDs (which we currently don't, and it's likely never to actually hit).

Just expose the (opaque) pointer of the call-id.

We still keep a "request_id", but that is only for logging purpose.
2019-05-27 12:39:37 +02:00
Thomas Haller
c82703d417 dispatcher: add logging macros for per-request messages
This way, we avoid code duplication of how to print the request-id
("(%u) "), but it also will allow up to attach the interface name
and connection name to the call-id, so that we can use it for structured
logging.
2019-05-27 12:39:37 +02:00
Thomas Haller
da345efc08 dispatcher: cleanup constructing parameter in _dispatcher_call()
Don't duplicate this code.
2019-05-27 12:39:37 +02:00
Thomas Haller
f8b0bad2c9 dispatcher: cleanup dispatcher_results_process()
We don't need the two callers both unpack the GVariant and pass a GVariantIter.
Let dispatcher_results_process() do the unpacking.

Also, use some cleanup attributes.
2019-05-27 12:39:37 +02:00
Thomas Haller
13f6f3a410 libnm: rework team handling of JSON config
Completely refactor the team/JSON handling in libnm's NMSettingTeam and
NMSettingTeamPort.

- team handling was added as rh#1398925. The goal is to have a more
  convenient way to set properties than constructing JSON. This requires
  libnm to implement the hard task of parsing JSON (and exposing well-understood
  properties) and generating JSON (based on these "artificial" properties).
  But not only libnm. In particular nmcli and the D-Bus API must make this
  "simpler" API accessible.

- since NMSettingTeam and NMSettingTeamPort are conceptually the same,
  add "libnm-core/nm-team-utils.h" and NMTeamSetting that tries to
  handle the similar code side-by-sdie.
  The setting classes now just delegate for everything to NMTeamSetting.

- Previously, there was a very fuzzy understanding of the provided
  JSON config. Tighten that up, when setting a JSON config it
  regenerates/parses all other properties and tries to make the
  best of it. When modifying any abstraction property, the entire
  JSON config gets regenerated. In particular, don't try to merge
  existing JSON config with the new fields. If the user uses the
  abstraction API, then the entire JSON gets replaced.

  For example note that nm_setting_team_add_link_watcher() would not
  be reflected in the JSON config (a bug). That only accidentally worked
  because client would serializing the changed link watcher to
  GVariant/D-Bus, then NetworkManager would set it via g_object_set(),
  which would renerate the JSON, and finally persist it to disk. But
  as far as libnm is concerned, nm_setting_team_add_link_watcher() would
  bring the settings instance in an inconsistent state where JSON and
  the link watcher property disagree. Setting any property must
  immediately update both the JSON and the abstraction API.

- when constucting a team setting from D-Bus, we would previously parse
  both "config" and abstraction properties. That is wrong. Since our
  settings plugins only support JSON, all information must be present
  in the JSON config anyway. So, when "config" is present, only the JSON
  must be parsed. In the best case, the other information is redudant and
  contributes nothing. In the worse case, they information differs
  (which might happen if the client version differs from the server
  version). As the settings plugin only supports JSON, it's wrong to
  consider redundant, differing information from D-Bus.

- we now only convert string to JSON or back when needed. Previously,
  setting a property resulted in parsing several JSON multiple times
  (per property). All operations should now scale well and be reasonably
  efficient.

- also the property-changed signals are now handled correctly. Since
  NMTeamSetting knows the current state of all attributes, it can emit
  the exact property changed signals for what changed.

- we no longer use libjansson to generate the JSON. JSON is supposed
  to be a machine readable exchange format, hence a major goal is
  to be easily handled by applications. While parsing JSON is not so
  trivial, writing a well-known set of values to JSON is.
  The advantage is that when you build libnm without libjansson support,
  then we still can convert the artificial properties to JSON.

- Requiring libjansson in libnm is a burden, because most of the time
  it is not needed (as most users don't create team configurations). With
  this change we only require it to parse the team settings (no longer to
  write them). It should be reasonably simple to use a more minimalistic
  JSON parser that is sufficient for us, so that we can get rid of the
  libjansson dependency (for libnm). This also avoids the pain that we have
  due to the symbol collision of libjansson and libjson-glib.

https://bugzilla.redhat.com/show_bug.cgi?id=1691619
2019-05-23 18:09:49 +02:00
Thomas Haller
d31622a63e ifcfg-rh: don't check for errors reading team settings in ifcfg-rh
We have nm_setting_verify() for a purpose.

The checks that ifcfg-rh reader does are either

  - redundant (and thus unnecessary)

  - wrong (and thus we cannot read valid settings)

  - should belong to libnm's nm_setting_verify().

NMSettingTeam/NMSettingTeamPort are already very libraral and don't do
almost any strict validation. Previously, ifcfg reader would be even more
liberal. If there is totally invalid data in the profile, reading the profile
should fail.
2019-05-23 18:09:49 +02:00
Thomas Haller
4b8a9cc51b ifcfg: use proper define for D-Bus interface name in "nms-ifcfg-rh-plugin.c"
No difference in practice, as both defines define the same name.
2019-05-23 11:07:26 +02:00
Beniamino Galvani
008a4b4215 team: don't kill teamd for external devices
The teamd instance must not be killed if the device was externally
activated.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/158
https://bugzilla.redhat.com/show_bug.cgi?id=1693142
2019-05-20 14:54:07 +02:00
Beniamino Galvani
58db61545d device: don't wait udev for devices created by us
If we created a software interface it is because we already decided
that it should be managed, and so there is no point in waiting udev to
check that the interface is not udev-unmanaged.

We still wait udev for software interfaces created externally.
2019-05-20 14:49:59 +02:00
Beniamino Galvani
d33c995d45 manager: relax condition when checking for duplicate ACs
An active connection started by user could be queued in state UNKNOWN
which means the device hasn't started activating yet. Eventually it
will, and we don't want to cancel the user activation because of an
internal autoconnection attempt.
2019-05-20 13:57:35 +02:00
Beniamino Galvani
831f079e55 device: use variable for platform in realize_start_setup() 2019-05-20 13:57:35 +02:00
Lubomir Rintel
ff2d0f5add manager: don't allow femoving a device without traversing proper states
There was a special case for ensuring that the device's configuration
doesn't disappear when some factory is too late at recognizing the
device is just a component of another one.

It was always a bad idea. If the device already had an active
connection (such as for a generated default wired connection), it would
remain around, with a dangling reference to the device.

This effectively reverts commit 5ad69cb29b ('core: remove child devices
without deconfiguring them (bgo #738479)'). It's okay to do so, because
we now wouldn't deconfigure the device upon its removal anyway.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/151/
2019-05-20 12:50:01 +02:00
Thomas Haller
eebcbfae75 dhcp: store dhclient's pid file in "/var/run/NetworkManager" instead of "/var/run"
The pid-file is private to NetworkManager. It should reside in NetworkManager's
run directory instead of "/var/run".

I don't think that changing this location can break existing uses. Why
would somebody outside of NetworkManager care about this file?

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/157
2019-05-20 11:52:31 +02:00
Thomas Haller
1da7dfc408 gitignore: merge gitignore files
For the most part, we only have one main .gitignore file.

There were a few nested files, merge them into the main file.

I find it better to have only one gitignore file, otherwise the
list of ignored files is spread out through the working directory.
2019-05-19 14:41:21 +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
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
Patrick J. Volkerding
e1df17e0ac hostname-manager: use fqdn for persistent hostname on Slackware
This will be the default for Slackware 15.0 and on.

This should be safe for both master and 1.12.x stable branch, as
no existing Slackware releases are expected to run NM-1.12.x or
later.

Signed-off-by: Robby Workman <rworkman@slackware.com>

https://mail.gnome.org/archives/networkmanager-list/2019-May/msg00011.html
2019-05-19 10:45:07 +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
16cd84d346 build/meson: rename platform tests to use same name as autotools
First of all, all file names in our source-tree should be unique. We should
not have stuff like "libnm-core/tests/test-general.c" and "src/tests/test-general.c".
The problem here are the C source files, and consequently also the test
binaries have duplicate names. We should avoid that in general. However,
our binaries should have a matching name with the C source. If
"test-general.c" is not good enough, that needs renaming. Not building
"platform-test-general" out of it.

On the other hand, all our tests should have a filename "*/tests/test-*", like
they do for autotools.

Rename the meson platform tests.

It's also important because "tools/run-nm-test.sh" relies on the test
name to workaround valgrind warnings.
2019-05-17 21:47:04 +02:00
Thomas Haller
b32ad2344e session-monitor: use "/run/ConsoleKit/database" instead of "/var/run/ConsoleKit/database"
There should be no difference in pratice. But we should not mention "/var/run"
as /var might not be mounted in early boot or rescue environment. Of course,
in those cases ConsoleKit is not running either. But still...
2019-05-17 21:24:18 +02:00
Thomas Haller
6a89f6c368 trivial: fix code comment mentioning "/var/run/NetworManager" to refer to "/run" 2019-05-17 21:24:18 +02:00