Commit graph

34212 commits

Author SHA1 Message Date
Thomas Haller
a44489697d
all: merge branch 'th/platform-rt-prefsrc' (part 1)
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1550
2023-03-08 15:34:48 +01:00
Thomas Haller
5558498721
all: use c_list_is_empty_or_single() where appropriate 2023-03-08 15:34:47 +01:00
Thomas Haller
4733cf7460
std-aux: add c_list_is_empty_or_single() helper
Having a list with only one element is often interesting to know. For
example, if you are about to unlink an element, you may want to check
whether afterwards the list is empty.

Add c_list_is_empty_or_single() for that. It is probably more efficient than
plain c_list_length_is(list, 1) and also a better name.
2023-03-08 15:34:47 +01:00
Thomas Haller
84ac0bdf65
glib-aux: make _LOGT_ENABLED()/_LOGD_ENABLED() as G_UNLIKELY() 2023-03-08 15:34:47 +01:00
Thomas Haller
dc5ac4d83c
std-aux/trivial: add code comment to NM_IS_IPv4() 2023-03-08 15:34:46 +01:00
Lubomir Rintel
17935511a5 release: bump version to 1.43.3 (development) 2023-03-08 15:20:37 +01:00
Fernando Fernandez Mancera
1839e38e93 merge: branch 'ff/fix_networking_off'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1512
2023-03-08 14:50:08 +01:00
Fernando Fernandez Mancera
7f96d4d2cd devices: drop wrong assertion on parent when ifindex is not present
When creating a parent dependent device it can have software device as
parent without an ifindex. In that case, it will fail on an ssertion on
parent being missing.

In order to avoid this, we are handling the situation similar to what we
do for VLAN devices. NetworkManager will raise different error and block
the autoconnection instead of asserting.

This solves the assert error for the following commands:

```
nmcli connection add type macvlan ifname mv1 con-name mv1+ macvlan.parent dummy0 mode vepa
nmcli connection add type dummy ifname dummy0 con-name dummy0+ autoconnect no
```
2023-03-08 14:49:01 +01:00
Fernando Fernandez Mancera
5a9a7623c5 core: set STATE_REASON_CONNECTION_ASSUMED when waking up
Otherwise, external devices become managed and we clear IP addresses.
2023-03-08 14:49:01 +01:00
Fernando Fernandez Mancera
f00db8e15d device: always queue recheck_assume before making device managed
There were a few places where we did already this but there was one
place where we missed it, in nm-manager.c:do_sleep_wake(). Therefore,
the device end in DISCONNECTED state and did not assume the connection.
2023-03-08 14:49:01 +01:00
Fernando Fernandez Mancera
3d18c9c841 device: do cleanup type removed if sys-iface-state is REMOVED
When the state is DISCONNECTED is being set from a
configuring/configured state we might want to always DECONFIGURE the
interface (ifindex, ip addresses, routes..) except if the
sys-iface-state is REMOVED in that case we would like to remove it.
2023-03-08 14:49:01 +01:00
Lubomir Rintel
c739ebaf4b merge: branch 'lr/aws-ec2-idms2'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1547
https://bugzilla.redhat.com/show_bug.cgi?id=2151986
2023-03-08 12:09:13 +01:00
Thomas Haller
acd895e1f7
contrib: update history and hints in "nm-in-container.sh" script
Calling `nm-env-prepare.sh --prefix eth -i 1 && nmcli device connect eth1` has
a race, where NetworkManager didn't see the interface yet. Add a sleep.
2023-03-08 11:22:52 +01:00
Thomas Haller
0ebfffb5eb
libnm/docs: mention "ipv[46].dhcp-iaid=stable" to be affected by "connection.stable-id" 2023-03-08 09:04:32 +01:00
Lubomir Rintel
33ca7a0c83 nmcli: set LESSSECURE=1 (unless already set)
Apparently, the pager being able to execute commands takes some people
by surprpise, making their poor configuration choices have consequences.

Let's pray for some mercy on their souls with the LESSECURE variable,
which makes less less likely to conduct evil deeds.

Systemd also deals with this, but being systemd they make it as
complicated as possible. We just set it unconditionally, hoping nobody
wanted the extra functionality and they're in only for the scrolling.
If anyone minds they can just set LESSSECURE=0 and we'll leave it alone.

See also: SYSTEMD_PAGERSECURE in systemctl(1) manual.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1559
2023-03-07 20:12:00 +01:00
Lubomir Rintel
8b7e12c2d6 cloud-setup/ec2: start with requesting a IMDSv2 token
The present version of the EC2 metadata API (IMDSv2) requires a header
with a token to be present in all requests. The token is essentially a
cookie that's not actually a cookie that's obtained with a PUT call that
doesn't put anything. Apparently it's too easy to trick someone into
calling a GET method.

EC2 now supports IMDSv2 everywhere with IMDSv1 being optional, so let's
just use IMDSv2 unconditionally. Also, the presence of a token API can
be used to detect the AWS EC2 cloud.

https://bugzilla.redhat.com/show_bug.cgi?id=2151986
2023-03-07 13:54:08 +01:00
Lubomir Rintel
088bfd817a cloud-setup: document detect() and get_config() methods
Clarify that detect() needs to succeed before get_config().

