Commit graph

21203 commits

Author SHA1 Message Date
Thomas Haller
20f4c68fc6 core: fix checking multi-connect flag in nm_manager_get_best_device_for_connection()
We should not check @sett_conn, but @connection.

Fixes: 09719bc479
(cherry picked from commit 45913c11df)
2018-10-17 15:54:03 +02:00
Thomas Haller
559e9a79d9 core: improve selection of device when activating profile on any device
With

  $ nmcli connection up "$PROFILE" ifname "$DEVICE"

it's clear that the user means the particular device. That also
is taken as a indication to make $DEVICE as managed, in case it was
unmanaged before. So, this command implies a previous

  $ nmcli device set $DEVICE managed yes

On the other hand, if the user just issues

  $ nmcli connection up "$PROFILE"

without a particular device, then we should prefer devices which
are marked as managed instead of unmanaged once.

Likewise, we should consider the device's state when selecting
a device. This means, when activating a profile which is activatable on
multiple devices, it will now prefer devices which are not already
active. The exception to this is that if the profile itself is already
active (and multi-connect "single"), then it will prefer to re-activate
the profile on the same device. This was done previously already. What's
new is that if the the profile is not multi-connect "single", the said
exception no longer applies, and we prefer to activate the profile on a
hitherto unactivated device.

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

https://github.com/NetworkManager/NetworkManager/pull/232
(cherry picked from commit 09719bc479)
2018-10-17 15:53:36 +02:00
Lubomir Rintel
d7d085a88d po: update from Red Hat translators
https://bugzilla.redhat.com/show_bug.cgi?id=1608323
2018-10-16 16:30:11 +02:00
Thomas Haller
8c24119859 ndisc: merge branch 'th/ndisc-addr-lifetime'
https://github.com/NetworkManager/NetworkManager/pull/228

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/57
https://bugs.launchpad.net/ubuntu/+source/network-manager/+bug/1796622

(cherry picked from commit 3baa016f89)
2018-10-13 17:39:32 +02:00
Thomas Haller
036d1f56ea ndisc: don't update dad_counter for addresses in router config
I am not sure, we ever call complete_address() for router-configurations.
Maybe not, so the dad-counter is never incremented and does not matter either.

If we however do, then we certainly want to preserve the DAD counter
when the address is already tracked.

(cherry picked from commit 8c6629b356)
2018-10-13 17:39:15 +02:00
Thomas Haller
8e2ccd3921 ndisc: fix updating address lifetime on Router Announcement according to RFC4862
This is a denial-of-service protection, where a malicious router
advertisement can expire the addresses.

See-also: 6554550f35
See-also: https://tools.ietf.org/search/rfc4862#section-5.5.3

https://bugs.launchpad.net/ubuntu/+source/network-manager/+bug/1796622
(cherry picked from commit 27be3e0338)
2018-10-13 17:39:15 +02:00
Thomas Haller
fe60843232 ndisc: handle integer overflows better for lifetime handling
we use get_expiry() to compare two lifetimes. Note, that previously,
it would correctly truncate the calculated expiry at G_MAXINT32-1.

However, that means, that two different lifetimes that both lie
more than 68 years in the future would compare equal.

Fix that, but extending the range to int64, so that no overflow
can happen.

(cherry picked from commit b086535cb7)
2018-10-13 17:39:15 +02:00
Thomas Haller
3cecb4d018 ndisc: minor refactoring loop in nm_ndisc_add_address()
No change in behavior. Just don't do so much work inside
the deeper nesting of the loop.

(cherry picked from commit 9d0a138ef0)
2018-10-13 17:39:15 +02:00
Thomas Haller
ac5669633c ndisc: only generate address interface identifer after checking existing prefix
RFC4862 5.5.3, points d) and e) make it clear, that the list of
addresses should be compared based on the prefix.

  d)  If the prefix advertised is not equal to the prefix of an
    address configured by stateless autoconfiguration already in the
    list of addresses associated with the interface (where "equal"
    means the two prefix lengths are the same and the first prefix-
    length bits of the prefixes are identical), and if the Valid
    Lifetime is not 0, form an address (and add it to the list) by
    combining the advertised prefix with an interface identifier of
    the link as follows:

That means, we should not initialize the interface identifier first
(via complete_address()) and then search for the full address.

See-also: https://tools.ietf.org/search/rfc4862#section-5.5.3
(cherry picked from commit 23c417854a)
2018-10-13 17:39:15 +02:00
Thomas Haller
e0e698e463 ndisc: ensure we skip unspecified IPv6 address in ndisc_set_router_config()
Later, nm_ndisc_add_address() asserts that the address is not an
unspecified address. Skip it, just to be sure.

