Commit Graph

25044 Commits

Author SHA1 Message Date
Thomas Haller
bfd74974dc platform: implement link_ip6tnl_add via nm_platform_link_add() 2020-01-09 10:42:31 +01:00
Thomas Haller
8b417300ca platform: implement link_6lowpan_add via nm_platform_link_add() 2020-01-09 10:42:31 +01:00
Thomas Haller
d3963e4ac7 platform: implement link_vxlan_add via nm_platform_link_add() 2020-01-09 10:42:31 +01:00
Thomas Haller
62b9d8ee33 platform: implement link_vlan_add via nm_platform_link_add() 2020-01-09 10:42:31 +01:00
Thomas Haller
4029f9cd2e platform: implement link_sit_add via nm_platform_link_add() 2020-01-09 10:42:31 +01:00
Thomas Haller
385764398e platform: implement link_gre_add via nm_platform_link_add() 2020-01-09 10:42:31 +01:00
Thomas Haller
792118558c platform: add parent argument to nm_platform_link_add()
This is to set the IFLA_LINK parameter.
2020-01-09 10:42:31 +01:00
Thomas Haller
9763d9f8a9 platform: move special link-add functions to header
These are thin abstractions over nm_platform_link_add(). Move them to
the header.
2020-01-09 10:42:31 +01:00
Thomas Haller
4a743aba65 platform: extend nm_platform_link_add() to accept type specific extra parameter
This will be used to unify all link-add implementation.
2020-01-09 10:42:31 +01:00
Thomas Haller
6e8653eb5b platform: log name of link that gets added by nm_platform_link_add() 2020-01-09 10:42:31 +01:00
Thomas Haller
6ccd88a286 device: avoid assertion failure when setting MAC address of unexpected address length
IP tunnels honor ethernet.cloned-mac-address. That is a MAC address of 6 bytes (ETH_ALEN).
Note that for example for gre tunnels, kernel exposes an address 00:00:00:00. Hence, trying
to set ethernet.cloned-mac-address with an gre tunnel leads to an assertion failure.

Instead, report and log a regular error.
2020-01-09 10:42:31 +01:00
Beniamino Galvani
7129e669c0 dhcp: merge branch 'bg/nettools-fixes-pt2'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/387
2020-01-09 09:43:37 +01:00
Beniamino Galvani
2523000b36 dhcp: nettools: handle 'retracted' event as 'expired'
The 'retracted' event is emitted when the client receives a NAK in the
rebooting, requesting, renewing or rebinding state, while 'expired'
means that the client wasn't able to renew the lease before expiry.

In both cases the old lease is no longer valid and n-dhcp4 keep trying
to get a lease, so the two events should be handlded in the same way.

Note that the systemd client doesn't have a 'retracted' event and
considers all NAKs as 'expired' events.
2020-01-09 09:04:08 +01:00
Beniamino Galvani
218782a9a3 n-dhcp4: restart the transaction after a NAK
It is not enough to set the INIT state after a NAK; a timeout
(ns_deferred) must be set so that it is added to the event fd. The
client retries immediately the first time, so that in the successful
case it gets an address quickly. To avoid flooding the network in case
of servers always replying with NAKs, next attempts are done with
intervals from 2 seconds to 5 minutes using exponential backoff. See
also systemd commit [1].

