Commit graph

28746 commits

Author SHA1 Message Date
Ana Cabral
d84cb1c67b nm-initrd-generator: include man entry for rd.ethtool options
(cherry picked from commit 44a5bdabe9)
2021-08-17 15:21:58 -03:00
Ana Cabral
926b96a53c nm-initrd-generator: remove duplex option
(cherry picked from commit 750d35a6e3)
2021-08-17 15:21:58 -03:00
Thomas Haller
781142c67c
core: merge branch 'th/fix-addr-order-on-assume'
https://bugzilla.redhat.com/show_bug.cgi?id=1988751

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

(cherry picked from commit f76af50df3)
2021-08-17 19:58:51 +02:00
Thomas Haller
8e05b05135
nmcli/docs: better describe ipv[46].addresses in man nm-settings-nmcli
(cherry picked from commit 7aa4ad0fa2)
2021-08-17 19:58:51 +02:00
Thomas Haller
823b94290b
platform: capture NMIP[46]Config from platform with correct (reversed) order of IP addresses
Fix the order of IP addresses when assuming devices (service restart).

The order of IP addresses matters to kernel for selection of source IP
address.

If all other properties are equal ([1]), for IPv6, the address added *last*
will be preferred. That is the address you see *first*` in `ip -6 addr show`.
NMPlatform also preserves that order, so the address *first* is the most
important one.

On the other hand, in a connection profile, `ipv6.addresses` lists
addresses in increasing priority (the last address is the primary one).
That is for compatibility with initscripts, which iterates over the
list of addresses and calls `ip addr add` (meaning, the last address
will be added last and is thus preferred by kernel).

As the priority order in the profile is reversed, also the priority
order in NMIP[46]Config is reversed. Fix creating an NMIP[46]Config
instance from platform addresses to honor the priority.

This has real consequences. When restarting NetworkManager, the interface
stays up with the addresses configured in the right order. After
restart, the device gets assumed, which means that the NMIP[46]Config
instance from the connection is not yet set, only the config from the
platform gets synchronized. Previously the order was wrong, so during
restart the order of IP addresses was reverted.

[1] https://access.redhat.com/solutions/189153

https://bugzilla.redhat.com/show_bug.cgi?id=1988751
(cherry picked from commit c631aa48f0)
2021-08-17 19:58:50 +02:00
Thomas Haller
feaa4943a0
platform: add nmp_cache_iter_for_each_reverse() helper
(cherry picked from commit 9c99c948fd)
2021-08-17 19:58:50 +02:00
Thomas Haller
e60c52829c
glib-aux: clear iterator in nm_dedup_multi_iter_{next,prev}() at the end
It seems slightly nicer not to leave a dangling pointer at the
end of the iteration. Then you could do something like

    nm_dedup_multi_iter_init(&iter, head_entry);
    while (nm_dedup_multi_iter_next(&iter)) {

        if (some_condition())
            break;
    }
    if (!iter.current)
        printf("iterated to the end\n");

As nm_dedup_multi_iter_next() and nm_dedup_multi_iter_init() are inline
functions, the compiler should even be able to see that the initial
setting becomes unnecessary (the field will be initialized by the
first nm_dedup_multi_iter_next()). Likewise, the final clearing
of the field might also be optimized away at the end of the iteration
(if, as in the common case, the iterator is not accessed afterwards).

(cherry picked from commit 53070705b0)
2021-08-17 19:58:50 +02:00
Thomas Haller
1803370cb2
glib-aux: add nm_dedup_multi_iter_init_reverse() to iterate in reverse order
(cherry picked from commit 57a519cc03)
2021-08-17 19:58:50 +02:00
Thomas Haller
b1a7c71da7
udev: also react to "move" (and "change") udev actions in our rules
NetworkManager handles "add" and "move" actions the same way, by
tracking the "struct udev_device" instance.

Still, this means that also for move events, we need the right
attributes set.

See-also: https://github.com/openshift/sriov-network-operator/issues/414
(cherry picked from commit b57c1af814)
2021-08-16 19:23:07 +02:00
Ana Cabral
0271c71ec8 nm-initrd-generator: add kernel command line options ethtool autoneg, speed and duplex to configure NICs
Merge Request !941

(cherry picked from commit f06c89f5)
2021-08-12 15:57:43 -03:00
Thomas Haller
937171ba18
ifup: extend ifup/ifdown to be smarter about NetworkManager profiles
Now that NetworkManager on Fedora 33 and RHEL 9 no longer writes
ifcfg-rh files by default ([1]), ifup/ifdown became less useful.

Possibly users shouldn't use it and it would be fine that new-style profiles
(keyfile) no longer work with these commands. But this is deemed as too
disruptive for users.

Note that our previous ifup/ifdown compat scripts only honored the argument
to be part of the ifcfg filename. That was not what initscripts were doing,
which called `need_config()` function that searched also the contents of
the files. With this extension, ifup/ifdown gets smarter too, to better
guess what the user might have wanted.

Extend the script by making it smarter, and to work with connection profile
names.

With this extension we further solidify ifup/ifdown as part of NetworkManager
command line API. That is problematic, because these tools pollute the
$PATH, by not having a clear NM-specific name. Also, these scripts
should only exist on Fedora/RHEL, which makes their usage non-portable
to other distros.
Also, other distros already ship different tools with name ifup/ifdown.
Extending the use of these scripts is thus undesirable, as it furthers
distro-specific commands.

Still, these arguments seem to not hold and users need to be "helped".
As Fedora users cannot be expected to unlearn "ifup" today, there is no
reason to assume they could in a few years. This likely means we will
never get rid of these scripts.

Also, if we truly would make ifup/ifdown part of NetworkManager, then a better
implementation would be that nmcli honors being called with these names.
That is not done, because nmcli's implementation currently is not as
nice to make that extension trivial (as it should be). It also would
mean to embrace ifup/ifdown officially. A shell script works well enough
as a hack.

[1] https://fedoraproject.org/wiki/Changes/NetworkManager_keyfile_instead_of_ifcfg_rh

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

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/936
(cherry picked from commit 30e7400528)
2021-08-10 22:00:22 +02:00
Thomas Haller
55aa9eda0d
release: bump version to 1.32.9 (development) 2021-08-10 19:16:43 +02:00
Thomas Haller
921cfd8ef1
release: bump version to 1.32.8 2021-08-10 19:16:43 +02:00
Thomas Haller
c37f72acd3
glib-aux: fix thread-safe initialization in _nm_g_source_sentinel_get_init()
Fixes: ce7c28c514 ('glib-aux: add nm_g_source_sentinel_get() util')
(cherry picked from commit 2140bbf7f5)
2021-08-10 19:15:07 +02:00
Thomas Haller
ef3b773bc3
NEWS: update 2021-08-10 16:20:17 +02:00
Wen Liang
59633dbe11
aliyun: reuse ipv4 gateway address returned by metadata server
The default ipv4 gateway address of the VPC in Aliyun cloud is not the
first IP address in the CIDR subnet block, we should instead use the
ipv4 gateway address retrieved from the metadata server in
`_nmc_mangle_connection()`.

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

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

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
(cherry picked from commit 778e1f8493)
2021-08-09 17:16:07 +02:00
Ana Cabral
0e7d260852
.gitignore: include files used by eclipse-cdt IDE
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/957
(cherry picked from commit e6583941b1)
2021-08-06 20:19:47 +02:00
Beniamino Galvani
7730547721 device: store the original MTU before force-setting it
In case the MTU is force-set (e.g. for bridges), priv->mtu_initial and
priv->ip6_mtu_initial must be initialized before changing the MTU,
otherwise the wrong value will be restored on deactivation.

Fixes: e23798a5e5 ('bridge: force (hack)-set of the MTU when explicitly set in the profile')

https://bugzilla.redhat.com/show_bug.cgi?id=1973536
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/955
(cherry picked from commit 3f42e2005a)
2021-08-06 15:37:23 +02:00
Thomas Haller
780f89720d
firewalld: fix build error due to nm_utils_strdup_reset() 2021-08-06 14:43:35 +02:00
Thomas Haller
f915a43eb2
firewalld: merge branch 'th/firewalld-reloaded'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/949

(cherry picked from commit a9279d1e89)
2021-08-06 14:38:36 +02:00
Thomas Haller
d409a3c230
firewalld: listen to Reloaded signal and reconfigure firewall zones
During reload, firewalld drops the current runtime configuration.
NetworkManager should listen to that, and reconfigure the zones
that it cares about.

(cherry picked from commit 0f100abd85)
2021-08-06 14:38:35 +02:00
Thomas Haller
424535093c
firewalld: fix initialized_now argument for NMFirewalldManager's "state-changed" signal
(cherry picked from commit b2ed02dda9)
2021-08-06 14:38:35 +02:00
Thomas Haller
17312aa25c
firewalld: make D-Bus calls against unique name for firewalld service
As we keep track of the current name owner, use its unique name
for the D-Bus requests.

We also track when the name owner changes, so at the point when we make
the D-Bus call, the current name owner was still running. We should talk
to it directly. If at the same time, firewalld restarts, we go through
our usual tracking of the name owner and will retry -- but always
talking to the unique name.

(cherry picked from commit 3d949f98e4)
2021-08-06 14:38:35 +02:00
Thomas Haller
500c66551a
firewalld: track current name_owner in NMFirewalldManager
Not only track whether we have a name-owner, but also which.

(cherry picked from commit 9debc3d028)
2021-08-06 14:38:35 +02:00
Thomas Haller
78cc70feb3
firewalld: prefix firewalld logging messages with "firewalld"
It seems more apt than "firewall: ...".

(cherry picked from commit b55f95abfa)
2021-08-06 14:38:35 +02:00
Thomas Haller
a7a0404cb5
man: update URL for networkmanager.dev home page
(cherry picked from commit 7a39f1f7e7)
2021-08-03 14:58:08 +02:00
Thomas Haller
788c13c94f
release: bump version to 1.32.7 (development) 2021-07-28 18:00:18 +02:00
Thomas Haller
dd3f3cb9e5
release: bump version to 1.32.6 2021-07-28 18:00:18 +02:00
Thomas Haller
7521ede1ad
initrd: fix handling "ip=single-dhcp:..." in reader_parse_ip()
Fixes: bf7530ccc1 ('initrd: honor "ip=single-dhcp" option as alias for "dhcp"')
(cherry picked from commit 22d6be54f3)
2021-07-28 17:56:58 +02:00
Thomas Haller
404272b152
NEWS: update 2021-07-28 17:26:28 +02:00
Beniamino Galvani
2188c00ed4 merge: branch 'bg/rh1934122'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/862

(cherry picked from commit 2d879c1ac5)
2021-07-27 17:51:10 +02:00
Beniamino Galvani
72f6edb01d core: introduce device 'allowed-connections' property
Configuration can have [device*] and [connection*] settings and both
can include a 'match-device=' key, which is a list of device-specs.

Introduce a new 'allowed-connections' key for [device*] sections,
which specifies a list of connection-specs to indicate which
connections can be activated on the device.

With this, it becomes possible to have a device configuration like:

  [device-enp1s0]
  match-device=interface-name:enp1s0
  allowed-connections=except:origin:nm-initrd-generator

so that NM in the real root ignores connections created by the
nm-initrd-generator, and starts activating a persistent
connection. This requires also setting 'keep-configuration=no' to not
generate an assumed connection.

(cherry picked from commit bace14fe1f)
2021-07-27 17:51:10 +02:00
Beniamino Galvani
7ca6e9d687 core: add nm_utils_connection_match_spec_list()
Add function nm_utils_connection_match_spec_list() to check whether a
connection matches a spec list. Also document the supported syntax in
the man page.

(cherry picked from commit 604c611cd0)
2021-07-27 17:51:10 +02:00
Beniamino Galvani
1a0f7e1bd3 initrd: add a 'origin' user tag to connections
Introduce a user tag key to indicate where the connection comes
from. It would also be possible to have this as a standard property
(as 'connection.origin'), but since this information can be considered
'meta-data' I think the user setting is more appropriate.

(cherry picked from commit 86f22ce8ba)
2021-07-27 17:51:10 +02:00
Beniamino Galvani
165daca280 core: add 'keep-configuration' device configuration option
Add a new 'keep-configuration' device option, set to 'yes' by
default. When set to 'no', on startup NetworkManager ignores that the
interface is pre-configured and doesn't try to keep its
configuration. Instead, it activates one of the persistent
connections.

(cherry picked from commit df2fe15714)
2021-07-27 17:51:10 +02:00
Beniamino Galvani
a2f9e11942 manager: exit early in get_existing_connection()
Later the function will become more complex. Add a check to exit early
if the device can't assume connections.

(cherry picked from commit b1644fa826)
2021-07-27 17:51:09 +02:00
Beniamino Galvani
bd114483b2 core: add comments about assuming connections
(cherry picked from commit bb37e30867)
2021-07-27 17:51:09 +02:00
Beniamino Galvani
9b704bf4bf merge: branch 'bg/dhcp-filename-rh1979387'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/929

(cherry picked from commit eaacfd249c)
2021-07-27 09:44:28 +02:00
Beniamino Galvani
69cd16e458 core: persist the bootfile from DHCP
The bootfile location is needed by the anaconda dracut module; write
it to the device state file.

(cherry picked from commit 9a09c02012)
2021-07-27 09:44:28 +02:00
Beniamino Galvani
b77a5bb7b0 dhcp: nettools: parse the filename and the bootfile-name option
(cherry picked from commit 3c79944e15)
2021-07-27 09:44:28 +02:00
Beniamino Galvani
50e65f8ce4 n-dhcp4: add an accessor for the file name in the lease
The name of the boot file can be either in option 67 or in a field of
the DHCP header. Add an accessor for the one from the DHCP header.

(cherry picked from commit 6a1349c5fb)
2021-07-27 09:44:28 +02:00
Beniamino Galvani
a4acfef3aa n-dhcp4: fix n_dhcp4_client_lease_get_server_identifier()
N_DHCP4_E_MALFORMED is an internal error code, replace it with
N_DHCP4_E_INTERNAL. Also, remove extra spaces.

(cherry picked from commit be6997d127)
2021-07-27 09:44:28 +02:00
Beniamino Galvani
667f2a5d76 dhcp: add internal option for the boot file name
Add an internal option that specifies the boot file name from the DHCP
header. The option name 'filename' is the same as exposed by dhclient.

(cherry picked from commit 0994a444e5)
2021-07-27 09:44:28 +02:00
Beniamino Galvani
5f85f1631b dhcp: escape control characters in DHCP options
Control characters (DEL (=127) or those below 32) could cause undesired
effects when a client displays or parses DHCP options. Escape them.

(cherry picked from commit 0c10e4f8b6)
2021-07-27 09:44:28 +02:00
Beniamino Galvani
8481470557 initrd: support infiniband pkeys
Introduce a new "ib.pkey=<parent>.<pkey>" command line argument to
create a Infiniband partition.

The new connection has IPv4 and IPv6 enabled by default. Unlike for
VLANs, the generator doesn't create a connection for the parent
Infiniband interface.

See also: https://github.com/dracutdevs/dracut/pull/1538

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/884
(cherry picked from commit 9060c14ccf)
2021-07-27 09:08:11 +02:00
Thomas Haller
c880b9eab9
initrd: honor "ip=single-dhcp" option as alias for "dhcp"
This mode was added to network-legacy in [1]. NetworkManager anyway always
does DHCP in parallel, so this is basically an alias for "dhcp".
Note that network-legacy's "single-dhcp" will stop waiting for DHCP
once the first device gets an address. NetworkManager currently cannot
do that. While it runs DHCP in parallel, all devices need to settle
and there is no concept where completing one device makes the overall
"startup complete" process finish early. That could however be added.

Anyway, while not being exactly the same, it's still more useful to do
something similar instead of not working at all.

See-also: https://github.com/dracutdevs/dracut/pull/853
See-also: https://github.com/dracutdevs/dracut/pull/961
See-also: https://github.com/dracutdevs/dracut/pull/1048

[1] 4026cd3b01

(cherry picked from commit bf7530ccc1)
2021-07-23 11:09:01 +02:00
Thomas Haller
d2075ac770
core: merge branch 'th/external-routes-no-sync'
https://bugzilla.redhat.com/show_bug.cgi?id=1979192

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

(cherry picked from commit 4ad4db6cf1)
2021-07-21 10:09:10 +02:00
Thomas Haller
6ee7be690e
platform: don't add routes that are tracked as external routes
Due to something that really should be fixed, NetworkManager merges the routes
that it wants to configure, with the routes that are configured externally.
This includes a subtract and merge dance, which is wrong.

Anyway. If we are in nm_platform_ip_route_sync(), then we never want to
actively configure a route, that we only have in the list because it is
(or was) present on the interface.

Otherwise we have a problem. Note that we make a plan which
routes/addresses to add/remove before starting. So, if we start with an
IPv4 address configured in kernel, then there is also a corresponding
local route. We would track that local route as external.
During sync, we first remove the IP address, and kernel automatically
also removes the local route. However, as we already made the plan to
keep that route, NetworkManager would wrongly configure it again.

This should fix that bug. It is anyway wrong to even try to explicitly
configure a route, that is purely in the list as being external.

https://bugzilla.redhat.com/show_bug.cgi?id=1979192#c11
(cherry picked from commit 13d749942f)
2021-07-21 10:09:09 +02:00
Thomas Haller
d009ee54ec
platform: mark routes in NMPlatform cache as "external"
(cherry picked from commit 1f1c7b82fd)
2021-07-21 10:09:09 +02:00
Thomas Haller
ed30b717ae
core: preserve "is_external" route flag during _nm_ip_config_add_obj()
(cherry picked from commit a6649ef87b)
2021-07-21 10:09:09 +02:00