Commit Graph

23466 Commits

Author SHA1 Message Date
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 548bacd24e1b7d1d5b37dd83768c1e425a6b5cee)
2019-05-28 14:37:30 +02:00
Lubomir Rintel
a9da4f5180 po: update-po
(cherry picked from commit 9de7c0542c6ee44cb0c54c0fcdb5155d00ef3a31)
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
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
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
cdaedecaa7 dispatcher: unown dispatcher D-Bus name on exit 2019-05-27 12:10:26 +02:00
Thomas Haller
a01e760667 dispatcher: drop GDBusInterfaceSkeleton and generate GDBus bindings
Just hook into GDBusConnection directly. No need for this additional
layer that provides nothing. It doesn't even provide extra type-safety,
because you still need to get the arguments of the signal handler right.
That that point, it's as hard as getting the format string for
g_variant_get() right.

It still adds lines of code, because the "Action" method has such a
large argument list.
2019-05-27 12:10:26 +02:00
Thomas Haller
484194fa07 dispatcher: drop Handler GObject
"nm-dispatcher.c" does something rather simple. It is natural that it
has a bit of global data to keep track of that it's doing ("gl").

But this does not lend itself to pack the job of dispatcher into an
object. In fact, the Handler object was little more about packaging
the GDBus interface skeleton and a bit of state.

Global variables are often problematic because they makes unit testing hard.
But first of all, we have no test for this (we should). But it's not said
that you need an "object" to make testing easier. If we want to make
individual bits easier testable, we can just as well pass all required
parameters explicitly instead of accessing global variables. Since we
package global variables neatly in "gl", this is very simple to
refactor. Also, global variables can make code harder to understand. But
the problem is the amount of state that is accessible. This is not
alleviated by packaging the state in a Handler object.

As there is always only one handler instance, this provides very little
benefit.

I will drop the GDBus interface skeleton soon. So this Handler object
will have even less purpose. Drop it.
2019-05-27 12:10:26 +02:00
Thomas Haller
cdea5ca795 dispatcher: keep the GDBusConnection instance in the global variable
It's anyway a singleton that is still referenced by other components.
So unrefing it in the mainloop does not actually release any memory.

However, the GDBusConnection singleton is fundamental for the run of
the program. Keep it accessible in the global variables.

Note that soon I will drop the GDBusInterfaceSkeleton and only operate
on the GDBusConnection. Then it makes more sense to keep it around.

Note that usually we want to keep the amount of global state small.
But this connection is anyway a singleton (that we already implicitly
use). So, it doesn't change the amount of global state nor does it really
have much state (we either have a reference to the singleton or we don't).
2019-05-27 12:09:53 +02:00
Thomas Haller
3a3c807add dispatcher: parse command line arguments in a seprate function
Split command line parsing out of the main() function. For one, it's
an self-contained step, so we can make main() simpler.

Also, we don't need the GOptionEntry on the stack of the main() function
for the remainder of the program.
2019-05-27 12:07:52 +02:00
Thomas Haller
866189a001 dispatcher: don't just exit() but always shutdown before exiting
It's ugly to uncoordinated just call exit(). We should quit the mainloop
and clean up everything we had going.

Note that since Handler has no dispose() function, we also need to hack
a g_signal_handlers_disconnect_by_func(). This will change soon.
2019-05-27 12:07:52 +02:00
Thomas Haller
90e4ba15bc dispatcher: move global variable ever_aquired_name into "gl" struct 2019-05-27 12:07:52 +02:00
Thomas Haller
a454e418d4 dispatcher: unref main loop at exit and remove signal handler sources 2019-05-27 12:07:52 +02:00
Thomas Haller
bccf754347 dispatcher: namespace global variables in a struct "gl" 2019-05-27 12:07:52 +02:00
Thomas Haller
23286b2afa dispatcher: use logging macros instead of g_log() directly
Also cleanup the logging macros.
2019-05-27 12:01:09 +02:00
Thomas Haller
b4d678b314 dispatcher: silence message about non-existing dispatcher directory
Silence messages like

  find-scripts: Failed to open dispatcher directory '/usr/lib/NetworkManager/dispatcher.d': Error opening directory “/usr/lib/NetworkManager/dispatcher.d”: No such file or directory

  find-scripts: Failed to open dispatcher directory '/usr/lib/NetworkManager/dispatcher.d/pre-up.d': Error opening directory “/usr/lib/NetworkManager/dispatcher.d/pre-up.d”: No such file or directory
2019-05-27 12:01:09 +02:00
Thomas Haller
8518a87387 dispatcher: log messages about loading scripts per-request
The messages about loading the scripts are releated to a particular
request. Hence, they should be logged with that context.

Also, we should avoid using g_log() directly. Use our logging macros
instead.
2019-05-27 12:01:09 +02:00
Thomas Haller
58704a37ae dispatcher: don't print debug messages of dispatcher in regular mode
Previously, we would log several messages with level "debug" / g_info().

  _LOG_R_D (request, "start running ordered scripts...");
  _LOG_R_D (request, "new request (%u scripts)", request->scripts->len);
  _LOG_R_D (request, "completed: no scripts");

Note that this effectively logs a message for every event. I think that
is to verbose and not suitable for regular logging.

Only enable these messages if debug logging is enabled. As such, these debug
level messsages now are enabled together with the trace level messages.
2019-05-27 12:01:09 +02:00
Thomas Haller
dd72696af7 dispatcher/trivial: rename logging levels
What we currently print as "info" level is too verbose for regular
operation. It prints two messages for every dispatcher event. That's
already for debugging.

Next that will be downgraded, so rename "debug" to "trace" and "info" to
"debug".

There is only renaming, no change in behavior.
2019-05-27 12:01:09 +02:00
Thomas Haller
17dc6a9da6 shared: add _NM_ENSURE_TYPE_CONST()
The sole purpose of this is more type-safe macros.

An alternative solution would be to define a function instead of a
macro. But if the function is unused (currently!) you get a compiler
warning (on some compilers even when marking the function as "static
inline", if it's in the source file). A workaround for that would be
to mark the function as _nm_unused, or to use a macro instead.

_NM_ENSURE_TYPE_CONST() is to aid the macro solution.
2019-05-27 12:01:09 +02:00