Commit Graph

21088 Commits

Author SHA1 Message Date
Thomas Haller
5912b2f9a1 core: persist the fake permanent hardware address to the device's statefile
On devices that have no real permanent hardware address (as returned
by ethtool), we take the current MAC address of the device.

Currently, NM is a bit flaky about whether to accept such fake permanent
addresses for settings like keyfile.unmanaged-devices or the per-
connection property ethernet.mac-address. Probably, we should allow
using fake addresses there in general.

However, that leads to problems because NetworkManager itself changes
the current MAC address of such devices. For example when
configuing

  keyfile.unmanaged-device=22:33:44:55:66:77

and later activating a connection with

  ethernet.cloned-mac-address=22:33:44:55:66:77

we have a strange situation after restart and the device becomes
unmanaged.

We are going to avoid that, by remembering the fake permanent address
in the device state file.

This only matters:

  - for devices that don't have a real permanent address (veth)

  - if the user or NetworkManager itself changed the MAC address
    of the device

  - after a restart of NetworkManager, without reboot. A reboot
    clears the device state for /var/run/NetworkManager.
2016-10-28 16:44:56 +02:00
Thomas Haller
e5fe5a4c03 libnm-core/utils: update hwaddr utilities
_nm_utils_hwaddr_length() did a validation of the string
and returned the length of the address. In all cases where
we were interested in that, we also either want to validate
the address, get the address in binary form, or canonicalize
the address.

We can avoid these duplicate checks, by using _nm_utils_hwaddr_aton()
which both does the parsing and returning the length.
2016-10-28 16:28:29 +02:00
Thomas Haller
5e208e59b3 config: remove unused error variable from nm_config_device_state_load() 2016-10-28 16:28:29 +02:00
Thomas Haller
ba950cedee shared: add nm_assert_se() macro
We usually don't build NM with g_assert() disabled (G_DISABLE_ASSERT).
But even if we would, there is no assertion macro that always evaluates
the condition for possible side effects.

I think that is a useful thing to have.
2016-10-28 16:28:29 +02:00
Beniamino Galvani
632dd26288 manager: allow slave connection to auto-connect its slaves
Since connection.autoconnect-slaves was introduced, we only allowed it
to autoactivate slaves for connections that were not slave themselves.

It seems useful to remove such limitation, but we must prevent an
infinite loop if there is a circular dependency between connections.

https://bugzilla.redhat.com/show_bug.cgi?id=1360386
2016-10-28 16:00:12 +02:00
Thomas Haller
2ce3c42d4f contrib/rpm: merge branch 'th/no-dhclient-default-rh1204226'
https://bugzilla.redhat.com/show_bug.cgi?id=1204226
2016-10-27 11:50:52 +02:00
Thomas Haller
1c1da147c9 contrib/rpm: update comments in NetworkManager.conf explaining /var/lib/NetworkManager/conf.d 2016-10-27 11:50:24 +02:00
Thomas Haller
209b5a57fd contrib/rpm: add NetworkManager-config-dhcp-dhclient package
This allows to get rid of the dhclient requirement of NetworkManager
package and moves the package dependency to the new sub package
NetworkManager-config-dhcp-dhclient.

For the moment, I think dhclient should still be the default choice for
regular users due to dhclient providing better better previledge separation
of network facing code. A user who knows that he's doing, can now however
remove dhclient while keeping NetworkManager.

https://bugzilla.redhat.com/show_bug.cgi?id=1204226
2016-10-27 11:46:15 +02:00
Thomas Haller
e9bf87805c dhcp: make default dhcp plugin configurable at compile-time 2016-10-27 11:28:01 +02:00
Thomas Haller
d298b7c96d core: don't unmanage devices on shutdown
... except Wi-Fi and devices that cannot assume connections at all.

