Commit graph

17467 commits

Author SHA1 Message Date
Lubomir Rintel
452ec2956b po: import Japanese translation
From Red Hat translators. The master translation updated via Zanata.

https://bugzilla.redhat.com/show_bug.cgi?id=1382625
2017-05-29 17:11:49 +02:00
Francesco Giudici
2c0865db25 device: when setting back a device to managed, update internal sys state
Otherwise a device which was set as unmanaged (updated to the REMOVED
internal sys-state) will never update its own sys-state if later set
back as managed.
Manage either when setting explictly the device to managed either when
just upping a connection on an unmanaged device.

(cherry picked from commit adbf383628)
2017-05-26 16:10:26 +02:00
Francesco Giudici
3c7c273836 device: add the internal interface state to the state change log message
(cherry picked from commit 55b8ba4ddc)
2017-05-26 16:10:18 +02:00
Beniamino Galvani
3fefef8594 core: add configuration flag to choose slaves activation order
Commits 39d0559d9a ("platform: sort links by name instead of
ifindex") and 529a0a1a7f ("manager: sort slaves to be autoconnected
by device name") changed the order of activation of slaves. Introduce
a system-wide configuration property to preserve the old behavior.

https://bugzilla.redhat.com/show_bug.cgi?id=1452585
(cherry picked from commit 31656a066b)
2017-05-24 15:59:58 +02:00
Beniamino Galvani
6110b11235 device: release removed devices from master on cleanup
On cleanup, unconditionally release a device from its master if the
link is missing or it doesn't have a master, otherwise the master
would later try to release the slave, hitting the following assertion:

 "nm_platform_link_release: assertion 'slave > 0' failed"
  #0  g_logv
  #1  g_log
  #2  g_return_if_fail_warning
  #3  nm_platform_link_release
  #4  release_slave
  #5  nm_device_master_release_one_slave
  #6  slave_state_changed
  #7  ffi_call_unix64
  #8  ffi_call
  #9  g_cclosure_marshal_generic
  #10 g_closure_invoke
  #11 signal_emit_unlocked_R
  #12 g_signal_emit_valist
  #14 _set_state_full
  #15 nm_device_state_changed
  #16 nm_device_unrealize
  #17 _platform_link_cb_idle
  #18 g_main_context_dispatch
  #19 g_main_context_dispatch
  #20 g_main_context_iterate
  #21 g_main_loop_run
  #22 main

Fixes: 9e8218f99a

https://bugzilla.redhat.com/show_bug.cgi?id=1448907
(cherry picked from commit 3355a2823b)
2017-05-24 13:44:46 +02:00
Thomas Haller
58b15abfb1 contrib/rpm: allow building devel RPMs without debug enabled
Since commit 1afbf948a0,
"build: use different defaults for snapshot builds",
configure would enable debugging options if the version
number is odd.

Hence, on the master branch it was no longer possible to
build an RPM without debugging enabled. Especially,

  ./contrib/fedora/rpm/build_clean.sh -g -W debug

would not work as one would expect.

(cherry picked from commit 22ad5422cf)
2017-05-24 10:35:21 +02:00
Thomas Haller
fb4b5001ac contrib/rpm: add option to build package with sanitizer
(cherry picked from commit 07036d731a)
2017-05-24 10:35:20 +02:00
Thomas Haller
06d3c95e4f clients: fix appending integer to result in nmc_property_set_bytes()
(cherry picked from commit d76c190dc7)
2017-05-23 16:10:46 +02:00
Beniamino Galvani
cc6c9468fc clients: fix setter for 802-1x.password-raw
The property is a GBytes, not a GByteArray.

https://bugzilla.gnome.org/show_bug.cgi?id=782836
(cherry picked from commit 30393ee236)
2017-05-23 16:00:33 +02:00
Lubomir Rintel
7851f1c595 bluetooth: unhook adapter properties callback when the adapter vanishes
https://bugzilla.redhat.com/show_bug.cgi?id=1454654
(cherry picked from commit 0aa2e0bad3)
2017-05-23 11:39:21 +02:00
Lubomir Rintel
390cfec792 device: capture the IP6 configuration on the IP interface
Fixes a crash with Bluetooth devices where the device is the BlueZ
device and iface stays 0 while the IP interface is the actual BNEP link.

https://bugzilla.gnome.org/show_bug.cgi?id=782545
(cherry picked from commit 30d06b2253)
2017-05-22 17:14:43 +02:00
Thomas Haller
54203d986f shared: refactor nm_utils_is_power_of_two() to return false for 0
Returning TRUE for zero makes no sense. Obviously, zero is not a power
of two.

Also, the function is used to check whether a number has only one bit
(flag) set, so, an alternative name would be "has-one-bit-set", which
also should return FALSE for zero. All callers didn't really care for
the previous meaning "has-at-most-one-bit-set".

This also avoids the issue of checking (x >= 0), which causes
-Wtype-limits warnings for unsigned types. Which was avoided
by doing (x == 0 || x > 0), which caused -Wlogical-op warning,
which then was avoided (x == 0 || (x > 0 && 1)). Just don't.

(cherry picked from commit a2663803c3)
2017-05-22 14:03:08 +02:00
Francesco Giudici
4f45f04d0f build: work around GCC -Wlogical-op for "nm_utils_is_power_of_two" macros
We recently added -Wlogical-op in our build process
(commit #41e7fca59762dc928c9d67b555b1409c3477b2b0).
Seems that old versions of gcc (4.8.x) will hit that warning with our
implementation of our "nm_utils_is_power_of_two" and
"test_nm_utils_is_power_of_two_do" macros.
Fool it just adding an always TRUE check.

(cherry picked from commit 7c2ecaa4e0)
2017-05-22 14:03:07 +02:00
Beniamino Galvani
4b6955095b device: fix capture of device config in ipX_config_merge_and_apply()
Use nm_device_get_ip_ifindex() to obtain the right ifindex for the
device. Fixes the following:

 nm_platform_ip4_address_get_all: assertion 'ifindex > 0' failed
 #0  _g_log_abort () from target:/lib64/libglib-2.0.so.0
 #1  g_logv () from target:/lib64/libglib-2.0.so.0
 #2  g_log () from target:/lib64/libglib-2.0.so.0
 #3  nm_platform_ip4_address_get_all (self=self@entry=0x1181020, ifindex=ifindex@entry=0) at src/platform/nm-platform.c:2640
 #4  nm_ip4_config_capture (platform=0x1181020, ifindex=ifindex@entry=0, capture_resolv_conf=capture_resolv_conf@entry=0) at src/nm-ip4-config.c:271
 #5  ip4_config_merge_and_apply (self=self@entry=0x1254a70, config=config@entry=0x0, commit=commit@entry=1) at src/devices/nm-device.c:5447
 #6  activate_stage5_ip4_config_commit (self=0x1254a70) at src/devices/nm-device.c:8299
 #7  activation_source_handle_cb (self=0x1254a70, family=family@entry=2) at src/devices/nm-device.c:4421
 #8  activation_source_handle_cb4 (user_data=<optimized out>) at src/devices/nm-device.c:4358
 #9  g_idle_dispatch () from target:/lib64/libglib-2.0.so.0
 #10 g_main_context_dispatch () from target:/lib64/libglib-2.0.so.0
 #11 g_main_context_iterate.isra () from target:/lib64/libglib-2.0.so.0
 #12 g_main_loop_run () from target:/lib64/libglib-2.0.so.0
 #13  main (argc=<optimized out>, argv=<optimized out>) at src/main.c:435

Fixes: a21b8882cc
(cherry picked from commit 6389d637a7)
2017-05-21 15:59:25 +02:00
Beniamino Galvani
cb5ba08f00 ifcfg-rh: omit empty next hop for routes in legacy format
Don't add "via (null)" if the next hop is missing.

https://bugzilla.redhat.com/show_bug.cgi?id=1452648
(cherry picked from commit af8aac9b54)
2017-05-19 17:45:46 +02:00
Thomas Haller
da2a02138d build: don't link static libraries multiple times
libnm-core.a should only be linked once in libnm.so. Previously,
it was linked twice, once as part of libnm-utils.a and once
directly in libnm.so.

Fixes: 8df944c7e4
(cherry picked from commit 5a67130e15)
2017-05-19 14:54:19 +02:00
Thomas Haller
23b5bdd843 build: don't install intermediate library libnm/libnm-utils.la
Fixes: 8df944c7e4
(cherry picked from commit 733160c862)
2017-05-19 14:14:45 +02:00
Thomas Haller
ac8e47f325 libnm: merge branch 'th/sanitize-non-utf8-rh1443114-pt2'
https://bugzilla.redhat.com/show_bug.cgi?id=1443114

(cherry picked from commit 9d2cdb80e6)
2017-05-19 13:17:10 +02:00
Thomas Haller
ea0fd21428 libnm: move fixup_desc_string() to nm-libnm-utils.c
(cherry picked from commit e255ad2a03)
2017-05-19 13:15:50 +02:00
Thomas Haller
1ebac60d22 libnm: add testable libnm/nm-libnm-utils.c file
Previously, internal parts of libnm were not testable.
Instead, add "libnm/nm-libnm-utils.c" and "libnm/libnm-utils.la"
to contain code that can be statically linked with a new
test "libnm/tests/test-general".

(cherry picked from commit 8df944c7e4)
2017-05-19 13:15:50 +02:00
Thomas Haller
aa60b77146 libnm: ignore phrases in fixup device description only when delimited by space
(cherry picked from commit 72104ea10a)
2017-05-19 13:15:50 +02:00
Thomas Haller
c22075dc98 libnm: fix device description in fixup_desc_string()
Fixes: b9e9f76165
(cherry picked from commit 12c881ad40)
2017-05-19 13:15:50 +02:00
Thomas Haller
71eb7b5c1e all: merge branch 'th/sanitize-non-utf8-rh1443114'
https://bugzilla.redhat.com/show_bug.cgi?id=1443114
https://bugzilla.redhat.com/show_bug.cgi?id=1451160
https://bugzilla.redhat.com/show_bug.cgi?id=1451286

(cherry picked from commit dfd72a623e)
2017-05-19 10:07:48 +02:00
Thomas Haller
d7b184d992 libnm: UTF-8 sanitize strings from UDev in NMDevice
(cherry picked from commit b9e9f76165)
2017-05-19 10:07:14 +02:00
Thomas Haller
3a96772918 device: sanitze UTF-8 values for D-Bus
ip link add name $'d\xccf\\c' type dummy

Use nm_utils_str_utf8safe_escape() to sanitize non UTF-8 sequences
before exposing them on D-Bus. The operation can be reverted client
side via nm_utils_str_utf8safe_unescape() or simply g_strcompress().

Note that this preserves all valid UTF-8 sequences as-is, with exception
of the backslash escape character and ASCII control characters. Thus, this
is a change in behavior for strings that contain such characters.

Note that nmcli is not changed to somehow unescape the string before
printing. As the string is not valid UTF-8 (or contains ASCII characters
that need escaping), they are not printable as-is, so unescaping before
printing makes little sense.

(cherry picked from commit 0870906540)
2017-05-19 10:07:14 +02:00
Thomas Haller
52105f27df shared: add nm_utils_str_utf8safe_*() API to sanitize UTF-8 strings
Use C-style backslash escaping to sanitize non-UTF-8 strings.
The functions are compatible with glib's g_strcompress() and
g_strescape().

The difference is only that g_strescape() escapes all non-printable,
non ASCII character as well, while nm_utils_str_utf8safe_escape()
-- depending on the flags -- preserves valid UTF-8 sequence except
backslash.

The flags allow to optionally escape ASCII control characters and
all non-ASCII (valid UTF-8) characters. But the option to preserve
valid UTF-8 (non-ASCII) characters verbatim, is what distinguishes
from g_strescape().

(cherry picked from commit df6d27b33a)
2017-05-19 10:07:14 +02:00
Thomas Haller
c3b180198f device: make UDI property construct-only
(cherry picked from commit e216d5eac0)
2017-05-19 10:07:14 +02:00
Thomas Haller
4ae14d3677 device: fix setting device's UDI property
Fixes: e8139f56c2
(cherry picked from commit 5eac18b58d)
2017-05-19 10:07:14 +02:00
Thomas Haller
822282754d libnm: don't cunescape \x00 encoding in nm_udev_utils_property_decode()
UDev never creates such invalid escape sequences. Anyway,
we cannot accept a NUL character at this point. Just take
the ill escape verbatim -- it should never happen anyway.

(cherry picked from commit c15eae92c0)
2017-05-19 10:07:14 +02:00
Thomas Haller
5eb11aa8ec libnm: fix unterminated NUL string when parsing UDev properties
This can result in trailing garbage (which fails UTF-8 validation
checks) or even worse, in read-out-of-bounds.

Fixes: 6808bf8195

https://bugzilla.redhat.com/show_bug.cgi?id=1443114
https://bugzilla.redhat.com/show_bug.cgi?id=1451160
https://bugzilla.redhat.com/show_bug.cgi?id=1451286
(cherry picked from commit 9594ee6e69)
2017-05-19 10:07:14 +02:00
Thomas Haller
29c86eda62 contrib/rpm: drop explicit dependency on libnl3 package
We already get a library dependency on

    libnl-3.so.200()(64bit)
    libnl-3.so.200(libnl_3)(64bit)

Drop the explicit package dependency, leaving only the
BuildRequires.

Also, all recent versions of libnl3 implement library versioning.

(cherry picked from commit 225f7e8602)
2017-05-19 09:14:23 +02:00
Thomas Haller
48e6a014e0 build: enable -Wlogical-op and -Wshift-negative-value compiler warning
(cherry picked from commit 41e7fca597)
2017-05-19 09:14:11 +02:00
Beniamino Galvani
bf28e0845f device: fix crash in ip6_config_merge_and_apply()
nm_ip6_config_capture() returns NULL for slaves. Fixes the following:

 nm_ip6_config_new_cloned: assertion 'NM_IS_IP6_CONFIG (src)' failed

 #0 g_logv () at /lib64/libglib-2.0.so.0
 #1 g_log () at /lib64/libglib-2.0.so.0
 #2 nm_ip6_config_new_cloned (src=0x0) at src/nm-ip6-config.c:2272
 #3 ip6_config_merge_and_apply (self=self@entry=0x200d8f0, commit=commit@entry=1) at src/devices/nm-device.c:6192
 #4 nm_device_bring_up (self=self@entry=0x200d8f0, block=block@entry=1, no_firmware=no_firmware@entry=0x0) at src/devices/nm-device.c:10369
 #5 _hw_addr_set (self=self@entry=0x200d8f0, addr=addr@entry=0x2095ea0 "6A:1C:00:2A:68:7C", operation=operation@entry=0x64f8ba "set", detail=detail@entry=0x67369d "restore") at src/devices/nm-device.c:13225
 #6 nm_device_hw_addr_set (self=self@entry=0x200d8f0, addr=addr@entry=0x2095ea0 "6A:1C:00:2A:68:7C", detail=detail@entry=0x67369d "restore", set_permanent=set_permanent@entry=0) at src/devices/nm-device.c:13255
 #7 release_slave (device=0x200d8f0, slave=0x1ef2990, configure=<optimized out>) at src/devices/nm-device-bond.c:463
 #8 nm_device_master_release_one_slave (self=self@entry=0x200d8f0, slave=slave@entry=0x1ef2990, configure=1, reason=reason@entry=NM_DEVICE_STATE_REASON_CONNECTION_REMOVED) at src/devices/nm-device.c:2041
 #9 slave_state_changed (slave=0x1ef2990, slave_new_state=NM_DEVICE_STATE_DEACTIVATING, slave_old_state=NM_DEVICE_STATE_ACTIVATED, reason=NM_DEVICE_STATE_REASON_CONNECTION_REMOVED, self=0x200d8f0)
     at src/devices/nm-device.c:3366
 ...

Fixes: a21b8882cc
(cherry picked from commit 1e78f50b8e)
2017-05-17 09:52:53 +02:00
Beniamino Galvani
bf5407992f device: update external configuration before commit
If the platform signaled that the external configuration changed (and
thus update_ipX_config() is scheduled) and we are doing a commit of
the new configuration, update priv->ext_ipX_config. Without this, the
commit will remove addresses added externally but not yet captured in
the external configuration.

https://bugzilla.redhat.com/show_bug.cgi?id=1449873
(cherry picked from commit a21b8882cc)
2017-05-16 11:42:48 +02:00
Beniamino Galvani
cbf5a776f7 dhcp: don't add route to DHCP4 server
This basically reverts commit 31fe84e467 "core: Add host route for
DHCP4 server if outside assigned subnet (bgo #721767)" because the
additional route added by NM does more harm than good.

First, the code does not consider routes pushed by the server and thus
it can add a route conflicting with the ones from the network
administrator.

Second, there is no specification on what a DHCP client should do when
the server is not reachable via unicast, and adding arbitrary logic
into the client is likely to break things in specific cases. If
network administrators want to make the DHCP server reachable from a
client in a different subnet, they should push proper routes with the
lease.

In any case, if the DHCP server is not reachable through unicast,
before the lease expiration (after timeout T2) the client will resort
to broadcast and so there won't be any network disruption; the renewal
will only happen at a later time.

Fixes: 31fe84e467

https://bugzilla.redhat.com/show_bug.cgi?id=1448987
(cherry picked from commit 36e97f5d7b)
2017-05-16 11:42:47 +02:00
Thomas Haller
8ca05e9fd2 device: merge branch 'th/device-carrier-wait-rh1450444'
https://bugzilla.redhat.com/show_bug.cgi?id=1450444

(cherry picked from commit f8316a536c)
2017-05-15 17:47:27 +02:00
Thomas Haller
51a1fc3cd9 device: fix delaying startup complete waiting for carrier
platform: signal: link changed: 2: eth0 <DOWN;broadcast,multicast> mtu ...
    ...
    device[0x7f90c29c64d0] (eth0): bringing up device
    ...
    platform: signal: link changed: 2: eth0 <UP,LOWER_UP;broadcast,multicast,up,running,lowerup> mtu ...
    ...
    device (eth0): link connected
    ...
    device[0x7f90c29c64d0] (eth0): add_pending_action (2): 'carrier wait'

Note how we schedule the pending action 'carrier-wait', although the device
already has carrier. That means, the pending action will not be removed
until timeout, 5 seconds later.

Avoid scheduling 'carrier-wait' if we already have carrier.

However, don't just add the pending action 'carrier-wait' only during
nm_device_bring_up(). Instead, always schedule the carrier_wait timeout.
This gives a grace period during which we keep setting 'carrier-wait' whenever
we have no carrier. This should prevent two cases:
  - during nm_device_bring_up() the platform state might not yet have
    caught up. If we don't add the pending action there, we will add
    it a moment later when carrier goes away.
  - bringing the interface up might cause carrier to get lost for a
    moment (flapping). If that happens within the timeout, also add the
    pending action.

(cherry picked from commit 9f874d166d)
2017-05-15 17:44:44 +02:00
Thomas Haller
3786e17c0f device: cleanup nm_device_set_carrier_from_platform()
nm_device_set_carrier_from_platform() is only called from two places.

- both check for NM_DEVICE_CAP_CARRIER_DETECT, so move that check
  inside the function.
- drop the logging in realize_start_setup(). nm_device_set_carrier() already
  does logging.
- always set the fake carrier in nm_device_set_carrier_from_platform().
  For the fake carrer, we anyway expect it to be already TRUE in most
  case, so usually this should have no effect.
  Also emit a property changed signal. That is necessary to refresh the
  D-Bus property.

(cherry picked from commit 02bb4ce7eb)
2017-05-15 17:44:44 +02:00
Thomas Haller
83c2243d80 device: rename and minor refactoring of check_carrier()
The name should mirror what we already have: nm_device_set_carrier().
Also, move the code closer to nm_device_set_carrier() and refactor
it a bit.

(cherry picked from commit 7e472b4eb3)
2017-05-15 17:44:44 +02:00
Thomas Haller
f4600c7fa5 device: downgrade logging messages about (non) pending action
Adding/Removing a pending action with assert_not_yet_pending/
assert_is_pending means that we expect that no action is taken.

Downgrade the logging level in those cases to <trace>.

(cherry picked from commit eaba285375)
2017-05-15 17:44:44 +02:00
Thomas Haller
62f1875766 device: minor cleanup of carrier_disconnected_action_cancel()
(cherry picked from commit 6c5d883a4b)
2017-05-15 17:44:44 +02:00
Thomas Haller
0ed6b5bfff device/trivial: rename functions related to "carrier"
(cherry picked from commit a07c6255a0)
2017-05-15 17:44:44 +02:00
Thomas Haller
e9aa3cc357 device: don't call virtual function carrier_changed() directly
Don't give the subclass the ability to override the parents
behavior. The parent implementation is not intended to allow
for that. Instead, restrict the flexibility of how the virtual
function integrates with the larger picture. That means, the
virtual function is only called at one place, and there is only
one implementation in NMDeviceEthernet (and it doesn't really
matter whether the implementation chains up the parent implementation
or not).

(cherry picked from commit 5a7374d8be)
2017-05-15 17:44:44 +02:00
Thomas Haller
7f139c8ea8 connectivity: avoid compiler warning for argument of curl_easy_getinfo()
libcurl employs some typechecking via "curl/typecheck-gcc.h". When
compling with --enable-lto, compilation fails otherwise with:

    make[2]: Entering directory '/data/src/NetworkManager'
      CC       src/src_libNetworkManager_la-nm-connectivity.lo
      CCLD     src/libNetworkManager.la
      CCLD     src/libNetworkManagerTest.la
      CCLD     src/dhcp/tests/test-dhcp-dhclient
    src/nm-connectivity.c: In function 'curl_check_connectivity':
    src/nm-connectivity.c:147:10: error: call to '_curl_easy_getinfo_err_string' declared with attribute warning: curl_easy_getinfo expects a pointer to char * for this info [-Werror]
       eret = curl_easy_getinfo (msg->easy_handle, CURLINFO_PRIVATE, &cb_data);
              ^
    lto1: all warnings being treated as errors
    lto-wrapper: fatal error: /usr/bin/gcc returned 1 exit status
    compilation terminated.
    /usr/bin/ld: error: lto-wrapper failed

(cherry picked from commit 7f8815a9c3)
2017-05-12 09:56:58 +02:00
Thomas Haller
33d3ec3b3e core: fix reading device state file
For manged=unknown, we don't write the value to the
device state keyfile. The results in an empty file,
or at least, a keyfile that doesn't have device.managed
set.

On read, we must treat a missing device.managed flag as
unknown, and not as unmanaged. Otherwise, on restart
a device becomes marked as explicitly unmanaged.

This was broken by commit 142ebb1 "core: only persist explicit managed
state in device's state file", where we started conditionally
to no longer write the managed state.

Reported-by: Michael Biebl <mbiebl@debian.org>
Fixes: 142ebb1037
(cherry picked from commit 348ffdec18)
2017-05-11 20:09:37 +02:00
Thomas Haller
8da225283b core: cleanup logging reading device-state
- print string value instead of numerical "managed"
- for missing state, print the same format. After all,
  some defaults apply and it is interesting to know what
  they are.

(cherry picked from commit 81008c90ac)
2017-05-11 20:09:37 +02:00
Thomas Haller
6cfd927962 proxy: fix passing cancellable to async D-Bus operations
We must not cancel pacrunner_cancellable when the D-Bus proxy is
created. Instead, keep it around and use it later for the asynchronous
D-Bus operations.

This doesn't really matter at the moment, because the pacrunner manager
is only destroyed when NetworkManager is about to terminated. That is
the only time when we actually cancel the asynchronous request. Also,
at that time we no longer iterate the mainloop, so the pending requests
are never completed anyway.

(cherry picked from commit a08540d967)
2017-05-11 18:55:23 +02:00
Thomas Haller
10373de907 proxy: fix refcount handing for DestroyProxyConfiguration operation
Fixes: e895beb0da
(cherry picked from commit df137fdf9a)
2017-05-11 18:55:22 +02:00
Nikolay Martynov
888a6ae029 platform: ignore RTM_GETLINK messages sent by wireless extentions
We listen to all RTM_GETLINK messages to get updates on interfaces statuses.
Unfortunately wireless code in the kernel sends those messages with wireless information included
and all other information excluded. When we receive such message we wipe out our valid cached entry
with new object that is almost empty because netlink message didn't contain any information.

Solution to this is to check that incoming message contains MTU field: this field is always
set for complete messages about interfaces and is not set by wireless code.

Signed-off-by: Nikolay Martynov <mar.kolya@gmail.com>

https://github.com/NetworkManager/NetworkManager/pull/17
(cherry picked from commit 58f7813283)
2017-05-11 17:42:13 +02:00
Thomas Haller
f128c48853 contrib/rpm: fix specifying build with/without libpsl
Fixes: faad17f9e8
(cherry picked from commit fe648f6cde)
2017-05-10 17:08:00 +02:00