Commit Graph

21088 Commits

Author SHA1 Message Date
Andrew Zaborowski
ec1db966f7 devices/wifi: Add NMDeviceIwd class to support IWD backend
This is very similar to NMDeviceWifi but simplified to remove the things
currently unsupported and with calls to nm_platform_wifi_* and
nm_supplicant_* replaced with IWD DBus API calls.  Only unsecured
infrastructure-mode networks are supported here.

[bgalvani@redhat.com: fix compilation error after rebase for
  NMActRequestGetSecretsCallId]
[thaller@redhat.com: don't use _() macro strings server side.
  Translating strings only makes sense for clients that set environment
  variables accordingly.]
2017-12-13 14:15:35 +01:00
Andrew Zaborowski
89bbcb816b devices/wifi: Move is_manf_default_ssid to nm-wifi-utils.c
Move the function for easier code reuse.
2017-12-13 13:10:27 +01:00
Andrew Zaborowski
0ff9471837 devices/wifi: Move AP list utilities to nm-wifi-ap.c
Move three functions for easier code reuse.
2017-12-13 13:10:27 +01:00
Thomas Haller
8c0dfd7188 systemd: merge branch systemd into master
Systemd instroduces a macro _fallthrough_, see
https://github.com/systemd/systemd/pull/7389.
However, it does not yet seem conclusive how to
handle this properly in ever situation.

While shared/nm-utils/siphash24.c makes use of
the new macro, don't do that in our fork. siphash24.h
does not include all systemd headers, hence _fallthrough_
is not defined. We could re-implement it as _nm_fallthrough,
but given the open questions, that doesn't seem the
2017-12-13 10:41:18 +01:00
Thomas Haller
2fb7479e82 macros: add _nm_fallthrough macro
Systemd introduced a _fallthrough_ macro in
https://github.com/systemd/systemd/pull/7389.

There might still be some issue with it, but as
I am going to re-import the latest systemd code,
we get them too.

We need it, because "shared/nm-utils/siphash24.c"
will use it too, and that source file does not include
the other systemd macros. So, we will need to re-define
it.
2017-12-13 10:41:01 +01:00
Francesco Giudici
5c6a382d4d devices/test: give more time to dad checking in test-arping
# random seed: R02Sc708af827453d4ace33cd27ffd3d7f0b
  1..2
  # Start of arping tests
  **
  NetworkManager:ERROR:src/devices/tests/test-arping.c:95:test_arping_common: assertion failed (nm_arping_manager_check_address (manager, info->addresses[i]) == info->expected_result[i]): (1 == 0)
  ok 1 /arping/1
  PASS: src/devices/tests/test-arping 1 /arping/1
  ./tools/run-nm-test.sh: line 193:  2836 Aborted                 "${NMTST_DBUS_RUN_SESSION[@]}" "$TEST" "$@"
  # NetworkManager:ERROR:src/devices/tests/test-arping.c:95:test_arping_common: assertion failed (nm_arping_manager_check_address (manager, info->addresses[i]) == info->expected_result[i]): (1 == 0)
  ERROR: src/devices/tests/test-arping - too few tests run (expected 2, got 1)
  ERROR: src/devices/tests/test-arping - exited with status 134 (terminated by signal 6?)
2017-12-13 10:26:10 +01:00
Thomas Haller
ac29b8cf8a systemd: update code from upstream (2017-12-13)
This is a direct dump from systemd git on 2017-12-13, git commit
18a121f9b462e2241c4a590f0a47f5351cd47e0f.

======

SYSTEMD_DIR=../systemd
COMMIT=18a121f9b462e2241c4a590f0a47f5351cd47e0f

