Commit graph

16580 commits

Author SHA1 Message Date
Beniamino Galvani
220189b9e6 device: manually update link properties for ovs interfaces
OVS interfaces are special: the kernel link is created only after the
device is attached to the ovs-port, and as with all ports this happens
during stage3(ip-config). That means that the link doesn't exist
during stage2(config); therefore, explicitly update link properties
once the link appears.
2023-03-02 16:57:08 +01:00
Beniamino Galvani
16f491eb13 device: set link properties
Set link properties during activation and restore the previous values
on deactivation.
2023-03-02 16:53:54 +01:00
Beniamino Galvani
e02fd76d9f platform: support changing link properties
Add support in platform for changing the newly introduced link
properties.
2023-03-02 16:51:16 +01:00
Beniamino Galvani
39bfcf7aab all: add "link" setting
Introduce a new "link" setting that holds properties that are related
to the kernel link.
2023-03-02 16:51:16 +01:00
Beniamino Galvani
f97dd2bb95 libnm-core: remove assertion in test
It's another place to change when adding a new setting and it doesn't
seem useful to assert that the number is exactly 54.
2023-03-02 16:51:16 +01:00
Beniamino Galvani
cae5d1b89f libnmc-setting: allow the "match" setting for some port connections
A {bond, bridge, team, ovs-port} port profile should support a "match"
setting.
2023-03-02 16:51:16 +01:00
Beniamino Galvani
babe2bacd3 platform: rename link_change() to link_change_extra()
There are many functions to replace properties of a link
(link_set_address, link_set_mtu, link_set_name, link_change,
etc.). Eventually, they will be replaced by a function that does
everything and removes all the code duplication.

That function will be named link_change(); rename the current
link_change() to link_change_extra().
2023-03-02 16:51:16 +01:00
Beniamino Galvani
24deb07159 device: reconfigure ethtool and tc also for assumed devices
We need to set the ethtool and tc properties for assumed devices,
since they go through a normal activation. External devices should not
be touched by NM.
2023-03-02 16:51:16 +01:00
Beniamino Galvani
86b922695f settings: preserve existing connection flags on update
We are passing to the plugin only 'sett_flags', which is the bitmask
of flags to change and works together with 'sett_mask'; however,
plugins interpret that value as the new flags value. The result is
that if there is no change needed (0/0), the existing flags are lost.
Simple reproducer:

  ip link add dummy1 type dummy
  ip link set dummy1 up
  ip addr add dev dummy1 fd01::12/64
  sleep 1

  # now, a external connection is created by NM

  echo "BEFORE:"
  cat /run/NetworkManager/system-connections/dummy1.nmconnection | grep "nm-generated\|volatile\|external"

  # just add a new address to the interface to make it lose
  # the external flag

  ip addr add dev dummy1 172.25.42.1/24
  sleep 1

  echo "AFTER:"
  cat /run/NetworkManager/system-connections/dummy1.nmconnection | grep "nm-generated\|volatile\|external"

Output:

  BEFORE:
  nm-generated=true
  volatile=true
  external=true
  AFTER:

Fixes: d35d3c468a ('settings: rework tracking settings connections and settings plugins')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1548
2023-03-02 11:21:34 +01:00
Beniamino Galvani
a7405b0892 platform: fix bridge test with fake platform
Fixes: 5afb323ed8 ('platform/tests: add test for nm_platform_link_set_bridge_info()')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1552
2023-03-01 23:51:22 +01:00
liaohanqin
2f8694c439 nmcli: add WPA-EAP-SUITE-B-192 to SECURITY 2023-03-01 13:59:32 +00:00
Thomas Haller
5afb323ed8
platform/tests: add test for nm_platform_link_set_bridge_info() 2023-03-01 11:39:07 +01:00
Vladislav Tsisyk
6de0bb6a86
bridge: set vlan_filtering and vlan_default_pvid via netlink
This commit changes setting values of said attributes from writing string to
sysfs to sending Netlink message.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1499
2023-03-01 11:39:01 +01:00
Thomas Haller
336b46d1c2
ifcfg-rh: fix wrong (transfer-full) annotation in internal code
The annotation is wrong. However, we don't generate
gtk-doc/introspection data for such internal code, so it doesn't really
matter.
2023-03-01 08:25:58 +01:00
Thomas Haller
e3ae3b1732
libnm: add missing types to "nm-autoptr.h" header 2023-02-28 16:33:07 +01:00
Corentin Noël
e0b2123c2c
libnm/connection: Add missing annotations to nm_connection_diff
Allows to use this function in GObject introspected languages.

