Commit graph

395 commits

Author SHA1 Message Date
Thomas Haller
0510e6f57d
libnm/tests: avoid uninitialized variable warning in _invalid_option_write_handler()
src/libnm-core-impl/tests/test-keyfile.c: In function '_invalid_option_write_handler':
  src/libnm-core-impl/tests/test-keyfile.c:917:9: error: 'message' may be used uninitialized [-Werror=maybe-uninitialized]
    917 |         g_assert(message && strstr(message, "ethtool.bogus"));
        |         ^
  src/libnm-core-impl/tests/test-keyfile.c:905:29: note: 'message' was declared here
    905 |     const char             *message;
        |                             ^
  lto1: all warnings being treated as errors

(cherry picked from commit 8d6349156b)
(cherry picked from commit a71e51e712)
2023-04-03 21:31:48 +02:00
Fernando Fernandez Mancera
920ab658b2 dns: add support to no-aaaa option
Users can set `no-aaaa` DNS option to suppress AAAA queries made by the
stub resolver, including AAAA lookups triggered by NSS-based interfaces
such as getaddrinfo. Only DNS lookups are affected.

(cherry picked from commit 9d4bbf78f0)
(cherry picked from commit f71cd2eb72)
2023-03-29 12:24:44 +02:00
Etienne Champetier
979591a067
doc: fix route type name (unavailable -> unreachable)
Fixes: 1cc3d00cb7 ('libnm/doc: list route attributes in `man nm-settings-nmcli`')
(cherry picked from commit fb03dbacd8)
(cherry picked from commit e308bd79e8)
2023-03-09 07:21:43 +01:00
Thomas Haller
bb20948b7b
libnm/docs: improve documentation for ipv[46].dhcp-iaid setting
(cherry picked from commit f36fabc0fa)
(cherry picked from commit e1d6d72f8e)
2023-02-21 09:46:42 +01:00
Thomas Haller
c45c5c37a4
libnm: accept ipv[46].dhcp-iaid as hexstr
dhclient exports the currently used IAID in the environment as
hex string. We expose this environment in our API, so this is also
the format that NetworkManager uses.

Accept setting the ipv[46].dhcp-iaid as hex string, so that the same
format is accepted on the profile.

While at it, also accept a hex number (0x) because it is also
convenient, and this change already introduces the precedent that the
IAID string is not unique/normalized.

(cherry picked from commit e5dc489197)
(cherry picked from commit 0b4446e252)
2023-02-21 09:45:25 +01:00
Thomas Haller
5f8b0c4713
base: add nm_dhcp_iaid_{from,to}_hexstr() helpers
(cherry picked from commit 4c18adbc74)
(cherry picked from commit 05c6a0d6fa)
2023-02-21 09:45:11 +01:00
Thomas Haller
66d1039520
libnm/tests: adjust test for glib change in 2.75.0 for assertion warning
See-also: 0ffe86a1f7
(cherry picked from commit 861fc6854c)
(cherry picked from commit c5917b0a50)
2023-02-11 18:33:39 +01:00
Beniamino Galvani
2dd070e646 macsec: document the format of CAK and CKN properties
(cherry picked from commit dfe63d9eb3)
2022-12-05 17:15:06 +01:00
Beniamino Galvani
faf8f0ff24 macsec: allow CKN shorter than 64 characters
See wpa_supplicant commit [1]:

    macsec: Make pre-shared CKN variable length

    IEEE Std 802.1X-2010, 9.3.1 defines following restrictions for
    CKN:

    "MKA places no restriction on the format of the CKN, save that it
    comprise an integral number of octets, between 1 and 32
    (inclusive), and that all potential members of the CA use the same
    CKN. No further constraints are placed on the CKNs used with PSKs,
    ..."

    Hence do not require a 32 octet long CKN but instead allow a
    shorter CKN to be configured.

    This fixes interoperability with some Aruba switches, that do not
    accept a 32 octet long CKN (only support shorter ones).

[1] https://w1.fi/cgit/hostap/commit/?id=b678ed1efc50e8da4638d962f8eac13312a4048f

