Commit graph

8768 commits

Author SHA1 Message Date
Thomas Haller
950991d781 supplicant: fix passing FALSE to hidden argument for nm_supplicant_config_add_option()
Fixes: 34b4a0e561
2017-01-12 13:57:02 +01:00
Dan Williams
8de7b8ed31 device/wwan: indicate whether IP iface/ifindex changed and simplify WwAN code
Replace some code in the WWAN device class that checks for a changed
interface name with code that uses the new return value from
nm_device_set_ip_iface(), which now checks whether the ip_ifindex
changed too.

https://mail.gnome.org/archives/networkmanager-list/2017-January/msg00010.html
2017-01-12 13:34:22 +01:00
Thomas Haller
bf3b3d444c device: avoid changing immutable properties during reapply
We allow to reapply a connection with different id, uuid, stable-id, autoconnect value.
This is allowed for convenience, so that a user can reapply a connection that differs
in these fields. But actually, these fields cannot be reapplied. That
is, their new values are not considered and the old values are continued
to be used.

Thus, mangle the reapplied connection to use the original, actually used
values.
2017-01-12 13:02:25 +01:00
Thomas Haller
304e2f56af device: allow reapplying a connection with differing stable-id
The stable-id for one activation cannot actually change. This is also, because we cache it
as priv->current_stable_id. Still, allow reapply with a differing stable-id for convenience.
2017-01-12 12:59:07 +01:00
Lubomir Rintel
9b9a180597 ifcfg-rh: unknown scheme means no certificate at all
Fixes: 30db08d38e
2017-01-11 15:12:29 +01:00
Lubomir Rintel
30db08d38e ifcfg-rh: don't ignore certificates with unknown scheme 2017-01-10 23:30:18 +01:00
Lubomir Rintel
13b2ac2214 sparse: avoid clash with __bitwise and __force from 4.10 linux/types.h
It also used __bitwise and __force. It seems easier to rename
our versions since they are local to this one single header.

Also, undefine them afteerwards, so that we don't pollute the
preprocessor macro namespace.

https://github.com/systemd/systemd/pull/5061
2017-01-10 20:21:34 +01:00
Beniamino Galvani
1dbd9d7948 platform: don't update IPv6 temporary addresses
The kernel already takes care of adding and updating temporary
addresses when an address with IFA_F_MANAGETEMPADDR flag is added or
updated; doing it also in nm_platform_ip6_address_sync() can overwrite
the changes done by kernel, especially because since commit
0a0bca9c7f ("ip6-config: sort addresses only when reading the
property value") there is no guarantee that temporary addresses are
before the public ones in the IPv6 configuration.

Still delete temporary addresses, but don't add or update them.
2017-01-10 15:39:15 +01:00
Thomas Haller
6eb2d60fbe iface-helper: don't cache nm_platform_check_support_kernel_extended_ifa_flags() flag
nm_platform_check_support_kernel_extended_ifa_flags() is already cached in a static
variable. Just look it up anew every time.
2017-01-10 14:29:46 +01:00
Beniamino Galvani
a9384452ed settings: fix assertion when changing connection managed state
When a ifcfg-rh connection becomes unamanaged it is removed from the
connection list in NMSettings and marked as removed; it is however
kept alive in the plugin and can become managed again later. To avoid
failed assertions, the @removed flag of the NMSettingsConnection must
be cleared if the connection is not being disposed.
2017-01-10 14:26:32 +01:00
Thomas Haller
be1f04038d device: fix invalid assertion
Fixes: f0d40525df
2017-01-09 20:24:23 +01:00
Thomas Haller
f0d40525df device: support dynamic "connection.stable-id" in form of text-substitution
Usecase: when connecting to a public Wi-Fi with MAC address randomization
("wifi.cloned-mac-address=random") you get on every re-connect a new
IP address due to the changing MAC address.
"wifi.cloned-mac-address=stable" is the solution for that. But that
means, every time when reconnecting to this network, the same ID will
be reused. We want an ID that is stable for a while, but at a later
point a new ID should e generated when revisiting the Wi-Fi network.

Extend the stable-id to become dynamic and support templates/substitutions.
Currently supported is "${CONNECTION}", "${BOOT}" and "${RANDOM}".
Any unrecognized pattern is treated verbaim/untranslated.

"$$" is treated special to allow escaping the '$' character. This allows
the user to still embed verbatim '$' characters with the guarantee that
future versions of NetworkManager will still generate the same ID.
Of course, a user could just avoid '$' in the stable-id unless using
it for dynamic substitutions.

Later we might want to add more recognized substitutions. For example, it
could be useful to generate new IDs based on the current time. The ${} syntax
is extendable to support arguments like "${PERIODIC:weekly}".

Also allow "connection.stable-id" to be set as global default value.
Previously that made no sense because the stable-id was static
and is anyway strongly tied to the identity of the connection profile.
Now, with dynamic stable-ids it gets much more useful to specify
a global default.

Note that pre-existing stable-ids don't change and still generate
the same addresses -- unless they contain one of the new ${} patterns.
2017-01-09 14:50:33 +01:00
Thomas Haller
21ae09c1cc core: add assertions for network_id/stable_type
We require a network-id. Assert that it is set.

Also, we encode the stable-id as uint8. Thus, add
an assertion that we don't use more then 254 IDs.

If we ever make use of stable-type 255, we must extend
the encoding to allow for more values. The assertion
is there to catch that.
2017-01-09 14:50:33 +01:00
Thomas Haller
dea3c49ce2 utils: add nm_utils_get_boot_id() util to read "/proc/sys/kernel/random/boot_id" 2017-01-09 14:50:33 +01:00
Beniamino Galvani
ae5adc9e21 vpn: add device route to VPN gateway if parent has no gateway
We set a dedicated route to reach the VPN gateway only if the parent
device has a gateway. If the parent device doesn't have a gateway (for
example in case of GSM connections) and the VPN gets the default
route, the VPN gateway will be contacted through the VPN itself, which
obviously doesn't work.

