Commit graph

26165 commits

Author SHA1 Message Date
Antonio Cardace
aefca972b6
core: add dependent multicast route configured by kernel for IPv6
Pre-generate the device multicast route in the local table that are configured
by kernel when an ipv6-address is assigned to an interface.

This helps NM taking into account routes that are not to be deleted
when a connection is reapplied on an interface.

https://bugzilla.redhat.com/show_bug.cgi?id=1821787
(cherry picked from commit cd89026c5f)
2020-07-09 11:42:04 +02:00
Antonio Cardace
f61e9a0011
platform: parse route type from netlink messages
https://bugzilla.redhat.com/show_bug.cgi?id=1821787
(cherry picked from commit 04878193f7)
2020-07-09 11:42:04 +02:00
Antonio Cardace
9120cfaf9c
utils: add 'unspecified' to nm_utils_route_type2str()
https://bugzilla.redhat.com/show_bug.cgi?id=1821787
(cherry picked from commit e3e7bdf96e)
2020-07-09 11:42:04 +02:00
Antonio Cardace
6e73e27622
platform: always display route type when calling nmp_object_to_string()
https://bugzilla.redhat.com/show_bug.cgi?id=1821787
(cherry picked from commit d67ad4c86b)
2020-07-09 11:42:00 +02:00
Beniamino Galvani
72d66fffac ppp: fix taking control of link generated by kernel
NetworkManager can't control the name of the PPP interface name
created by pppd; so it has to wait for the interface to appear and
then rename it. This happens in nm_device_take_over_link() called by
nm-device-ppp.c:ppp_ifindex_set() when pppd tells NM the ifindex of
the interface that was created.

However, sometimes the initial interface name is already correct, for
example when the connection.interface-name is ppp0 and this is the
first PPP interface created.

When this happens, nm_device_update_from_platform_link() is called on
the NMDevicePPP and it sets the device ifindex. Later, when pppd
notifies NM, nm_device_take_over_link() fails because the ifindex is
already set:

 nm_device_take_over_link: assertion 'priv->ifindex <= 0' failed

Make nm_device_take_over_link() more robust to cope with this
situation.

https://bugzilla.redhat.com/show_bug.cgi?id=1849386
(cherry picked from commit 75bc21c4cf)
2020-07-08 15:07:44 +02:00
Thomas Haller
2ced21c5b7
core: fix treating route metric zero of IPv6 routes special
Userspace cannot add IPv6 routes with metric 0. Trying to do that, will
be coerced by kernel to route metric 1024. For IPv4 this is different,
and metric zero is commonly allowed.

However, kernel itself can add IPv6 routes with metric zero:

  # ip -6 route show table local
  local fe80::2029:c7ff:fec9:698a dev v proto kernel metric 0 pref medium

That means, we must not treat route metric zero special for most cases.
Only, when we want to add routes (based on user configuration), we must
coerce a route metric of zero to 1024.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/563
(cherry picked from commit 1b408e243d)
2020-07-07 16:15:41 +02:00
Beniamino Galvani
db1363fcec initrd: merge branch 'bg/initrd-bootif'
https://bugzilla.redhat.com/show_bug.cgi?id=1853277
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/562
(cherry picked from commit fbac6217b1)
2020-07-06 09:59:56 +02:00
Beniamino Galvani
0cb5bec7ae initrd: write the hostname to stdout with --stdout
Don't try to open /run/NetworkManager/initrd when called with
--stdout, but instead write the hostname to the standard output.

Fixes: ff70adf873 ('initrd: save hostname to a file in /run')
(cherry picked from commit 5fa97d7796)
2020-07-06 09:59:33 +02:00
Beniamino Galvani
b8246ea367 initrd: fix generating default BOOTIF= connection
There is a bug when parsing a BOOTIF= without any existing
connection. The generated connection doesn't have wired setting and
later we try to access it:

 # nm-initrd-generator --stdout -- BOOTIF=01-50-50-00-9f-21-21
  (nm-initrd-generator:1546): libnm-CRITICAL **: ((libnm-core/nm-setting-wired.c:205)): assertion '<dropped>' failed
  (nm-initrd-generator:1546): GLib-GObject-CRITICAL **: g_object_set: assertion 'G_IS_OBJECT (object)' failed

