Commit graph

23051 commits

Author SHA1 Message Date
Beniamino Galvani
ade9864366 wifi: allow reapply when the seen-bssids property changed
wifi.seen-bssid is a synthetic read-only property that lists all the
bssids seen for that connection; it should be ignored during a
reapply.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/243
(cherry picked from commit 8cd8a5fbed)
(cherry picked from commit 81cc4ddb1a)
2019-09-13 14:31:47 +02:00
Beniamino Galvani
d6c3d9c9dc core: fix adding objects to NMIPConfig with @append_force
If the @append_force argument is set and the object is already in the
list, it must be moved at the end.

Fixes: 22edeb5b69 ('core: track addresses for NMIP4Config/NMIP6Config via NMDedupMultiIndex')
(cherry picked from commit 8b121c7048)
(cherry picked from commit 52241748e8)
2019-08-28 16:19:31 +02:00
Beniamino Galvani
eb56d48c0b core: add test to show nm_ipX_config_replace() bug
Add test to show a wrong result of ip_ipX_config_replace() due to a
bug in _nm_ip_config_add_obj(). When an address is added to the tail
of the index and another address with the same id already exists, the
existing object is left at the same place, breaking the order of
addresses.

(cherry picked from commit 24741bff8b)
(cherry picked from commit ebaf890057)
2019-08-28 16:19:30 +02:00
Thomas Haller
b629570a75 bluetooth: fix leak in get_managed_objects_cb()
Fixes: 1ae5d53354 ('bluez: add support for BlueZ 5')
(cherry picked from commit 25571bb639)
(cherry picked from commit 6118f808d9)
2019-08-23 13:19:11 +02:00
Piotr Drąg
21ebc6488a po: update Polish (pl) translation
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/237
2019-08-12 11:36:39 +02:00
Beniamino Galvani
05319cb391 modem: fix memory leak
Fixes: 9b935fad9b ('modem: don't use GAsyncResult pattern for disconnecting modem')
(cherry picked from commit 22cd9e754b)
(cherry picked from commit 47c772354e)
2019-08-06 09:17:40 +02:00
Beniamino Galvani
7f532e9ab5 libnm-core: fix ifcfg-rh variable name for DHCPv6 hostname
Fixes: 2852b50945 ('ifcfg-rh: add DHCPV6_HOSTNAME and DHCPV6_SEND_HOSTNAME vars')
(cherry picked from commit 657b8b31b0)
(cherry picked from commit df5d76b0dc)
2019-08-05 16:03:09 +02:00
Thomas Haller
8bcfda364e wireguard: fix use-after free in _peers_remove()
(cherry picked from commit 85c26341a2)
(cherry picked from commit a3f9ab473b)
2019-08-03 12:28:51 +02:00
Thomas Haller
52dcdc98e8 libnm: fix leak in NMSettingWireGuard's update_one_secret()
(cherry picked from commit eea8bbd9ae)
(cherry picked from commit 8f2e3d1439)
2019-08-03 11:30:26 +02:00
Thomas Haller
134ccb4a17 core/lldp: minor cleanup in _lldp_attr_*()
- use nm_g_variant_unref_floating()

- rename _lldp_attr_take_str_ptr() to _lldp_attr_set_str_take().
  The new name has the same "_lldp_attr_set_" prefix as other setters.
  Also, with the previous name it is unclear why it takes a "str-ptr".

- setting the same attribute multiple times, ignores all but the first
  value. Avoid cloning the string in that case, and explicitly choose
  the set or take function.

(cherry picked from commit 0fbb54839e)
(cherry picked from commit d84d1db39e)
2019-08-01 15:22:00 +02:00
Thomas Haller
5233a02e28 core/lldp: fix memleak in _lldp_attr_take_str_ptr()
Valgrind complains:

  ==26355== 32 bytes in 2 blocks are definitely lost in loss record 2,829 of 6,716
  ==26355==    at 0x4838748: malloc (vg_replace_malloc.c:308)
  ==26355==    by 0x483AD63: realloc (vg_replace_malloc.c:836)
  ==26355==    by 0x4F6AD4F: g_realloc (in /usr/lib64/libglib-2.0.so.0.6000.6)
  ==26355==    by 0x4F87B33: ??? (in /usr/lib64/libglib-2.0.so.0.6000.6)
  ==26355==    by 0x4F87B96: g_string_sized_new (in /usr/lib64/libglib-2.0.so.0.6000.6)
  ==26355==    by 0x2D66E1: nm_utils_buf_utf8safe_escape (nm-shared-utils.c:1911)
  ==26355==    by 0x4113B0: lldp_neighbor_new (nm-lldp-listener.c:676)
  ==26355==    by 0x412788: process_lldp_neighbor (nm-lldp-listener.c:882)
  ==26355==    by 0x4135CF: lldp_event_handler (nm-lldp-listener.c:931)
  ==26355==    by 0x422CDB: lldp_callback (sd-lldp.c:50)
  ==26355==    by 0x4235F9: lldp_add_neighbor (sd-lldp.c:166)
  ==26355==    by 0x423679: lldp_handle_datagram (sd-lldp.c:189)
  ==26355==    by 0x423C8B: lldp_receive_datagram (sd-lldp.c:235)
  ==26355==    by 0x2F887A: source_dispatch (sd-event.c:2832)
  ==26355==    by 0x2FAD43: sd_event_dispatch (sd-event.c:3245)
  ==26355==    by 0x2D9237: event_dispatch (nm-sd.c:51)
  ==26355==    by 0x4F64EDC: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.6000.6)
  ==26355==    by 0x4F6526F: ??? (in /usr/lib64/libglib-2.0.so.0.6000.6)
  ==26355==    by 0x4F655A2: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.6000.6)
  ==26355==    by 0x140932: main (main.c:465)
  ==26355==