Also workaround a current issue with the gtk-doc parser not taking nested
element-type into account.
2023-02-28 13:05:47 +01:00
Corentin Noël
169f8748ba
libnm: Specify the main header in the .gir file
Bindings compiling to C need to know which main header to include.
2023-02-28 13:05:47 +01:00
Thomas Haller
9bb47d07d9
platform: minor refactoring of temporary-not-available routes
This will be used also for IPv4 addresses. Rename and make the function
more generally useful.
2023-02-28 12:13:45 +01:00
Thomas Haller
eca8ebef18
platform: get extack_msg innm_platform_ip_route_sync()
Request the extack_msg for nm_platform_ip_route_add() call. Note that we (currently)
don't do anything with it, however requesting it has no downsides. That is, the
message already is heap allocated in the lower layers, so this only affects whether
it will be returned up to nm_platform_ip_route_sync().
2023-02-28 12:12:08 +01:00
Thomas Haller
d755b50808
platform: return extack message from add address/route operations 2023-02-28 12:08:07 +01:00
Thomas Haller
61388fd9c7
platform: drop logging for unexpected sequence number
It is not clear how that information is relevant. Since it is also
only logged when building with a non-default configure option, this
doesn't seem useful. Drop it.
2023-02-28 12:08:07 +01:00
Thomas Haller
bb9894abec
platform: minor cleanup of event_seq_check()
- unindent the code by "continue" the loop for the irrelevant case.
- fix indentation of comments.
- avoid unnecessary g_strdup() call if the extack message is NULL.
2023-02-28 12:08:06 +01:00
Thomas Haller
1d69b41db9
platform: log extack warning messages for netlink requests
The extack can also be returned on success. In that case,
they are warnings. Log them, it might be useful.
2023-02-28 12:08:06 +01:00
Thomas Haller
6ca537fa6a
platform: rename variables for extack message
Consistently name those variables and parameters "extack_msg".
The previous term "errmsg"/"msg" was not used consistently, and it
is also not clear what message this really is. For netlink, it
is well understood what Extended ACK means.
2023-02-28 12:08:06 +01:00
Thomas Haller
6f854ecaeb
platform/netlink: cleanup nla_strlcpy() to not wipe remaining buffer
strlcpy()/g_strlcpy() has a well understood behavior. nla_strlcpy()
did not behave like that. Instead, it also used to always wipe the
remainder of the string, similar to what strncpy() would do.

True, if we do

  nla_strlcpy(obj->link.name, tb[IFLA_IFNAME], IFNAMSIZ);

then we might want to clear the remainder and don't care about the
overhead of writing up to 14 bytes unnecessarily... However, actually
all callers of nla_strlcpy() either operate on a buffer that is already
pre-inialized with zero, or they really don't care about the
uninitialized memory after the string. So this was nowhere the desired
behavior.

Change nla_strlcpy() to not wipe the remainder of the buffer, so it behaves
mostly like strlcpy()/g_strlcpy() and as one would expect.

