Commit Graph

21088 Commits

Author SHA1 Message Date
Lubomir Rintel
ee916a1e9e all: fix -Wcast-function-type warnings
GCC 8.0's -Wcast-function-type objects casting function pointers to ones
with incompatible prototypes. Sometimes we do that on purpose though.

Notably, the g_source_set_callback()'s func argument can point to functions
of various prototypes. Also, libnm-glib/nm-remote-connection is perhaps
just not worth reworking, that would just be a waste of time.

A cast to void(*)(void) avoids the GCC warning, let's use it.
2018-02-08 17:11:46 +01:00
Lubomir Rintel
3113e193c0 platform/nmp-object: make nmp_object_unref() return void
This makes its prototype compatible with GDestroyNotify so that GCC 8.0
won't warn.

The return value is not used anywhere and the unref() functions typically
don't return any.
2018-02-08 17:11:46 +01:00
Lubomir Rintel
411e72b3c9 shared/utils/dedup-multi: make nm_dedup_multi_obj_unref() return void
This makes its prototype compatible with GDestroyNotify so that GCC 8.0
won't warn.

The return value is not used anywhere and the unref() functions typically
don't return any.
2018-02-08 17:11:46 +01:00
Lubomir Rintel
7f7207f36b libnm/vpn-plugin: avoid bad function pointer type casts
This makes GCC 8.0 unhappy and it is probably right about that -- it's more
difficult to get things wrong when the function prototypes actually match.
2018-02-08 17:11:46 +01:00
Lubomir Rintel
422e87ec0d m4/trivial: add a bug link to a compiler warning check 2018-02-08 17:11:46 +01:00
Beniamino Galvani
10ef61408e dns: fix compilation error
Fixes the following error when building with gcc 4.8.5 and address
sanitizer:

src/dns/nm-dns-dnsmasq.c: In function 'update':
src/dns/nm-dns-dnsmasq.c:506:44: error: 'first_prio' may be used uninitialized in this function [-Werror=maybe-uninitialized]
    } else if (first_prio < 0 && first_prio != prio)
                                            ^
2018-02-08 11:18:06 +01:00
Thomas Haller
bc81efec55 all: merge branch 'th/mixed'
https://github.com/NetworkManager/NetworkManager/pull/64
2018-02-07 13:42:36 +01:00
Thomas Haller
54b2e8d679 platform: allow omitting output arguments for nm_utils_lifetime_get()
At various places we don't need the output argument. Allow to omit it,
which cleans up the caller.
2018-02-07 13:42:24 +01:00
Thomas Haller
d2871e453f platform: reorder printing address flags in nm_platform_addr_flags2str()
Print the "tentative" flags as last. Most other flags, have more the character of
a user configured attribute, while "tentative" reflects the current state of the address.

Previously, we would log
    secondary,tentative
and
    tentative,mngtmpaddr,noprefixroute

Print the "tenative" flag last. This way, the flag that commonly
will flip by kernel's decision, is consistently printed last.
2018-02-07 13:41:52 +01:00
Thomas Haller
e6f15f26eb core/logging: with --debug also output glib messages in stderr
With --debug, we duplicate nm-log messages to stderr. Do the same
for glib messages and don't only send them to syslog/journal.
2018-02-07 13:41:52 +01:00
Thomas Haller
8b4f119272 core: avoid IFA_F_TEMPORARY alias for IFA_F_SECONDARY
IFA_F_SECONDARY and IFA_F_TEMPORARY have the same numerical values,
and are synonymous. Consistently use IFA_F_SECONDARY.
2018-02-07 13:37:12 +01:00
Thomas Haller
b680cdd063 ndisc: adjust logging of timeouts for NDisc result
Previously, we would directly log get_expiry(), which is the absolute timestamp
inn nm_utils_get_monotonic_timestamp_s() scale. This time scale starts counting
somewhere around the time when the NetworkManager process starts, hence it is not
very intuitive to look at.

