Commit Graph

24017 Commits

Author SHA1 Message Date
Lubomir Rintel
ad86ee4d48 wifi/olpc-mesh: drop assert(companion) from get_autoconnect_allowed()
The comment is wrong. Since 6eaded9071 ('device: add
get_autoconnect_allowed() virtual function'), get_autoconnect_allowed()
is called before the device state is consulted.
2019-09-07 17:22:00 +02:00
Lubomir Rintel
cc96771f32 wifi: add OLPC Mesh support via nl80211 2019-09-07 17:22:00 +02:00
Beniamino Galvani
11cf082a62 build: use regexp in gtkdoc --ignore-decorators option
gtkdoc-scan supports regular expressions in the --ignore-decorators
command-line option. Since it is easier to use a regexp than grepping
macros from a source file, revert the ugly solution from commit
2d941dc95a ('build: fix errors when building with gtk-doc 1.32').
2019-09-06 14:18:24 +02:00
Francesco Giudici
a0498e0829 meson: fix build_clean.sh -w meson -w test
Fixes: 2d941dc95a ('build: fix errors when building with gtk-doc 1.32')
2019-09-05 13:07:41 +02:00
Francesco Giudici
eb5bcb1ded dhcp: merge branch 'fg/nettools_persist_lease'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/246
2019-09-05 12:14:39 +02:00
Francesco Giudici
9f89516928 dhcp: nettools: read/write lease files
Use the same format of systemd-netword, so that we will be compatible
with the leases created/read by the current "internal" plugin.
Note that actually only the leased address is processed when reading a
lease file, so no need to save more than the ip address when saving the
lease.
2019-09-05 12:13:36 +02:00
Francesco Giudici
f60a60a0d0 dhcp: dhclient: use the shared function to retrieve the lease file path
... but leave in place the custom checks dependant on the dhclient plugin
2019-09-05 12:13:36 +02:00
Francesco Giudici
ee20761ea8 dhcp: prefer nm_assert() to g_assert*() 2019-09-05 12:13:36 +02:00
Francesco Giudici
89814d90aa dhcp: internal: use the shared function to retrieve the lease file path 2019-09-05 12:13:36 +02:00
Francesco Giudici
afb9bb0dac dhcp: add a shared function to retrieve the dhcp lease file
For each plugin we try to come up with a lease file constructed in the
same way, i.e., plugin name + iface + connection duid. If the file isn't
already there, for some plugins (dhclient) we do extra checks in order
to allow to use lease files generated outside of NetworkManager. Let's
allow to generate the common NetworkManager dhcp lease file name in a
shared function, reporting to the caller if the file isn't already there,
so that further plugin specific checks can be performed if needed.
2019-09-05 12:13:36 +02:00
Beniamino Galvani
2ca8b511e6 core: add audit log for the SaveHostname call
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/260
2019-09-05 11:42:01 +02:00
Beniamino Galvani
4bd192a350 core: add defines for common authentication-related error messages
All D-Bus method call implementations use similar error messages when
authenticating requests; add defines for them to ensure the same exact
message is reused.
2019-09-05 11:41:57 +02:00
Beniamino Galvani
2d941dc95a build: fix errors when building with gtk-doc 1.32
gtkdoc-scan 1.32 performs stricter checks on structures definitions
and so it complains on:

 /build/networkmanager/src/NetworkManager/libnm/./nm-vpn-plugin-old.h:0: warning: partial declaration (struct) : typedef struct {
 	NM_DEPRECATED_IN_1_2
 	GObject parent;
 } NMVpnPluginOld NM_DEPRECATED_IN_1_2;

because of the unrecognized token 'NM_DEPRECATED_IN_1_2'.

Pass all allowed macros to gtkdoc-scan through the --ignore-decorators
argument.

https://gitlab.gnome.org/GNOME/gtk-doc/issues/98
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/238
2019-09-05 11:17:54 +02:00
Thomas Haller
de6f0bc6db core/tests: avoid deprecated g_main_run()/g_main_loop_unref() in test
These are deprecated. Also, they are nowadays implemented as macros
that expand to

  #define g_main_run(loop) g_main_loop_run(loop) GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_main_loop_run)

This can cause compilation failure (in some environments).
2019-09-03 18:13:27 +02:00
Beniamino Galvani
dbfbbed53c core: merge branch 'bg/device-realize-failed-rh1686634'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/252
https://bugzilla.redhat.com/show_bug.cgi?id=1686634
2019-09-03 16:53:15 +02:00
Beniamino Galvani
f07aa329b2 manager: keep device if realize() fails
system_create_virtual_device() first creates the device (unrealized)
and then, if there a connection for the device with autoconnect=yes,
creates the backing resources. If this last step fails the device
should continue to exist, even if in an unrealized state.

https://bugzilla.redhat.com/show_bug.cgi?id=1686634
2019-09-03 16:53:04 +02:00
Beniamino Galvani
4bc4156424 device: don't set nm-owned flag if realize() fails
The nm-owned flag indicates whether the device was created by NM. If
the realization step fails, the device was not created and so nm-owned
should not be updated.
2019-09-03 16:53:04 +02:00
Davide Palma
6a7c2d44ae po: fixed typo in it.po
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/259
2019-09-03 16:04:03 +02:00
Lubomir Rintel
4534c6c366 core: fix a typo
s/grater/greater/
2019-09-03 11:43:56 +02:00
Beniamino Galvani
eec6951949 device: fix crash when master connection fails
When the master AC becomes ready, activate_stage1_device_prepare() is
called in a idle handler. If the master AC fails in the meantime, it
will change state to deactivating or deactivated. We must check for
that condition before proceeding with slave activation. Note the the
'master_ready' flag of an AC is never cleared after it is set.

Fixes: 5b677d5a3b ('device: move check for master from nm_device_activate_schedule_stage2_device_config() to end of stage1')

https://bugzilla.redhat.com/show_bug.cgi?id=1747998
2019-09-03 09:00:44 +02:00
Lubomir Rintel
74a7626940 libnm/remote-connection: add a pair of curly brackets
...to aid readability.
2019-09-02 14:58:43 +02:00
Lubomir Rintel
b76da15dbf clients: avoid clearing a structure pointer when we're still using it
We're dereferencing the info pointer in the argument list in the call to
nm_client_activate_connection_async(). Stealing it at that point causes
a crash.

This reverts a chunk of commit b298f2e605 ('cli: use cleanup macro for
freeing AddAndActivateInfo').
2019-09-02 14:58:43 +02:00
Thomas Haller
576a128954 keyfile: reorder printing empty [wireguard] section with peers and fix test failure
We want to print the [wireguard] section before printing sections of the
peers. It just looks nicer.

This also fixes a test failure:

  /libnm/settings/roundtrip-conversion/wireguard/2: **
  test:ERROR:./shared/nm-utils/nm-test-utils.h:2254:nmtst_keyfile_assert_data: assertion failed (d1 == data): ("[connection]\nid=roundtrip-conversion-2\nuuid=63376701-b61e-4318-bf7e-664a1c1eeaab\ntype=wireguard\ninterface-name=ifname2\npermissions=\n\n[wireguard-peer.uoGoXWWRxJvu4jDva8pPGA4nxau8B33S+YR+MfPFjxc=]\nendpoint=192.168.255.180:30429\npreshared-key-flags=2\n\n[wireguard-peer.BED73rH9j3OCHYAeXNrW5y5oia/Ngj+M04e9sG7DQOo=]\nendpoint=192.168.188.253:30407\npreshared-key-flags=1\npersistent-keepalive=5070\nallowed-ips=192.168.215.179/32;192.168.120.249/32;a🅱️c::e4:13/128;192.168.157.84/32;a🅱️c::1b:df/128;a🅱️c::b0:84/128;192.168.168.17/32;\n\n[wireguard]\n\n[ipv4]\ndns-search=\nmethod=disabled\n\n[ipv6]\naddr-gen-mode=stable-privacy\ndns-search=\nmethod=ignore\n\n[proxy]\n" == "[connection]\nid=roundtrip-conversion-2\nuuid=63376701-b61e-4318-bf7e-664a1c1eeaab\ntype=wireguard\ninterface-name=ifname2\npermissions=\n\n[wireguard]\n\n[wireguard-peer.uoGoXWWRxJvu4jDva8pPGA4nxau8B33S+YR+MfPFjxc=]\nendpoint=192.168.255.180:30429\npreshared-key-flags=2\n\n[wireguard-peer.BED73rH9j3OCHYAeXNrW5y5oia/Ngj+M04e9sG7DQOo=]\nendpoint=192.168.188.253:30407\npreshared-key-flags=1\npersistent-keepalive=5070\nallowed-ips=192.168.215.179/32;192.168.120.249/32;a🅱️c::e4:13/128;192.168.157.84/32;a🅱️c::1b:df/128;a🅱️c::b0:84/128;192.168.168.17/32;\n\n[ipv4]\ndns-search=\nmethod=disabled\n\n[ipv6]\naddr-gen-mode=stable-privacy\ndns-search=\nmethod=ignore\n\n[proxy]\n")

Fixes: ddd148e02b ('keyfile: let keyfile writer serialize setting with all default values')
2019-09-02 13:18:22 +02:00
Beniamino Galvani
6cf28fe2c0 merge: branch 'bg/ipv6-accept-ra-rh1734470'
https://bugzilla.redhat.com/show_bug.cgi?id=1734470

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/247
2019-08-30 10:24:07 +02:00
Beniamino Galvani
5a534529e2 ipv6: disable kernel handling of RAs (accept_ra)
With accept_ra set to 1, kernel sends its own router solicitation
messages and parses the advertisements. This duplicates what NM
already does in userspace and has unwanted consequences like [1] and
[2].

The only reason why accept_ra was re-enabled in the past was to apply
RA parameters like ReachableTime and RetransTimer [3]; but now NM
supports them and so accept_ra can be turned off again.

Also, note that previously the option was set in
addrconf6_start_with_link_ready(), and so this was done only when the
method was 'auto'. Instead, now we clear it for all methods except
'ignore'.

[1] https://mail.gnome.org/archives/networkmanager-list/2019-June/msg00027.html
[2] https://bugzilla.redhat.com/show_bug.cgi?id=1734470
[3] https://bugzilla.redhat.com/show_bug.cgi?id=1068673
2019-08-30 09:53:04 +02:00
Beniamino Galvani
5f0c6f8d3b ipv6: set neighbor parameters from RAs
IPv6 router advertisement messages contain the following parameters
(RFC 4861):

 - Reachable time: 32-bit unsigned integer.  The time, in
   milliseconds, that a node assumes a neighbor is reachable after
   having received a reachability confirmation.  Used by the Neighbor
   Unreachability Detection algorithm.  A value of zero means
   unspecified (by this router).

 - Retrans Timer: 32-bit unsigned integer.  The time, in milliseconds,
   between retransmitted Neighbor Solicitation messages.  Used by
   address resolution and the Neighbor Unreachability Detection
   algorithm.   A value of zero means unspecified (by this router).

Currently NM ignores them; however, since it leaves accept_ra=1, the
kernel parses RAs and applies those parameters for us [1].

In the next commit kernel handling of RAs will be disabled, so let NM
set those neighbor-related parameters.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/net/ipv6/ndisc.c?h=v5.2#n1353
2019-08-30 09:53:04 +02:00
Beniamino Galvani
c0a825bc8e dhcp: fall back to 'internal' client for IPv6 when using 'nettools'
The 'nettools' client doesn't support IPv6, fall back to 'internal'.
2019-08-29 09:39:42 +02:00
Thomas Haller
397b05e8ba device: merge branch 'th/act-stage1-re-entrant'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/245
2019-08-28 16:27:16 +02:00
Thomas Haller
79952b6296 device: after stage1 call stage2 synchronously
We know we are ready and in a situation where we can handle state changes.
Don't schedule stage2 in an idle handler, just invoke it directly.
2019-08-28 16:27:00 +02:00
Thomas Haller
5b677d5a3b device: move check for master from nm_device_activate_schedule_stage2_device_config() to end of stage1
Note that by now no callers of nm_device_activate_schedule_stage2_device_config()
are left. All previous callers now re-schedule stage1 instead of directly
scheduling stage2.
Note that if stage2 later also gets re-factored to re-enter itself
instead of scheduling stage3 right away, the function will be used
again.

That means, we can move the check for the master where it belongs: as
part (and at the end of) stage1.

Also, slightly simplify the code. The handler master_ready_cb()
no longer directly calls master_ready(). It's enough to always
enter stage1 again.

Also drop master_ready_handled. We don't need to remember that this
condition was satsified. We can just check it always when we reach
the place in activate_stage1_device_prepare().
2019-08-28 16:27:00 +02:00
Thomas Haller
29562a9751 device: let devices call stage1 again after being ready to proceed
I am about to change the when stage1 gets postponed, then the way to
proceed it is to schedule stage1 again (instead of scheduling stage2).

The reason is that stage1 handling should be reentrant and we should
keep entering it until there is no more reason to postpone it. If
a subclass postpones stage1 and then later progresses it by directly
scheduling stage2, then only the subclass is in control over postponing
stage 2.

Instead, anybody should be able to delay stage2 independently. That can
only work if everybody signals readyness to proceed by scheduling stage1
again.
2019-08-28 16:27:00 +02:00
Thomas Haller
86f8f5a71c device/wifi-p2p: inline and drop local function cleanup_p2p_connect_attempt()
It has only one caller. It's clearer to do the cleanup right there.
2019-08-28 16:27:00 +02:00
Thomas Haller
51ddbda5d2 device/team: don't remember connection while killing team
We don't need this. The applied-connection is already remembered
and suitable.
2019-08-28 16:27:00 +02:00
Thomas Haller
efa3b5b443 device/team: various cleanups 2019-08-28 16:27:00 +02:00
Thomas Haller
34895adcc4 device: set failure reason when settings hardware address fails 2019-08-28 16:27:00 +02:00
Thomas Haller
e034cc3264 device: let NMDevice set hardware address instead of act_stage1_prepare() for NMDeviceEthernet
There is a small change in the order of actions. Now we set the MAC address before
calling link_negotiation_set(). That shouldn't make a difference.
2019-08-28 16:27:00 +02:00
Thomas Haller
2d40b7ba61 device: let NMDevice set hardware address instead of act_stage1_prepare() 2019-08-28 16:27:00 +02:00
Thomas Haller
de439148dd device: move redundant act_stage1_prepare() implementations to set hwaddr to NMDevice
This is so common, that NMDevice can handle it for us.
2019-08-28 16:27:00 +02:00
Thomas Haller
dc27512184 device: don't let subclasses call NMDevice's act_stage1_prepare()
NMDevice's act_stage1_prepare() now does nothing. Calling it is not
useful and has no effect.

In general, when a subclass overwrites a virtual function, it must be
defined whether the subclass must, may or must-not call the parents
implementation. Likewise, it must be clear when the parents
implementation should be chained: first, as last, does it matter?
In any case, that very much depends on how the parent is implemented
and this can only be solved by documentation and common conventions.

It's a forgiving approach to have a parents implementation do nothing,
then the subclass may call it at any time (or not call it at all).
This is especially useful if classes don't know their parent class well.
But in NetworkManager code the relationship between classes are known
at compile time, so every of these classes knows it derives directly
from NMDevice.

This forgingin approach was what NMDevice's act_stage1_prepare() was doing.
However, it also adds lines of code resulting in a different kind of complexity.
So, it's not clear that this forgiving approach is really better. Note
that it also has a (tiny) runtime and code-size overhead.

Change the expectation of how NMDevice's act_stage1_prepare() should be
called: it is no longer implemented, and subclasses *MUST* not chain up.
2019-08-28 16:27:00 +02:00
Thomas Haller
cca0c2b56a device: move SR-IOV initialization to activate_stage1_device_prepare()
Note that all subclasses of NMDevice that implement act_stage1_prepare(), call
the parents implementation as very first thing.

Previously, NMDevice's act_stage1_prepare() was setting up SR-IOV. But that is
problemantic. Note that it may have returned NM_ACT_STAGE_RETURN_POSTPONE, in which
case subclasses would just skip their action and return to the caller. Later,
sriov_params_cb() would directly call nm_device_activate_schedule_stage2_device_config(),
and thus act_stage1_prepare() was never executed for the subclass. That
is wrong.

First, I don't think it is good to let subclasses decide whether to call a
parents implementation (and when). It just causes ambiguity. In
the best case we do it always in the same order, in the worst case we
call the parent at the wrong time or never. Instead, we want to initialize
SR-IOV always and early in stage1, so we should just do it directly from
activate_stage1_device_prepare(). Now NMDevice's act_stage1_prepare() does
nothing.

The bigger problem is that when a device wants to resume a stage that
it previously postponed, that it would schedule the next stage!
Instead, it should schedule the same stage again instead. That allows
to postpone the completion of a stage for multiple reasons, and each
call to a certain stage merely notifies that something changed and
we need to check whether we can now complete the stage.

For that to work, stages must become re-entrant. That means we need to
remember whether an action that we care about needs to be started, is pending
or already completed.

Compare this to nm_device_activate_schedule_stage3_ip_config_start(),
which checks whether firewall is configured. That is likewise the wrong
approach. Callers that were in stage2 and postponed stage2, and later would
schedule stage3 when they are ready.
Then nm_device_activate_schedule_stage3_ip_config_start() would check whether
firewall is also ready, and do nothing if that's not the case (relying
that when the firewall code completes to call
nm_device_activate_schedule_stage3_ip_config_start().
2019-08-28 16:27:00 +02:00
Thomas Haller
c3d41fa452 device: refactor handling of scheduled activation tasks on idle
- use a [2] array for IPv4/IPv6 variants and a IS_IPv4 variable,
  like we do for other places that have similar implementations for
  both address families.

- drop ActivationHandleData and use the fields directly. Also drop
  activation_source_get_by_family().

- rename "act_handle*" field to "activation_source_*", to follow the
  naming of the related accessor functions.

- downgrade the severity of some logging messages.
2019-08-28 16:27:00 +02:00
Thomas Haller
f42ced162f device/trivial: rename local variable for device in "nm-device-{ethernet,macvlan}.c"
This variable is commonly called "device", not "dev". Rename.
2019-08-28 16:27:00 +02:00
Thomas Haller
7fd50f2789 device: various minor style cleanup 2019-08-28 16:27:00 +02:00
Thomas Haller
7bf8c45b19 device/wifi: cleanup supplicant_iface_wps_credentials_cb()
Restructure code to return early and free resources with nm_auto.
2019-08-28 16:27:00 +02:00
Thomas Haller
81816ebffa device/wifi: various cleanup in act_stage1_prepare()
The only change in behavior is in act_stage1_prepare().

That changes compared to before that we also set the specific
object path if it was already set (and we looked up the AP by
specific object to start with).

Also, for existing APs that we found with nm_wifi_aps_find_first_compatible(),
it changes the order of calling set_current_ap() before nm_active_connection_set_specific_object().

That should not make a different though. I anyway wonder why we even bother to
set the specific object on the AC. Maybe that should be revisited.
2019-08-28 16:27:00 +02:00
Thomas Haller
1f7e0f1d1f device/wifi-p2p: make act_stage1_prepare() re-entrant
Don't clear and reschedule finding of p2p peer if called multiple
times during (the same) activation.
2019-08-28 16:27:00 +02:00
Thomas Haller
df086f5366 device/wpan: cleanup act_stage1_prepare() and don't assert with missing hwaddr 2019-08-28 16:27:00 +02:00
Thomas Haller
cc4d69c1c3 device/wireguard: drop act_stage1_prepare() implementation
act_stage1_prepare() should become re-entrant. That means, we should not clear the state
there. Instead, we clear it where necessary or on deactivate (which we do already).
2019-08-28 16:27:00 +02:00
Thomas Haller
2d42c1b102 device/ethernet: make NMDeviceEthernet.act_stage1_prepare() reentrant and minor cleanups 2019-08-28 16:27:00 +02:00
Thomas Haller
f0775963c2 device/bridge: minor cleanup in NMDeviceBridge's act_stage1_prepare()
Only reset "vlan_configured" when deactivating. stage1() should be
re-entrant.
2019-08-28 16:27:00 +02:00