[1] 1d1a3e0afb

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/325
2020-01-09 09:04:08 +01:00
Beniamino Galvani
4bcdc3c1eb n-dhcp4: allow calling listen() on already listening connection
When the client enters the INIT state, it calls listen() on the
connection connection to create the packet socket. However, if the
client is coming from the REBOOTING state after a NAK, the connection
is already in the listening state; do nothing in such case.
2020-01-09 09:04:08 +01:00
Thomas Haller
900af25263 client: add nm_client_get_object_by_path() and nm_object_get_client() API
When iterating the GMainContext of the NMClient instance, D-Bus events
get processed. That means, every time you iterate the context (or "return to
the main loop"), the content of the cache might change completely.

It makes sense to keep a reference to an NMObject instance, do something,
and afterwards check whether the instance can still be found in the cache.

Add an API for that. nm_object_get_client() allows to know whether the
object is still cached.

Likewise, while NMClient abstracts D-Bus, it should still provide a way
to look up an NMObject by D-Bus path. Add nm_client_get_object_by_path()
for that.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/384
2020-01-08 18:33:10 +01:00
Thomas Haller
5080dfa46f wifi: merge branch 'th/ssids-options-to-ptrarray'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/385
2020-01-08 12:14:51 +01:00
Thomas Haller
e6d256fe81 device/wifi: cleanup ssids_options_to_ptrarray()
- use proper gsize type to hold g_variant_n_children()

- use cleanup attribute for GPtrArray

- move variables inside nested scope where they are used
2020-01-08 11:23:24 +01:00
Thomas Haller
023dc9646c wifi/tests: add test for ssids_options_to_ptrarray() 2020-01-08 11:23:24 +01:00
Thomas Haller
7d8da6c9c1 build: build intermediate library with core wifi for device-plugin and tests
Don't build the same sources multiple times. The test code should
statically link against the tested code, just like the device plugin
that uses the code in production.
2020-01-08 11:23:24 +01:00
Thomas Haller
5ed1edc02a device/wifi: fix memleak parsing SSID arguments for "RequestScan"
Oddly enough, valgrind was not complaining about this leak...

Fixes: 87b2d783b6 ('core: accept 'ssids':aay option in RequestScan() dictionary parameter')
2020-01-08 10:29:04 +01:00
Thomas Haller
6da9e06508 libnm: merge branch 'th/utils-security-valid'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/382
2020-01-08 10:14:15 +01:00
Thomas Haller
4e9119c52e libnm: let nm_utils_security_valid() reject TKIP with SAE (WPA3)
SAE should always use CCMP.
2020-01-08 09:47:57 +01:00
Thomas Haller
31aac7a9d8 libnm: let nm_utils_security_valid() reject adhoc mode with SAE 2020-01-08 09:47:57 +01:00
Thomas Haller
3d20c9985d libnm: avoid deep nesting in checks of nm_utils_security_valid() 2020-01-08 09:47:57 +01:00
Thomas Haller
e9d4980d6b libnm: cleanup conditions by moving pre-check in nm_utils_security_valid()
Do the switch based on the type on the top level, don't split the
conditions to first handle some cases, and some later.
2020-01-08 09:47:57 +01:00
Thomas Haller
936bb8716b libnm: break lines in conditions of nm_utils_security_valid() 2020-01-08 09:47:57 +01:00
Thomas Haller
2e72403cb7 libnm: add missing braces to multi-line condition in nm_utils_security_valid() 2020-01-08 09:47:57 +01:00
Thomas Haller
cffe3a3ef6 libnm: return early from nm_utils_security_valid()
Once we know the outcome of the check, just return it instead of
falling though to return a variable "good" which was initialized
two pages earlier.

Also, avoid the "default" switch case. This way, we get a compiler
warning about missing enum values.
2020-01-08 09:47:57 +01:00
Antonio Cardace
fa144b5ae9 platform/linux: add support for /31 prefixes on IPv4 point-to-point links
Previously NetworkManager would wrongly add a broadcast address for the
network prefix that would collide with the IP address of the host on
the other end of the point-to-point link thus exhausting the IP address
space of the /31 network and preventing communication between the two
nodes.

Configuring a /31 address before this commit:
	IP addr -> 10.0.0.0/31, broadcast addr -> 10.0.0.1

If 10.0.0.1 is configured as a broadcast address the communication
with host 10.0.0.1 will not be able to take place.

Configuring a /31 address after this commit:
	IP addr -> 10.0.0.0/31, no broadcast address

Thus 10.0.0.0/31 and 10.0.0.1/31 are able to correctly communicate.

See RFC-3021. https://tools.ietf.org/html/rfc3021

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/295

https://bugzilla.redhat.com/show_bug.cgi?id=1764986
2020-01-07 16:52:18 +01:00
Thomas Haller
d964decbbd libnm/keyfile: build keyfile code as separate GPL licensed internal library
Keyfile support was initially added under GPL-2.0+ license as part of
core. It was moved to "libnm-core" in commit 59eb5312a5 ('keyfile: merge
branch 'th/libnm-keyfile-bgo744699'').

"libnm-core" is statically linked with by core and "libnm". In
the former case under terms of GPL-2.0+ (good) and in the latter case
under terms of LGPL-2.1+ (bad).

In fact, to this day, "libnm" doesn't actually use the code. The linker
will probably remove all the GPL-2.0+ symbols when compiled with
gc-sections or LTO. Still, linking them together in the first place
makes "libnm" only available under GPL code (despite the code
not actually being used).

Instead, move the GPL code to a separate static library
"shared/nm-keyfile/libnm-keyfile.la" and only link it to the part
that actually uses the code (and which is GPL licensed too).

This fixes the license violation.

Eventually, it would be very useful to be able to expose keyfile
handling via "libnm". However that is not straight forward due to the
licensing conflict.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/381
2020-01-07 13:17:47 +01:00
Andika Triwidada
7bbccab4f2 po: update Indonesian (id) translation
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/376
2020-01-01 13:35:44 +01:00
Thomas Haller
e055bdbbc3 agent-manager: merge branch 'th/agent-manager-cleanup'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/374
2019-12-31 02:18:07 +01:00
Thomas Haller
bf25081dfe agent-manager: fix races registering secret agent and track auth-chain per agent
We don't need a separate "GSList *chains" to track the NMAuthChain
requests for the agents. Every agent should only have one auth-chain in
fly at any time. We can attach that NMAuthChain to the secret-agent.

Also, fix a race where:

  1) A secret agent registers. We would start an auth-chain check, but not
    yet track the secret agent.
  2) Then the secret agent unregisters. The unregistration request will fail,
    because the secret agent is not yet in the list of fully registered agents.
    The same happens if the secret agent disconnects at this point.
    agent_disconnect_cb() would not find the secret agent to remove.
  3) afterwards, authentication completes and we register the
    secret-agent, although we should not.

