Commit Graph

22921 Commits

Author SHA1 Message Date
Thomas Haller
2861a7ae0a shared: add nm_strstrip_avoid_copy_a() helper 2019-04-04 21:01:15 +02:00
Thomas Haller
26d144d5a0 shared: move nm_memdup(), nm_strndup_a(), and nm_strdup_int() to "nm-macros-internal.h"
The main difference between "shared/nm-utils/nm-macros-internal.h" and
"shared/nm-utils/nm-shared-utils.h" is that the former is header-only
while the latter has a source file as well.

Apart from that, both headers are included everywhere.

The next commit will add nm_strstrip_avoid_copy_a() to
"nm-macros-internal.h" header, which will use nm_strndup_a().
Hence, also nm_strndup_a() should be in "nm-macros-internal.h".
2019-04-04 21:01:15 +02:00
Thomas Haller
08c327f8a6 shared/trivial: rename variables in nm_strndup_a() and nm_str_skip_leading_spaces() macros
"_str" is a very tempting name for a temporary variable.

Rename the variable in nm_strndup_a() macro, so that other macros can
call these (more general) macros (and still use the name "_str").
2019-04-04 21:01:15 +02:00
Beniamino Galvani
9c049b3a00 sriov: merge branch 'bg/sriov-drivers-autoprobe-rh1695093'
https://github.com/NetworkManager/NetworkManager/pull/331
https://bugzilla.redhat.com/show_bug.cgi?id=1695093
2019-04-04 15:37:03 +02:00
Beniamino Galvani
8698f512d7 platform: assume 'sriov_drivers_autoprobe' is 1 when sysfs file is missing
'sriov_drivers_autoprobe' was added in kernel 4.12. With previous
kernel versions NM is currently unable to set any SR-IOV parameter
because it tries to read 'sriov_drivers_autoprobe' which doesn't
exist, assumes that current value is -1 and tries to change it,
failing.

When the file doesn't exist, drivers are automatically probed so we
can assume the value is 1. In this way NM is able to activate a
connection with sriov.autoprobe-drivers=1 (the default) even on older
kernel versions.