(cherry picked from commit ece270ea5f)
(cherry picked from commit 273f0b5416)
2019-08-01 15:21:59 +02:00
Beniamino Galvani
a1f39b69e0 ovs: don't release slaves on quit
An OVS bridge and its slaves can continue to work even after NM has
quit. Keep the interface enslaved when the @configure argument of
device->release_slave() is FALSE, which happens on quit and in other
circumstances when we don't really want to release the slave from its
master.

https://bugzilla.redhat.com/show_bug.cgi?id=1733709
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/215
(cherry picked from commit ccd4be4014)
2019-08-01 09:40:16 +02:00
Beniamino Galvani
e066ac5545 merge: branch 'bg/ovs-restart-part2-rh1733709'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/216

https://bugzilla.redhat.com/show_bug.cgi?id=1733709
(cherry picked from commit 5f668b81d3)
(cherry picked from commit 0581a53a46)
2019-08-01 09:38:09 +02:00
Beniamino Galvani
f6a90b899a device: fix releasing slaves
Not all masters type have a platform link and so it's wrong to check
for it to decide whether the slave should be really released. Move the
check to master devices that need it (bond, bridge and team).

OVS ports don't need the check because they don't call to platform to
remove a slave.

https://bugzilla.redhat.com/show_bug.cgi?id=1733709
(cherry picked from commit 57e3734b6c)
(cherry picked from commit ec1b5fb019)
2019-08-01 09:37:45 +02:00
Beniamino Galvani
511ef27d5e device: check platform link compatibility when setting nm-owned flag
We set nm-owned to indicate whether a software device was created by
NM or it was pre-existing. When checking the existence, we must verify
also whether the link type is compatible with the device, otherwise it
is possible to match unrelated interfaces. For example, when checking
for the existence of an ovs-bridge (which is not compatible with any
platform link) we could match a unrelated platform link with the same
name.

https://bugzilla.redhat.com/show_bug.cgi?id=1733709
(cherry picked from commit 3cb4b36261)
(cherry picked from commit cb20d0791a)
2019-08-01 09:35:22 +02:00
Thomas Haller
d69b4b3e70 NEWS: fix typo 2019-07-26 09:36:37 +02:00
Thomas Haller
a3e51a74aa policy-routing: take ownership of externally configured rules
IP addresses, routes, TC and QDiscs are all tied to a certain interface.
So when NetworkManager manages an interface, it can be confident that
all related entires should be managed, deleted and modified by NetworkManager.

Routing policy rules are global. For that we have NMPRulesManager which
keeps track of whether NetworkManager owns a rule. This allows multiple
connection profiles to specify the same rule, and NMPRulesManager can
consolidate this information to know whether to add or remove the rule.

NMPRulesManager would also support to explicitly block a rule by
tracking it with negative priority. However that is still unused at
the moment. All that devices do is to add rules (track with positive
priority) and remove them (untrack) once the profile gets deactivated.