(cherry picked from commit df999d1fca)
2022-12-05 17:15:06 +01:00
Thomas Haller
b73230ee20
libnm: workaround compiler warning in nm_sock_addr_endpoint_new()
gcc-12.2.1_git20220924-r4 (on Alpine Linux) warns:

  ../src/libnm-core-impl/nm-utils.c: In function 'nm_sock_addr_endpoint_new':
  ../src/libnm-core-impl/nm-utils.c:168:18: error: 'port' may be used uninitialized [-Werror=maybe-uninitialized]
    168 |         ep->port = port;
        |         ~~~~~~~~~^~~~~~
  ../src/libnm-core-impl/nm-utils.c:150:25: note: 'port' was declared here
    150 |     guint16             port;
        |                         ^~~~

Workaround.

Fixes: 713e879d76 ('libnm: add NMSockAddrEndpoint API')
(cherry picked from commit 3515324e90)
2022-11-30 15:25:18 +01:00
Thomas Haller
e5e8515dd9
libnm/tests: check assigning same setting in nm_connection_add_setting()
Fixes: 3e3b629586 ('libnm: fix leak with self assignment in nm_connection_add_setting()')
(cherry picked from commit a87fd2e4d2)
2022-11-17 16:36:28 +01:00
Thomas Haller
ef29015d0b
libnm: fix leak with self assignment in nm_connection_add_setting()
We must consume the reference, like we would in the other case.

Interestingly, I am unable to reproduce a case where valgrind would
complain about the leak. But it is there nonetheless.

Fixes: 0a22f4e490 ('libnm: refactor tracking of NMSetting in NMConnection')
(cherry picked from commit 3e3b629586)
2022-11-17 16:34:01 +01:00
Thomas Haller
3e9b5217f3
libnm: workaround crash in nm_vpn_editor_plugin_import() for plugin requiring GError
The "GError **error" parameter in GLib API should be optional. Due to a
bug in at least nm-vpnc ([1]), this is not the case. Workaround in
libnm.

[1] c7d197477c/properties/nm-vpnc-editor-plugin.c (L281)

(cherry picked from commit 3b2eb689f3)
2022-11-16 13:37:52 +01:00
Lubomir Rintel
8080aceb0f libnm: actually export a lot of routines that were supposed to be public
Add them to @libnm_1_40_4 as opposed to @libnm_1_42_0 because we now know
this is going to be backported to 1.40.4 first.

(cherry picked from commit 45d9f1c01c)

Compared to version in main branch, the Since tags and
NM_AVAILABLE_IN_* macros indicate the branched version.
2022-11-11 16:49:39 +01:00
Lubomir Rintel
78e94e63b6 libnm: export nm_utils_ip_{address,rout}es_{from,to}_variant
These are present in a public header yet are not properly commented,
versioned or exported.

Export them now. Another option would be to move them to a private
header; but I suspect someone has intended them to be exported at some
point.

Add them to @libnm_1_40_4 as opposed to @libnm_1_42_0 because we now know
this is going to be backported to 1.40.4 first.

(cherry picked from commit d78000d921)

Compared to version in main branch, the Since tags and
NM_AVAILABLE_IN_* macros indicate the branched version.
2022-11-11 16:49:39 +01:00
Lubomir Rintel
af6be92033 libnm/connection: fix a handful of versioning tags
These are marked as being available sooner than they actually appear in
libnm.ver.

(cherry picked from commit c0b2b5e3a8)
2022-11-11 16:49:39 +01:00
Lubomir Rintel
e401307bec libnm: fix a large amount of Since tags
Some comments are malformed, some are missing altogether.

(cherry picked from commit 117a440cd9)

Compared to version in main branch, the Since tags document the
branched version as well.

The backport omits changes to nm_client_wait_shutdown(), since that one
is not yet present in 1.40.
2022-11-11 16:49:39 +01:00
Lubomir Rintel
3c1471d9ca libnm: export nm_setting_ip_config_get_dhcp_iaid
The export was left out when the symbol was added; apparently by
accident.

Let's also bump the documented version of when is the symbol supposed to
be available, because it actually wasn't.

Fixes: 56a1a5426a ('all: add ipvX.dhcp-iaid properties')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1447
(cherry picked from commit 941e8b70f8)

Compared to version in main branch, the Since tags and
NM_AVAILABLE_IN_* macros indicate the branched version.

