Commit graph

24809 commits

Author SHA1 Message Date
Thomas Haller
78c4bc58c7 shared: use G_SOURCE_FUNC() macro in "shared/nm-test-utils-impl.c" 2020-01-13 15:46:04 +01:00
Thomas Haller
38323216f5 tui: fix signature for nmt_newt_form_keypress_callback() callback
Fixes: 3bda3fb60c ('nmtui: initial import of nmtui')
2020-01-13 15:46:04 +01:00
Thomas Haller
d63cd26e60 shared: improve nm_free_secret() to clear entire memory buffer
The purpose is to clear the entire available buffer, not only
up to the first '\0'. This is done, because otherwise we might
leak sensitive data that happens to be after the first '\0',
or we might give away the length of the secrets.

Of course, those are very (very) minor concerns. But avoiding them is
easy enough.
2020-01-09 17:45:01 +01:00
Yuri Chornoivan
1c7ea45aaa po: update Ukrainian (uk) translation
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/388
2020-01-09 14:09:20 +01:00
Thomas Haller
e1a76a201a license: add Beniamino Galvani to RELICENSE.md
https://mail.gnome.org/archives/networkmanager-list/2020-January/msg00011.html
2020-01-09 14:07:46 +01:00
Beniamino Galvani
3a9b069c41 n-dhcp4: use C_CLAMP() macro instead of c_clamp()
The latter requires __auto_type which is not available in GCC versions
older than 4.9. Fix the following compile error on RHEL 7.8:

 CC       src/src_libNetworkManagerBase_la-NetworkManagerUtils.lo
 shared/n-dhcp4/src/n-dhcp4-c-probe.c: In function 'n_dhcp4_client_probe_transition_nak':
 shared/n-dhcp4/src/n-dhcp4-c-probe.c:1008:17: error: unknown type name '__auto_type'
                  probe->ns_nak_restart_delay = c_clamp(probe->ns_nak_restart_delay * 2,
                  ^
 shared/n-dhcp4/src/n-dhcp4-c-probe.c:1008:17: error: unknown type name '__auto_type'
 shared/n-dhcp4/src/n-dhcp4-c-probe.c:1008:17: error: unknown type name '__auto_type'

Fixes: 218782a9a3 ('n-dhcp4: restart the transaction after a NAK')
2020-01-09 13:19:54 +01:00
Thomas Haller
d9451fcc0b license: add RELICENSE.md file to track consent/disapproval for relicensing under LGPL-2.1+ 2020-01-09 11:34:55 +01:00
Thomas Haller
5fc1b1a681 platform,device: merge branch 'th/device-ip-tunnel-mac'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/377
2020-01-09 10:42:45 +01:00
Thomas Haller
a90397b963 core: set MAC address for IP tunnels when creating device
There is however a serious issue currently: when NetworkManager creates
virtual devices, it starts from an unrealized NMDevice, creates the
netdev device, realizes the device, and transitions through states
UNMANAGED and DISCONNECTED. Thereby, the state of NMDevice gets cleared
again. That means, if the profile has "connection.stable-id=${RANDOM}"
and "ethernet.cloned-mac-address=stable", then we will first set a
random MAC address when creating the device. Then, the NMDevice
transitions through UNMANAGED state, forgets the MAC address it
generated and creates a new MAC address in stage 1. This should be
fixed by better handling unrealized devices. It also affects all
software devices that set the MAC address upon creation of the
interfaces (as they all should).
2020-01-09 10:42:32 +01:00
Thomas Haller
81d83b9e00 platform: support setting MAC address during nm_platform_link_gre_add()
We should set the MAC address of devices early on, and not later.
2020-01-09 10:42:32 +01:00
Thomas Haller
cb4093fc8f platform: drop NMPlatformLnkMacvtap typedef
In several cases, the layer 2 and layer 3 type are very similar, also from
kernel's point of view. For example, "gre"/"gretap" and "ip6tnl"/"ip6gre"/"ip6gretap"
and "macvlan"/"macvtap".

While it makes sense that these have different NMLinkType types
(NM_LINK_TYPE_MACV{LAN,TAP}) and different NMPObject types
(NMPObjectLnkMacv{lan,tap}), it makes less sense that they have
different NMPlatformLnk* structs.

Remove the NMPlatformLnkMacvtap typedef. A typedef does not make things simpler,
but is rather confusing. Because several API that we would usually have, does
not exist for the typedef (e.g. there is no nm_platform_lnk_macvtap_to_string()).

Note that we also don't have such a typedef for NMPlatformLnkIp6Tnl
and NMPlatformLnkGre, which has the same ambiguity between the link type
and the struct with the data.
2020-01-09 10:42:32 +01:00
Thomas Haller
f30ae56608 platform: implement link_macvlan_add via nm_platform_link_add() 2020-01-09 10:42:32 +01:00
Thomas Haller
1ffdca6331 platform: implement link_macsec_add via nm_platform_link_add() 2020-01-09 10:42:32 +01:00
Thomas Haller
14b5627633 platform: implement link_ipip_add via nm_platform_link_add() 2020-01-09 10:42:32 +01:00
Thomas Haller
16fd8ddf95 platform: implement link_ip6gre_add via nm_platform_link_add() 2020-01-09 10:42:31 +01:00
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