For certain options, kernel stores the numeric values in jiffies scale,
while the user space value is in USER_HZ (1/100th of a second) scale.
Jiffies scale depends on HZ setting (CONFIG_HZ), and depending on kernel
configuration its 100, 250, 300, or 1000.
That means, the round trip of clock_t_to_jiffies()/jiffies_to_clock_t()
has different rounding errors, depending on CONFIG_HZ and it maybe be
+/- 1 of the requested value.
Since the rounding error depends on CONFIG_HZ, we cannot find "good"
values for testing, that always behave the same. So we need to
workaround that.
Normalize the bridge values, if they look as if the value was mangled
due to rounding.
Related: https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/665
Some compiler versions don't like to dereference and opaque
pointer for typeof:
gcc 8.3.1-5.1.el8 on RHEL:
In file included from ./src/libnm-glib-aux/nm-macros-internal.h:41,
from ./src/libnm-glib-aux/nm-default-glib.h:68,
from ./src/libnm-glib-aux/nm-default-glib-i18n-lib.h:13,
from ./src/libnm-core-impl/nm-default-libnm-core.h:11,
from src/libnm-core-impl/nm-setting-8021x.c:7:
src/libnm-core-impl/nm-setting-8021x.c: In function '_nm_setting_802_1x_cert_value_to_bytes':
./src/libnm-glib-aux/nm-glib.h:417:16: error: dereferencing pointer to incomplete type 'GBytes' {aka 'struct _GBytes'}
typeof(**_pp) *const _p = *_pp; \
^~~~~
src/libnm-core-impl/nm-setting-8021x.c:361:12: note: in expansion of macro 'g_steal_pointer'
return g_steal_pointer(&bytes);
^~~~~~~~~~~~~~~
./src/libnm-glib-aux/nm-glib.h:417:54: error: initialization of 'int * const' from incompatible pointer type 'GBytes *' {aka 'struct _GBytes *'} [-Werror=incompatible-pointer-types]
typeof(**_pp) *const _p = *_pp; \
^
src/libnm-core-impl/nm-setting-8021x.c:361:12: note: in expansion of macro 'g_steal_pointer'
return g_steal_pointer(&bytes);
^~~~~~~~~~~~~~~
./src/libnm-glib-aux/nm-glib.h:415:6: error: returning 'int * const' from a function with incompatible return type 'GBytes *' {aka 'struct _GBytes *'} [-Werror=incompatible-pointer-types]
({ \
~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
typeof(*(pp)) *const _pp = (pp); \
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
typeof(**_pp) *const _p = *_pp; \
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_nm_unused const void *const _p_type_check = _p; \
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\
~
*_pp = NULL; \
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_p; \
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
})
~~
src/libnm-core-impl/nm-setting-8021x.c:361:12: note: in expansion of macro 'g_steal_pointer'
return g_steal_pointer(&bytes);
^~~~~~~~~~~~~~~
Fixes: 5bc511203e ('all: make nm_steal_pointer() and g_steal_pointer() more typesafe using typeof()')
NM_DHCP_STATE_DONE is for when the client reports that it is shutting
down. If we manually stop it, we should set the TERMINATED state, so
that NMDevice doesn't start a grace period waiting for a renewal.
This fixes the:
device (enp1s0): DHCPv4: trying to acquire a new lease within 90 seconds
message printed when NM is shutting down.
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/802
The previous code would always cast the argument to "void *", and thus
loose some type information.
For example,
gulong variable = 0;
g_steal_pointer(&variable);
would compile, when it shouldn't.
In general, we try to avoid redefining glib macros and headers. But we
really want those extra compile time checks that we can get, so let's do
it.
build_message() is an internal helper function with a very specific
purpose.
Let's change it to take an NMStrBuf argument for generating
the string. The advantage is that we don't need to allocate and
free the buffers in between, but can just reuse it.
When using a GValue, we really should call g_value_unset(). Otherwise
it is a code smell, even if we technically only created GValue with
static strings and integers.
But changing that is not easy, because the AuditField structs are
allocated on the stack, and in different functions. So we cannot just
pass a GDestroyNotify to GPtrArray to cleanup all those fields, because
by then they will be out of scope.
The proper solution would be to heap allocate the AuditField struct, add
them to the GPtrArray, and free them with the free function. But that
seams really unnecessary overhead, for something that is correct in
practice. Let's accept the fact that by the time the fields array gets
destroyed, it contains dangling pointers.
If we already embrace the dangling pointers and that stuff is allocated
on the stack and that we don't need to free, also get rid of GValue
and use our plain NMValueType and NMValueTypUnion. GValue really doesn't
give us much here. And it only makes us wonder: is it OK to not call
g_value_unset()? With the plain tracking of the values, we know that
it is OK.
_nm_log_impl() is the underlying implementation. As we have
multiple implementations, it's a bit confusing how it all works
together.
We thus should not call this directly, so that there are few (literal)
uses of this symbol.
Still, we may need to call this version of the logging statement,
because it's the only one that allows to provide the file location.
Add a wrapper macro for this, that callers can use.
$ make src/libnm-systemd-shared/src/fundamental/libnm_systemd_shared_la-string-util-fundamental.lo
CC src/libnm-systemd-shared/src/fundamental/libnm_systemd_shared_la-string-util-fundamental.lo
In file included from ./src/libnm-glib-aux/nm-default-glib.h:11,
from ./src/libnm-systemd-shared/nm-default-systemd-shared.h:11,
from ./src/libnm-systemd-shared/sd-adapt-shared/nm-sd-adapt-shared.h:9,
from src/libnm-systemd-shared/src/fundamental/string-util-fundamental.c:3:
./src/libnm-std-aux/nm-default-std.h:32:10: fatal error: config-extra.h: No such file or directory
32 | #include "config-extra.h"
| ^~~~~~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:15660: src/libnm-systemd-shared/src/fundamental/libnm_systemd_shared_la-string-util-fundamental.lo] Error 1
Fixes: 2a88de2280 ('systemd: merge branch systemd into master')
Previously, nmtui would set the newt color "checkbox" to a hard coded
value. This made it impossible to override the color via "$NEWT_COLORS".
With this change, nmtui also parses "$NEWT_COLORS" to allow setting
newt colors:
$ NEWT_COLORS='
window=white,red
border=white,red
checkbox=white,red
actcheckbox=white,green
' nmtui
Custom nmtui colors can now also be set via "$NMT_NEWT_COLORS":
"badLabel"
"plainLabel"
"disabledButton"
"textboxWithBackground"
For example:
$ NMT_NEWT_COLORS='plainLabel=green,lightgray' nmtui
The environment variables "$NEWT_COLORS_FILE" and "NMT_NEWT_COLORS_FILE"
are honored too.
The code is based on libnewt code ([1]), authored by Miroslav Lichvar.
That patch is originally LGPL-2.0-only licensed, but for inclusion in
NetworkManager we require it to be LGPL-2.1-or-later. Miroslav kindly
agreed to use his original contribution in NetworkManager.
[1] https://pagure.io/newt/c/34e56d12931a25222d7debb22f95bb2f9fa696a0
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/653https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/793
In many cases, macros should aim to be function-like. That is,
to evaluate all arguments and evaluate them exactly once.
Fix NM_FLAGS_ALL() to evaluate the "check" argument only once.
One downside of this change is that the result is no longer a compile
time constance and cannot be used to initialize static variables. But
that isn't used much anyway.
The "_lst" suffix already indicates that this is a list. We have
a list of ip-configs, so the prefix should be singular. It also matches
the "NMDnsConfigIPData.ip_config_lst" field.
The main reason for this renaming is that I want to search the file
for /ip_config_lst/ and find both the list head and the list elements.
Better fix for https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/732
The original issue was that when compiling NetworkManager with slibtool
the create-exports-NetworkManager.sh script gave the NetworkManager-all-sym
slibtool wrapper script to nm(1) instead of the actual binary. This is
because slibtool and GNU libtool do not place the compiled programs in
the same location. The original fix was to test both locations, but this
is bit of a hack especially since the build system should not be using the
.libs directory directly. However with $(LIBTOOL) --mode=execute this is
not a problem since both implementations can figure out where the correct
binary is.
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/805
- add more error handling and free/unref data.
- split code in 3 functions: vpn_connection_import(),
connection_add() and main(). These steps are mostly
independent, and having them in separate functions
makes their separation clearer.
- handle error from nm_client_add_connection_async() to
exit program with non zero exit code.