Commit graph

19197 commits

Author SHA1 Message Date
Thomas Haller
ff380c37bb 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.

(cherry picked from commit 6d623825f6)
2018-02-07 12:54:53 +01:00
Thomas Haller
5769d357c7 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.

(cherry picked from commit c5a97ad265)
2018-02-07 12:54:53 +01:00
Thomas Haller
4b35d0c109 core: add nm_active_connection_set_state_fail() helper
(cherry picked from commit c027fc5d82)
2018-02-07 12:54:53 +01:00
Thomas Haller
e127a54ba6 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().

(cherry picked from commit c6d0fbe7b0)
2018-02-07 12:54:53 +01:00
Thomas Haller
51a73e23e4 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.

(cherry picked from commit 6b08d2dda2)
2018-02-07 12:54:52 +01:00
Thomas Haller
883698482f manager: refactor active_connection_parent_active() to return-early
Replace the if-else-if construct with "if(failure) return;". It reads nicer.

(cherry picked from commit 61380c0d87)
2018-02-07 12:54:52 +01:00
Thomas Haller
9da9f22fed 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.

(cherry picked from commit 6075348f0f)
2018-02-07 12:54:52 +01:00
Thomas Haller
8c0f322892 core/trivial: add comment in set_property() for construct-only properties
(cherry picked from commit fc0430b1ab)
2018-02-07 12:54:52 +01:00
Thomas Haller
33d33be6af core/trivial: add FIXME comment about uncancellable async action
(cherry picked from commit 80b95f8b5f)
2018-02-07 12:54:52 +01:00
Thomas Haller
9c137d7e42 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.

(cherry picked from commit 0df3837656)
2018-02-07 12:54:52 +01:00
Lubomir Rintel
9777492dde 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.

