Commit Graph

27030 Commits

Author SHA1 Message Date
Thomas Haller
b2780ffa72 libnm: cleanup constructing GVariants for IP addresses 2020-10-30 11:58:45 +01:00
Thomas Haller
11fc851741 libnm: cleanup signedness and range of intergers in "nm-utils.c" 2020-10-30 11:58:45 +01:00
Thomas Haller
a7e1fa48fd shared: add nm_g_variant_new_ay_inaddr() helper 2020-10-30 11:58:44 +01:00
Beniamino Galvani
f70ee67058 dns: sd-resolved: reset interface configuration on deactivation
If an update doesn't contain an interface but the previous update did,
the systemd-resolved DNS plugin must send a request to clear the
previous configuration. Otherwise the previous DNS configuration would
persist even after interface deactivation.

https://bugzilla.redhat.com/show_bug.cgi?id=1888229
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/662
2020-10-29 17:23:28 +01:00
Thomas Haller
545d5a4e70 python,tests: merge branch 'fmartinsons:master' (#661)
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/661
2020-10-29 09:36:46 +01:00
Frederic Martinsons
1f5c7f7d81 Correct python black rules
Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
2020-10-29 09:35:10 +01:00
Frederic Martinsons
c8b13dc92f Manage deactivation of active connection
Like what was done for activating an active connection, so
some state change are simulated and a dbus test method is added

Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
2020-10-29 09:35:10 +01:00
Frederic Martinsons
51dd9ed89a Enhance device state and active connection management
Add reason for device state change.
Add dbus test method to force failure of activation, set the
device state and the active connection state.

Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
2020-10-29 09:35:10 +01:00
Frederic Martinsons
a3f596e273 Add basic modem device support
The modem device will have hardcoded capability which make it
compatible with GSM connection settings.
It will be seen with hardcoded ModemManager manager dbus object path
for the UDI property.
Add also a dbus test method to add the modem device.

Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
2020-10-29 09:35:06 +01:00
Frederic Martinsons
f225148754 Initialize correctly _dbus_error_name in BusErr classes
To be consistent with dbus.DbusException classes which do the
following in __init__:

    def __init__(self, *args, **kwargs):
        name = kwargs.pop('name', None)
        if name is not None or getattr(self, '_dbus_error_name', None) is None:
            self._dbus_error_name = name
        if kwargs:
            raise TypeError('DBusException does not take keyword arguments: %s'
                            % ', '.join(kwargs.keys()))
        Exception.__init__(self, *args)

Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
2020-10-29 09:35:06 +01:00
Frederic Martinsons
7bc01ea14c Add dbus.Int32 support for variant parsing
Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
2020-10-29 09:35:06 +01:00
Thomas Haller
7616469df8 libnm/keyfile: merge branch 'th/keyfile-public-api'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/517
2020-10-29 09:28:27 +01:00
Thomas Haller
a9e6774670 example: add python gi example for keyfile handling 2020-10-28 14:30:49 +01:00
Thomas Haller
157d7bd5b9 keyfile: expose keyfile handling in libnm as public API 2020-10-28 14:30:49 +01:00
Thomas Haller
49fd96bf01 libnm: add "nm-keyfile.h" header
Keyfile API will become part of public libnm API. Add "nm-keyfile.h"
header for that.
2020-10-28 14:30:48 +01:00
Thomas Haller
ed82bbe986 core: use nm_clear_pointer() instead of g_clear_pointer()
Our macro is more type-safe than glib's, because it does
not C cast the arguments. It seems preferable in general.
2020-10-28 13:59:22 +01:00
Thomas Haller
817ea086ee l3cfg: merge branch 'th/l3cfg-14'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/660
2020-10-28 12:10:40 +01:00
Thomas Haller
33041e04af core: use nm_utils_share_rules_add_all_rules() from NMDevice 2020-10-27 17:40:20 +01:00
Thomas Haller
be7bf38a3a core: add nm_utils_share_rules_add_all_rules() for constructing iptables rules 2020-10-27 17:40:19 +01:00
Thomas Haller
701654b930 core: refactor tracking of shared-rules to use NMUtilsShareRules
It's a bit ugly that NMActRequest also tracks the shared rules.
Why? It's just some additional state (the rules) and some additional
actions that should be done when activating/deactivating the profile.
NMActRequest also doesn't track the NMDhcpClient, so why these shared
rules?

Also, removing the rules from an object destructor is ugly. NMActRequest
is a GObject and ref-counted. We should not make assumptions when the
last reference gets releases, at least not in cases like this, where
we hand out the reference and the object is passed around through large
parts of the source code.

For now, still let NMActRequest keep track of NMUtilsShareRules.
Later this will be refactored too.
2020-10-27 17:40:19 +01:00
Thomas Haller
0c2d5fc972 core: add NMUtilsShareRules API for handling IP tables rules
Currently, shared rules are tracked by NMActRequest. Add a small
type for tracking the shared rules.
2020-10-27 17:07:57 +01:00
Thomas Haller
0438820805 device: use static array for modules in share_init()
A static const array is marked as immutable by the linker.
This is what we want, because there is no need to change this
array.

Also, the tailing %NULL entry is not necessary, we can just
iterate over the fixed number of elements.
2020-10-27 17:04:21 +01:00
Thomas Haller
379dde287c l3cfg: let NML3Cfg return a singleton NML3IPv4LL instance
NML3Cfg is the manager instance for one interface (ifindex). For one
interface, it is not supported (nor useful) to run IPv4LL multiple
times. Hence, let NML3Cfg manage and return a single instance.
2020-10-27 17:04:20 +01:00
Thomas Haller
291b3a52b7 l3cfg: add NM_ACD_TIMEOUT_RFC5227_MSEC define 2020-10-27 17:04:20 +01:00
Thomas Haller
6dd557c324 l3cfg: add nm_l3_ipv4ll_is_timed_out() for letting IPv4LL reach a failed state
We may want to handle cases where we cannot assign a IPv4LL address
even after multiple attempts.

Add a new property nm_l3_ipv4ll_is_timed_out() to get into a failed
state. The user may choose to fail the activation or ignore it.

Also, remove some unused code and fix minor issues in NML3IPv4LL.
2020-10-27 17:04:20 +01:00
Thomas Haller
f5b89e8060 shared: add nm_mult_clamped_u() helper 2020-10-27 17:04:20 +01:00
Thomas Haller
931573dfda shared: rename nm_add_u32_clamped() to nm_add_clamped_u32() 2020-10-27 17:04:19 +01:00
Thomas Haller
1cda792206 format: add ".git-blame-ignore-revs" and hint how to ignore the commit during git-blame 2020-10-27 16:00:45 +01:00
Thomas Haller
39026b64eb device/wifi: remove unused function nm_wifi_ap_set_ssid_arr() 2020-10-27 14:10:38 +01:00
Thomas Haller
eb36380335 device/wifi: don't reset the SSID of a NMWifiAP to unknown
For hidden networks, we usually don't have an SSID. We try to match
and fill the SSID based on the profiles that we have:

  <debug> [1603798852.9918] device[6b383dca267b6878] (wlp2s0): matched hidden AP AA:BB:CC:DD:EE:FF => "SSID"

However, we should not clear that value again on the next update:

  <trace> [1603798856.5724] sup-iface[66c1a0883a262394,0,wlp2s0]: BSS /fi/w1/wpa_supplicant1/Interfaces/0/BSSs/3 updated
  <debug> [1603798856.5726] device[6b383dca267b6878] (wlp2s0): wifi-ap: updated AA:BB:CC:DD:EE:FF (none)

Once we have a SSID, we can only update it to a better value,
but not clear it.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/438

Fixes: b83f07916a ('supplicant: large rework of wpa_supplicant handling')
2020-10-27 14:10:35 +01:00
Fernando Fernandez Mancera
9a935e516e Makefile: remove "libnm.actions" explicitly when uninstalling
On Fedora 33 when compiling NetworkManager it is failing with the
following error:

```
ERROR: files left in build directory after distclean:
./docs/libnm/libnm.actions
make[1]: *** [Makefile:18427: distcleancheck] Error 1
make[1]: Leaving directory '/builddir/nm-build/NetworkManager/NetworkManager-1.27.90/_build/sub'
make: *** [Makefile:18356: distcheck] Error 1
Error make distcheck
```

Adding the file to the DISTCLEANFILES will enforce the removal of this
file.

Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/659
2020-10-26 15:56:39 +01:00
Antonio Cardace
983798d945 l3cfg: fix typo in test
Signed-off-by: Antonio Cardace <acardace@redhat.com>
2020-10-23 18:30:33 +02:00
Thomas Haller
b4ced8b911 l3cfg: merge branch 'th/l3cfg-13'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/657
2020-10-23 17:12:42 +02:00
Thomas Haller
17269b0520 l3cfg: add support for IPv4 link local addresses (ipv4ll) to NML3Cfg
NML3Cfg already handles IPv4 ACD. IPv4LL is just a small additional
layer on top of that, so it makes sense that it also is handled by
NML3Cfg.

Also, the overall goal is that multiple NMDevice and NMVpnConnection
instances can cooperate independently. So if multiple "users" enable
IPv4LL on an interface, then we should only run it once. This is
achieved by NML3IPv4LL's API where users register what they want,
and NML3IPv4LL figures out what that means as a whole.

Also, we thus will no longer need to use sd_ipv4ll/n-ipv4ll, because
we implement it ourself.
2020-10-23 17:11:57 +02:00
Thomas Haller
3caf419df6 l3cfg: combine NML3AcdAddrTrackInfo and AcdTrackData
On the one hand, we want to keep the private fields internal. On the
other hand, we want to directly expose the NML3AcdAddrTrackInfo, so
that the user can access them without copying or calling a function.

Previously, there was some union ugliness and some padding involved.
That was probably correct, but lets solve this somewhat nicer by
having the private fields in a "_priv" struct and use NML3AcdAddrTrackInfo
throughout.
2020-10-23 17:11:56 +02:00
Thomas Haller
3874e061d4 platform/tests: add NMTstpAcdDefender helper for testing 2020-10-23 17:11:55 +02:00
Thomas Haller
60da4cb494 platform: interpret metric_any for routes to accept offset for default metric
The DHCP client likes to order multiple default routes by adding
them with different, increasing metric.

To support that, let "metric_any" not completely disable the "metric"
field, but instead interpret it as an offset that should be added to
the default metric.
2020-10-23 17:11:55 +02:00
Thomas Haller
f6a8aca1b4 l3cfg/tests: cleanup l3cfg tests and set a fixed MAC address on the test interfaces
It's better to have a well-known, fixed MAC address on our test veth
devices.

Also, because later we will test IPv4 link local addressing, which
generates addresses by hashing the MAC address (among others).
2020-10-23 17:11:55 +02:00
Thomas Haller
15f5d10352 l3cfg: add nm_netns_get_l3cfg() accessor
This is more for debugging and testing. Usually you want to call
nm_netns_access_l3cfg() which creates a NML3Cfg instance, if necessary.
2020-10-23 17:11:54 +02:00
Thomas Haller
b38fbb3bf6 l3cfg: add nm_l3_acd_addr_info_find_track_info() helper 2020-10-23 17:11:54 +02:00
Thomas Haller
4561b3c114 l3cfg: various bugfixes in NML3Cfg
- fix iterating logic in nm_l3cfg_add_config()

- fix preserving order during nm_l3cfg_commit_type_register()

- fix logic in _l3cfg_externally_removed_objs_drop_unused() to handle
  all object types and not only routes.

- in nm-l3-config-data.c, fix coercing the route metric from metric_any
  to the default metric.

- in _l3cfg_externally_removed_objs_drop_unused() and
  _l3cfg_externally_removed_objs_track() ensure that the object is kept
  alive long enough. The externally_removed_objs_hash hash keeps a
  reference to the object, so when removing it, we either must no longer
  access the object, or delay the destruction until later.
2020-10-23 17:11:54 +02:00
Thomas Haller
6cb6888404 platform/tests: better handling "timeout_msec" argument in nmtst_main_context_iterate_until()
nmtst_main_context_iterate_until() is a macro, and we don't want to restrict the
valid integer type (or range) of the "timeout_msec" argument.

In particular, if the user calculates a timeout with "timestamp_msec -
now_msec", the resulting "timeout_msec" might be a negative gint64.
We should handle that gracefully, and not let it be cast to a huge
unsigned int.
2020-10-23 17:11:54 +02:00
Thomas Haller
dd7ce063fb tests: add nmtst_get_rand_one_case_in() helper 2020-10-23 17:11:53 +02:00
Thomas Haller
c947c51651 shared: add nm_ptr_to_uintptr() helper 2020-10-23 17:11:53 +02:00
Thomas Haller
b38075b751 shared: add nm_add_u32_clamped() helper 2020-10-23 17:11:53 +02:00
Thomas Haller
c3fe895ebc trivial: whitespace fixes 2020-10-23 17:11:53 +02:00
Thomas Haller
ad18612c36 core: remove error checking for nm_auth_chain_new_subject() which cannot fail
nm_auth_chain_new_subject() cannot return %NULL, so these checks are only
noise. Also, there are already calls that correctly rely on the fact that
this function cannot fail.

We use glib, where memory allocation by definition cannot fail. That means,
a lot of functions simply cannot fail in our code base. This is a very nice
property (to have an functions that cannot fail), so don't add error
checking that is not useful.
2020-10-23 12:23:08 +02:00
Antonio Cardace
b6a18e0593 manager: fix very bad usage of 'nm_utils_user_data_unpack'
This results in the args of 'nm_utils_user_data_unpack'
containing random data potentially also from the
previous stack-frame which is really really bad.

Signed-off-by: Antonio Cardace <acardace@redhat.com>
Fixes: b50702775f ('device: implement auth-request as async operation nm_manager_device_auth_request()')
2020-10-22 17:38:08 +02:00
Thomas Haller
6e44842dc6 shared: introduce opaque type NMUtilsUserData for nm_utils_user_data_pack()
This makes the usage slightly more type safe.
2020-10-22 17:38:08 +02:00
Thomas Haller
515df289de all/trivial: fix formatting 2020-10-22 17:22:09 +02:00