Add nla_strlcpy_wipe(), which on top of it also clears the remaining
buffer. In that aspect, it bears some similarities with strncpy(), but it
differs in other regards from strncpy (always NUL terminating and
returning the srclen). Yes, the name nla_strlcpy_wipe() is maybe
unfamiliar to the user, but it really is like nla_strlcpy() with the
addition to clear the buffer. That seems simple enough to understand
based on the name.

Note that all existing callers of nla_strlcpy() do not care about
clearing the memory, and the change in behavior is fine for them.
2023-02-28 12:08:06 +01:00
Thomas Haller
d73a5d692b
platform/netlink: assert for valid string in nla_get_string() 2023-02-28 12:08:06 +01:00
Etienne Champetier
0decc027ba
platform/trivial: fix route type name (unavailable -> unreachable)
Fixes: 766349879e ('platform/trivial: add code comments for NMPGlobalTracker')
2023-02-28 11:29:59 +01:00
Etienne Champetier
fb03dbacd8
doc: fix route type name (unavailable -> unreachable)
Fixes: 1cc3d00cb7 ('libnm/doc: list route attributes in `man nm-settings-nmcli`')
2023-02-28 11:28:58 +01:00
Thomas Haller
93b94a6151
libnm: drop _NMConnectionForEachSecretFunc from public headers
It was always a private typedef. Not meant to be used.  This was left
over since commit e46d484fae ('libnm: hide NMSetting types from public
headers')
2023-02-27 14:01:09 +01:00
Thomas Haller
599fe234ea
cloud-setup: use nm_strv_dup_packed() in nm_http_client_poll_get()
No need to do a deep clone. The strv array is not ever modified and we
pack it together in one memory allocation.
2023-02-27 14:01:04 +01:00
Beniamino Galvani
933e8ea11c device: fix copy/paste error in nm-device-ip-tunnel.c
Fixes: 351c562491 ('devices: support VTI tunnels')
2023-02-27 13:38:40 +01:00
Thomas Haller
6dafe78088
platform: ensure ext-data is of expected type
We just lookup the link info by ifindex. There is no guarantee that that
ifindex is of the expected type, to have a suitable ext-data. Check for
that.

Fixes: a7d2cad67e ('platform/linux: add support for WPAN links')
2023-02-24 10:16:08 +01:00
Fernando Fernandez Mancera
81fbe0634e utils: rename NM_SETTINGS_AUTO_CONNECT_* to NM_SETTINGS_AUTOCONNECT_* 2023-02-23 09:12:43 +01:00
Fernando Fernandez Mancera
b73b34c3ee policy: track autoconnect retries per Device x Connection
Autoconnect retries are not being tracked by connection anymore. Now it
is tracked per Device x Connection. In addition, autoconnect might be
blocked for the connection due to no secrets or user requested.

All the properties tracking the retries and blocked time were move to
DevConData and the functions to manipulate them aswell. In NMPolicy the
logic didn't change very much. Instead of looking into the connection
when the device failed activation it looks for DevConData.
2023-02-23 09:12:37 +01:00
Fernando Fernandez Mancera
10c38eabb9 utils: move autoconnect_blocked_reason_to_string to NetworkManagerUtils
As this is going to be used by multiple components, let's move it to
NetworkManagerUtils.[ch]
2023-02-22 22:38:03 +00:00
Thomas Haller
dc1cf48b86 core: add support for tracking Device times Profile in NMManager
This will be used next, to track the per-device, per-profile autoconnect
state.
2023-02-22 22:38:03 +00:00
Thomas Haller
20f791d8fe core: expose accessors to NMManager in NMSettings, NMSettingsConnection, NMDevice
We should avoid using the NM_MANAGER_GET singleton. Everybody already
has a manager instance. Expose it and allow to use it.
2023-02-22 22:38:03 +00:00
Fernando Fernandez Mancera
b5e347b313 client/tests: adjust expected output for new order of replace-local-rule
Now replace-local-rule is under routing-rules and therefore expected
output need to be adjusted in tests.
2023-02-22 22:20:41 +00:00
Fernando Fernandez Mancera
f46512c54f libnmc-setting: place replace-local-rule under routing-rules
This affects the order in which properties are listed in `nmcli
connection show`. The replace-local-rule property should be after the
routing-rule property.
2023-02-22 15:09:45 +01:00
Wen Liang
cefe4a7885 libnm: adjust symbol versioning of deprecating NMActiveConnection Master property
The symbol "nm_active_connection_get_controller" was backported to
1.42.1+. Since 1.44 is not yet released, move the symbol from
libnm_1_44 to libnm_1_42_2, like it is on 1.42.2 release. That way, we
don't need to duplicate the symbol while 1.44 being forward compatible
with 1.42.2.
2023-02-22 08:59:13 -05:00
Thomas Haller
da3c9e470e
glib-aux/trivial: reword code comments about bad random fallback in "nm-random-utils.c" 2023-02-22 14:01:03 +01:00
Thomas Haller
d359a9a1e7
glib-aux: improve NM_FLAGS_{SET,UNSET,ASSIGN,ASSIGN_MASK}() macros
- add unused code which triggers a compiler check about compatible enum
  values.
2023-02-22 09:59:05 +01:00
Fernando Fernandez Mancera
28c27f3070 libnm: adjust symbol versioning for backporting replace-local-rule
NM 1.44 is not released yet and 1.42.2 will happen before 1.44.0, so we
can introduce the new API with version libnm_1_42_2 in both releases
without having duplicate symbols on 1.44.
2023-02-21 18:20:44 +01:00
Thomas Haller
a08214f60d
wwan: workaround missing mm_modem_3gpp_set_initial_eps_bearer_settings() API
This was introduced only in MM 1.10. This breaks build on Centos7.

Fixes: c52999ee90 ('wwan: Set initial EPS bearer settings')
2023-02-21 18:04:23 +01:00
Fernando Fernandez Mancera
d2ca44ffc6 all: add new "ipv[46].replace-local-rule" setting
This setting allows the user to remove the local route rule that is
autogenerated for both IPv4 and IPv6. By default, NetworkManager won't
touch the local route rule.
2023-02-21 15:36:38 +01:00
Fernando Fernandez Mancera
79611e4fcc platform: introduce function to globally track local route rule
The new function tracks local route rule in the GlobalTracker properly.
It also allow the developer to specify the untrack user tag.
2023-02-21 15:36:38 +01:00
Beniamino Galvani
4138be6a5a device: skip DNS resolution for tentative IPv6 addresses
A tentative IPv6 address can still fail DAD, so don't use it to
resolve the hostname via DNS. Furthermore, tentative addresses can't
be used to contact the nameserver and so the resolution will fail if
there is no other valid IPv6 address. Wait that the address becomes
non-tentative.
2023-02-21 13:46:55 +01:00
Beniamino Galvani
ac5325e96b nm-daemon-helper: log to stderr any error from getaddrinfo()
Print errors from getaddrinfo() to stderr so that they will be logged
by NM.
2023-02-21 13:46:55 +01:00
Beniamino Galvani
d65702803c core: print stderr from nm-daemon-helper
Currently the only way to return an error code from the daemon helper
is via the process exit code, but that is not enough to fully describe
an error from getaddrinfo(); in fact, the function returns a EAI_*
error code and when the value is EAI_SYSTEM, the error code is
returned in errno.

At the moment, any messages printed to stderr by the helper goes to NM
stderr; instead, we want to capture it and pass it through the logging
mechanism of NM, so that it can be filtered according to level and
domain.
2023-02-21 13:46:54 +01:00
Beniamino Galvani
7037aa66c6 device: improve logging for hostname-from-dns events
Improve logging:
 - log only when something changes
 - print the new resolver state, instead of the old one
 - rename state "in-progress" to "started"
 - log when the resolver state is reset due to DNS changes
2023-02-21 13:46:54 +01:00