Instead, print the remaining time that is left counting from now. Since
we anyway only track timeouts with a granularity of whole seconds,
printing up to 4 decimal places is sufficiently precise.
2018-02-07 13:37:12 +01:00
Thomas Haller
28da0154fc all: drop trailing spaces 2018-02-07 13:32:04 +01:00
Thomas Haller
e4839accf5 all: replace non-leading tabs with spaces
We commonly only allow tabs at the beginning of a line, not
afterwards. The reason for this style is so that the code
looks formated right with tabstop=4 and tabstop=8.
2018-02-07 13:32:04 +01:00
Thomas Haller
ca7273b3e2 dhcp/tests: don't use tab characters in string literal
I think we should avoid non-trailing tabs in source code.
Allowing unescaped tab characters in string literals, adds
noise when searching the code for non-trailing tabs.

Also, depending on the editor configuration, it might be
non-obvious that tabs are used. And while I dislike tabs in general,
I think they are especially bad, when they have actual meaning
in code.
2018-02-07 13:32:04 +01:00
Thomas Haller
49985a890f po: drop Changelog file
The file is badly outdated and obviously unused. Replace the existing entries
with a comment where to find the outdated changelog.
2018-02-07 13:32:01 +01:00
Thomas Haller
665d47466a device: merge branch 'th/device-activation-fix-rh1537160'
I was unable to actually reproduce the crash from rh1537160. But
these fixes seem right either way and might even fix the bug.

https://bugzilla.redhat.com/show_bug.cgi?id=1537160
2018-02-07 12:52:15 +01:00
Thomas Haller
bbaa603a72 device: gracefully handle unmanaged device during _device_activate() 2018-02-07 12:35:22 +01:00
Thomas Haller
9c094f93fb device: don't return value from _device_activate()
It was only used at one place for an assertion. And it's not clear that the
assertion always holds.
2018-02-07 12:35:22 +01:00
Thomas Haller
ecf3677e57 device: clear priv->queued_act_request before setting state
Setting the state of NMActiveConnection results in invoking callbacks
in NMManager. Hence, it might be far-reaching. Clear
priv->queued_act_request before invoking the callbacks.
2018-02-07 12:35:22 +01:00
Thomas Haller
edc4dd5167 device: minor cleanup unqueuing queued_act_request
Use gs_unref_object and g_steal_pointer() to move ownership around.
2018-02-07 12:35:22 +01:00
Thomas Haller
6d623825f6 core: transit to DISCONNECTING state for NMActiveConnection
Don't just directly switch to DISCONNECTED state. If we are ACTIVATING
or ACTIVATED, first transition to DISCONNECTING state.
2018-02-07 12:35:22 +01:00
Thomas Haller
c5a97ad265 manager: use nm_active_connection_set_state_fail() instead of _internal_activation_failed()
There is a small change in behavior:

Previously, the DEACTIVATING/DEACTIVATED states were set if and only if
the previous state was less or equal then ACTIVATED. For example,
if the state was already DEACTIVATING, it would have done nothing.

Now, nm_active_connection_set_state_fail() transitions the states
depending on the previous state. E.g. it would only set DEACTIVATING
state, if the previous state was ACTIVATING/ACTIVATED. On the other hand,
it would always progress the state to DEACTIVATED.

The new behavior makes more sense to me, although I doubt that there is
a visible difference.
2018-02-07 12:35:22 +01:00
Thomas Haller
c027fc5d82 core: add nm_active_connection_set_state_fail() helper 2018-02-07 12:35:22 +01:00
Thomas Haller
c6d0fbe7b0 manager: abort activation if the device is still unmanaged
unmanaged_to_disconnected() is supposed to mark the device as managed.
However, it may easily be unable to do so, for example if the device
is unmanaged by NM_UNMANAGED_USER_SETTINGS.

Shortly before actually enqueuing the activation request, check and
error out. Otherwise, we might hit an assertion later in
_device_activate().
2018-02-07 12:35:22 +01:00
Thomas Haller
6b08d2dda2 manager: reorder adding active-connection and queueing activation
Note how recheck_assume_connection() called:

    nm_exported_object_export (NM_EXPORTED_OBJECT (active));
    active_connection_add (self, active);
    nm_device_queue_activation (device, NM_ACT_REQUEST (active));