As rules are not exclusively owned by NetworkManager, NetworkManager
tries not to interfere with rules that it knows nothing about. That
means in particular, when NetworkManager starts it will "weakly track"
all rules that are present. "weakly track" is mostly interesting for two
cases:

  - when NMPRulesManager had the same rule explicitly tracked (added) by a
    device, then deactivating the device will leave the rule in place.

  - when NMPRulesManager had the same rule explicitly blocked (tracked
    with negative priority), then it would restore the rule when that
    block gets removed (as said, currently nobody actually does this).

Note that when restarting NetworkManager, then the device may stay and
the rules kept. However after restart, NetworkManager no longer knows
that it previously added this route, so it would weakly track it and
never remove them again.

That is a problem. Avoid that, by whenever explicitly tracking a rule we
also make sure to no longer weakly track it. Most likely this rule was
indeed previously managed by NetworkManager. If this was really a rule
added by externally, then the user really should choose distinct
rule priorities to avoid such conflicts altogether.

(cherry picked from commit 15b1304477)
2019-07-25 10:29:16 +02:00
Thomas Haller
a55467a334 libnm: accept special table names for policy-routing
The tables "main", "local", and "default" have well known names.
Accept them as aliases when parsing the string representation of
the rule.

Note that iproute2 also considers /etc/iproute2/rt_tables for table
names. In particular, that allows a user to re-map the well-known names
like "main" to a different table. We never honor that file, and "main"
always means table 254.

Note that this only affects how we parse the string representation for
rules. As the representation is neither unique nor enforced to be normalized,
being more graceful here is no problem.

The point is of course that the user possibly has existing iproute2
scripts that use such keyword. This makes it simpler to copy & paste
the rule.

(cherry picked from commit 70b23c7979)
2019-07-25 10:29:02 +02:00
Lubomir Rintel
747021681b release: bump version to 1.18.3 (development) 2019-07-25 09:57:25 +02:00
Lubomir Rintel
b77764a9cd release: bump version to 1.18.2 2019-07-24 13:33:39 +02:00
Lubomir Rintel
9d948f5f14 release: update NEWS 2019-07-24 13:32:45 +02:00
Lubomir Rintel
cbf5d13584 dispatcher: tolerate lack of connection path
If the dispatcher is being invoked because the connection was removed
(e.g. device going down), it doesn't have a path or a filename anymore.
Don't abort in such cases.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/205
(cherry picked from commit 0c62445853)
2019-07-24 13:32:45 +02:00
Lubomir Rintel
23d244dee1 all: codespell fixes
Codespel run with the same arguments as described in
commit 58510ed566 ('docs: misc. typos pt2').

(cherry picked from commit 3c6644db32)
2019-07-24 13:32:45 +02:00
Lubomir Rintel
c628a15ada initrd/tests: add some more variations of possible BOOTIF= variables
Test the form with a hwtype and color-separated as well as
hyphen-separated.

(cherry picked from commit 93859d8ffd)
2019-07-24 08:45:38 +02:00
Lubomir Rintel
5a565659fa initrd: skip ethernet hwtype in BOOTIF
Dracut documents the BOOTIF argument to be a MAC address and so we
accept one in any of the conventions we recognize. However, the PXE boot
loaders like to prepend a "01-" to denote an ethernet hardware type.
Accept that too.

https://bugzilla.redhat.com/show_bug.cgi?id=1726240
(cherry picked from commit 2952953a48)
2019-07-24 08:45:37 +02:00
Lubomir Rintel
be01ba6d98 initrd/tests: ensure that nameserver= setting affects the correct connection
(cherry picked from commit 39d5c8c12f)
2019-07-24 08:45:37 +02:00
Lubomir Rintel
0d9a62c25e initrd: don't create a default connection if there's already one
Certain arguments (such as "nameserver") don't specify a connection they
apply to and using them would generate a default ethernet connection.
This is probably not the right thing to do.

(cherry picked from commit 6da2058237)
2019-07-24 08:45:37 +02:00
Lubomir Rintel
24c3a0c88f initrd/tests: ensure we accept a prefix in place of an IPv4 mask
(cherry picked from commit 77540b2a7c)
2019-07-24 08:45:37 +02:00
Lubomir Rintel
fe803a577c initrd: allow specifying the net mask in form of a prefix
This is not documented in dracut.cmdline(7), however it seems to have
worked and has users and Red Hat even seems to recommend this (thanks to
Dan Horak for the pointers):

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/installation_guide/chap-installer-booting-ipl-s390
https://bugzilla.redhat.com/show_bug.cgi?id=1725872
(cherry picked from commit 390d79079e)
2019-07-24 08:45:37 +02:00
Lubomir Rintel
c0b2950282 initrd: remove an accidental backspace
(cherry picked from commit 920e59016f)
2019-07-24 08:45:37 +02:00
Lubomir Rintel
d023155894 initrd: fix error reporting on bad netmask
It says the address is bad, but what is wrong is the mask.