Fix this.

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

Fixes: 25a2b6e14f ('initrd: rework command line parsing')
(cherry picked from commit 3023c70e4e)
2020-07-06 09:59:28 +02:00
Beniamino Galvani
5a0be027a8 initrd: fix generation of MTU and cloned-mac-address for masters
Setting a MTU or a cloned MAC for bonds/bridges/teams fails with:

 # nm-initrd-generator -- bond=bond0:eno1,eno2:mode=802.3ad
    ip=192.168.1.5::192.168.1.254:255.255.255.0:MyServer:bond0:none::01:02:03:04:05:06
    bootdev=bond0 nameserver=192.168.1.1

 <warn> cmdline-reader: 'bond' does not support setting cloned-mac-address

Fix this.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/460
(cherry picked from commit 79f70bf5d6)
2020-07-06 09:58:22 +02:00
Beniamino Galvani
f819a7cabf ovs: merge branch 'bg/ovs-mac-pt2'
https://bugzilla.redhat.com/show_bug.cgi?id=1852106
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/557
(cherry picked from commit 15492e6c50)
2020-07-06 09:52:11 +02:00
Beniamino Galvani
791a888cad device: don't reset the MAC without ifindex
nm_device_cleanup() can be called when the device no longer has an
ifindex. In such case, don't try to reset the MAC address as that
would lead to an assertion failure.

(cherry picked from commit 77b6ce7d04)
2020-07-06 09:51:34 +02:00
Beniamino Galvani
60d10b146d ovs: also set cloned MAC address via netlink
We already set the MAC of OVS interfaces in the ovsdb. Unfortunately,
vswitchd doesn't create the interface with the given MAC from the
beginning, but first creates it with a random MAC and then changes it.

This causes a race condition: as soon as NM sees the new link, it
starts IP configuration on it and (possibly later) vswitchd will
change the MAC.

To avoid this, also set the desired MAC via netlink before starting IP
configuration.

https://bugzilla.redhat.com/show_bug.cgi?id=1852106
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/483
(cherry picked from commit 47ec3d14d4)
2020-07-06 09:51:31 +02:00
Beniamino Galvani
7548c29a89 ovs: set MAC address on the bridge for local interfaces
When a user creates a ovs-interface with the same name of the parent
ovs-bridge, openvswitch considers the interface as the "local
interface" [1] and assigns the MAC address of the bridge to the
interface [2].

This is confusing for users, as the cloned MAC property is ignored in
some cases, depending on the ovs-interface name.

Instead, detect when the interface is local and set the MAC from the
ovs-interface connection in the bridge table.

[1] https://github.com/openvswitch/ovs/blob/v2.13.0/vswitchd/vswitch.xml#L2546
[2] https://github.com/openvswitch/ovs/blob/v2.13.0/vswitchd/bridge.c#L4744

(cherry picked from commit 5d4c8521a3)
2020-07-06 09:51:29 +02:00
Beniamino Galvani
5321490180 device: restart DHCP only for devices that are active or activating
do_sleep_wake() tries to restart DHCP for all devices, even ones that
are disconnecting. When a device is disconnecting, it still has a DHCP
client instance but we shouldn't restart it because it makes no sense;
and especially, the device could be already removed.

https://bugzilla.redhat.com/show_bug.cgi?id=1852612
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/561
(cherry picked from commit 2c50438987)
2020-07-06 09:39:53 +02:00
Thomas Haller
838777a891
ndisc/tests: fix assertion in "test-ndisc-fake.c"
First I wanted to fix

  test:ERROR:../src/ndisc/tests/test-ndisc-fake.c:373:test_preference_changed_cb: assertion failed (_a->timestamp == (data->timestamp1 + 3)): (9 == 10)