(cherry picked from commit 631982a796)
2018-02-07 11:47:19 +01:00
Francesco Giudici
10760b100c libnm-core: team: add support to runner "random"
https://bugzilla.redhat.com/show_bug.cgi?id=1538699
(cherry picked from commit 31d9a9de14)
2018-02-06 12:45:18 +01:00
Thomas Haller
5159c34ea8 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
(cherry picked from commit 782578122c)
2018-02-05 14:04:06 +01:00
Thomas Haller
640673f75b 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
(cherry picked from commit a43bf33888)
2018-02-05 13:01:30 +01:00
Lubomir Rintel
2405959132 release: bump version to 1.10.5 (development) 2018-02-05 11:04:49 +01:00
Lubomir Rintel
f781411ceb release: bump version to 1.10.4 2018-02-05 11:03:52 +01:00
Lubomir Rintel
f32367d4c6 release: update NEWS 2018-02-05 10:58:33 +01:00
Lubomir Rintel
60eb596b0d 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
(cherry picked from commit 8ad310f8e3)
2018-02-05 10:58:33 +01:00
Piotr Drąg
f9f55afa18 po: update Polish (pl) translation (bgo #792436)
https://bugzilla.gnome.org/show_bug.cgi?id=792436
2018-02-04 16:28:28 +01:00
Thomas Haller
ec630dc256 libnm: cleanup include in "libnm-core/nm-json.c"
We already define _GNU_SOURCE in "config.h", depending
on configure checks.

Also, we always should first include "config.h" (which means
to first include "nm-default.h").

Also, we don't need the entire <link.h>, <dlfcn.h> suffices.

(cherry picked from commit 84576ce861)
2018-01-25 18:26:34 +01:00
Thomas Haller
5269978e37 libnm: add include guard to nm-json.h
(cherry picked from commit ee56c9250f)
2018-01-25 18:23:34 +01:00
Thomas Haller
0aa9273d33 libnm: fix spelling for NM_JAONSSON_C define
(cherry picked from commit 2888778480)
2018-01-25 18:23:07 +01:00
Thomas Haller
bbcb9ebefc libnm: rename "libnm-core/nm-jansson.h" to "libnm-core/nm-json.h"
We already have "shared/nm-utils/nm-jansson.h". Avoid reusing the same file name.

(cherry picked from commit b6b6baa773)
2018-01-25 18:23:01 +01:00
Thomas Haller
75dfbfcef4 libnm/trivial: don't use non-leading tabs
(cherry picked from commit 950a14128b)
2018-01-25 18:22:26 +01:00
Lubomir Rintel
66ae13f012 core: load jansson on demand
Avoid using it if the symbols clash is detected.

(cherry picked from commit cd476e4dc9)
2018-01-25 18:19:59 +01:00
Lubomir Rintel
2f991e379b 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.

(cherry picked from commit edf6f826b5)
2018-01-24 09:55:18 +01:00
Lubomir Rintel
3b7211a096 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.

(cherry picked from commit 7e8a84ae10)
2018-01-24 09:55:18 +01:00
Lubomir Rintel
356f1131f3 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.

(cherry picked from commit fc4552d391)
2018-01-24 09:55:18 +01:00
Francesco Giudici
e3affd7fd5 cli: merge branch 'fg/team_link_watchers_overwrite-rh1533926'
https://bugzilla.redhat.com/show_bug.cgi?id=1533926

(cherry picked from commit 72bf38cad6)
2018-01-22 19:34:07 +01:00
Francesco Giudici
4f76b01f10 doc: fix describe message for team link watchers
(cherry picked from commit d7f3c79881)
2018-01-22 19:31:29 +01:00
Francesco Giudici
97d153d9e3 nmcli: clear link-watchers before adding the new ones we want to set
(cherry picked from commit ff16252a71)
2018-01-22 19:31:04 +01:00
Francesco Giudici
fa3efd3ed6 libnm-core: ensure alignment of team.config and other team properties
https://bugzilla.redhat.com/show_bug.cgi?id=1533830
(cherry picked from commit 381c1a19b6)
2018-01-22 19:18:32 +01:00
Beniamino Galvani
a169247b7d device: skip IP configuration phase for external devices
We already avoid committing the IP configuration for external devices
(see commit 60334a2893). However, we still start DHCP/IPv6-autoconf
and, especially, we change sysctl values of the device.

To be sure that no action is taken on the device, return early from
the IP configuration phase, as in the method=disabled/ignore case.

https://bugzilla.redhat.com/show_bug.cgi?id=1530288
(cherry picked from commit 22f32a16f5)
2018-01-19 14:14:30 +01:00
Francesco Giudici
ba7c7c8402 team: merge branch 'fg/team_sys_prio_default-rh1533810'
https://bugzilla.redhat.com/show_bug.cgi?id=1533810

(cherry picked from commit 345d34b369)
2018-01-18 18:50:27 +01:00
Francesco Giudici
c34cd5e09a libnm-core: team: fix runner sys_prio default value
(cherry picked from commit 2c99eba42f)
2018-01-18 18:49:42 +01:00
Francesco Giudici
f219090fdd cli: get team defaults from setting header files
this allows centralizing default values definition and allows quicker
and safer update of default values.

(cherry picked from commit c6448f724b)
2018-01-18 18:49:28 +01:00
Beniamino Galvani
3c60d63540 device: increase carrier wait time to 6 seconds
Some NICs need longer to establish the link, increase the timeout from
5 to 6 seconds.

https://bugzilla.redhat.com/show_bug.cgi?id=1520826
(cherry picked from commit 156344b8be)
2018-01-18 15:29:24 +01:00
Lubomir Rintel
c778d9a252 ifcfg: don't forget master of ovs interfaces
https://bugzilla.redhat.com/show_bug.cgi?id=1519179
(cherry picked from commit 1440fe6a88)
2018-01-18 13:31:30 +01:00
Pavel Šimerda
a30b2fcd84 libnm: fix empty statements that were supposed to return NULL
Discovered thanks to `-Wunused-value` when building on openSUSE Leap 42.3.

(cherry picked from commit c4f655579c)
2018-01-17 19:21:10 +01:00
Lubomir Rintel
7ea865ef49 rpm: disable libnm-glib for Fedora 29 and RHEL 8
While at it, move the API documentation to libnm-devel.
There doesn't seem to be a better place for it.

(cherry picked from commit 8ba46ff4c6)
2018-01-16 17:26:15 +01:00
Lubomir Rintel
59e8eed447 build: don't install NetworkManager.pc when libnm-glib is disabled
(cherry picked from commit bfff3ecfb0)
2018-01-16 17:26:12 +01:00
Thomas Haller
c17315d555 platform: fix wrong cleanup function in ip_route_get()
Fixes: 33a2a7c3e3
(cherry picked from commit 3de3f59ffd)
2018-01-15 20:33:47 +01:00
Thomas Haller
55845e84da libnm/vpn: unexport and destroy D-Bus glue instance with NMVpnServicePlugin
Otherwise, we might still be called back with D-Bus requests, after
the NMVpnServicePlugin instance is already destroyed.

(cherry picked from commit 929f36c56f)
2018-01-15 14:45:02 +01:00
Francesco Giudici
bcababf612 libnm-core: docs update requires also settings-docs.c.in update
Fixes: c6e1b3abc0
2018-01-12 15:20:23 +01:00
Francesco Giudici
c6e1b3abc0 libnm-core: update team.runner description
https://bugzilla.redhat.com/show_bug.cgi?id=1533799
(cherry picked from commit 112f8bd5af)
2018-01-12 14:25:29 +01:00
Lubomir Rintel
78ef571972 secret-agent: construct the dbus proxy for async agent with the correct bus name
The asynchronous secret agent initialization doesn't work at all due to a
rather silly typo. Oops.

While at it, fix a whitespace error too.

(cherry picked from commit 603daa5b25)
2018-01-11 11:53:01 +01:00
Thomas Haller
8998ce629d dhcp: fix check for client-id in _set_client_id()
Fixes: 686afe531a
(cherry picked from commit 0e1fb1dbd2)
2018-01-09 15:56:20 +01:00
Lubomir Rintel
ccd98ba214 platform-linux: reload qdiscs and tfilters after removing them
Kernel (as of 4.14) merely ACKs our RTM_DELQDISC and RTM_DELTFILTER, not
bothering to signal the full RTM_DEL* message unless the removal is
external to NetworkManager.

https://bugzilla.redhat.com/show_bug.cgi?id=1527197
(cherry picked from commit f3b4053a91)
2018-01-08 17:51:54 +01:00
Thomas Haller
41a89aeeba dhcp: cleanup handling of ipv4.dhcp-client-id and avoid assertion failure
The internal client asserts that the length of the client ID is not more
than MAX_CLIENT_ID_LEN. Avoid that assert by truncating the string.

Also add new nm_dhcp_client_set_client_id_*() setters, that either
set the ID based on a string (in our common dhclient specific
format), or based on the binary data (as obtained from systemd client).

Also, add checks and assertions that the client ID which is
set via nm_dhcp_client_set_client_id() is always of length
of at least 2 (as required by rfc2132, section-9.14).

(cherry picked from commit 686afe531a)
2018-01-04 18:53:34 +01:00
Beniamino Galvani
207eb3266f all: add more meaningful error code for unsupported IP method
Add a new device state reason code for unsupported IP method. It is
returned, for example, when users select manual IP configuration for
WWAN connections:

 # nmcli connection mod Gsm ipv4.method manual ipv4.address 1.2.3.4/32
 # nmcli connection up Gsm
 Error: Connection activation failed: The selected IP method is not
 supported

compared to the old:

 Error: Connection activation failed: IP configuration could not be
 reserved (no available address, timeout, etc.)

Note that we could instead fail the connection validation if the
method is not supported by the connection type, but adding such
limitation now could make existing connections invalid.

https://bugzilla.redhat.com/show_bug.cgi?id=1459529
(cherry picked from commit aa820e9386)
2017-12-21 10:07:12 +01:00