Set up a device route if the parent device doesn't provide a gateway.

https://bugzilla.redhat.com/show_bug.cgi?id=1403660
2017-01-07 15:05:03 +01:00
Lubomir Rintel
234a72cb91 supplicant: allow accessing certs and keys in PKCS#11 tokens 2017-01-06 15:56:11 +01:00
Lubomir Rintel
34b4a0e561 supplicant: allow specifying a replacement string for hidden items
Makes it possible to hide only a part of a value (such as inline PIN),
but still log useful info.
2017-01-06 15:56:11 +01:00
Lubomir Rintel
faed200b2b keyfile: add support for pkcs11: URI scheme 2017-01-06 15:56:11 +01:00
Lubomir Rintel
260563a7d9 all: use nm_utils_is_valid_iface_name() 2017-01-06 15:11:56 +01:00
Thomas Haller
f779c51f87 shared: move nm_utils_strbuf_*() helper to shared/nm-utils 2017-01-05 11:13:17 +01:00
Thomas Haller
f4fb4d271f keyfile/tests: add test for reading dcb connection
Catches previously fixed memleak in read_array_of_uint()
2017-01-05 11:13:17 +01:00
Thomas Haller
a8afbb7299 systemd: merge branch systemd into master 2017-01-04 15:55:46 +01:00
Thomas Haller
17820bf42a systemd: update code from upstream
This is a direct dump from systemd git on 2017-01-04, git commit
6a47fd894d601f7e8e88dec4cb35dfb7d7c15eff.

======

SYSTEMD_DIR=../systemd
COMMIT=6a47fd894d601f7e8e88dec4cb35dfb7d7c15eff