That differs from the order during _internal_activate_generic(), where
we would end up with:

    nm_exported_object_export (NM_EXPORTED_OBJECT (active));
    nm_device_queue_activation (device, NM_ACT_REQUEST (active));
    active_connection_add (self, active);

It makes more sense to me to *first* add the connection, and only then
starting the activation with nm_device_queue_activation().

Also, let active_connection_add() always export the new active
connection object, if it is not already exported. All callers of
active_connection_add() ensured that the new object is already
exported.
2018-02-07 12:35:22 +01:00
Thomas Haller
61380c0d87 manager: refactor active_connection_parent_active() to return-early
Replace the if-else-if construct with "if(failure) return;". It reads nicer.
2018-02-07 12:35:22 +01:00
Thomas Haller
6075348f0f manager: reorder conditions in unmanaged_to_disconnected() to check cheaper condition first
Getting nm_device_get_state() is cheap, contrary to nm_device_is_available().
Reorder the checks.
2018-02-07 12:35:22 +01:00
Thomas Haller
fc0430b1ab core/trivial: add comment in set_property() for construct-only properties 2018-02-07 12:35:21 +01:00
Thomas Haller
80b95f8b5f core/trivial: add FIXME comment about uncancellable async action 2018-02-07 12:31:54 +01:00
Thomas Haller
0df3837656 manager: use cleanup functions for impl_manager_activate_connection()
Also, drop two redundant g_assert(). If we proceed, we will very soon afterwards
hit a SEGFAULT or a g_return_val_if_fail(), which is just as good.
2018-02-07 12:31:54 +01:00
Lubomir Rintel
631982a796 m4: disable -Wcast-function-type
This fixes the GCC 8 build. It disables the warning conditionally so that we
get the warning back if glib gets fixed.
2018-02-07 11:46:56 +01:00
Francesco Giudici
31d9a9de14 libnm-core: team: add support to runner "random"
https://bugzilla.redhat.com/show_bug.cgi?id=1538699
2018-02-05 15:24:36 +01:00
Thomas Haller
782578122c ovs: fix compiler error for passing NMDevice pointer to NM_DEVICE_OVS_INTERFACE_GET_PRIVATE()
NM_DEVICE_OVS_INTERFACE_GET_PRIVATE() is implemented via the _NM_GET_PRIVATE()
macro. This macro uses C11's _Generic() to provide additional compiler checks
when casting from an incompatible pointer type.

As such,

  NMDevice *device = ...;
  NMDeviceOvsInterfacePrivate *priv;

  priv = NM_DEVICE_OVS_INTERFACE_GET_PRIVATE (device);

causes a compilation error:

    error: ‘_Generic’ selector of type ‘NMDevice * {aka struct _NMDevice *}’ is not compatible with any association

One workaround would be to cast the pointer first:

  priv = NM_DEVICE_OVS_INTERFACE_GET_PRIVATE ((NMDeviceOvsInterface *) device);

A better fix is to mark NMDevice as a compatible pointer in _NM_GET_PRIVATE(),
which this patch does.

Previously, this went unnoticed, because due to bug "a43bf3388 build: fix configure
check for CC support of _Generic() and __auto_type", we failed to detect support
for _Generic() when compiling with -Werror. That essentially disables this check,
and NM_DEVICE_OVS_INTERFACE_GET_PRIVATE() would do a direct cast.

A workaround for this build failure might be to build with -Werror, which accidentally
results in not using _Generic().

https://bugzilla.gnome.org/show_bug.cgi?id=793183

Fixes: 8ad310f8e3
2018-02-05 13:59:15 +01:00
Thomas Haller
a43bf33888 build: fix configure check for CC support of _Generic() and __auto_type
autotools' AC_LANG_PROGRAM() generates a main() function which triggers
a compiler warning (for which we fail with -WError).

    conftest.c:92:1: error: function declaration isn't a prototype [-Werror=strict-prototypes]
     main ()
     ^~~~
    cc1: all warnings being treated as errors