(cherry picked from commit 700b04d0de)
2018-10-13 17:39:15 +02:00
Thomas Haller
eff9e161cb ndisc: ignore addresses with preferred lifetime larger than lifetime
Previously, we would coerce the value so that preferred is the same
as lifetime. However, RFC4862 5.5.3.c) says:

  c)  If the preferred lifetime is greater than the valid lifetime,
    silently ignore the Prefix Information option.  A node MAY wish to
    log a system management error in this case.

See-also: https://tools.ietf.org/search/rfc4862#section-5.5.3
(cherry picked from commit 43c3c259c8)
2018-10-13 17:39:15 +02:00
Thomas Haller
8ee0ca8cce ndisc: merge branch 'th/ndisc-fixes'
https://github.com/NetworkManager/NetworkManager/pull/219

(cherry picked from commit 6e41d79067)
2018-10-13 17:36:44 +02:00
Thomas Haller
2e12660dd4 ndisc: always emit changed signal if an ndisc parameter changes
Note how the nm_ndisc_add_*() return a boolean to indicate whether
anything changes. That is taken to decide whether to emit a changed
signal.

Previously, we would not consider all fields which are exposed
as public API.

Note that nm-ip6-config.c would care about the lifetime of NMNDiscAddress.
For that, nm_ndisc_add_address() would correctly consider a change of
the lifetime as relevant. So, this was for the most part not broken.
However, for example nm_ndisc_add_route() would ignore changes to the
gateway.

Always signal changes if anything changes at all. It's more correct
and robust.

(cherry picked from commit 98ec56c670)
2018-10-13 17:36:15 +02:00
Thomas Haller
bd41719f95 ndisc/trivial: move code
(cherry picked from commit 4f78d82fcd)
2018-10-13 17:35:49 +02:00
Thomas Haller
6631debaa3 ndisc: abort handling IO in event_ready() if we are unable to switch namespace
It should never happen that we are unable to switch the namespace.
However, in case it does, we cannot just return G_SOURCE_CONTINUE,
because we will just endlessly trying to process IO without actually
reading from the socket.

This shouldn't happen, but the instance is hosed and something is
very wrong. No longer handle the socket to avoid an endless loop.

(cherry picked from commit d444fcde34)
2018-10-13 17:35:32 +02:00
Thomas Haller
efb9e2bc6b ndisc: keep NMNDisc instance alive while processing IO in event_ready()
event_ready() calls ndp_callall_eventfd_handler(), which invokes
our own callback, which may invoke change notification.

At that point, it's not guaranteed that the signal handler won't
destroy the ndisc instance, which means, the "struct ndp" gets destroyed
while invoking callbacks. That's bad, because libndp is not robust
against that.

Ensure the object stays alive long enough.

(cherry picked from commit 9aa628cedb)
2018-10-13 17:34:54 +02:00
Thomas Haller
a3c73e783b ndisc: first reschedule timeout before invoking change event in check_timestamps()
It's just ugly to invoke external code in the middel of an operation.
You never know, whether the handler won' unref the ndisc instance.

(cherry picked from commit 1f856b7cb3)
2018-10-13 17:34:41 +02:00
Lubomir Rintel
d947c27fd7 all: remove \n endings from log calls
The extra newlines look bad when logging to the console.

https://github.com/NetworkManager/NetworkManager/pull/223
(cherry picked from commit 02958bba80)
2018-10-12 14:36:22 +02:00
Lubomir Rintel
514aadd75b release: update NEWS 2018-10-12 12:59:16 +02:00
Lubomir Rintel
7e793bf3b4 devices/olpc: don't assert we're waiting for companion on device_added_cb()
We're hooking the signal on construction, but we only queue a pending
action on reaching UNAVAILABLE state. The signal could fire in between:

  <info>  [1539282167.9666] manager: (msh0): new 802.11 OLPC Mesh device (/org/freedesktop/NetworkManager/Devices/4)
  <info>  [1539282168.1440] manager: (wlan0): new 802.11 WiFi device (/org/freedesktop/NetworkManager/Devices/5)
  <info>  [1539282168.1831] device (msh0): found companion WiFi device wlan0
  <warn>  [1539282168.2110] device (msh0): remove_pending_action (1): 'waiting-for-companion' not pending
  file src/devices/nm-device.c: line 13966 (<dropped>): should not be reached

https://github.com/NetworkManager/NetworkManager/pull/229
(cherry picked from commit 08225c5e96)
2018-10-12 12:57:12 +02:00
Thomas Haller
00f14736e6 wwan: don't assume DNS info is always available for IPv6
See also "5df024f57a wwan: don't assume DNS info is always available"
which does the same for IPv4.

