Commit Graph

19705 Commits

Author SHA1 Message Date
Beniamino Galvani
a2f1a93817 platform: remove unused typedef 2018-03-09 17:52:43 +01:00
Beniamino Galvani
773ab140d2 platform: return extack message from WaitForNlResponse delayed action
Return the extended ack message from the WaitForNlResponse delayed
action so that the caller can print a detailed reason with the
appropriate logging level.
2018-03-09 17:52:43 +01:00
Beniamino Galvani
b107e121b0 platform: print error message from netlink extended ack
From v4.12 the kernel appends some attributes to netlink acks
containing a textual description of the error and other fields (see
commit [1]). Parse those attributes and print the error message.

Examples:

platform-linux: netlink: recvmsg: error message from kernel: Network is unreachable (101) "Nexthop has invalid gateway" for request 12

platform-linux: netlink: recvmsg: error message from kernel: Invalid argument (22) "Local address cannot be multicast" for request 21

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=2d4bc93368f5a0ddb57c8c885cdad9c9b7a10ed5
2018-03-09 17:52:43 +01:00
Benjamin Berg
26c215e22d Add calls to g_simple_async_result_set_check_cancellable
If an operation is cancelled through the GCancellable, then the idiom is
that the operation is always cancelled, even if it has finished
successfully. To ensure this is the case, add calls to
g_simple_async_result_set_check_cancellable everywhere.

Without this, e.g. gnome-control-center will crash when switching away
from the power panel quickly, as the NMClient creation finishes
asynchronously and g-c-c assume that G_IO_ERROR_CANCELLED is returned to
ensure it doesn't access the now invalid user_data parameter.

https://bugzilla.gnome.org/show_bug.cgi?id=794088
2018-03-08 14:52:45 +01:00
Thomas Haller
d76cfa3814 device: rework checking for bluetooth NAP connection in nm_device_update_metered()
NAP connections are a bit special, in that they also have a [bridge]
setting, but their connection.type is "bluetooth".

The canonical way to check whether a bluetooth connection is of NAP type
is by calling _nm_connection_get_setting_bluetooth_for_nap().

So, instead of checking for bluetooth.type "pan" or "dun", check the
opposite and whether the connection is of NAP type. In practice it's the
same, but let'check for NAP consistently via get_setting_bluetooth_for_nap().
2018-03-08 14:49:58 +01:00
Philip Withnall
599da6fd02 devices: Set NM_METERED_GUESS_YES for Bluetooth PANU/DUN connections
Bluetooth tethering using DUN or PANU is a common way to expose a
metered 3G or 4G connection from a phone to a laptop. We deliberately
ignore NAP connections, which is where we’re sharing internet from the
laptop to another device.

We could also set GUESS_YES for WiMAX connections, but NetworkManager
doesn’t support them any more. Add a comment about that.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://bugzilla.gnome.org/show_bug.cgi?id=794120
2018-03-08 13:35:21 +01:00
Fabian Vogt
d2f019409d policy: fix blocking autoconnect for no-secrets
The condition was obviosly inverted, blocking autoconnect when
it should not, and not blocking it when it should.

[thaller@redhat.com: modified original patch and rewrite commit message]

Fixes: e2c8ef45ac