(
  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"
2017-01-04 15:46:38 +01:00
Thomas Haller
2a14a1c7bd device: drop unused hook nm_device_notify_new_device_added()
The only implementations were there for tracking the parent device.
That is now donw via nm_device_parent_*(), parent_changed_notify()
and _parent_notify_changed().
2017-01-04 14:18:01 +01:00
Thomas Haller
992beb4f34 device: move tracking of peer device from NMDeviceVeth to NMDevice 2017-01-04 14:18:01 +01:00
Thomas Haller
6df235df74 device: move tracking of parent device from NMDeviceVxlan to NMDevice 2017-01-04 14:18:01 +01:00
Thomas Haller
b8bfdd99af device: move tracking of parent device from NMDeviceVlan to NMDevice 2017-01-04 14:18:01 +01:00
Thomas Haller
31682f7a3b device: move tracking of parent device from NMDeviceMacvlan to NMDevice 2017-01-04 14:18:01 +01:00
Thomas Haller
3be1811a7d device: move tracking of parent device from NMDeviceIPTunnel to NMDevice 2017-01-04 14:18:01 +01:00
Thomas Haller
f703f4bb65 device: track parent device in NMDevice
Multiple subclasses have a parent/link interface (NMDeviceIPTunnel,
NMDeviceVlan). Tracking the parent interface properly is midly
complicated to get right. So, instead of repeating it in each
subclass, track it in the parent device.
2017-01-04 14:18:01 +01:00
Thomas Haller
bd09decf16 device: only emit notify::ifindex when the value actually changes 2017-01-04 14:18:01 +01:00
Thomas Haller
78017f1bdc device: cleanup setting of ip-iface
Move the updating/setting of the ip-ifindex/ip-iface to one place.

Properties should be for the most part immutable/read-only, and only
at particular places modified. That way, it's easier to track who
changes a property.

Also, add a logging line with "ip-ifname" prefix.
2017-01-04 14:18:01 +01:00
Thomas Haller
87076d9345 platform: use wrappers for if_nametoindex() and if_indextoname() 2017-01-04 14:18:01 +01:00
Thomas Haller
e8d5a8356c platform: add wrappers for if_nametoindex() and if_indextoname() 2017-01-04 14:18:01 +01:00
Thomas Haller
d481489804 device: mark _nm_device_log_self_to_device() as unused 2017-01-04 14:18:01 +01:00
Thomas Haller
15d8634b9a trivial: rename reload_tun_properties() to update_properties()
That is what the function is called in other device implementations.
2017-01-04 14:18:01 +01:00
Thomas Haller
0eb4b404f2 device: have realize_start_notify() call link_changed()
Most implementations of realize_start_notify() do the same
for link_changed().

Let NMDevice's base implementation of realize_start_notify() call
link_changed() -- which by default does notthing. This allows subclasses
to only overwrite link_changed().
2017-01-04 14:18:01 +01:00
Thomas Haller
0bb84d1b85 device/ethernet: refactor loading s390 subchannels during realize
Instead of overwriting constructed(), update the s390 subchannels via
realize_start_notify(). This makes more sense and is also more similar
to what other device implementations do.
2017-01-04 14:18:01 +01:00
Thomas Haller
7e4120860f device/vlan: update vlan properties when link changes
For example, when the parent link is moved to a different netns,
we must update (clear) the vlan's parent.
2017-01-04 14:18:01 +01:00
Thomas Haller
a2dce28fc8 device: do nothing in NMDevice's link_changed() function
All implementations of link_changed() chain up to NMDevice's
base implementation. Thus, everybody wants to set the carrier.

Refactor the code to set the carrier outside of link_changed().
2017-01-04 14:18:01 +01:00
Thomas Haller
c2bc2fbac3 device: make @pllink argument in link_changed() function const 2017-01-04 14:18:01 +01:00
Thomas Haller
d9efe73fed wifi: fix nm_wifi_ap_get_id() to parse the ID as guint64 from the exported path 2017-01-04 14:05:27 +01:00
Thomas Haller
49ec12bab3 wifi: implement NM_DEVICE_WIFI_ACCESS_POINTS property getter via ap_list_get_sorted_paths()
That way, we get the list sorted. Also, it saves several allocations of
temporary variables.
2017-01-04 14:05:27 +01:00
Thomas Haller
7c601ab8ca wifi: refactor getting sorted AP list
Instead of creating a GSList use an array. That way, we save
the allocation and free of an GSList instance. Also, avoid
cloning the export path. It is stable.
2017-01-04 14:05:27 +01:00
Thomas Haller
674f5f24af dns: fix memleak in _get_config_variant()
There are cases where we wouldn't call g_variant_builder_end()
on @strv_builder and @entry_builder.

Fixes: e3c67177ac
2017-01-04 14:05:22 +01:00
Thomas Haller
2486dc5c45 exported-object: don't use "/0" for D-Bus paths but start with 1
Only use non-negative index values for the D-Bus path. This is purely
cosmetical, as the actual path value should be treated as opaque. Still,
avoid using 0 and start counting at 1.
2017-01-03 15:46:59 +01:00
Thomas Haller
cd1466190e exported-object: don't clone class_export_path for counter cache
It's a static string anyway.
2017-01-03 15:46:10 +01:00
Thomas Haller
8006045d0d exported-object: make export_path D-Bus counter 64 bit
An overflow of the 32 bit guint is possible and rather ugly
because the D-Bus path should be unique and not repeat.
Avoid that by extending the counter to 64 bit.
2017-01-03 15:42:53 +01:00
Thomas Haller
32dd257d31 exported-object: use NM_EXPORT_PATH_NUMBERED() macro 2017-01-03 15:40:17 +01:00
Thomas Haller
20431a4c16 exported-object: add NM_EXPORT_PATH_NUMBERED() macro 2017-01-03 15:38:49 +01:00