(
  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"
2017-12-13 09:09:50 +01:00
Thomas Haller
da4388502a cli: merge branch 'th/cli-strsplit'
https://github.com/NetworkManager/NetworkManager/pull/38
2017-12-12 15:19:48 +01:00
Thomas Haller
5d3736ac65 cli: drop nmc_strsplit_set()
In most cases, it copies the entire strv needlessly.
We can do better.

Also, the max_tokens argument is handled wrongly (albeit
not used anywhere anymore).
2017-12-12 15:19:43 +01:00
Thomas Haller
8869943594 cli: refactor splitting of first command line argument
nmc_strsplit_set() handles max_token wrong. It cannot call
g_strsplit_set() with max_token first, and then split empty
words. You cannot use g_strsplit_set() to achieve what
nmc_strsplit_set() wants to do, unless you first split all
tokens, then them construct them together again -- thereby
loosing the delimiters.

Anyway, there are just a few caller that do essentially the same.

Refactor the code to not use nmc_strsplit_set().
2017-12-12 15:19:43 +01:00
Thomas Haller
97acd737bb cli: rework DEFINE_SETTER_PRIV_KEY()
nmc_strsplit_set()'s max_token argument is broken,
because it *first* calls g_strsplit_set() and then removes
empty tokens. It wasn't an issue, because DEFINE_SETTER_PRIV_KEY()
would first already remove leading spaces, and who uses multiple
spaces anyway...

Anyway, refactor DEFINE_SETTER_PRIV_KEY() to not use it.
2017-12-12 15:19:43 +01:00
Thomas Haller
51a3d8a861 libnm: make nm_setting_802_1x_set_private_key() self-assignment safe
nmcli calls nm_setting_802_1x_set_private_key() with a password pointer that
it just got from the setting connection itself. Make this less fragile, by
not freeing the current password before assigning it.
2017-12-12 15:19:43 +01:00
Beniamino Galvani
19d6d54b6f platform: improve ipv6 addresses synchronization
nm_platform_ip6_address_sync() must take care not only of adding
missing addresses and removing unknown addresses, but also of the
order in which they are added. The order is important because it
determines which address is preferred by kernel.

Since we can only add addresses at the top of the list, in order to
change the position of an address we must first remove it and then
re-add it in the right position.
2017-12-12 15:17:10 +01:00
Thomas Haller
cc5ff98456 merge: bug fixes found via coverity 2017-12-12 11:16:00 +01:00
Thomas Haller
f44f21c87e core: avoid leaks parsing team link-watcher
Found by coverity.
2017-12-12 11:15:38 +01:00
Thomas Haller
c274b565a6 cli: avoid out-of-bounds-read for show_device_info()
Probably not critical, because it will still include
the terminating NULL, and just continue to fill the
temporary buffer with static addresses.

Found by coverity.

Fixes: bfb9fd0d2f
2017-12-12 11:15:38 +01:00
Thomas Haller
62d4dba74b platform: assert() for valid item in nm_platform_link_get_all()
Coverity thinks that item might be NULL, but actually it
cannot. Unclear how to avoid the false positive.
2017-12-12 11:15:38 +01:00
Thomas Haller
27e8fffdb8 platform: fix crash hashing NMPlatformTfilter and NMPlatformQdisc
@kind might be NULL. There are 3 forms of the hash-update functions for
string: str(), str0(), and strarr().

- str0() is when the string might be NULL.
- str() does not allow the string to be NULL
- strarr() is like str(), except it adds a G_STATIC_ASSERT()
  that the argument is a C array.

The reason why a difference between str() and str0() exists, is
because str0() hashes NULL different from a "" or any other string.
This has an overhead, because it effectively must hash another bit
of information that tells whether a string was passed or not.

The reason is, that hashing a tupple of two strings should always
yield a different hash value, even for "aa",""; "a","a"; "","aa",
where naive concatentation would yield identical hash values in all
three cases.

Fixes: e75fc8279b
2017-12-12 11:15:38 +01:00
Thomas Haller
fb2da4b26c libnm: fix checking argument in nm_team_link_watcher_new_arp_ping()
Found by coverity.

Fixes: 6c93e32212
2017-12-12 11:15:38 +01:00
Thomas Haller
a7087b1f05 core: avoid dereferencing NULL in nm_utils_resolve_conf_parse()
Found by coverity.

Fixes: 8f1ef161f4
2017-12-12 11:15:38 +01:00
Thomas Haller
fbc6008260 core: fix uninialized boolean variable in reset_autoconnect_all()
It's not critical, because at worst we get a false-positive that
something changed.

Found by coverity.

Fixes: 4e7b05de79
2017-12-12 11:15:38 +01:00
Lubomir Rintel
f4419783b7 po: translations from the Red Hat translators 2017-12-12 10:49:37 +01:00
Lubomir Rintel
4103c72c15 po: update-po for the translations that are going to be updated
Just so that we get a nicer diff when pulling from the Red Hat Zanata.
2017-12-12 10:49:37 +01:00
Thomas Haller
5201121a1b platform/tests: fix memleaks in tests
Fixes: 0b0fb045bc
2017-12-11 21:01:29 +01:00
Lubomir Rintel
9c03a813e0 libnm: move symbols that were backported to 1.10.2 before 1.12 to libnm_1_10_2
See also: ae5af6b368
2017-12-11 20:22:30 +01:00
Lubomir Rintel
9639a176ff device: ensure simple action sdata is a NUL-terminated bytestring 2017-12-11 18:49:48 +01:00
Thomas Haller
023ce50d21 settings: mark the connection as UNSAVED if it was modified in-memory 2017-12-11 18:48:47 +01:00
Thomas Haller
e8299e30b8 settings: for persist-mode KEEP do not ever save the connection to disk
KEEP means to don't do anything, really.
2017-12-11 18:37:49 +01:00
Thomas Haller
7044febf97 settings: fix clearing nm-generated/volatile flags of connection
There are a few cases where we don't want to clear a potential
nm-generated/volatile flag, but only mark the connection as
unsaved.

Otherwise, we wrongly end up clearing these flags and the connection
is wrongly not NM_DEVICE_SYS_IFACE_STATE_EXTERNAL.

Fixes: 35dc6421de
2017-12-11 12:12:08 +01:00
Lubomir Rintel
e75fc8279b lr/tc: initial support for TC qdiscs and filters
https://bugzilla.gnome.org/show_bug.cgi?id=790630
2017-12-11 11:20:50 +01:00
Lubomir Rintel
902bbfdb18 ifcfg-rh: add tc support
Format:

  QDISC1=ingress
  QDISC2="root handle 1234: fq_codel"
  FILTER1="parent ffff: matchall action simple sdata Input"
  FILTER2="parent 1234: matchall action simple sdata Output"
2017-12-11 11:20:13 +01:00
Lubomir Rintel
8bffb2c750 device: set traffic filters when device comes up 2017-12-11 11:20:13 +01:00
Thomas Haller
fe3d7209e7 platform: fix TC to-string/hash/cmp functions to include the action
Also add a define NM_PLATFORM_ACTION_KIND_SIMPLE. It makes the
uses of "simple" grepable.
2017-12-11 11:08:41 +01:00
Lubomir Rintel
b0fd3ecbaf platform: add support for traffic filters 2017-12-11 11:08:41 +01:00
Lubomir Rintel
3261820004 clients: add tc tfilter support
What works:

  nmcli c add con-name dum0 ifname dum0 type dummy \
      tc.tfilters 'parent 1234: matchall action drop, parent ffff: matchall action drop'
  nmcli c modify dum0 -tc.tfilters 'parent ffff: matchall action drop'
  nmcli c modify dum0 +tc.tfilters 'parent ffff: matchall action simple sdata Hello'
2017-12-11 11:02:04 +01:00
Lubomir Rintel
bc471c8e7a keyfile/tests: test tc traffic filter reading and writing 2017-12-11 11:02:04 +01:00
Lubomir Rintel
2e8fc6947d keyfile: add ability to read/write tc filters
The idea is

  tfilter.<parent>=[handle <handle>] <tfilter> [<options>] [action [<action options>...]]

What works now:

  [tc]
  qdisc.root=handle 1234: fq_codel
  qdisc.ffff:fff1=ingress
  tfilter.1234:=matchall action drop
  tfilter.ffff:=matchall action simple sdata Hello
2017-12-11 11:02:04 +01:00
Thomas Haller
7cd2b6178d libnm: disable g_warning() from library
Printing a g_warning() from the library is not helpful.

Client-side, libnm should support newer server versions and changing
formats. To support forward-compatibility, it should parse the received
GVariant best-effort like, without complaining.

Server-side, libnm-core should return errors when receiving invalid
configuration. It must not maintain forward-compatibility, only
backward-compatibility -- which is implemented by handling old
and newer formats. But never should server allow a configuration
that is invalid.

Currently, the libnm API cannot yet fail at this point. Hence,
it cannot return an error. It would need a strict and relaxed
parsing mode. Until that exists, just comment out the warnings.
2017-12-11 11:02:04 +01:00
Lubomir Rintel
dbef7e684f libnm-core/tests: test NMSettingTCConfig traffic filter support 2017-12-11 11:02:04 +01:00
Lubomir Rintel
de41c45e61 libnm-core: add functionality for dealing with tc-style traffic filter specifiers
Tailored to fit both nmcli and keyfile needs.
2017-12-11 11:02:04 +01:00
Lubomir Rintel
e035cb7be0 libnm-core: add traffic filter support to NMSettingTCConfig 2017-12-11 11:02:04 +01:00
Lubomir Rintel
883e565b7d libnm-core/tests: test NMSettingTCConfig action support 2017-12-11 11:02:04 +01:00
Lubomir Rintel
733464ada3 libnm-core: add functionality for dealing with tc-style action specifiers
Tailored to fit both nmcli and keyfile needs.
2017-12-11 11:02:04 +01:00
Thomas Haller
b0ba17e903 libnm-core: consider attributes in nm_tc_action_equal() 2017-12-11 11:01:59 +01:00
Lubomir Rintel
7c8ce778fb libnm-core: add action support to NMSettingTCConfig
The actions are not too useful my themselves, but it will be possible to
embed them into traffic filters in subsequent commits.
2017-12-11 10:52:23 +01:00
Lubomir Rintel
e4bdb21909 device: set qdiscs when device comes up 2017-12-11 10:52:23 +01:00
Lubomir Rintel
92f8f30d47 clients: add tc qdisc support
What works:

  nmcli c add con-name dum0 ifname dum0 type dummy \
      tc.qdiscs 'ingress, root pfifo_fast'
  nmcli c modify dum0 -tc.qdiscs 'root pfifo_fast'
  nmcli c modify dum0 +tc.qdiscs 'root handle 666: fq_codel'
2017-12-11 10:52:23 +01:00
Lubomir Rintel
8547387942 keyfile/tests: test tc qdisc reading and writing 2017-12-11 10:52:23 +01:00
Lubomir Rintel
9d0eeb30b6 keyfile: add ability to read/write qdiscs from tc setting
The format for qdiscs is

  qdisc.<parent>=[handle <handle>] <qdisc> [<options>...]

E.g.:

  [tc]
  qdisc.root=fq_codel handle de4d:
  qdisc.ffff:fff1=ingress

That is pretty much what is supported at this point.
2017-12-11 10:52:23 +01:00
Lubomir Rintel
0ab77ebd1d libnm-core/tests: test NMSettingTCConfig qdisc support
...so that we have an excuse when it breaks.
2017-12-11 10:52:22 +01:00