Commit Graph

242 Commits

Author SHA1 Message Date
Thomas Haller
bd8d49495b
libnm: embed private structure in NMSetting and avoid g_type_class_add_private()
Historically, the NMSetting types were in public headers. Theoretically,
that allowed users to subtype our classes. However in practice that was
impossible because they lacked required access to internal functions to
fully create an NMSetting class outside of libnm. And it also was not
useful, because you simply cannot extend libnm by subtyping a libnm
class. And supporting such a use case would be hard and limit what we can
do in libnm.

Having GObject structs in public headers also require that we don't
change it's layout. The ABI of those structs must not change, if anybody
out there was actually subclassing our GObjects.

In libnm 1.34 (commit e46d484fae ('libnm: hide NMSetting types from
public headers')) we moved the structs from headers to internal.
This would have caused a compiler error if anybody was using those
struct definitions. However, we still didn't change the ABI/layout so
that we didn't break users who relied on it (for whatever reason).

It doesn't seem there were any affected user. We waited long enough.
Change internal ABI.

No longer use g_type_class_add_private(). Instead, embed the private
structs directly (_NM_GET_PRIVATE()) or indirectly
(_NM_GET_PRIVATE_PTR()) in the object.

The main benefit is for debugging in the debugger, where we can now
easily find the private data. Previously that was so cumbersome to be
effectively impossible.

It's also the fastest possible way, since NM_SETTING_*_GET_PRIVATE()
literally resolves to "&self->_priv" (plus static asserts and
nm_assert() for type checking).

_NM_GET_PRIVATE() also propagates constness and requires that the
argument is a compatible pointer type (at compile time).

Note that g_type_class_add_private() is also deprecated in glib 2.58 and
replaced by G_ADD_PRIVATE(). For one, we still don't rely on 2.58. Also,
G_ADD_PRIVATE() is a worse solution as it supports a usecase that we
don't care for (public structs in headers). _NM_GET_PRIVATE() is still
faster, works with older glib and most importantly: is better for
debugging as you can find the private data from an object pointer.

For NMSettingIPConfig this is rather awkward, because all direct
properties require a common "klass->private_offset". This was however
the case before this change. Nothing new here. And if you ever touch
this and do something wrong, many unit tests will fail. It's almost
impossible to get wrong, albeit it can be confusing to understand.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1773
2023-10-31 11:29:37 +01:00
Fernando Fernandez Mancera
4dc85ffa5c NEWS: update
(cherry picked from commit a1f48355de)
2023-08-09 17:19:58 +02:00
Fernando Fernandez Mancera
7d0065062c NEWS: update
(cherry picked from commit 52999c0709)
2023-08-09 16:53:35 +02:00
Beniamino Galvani
c13b475cb9 NEWS: update 2023-07-26 15:36:01 +02:00
Thomas Haller
e9426e6d07
keyfile: add a NetworkManager.conf option "keyfile.rename"
The default behavior is not to rename profiles. I guess, that makes
sense, as renaming a file when changing the "connection.id" could break
users who rely on the name.

My use case is the following. When I connect a Wi-Fi hotspot I use
`nmcli device wifi connect $SSID`, which -- as expected -- persists the
profile to "/etc/NetworkManager/system-connections/$SSID.nmconnection".
Later, I always update the profile's name to "w_$SSID" so I can see on
the name that this is wireless profile. I also want the filename to
reflect that change of name.

Add a configuration option for that. All the infrastructure
("force_rename" parameter) already exists.
2023-06-29 14:05:27 +02:00
Thomas Haller
6a4097fe0b
NEWS: update 2023-05-02 11:42:55 +02:00
Thomas Haller
21cf2dc58f
libnm,core: make "default${CONNECTION}" the built-in stable ID
The "connection.stable-id" supports placeholders like "${CONNECTION}" or
"${DEVICE}".

The stable-id can also be specified in global connection defaults in
NetworkManager.conf, by leaving it unset in the profile. Global
connection defaults always follow the pattern, that they correspond to a
per-profile property, and only when the per-profile value indicates a
special default/unset value, the global connection default is consulted.
Finally, if the global connection default is also not configured in
NetworkManager.conf, a built-in default is used (which may not be
constant either, for example ipv6.ip6-privacy's built-in default depends
on a sysctl value).

In any case, every possible configuration that can be achieved should be
configurable both per-profile and via global connection default. That
was not given for the stable-id, because the built-in default generated
an ID in a way that could not be explicitly expressed otherwise.

So you could not:
- explicitly set the per-profile value to the built-in default, to avoid
  that the global-connection-default overwrites it.
- explicitly set the global-connection-default to the built-in default,
  to avoid that a lower priority [connection*] section overwrites the
  stable-id again.

Fix that inconsistency to make it possible to explicitly set the
built-in default.

Change behavior for literally "default${CONNECTION}" and make it behave
as the built-in default. Also document that the built-in default has that
value.

It's unlikely that this breaks an existing configuration, but of course,
if any user configured "connection.stable-id=default${CONNECTION}", then
the behavior changes for them.
2023-04-21 12:49:18 +02:00
Thomas Haller
48a3682a75
NEWS: belatedly mention default for ipv6.addr-gen-mode
Fixes: e6a33c04eb ('all: make "ipv6.addr-gen-mode" configurable by global default')
2023-04-20 17:01:07 +02:00
Thomas Haller
c74c16ee21
NEWS: update 2023-02-10 09:37:36 +01:00
Lubomir Rintel
479e4dbfee
NEWS: update
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1521
2023-02-09 12:53:10 +01:00
Fernando Fernandez Mancera
d02be1c123 NEWS: update 2023-01-19 16:07:57 +01:00
Wen Liang
e8618f03d7
support loopback interface
Support managing the loopback interface through NM as the users want to
set the proper mtu for loopback interface when forwarding the packets.
Additionally, the IP addresses, DNS, route and routing rules are also
allowed to configure for the loopback connection profiles.

https://bugzilla.redhat.com/show_bug.cgi?id=2060905
2022-11-23 20:51:22 +01:00
Thomas Haller
3970489219
NEWS: update 2022-10-27 09:15:26 +02:00
Thomas Haller
22f670687a
libnm,core: support "bond.balance-slb" option 2022-10-04 12:37:41 +02:00
Thomas Haller
786bb9d048
NEWS: update 2022-09-28 21:37:00 +02:00
Beniamino Galvani
48b7ab5636 NEWS: update 2022-09-28 09:09:09 +02:00
Thomas Haller
ef712733aa
NEWS: update 2022-08-31 19:22:01 +02:00
Thomas Haller
55767cf5c5
NEWS: update 2022-08-26 19:45:28 +02:00
Ana Cabral
2652df3f47 NEWS: update 2022-08-26 16:17:40 +02:00
Ana Cabral
38f00bf6c9 NEWS: update
(cherry picked from commit dc01d353aa)
2022-08-24 11:04:46 +02:00
Ana Cabral
28282eb1d5 NEWS: update 2022-08-15 17:38:13 -03:00
Thomas Haller
3117198f15
Revert "wifi: support "802-1x.phase1-auth-flags=tls-allow-unsafe-renegotiation" flag"
There is still no agreement, about how to name this option, or whether
it should exist at all. Revert the addition of the flag.

As the new release is coming up, drop the new API.

https://bugzilla.redhat.com/show_bug.cgi?id=2072070#c64
https://bugzilla.redhat.com/show_bug.cgi?id=2077973#c24
http://lists.infradead.org/pipermail/hostap/2022-July/040665.html

This reverts commit a5a4aea2e6.
2022-08-11 19:36:26 +02:00
Thomas Haller
c99503abc4
NEWS: update 2022-08-11 15:36:03 +02:00
Thomas Haller
6f957f2ef8
NEWS: update 2022-08-09 09:00:52 +02:00
Beniamino Galvani
21fa345448 NEWS: update 2022-07-27 19:56:25 +02:00
Thomas Haller
5d095062e6
NEWS: update 2022-05-27 08:53:55 +02:00
Ana Cabral
d5b76a0a14 NEWS: update 2022-05-19 09:21:45 +02:00
Thomas Haller
f3db8049b7
NEWS: update
Resync latest changes from nm-1-38 branch.
2022-05-03 12:30:00 +02:00
Beniamino Galvani
6ab5c4e578 core: save DHCP lease information in state file in /run
DHCP leases for a given interface are already exported on D-Bus
through DHCP4Config and DHCP6Config objects. It is useful to have the
same information also available on the filesystem so that it can be
easily used by scripts.

NM already saves some information about DHCP leases in /var, however
that directory can only be accessed by root, for good reasons.

Append lease options to the existing state file
/run/NetworkManager/devices/$ifindex. Contrary to /var this directory
is not persistent, but it seems more correct to expose the lease only
when it is active and not after it expired or after a reboot.

Since the file is in keyfile format, we add new [dhcp4] and [dhcp6]
sections; however, since some options have the same name for DHCPv4
and DHCPv6, we add a "dhcp4." or "dhcp6." prefix to make the parsing
by scripts (e.g. via "grep") easier.

The option name is the same we use on D-Bus. Since some DHCPv6 options
also have a "dhcp6_" prefix, the key name can contain "dhcp6" twice.

The new sections look like this:

  [dhcp4]
  dhcp4.broadcast_address=172.25.1.255
  dhcp4.dhcp_lease_time=120
  dhcp4.dhcp_server_identifier=172.25.1.4
  dhcp4.domain_name_servers=172.25.1.4
  dhcp4.domain_search=example.com
  dhcp4.expiry=1641214444
  dhcp4.ip_address=172.25.1.182
  dhcp4.next_server=172.25.1.4
  dhcp4.routers=172.25.1.4
  dhcp4.subnet_mask=255.255.255.0

  [dhcp6]
  dhcp6.dhcp6_name_servers=fd01::1
  dhcp6.dhcp6_ntp_servers=ntp.example.com
  dhcp6.ip6_address=fd01::1aa
2022-05-03 09:12:12 +02:00
Thomas Haller
3d6b6aa317
core: change the priority order in static "ipv6.addresses"
The order of addresses matters. For "ipv4.addresses", the list
contains the primary address first. For "ipv6.addresses", the
order was reverted. This was also documented behavior.

The previous patch just changed behavior with respect to relative order
of static IPv6 addresses and autoconf6/DHCPv6. As we seem in the mood
for changing behavior, here is another one.

Now the addresses are interpreted in an order consistent with IPv4 and
how one might expect: preferred addresses first.
2022-04-27 15:50:55 +02:00
Thomas Haller
4a548423b9
core: change order/priority of static IPv6 addresses relative to autoconf6/DHCPv6
The order of addresses can matter for source address selection.
This is described in RFC 6724 section 5, but if the rules don't
determine a clear winner, the order matters.

Change the relative order of IPv6 addresses. Previously, we would prefer
autoconf6, over DHCPv6, over manual addresses. Now that got reverted
to make more sense and be consistent with IPv4.
Also, if we had multiple autoconf6 addresses (received at different
moments in time), then previously a newly received address would be
added with highest priority. Now, the older address will be preferred
and that order will be enforced (this can be a problem, see (*) below).

For IPv4, it's all simple and sensible. When we add addresses in kernel
via netlink, the first address (of a subnet) becomes the primary.
Note that we only control the order of addresses of the same subnet.
The addresses in ipv4.addresses" are sorted with primary address first.
In the same way is the order for addresses in NML3ConfigData and for
@known_addresses in nm_platform_ip_address_sync(), all primary-first.
Also, manual addresses are sorted with higher priority compared to DHCPv4
addresses (at least since NetworkManager 1.36). That means the way how we
merge NML3ConfigData makes sense (nm_l3_config_data_merge()) because we first
merge the static configuration, then the DHCPv4 configuration, where we just
append the lower priority DHCPv4 addresses.

For IPv6, the address priority is messed up. On netlink/kernel, the last added
address becomes the preferred one (we thus need to add them in the order of
lowest priority first). Consequently and historically, the IPv6 addresses in
@known_addresses parameter to nm_platform_ip_address_sync() were
lowest priority first. And so they were tracked in NML3ConfigData
and in the profile ("ipv6.addresses"). That is confusing.
Also, we usually want to merge NML3ConfigData with different priorities
(e.g. static configuration from the profile before autoconf6/DHCPv6),
as we do with IPv4. However, since internally IPv6 addresses are tracked in
reverse order, it means later NML3ConfigData would be appended and get effectively
a higher priority. That means, autoconf6 addresses were preferred over DHCPv6 and
over manual "ipv6.addresses", respectively. That seems undesirable and inconsistent
with IPv4. Change that. This is a change in behavior.

Note that changing the order of addresses means to remove and re-add
them in the right (inverse) order, with lease important first. This
means, when we add a new address with lower priority, we need to remove
all higher priority addresses temporarily, before readding them. That
is a problem(*).

Note that in the profile, "ipv6.addresses" is still tracked in reverse
order. This did not change, but might change later.
2022-04-27 15:50:50 +02:00
Lubomir Rintel
6fa1323ce5 nmcli: add --offline option for "add" and "modify"
This adds a global "--offline" option and allows its use with "add" and
"modify" commands. The "add" looks like this:

  $ nmcli --offline conn add type ethernet ens3 ipv4.dns 192.168.1.1 \
      >output.nmconnection

The "modify" is essentially implementing what's been suggested by
Beniamino in bugzilla ticked (referred to below):

  $ nmcli --offline connection modify ens3 ipv4.dns 192.168.1.1 \
      <input.nmconnection >output.nmconnection

Other commands don't support the argument at the moment:

  $ nmcli --offline c up ens3
  Error: 'up' command doesn't support --offline mode.

https://bugzilla.redhat.com/show_bug.cgi?id=1361145
2022-04-19 14:12:42 +02:00
Thomas Haller
54119d4105
dhcp: drop internal systemd DHCPv4 client
This is long replaced by nettools' n-dhcp4 client.
Drop it.

We still require NMDhcpSystemd for the DHCPv6 client.

Note that "[main].dhcp=systemd" now falls back to the internal client.
But this option was undocumented and internal anyway.
2022-04-14 14:51:02 +02:00
Thomas Haller
0f2708f86a
NEWS: update 2022-04-08 17:53:21 +02:00
Thomas Haller
2dc7a3d9f9
dhcp: set "src" for DHCPv4 routes
Let's set the "src" (RTA_PREFSRC) of DHCP routes.
This helps with source address selection.

This can matter if the interface also has static addresses
configured.

Systemd-networkd also does this ([1], [2]).

[1] ac2dce5f36
[2] 5b89bff55f/src/network/networkd-dhcp4.c (L395)

Related: https://bugzilla.redhat.com/show_bug.cgi?id=1995372

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1173
2022-04-07 10:20:46 +02:00
Thomas Haller
8e76b08e1c
NEWS: update 2022-04-06 18:28:06 +02:00
Thomas Haller
1d7bea8cf6
NEWS: update 2022-04-06 16:02:10 +02:00
Lubomir Rintel
79e8f9f258 NEWS: update 2022-03-24 21:33:39 +01:00
Beniamino Galvani
429228bfdd NEWS: update 2022-03-09 15:32:51 +01:00
Beniamino Galvani
392daa5dab core: fall back to loading all known settings plugins
Currently it is possible to specify a list of default settings plugins
to be used when configuration doesn't contain the main.plugins key.

We want to add a mechanism that allows to automatically load any
plugin found in the plugins directory without needing
configuration. This mechanism is useful when plugins are shipped in a
different, optional subpackage, to automatically use them.

With such mechanism, the actual list of plugins will be determined
(in order of evaluation):

 1. via explicit user configuration in /etc, if any
 2. via distro configuration in /usr, if any
 3. using the build-time default, if any
 4. looking for known plugins in /usr/lib
2022-03-06 09:12:06 +01:00
Thomas Haller
38290b1b86
NEWS: update
This paragraph that "it's likely that" some changes will be backported
to 1.34 branch seems unnecessary. Whenever we backport things to 1.34
we will add them to the NEWS file for nm-1-34, and then also mention
them in nm-1-36 and newer. But we don't need to announce that.
2022-02-24 17:44:12 +01:00
Thomas Haller
e023ac30f2
NEWS: update 2022-02-23 14:57:49 +01:00
Christian Eggers
b26c9723d9
libnm-crypto: add new option for no cryptography
For some embedded systems, no cryptography is required at all (e.g when
only using Ethernet).

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1108
2022-02-21 19:12:27 +01:00
Thomas Haller
f18bf17dea
wifi: cleanup ensure_hotspot_frequency()
wifi: choose a (stable) random channel for Wi-Fi hotspot

The channel depends on the SSID.

Based-on-patch-by: xiangnian <xiangnian@uniontech.com>

See-also: https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1054

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1099
2022-02-21 16:03:24 +01:00
Thomas Haller
365d0e49bc
NEWS: update NEWS file for 1.38 development 2022-02-16 11:11:24 +01:00
Lubomir Rintel
122070142d NEWS: update for 1.36-rc2 2022-02-10 12:29:52 +01:00
Lubomir Rintel
dc9d932ecc NEWS: update for 1.36-rc1 2022-02-04 18:04:41 +01:00
Beniamino Galvani
d68ab6b8f0 nm-sudo: rename to nm-priv-helper
The name "nm-sudo" reminds of the "sudo" tool, and this is a bit
confusing because it's not related. Rename the service to
"nm-priv-helper", which stands for "NM privileged helper".

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/938
2022-01-11 21:46:55 +01:00
Thomas Haller
a2b26e26d9
NEWS: update 2021-11-19 11:16:01 +01:00
Thomas Haller
2cd1a22a78
NEWS: drop unstable warning for 1.34 2021-11-19 11:12:50 +01:00