but that leads to a different failure:

  test:ERROR:../src/ndisc/tests/test-ndisc-fake.c:375:test_preference_changed_cb: assertion failed (_a->lifetime == (9)): (10 == 9)

Instead, the start and end times must match exact (in their duration),
we only allow them to be shifted by up to one second.

Fixes: 8209095ee1 ('ndisc/tests: relax the assertion in "test-ndisc-fake.c"')
(cherry picked from commit b2f03544a7)
2020-07-03 20:41:43 +02:00
Thomas Haller
75177f6967
ndisc/tests: relax the assertion in "test-ndisc-fake.c"
test:ERROR:../src/ndisc/tests/test-ndisc-fake.c:373:test_preference_changed_cb: assertion failed (_a->timestamp == (data->timestamp1 + 3)): (9 == 10)

(cherry picked from commit 8209095ee1)
2020-07-03 20:41:42 +02:00
Thomas Haller
0847ede1e3
cli: suppress "(unknown)" output in terse mode for device properties HWADDR and DRIVER
$ nmcli -f GENERAL.HWADDR device show ovsport0
  GENERAL.HWADDR: (unknown)

but:

  $ nmcli -f GENERAL.HWADDR --terse device show ovsport0
  GENERAL.HWADDR:

This is an API change of nmcli.

(cherry picked from commit 2a1e621704)
2020-07-03 15:09:26 +02:00
Thomas Haller
c624fa684c
cli: add nmc_meta_generic_get_str_i18n_null() helper
(cherry picked from commit 05a84be550)
2020-07-03 15:09:20 +02:00
Thomas Haller
b1a7eda71d
ndisc/tests: make assertion checks a macro and not a function in test-ndisc-fake
By having it a function, the assertion failure does not show the line
number of the origin. Make them a macro, so that we see where exactly it
failed.