(cherry picked from commit cec7ade86c)
2018-10-12 00:18:09 +02:00
Thomas Haller
ec1c512e40 platform/netlink: fix overrun in attribute iteration in nla_ok()
See-also: 123dc07bcc
See-also: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=1045b03e07d85f3545118510a587035536030c1c
(cherry picked from commit c295d45a3b)
2018-10-10 12:16:52 +02:00
Lubomir Rintel
8f1631c679 devices/olpc: correct the signal handler arguments
Commit 631ca806 ("devices/wifi: flip meaning of scanning allowed
signal") added a "periodic" argument, but the OLPC companion handler was
not adjusted. Fix it now.

https://github.com/NetworkManager/NetworkManager/pull/222

Fixes: 631ca80692
(cherry picked from commit aa0e395530)
2018-10-09 20:23:59 +02:00
Beniamino Galvani
628c976f54 core: merge branch 'bg/preserve-routes-down-rh1626004'
https://bugzilla.redhat.com/show_bug.cgi?id=1623740
https://bugzilla.redhat.com/show_bug.cgi?id=1626004

https://github.com/NetworkManager/NetworkManager/pull/210
(cherry picked from commit b1a6454b6c)
2018-10-08 18:10:59 +02:00
Beniamino Galvani
ce2d403530 device: don't remove routes when the interface is down
In update update_ext_ip_config() we remove from various internal
configurations those addresses and routes that were removed externally
by users.

When the interface is brought down, the kernel automatically removes
routes associated with it and so we should not consider them as
"removed by users".

Instead, keep them so that they can be restored when the interface
comes up again.

(cherry picked from commit f069c98cc9)
2018-10-08 18:10:26 +02:00
Beniamino Galvani
bd79e67c55 ip-config: add @intersect_routes argument to intersect functions
In some cases we want to intersect two IP configurations without
considering routes.

(cherry picked from commit 8f07b3ac4f)
2018-10-08 18:10:23 +02:00
Beniamino Galvani
81aaf0ff93 device: fix updating device information after link change
device_link_changed() can't use nm_device_update_from_platform_link()
to update the device private fields because the latter overwrites
priv->iface and priv->up, and so the checks below as:

  if (info.name[0] && strcmp (priv->iface, info.name) != 0) {

and:

  was_up = priv->up;
  priv->up = NM_FLAGS_HAS (info.n_ifi_flags, IFF_UP);
  ...
  if (priv->up && !was_up) {

never succeed.

Fixes: d7f7725ae8
(cherry picked from commit 46ed756112)
2018-10-08 18:10:17 +02:00
Beniamino Galvani
0b1ffdbdb5 core: improve nm_ip_config_dump()
Previously we had nm_ip{4,6}_config_dump() for debugging purposes, but
they were inconveniently printing to stdout and so the output was not
ordered in the journal.

Implement a unified nm_ip_config_dump() that logs through the usual
logging mechanism.

(cherry picked from commit 3b49d1075d)
2018-10-08 18:10:16 +02:00
Beniamino Galvani
3a6da57b16 libnm-core: fix other int comparisons in team setting
I forgot to update them when applying commit 72b4541771.

Fixes: 72b4541771
(cherry picked from commit 17a942b458)
2018-10-08 11:52:58 +02:00
Beniamino Galvani
faeda5fdbf merge: branch 'bg/covscan'
Some coverity fixes.

https://github.com/NetworkManager/NetworkManager/pull/220
(cherry picked from commit 0cb5c4f611)
2018-10-07 14:15:39 +02:00
Thomas Haller
1d718cd16f libnm-core: fix int comparisons in team setting
(cherry picked from commit 72b4541771)
2018-10-07 14:15:22 +02:00
Beniamino Galvani
c81d35d352 libnm-core: remove unneeded comparisons
a_gendata and b_gendata cannot be NULL. This makes coverity happy.

(cherry picked from commit d0f85092b9)
2018-10-07 14:15:20 +02:00
Beniamino Galvani
8fb85b1f5b shared/nm-utils: avoid a coverity warning
1. NetworkManager-1.14.0/shared/nm-utils/nm-shared-utils.c:1242: value_overwrite: Overwriting previous write to "ch" with value from "v".
 2. NetworkManager-1.14.0/shared/nm-utils/nm-shared-utils.c:1239: assigned_value: Assigning value from "++str[0]" to "ch" here, but that stored value is overwritten before it can be used.
 #  1237|   				if (ch >= '0' && ch <= '7') {
 #  1238|   					v = v * 8 + (ch - '0');
 #  1239|-> 					ch = (++str)[0];
 #  1240|   				}
 #  1241|   			}

Don't assign ch when it is going to be overwritten.

(cherry picked from commit e4154895ff)
2018-10-07 14:15:18 +02:00
Beniamino Galvani
8cbc08ce29 device: fix a wrong comparison
'i <= G_MAXINT' is always true.

(cherry picked from commit e3b9606b24)
2018-10-07 14:15:17 +02:00
Beniamino Galvani
6df6ed4483 dispatcher: fix shellcheck warnings
Prefer [ p ] && [ q ] as [ p -a q ] is not well defined.
And likewise, prefer [ p ] || [ q ] over [ p -o q ].

https://github.com/koalaman/shellcheck/wiki/SC2166
(cherry picked from commit 9e43821e17)
2018-10-07 14:15:16 +02:00
Beniamino Galvani
1d25a49485 libnm-core: use g_variant_type_equal() to compare variant types
Even if a direct pointer comparison should be fine, use the proper
function. GVariantType documentation says:

 "Two types may not be compared by value; use g_variant_type_equal()
 or g_variant_type_is_subtype_of()."

This also fixes coverity warnings.

(cherry picked from commit 27ab932a49)
2018-10-07 14:15:15 +02:00
Beniamino Galvani
da3e0af01a libnm-core: fix coverity warning
3. NetworkManager-1.14.0/libnm-core/nm-utils.c:4944: var_compare_op: Comparing "str" to null implies that "str" might be null.
 4. NetworkManager-1.14.0/libnm-core/nm-utils.c:4958: var_deref_op: Dereferencing null pointer "str".
 #  4956|
 #  4957|   	/* do some very basic validation to see if this might be a JSON object. */
 #  4958|-> 	if (str[0] == '{') {
 #  4959|   		gsize l;
 #  4960|

(cherry picked from commit 9b04b871a0)
2018-10-07 14:15:13 +02:00
Evgeny Vereshchagin
cd3aacefdd dhcp6: fix an off-by-one error in dhcp6_option_parse_domainname
==14==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x60200055fa9c at pc 0x0000005458f1 bp 0x7ffc78940d90 sp 0x7ffc78940d88
READ of size 1 at 0x60200055fa9c thread T0
    #0 0x5458f0 in dhcp6_option_parse_domainname /work/build/../../src/systemd/src/libsystemd-network/dhcp6-option.c:555:29
    #1 0x54706e in dhcp6_lease_set_domains /work/build/../../src/systemd/src/libsystemd-network/sd-dhcp6-lease.c:242:13
    #2 0x53fce0 in client_parse_message /work/build/../../src/systemd/src/libsystemd-network/sd-dhcp6-client.c:984:29
    #3 0x53f3bc in client_receive_advertise /work/build/../../src/systemd/src/libsystemd-network/sd-dhcp6-client.c:1083:13
    #4 0x53d57f in client_receive_message /work/build/../../src/systemd/src/libsystemd-network/sd-dhcp6-client.c:1182:21
    #5 0x7f0f7159deee in source_dispatch /work/build/../../src/systemd/src/libsystemd/sd-event/sd-event.c:3042:21
    #6 0x7f0f7159d431 in sd_event_dispatch /work/build/../../src/systemd/src/libsystemd/sd-event/sd-event.c:3455:21
    #7 0x7f0f7159ea8d in sd_event_run /work/build/../../src/systemd/src/libsystemd/sd-event/sd-event.c:3512:21
    #8 0x531f2b in fuzz_client /work/build/../../src/systemd/src/fuzz/fuzz-dhcp6-client.c:44:9
    #9 0x531bc1 in LLVMFuzzerTestOneInput /work/build/../../src/systemd/src/fuzz/fuzz-dhcp6-client.c:53:9
    #10 0x57bec8 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/libfuzzer/FuzzerLoop.cpp:570:15
    #11 0x579d67 in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool*) /src/libfuzzer/FuzzerLoop.cpp:479:3
    #12 0x57dc92 in fuzzer::Fuzzer::MutateAndTestOne() /src/libfuzzer/FuzzerLoop.cpp:707:19
    #13 0x580ca6 in fuzzer::Fuzzer::Loop(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, fuzzer::fuzzer_allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) /src/libfuzzer/FuzzerLoop.cpp:838:5
    #14 0x55e968 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/libfuzzer/FuzzerDriver.cpp:764:6
    #15 0x551a1c in main /src/libfuzzer/FuzzerMain.cpp:20:10
    #16 0x7f0f701a082f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
    #17 0x41e928 in _start (/out/fuzz-dhcp6-client+0x41e928)

https://github.com/systemd/systemd/pull/10200
b387d3c132
(cherry picked from commit 7cb7cffc49)
2018-10-05 01:41:38 +02:00
Yu Watanabe
0cec1cb93e dhcp6: check option length before reading values
Fixes oss-fuzz#10746
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=10746.

https://github.com/systemd/systemd/pull/10213
84452783b8
(cherry picked from commit 484e92e17f)
2018-10-05 01:41:37 +02:00
Beniamino Galvani
1c3722b6a7 build: meson: merge branch 'bg/rpm-meson'
Add meson support to RPM spec file.

https://github.com/NetworkManager/NetworkManager/pull/212
(cherry picked from commit d6db262597)
2018-10-02 10:02:57 +02:00
Beniamino Galvani
c762160692 contrib/rpm: support building with meson
Add support for building with meson, enabled by '--with meson' so that
we can regularly test the whole build+test+install procedure with
meson. I compared the RPM contents of NM, NM-libnm, NM-libnm-devel
packages and they match the autotools ones. It's also faster:

  $ time contrib/fedora/rpm/build_clean.sh -g -Q -f

  real    3m54.239s
  user    11m15.000s
  sys     1m28.456s

  $ time contrib/fedora/rpm/build_clean.sh -g -Q -f -w meson

  real    3m9.938s
  user    9m5.225s
  sys     1m4.392s

(cherry picked from commit 295b9d5b81)
2018-10-02 10:02:39 +02:00
Beniamino Galvani
d04dd3385c contrib/rpm: remove duplicate documentation
In NetworkManager-libnm-devel we ship the same documentation in two
different places:

 /usr/share/doc/NetworkManager-libnm-devel
 /usr/share/gtk-doc/html/NetworkManager

Remove the former, which was added in commit e01c17523a.

Also, remove the same documentation from NetworkManager-glib-devel
since it's already present in NetworkManager-libnm-devel.

(cherry picked from commit 1f18783404)
2018-10-02 10:02:34 +02:00
Beniamino Galvani
4c9aa0ced0 build: meson: install ifcfg-rh files and directory
(cherry picked from commit 34ffd9fcab)
2018-10-02 10:02:32 +02:00
Beniamino Galvani
db6b9ca63b build: meson: fix install script
Fix directory paths and modes.

Fixes: 98b4a19a53
(cherry picked from commit 24fc3c54a3)
2018-10-02 10:02:29 +02:00
Beniamino Galvani
aeb7eb7376 build: meson: fix generation of api docs
We need to copy all introspection files to the same directory when
building the documentation.

Note that we only require Meson 0.44, but for the documentation at
least 0.46 is needed because of a new functionality of
gnome.gdbus_codegen(). In this way we can still build on Travis CI
(without documentation).

(cherry picked from commit dcfddeef7a)
2018-10-02 10:02:26 +02:00
Beniamino Galvani
4109ab8318 build: meson: ifcfg-rh plugin should not enable ibft
This is not the case with autotools.

(cherry picked from commit e22c7150e0)
2018-10-02 10:02:00 +02:00
Beniamino Galvani
8ac6aa4f97 merge: branch 'bg/meson-fixes'
https://github.com/NetworkManager/NetworkManager/pull/204
(cherry picked from commit c7c3acf280)
2018-10-02 10:00:54 +02:00
Beniamino Galvani
fb432eec25 travis: disable gtk-doc for meson builds
Introspection can't be enabled on travis due to a GLib bug [1].
Therefore, gtk-doc must be disabled as well.

[1] https://bugzilla.gnome.org/show_bug.cgi?id=774368

(cherry picked from commit 5af7d46be4)
2018-10-02 10:00:33 +02:00
Beniamino Galvani
6a815260db build: meson: GTK documentation requires introspection
(cherry picked from commit 84701c049c)
2018-10-02 10:00:27 +02:00
Beniamino Galvani
3711c31467 build: meson: fix computing NM exported symbols
The script didn't include all the symbols needed by plugins because
libNetworkManager.a, as built by meson, doesn't include symbols from
other static libraries that are linked in. Since we used
libNetworkManager.a to know which symbols are potentiall available
from NM, the result was an incomplete list.

Unfortunately, the only way to include the whole static library is to
create a dependency object and use 'link_whole', but this is only
available in meson >= 0.46. Since 'link_whole' is available for
executables in meson >= 0.40, create a fake executable and use that to
enumerate symbols.

Also add tests to check that plugins can be loaded correctly.

Fixes: dfa2a2b40c
(cherry picked from commit 19a718bc13)
2018-10-02 10:00:25 +02:00