https://bugzilla.redhat.com/show_bug.cgi?id=1371126
https://bugzilla.redhat.com/show_bug.cgi?id=1378418
2016-10-27 11:09:47 +02:00
Thomas Haller
1bb2103aa9 build: fix search path for building vapi
`make V=1` fails with:

    G_DEBUG='' /usr/bin/vapigen-0.26  --library vapi/libnm-glib --metadatadir ./vapi --vapidir . --girdir ./libnm-util --pkg gio-2.0 ./libnm-glib/NMClient-1.0.gir && touch vapi/libnm-glib.vapi
    error: Package `libnm-util' not found in specified Vala API directories or GObject-Introspection GIR directories
    Generation failed: 1 error(s), 0 warning(s)

Fixes: 14b5309af3
2016-10-26 16:25:53 +02:00
Beniamino Galvani
108f04e71e cli: completion: escape shell special characters "()&!"
https://bugzilla.gnome.org/show_bug.cgi?id=772629
2016-10-26 13:41:00 +02:00
Beniamino Galvani
7034ea7aa3 wwan: fix wrong connection cast on device state change
nm_settings_connection_set_autoconnect_blocked_reason() must be called
on the settings-connection. Fixes the following:

GLib-GObject-WARNING **: invalid cast from 'NMSimpleConnection' to 'NMSettingsConnection'

Fixes: 06da353242
2016-10-26 13:21:09 +02:00
Francesco Giudici
d860ccfc7b build: add glob-util.h to systemd source list
Fixes d00d907c06
2016-10-26 11:34:25 +02:00
Francesco Giudici
7939f373be build: fix "settings-docs.c" include path
Fixes: c8a25001f4
2016-10-25 16:44:47 +02:00
Thomas Haller
d00d907c06 systemd: merge branch systemd into master 2016-10-24 17:39:38 +02:00
Thomas Haller
d84a275bd2 systemd: update code from upstream
This is a direct dump from systemd git on 2016-10-24, git commit
9b3313d678a4f666e9ddc086a8e92652c9294411.

======

SYSTEMD_DIR=../systemd
COMMIT=9b3313d678a4f666e9ddc086a8e92652c9294411

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

git ls-files :/src/systemd/src/ | xargs -d '\n' rm -f

nm_copy_sd() {
    mkdir -p "./src/systemd/$(dirname "$1")"
    cp "$SYSTEMD_DIR/$1" "./src/systemd/$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/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 "src/basic/siphash24.c"
nm_copy_sd "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 "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"
2016-10-24 17:22:45 +02:00
Thomas Haller
0846cb98aa src/tests: relax assertion for test_nm_utils_monotonic_timestamp_as_boottime()
When running under load (e.g. with parallel make and valgrind
enabled), the checked time interval might be too short. Relax
the assertion

    NetworkManager:ERROR:src/tests/test-general-with-expect.c:65:test_nm_utils_monotonic_timestamp_as_boottime: assertion failed (now_boottime_2 - now_boottime <= NM_UTILS_NS_PER_SECOND / 1000): (15156494 <= 1000000)
2016-10-24 15:27:31 +02:00
Thomas Haller
6df24ee8cc platform/tests: relax assertion for expected link-changed signal 2016-10-24 15:15:15 +02:00
Thomas Haller
be822292d8 build: remove long gone libndp submodule from configure.ac 2016-10-24 12:01:54 +02:00
Thomas Haller
8cca81bbb0 libnm: merge branch 'th/libnm-no-empty-string-properties-rh1380424'
https://bugzilla.redhat.com/show_bug.cgi?id=1380424
2016-10-24 10:14:02 +02:00
Thomas Haller
95ab69b761 libnm: coerce empty strings to NULL for D-Bus properties
On D-Bus level, string (s) or object paths (o) cannot be NULL.
Thus, whenver server exposes such an object, it gets automatically
coerced to "" or "/", respectively.

On client side, libnm should coerce certain properties back, for which
"" is just not a sensible value.

For example, an empty NM_DEVICE_ETHERNET_HW_ADDRESS should be instead
exposed as NULL.

Technically, this is an API change. However, all users were well advised
to expect both NULL and "" as possible return values and handle them
accordingly.
2016-10-24 10:14:02 +02:00
Thomas Haller
21d7aa9204 libnm: minor refactoring by using g_clear_object() and nm_str_not_empty() 2016-10-24 10:14:02 +02:00
Thomas Haller
c4198d45e3 libnm: avoid possibly NULL address for NMDeviceVlan calling nm_utils_hwaddr_matches() 2016-10-24 10:14:02 +02:00
Thomas Haller
7eb054d099 libnm: fix memleak in NMDeviceVxlan 2016-10-24 10:14:02 +02:00
Thomas Haller
16a6991b90 team: minor cleanup handling empty team config 2016-10-24 10:14:02 +02:00
Thomas Haller
34970e4141 shared: make nm_str_not_empty() inline function instead of macro
It was a macro to pass on the non-const-ness of the argument, but
that just doesn't make sense.

That is a signature

  char *nm_str_not_empty (char *)

does not make sense, because you cannot transfer ownership
conditionally without additional checks to avoid a leak. Which makes
this form is pointless. For example:

    char *
    foo (void)
    {
        char *s;

        s = _create_value ();
        return nm_str_not_empty (s); /* leaks "" */
    }
2016-10-24 10:14:02 +02:00
Beniamino Galvani
ddeef464af checkpoint: introduce new flags to better restore previous state
When a global checkpoint is created (one with empty device list) we
save the status of all devices to restore it later. After the
checkpoint new interfaces and connections may appear and they can
significantly influence the overall networking status, but we don't
consider them at the moment.

Introduce a new flag DELETE_NEW_CONNECTIONS to delete any connection
added after the checkpoint and similarly a DISCONNECT_NEW_DEVICES to
ensure that the connection active on newly appeared devices doesn't
disrupt network connectivity.

https://bugzilla.redhat.com/show_bug.cgi?id=1378393
2016-10-24 09:57:18 +02:00
Thomas Haller
a5e3016fc9 man: document /var/run/NetworkManager/conf.d directory 2016-10-23 13:33:09 +02:00
Thomas Haller
b8b47babd2 config: avoid conflicts of /run config dir with other directories
The user can configure the configuration paths via command line
arguments. If the user configures /var/run/NetworkManager/conf.d
as --system-config-dir or --config-dir, avoid using it as run-config
directory.

Yes, this doesn't catch

  NetworkManager --config-dir=/etc/NetworkManager/conf.d \
          --system-config-dir=/etc/NetworkManager/conf.d/
2016-10-23 12:52:01 +02:00
Thomas Haller
3248b387a2 config: merge branch 'th/run-conf.d-bgo773069'
https://bugzilla.gnome.org/show_bug.cgi?id=773069
2016-10-23 11:42:51 +02:00
Thomas Haller
4b965d0cf6 build: exclude building src/platform/tests/monitor for --enable-tests=no
src/platform/tests/monitor is more a test-program. If should not
be compiled in a non-test build.
2016-10-23 10:52:57 +02:00
Thomas Haller
b5aec6b7e7 config: cleanup ownership handling of @keyfile in read_entire_config() 2016-10-23 10:52:57 +02:00
Thomas Haller
f8c4a33f25 config: add run-configs to description string 2016-10-23 10:52:57 +02:00
Martin Pitt
49fcfcdfae config: skip shadowed run-config files in read_entire_config()
https://bugzilla.gnome.org/show_bug.cgi?id=773069
2016-10-23 10:52:57 +02:00
Mathieu Trudel-Lapierre
feff60ef3e config: read /run/NetworkManager/conf.d files
This is useful for configuration that gets auto-generated from another source.
These are then not primary configuration files and thus should not be put into
/etc.

This mirrors the structure of udev rules or systemd units, which can also be in
/usr, /run/, or /etc/.

Signed-off-by: Mathieu Trudel-Lapierre <mathieu.trudel-lapierre@canonical.com>

https://bugzilla.gnome.org/show_bug.cgi?id=773069
2016-10-23 10:52:57 +02:00
Thomas Haller
9cb2bbe658 build: merge branch 'th/build-cleanup'
Some cleanup of the toplevel Makefile.am.

The aim it to build every source file only once. That saves compilation
time, but more importantly it guarantees that there are no differing CFLAGS
and all users use exactly the same binary.
2016-10-22 17:56:32 +02:00
Thomas Haller
5cb60e7099 build: combine CPPFLAGS for src/tests 2016-10-22 17:55:44 +02:00
Thomas Haller
7b73951b1b build: buld nm-dhcp-manager.c as part of libNetworkMangerBase
NetworkManager and nm-iface-helper compiled nm-dhcp-manager.c twice,
the latter with setting -DNM_DHCP_INTERNAL_ONLY to only enable the
internal plugin.

Change that to compile nm-dhcp-manager.c once for both users
by putting it into libNetworkManagerBase.
2016-10-22 17:55:15 +02:00
Thomas Haller
f9bd72c337 build: build src/platform/tests/test-common.c as part of libNetworkManagerTest.la
Instead having a base test-library libNetworkManagerTest.la and a separate
libnm-platform-tests.la, merge them together.
2016-10-22 17:16:17 +02:00
Thomas Haller
58916ff30a build: refactor intermediate NetworkManager libraries during build
nm-iface-helper re-compiled a number of source files that are already
compiled for NetworkManager. Prepare those files as libNetworkManagerBase.la.
2016-10-22 17:16:17 +02:00
Thomas Haller
002f17c25d src: drop generated nm-src-enum-types.h
We only needed proper glib enum types for having properties
and signal arguments. These got all converted to plain int,
so no longer generate such an enum type.
2016-10-22 17:16:17 +02:00
Thomas Haller
3bbc55fd9c core: don't use generated glib enum for platform types 2016-10-22 17:16:17 +02:00
Thomas Haller
931a5b4f1c core: don't use generated glib enum for NMAuthSubjectType 2016-10-22 17:16:17 +02:00
Thomas Haller
5657d4dffb build: reuse common CPPFLAGS via dflt_cppflags_libnm_core variable 2016-10-22 17:16:17 +02:00
Thomas Haller
f5c5dba4f5 build: don't link libnm-wwan.la against introspection/libnmdbus.la
Also, the $(top_builddir) was wrong.
2016-10-22 17:15:50 +02:00
Thomas Haller
6375c54679 travis: build additional settings plugin in travis-ci
Although the build environment is Ubuntu, we still can build the
non-native settings plugins to test the build.
2016-10-22 17:15:50 +02:00
Thomas Haller
4450215ad1 build: fix out-of-tree build for libnm-core/tests 2016-10-22 17:12:06 +02:00
Thomas Haller
548a5440e9 ifcfg-rh: fix signature of link_changed() callback
Depending on how arguments are passed to the called function,
this could lead to a crash.

Maybe not on 32 bit machines where the size of the pointer is
the size of an int.

Maybe not on x86_64, where the arguments are passed in registers.

Fixes: b88c309167
2016-10-22 16:12:58 +02:00
Thomas Haller
9f11610606 build: fix out-of-tree build for dispatcher 2016-10-22 16:12:46 +02:00