I thought it's sort of common sense, but it's better to be explicit as
we're going to rely on that.
2023-03-07 13:54:03 +01:00
Lubomir Rintel
cd74d75002 cloud-setup: make nm_http_client_req() accept a method argument
We'll need to be able to issue PUT calls.
2023-03-07 13:54:03 +01:00
Lubomir Rintel
85ce088616 cloud-setup: rename get/Get identifiers to req and Req
We're going to extend those to issue methods other than GET.
Also, "request" would've been too long, "req" looks nicer.
2023-03-07 13:54:03 +01:00
Lubomir Rintel
ce225b2c06 cloud_setup: unexport nm_http_client_get()
It's not used anywhere.
2023-03-07 13:54:03 +01:00
Daniel Kolesa
97abbbb987
build: fix pretty() sed invocation portability in .ver script
The `\0` being used to refer to the whole match is a GNU
extension. On other implementations of sed, this will simply
replace the each matched line with `	0;`, resulting in symbols
being missing in the NetworkManager executable, which breaks the
wifi plugin and others.

Use `&` instead, which behaves as expected in all implementations.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1562
2023-03-07 08:02:22 +01:00
Fernando Fernandez Mancera
747d1100f5 merge: branch 'ff/new_bond_options'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1553
2023-03-06 17:44:31 +01:00
Fernando Fernandez Mancera
c6487c240c bonding: add support to ns_ip6_target option
This is the IPv6 equivalent of arp_ip_target option. It requires
arp_interval set and allow the user to specify up to 16 IPv6 addresses
as targets. By default, the list is empty.
2023-03-06 15:06:41 +01:00
Fernando Fernandez Mancera
426658b422 netlink: introduce nla_get_in6_addr() helper 2023-03-06 15:05:51 +01:00
Fernando Fernandez Mancera
6cde20fecc bonding: add support to lacp_active option
The valid values for this option are 0 (off) and 1 (on). By default the
value is 1 (on). Please notice that this option is only compatible with
802.3AD mode.
2023-03-06 15:05:46 +01:00
Fernando Fernandez Mancera
ddd2fd46b0 bonding: add support to arp_missed_max option
The new arp_missed_max option valid range is 0-255 where value 0 means
not set. Please notice that this option is not compatible with 802.3AD,
balance-tlb and balance-alb modes.
2023-03-06 15:04:54 +01:00
Fernando Fernandez Mancera
8dd18d91b2 platform: compare arp_ip_targets_num before arp_ip_target values
We must first check whether a->arp_ip_targets_num and
b->arp_ip_targets_num are identical. Otherwise, this accesses
potentially uninitialized values.

Fixes: f900f7bc2c ('platform: add netlink support for bond link')
2023-03-06 14:25:55 +01:00
Beniamino Galvani
ba4a9ea79a core: fix crash when reloading global dns configuration
When reloading the configuration and there is a global DNS
configuration without domains, NM crashes in global_dns_equal()
because `old->domains` and `new->domains` are both NULL. Fix that.

  Thread 1 "NetworkManager" received signal SIGTRAP, Trace/breakpoint trap.
  0  g_logv (log_domain=0x7fe81a2110be "GLib", log_level=G_LOG_LEVEL_CRITICAL, format=<optimized out>, args=<optimized out>) at ../glib/gmessages.c:1433
  1  g_log (log_domain=<optimized out>, log_level=<optimized out>, format=<optimized out>) at ../glib/gmessages.c:1471
  2  g_hash_table_size (hash_table=<optimized out>) at ../glib/ghash.c:2183
  3  g_hash_table_size (hash_table=<optimized out>) at ../glib/ghash.c:2181
  4  global_dns_equal (new=0xecc540, old=0xe618e0) at ../src/core/nm-config-data.c:1466
  5  nm_config_data_diff (old_data=old_data@entry=0xe60020, new_data=new_data@entry=0xe606a0) at ../src/core/nm-config-data.c:1946
  6  _set_config_data (self=0xe45810, new_data=0xe606a0, reload_flags=NM_CONFIG_CHANGE_CAUSE_SIGHUP) at ../src/core/nm-config.c:2923
  7  nm_config_reload (self=0xe45810, reload_flags=NM_CONFIG_CHANGE_CAUSE_SIGHUP, emit_warnings=emit_warnings@entry=1) at ../src/core/nm-config.c:2875
  8  nm_main_config_reload (signal=<optimized out>) at ../src/core/main.c:141
  9  sighup_handler (user_data=<optimized out>) at ../src/core/main-utils.c:26
  10 g_main_dispatch (context=0xe619e0) at ../glib/gmain.c:3444
  11 g_main_context_dispatch (context=0xe619e0) at ../glib/gmain.c:4162
  12 g_main_context_iterate.constprop.0 (context=0xe619e0, block=1, dispatch=1, self=<optimized out>) at ../glib/gmain.c:4238
  13 g_main_loop_run (loop=0xe5e310) at ../glib/gmain.c:4438
  14 main (argc=<optimized out>, argv=<optimized out>) at ../src/core/main.c:515