Fixes: 1e41495d9a ('platform: sriov: write new values when we can't read old ones')

https://bugzilla.redhat.com/show_bug.cgi?id=1695093
2019-04-04 15:35:13 +02:00
Thomas Haller
dc64745dd8 platform: set errno to ENOENT for nm_platform_sysctl_get() 2019-04-04 15:35:13 +02:00
Beniamino Galvani
e7e5f4a2d6 libnm-core: fix build warning
libnm-core/nm-keyfile.c:679:32: error: 'key_type' may be used uninitialized in this function [-Werror=maybe-uninitialized]
   build_list[build_list_len++] = (BuildListData) {
                                ^
2019-04-04 15:34:41 +02:00
Thomas Haller
899220485e acd: merge branch 'th/gitlab-ci-fixes'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/103
2019-04-04 10:02:03 +02:00
Thomas Haller
dfc4e47cd2 acd/tests: assert that nm_acd_manager_announce_addresses() did not fail 2019-04-04 09:56:56 +02:00
Thomas Haller
331073e03c acd/tests: use nm_auto cleanup attributes for mainloop and NMAcdManager 2019-04-04 09:56:19 +02:00
Thomas Haller
e90f4c31b0 acd: return error code from nm_acd_manager_start_probe()
... and nm_acd_manager_announce_addresses().

The test will need more information to know why it may fail.
Return a NetworkManager error code, instead of a boolean.
2019-04-04 09:56:19 +02:00
Thomas Haller
b761064fd8 core: add nm_auto_free_acdmgr cleanup macro 2019-04-04 09:56:19 +02:00
Thomas Haller
f63594c26b shared: add nm_auto_unref_gmainloop cleanup macro 2019-04-04 09:56:19 +02:00
Thomas Haller
ef338667f8 contrib/rpm: disable NDEBUG for meson builds
For better or worse, our release builds commonly do not disable assertions.
That means,

 - NDEBUG is not set, and assert() is in effect
 - G_DISABLE_ASSERT is not set, and g_assert() is in effect
 - G_DISABLE_CHECKS is not set, and g_return*() is in effect.

On the other hand, NM_MORE_ASSERTS is not enabled by default and nm_assert()
is stripped away. That is the actual purpose of nm_assert(): it is
commonly disabled on release builds, while all other assertions are
enabled.

Note that it is fully supported to build NetworkManager with all kind of
assertions disabled. However, such a configuration is not much tested
and I would not recommend it for that reason.

%meson expands to

  $ /usr/bin/meson --buildtype=plain --prefix=/usr --libdir=/usr/lib64 --libexecdir=/usr/libexec --bindir=/usr/bin --sbindir=/usr/sbin --includedir=/usr/include --datadir=/usr/share --mandir=/usr/share/man --infodir=/usr/share/info --localedir=/usr/share/locale --sysconfdir=/etc --localstatedir=/var --sharedstatedir=/var/lib --wrap-mode=nodownload --auto-features=enabled -Db_ndebug=true . x86_64-redhat-linux-gnu $OTHER_ARGS

thus passing -DNDEBUG to the meson build. Override that.
2019-04-04 09:56:19 +02:00
Thomas Haller
c50ef0df3b shared: workaround -Wunused-but-set-variable warning with assertions
Usually, we don't want to build with NDEBUG (because disabling regular
assertions is an untested configuration). Still, when we do, we get
compiler warnings.

Non-debug builds break with a compiler warning:

  $ ccache cc -Ishared/a4d2686@@n-acd@sta -Ishared -I../shared -I../shared/c-siphash/src -I../shared/c-list/src -I../shared/c-rbtree/src -fdiagnostics-color=always -DNDEBUG -pipe -D_FILE_OFFSET_BITS=64 -Werror -std=gnu11 -fdata-sections -ffunction-sections -O2 -g -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fPIC -D_GNU_SOURCE -DSO_ATTACH_BPF=50 -std=c11 -Wno-pointer-arith -Wno-vla -MD -MQ 'shared/a4d2686@@n-acd@sta/n-acd_src_n-acd-probe.c.o' -MF 'shared/a4d2686@@n-acd@sta/n-acd_src_n-acd-probe.c.o.d' -o 'shared/a4d2686@@n-acd@sta/n-acd_src_n-acd-probe.c.o' -c ../shared/n-acd/src/n-acd-probe.c
  ../shared/n-acd/src/n-acd-probe.c: In function 'n_acd_probe_unlink':
  ../shared/n-acd/src/n-acd-probe.c:209:13: error: variable 'r' set but not used [-Werror=unused-but-set-variable]
           int r;
               ^

  $ cache cc -Ishared/a4d2686@@c-rbtree@sta -Ishared -I../shared -fdiagnostics-color=always -DNDEBUG -pipe -D_FILE_OFFSET_BITS=64 -Werror -std=gnu11 -fdata-sections -ffunction-sections -O2 -g -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fPIC -std=c11 -MD -MQ 'shared/a4d2686@@c-rbtree@sta/c-rbtree_src_c-rbtree.c.o' -MF 'shared/a4d2686@@c-rbtree@sta/c-rbtree_src_c-rbtree.c.o.d' -o 'shared/a4d2686@@c-rbtree@sta/c-rbtree_src_c-rbtree.c.o' -c ../shared/c-rbtree/src/c-rbtree.c
  ../shared/c-rbtree/src/c-rbtree.c: In function 'c_rbtree_move':
  ../shared/c-rbtree/src/c-rbtree.c:456:18: error: variable 't' set but not used [-Werror=unused-but-set-variable]
           CRBTree *t;
                    ^

https://github.com/nettools/n-acd/pull/6
https://github.com/c-util/c-rbtree/pull/3
2019-04-04 09:54:44 +02:00
Thomas Haller
645b195f9c gitlab-ci: print information about test environment in tests
It's just interesting to see in the logs.
2019-04-04 09:54:35 +02:00
Thomas Haller
917cd3eb03 systemd: merge branch systemd into master 2019-04-04 09:49:37 +02:00
Thomas Haller
b603222398 systemd: update code from upstream (2019-04-04)
This is a direct dump from systemd git.

======

SYSTEMD_DIR=../systemd
COMMIT=6e79d2b5a414f49c05392cf5f52072c5f081442e

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

git ls-files -z :/src/systemd/src/ \
                :/shared/systemd/src/ \
                :/shared/nm-utils/unaligned.h | \
  xargs -0 rm -f

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

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

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

nm_copy_sd_core "src/libsystemd-network/arp-util.c"
nm_copy_sd_core "src/libsystemd-network/arp-util.h"
nm_copy_sd_core "src/libsystemd-network/dhcp-identifier.c"
nm_copy_sd_core "src/libsystemd-network/dhcp-identifier.h"
nm_copy_sd_core "src/libsystemd-network/dhcp-internal.h"
nm_copy_sd_core "src/libsystemd-network/dhcp-lease-internal.h"
nm_copy_sd_core "src/libsystemd-network/dhcp-network.c"
nm_copy_sd_core "src/libsystemd-network/dhcp-option.c"
nm_copy_sd_core "src/libsystemd-network/dhcp-packet.c"
nm_copy_sd_core "src/libsystemd-network/dhcp-protocol.h"
nm_copy_sd_core "src/libsystemd-network/dhcp6-internal.h"
nm_copy_sd_core "src/libsystemd-network/dhcp6-lease-internal.h"
nm_copy_sd_core "src/libsystemd-network/dhcp6-network.c"
nm_copy_sd_core "src/libsystemd-network/dhcp6-option.c"
nm_copy_sd_core "src/libsystemd-network/dhcp6-protocol.h"
nm_copy_sd_core "src/libsystemd-network/lldp-internal.h"
nm_copy_sd_core "src/libsystemd-network/lldp-neighbor.c"
nm_copy_sd_core "src/libsystemd-network/lldp-neighbor.h"
nm_copy_sd_core "src/libsystemd-network/lldp-network.c"
nm_copy_sd_core "src/libsystemd-network/lldp-network.h"
nm_copy_sd_core "src/libsystemd-network/network-internal.c"
nm_copy_sd_core "src/libsystemd-network/network-internal.h"
nm_copy_sd_core "src/libsystemd-network/sd-dhcp-client.c"
nm_copy_sd_core "src/libsystemd-network/sd-dhcp-lease.c"
nm_copy_sd_core "src/libsystemd-network/sd-dhcp6-client.c"
nm_copy_sd_core "src/libsystemd-network/sd-dhcp6-lease.c"
nm_copy_sd_core "src/libsystemd-network/sd-ipv4acd.c"
nm_copy_sd_core "src/libsystemd-network/sd-ipv4ll.c"
nm_copy_sd_core "src/libsystemd-network/sd-lldp.c"
nm_copy_sd_core "src/libsystemd/sd-event/event-source.h"
nm_copy_sd_core "src/libsystemd/sd-event/event-util.c"
nm_copy_sd_core "src/libsystemd/sd-event/event-util.h"
nm_copy_sd_core "src/libsystemd/sd-event/sd-event.c"
nm_copy_sd_core "src/libsystemd/sd-id128/id128-util.c"
nm_copy_sd_core "src/libsystemd/sd-id128/id128-util.h"
nm_copy_sd_core "src/libsystemd/sd-id128/sd-id128.c"
nm_copy_sd_core "src/shared/dns-domain.c"
nm_copy_sd_core "src/shared/dns-domain.h"
nm_copy_sd_core "src/systemd/_sd-common.h"
nm_copy_sd_core "src/systemd/sd-dhcp-client.h"
nm_copy_sd_core "src/systemd/sd-dhcp-lease.h"
nm_copy_sd_core "src/systemd/sd-dhcp6-client.h"
nm_copy_sd_core "src/systemd/sd-dhcp6-lease.h"
nm_copy_sd_core "src/systemd/sd-event.h"
nm_copy_sd_core "src/systemd/sd-id128.h"
nm_copy_sd_core "src/systemd/sd-ipv4acd.h"
nm_copy_sd_core "src/systemd/sd-ipv4ll.h"
nm_copy_sd_core "src/systemd/sd-lldp.h"
nm_copy_sd_core "src/systemd/sd-ndisc.h"
nm_copy_sd_nmutils "src/basic/unaligned.h"
nm_copy_sd_shared "src/basic/alloc-util.c"
nm_copy_sd_shared "src/basic/alloc-util.h"
nm_copy_sd_shared "src/basic/async.h"
nm_copy_sd_shared "src/basic/env-file.c"
nm_copy_sd_shared "src/basic/env-file.h"
nm_copy_sd_shared "src/basic/env-util.c"
nm_copy_sd_shared "src/basic/env-util.h"
nm_copy_sd_shared "src/basic/errno-util.h"
nm_copy_sd_shared "src/basic/escape.c"
nm_copy_sd_shared "src/basic/escape.h"
nm_copy_sd_shared "src/basic/ether-addr-util.c"
nm_copy_sd_shared "src/basic/ether-addr-util.h"
nm_copy_sd_shared "src/basic/extract-word.c"
nm_copy_sd_shared "src/basic/extract-word.h"
nm_copy_sd_shared "src/basic/fd-util.c"
nm_copy_sd_shared "src/basic/fd-util.h"
nm_copy_sd_shared "src/basic/fileio.c"
nm_copy_sd_shared "src/basic/fileio.h"
nm_copy_sd_shared "src/basic/fs-util.c"
nm_copy_sd_shared "src/basic/fs-util.h"
nm_copy_sd_shared "src/basic/hash-funcs.c"
nm_copy_sd_shared "src/basic/hash-funcs.h"
nm_copy_sd_shared "src/basic/hashmap.c"
nm_copy_sd_shared "src/basic/hashmap.h"
nm_copy_sd_shared "src/basic/hexdecoct.c"
nm_copy_sd_shared "src/basic/hexdecoct.h"
nm_copy_sd_shared "src/basic/hostname-util.c"
nm_copy_sd_shared "src/basic/hostname-util.h"
nm_copy_sd_shared "src/basic/in-addr-util.c"
nm_copy_sd_shared "src/basic/in-addr-util.h"
nm_copy_sd_shared "src/basic/io-util.c"
nm_copy_sd_shared "src/basic/io-util.h"
nm_copy_sd_shared "src/basic/list.h"
nm_copy_sd_shared "src/basic/log.h"
nm_copy_sd_shared "src/basic/macro.h"
nm_copy_sd_shared "src/basic/memory-util.c"
nm_copy_sd_shared "src/basic/memory-util.h"
nm_copy_sd_shared "src/basic/mempool.c"
nm_copy_sd_shared "src/basic/mempool.h"
nm_copy_sd_shared "src/basic/missing_fcntl.h"
nm_copy_sd_shared "src/basic/missing_socket.h"
nm_copy_sd_shared "src/basic/missing_stat.h"
nm_copy_sd_shared "src/basic/missing_type.h"
nm_copy_sd_shared "src/basic/parse-util.c"
nm_copy_sd_shared "src/basic/parse-util.h"
nm_copy_sd_shared "src/basic/path-util.c"
nm_copy_sd_shared "src/basic/path-util.h"
nm_copy_sd_shared "src/basic/prioq.c"
nm_copy_sd_shared "src/basic/prioq.h"
nm_copy_sd_shared "src/basic/process-util.c"
nm_copy_sd_shared "src/basic/process-util.h"
nm_copy_sd_shared "src/basic/random-util.c"
nm_copy_sd_shared "src/basic/random-util.h"
nm_copy_sd_shared "src/basic/set.h"
nm_copy_sd_shared "src/basic/signal-util.h"
nm_copy_sd_shared "src/basic/siphash24.h"
nm_copy_sd_shared "src/basic/socket-util.c"
nm_copy_sd_shared "src/basic/socket-util.h"
nm_copy_sd_shared "src/basic/sort-util.h"
nm_copy_sd_shared "src/basic/sparse-endian.h"
nm_copy_sd_shared "src/basic/stat-util.c"
nm_copy_sd_shared "src/basic/stat-util.h"
nm_copy_sd_shared "src/basic/stdio-util.h"
nm_copy_sd_shared "src/basic/string-table.c"
nm_copy_sd_shared "src/basic/string-table.h"
nm_copy_sd_shared "src/basic/string-util.c"
nm_copy_sd_shared "src/basic/string-util.h"
nm_copy_sd_shared "src/basic/strv.c"
nm_copy_sd_shared "src/basic/strv.h"
nm_copy_sd_shared "src/basic/time-util.c"
nm_copy_sd_shared "src/basic/time-util.h"
nm_copy_sd_shared "src/basic/tmpfile-util.c"
nm_copy_sd_shared "src/basic/tmpfile-util.h"
nm_copy_sd_shared "src/basic/umask-util.h"
nm_copy_sd_shared "src/basic/utf8.c"
nm_copy_sd_shared "src/basic/utf8.h"
nm_copy_sd_shared "src/basic/util.c"
nm_copy_sd_shared "src/basic/util.h"
2019-04-04 09:39:16 +02:00
Thomas Haller
9598adac60 cli,wwan: merge partial branch 'lr/gsm-default-apn'
Cherry-pick two patches from "lr/gsm-default-apn" and merge them to
master early.

Related: https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/98
2019-04-03 11:50:55 +02:00
Lubomir Rintel
5354fe4e7f wwan/modem-broadband: no point in insisting on pre-existing GSM setting
We can just create a default one upon connection completion.
2019-04-03 11:50:36 +02:00
Lubomir Rintel
4ddc2bb766 clients: do not require gsm.apn
The server doesn't require it either.
2019-04-03 11:50:35 +02:00
Rafael Fontenelle
605a575238 libnm-core: Remove duplicated word
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/97
2019-04-03 11:39:27 +02:00
Thomas Haller
d469421669 connectivity/trivial: add code comment 2019-04-03 11:29:33 +02:00
Antonio Larrosa
4c4dbcb78d Coerce connectivity "LIMITED" to "NONE" when device is disconnected
If the device is disconnected it can't have any connectivity, so we can
set it to NONE instead of LIMITED.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/138
Related: https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/99

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/100
2019-04-03 11:25:37 +02:00
Lubomir Rintel
9a8fe5f339 release: bump version to 1.17.2 (development) 2019-04-03 09:04:42 +02:00
Lubomir Rintel
acd734e7b7 merge: branch lr/agent-hints
https://github.com/NetworkManager/NetworkManager/pull/328
2019-04-03 08:59:08 +02:00
Lubomir Rintel
ee73c560b9 secret-agent-simple: pass hints to the auth dialog 2019-04-03 08:57:10 +02:00
Lubomir Rintel
6021ddb349 secret-agent-simple: get rid of an extra variable 2019-04-03 08:57:10 +02:00
Lubomir Rintel
5d481b9210 secret-agent-simple: replace a char array with a GPtrArray
This will make it easier to dynamically add more options.
2019-04-03 08:57:10 +02:00
Lubomir Rintel
b027723e00 Revert "all: goodbye libnm-glib"
We need this for a little little longer :(

This reverts commit 1de8383ad9.
2019-04-03 08:52:38 +02:00
Thomas Haller
61aad8cda4 shared: better implement compat version of explicit_bzero()
If we don't have explicit_bzero(), try a bit harder and use
a volatile pointer.

This is also what libsecret's egg_secure_clear() does [1]. However, for
us this is less important, because commonly we expect glibc to provide
a useable explicit_bzero().

[1] b5442654d4/egg/egg-secure-memory.c (L1352)
2019-04-02 19:30:33 +02:00
Antonio Larrosa
e504b7fc96 Update connectivity value on device removal
When a device is removed (like when the user unplugs a usb network
device) the device object is removed, so it doesn't emit a notify signal
for a change in its connectivity and so, device_connectivity_changed
is not called. This means that nobody updates the global connectivity
value which is potentially wrong if the device was the one providing
network connectivity.

Since device_connectivity_changed's first two parameters aren't actually
used and are there just for the signal to be able to be connected, I
moved the code from device_connectivity_changed to a new
update_connectivity_value function that just takes a NMManager
parameter and also call it from remove_device.

[thaller@redhat.com: fix coding style regarding whitespace]

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/141

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/101
2019-04-02 17:19:31 +02:00
Milo Casagrande
aba01d3d8a po: update Italian (it) translation
* Fixed translation errors.
  * Completed untranslated strings.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/102
2019-04-02 16:52:11 +02:00
Yupeng Chang
1dd67583e3 ifupdown: fix connection iterator
Fixes: 6aa66426a4 ('settings/ifupdown: merge eni_ifaces and connections hashes in plugin')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/145
https://bugzilla.redhat.com/show_bug.cgi?id=1694912
2019-04-02 11:33:25 +02:00
Beniamino Galvani
5b5a768b69 clients: only ask secrets for settings that require them
When nmcli needs secrets for a connection it asks them for every known
setting. nmtui is a bit smarter and asks them only for settings that
actually exist in the connection. Make a step further and let clients
ask secrets only for setting that exist *and* have any secret
property. This decreases the number of D-Bus calls when editing or
showing a connection with secrets.

https://bugzilla.redhat.com/show_bug.cgi?id=1506536
https://github.com/NetworkManager/NetworkManager/pull/327
2019-04-02 11:20:28 +02:00
Lubomir Rintel
9c9c8c68ff cli: fix a crash on "nmcli d wifi hotspot"
Call the correct _finish() function for
nm_client_add_and_activate_connection_async(). add_and_activate_cb()
somewhat confusingly alternates between two different ones depending on
whether info->create is set.

Fixes: 3593237527 ('cli: reuse connections in nmcli dev wifi con')
https://github.com/NetworkManager/NetworkManager/pull/326
2019-04-02 09:09:54 +02:00
Beniamino Galvani
23d8a4f230 libnm-core: fix memory leak in setting test
Fixes: 7fb23b0a62 ('libnm: add NMIPRoutingRule API')
2019-03-31 12:03:31 +02:00
Beniamino Galvani
bd4957fcd7 build: fix searching dlopen in configure
The 4th argument of AC_SEARCH_LIBS is a list of additional libraries,
not the name of the variable to hold the result which is always
ac_cv_search_$function. Also, we should ignore the result when it is
"none required".

Fixes: 1f2eeb85d8 ('build: rename $(LIBDL) to $(DL_LIBS) and modify detection')
2019-03-31 11:36:48 +02:00
Francesco Giudici
a0d1971c23 libnm-core: make compiler happy
../libnm-core/nm-utils.c:6784:30: error: unused variable 'var_unref' [-Werror,-Wunused-variable]
                gs_unref_variant GVariant *var_unref = vlan_var;
2019-03-29 12:16:37 +01:00
Francesco Giudici
bb0ecf07db libnm-core: drop unused variable 2019-03-28 18:35:30 +01:00
Lubomir Rintel
045b88a5b5 ovs: don't traverse interface through disconnected when the ovsdb entry is removed
Go straight to unmanaged. That's what all the other devices do when
their backing resources vanish. If the device reached disconnected
state, an autoconnect check would try to connect it back, in vain.

https://github.com/NetworkManager/NetworkManager/pull/324
2019-03-28 16:55:48 +01:00
Lubomir Rintel
3a55ec63e1 ovs-interface: dissociate the link on disconnection
Open vSwitch is the special kid on the block -- it likes to be in charge of
the link lifetime and so we shouldn't be. This means that we shouldn't be
attempting to remove the link: we'd just (gracefully) fail anyways.

More importantly, this also means that we shouldn't care if we see the link
go away. Once the device reaches DISCONNECTED state, its configuration is
cleaned up and we may already be activating another connection. We shouldn't
alter the device state when OpenVSwitch decides to drop the old link.

https://bugzilla.redhat.com/show_bug.cgi?id=1543557
https://github.com/NetworkManager/NetworkManager/pull/324
2019-03-28 16:55:40 +01:00
Lubomir Rintel
f034f17ff6 settings: keep the added connection alive for a bit longer
Fixes a crash on failed AddAndActivate:

  $ ip link set eth0 down
  $ nmcli d conn eth0
  Error: Failed to add/activate new connection: Connection 'eth0' is not available on device eth0 because device has no carrier
  <NetworkManager crashes>

  #3  0x000055555558b6c5 in _nm_g_return_if_fail_warning
  #4  0x00005555557008c7 in nm_settings_has_connection
  #5  0x0000555555700e5f in pk_add_cb
  #6  0x0000555555726e30 in pk_call_cb
  #7  0x0000555555726e30 in pk_call_cb
  #8  0x0000555555726e30 in pk_call_cb
  #9  0x00005555555aaea8 in _call_id_invoke_callback
  #10 0x00005555555ab2e8 in _call_on_idle

https://github.com/NetworkManager/NetworkManager/pull/325
2019-03-28 14:57:04 +01:00
Thomas Haller
7680014732 libnm,core: merge branch 'th/routing-rule-pt2'
https://github.com/NetworkManager/NetworkManager/pull/321
2019-03-27 16:32:39 +01:00
Thomas Haller
3f9347745b core: add handling of IP routing rules to NMDevice 2019-03-27 16:23:30 +01:00
Thomas Haller
ba59c7c3c0 cli: add support for routing rules to nmcli 2019-03-27 16:23:30 +01:00
Thomas Haller
4d46804437 ifcfg-rh: add support for routing rules as "ROUTING_RULE_#" keys
initscripts support rule-* and rule6-* files for that.

Up until now, we ignored these files for the most part, except if
a user configured such files, the profile could not contain any static
routes (or specify a route-table setting). This also worked together
with the dispatcher script "examples/dispatcher/10-ifcfg-rh-routes.sh".

We cannot now start taking over that file format for rules. It might
break existing setups, because we can never fully understand all rules as
they are understood by iproute2. Also, if a user has a rule/rule6 file and
uses NetworkManager successfully today, then clearly there is a script
in place to make that work. We must not break that when adding rules
support.

Hence, store routing rules as numbered "ROUTING_RULE_#" and
"ROUTING_RULE6_#" keys.

Note that we use different keys for IPv4 and IPv6. The main reason is
that the string format is mostly compatible with iproute2. That means,
you can take the value and pass it to `ip rule add`.
However, `ip rule add` only accepts IPv4 rules. For IPv6 rules, the user
needs to call `ip -6 rule add`. If we would use the same key for IPv4
and IPv6, then it would be hard to write a script to do this.
Also, nm_ip_routing_rule_from_string() does take the address family as
hint in this case. This makes

  ROUTING_RULE_1="pref 1"
  ROUTING_RULE6_1="pref 1"

automatically determine that address families. Otherwise, such
abbreviated forms would be not valid.
2019-03-27 16:23:30 +01:00
Thomas Haller
6e6d1e070c libnm: add API to NMSettingIPConfig for routing rules 2019-03-27 16:23:30 +01:00
Thomas Haller
7fb23b0a62 libnm: add NMIPRoutingRule API
Add NMIPRoutingRule API with a few basic rule properties. More
properties will be added later as we want to support them.

Also, add to/from functions for string/GVariant representations.
These will be needed to persist/load/exchange rules.

The to-string format follows the `ip rule add` syntax, with the aim
to be partially compatible. Full compatibility is not possible though,
for various reasons (see code comment).
2019-03-27 16:23:30 +01:00
Thomas Haller
71e40f519d cli: support escaping for splitting for objlist properties 2019-03-27 16:23:30 +01:00