There is also another race: if we get authority_changed_cb() we would
not restart the authentication for the secret-agent that is still
registering. Hence, we don't know whether the result once it completes
would already contain the latest state.
2019-12-31 02:13:45 +01:00
Thomas Haller
9bdf95458e agent-manager: move and inline _agent_remove_by_owner() to impl_agent_manager_unregister() 2019-12-31 02:13:45 +01:00
Thomas Haller
ed85842c36 agent-manager: disconnect agent_disconnected_cb handler from secret-agent
Also, we don't need to use _agent_remove_by_owner(). We know now
the agent to be removed.
2019-12-31 02:13:45 +01:00
Thomas Haller
821efd87d8 agent-manager: pass agent-manager to maybe_remove_agent_on_error() and don't lookup by name
Don't access the singleton getter here. Pass the agent-manager argument
instead to maybe_remove_agent_on_error().

Also, don't lookup the agent by name. We already know, whether the agent
is still tracked or not. Look at agent->agent_lst.
2019-12-31 02:13:45 +01:00
Thomas Haller
d4a821d53e agent-manager: let nm_settings_connection_check_permission() check all secret-agents searching for permission
nm_agent_manager_get_agent_by_user() would only return the first
matching secret agent for the user. This way, we might miss an agent
that has permissions.

Instead, add nm_agent_manager_has_agent_with_permission() and search
all agents.
2019-12-31 02:13:45 +01:00
Thomas Haller
3e0094af77 agent-manager: track secret agents with CList instead of hash table
There was literally only one place where we would make use of
O(1) lookup of secret-agents: during removal.

In all other cases (which are the common cases) we had to iterate the
known agents. CList is more efficient and more convenient to use when
the main mode of operation is iterating.

Also note that handling secret agents inevitably scales linear with
the number of agents. That is, because for every check we will have
to sort the list of agents and send requests to them. It would be
very complicated (and probably less efficient for reasonable numbers
of secret agents) to avoid O(n).
2019-12-31 02:13:45 +01:00
Thomas Haller
86ba66ee9b agent-manager: expose NMSecretAgent struct in header for tight coupling with NMAgentManager
NMAgentManager and NMSecretAgent work closely together. In particular,
the NMAgentManager creates and tracks the NMSecretAgents and controls
it.

Move NMSecretAgent struct to the header, so that some fields may become
accessible to NMAgentManager. In particular, we will track secret agents
with a CList, and this CList element can be embedded in the
NMSecretAgent structure.
2019-12-31 02:13:45 +01:00
Thomas Haller
0f32326257 agent-manager/trivial: rename CList fields to track Request instances 2019-12-31 02:13:45 +01:00
Thomas Haller
eba629fb07 agent-manager: don't handle failure of nm_secret_agent_new() in agent_manager_register_with_capabilities()
This never fails. There is no need to handle an "error".
2019-12-31 02:13:45 +01:00
Thomas Haller
2dcd9fa836 agent-manager: use cleanup macro for subject in agent_manager_register_with_capabilities()
More cleanup macros.
2019-12-31 02:13:45 +01:00
Thomas Haller
b32d656d26 agent-manager: drop unused error handling in agent_manager_register_with_capabilities()
nm_auth_chain_new_subject() cannot fail.
2019-12-31 02:13:45 +01:00
Thomas Haller
89bfb64af5 auth-chain: add nm_auth_chain_get_context() accessor
Will be used later. Also rename "struct NMAuthChain" to "struct _NMAuthChain".
It follows how we commonly name this kind of struct.
2019-12-31 02:13:45 +01:00
Thomas Haller
cb7cfc3f12 shared: don't allow NULL arguments with g_hash_table_steal_extended() compat implementation
We cannot know the key/value free functions, hence, our compat implementation
cannot free the values if they are not requested. The "solution" is to require
the caller to fetch all values, always.
2019-12-31 02:13:45 +01:00
Thomas Haller
7d5d7c6d59 libnm: sort settings when constructing GVariant for connection 2019-12-28 22:23:25 +01:00
Thomas Haller
655e1aa97f man: document connectivity.enabled option in NetworkManager.conf manual 2019-12-28 15:20:06 +01:00
Thomas Haller
72e025c33e libnm: move nm_client_get_capabilities() to separate linker version
nm_client_get_capabilities() was backported to 1.22.2. Add to to the
appropriate linker version.

Officially (and according to docs) nm_client_get_capabilities() still
appears first in libnm 1.24.0. However, as it got backported to 1.22.2,
it needs to be part of a different symbol version on 1.22. Instead
of adding the symbol twice (once for libnm_1_24_0 and libnm_1_22_2),
move it only to the libnm_1_22_2 symbol version, also on master.
2019-12-24 14:47:27 +01:00
Antonio Cardace
34514b6294 clients/polkit: signal error when polkit setuid helper cannot be spawned
Also the child fds are set to -1 so that nm_close() doesn't throw an assertion.

Fixes: df1d214b2 (clients: polkit-agent: implement polkit agent without using libpolkit)
2019-12-24 13:39:54 +01:00