(cherry picked from commit 3b896cc642)
2020-07-02 16:37:20 +02:00
Thomas Haller
49ec86092b
libnm: fix leak in nm_utils_is_json_object()
Fixes: 32f78ae6c3 ('libnm: expose nm_utils_is_json_object() utility function')
(cherry picked from commit 1cf11ccbca)
2020-07-01 15:48:10 +02:00
Thomas Haller
12e4a4a5df
modem: suppress deprecated warning from libmm for MM_MODEM_CAPABILITY_LTE_ADVANCED
On Ubuntu 20.10, we build against ModemManager 1.14.0 and get a compiler warning:

  ../src/devices/wwan/nm-modem-broadband.c: In function 'try_create_connect_properties':
  ../src/devices/wwan/nm-modem-broadband.c:492:2: error: 'MMModemCapabilityDeprecated' is deprecated [-Werror=deprecated-declarations]
    492 |  if (MODEM_CAPS_3GPP (ctx->caps)) {
        |  ^~

Suppress it.

An alternative would be to drop the flag entirely. It seems the flag
was never used (and never will be used). But if that's true, there is
little harm done checking it. If it's not true, we better keep checking
for older versions.

0cd76bf1c4
(cherry picked from commit 03dc759026)
2020-06-30 18:01:59 +02:00
Thomas Haller
e249262506
platform/tests: avoid test failures accepting route added signals
/route/ip6: NMPlatformSignalAssert: ../src/platform/tests/test-route.c:331, test_ip6_route(): failure to accept signal [0,2] times: ip6-route-changed-added ifindex 0 (3 times received)

(cherry picked from commit 3d542b55ed)
2020-06-30 18:01:58 +02:00
Thomas Haller
a32e0d7ce3
gitlab-ci: enable python black check in gitlab-ci
(cherry picked from commit 8c3ee4e857)
2020-06-29 09:26:43 +02:00
Thomas Haller
0ba2af495e
gitlab-ci: run checkpatch test against fedora:32 target
(cherry picked from commit 70f3ad6785)
2020-06-29 09:26:43 +02:00
Thomas Haller
a5d293c367
build: for signing use key from git's user.signingkey
(cherry picked from commit 53bb23b403)
2020-06-29 09:25:34 +02:00
Thomas Haller
326e0e8252
release: cleanup temporary release-branch and avoid prompt for ftpadmin install
(cherry picked from commit 0748bd989d)
2020-06-28 19:17:31 +02:00
Thomas Haller
29019eeb45
release: bump version to 1.25.91 (1.26-rc2) (development) 2020-06-28 19:03:43 +02:00
Thomas Haller
783e4086a9
release: fix "rc" release build and add option to suppress check for local branches
(cherry picked from commit 99f834842a)
2020-06-28 19:03:00 +02:00
Beniamino Galvani
2a9f5f25b2 NEWS: update 2020-06-28 18:37:09 +02:00
Thomas Haller
d4adb65fd6
release: fix RC_VERSION for release script
The release candidate -rc1 has version "1.y.90", -rc2 has "1.y.91", and so
on. Fix the script.

(cherry picked from commit 7f93fd8e7b)
2020-06-28 18:36:21 +02:00
Thomas Haller
a9247f6dd9
release: fix release script for "rc"
(cherry picked from commit 8e9e6fd024)
2020-06-28 18:08:25 +02:00
Beniamino Galvani
c3e8ec6717 platform: merge branch 'ac/local_route'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/526
(cherry picked from commit 3e21357888)
2020-06-28 17:47:54 +02:00
Antonio Cardace
5247e2f8f5 setting-ip-config: validate route attributes in verify()
It's better to verify these route attributes so that the user can be
notified early if something is not supported or invalid.

The downside is that some incorrect profiles (with invalid route attributes)
that previously would work since this commit will not anymore as
the incorrect bits don't get ignored but rejected instead.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/407
https://bugzilla.redhat.com/show_bug.cgi?id=1821787
(cherry picked from commit 7781f78435)
2020-06-28 17:47:35 +02:00
Antonio Cardace
c4528f221b platform: add support for local routes
Also update unit tests.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/407
https://bugzilla.redhat.com/show_bug.cgi?id=1821787
(cherry picked from commit 5d0d13f570)
2020-06-28 17:47:27 +02:00
Antonio Cardace
c7d61a53e5
NEWS: update
(cherry picked from commit cfe349b971)
2020-06-28 17:41:07 +02:00
Antonio Cardace
7018f20293
nmcs-gcp: merge branch 'ac/gcp_cloud_support'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/546
https://bugzilla.redhat.com/show_bug.cgi?id=1821787

(cherry picked from commit ccbae2422e)
2020-06-28 17:40:22 +02:00
Antonio Cardace
10abdedb1a
nmcs-gcp: add support for Google Cloud Platform load balancers
This add a provider implementation for GCP that when detected fetches
the ip addresses of configured internal load balancers.

Once this information is fetched from the metadata server it instructs
NetworkManager to add local routes for each found forwarded-ip.

https://bugzilla.redhat.com/show_bug.cgi?id=1821787
(cherry picked from commit a2b699f40f)
2020-06-28 17:40:22 +02:00
Antonio Cardace
8581038450
nmcs-main: support adding additional routes
This allows a provider to only add additional routes to the applied profile

https://bugzilla.redhat.com/show_bug.cgi?id=1821787
(cherry picked from commit 75a84677ca)
2020-06-28 17:40:21 +02:00
Antonio Cardace
23c11af7f5
nmcs-http: add param to GET API to set custom HTTP headers
https://bugzilla.redhat.com/show_bug.cgi?id=1821787
(cherry picked from commit 053bce438b)
2020-06-28 17:40:21 +02:00
Antonio Cardace
c8965f906e
main: remove unused argument
(cherry picked from commit 1095cef9a1)
2020-06-28 17:40:21 +02:00
Antonio Cardace
1f27c36288
nmcs: fix indentation
(cherry picked from commit d46da9072a)
2020-06-28 17:40:21 +02:00
Antonio Cardace
0d22e6b2fe
nm-shared-utils: add util to parse out lines from a string
https://bugzilla.redhat.com/show_bug.cgi?id=1821787
(cherry picked from commit aa5959a595)
2020-06-28 17:40:20 +02:00
Antonio Cardace
20a6fa7d1b
nmcs: add error message when a HTTP request times out
https://bugzilla.redhat.com/show_bug.cgi?id=1821787
(cherry picked from commit 3bd30f6064)
2020-06-28 17:40:20 +02:00
Antonio Cardace
b7d53f0d3a
nmcs-http: remove the timeout once expired
libcurl's documentation for CURLMOPT_TIMERFUNCTION requires the
application to install a non-repeating timer.

https://curl.haxx.se/libcurl/c/CURLMOPT_TIMERFUNCTION.html

So let's remove the GSource once expired.

Fixes: 69f048bf0c ('cloud-setup: add tool for automatic IP configuration in cloud')
(cherry picked from commit e09bd2339a)
2020-06-28 17:40:20 +02:00
Antonio Cardace
f5487645d8
nmcs-http: fix multiple HTTP request bug
Since just a single pointer is used to store the socket's GSource
if more than 1 consecutive request was done through the same
HTTP provider the 2nd request would clear the GSource associated to
the second request causing the 1st HTTP request to never complete
and end up in a expired timeout.

Use a hashtable instead so we can correctly track all requests.

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

Fixes: 69f048bf0c ('cloud-setup: add tool for automatic IP configuration in cloud')
(cherry picked from commit 427fbc85f0)
2020-06-28 17:40:13 +02:00
Beniamino Galvani
2b5ba370a6 device: clean up exported IP6 config when flushing addresses
After flushing addresses and routes, it's also necessary to update the
exported IP6 configuration.

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

Fixes: e302f5ff77 ('device: flush IP configuration of slaves during activation')
(cherry picked from commit 071104124b)
2020-06-28 17:00:03 +02:00
Thomas Haller
af3c8bcb45
core,libnm: merge branch 'th/kernel-cmdline-match'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/550

(cherry picked from commit d18d75f89c)
2020-06-26 13:33:42 +02:00
Thomas Haller
3ced486f41
libnm/match: extend syntax for match patterns with '|', '&', '!' and '\\'
For simple matches like match.interface-name, match.driver, and
match.path, arguably what we had was fine. There each element
(like "eth*") is a wildcard for a single name (like "eth1").

However, for match.kernel-command-line, the elements match individual
command line options, so we should have more flexibility of whether
a parameter is optional or mandatory. Extend the syntax for that.

- the elements can now be prefixed by either '|' or '&'. This makes
  optional or mandatory elements, respectively. The entire match
  evaluates to true if all mandatory elements match (if any) and
  at least one of the optional elements (if any).
  As before, if neither '|' nor '&' is specified, then the element
  is optional (that means, "foo" is the same as "|foo").

- the exclamation mark is still used to invert the match. If used
  alone (like "!foo") it is a shortcut for defining a mandatory match
  ("&!foo").

- the backslash can now be used to escape the special characters
  above. Basically, the special characters ('|', '&', '!') are
  stripped from the start of the element. If what is left afterwards
  is a backslash, it also gets stripped and the remainder is the
  pattern. For example, "\\&foo" has the pattern "&foo" where
  '&' is no longer treated specially. This special handling of
  the backslash is only done at the beginning of the element (after
  the optional special characters). The remaining string is part
  of the pattern, where backslashes might have their own meaning.

This change is mostly backward compatible, except for existing matches
that started with one of the special characters '|', '&', '!', and '\\'.

(cherry picked from commit 824ad6275d)
2020-06-26 13:33:41 +02:00
Thomas Haller
1149dff6a1
core/tests: add unit test for nm_utils_kernel_cmdline_match_check()
(cherry picked from commit fa56e52a4f)
2020-06-26 13:33:41 +02:00