Fixes: 1f0d1d78d2 ('dns-manager: always apply options from [global-dns]')
2023-03-06 12:04:41 +01:00
Jordi Mas
308e224e8e po/ca: fixes to Catalan translation
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1556
2023-03-06 08:38:07 +01:00
Thomas Haller
54c23f440b
connectivity: avoid uninitialized variable warning in nm_connectivity_check_start()
In file included from ./src/libnm-std-aux/nm-default-std.h:102,
                   from ./src/libnm-glib-aux/nm-default-glib.h:11,
                   from ./src/libnm-glib-aux/nm-default-glib-i18n-prog.h:13,
                   from ./src/core/nm-default-daemon.h:11,
                   from src/core/nm-connectivity.c:8:
  src/core/nm-connectivity.c: In function ‘nm_connectivity_check_start’:
  ./src/libnm-std-aux/nm-std-aux.h:180:12: error: ‘reason’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
           if (expr)                      \
              ^
  src/core/nm-connectivity.c:1055:29: note: ‘reason’ was declared here
           const char         *reason;
                               ^~~~~~
2023-03-03 19:49:28 +01:00
Thomas Haller
40dd8bf93a
platform/tests: avoid accessing in_addr_t via NMIPAddr union
The compiler may dislike this:

      CC       src/core/platform/tests/libNetworkManagerTest_la-test-common.lo
    In function '_ip_address_add',
        inlined from 'nmtstp_ip4_address_add' at ../src/core/platform/tests/test-common.c:1892:5:
    ../src/core/platform/tests/test-common.c:1807:63: error: array subscript 'NMIPAddr {aka const struct _NMIPAddr}[0]' is partly outside array bounds of 'in_addr_t[1]' {aka 'unsigned int[1]'} [-Werror=array-bounds]
     1807 |                                                   peer_address->addr4,
          |                                                   ~~~~~~~~~~~~^~~~~~~
    ../src/core/platform/tests/test-common.c: In function 'nmtstp_ip4_address_add':
    ../src/core/platform/tests/test-common.c:1886:36: note: object 'peer_address' of size 4
     1886 |                        in_addr_t   peer_address,
          |                        ~~~~~~~~~~~~^~~~~~~~~~~~
    ...

Fixes: 06aafabf14 ('platform/test: add test adding IPv4 addresses that only differ by their peer-address')
2023-03-03 19:31:18 +01:00
Thomas Haller
d0732962d2
contrib: install more packages in "nm-in-container.sh" 2023-03-03 15:42:05 +01:00
Beniamino Galvani
06219dbcf9 merge: branch 'bg/dnsmasq-global-conf'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1555
2023-03-03 14:53:29 +01:00
Beniamino Galvani
f57a848da5 man: update documentation about global DNS configuration
Now the settings in the [global-dns] section are used *in addition* to
connection-specific ones. Only the global domains sections, when
valid, override connection settings. Update the man page to clarify
that.

Fixes: 1f0d1d78d2 ('dns-manager: always apply options from [global-dns]')
2023-03-03 14:06:24 +01:00
Beniamino Galvani
5c0a927e0f dnsmasq: process both global and per-device configuration
The global configuration now can be valid when there are no global
domains defined. The dnsmasq backend must process it and then, if
there is no global default domain, also process the per-connection
settings.

Fixes: 1f0d1d78d2 ('dns-manager: always apply options from [global-dns]')
2023-03-03 14:06:24 +01:00
Thomas Haller
713de313dc
contrib: add usage comment to "git-subtree-reimport.sh" 2023-03-03 13:45:31 +01:00
Thomas Haller
e94e759f3a
c-stdaux: re-import git-subtree for 'src/c-stdaux'
git subtree pull --prefix src/c-stdaux git@github.com:c-util/c-stdaux.git main --squash
2023-03-03 13:40:38 +01:00
Thomas Haller
a6ead14f33 Squashed 'src/c-stdaux/' changes from eceefe959250..699c20de4e81
699c20de4e81 c-stdaux: workaround warning "-Wunused-value" in c_internal_assume_aligned()
193444c22c09 c-stdaux: workaround compiler error with clang 3.4 and __builtin_assume_aligned()
ed5fee49a3ec build: prepare v1.4.0
615c52daed67 Merge pull request #14 from dvdhrm/pr/load
32462ddc2ea5 c-stdaux: add c_load*() helpers
5878375d81ba c-stdaux: add c_assume_aligned()

git-subtree-dir: src/c-stdaux
git-subtree-split: 699c20de4e81f4b15786cb170340a87f69483f3d
2023-03-03 13:40:38 +01:00
Beniamino Galvani
aa66472146 platform: fix test_link_set_properties()
The link object is no longer valid after the cache gets updated in
nm_platform_link_change().

Fixes: e02fd76d9f ('platform: support changing link properties')
2023-03-03 12:04:38 +01:00
Beniamino Galvani
992e39e048 merge: branch 'bg/link-setting'
https://bugzilla.redhat.com/show_bug.cgi?id=2158328
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1541
2023-03-03 11:52:24 +01:00
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