Fixes: 557d83bf2d
2018-02-05 12:59:52 +01:00
Lubomir Rintel
8ad310f8e3 ovs-interface: avoid starting ip[46] configuration more than once
OvsInterface can postpone the stage3_ip[46]_config until the link
actually appears. It ought to restart the stage only when the link
appears, not upon further changes to it (which would trip an assertion
when starting the DHCP client while one already exists).

https://bugzilla.redhat.com/show_bug.cgi?id=1540063
2018-02-05 10:57:16 +01:00
Piotr Drąg
fa8a90a28e po: update Polish (pl) translation (bgo #792436)
https://bugzilla.gnome.org/show_bug.cgi?id=792436
2018-02-05 10:46:47 +01:00
Lubomir Rintel
edf6f826b5 nmcli: fix signal handling
Hook the signal handlers right before the main loop. Prior to that
the default handlers are good enough and our one crashes (due to
loop being instantialized).

Also, set the return value properly to indicate a termination by a
signal.
2018-01-24 09:53:38 +01:00
Lubomir Rintel
7e8a84ae10 nmcli/agent: fix handling of polkit agent failure
On "nmcli agent all", when the polkit agent fails (while the NM agent
succeeds), the failure is not communicated until the client exits.
2018-01-24 09:53:38 +01:00
Lubomir Rintel
fc4552d391 shared/utils: don't warn of unknown warning disables with clang
When pushing a warning disable with clang, always disable
-Wunknown-warning-option first -- it might be that clang wouldn't warn
of what we're trying to disable because it doesn't recognize it in the
first place. That is entierely okay.

With clang-5.0.0:

    CC       libnm/tests/libnm_tests_test_secret_agent-test-secret-agent.o
  In file included from libnm/tests/test-secret-agent.c:29:
  In file included from ./shared/nm-test-libnm-utils.h:23:
  ./shared/nm-utils/nm-test-utils.h:432:3: error: unknown warning group '-Wunused-but-set-variable', ignored [-Werror,-Wunknown-warning-option]
                  NM_PRAGMA_WARNING_DISABLE("-Wunused-but-set-variable")
                  ^
  ./shared/nm-utils/nm-macros-internal.h:223:9: note: expanded from macro 'NM_PRAGMA_WARNING_DISABLE'
          _Pragma(_NM_PRAGMA_WARNING_DO(warning))
          ^
  <scratch space>:204:25: note: expanded from here
   GCC diagnostic ignored "-Wunused-but-set-variable"
                          ^
  1 error generated.
2018-01-24 09:53:38 +01:00
Thomas Haller
c93827e404 wifi/iwd: fix compiler warning about uninitialized variable with cleanup attribute
Must always initialize cleanup variable, to be able to build with
"-fexceptions".

    make[2]: Entering directory './contrib/fedora/rpm/NetworkManager.20180124-060444.C5tHCi/BUILD/NetworkManager-1.11.1'
      CC       src/devices/wifi/src_devices_wifi_libnm_device_plugin_wifi_la-nm-device-iwd.lo
    In file included from ./shared/nm-utils/nm-glib.h:27:0,
                     from ./shared/nm-utils/nm-macros-internal.h:60,
                     from ./shared/nm-default.h:257,
                     from src/devices/wifi/nm-device-iwd.c:21:
    src/devices/wifi/nm-device-iwd.c: In function ‘deactivate_async_finish’:
    ./shared/nm-utils/gsystem-local-alloc.h:37:8: error: ‘variant’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
         if (*(Type*)v) \
            ^
    src/devices/wifi/nm-device-iwd.c:405:29: note: ‘variant’ was declared here
      gs_unref_variant GVariant *variant;
                                 ^~~~~~~

Fixes: d0c1e1a62a
2018-01-24 06:14:34 +01:00
Thomas Haller
aed6e28461 trivial: avoid XXX tag and replace by NOTE or FIXME
XXX was used to either raise attention (NOTE) or to indicate
that this is ugly code that should be fixed (FIXME). The usage
was inconsistent.

Let's avoid XXX and use either NOTE or FIXME.
2018-01-23 12:55:33 +01:00
Thomas Haller
b411b54e27 all: merge branch 'th/version-macros'
https://github.com/NetworkManager/NetworkManager/pull/61
2018-01-23 10:58:33 +01:00
Thomas Haller
c7ff37967a version: add reminder comment for adding version macros to configure.ac 2018-01-23 10:57:41 +01:00
Thomas Haller
4da1480cfd version: rename macro NM_VERSION_CUR_STABLE to NM_API_VERSION
NM_API_VERSION is a better name. It's not the current stable
version, but the version number of the API which the current
NM_VERSION provides. In practice, NM_API_VERSION is either identical
to NM_VERSION (in case of a release) or NM_VERSION is a development
version leading up the the upcoming NM_API_VERSION.

For example, with the new name the check

  #if NM_VERSION != NM_API_VERSION
  # warning this is an development version
  #endif

makes more sense.
2018-01-23 10:54:11 +01:00
Thomas Haller
165fe65eef version: calculate NM_VERSION_CUR_STABLE based on the version numbers
We have a well defined versioning scheme and a defined way how
the version number indicates a stable version. We can simply
calculate NM_VERSION_CUR_STABLE based on the version numbers.
2018-01-23 10:50:34 +01:00
Thomas Haller
9ef17869b5 version: drop NM_VERSION_MAX_ALLOWED defines for internal build
It already defaults to the right value. We only need to define
NM_VERSION_MIN_REQUIRED, so that parts of our internal build
can make use of deprecated API.
2018-01-23 10:50:34 +01:00
Thomas Haller
8a040c6883 version: combine NM_VERSION_CUR_STABLE and NM_VERSION_NEXT_STABLE
We don't need to have two version defines "CUR" and "NEXT".

The main purpose of these macros (if not their only), is to
make NM_AVAILABLE_IN_* and NM_DEPRECATED_IN_* macros work.

1) At the precise commit of a release, "CUR" and "NEXT" must be identical,
because whenever the user configures NM_VERSION_MIN_REQUIRED and
NM_VERSION_MAX_ALLOWED, then they both compare against the current
version, at which point "CUR" == "NEXT".