https://bugzilla.gnome.org/show_bug.cgi?id=794014
2018-03-08 11:34:39 +01:00
Andika Triwidada
e3214f8d95 po: updated Indonesian translation (bgo #794103)
https://bugzilla.gnome.org/show_bug.cgi?id=794103
2018-03-08 00:29:13 +01:00
Francesco Giudici
39fde61a5a man: drop duplicate text from dhcp-client-id description
Fixes: 62a7863979
2018-03-06 15:25:48 +01:00
Beniamino Galvani
2d1fad641b platform: don't require cloned flag for RTM_GETROUTE IPv6 result
IPv4 routes that are a response to RTM_GETROUTE must have the cloned
flag while IPv6 routes don't have to. Don't check the flag for IPv6
routes and add a test case to verify that RTM_GETROUTE works for IPv6.

https://bugzilla.gnome.org/show_bug.cgi?id=793962
2018-03-05 18:47:25 +01:00
Thomas Haller
065741c7b2 travis: install meson 0.44.1 for travis' meson build
Latest versions of meson require now Python 3.5+. Not only that meson requires Python3
and thus makes building on some systems cumbersome (RHEL7), it also eagerly bumps
Python3.y requirements.

Install the last working release which works with Python3.4. This fixes
the the travis build failure on Ubuntu 14.04 (trusty):

  Meson works correctly only with python 3.5+.
  You have python 3.4.3 (default, Nov 28 2017, 16:41:13)
  [GCC 4.8.4].
  Please update your environment
2018-03-05 17:47:21 +01:00
Thomas Haller
dd01418be8 wifi/iwd: merge branch 'az/iwd-secret-handling' (#73)
https://github.com/NetworkManager/NetworkManager/pull/73
2018-03-05 12:39:43 +01:00
Andrew Zaborowski
29e9d206aa iwd: don't call nm_wifi_ap_set_ssid for empty SSID
If SSID is an empty string there's no need to call nm_wifi_ap_set_ssid
as it won't do anything.  It also has an assert checking that NULL is
passed for an empty SSID and we were passing a non-NULL pointer.
2018-03-05 00:46:00 +01:00
Andrew Zaborowski
8435aa8b31 iwd: fix device-added signal handler signature
This bug was not causing a crash for me because of the !IS_NM_DEVICE_IWD
check and because my glib version probably had the assertion within
NM_IWD_MANAGER_GET_PRIVATE disabled.

While there, change the g_signal_connect line to use the macro for the
signal name.
2018-03-05 00:35:01 +01:00
Andrew Zaborowski
6571b576c4 iwd: set Device.Powered during set_enable
Make sure .set_enabled uses the Device.Powered property to basically
bring the netdev UP and DOWN as I understand is expected by the
nm_device logic.

Device.Powered should generally reflect the UP state immediately but
just to avoid possible race conditions .is_available() will now return
a value that is an AND of the local "enabled" state and IWD's Powered
property.
2018-03-05 00:34:43 +01:00
Andrew Zaborowski
f172681048 iwd: Disable timeout for iwd Device.Connect call
Change from the default dbus call timeout (-1) to infinite (G_MAXINT)
because the call may now include the secret requests which have their
own timeout policies.
2018-03-05 00:33:20 +01:00
Andrew Zaborowski
900751794f iwd: Only request secrets on request from IWD
Remove the code (mostly copied from nm-device-wifi.c) that handles
checking if the secrets were provided and requesting missing secrets
before starting a connection attempt.  Instead, request secrets when
we're asked for them by IWD through its agent interface.  This happens
while the dbus Connect call is running.  We change the NMDevice from
the CONFIG state to NEED_AUTH and then change back to CONFIG once we
sent the secrets back to IWD.

The current code would require the secrets only based on whether a
network is a KnownNetwork but IWD may need a new passwords even for
KnownNetworks if the last connection attempt has failed.
2018-03-05 00:31:34 +01:00
Thomas Haller
cf472f00a1 libnm/keyfile: merge branch 'th/keyfile-cert-parser' (#71)
https://github.com/NetworkManager/NetworkManager/pull/71
2018-03-03 17:00:12 +01:00
Thomas Haller
2aebb343d9 libnm/keyfile: refactor cert_parser() by merge helper functions
The parsing of the certificate consists of a series of checks, and if a
check matches, we determine the type and are done.

Moving these checks to different functions (that are only called once)
makes it more complicated to understand what really happens. Merge them
all together.
2018-03-03 16:57:42 +01:00
Thomas Haller
cf774a1bfc libnm/keyfile: refactor error paths for cert_parser()
Refactor cert_parser() to return early.

Also, rework handle_as_scheme() and handle_as_path() to check for
success first and return early. This in the next step will allow
to merge the functions.
2018-03-03 16:57:42 +01:00
Thomas Haller
3d6a2b8d6b libnm/keyfile/trivial: rename local variables in preparation of refactoring 2018-03-03 16:57:42 +01:00
Thomas Haller
608dfacb0b core: fix leaking connection in impl_settings_add_connection_helper()
Fixes: 0f6baeef35
2018-02-28 12:13:39 +01:00
Thomas Haller
19a78f8954 core: fix typo for parameter as "paramter" 2018-02-28 12:13:39 +01:00
Francesco Giudici
ff1884a219 ifcfg: don't skip ipv4 properties when method is shared
Always read and load ipv4 property values when method is shared also if
they will not be used: instead of dropping them at connection update,
keep their values in the ifcfg file.
Exceptions: ipv4.dns and ipv4.dns-search. They will be not read, otherwise
they may trigger a failure in nm-setting-ip4-config.c:verify() on load.

https://bugzilla.redhat.com/show_bug.cgi?id=1519299
2018-02-28 11:11:10 +01:00
Thomas Haller
6292851248 dhcp: fix uninitialized pointer in DHCP listener's _method_call_handle()
Fixes: f67269b49d
2018-02-28 06:41:40 +01:00
Thomas Haller
65049f6736 libnm/tests: fix compilation of test-general
../libnm/tests/test-general.c: In function ‘test_fixup_vendor_string’:
    ../libnm/tests/test-general.c:70:3: error: initializer element is not constant
       T_DATA ("3Com", "3Com"),
       ^
    ../libnm/tests/test-general.c:70:3: error: (near initialization for ‘data[0]’)
    ../libnm/tests/test-general.c: In function ‘test_fixup_product_string’:
    ../libnm/tests/test-general.c:365:3: error: initializer element is not constant
       T_DATA  ("10/100BaseTX [RTL81xx]", "RTL81xx"),
    ...

Fixes: 817fce917b
2018-02-26 14:42:09 +01:00
Thomas Haller
817fce917b libnm/tests: avoid compiler message about -fvar-tracking-assignments in test-general.c
CC       libnm/tests/libnm_tests_test_general-test-general.o
    libnm/tests/test-general.c: In function ‘test_fixup_product_string’:
    libnm/tests/test-general.c:328:1: note: variable tracking size limit exceeded with -fvar-tracking-assignments, retrying without
     test_fixup_product_string (void)
     ^~~~~~~~~~~~~~~~~~~~~~~~~

Fixes: 8e32d8fc23
2018-02-26 13:14:40 +01:00
Thomas Haller
fd166783e7 platform/wifi: don't pass ownership of message to nl80211_send_and_recv()
Passing ownership with a function call is confusing. Don't do that.

Since we have the cleanup attribute, it doesn't significantly
complicate the callers, as all they need to do is marking the
@msg variable to free the message when going out of scope.
That results in the function that allocates the message also being
responsible to free it.
2018-02-24 12:35:28 +01:00
Thomas Haller
a79e6b3b45 platform/wifi: fix memleak in _nl80211_send_and_recv()
The callers expect _nl80211_send_and_recv() to free @msg.

This was broken by the previous commit, which wrongly removed
the nm_auto_nlmsg cleanup attribute.

Fix the compiler warning differently.

Fixes: d7108d9362
2018-02-24 12:34:11 +01:00
Lubomir Rintel
d7108d9362 platform/wifi: drop an unused variable
src/platform/wifi/wifi-utils-nl80211.c:192:31: error: unused variable 'msg_free' [-Werror,-Wunused-variable]
          nm_auto_nlmsg struct nl_msg *msg_free = msg;

Fixes: a7bda2ed12
2018-02-23 22:04:11 +01:00
Lubomir Rintel
8b003e6d06 merge: branch 'lr/ugly-descriptions'
https://bugzilla.gnome.org/show_bug.cgi?id=791292
2018-02-23 19:47:44 +01:00
Lubomir Rintel
e4430e0969 libnm/device: use the type name for description if the product is empty
It's very likely that the product said something that was filtered out
by the fixup, such as "PCI Ethernet" or "Wi-Fi Adapter". Use a generic
type name in place of it.
2018-02-23 19:47:19 +01:00
Lubomir Rintel
c17155b1b9 libnm/device: (trivial) move some function upwards 2018-02-23 19:47:19 +01:00
Lubomir Rintel
22b76f4c58 libnm/device: prefer FROM_DATABASE udev properties
The database has a chance to fix up over garbage strings from the device
properties and we're now known to be reasonably good at fixing up crap
there.
2018-02-23 19:47:19 +01:00
Lubomir Rintel
4c963d719c libnm/utils: drop part after a dash in product name
It's always garbage.

At this point we seem to reasonably handle all product names that come
from hwdb.
2018-02-23 19:47:19 +01:00
Lubomir Rintel
0c151ae39d libnm/utils: extend the product fixup phrase list
The product names are generally of rather poor quality. The product name
is no place to enumerate product capabilities, the bus it's attached on
and similar nonsense.
2018-02-23 19:47:19 +01:00
Lubomir Rintel
e22b1c1d94 libnm/utils: ignore parts of vendor name after a slash
At this point the test suite also contains all network vendor names
known to hwdb.
2018-02-23 19:47:19 +01:00
Lubomir Rintel
f7805ab602 libnm/utils: deal with the square brackets on producr/vendor fixup
If there's a [<string>] that survived the substitution, then the string
is supposed to be a short form that is generally preferrable.

That's great in theory, but actually it's rather often pure garbage for
product names. Let's prefer it just for vendors and provide an option to
drop it (will be useful for fixing up product names).
2018-02-23 19:47:19 +01:00
Lubomir Rintel
280d095fdf libnm/utils: ignore stuff in parentheses for vendor/product fixups
It's always useless.
2018-02-23 19:47:19 +01:00
Lubomir Rintel
e974261e89 libnm/utils: add more phrases to vendor fixup list
Along with known correctly fixed up vendor names.
2018-02-23 19:47:19 +01:00
Lubomir Rintel
8e32d8fc23 libnm/utils: split out vendor fixup
The hwdb generally contains the strings of rather poor quality,
especially when it comes to sensibly presenting them to the user and
they need various cleanups.

While the following patches add fixups, this one splits out vendor
fixups, because it turns out that a different set of fixups is needed
than for products.
2018-02-23 19:47:19 +01:00
Beniamino Galvani
823839e933 systemd: merge branch systemd into master 2018-02-23 14:13:43 +01:00
Beniamino Galvani
f5b8b37eaf libsystemd-network: fix endianness in ARP BPF filter
systemd commit f11cba7479fe ("libsystemd-network: fix unaligned loads
(issue #7654)") changed the way in which the MAC address is read to
use native endiannes:

 htobe32(*((uint32_t *)x)  ->  unaligned_read_ne32(x)

This is wrong because loads done with BPF_LD + BPF_ABS are big-endian, as it
can be seen for the ethertype and arp-operation loads above in the
filter.  Also, the same commit changed:

 htobe32(*((unsigned int *)x) -> unaligned_read_be32(x)

in _bind_raw_socket(), which is the correct form.

The commit broke IPv4LL in presence of loops, as the sender now considers its
own packets as conflicting.

systemd commit: 6afe9046d570fd86dbc04526b5685c64d7958086
2018-02-23 14:11:27 +01:00
Beniamino Galvani
adced1a22b systemd: update code from upstream (2018-02-23)
This is a direct dump from systemd git on 2018-02-23, git commit
6084c4efa8dcc99659f62c7abc70f69a70220eb2

======

SYSTEMD_DIR=../systemd
COMMIT=6084c4efa8dcc99659f62c7abc70f69a70220eb2

(
  cd "$SYSTEMD_DIR"
  git checkout "$COMMIT"
  git reset --hard
  git clean -fdx
)

git ls-files :/src/systemd/src/ \
             :/shared/nm-utils/siphash24.c \
             :/shared/nm-utils/siphash24.h \
             :/shared/nm-utils/unaligned.h | \
  xargs -d '\n' rm -f

nm_copy_sd() {
    mkdir -p "./src/systemd/$(dirname "$1")"
    cp "$SYSTEMD_DIR/$1" "./src/systemd/$1"
}

nm_copy_sd_shared() {
    mkdir -p "./shared/nm-utils/"
    cp "$SYSTEMD_DIR/$1" "./shared/nm-utils/${1##*/}"
}

nm_copy_sd "src/basic/alloc-util.c"
nm_copy_sd "src/basic/alloc-util.h"
nm_copy_sd "src/basic/async.h"
nm_copy_sd "src/basic/escape.c"
nm_copy_sd "src/basic/escape.h"
nm_copy_sd "src/basic/ether-addr-util.c"
nm_copy_sd "src/basic/ether-addr-util.h"
nm_copy_sd "src/basic/extract-word.c"
nm_copy_sd "src/basic/extract-word.h"
nm_copy_sd "src/basic/fileio.c"
nm_copy_sd "src/basic/fileio.h"
nm_copy_sd "src/basic/fd-util.c"
nm_copy_sd "src/basic/fd-util.h"
nm_copy_sd "src/basic/fs-util.c"
nm_copy_sd "src/basic/fs-util.h"
nm_copy_sd "src/basic/hash-funcs.c"
nm_copy_sd "src/basic/hash-funcs.h"
nm_copy_sd "src/basic/hashmap.c"
nm_copy_sd "src/basic/hashmap.h"
nm_copy_sd "src/basic/hexdecoct.c"
nm_copy_sd "src/basic/hexdecoct.h"
nm_copy_sd "src/basic/hostname-util.c"
nm_copy_sd "src/basic/hostname-util.h"
nm_copy_sd "src/basic/in-addr-util.c"
nm_copy_sd "src/basic/in-addr-util.h"
nm_copy_sd "src/basic/io-util.c"
nm_copy_sd "src/basic/io-util.h"
nm_copy_sd "src/basic/list.h"
nm_copy_sd "src/basic/log.h"
nm_copy_sd "src/basic/macro.h"
nm_copy_sd "src/basic/mempool.h"
nm_copy_sd "src/basic/mempool.c"
nm_copy_sd "src/basic/parse-util.c"
nm_copy_sd "src/basic/parse-util.h"
nm_copy_sd "src/basic/path-util.c"
nm_copy_sd "src/basic/path-util.h"
nm_copy_sd "src/basic/prioq.h"
nm_copy_sd "src/basic/prioq.c"
nm_copy_sd "src/basic/process-util.h"
nm_copy_sd "src/basic/process-util.c"
nm_copy_sd "src/basic/random-util.c"
nm_copy_sd "src/basic/random-util.h"
nm_copy_sd "src/basic/refcnt.h"
nm_copy_sd "src/basic/set.h"
nm_copy_sd "src/basic/signal-util.h"
nm_copy_sd_shared "src/basic/siphash24.c"
nm_copy_sd_shared "src/basic/siphash24.h"
nm_copy_sd "src/basic/socket-util.c"
nm_copy_sd "src/basic/socket-util.h"
nm_copy_sd "src/basic/sparse-endian.h"
nm_copy_sd "src/basic/stdio-util.h"
nm_copy_sd "src/basic/string-table.c"
nm_copy_sd "src/basic/string-table.h"
nm_copy_sd "src/basic/string-util.c"
nm_copy_sd "src/basic/string-util.h"
nm_copy_sd "src/basic/strv.c"
nm_copy_sd "src/basic/strv.h"
nm_copy_sd "src/basic/time-util.c"
nm_copy_sd "src/basic/time-util.h"
nm_copy_sd "src/basic/umask-util.h"
nm_copy_sd_shared "src/basic/unaligned.h"
nm_copy_sd "src/basic/utf8.c"
nm_copy_sd "src/basic/utf8.h"
nm_copy_sd "src/basic/util.c"
nm_copy_sd "src/basic/util.h"
nm_copy_sd "src/libsystemd-network/arp-util.c"
nm_copy_sd "src/libsystemd-network/arp-util.h"
nm_copy_sd "src/libsystemd-network/dhcp6-internal.h"
nm_copy_sd "src/libsystemd-network/dhcp6-lease-internal.h"
nm_copy_sd "src/libsystemd-network/dhcp6-network.c"
nm_copy_sd "src/libsystemd-network/dhcp6-option.c"
nm_copy_sd "src/libsystemd-network/dhcp6-protocol.h"
nm_copy_sd "src/libsystemd-network/dhcp-identifier.c"
nm_copy_sd "src/libsystemd-network/dhcp-identifier.h"
nm_copy_sd "src/libsystemd-network/dhcp-internal.h"
nm_copy_sd "src/libsystemd-network/dhcp-lease-internal.h"
nm_copy_sd "src/libsystemd-network/dhcp-network.c"
nm_copy_sd "src/libsystemd-network/dhcp-option.c"
nm_copy_sd "src/libsystemd-network/dhcp-packet.c"
nm_copy_sd "src/libsystemd-network/dhcp-protocol.h"
nm_copy_sd "src/libsystemd-network/lldp-internal.h"
nm_copy_sd "src/libsystemd-network/lldp-neighbor.c"
nm_copy_sd "src/libsystemd-network/lldp-neighbor.h"
nm_copy_sd "src/libsystemd-network/lldp-network.c"
nm_copy_sd "src/libsystemd-network/lldp-network.h"
nm_copy_sd "src/libsystemd-network/network-internal.c"
nm_copy_sd "src/libsystemd-network/network-internal.h"
nm_copy_sd "src/libsystemd-network/sd-dhcp6-client.c"
nm_copy_sd "src/libsystemd-network/sd-dhcp6-lease.c"
nm_copy_sd "src/libsystemd-network/sd-dhcp-client.c"
nm_copy_sd "src/libsystemd-network/sd-dhcp-lease.c"
nm_copy_sd "src/libsystemd-network/sd-ipv4ll.c"
nm_copy_sd "src/libsystemd-network/sd-ipv4acd.c"
nm_copy_sd "src/libsystemd-network/sd-lldp.c"
nm_copy_sd "src/libsystemd/sd-event/sd-event.c"
nm_copy_sd "src/libsystemd/sd-id128/id128-util.c"
nm_copy_sd "src/libsystemd/sd-id128/id128-util.h"
nm_copy_sd "src/libsystemd/sd-id128/sd-id128.c"
nm_copy_sd "src/shared/dns-domain.c"
nm_copy_sd "src/shared/dns-domain.h"
nm_copy_sd "src/systemd/_sd-common.h"
nm_copy_sd "src/systemd/sd-dhcp6-client.h"
nm_copy_sd "src/systemd/sd-dhcp6-lease.h"
nm_copy_sd "src/systemd/sd-dhcp-client.h"
nm_copy_sd "src/systemd/sd-dhcp-lease.h"
nm_copy_sd "src/systemd/sd-event.h"
nm_copy_sd "src/systemd/sd-ndisc.h"
nm_copy_sd "src/systemd/sd-id128.h"
nm_copy_sd "src/systemd/sd-ipv4acd.h"
nm_copy_sd "src/systemd/sd-ipv4ll.h"
nm_copy_sd "src/systemd/sd-lldp.h"
2018-02-23 14:10:24 +01:00
Thomas Haller
0b25e30238 wwan: merge branch 'th/modem-ip-iface'
https://github.com/NetworkManager/NetworkManager/pull/55
2018-02-22 11:45:32 +01:00
Thomas Haller
de16ef91cf wwan: drop nm_modem_get_data_port() function
It was only used by bluetooth's component_added()
check. It should compare rfcomm_iface only against
the control-port, not the data-port.
2018-02-21 20:28:46 +01:00
Thomas Haller
78ca2a70c7 device: don't set invalid ip-iface
Now that every call to nm_device_set_ip_iface() and nm_device_set_ip_ifindex()
is checked, and setting an interface that does not exist causes the device
state to fail, we no longer need to allow setting an ip-iface if we are
unable to retrieve the ip-ifindex.
2018-02-21 20:28:46 +01:00
Thomas Haller
c7b3586b9d wwan: rework setting modem's data-port
Depending on the bearer's configuration method, the data-port is
either a networking interface, or an tty for ppp.

Let's treat them strictily separate.

Also, rework how NM_MODEM_DATA_PORT was used in both contexts.
Instead, use the that we actually care about.

Also, when nm_device_set_ip_ifindex() fails, fail activation
right away.

Also, we early try to resolve the network interface's name to
an ifindex. If that fails, the device is already gone and we
fail early.
2018-02-21 20:28:46 +01:00
Thomas Haller
2ea8e1029f bluetooth: fail activation when setting unknown ip-iface 2018-02-21 20:28:46 +01:00
Thomas Haller
a169d689ba wwan: avoid dangling pointer for error variable in connect_ready() 2018-02-21 20:28:46 +01:00