Backport also includes commit c7f6a506ef ('libnm: move
nm_setting_ip_config_get_dhcp_iaid() to @libnm_1_40_4 version node'),
it wouldn't be possible to backport both separately.
2022-11-11 16:49:39 +01:00
Thomas Haller
f0203ba8ac nm-setting: fix static assertions for NM_SETTING_PARAM_* flags and numeric values
- the static assertions were wrong, there was a "," instead of "==".

- the numeric values were wrong, as shown by the static assertions.

- move the code comment to the implementation. This does not seem
  relevant for the library user and should not be in the public header.

Fixes: 08e845f651 ('nm-setting: mangle public constant to make g-ir-scanner happy')
(cherry picked from commit c884d4d347)
2022-11-11 16:49:39 +01:00
Lubomir Rintel
bf9a1bedb8 nm-setting: mangle public constant to make g-ir-scanner happy
Some versions of g-ir-scanner's C parser silently coerce unrecognized
symbols into zeroes [1]. Let's avoid that so that we don't end up with
wrong constants in our Gir data.

[1] https://gitlab.gnome.org/GNOME/gobject-introspection/-/merge_requests/366

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1446
(cherry picked from commit 08e845f651)
2022-11-11 16:49:39 +01:00
Thomas Haller
a14aa08a43
ethtool: add and use nm_ethtool_id_get_variant_type() helper
(cherry picked from commit a0370e0efa)
2022-11-10 13:49:17 +01:00
Thomas Haller
1ae5af9898
bond: add _nm_setting_bond_opt_value_as_intbool() helper
Bond option values are just strings, however, some of them get
validated to be numbers, etc.

We also have effectively boolean values, like "use-carrier". Internally,
this is not validates as a boolean (_nm_utils_ascii_str_to_bool()) but
instead is an integer of either "0" or "1".

Add a helper function_nm_setting_bond_opt_value_as_intbool() to access
and parse such values.

(cherry picked from commit 489a1b8f1e)
2022-09-29 14:14:41 +02:00
Thomas Haller
45382be34d
bond: assert integer range in _nm_setting_bond_opt_value_as_u{8,16,32}()
The bond setting does some minimal validation of the options.
At least for those number typed values, it validates that the
string can be interpreted as a number and is within a certain range.

Add nm_assert() checks to our opt_value_u$SIZE() functions, that the
requested option is validated to be in a range which is sufficiently
narrow to be converted to the requested type. If that were not the case,
we would need some special handling (or question whether the option should
be retrieved as this type).

(cherry picked from commit a19458e11d)
2022-09-29 14:14:41 +02:00
Beniamino Galvani
30366e5b3a
libnm-core: allow empty slave-type with a NMSettingBondPort
It is allowed to have a connection with empty connection.slave-type
and a NMSettingBondPort; the property will be set automatically during
normalization if a master is set, otherwise the setting will be removed.

With this change, it becomes possible to remove a port from a bond
from nmcli, turning it into a non-slave connection. Before, this used
to fail with:

  $ nmcli connection add type ethernet ifname test con-name test+ connection.master bond0 connection.slave-type bond
  $ nmcli connection modify test+ connection.master '' connection.slave-type ''
  Error: Failed to modify connection 'test+': connection.slave-type: A connection with a 'bond-port' setting must have the slave-type set to 'bond'

https://bugzilla.redhat.com/show_bug.cgi?id=2126262
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1382

Fixes: 9958510f28 ('bond: add support of queue_id of bond port')
(cherry picked from commit 23ce9cff99)
2022-09-27 08:23:41 +02:00
Thomas Haller
3272e5cc92
libnm: avoid serializing "ipv6.addr-gen-mode" default to D-Bus
When serializing setting properties to GVariant/D-Bus, we usually
omit values that are set to the default. That is done by libnm(-core),
so it happens both on the daemon and client side. That might be
useful to avoid a large number of properties on D-Bus.

Before changing the default value for "ipv6.addr-gen-mode" ([1]), we
would not serialize the previous default value ("stable-privacy").
Now we would serialize the new default value ("default). This change
causes problems.

Scenario 1: have a profile in the daemon with "ipv6.addr-gen-mode=stable-privacy",
have an older daemon version before [1] and a newer client after [1]. Result:

  The daemon exposes the profile on D-Bus without the addr-gen-mode
  field (because it's the default). To the client, that is interpreted
  differently, as "ipv6.addr-gen-mode=default". This is already somewhat
  a problem.
  More severe is when modifying the profile, the client would now serialize
  the value "default" on D-Bus, which the older daemon rejects as invalid.
  That means, you could not modify the profile, unless also resetting
  addr-gen-mode to "stable-privacy" or "eui64".

You can imagine other scenarios where either the daemon or the client is
before/after change [1] and the addr-gen-mode is set to either "default"
or "stable-privacy". Depending on what scenario you look, that can either be
good or bad.

Scenario 1 is pretty bad, because it means `dnf upgrade NetworkManager
&& nmcli connection modify ...` will fail (if the daemon was not
restated). So try to fix Scenario 1, by also not serializing the new
default value on D-Bus. Of course, some of the scenarios will get
different problems, by exacerbating one side misunderstanding the actually
set value and interpreting a missing value on D-Bus wrongly.  But those
problems are likely less severe.

In case both client and daemon are older/newer than [1], it doesn't
matter either way. The problem happens with different version and is
caused by a change of the default value.

[1] e6a33c04eb

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1372
(cherry picked from commit 70060d570b)
2022-09-08 17:35:04 +02:00
Thomas Haller
2b1f7cfff4
style: fix code formatting
Fixes: eec9efd989 ('glib-aux: fix nicks for zero flag in nm_utils_enum_to_str()')
(cherry picked from commit befbad7375)
2022-08-25 23:28:05 +02:00
Thomas Haller
b1a402b1fc
glib-aux: fix nicks for zero flag in nm_utils_enum_to_str()
nm_utils_enum_to_str() can print flags, that is, combinations of
powers of two integers.

It also supports nicks, for certain flags.

When we have a nick for value zero, then that requires special
handling. Otherwise, that zero nick will always show up in the
string representation, although, it should only be used if the
enum value is exactly zero.

(cherry picked from commit eec9efd989)
2022-08-25 23:12:53 +02:00
Thomas Haller
56d0d35516
mptcp: rework "connection.mptcp-flags" for enabling MPTCP
1) The "enabled-on-global-iface" flag was odd. Instead, have only
and "enabled" flag and skip (by default) endpoints on interface
that have no default route. With the new flag "also-without-default-route",
this can be overruled. So previous "enabled-on-global-default" now is
the same as "enabled", and "enabled" from before behaves now like
"enabled,also-without-default-route".

2) What was also odd, as that the fallback default value for the flags
depends on "/proc/sys/net/mptcp/enabled". There was not one fixed
fallback default, instead the used fallback value was either
"enabled-on-global-iface,subflow" or "disabled".
Usually that is not a problem (e.g. the default value for
"ipv6.ip6-privacy" also depends on use_tempaddr sysctl). In this case
it is a problem, because the mptcp-flags (for better or worse) encode
different things at the same time.
Consider that the mptcp-flags can also have their default configured in
"NetworkManager.conf", a user who wants to switch the address flags
could previously do:

  [connection.mptcp]
  connection.mptcp-flags=0x32   # enabled-on-global-iface,signal,subflow

but then the global toggle "/proc/sys/net/mptcp/enabled" was no longer
honored. That means, MPTCP handling was always on, even if the sysctl was
disabled. Now, "enabled" means that it's only enabled if the sysctl
is enabled too. Now the user could write to "NetworkManager.conf"

  [connection.mptcp]
  connection.mptcp-flags=0x32   # enabled,signal,subflow

and MPTCP handling would still be disabled unless the sysctl
is enabled.

There is now also a new flag "also-without-sysctl", so if you want
to really enable MPTCP handling regardless of the sysctl, you can.
The point of that might be, that we still can configure endpoints,
even if kernel won't do anything with them. Then you could just flip
the sysctl, and it would start working (as NetworkManager configured
the endpoints already).

Fixes: eb083eece5 ('all: add NMMptcpFlags and connection.mptcp-flags property')
(cherry picked from commit c00873e08f)
2022-08-25 23:12:53 +02:00
Thomas Haller
86879692c6
libnm: reword documentation for "ipv4.gateway" and "ipv6.gateway"
(cherry picked from commit 0e26203e02)
2022-08-23 16:39:04 +02: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
f64dff6939
all: drop various NMMptcpFlags
The default behavior might be sufficient. Drop those flags for now,
and figure out a good solution when we have an actual use-case.
2022-08-09 08:02:56 +02:00
Thomas Haller
eb083eece5
all: add NMMptcpFlags and connection.mptcp-flags property 2022-08-09 08:02:54 +02:00
Fernando Fernandez Mancera
32870d8233 libnm-utils: convert string bond opts to int
NMPlatform code for bond netlink support will use the numeric values,
therefore we need functions to convert all the string values to int.
2022-08-04 11:18:36 +02:00
Georg Müller
1d614dbded
crypto: support EC private keys
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1324
2022-08-04 09:46:06 +02:00
Thomas Haller
60404836d8
std-aux: add c_list_insert_sorted()
The strength of CList is of course to use it as a stack of queue,
and only append/remove from the front/tail.

However, since this is an intrusive list, it can also be useful to
just use it to track elements, and -- when necessary -- sort them
via c_list_sort().

If we have a sorted list, we might want to insert a new element
honoring the sort order. This function achieves that.
2022-07-28 11:05:14 +02:00
Thomas Haller
d8a4b3bec2
all: reformat with clang-format (clang-tools-extra-14.0.0-1.fc36) and update gitlab-ci to f36 2022-07-06 11:06:53 +02:00
Thomas Haller
9bfe690ab7
libnm/docs: expand documentation for wireguard.ip4-auto-default-route 2022-06-30 21:30:49 +02:00
Thomas Haller
e6a33c04eb
all: make "ipv6.addr-gen-mode" configurable by global default
It can be useful to choose a different "ipv6.addr-gen-mode". And it can be
useful to override the default for a set of profiles.

For example, in cloud or in a data center, stable-privacy might not be
the best choice. Add a mechanism to override the default via global defaults
in NetworkManager.conf:

  # /etc/NetworkManager/conf.d/90-ipv6-addr-gen-mode-override.conf
  [connection-90-ipv6-addr-gen-mode-override]
  match-device=type:ethernet
  ipv6.addr-gen-mode=0

"ipv6.addr-gen-mode" is a special property, because its default depends on
the component that configures the profile.

- when read from disk (keyfile and ifcfg-rh), a missing addr-gen-mode
  key means to default to "eui64".
- when configured via D-Bus, a missing addr-gen-mode property means to
  default to "stable-privacy".
- libnm's ip6-config::addr-gen-mode property defaults to
  "stable-privacy".
- when some tool creates a profile, they either can explicitly
  set the mode, or they get the default of the underlying mechanisms
  above.

  - nm-initrd-generator explicitly sets "eui64" for profiles it creates.
  - nmcli doesn' explicitly set it, but inherits the default form
    libnm's ip6-config::addr-gen-mode.
  - when NM creates a auto-default-connection for ethernet ("Wired connection 1"),
    it inherits the default from libnm's ip6-config::addr-gen-mode.

Global connection defaults only take effect when the per-profile
value is set to a special default/unset value. To account for the
different cases above, we add two such special values: "default" and
"default-or-eui64". That's something we didn't do before, but it seams
useful and easy to understand.

Also, this neatly expresses the current behaviors we already have. E.g.
if you don't specify the "addr-gen-mode" in a keyfile, "default-or-eui64"
is a pretty clear thing.

Note that usually we cannot change default values, in particular not for
libnm's properties. That is because we don't serialize the default
values to D-Bus/keyfile, so if we change the default, we change
behavior. Here we change from "stable-privacy" to "default" and
from "eui64" to "default-or-eui64". That means, the user only experiences
a change in behavior, if they have a ".conf" file that overrides the default.

https://bugzilla.redhat.com/show_bug.cgi?id=1743161
https://bugzilla.redhat.com/show_bug.cgi?id=2082682

See-also: https://github.com/coreos/fedora-coreos-tracker/issues/907

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1213
2022-06-29 07:38:48 +02:00
Beniamino Galvani
90e7afc2cd libnm,core: add support for {rto_min,quickack,advmss} route attributes 2022-06-27 11:38:43 +02:00
Thomas Haller
863b71a8fe
all: use internal _nm_utils_ip4_netmask_to_prefix()
We have two variants of the function: nm_utils_ip4_netmask_to_prefix()
and _nm_utils_ip4_netmask_to_prefix(). The former only exists because it
is public API in libnm. Internally, only use the latter.
2022-06-27 10:50:24 +02:00
Thomas Haller
05014b328f
glib-aux: add _nm_utils_ip4_netmask_to_prefix() helper
nm_utils_ip4_netmask_to_prefix() and nm_utils_ip4_prefix_to_netmask()
are public API in libnm.

We thus already have an internal implementation _nm_utils_ip4_prefix_to_netmask(),
for non-libnm users. Internally, we should never use the libnm variant.

For consistency and so that we have the helper available in
libnm-glib-aux, add _nm_utils_ip4_netmask_to_prefix().
2022-06-27 10:50:23 +02:00
Thomas Haller
7a33870bf1
libnm: assert nm_utils_ip4_prefix_to_netmask() for valid IPv4 prefix length
There was already an nm_assert() assertion. Upgrade this
to a g_return_val_if_fail(). This function is public API,
so this is potentially an API break. But it should highlight
a bug in the caller.
2022-06-27 10:50:13 +02:00
Thomas Haller
3ee61f0913
libnm/docs: add comment about background scanning to wifi.bssid property 2022-06-21 10:36:05 +02:00
David Bauer
21a19383c8
libnm: fix compatibility of OWE-TM with unsecure profiles
A unsecure profile can be used with a OWE-TM network, in which case it
uses the non-OWE BSS.

Signed-off-by: David Bauer <mail@david-bauer.net>
2022-06-17 19:50:40 +02:00
Thomas Haller
612528af89
libnm/docs: elaborate how ipv4.dns-search/ipv6.dns-search works 2022-06-17 19:32:41 +02:00
Fernando Fernandez Mancera
87eb61c864 libnm: support wait-activation-delay property
The property wait-activation-delay will delay the activation of an
interface the specified amount of milliseconds. Please notice that it
could be delayed some milliseconds more due to other events in
NetworkManager.

This could be used in multiple scenarios where the user needs to define
an arbitrary delay e.g LACP bond configure where the LACP negotiation
takes a few seconds and traffic is not allowed, so they would like to
use nm-online and a setting configured with this new property to wait
some seconds. Therefore, when nm-online is finished, LACP bond should be
ready to receive traffic.

The delay will happen right before the device is ready to be activated.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1248

https://bugzilla.redhat.com/show_bug.cgi?id=2008337
2022-06-16 02:14:21 +02:00
Alex Henrie
0004a408ae
device: introduce ipv6.mtu property
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1003

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1231
2022-05-27 08:51:44 +02:00
Adrian Freihofer
cdaa99cd35
ifcfg-rh: add support for ipv4.link-local 2022-05-27 08:24:40 +02:00
Adrian Freihofer
cbde63a493
settings: add ipv4.link-local flag
Introduction of a new setting ipv4.link-local, which enables
link-local IP addresses concurrently with other IP address assignment
implementations such as dhcp or manually.
No way is implemented to obtain a link-local address as a fallback when
dhcp does not respond (as dhcpd does, for example). This could be be
added later.

To maintain backward compatibility with ipv4.method ipv4.link-local has
lower priority than ipv4.method. This results in:
* method=link-local overrules link-local=disabled
* method=disabled overrules link-local=enabled

Furthermore, link-local=auto means that method defines whether
link-local is enabled or disabled:
* method=link-local --> link-local=enabled
* else --> link-local=disabled

The upside is, that this implementation requires no normalization.
Normalization is confusing to implement, because to get it really
right, we probably should support normalizing link-local based on
method, but also vice versa. And since the method affects how other
properties validate/normalize, it's hard to normalize that one, so that
the result makes sense. Normalization is also often not great to the
user, because it basically means to modify the profile based on other
settings.

The downside is that the auto flag becomes API and exists because
we need backward compatibility with ipv4.method.
We would never add this flag, if we would redesign "ipv4.method"
(by replacing by per-method-specific settings).

Defining a default setting for ipv4.link-local in the global
configuration is also supported.
The default setting for the new property can be "default", since old
users upgrading to a new version that supports ipv4.link-local will not
have configured the global default in NetworkManager.conf. Therefore,
they will always use the expected "auto" default unless they change
their configuration.

Co-Authored-By: Thomas Haller <thaller@redhat.com>
2022-05-27 08:24:28 +02:00
Alex Henrie
7d8b749293
libnm: allow manually specified IP addresses to have prefix length 0
In IPv4, /0 prevents the creation of a device route, making it
effectively the same as /32. However, in IPv6, /0 makes the device route
an all-encompassing default route. This allows, for example, an 'fe80::'
link-local address to be used to communicate with any public or private
address on the local network without any additional configuration.

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

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1232
2022-05-26 19:08:28 +02:00