(cherry picked from commit 4b097e314e)
2019-07-24 08:45:37 +02:00
Thomas Haller
57048338ee platform/netlink: mark nested netlink attribute with NLA_F_NESTED
Kernel 5.2 is adding stricter checking for netlink messages.
In particular, for certain API it checks now that NLA_F_NESTED flag is
set for nested attributes ([1]).

Note that libnl3 does not ever set this flag, and since our netlink
implementation is copied from there, certain netlink messages are now
rejected as invalid.

On the other hand, libmnl always adds this flag ([2]). So we should do that
as well.

In particular, this affects the WireGuard netlink API causing request
from NetworkManager to be rejected ([3]).

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b424e432e770d6dd572765459d5b6a96a19c5286
[2] https://git.netfilter.org/libmnl/tree/src/attr.c?id=5937dfcb0185f5cb9cf275992ea701ec4e619d9c#n535
[3] https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/212

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/210
(cherry picked from commit 7811d1c187)
2019-07-23 14:45:09 +02:00
Marco Trevisan (Treviño)
64ed96fb5f device: free temporary typename with iface variable
To create a disambiguated name for some Bluetooth devices we use its type name
with iface, however this value is allocated but never free'd when passed to
g_strdup_printf.

So use instead a temporary variable and free it once done.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/208

Fixes: 8bbda5cdff
(cherry picked from commit b621aba5c2)
2019-07-22 08:31:17 +02:00
Thomas Haller
f6088582bb libnm,core: support more "arp_validate" bond options
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/networking/bonding.txt?id=22051d9c4a57d3b4a8b5a7407efc80c71c7bfb16#n306

https://bugzilla.redhat.com/show_bug.cgi?id=1730793
(cherry picked from commit b8e9a62f2a)
2019-07-18 14:20:38 +02:00
Thomas Haller
09f37d5bd4 device: fix reapplying changes to connection ID and UUID
4 properties are not really relevant for an already activated connection
or it makes not sense to change them. These are connection.id, connection.uuid,
connection.autoconnect and connection.stable-id.

For convenience, we allow to reapply these. This way, one can take
a different setting (e.g. with a different connection.id or
connection.uuid) and reapply them, but such changes are silently
ignored.

However this was done wrongly. Instead of reverting the change to the new
applied connection, we would change the input connection.

This is bad, for example with

  nmcli connection up uuid cb922f18-e99a-49c6-b200-1678b5070a82
  nmcli connection modify cb922f18-e99a-49c6-b200-1678b5070a82 con-name "bogus"
  nmcli device reapply eth0

the last re-apply would reset the settings-connection's connection ID to
what was before, while accepting the new name on the applied-connection
(while it should have been rejected).

Fixes: bf3b3d444c ('device: avoid changing immutable properties during reapply')

(cherry picked from commit adb51c2a7f)
2019-07-18 12:20:39 +02:00
Thomas Haller
44e4ed1e95 core: fix mangling static IPv6 routes in nm_ip6_config_merge_setting()
https://bugzilla.redhat.com/show_bug.cgi?id=1727193

Fixes: 433d2f8659 ('core: merge IPv4 and IPv6 version of _nm_ip_config_merge_route_attributes()')
(cherry picked from commit a8fa015a4e)
2019-07-09 14:35:05 +02:00
Beniamino Galvani
4150dd8c43 ifcfg-rh: fix memory leak reading infiniband setting
(cherry picked from commit c045267837)
2019-07-04 11:55:20 +02:00
Beniamino Galvani
5ca888d693 device: ppp: check that connection has a PPPoE parent
NMDevicePPP only handles connections with the pppoe.parent property
set. match_connection() already checks this when we creating a new
device. We should also perform the same check in
check_connection_compatible().

Fixes: 6c3195931e ('core: implement activation of PPP devices')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/203
(cherry picked from commit 17f4a1e794)
2019-07-03 17:59:00 +02:00
Beniamino Galvani
9fe7ef6ca3 clients: fix printing hexadecimal enum values
Use the 'x' conversion specifier for hexadecimal numbers.