2) Every other commit aside the release, is a development version that leads
up the the next coming release. But as far as versioning is concerned, such
a development version should be treated like that future release. It's unstable
API and it may or may not be close to later API of the release. But
we shall treat it as that version. Hence, also in this case, we want to
set both "NM_VERSION_CUR_STABLE" and again NEXT to the future version.

This makes NM_VERSION_NEXT_STABLE redundant.

Previously, the separation between current and next version would for
example allow that NM_VERSION_CUR_STABLE is the previously release
stable API, and NM_VERSION_NEXT_STABLE is the version of the next upcoming
stable API. So, we could allow "examples" to make use of development
API, but other(?) internal code still restrict to unstable API. But it's
unclear which other code would want to avoid current development.

Also, the points 1) and 2) were badly understood. Note that for our
previousy releases, we usually didn't bump the macros at the stable
release (and if we did, we didn't set them to be the same). While using
two macros might be more powerful, it is hard to grok and easy to
forget to bump the macros a the right time. One macro shall suffice.

All this also means, that *immediately* after making a new release, we shall
bump the version number in `configure.ac` and "NM_VERSION_CUR_STABLE".
2018-01-23 10:50:34 +01:00
Thomas Haller
f67686256f config: fix using the right nm-version for the match specification
We can disable/enable configuration snippets per NetworkManager
version. But we must compare it against the current version
that we build, not the current API version.
2018-01-23 10:50:34 +01:00
Francesco Giudici
72bf38cad6 cli: merge branch 'fg/team_link_watchers_overwrite-rh1533926'
https://bugzilla.redhat.com/show_bug.cgi?id=1533926
2018-01-22 19:23:25 +01:00