Fixes: f53218ed7c ('cli: add property type for enum and showcase for ipv6.addr-gen-mode'):
(cherry picked from commit 420554a72e)
2019-06-27 17:14:52 +02:00
Beniamino Galvani
7f239eff44 device: set IPv6 token only when necessary
Setting the IPv6 token triggers a new router solicitation from kernel
and so we should avoid when not strictly necessary.

https://mail.gnome.org/archives/networkmanager-list/2019-May/msg00004.html
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/179
(cherry picked from commit e4ce9bd7af)
2019-06-26 09:17:41 +02:00
Beniamino Galvani
52c886a6d7 cli: fix crash on autocompletion
@connections is NULL when doing autocompletion. Fixes the following:

 $ nmcli --complete-args con monitor ""
  help
  id
  uuid
  path
  filename
  ...
  Segmentation fault (core dumped)

Fixes: 4b3297271e ('cli: rework connection handling for multiple results')

https://bugzilla.redhat.com/show_bug.cgi?id=1716948
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/177
(cherry picked from commit 6a3bb90ad4)
2019-06-20 10:43:58 +02:00
Beniamino Galvani
591837d6f5 device: fix matching parent device by connection UUID
We must compare the UUID with the one on the *parent* device.

Also, simplify the checks to only return TRUE at the end of function.

Fixes: 27c281ac5a ('device: deduplicate match_parent()')

https://bugzilla.redhat.com/show_bug.cgi?id=1716438
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/176
(cherry picked from commit 3c54b5eb2b)
2019-06-20 10:40:56 +02:00
Beniamino Galvani
45d47a680b connectivity: merge branch 'bg/concheck-issue181'
Don't start connectivity check on unconfigured devices.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/181
(cherry picked from commit 4dce38c37f)
2019-06-20 10:28:48 +02:00
Thomas Haller
aa055239a2 Revert "Coerce connectivity "LIMITED" to "NONE" when device is disconnected"
NMConnectivity can now distinguish between LIMITED and NONE connectivity
and it does so based on whether IP addresses and routes are configured.

Previously, NMConnectivity would not differenciate between limited and
no connectivity, which is why NMDevice added some additional logic on top
to coerce LIMITED to NONE (if the device is not logically connected).

But note that the connectivity state (whether a network is reachable on
an interface) depends on what is configured in kernel and whether the
internet is reachable on that interface. It does not depend on the
logical device state.

On the other hand, whether the device is configured in a manner to have
connectivity depends on the logical state of the device (as NetworkManager
is configuring the device).

So, in many cases, the logical state and the connectivity state agree now,
but for the right reasons.

This reverts commit 4c4dbcb78d.

(cherry picked from commit 5a416a9da1)
2019-06-20 10:28:28 +02:00
Thomas Haller
a842280dbe connectivity: make platform argument to nm_connectivity_check_start() optional
The platform is used to detect whether to skip the connectivity check right away.
It should be an optional argument, so one could avoid this pre-check.

(cherry picked from commit b626baa313)
2019-06-20 10:28:26 +02:00
Thomas Haller
3c2886f447 connectivity: simplify passing result to idle handler
(cherry picked from commit 19c957f091)
2019-06-20 10:28:24 +02:00
Thomas Haller
28540a8eb8 connectivity: remove unused error varialbe in _idle_cb()
(cherry picked from commit 4001aee370)
2019-06-20 10:28:23 +02:00
Beniamino Galvani
7f937ecece device: don't start connectivity check on unconfigured devices
If the interface has no carrier, no addresses or no routes there is no
point in starting a connectivity check on it because it will fail.
Moreover, doing the check on a device without routes causes the
addition of a negative entry in the ARP table for each of the
addresses associated with the connectivity check host; this can lead
to poor network performances.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/181
(cherry picked from commit 91d447df19)
2019-06-20 10:28:21 +02:00
Beniamino Galvani
28c3692023 libnm-core: fix conversion to json of team watcher flags
Team watcher flags are boolean objects: persist them as such and not
as strings.

Fixes: e59878ce19
https://bugzilla.redhat.com/show_bug.cgi?id=1720153
2019-06-17 09:33:33 +02:00
Beniamino Galvani
3423629ff0 cli: don't wait for connection change on update failure
When saving a connection, we wait the connection-changed signal before
proceeding to ensure that the remote connection is up to date.
However, no signal is emitted if the update fails and so we shouldn't
wait for it.

Fixes: a370faeb59 ('cli: wait for changed signal after updating a connection'):

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/124
https://bugzilla.redhat.com/show_bug.cgi?id=1702203
(cherry picked from commit 2d347e7e17)
2019-06-14 17:22:08 +02:00