Commit graph

9177 commits

Author SHA1 Message Date
Beniamino Galvani
a72ffe230b supplicant: enable PMF only when wpa_supplicant supports it 2017-04-15 10:37:33 +02:00
Beniamino Galvani
d38eadd990 supplicant: enable PMF based on driver type
Instead of adding a new flag to configuration based on connection
type, use the driver-type field directly in the supplicant-interface.
2017-04-15 10:36:55 +02:00
Michael Cronenworth
8b051bb35e supplicant: Initial pmf support (a.k.a. MFP, a.k.a. 802.11w)
https://bugzilla.gnome.org/show_bug.cgi?id=748367

Signed-off-by: Michael Cronenworth <mike@cchtml.com>
2017-04-15 10:24:53 +02:00
Thomas Haller
b78562570a core: ignore host part when comparing routes for route-manager 2017-04-15 00:35:25 +02:00
Thomas Haller
5c54b7a31e route-manager: normalize host part of tracked routes in _vx_route_sync()
The input list of routes is allowed to contain non-normalized routes,
that is, routes which host part is non-zero. Such routes are rejected
by kernel, but NM should transparently allow them (by normalizing
the host part).

The ID comparison function route_id_cmp() already properly ignored
the (possibly non-zero) host part. However, in the internal list we
also should make sure not to track such routes. We achive that by
normalizing the host part to zero.

Note that below we check whether the tracked route is idential to
the route configured at platform. If we don't normalize the host part,
the comparison will always indicate that the route is not yet
configured, and thus we will re-sync the route every time.
2017-04-15 00:35:25 +02:00
Thomas Haller
034b7fb51c src: only compare network parts of routes in nm_utils_match_connection()
Kernel requires that routes have a host part of zero. For NetworkManager
configuration we allow non-zero host parts (but ignore them). Fix
route_compare() to ignore the host part.

This has only effect during assuming connections. That means, on
restart NM would fail to match a connection with static routes
if it has a non-zero host part. So, the impact is rather small.
2017-04-15 00:35:25 +02:00
Thomas Haller
57b0dce083 platform: only consider net part of routes for route cache's ID
Routes with a non-zero host part are not allowed by kernel and
don't really exist. We didn't reject such routes in users configuration,
so various part of NM allow such routes. NM should silently strip
the host part.

Extend the cache's route ID to clear the host part too.

Note that NM's handling of routes is fundamentally flawed, as
for kernels routes don't have an "id" (or rather: all properties
of a route are part of it's ID, not only the family,ifindex,
network/plen and metric tuple (see related bug rh#1337855).
2017-04-15 00:35:25 +02:00
Thomas Haller
11d8c41898 platform: cleanup possibly non-zero host part for route operations
Platform's add/remove operations accept a "network" argument.
Kernel requires that the host part (based on plen) is all zero.
For NetworkManager we are more resilient to user configuration.

Cleanup the input argument already before calling _nl_msg_new_route().
Note that we use the same "network" argument to construct a obj_id
instance and to find the route in the cache (do_add_addrroute()).
Without cleaning the host part, the added object cannot be found
and the add-route command seemingly fails.
2017-04-15 00:35:25 +02:00
Thomas Haller
b23484be72 vpn: inline call_plugin_disconnect()
There is only one caller. Don't bother moving the logic to a separate
function.
2017-04-15 00:31:23 +02:00
Thomas Haller
bc1d1c9df4 vpn: avoid calling call_plugin_disconnect() without proxy
Got an assertion due to priv-proxy unset.
  NMDevice:
    - _platform_link_cb_idle()
     - nm_device_unrealize() [NMDeviceTun]
      - nm_device_state_changed()
       - _set_state_full()
         NMVpnConnection:
           - _set_vpn_state()
            - call_plugin_disconnect()

It seam to me, that can only happen if the NMVpnConnection never
completed on_proxy_acquired() and is still in preparing state when
being disconnected.

Avoid that be checking whether we have a proxy.

https://bugzilla.redhat.com/show_bug.cgi?id=1442064
2017-04-15 00:31:23 +02:00
Beniamino Galvani
69fd96118e manager: unexport VPN connections when the activation fails early
When a VPN connection can't be activated we have to unexport and
dispose it. Commit f2182fbf9b ("core: don't emit double
PropertiesChanged signal for new active connections") removed the call
to nm_exported_object_unexport() in case of failure because the active
connection already gets unreferenced on failure.

However, an exported object can't be disposed until it's explicitly
unexported because GDBus code keeps a reference to it. The result was
that the active connection was kept alive and exported, but without
explicit references to it. As soon as the connection was unexported,
it was also automatically disposed, causing issues like:

 (src/nm-exported-object.c:1025):dispose: code should not be reached

 #0   _g_log_abort () at /lib64/libglib-2.0.so.0
 #1   g_logv () at /lib64/libglib-2.0.so.0
 #2   g_log () at /lib64/libglib-2.0.so.0
 #3   g_warn_message () at /lib64/libglib-2.0.so.0
 #4   dispose (object=0xaaf110) at src/nm-exported-object.c:1025
 #5   dispose (object=0xaaf110) at src/nm-active-connection.c:1246
 #6   dispose (object=0xaaf110) at src/vpn/nm-vpn-connection.c:2642
 #7   g_object_unref () at /lib64/libgobject-2.0.so.0
 #8   registration_data_free () at /lib64/libgio-2.0.so.0
 #9   g_hash_table_remove_internal () at /lib64/libglib-2.0.so.0
 #10  g_dbus_object_manager_server_unexport_unlocked () at /lib64/libgio-2.0.so.0
 #11  g_dbus_object_manager_server_unexport () at /lib64/libgio-2.0.so.0
 #12  nm_bus_manager_unregister_object (self=0x9069e0, object=object@entry=0xaaf110) at src/nm-bus-manager.c:858
 #13  nm_exported_object_unexport (self=0xaaf110) at src/nm-exported-object.c:714
 #14  _settings_connection_removed (connection=<optimized out>, user_data=0xaaf110) at src/nm-active-connection.c:184
 #15  g_closure_invoke () at /lib64/libgobject-2.0.so.0
 #16  signal_emit_unlocked_R () at /lib64/libgobject-2.0.so.0
 #17  g_signal_emit_valist () at /lib64/libgobject-2.0.so.0
 #18  g_signal_emit_by_name () at /lib64/libgobject-2.0.so.0
 #19  nm_settings_connection_signal_remove (self=self@entry=0x9e4a80, allow_reuse=allow_reuse@entry=0) at src/settings/nm-settings-connection.c:2085
 #20  do_delete (self=0x9e4a80, callback=0x58106a <con_delete_cb>, user_data=0xa84fa0) at src/settings/nm-settings-connection.c:768
 #21  do_delete (connection=0x9e4a80, callback=0x58106a <con_delete_cb>, user_data=0xa84fa0) at src/settings/plugins/keyfile/nms-keyfile-connection.c:127
 #22  nm_settings_connection_delete (self=self@entry=0x9e4a80, callback=callback@entry=0x58106a <con_delete_cb>, user_data=0xa84fa0) at src/settings/nm-settings-connection.c:694
 #23  delete_auth_cb (self=self@entry=0x9e4a80, context=context@entry=0x7fffd80131e0, subject=0x91fb40, error=<optimized out>, data=data@entry=0x0) at src/settings/nm-settings-connection.c:1879
 #24  pk_auth_cb (chain=0x7fffd00024a0, chain_error=<optimized out>, context=0x7fffd80131e0, user_data=<optimized out>) at src/settings/nm-settings-connection.c:1351
 #25  auth_chain_finish (user_data=0x7fffd00024a0) at src/nm-auth-utils.c:92
 #26  g_idle_dispatch () at /lib64/libglib-2.0.so.0

Restore the unexport upon failure to fix this.

Fixes: f2182fbf9b

https://bugzilla.redhat.com/show_bug.cgi?id=1440077
2017-04-11 20:27:48 +02:00
Lubomir Rintel
0234172923 wifi: only attempt to set the scan MAC address when it actually changes
The address change involves setting the link down which causes the supplicant
interface to change state and in turn another scan attempt. This could lead to
a loop in case of broken drivers that are not able to change the MAC address
iff the MAC address is attempted at each scan request.

https://bugzilla.redhat.com/show_bug.cgi?id=1382741
2017-04-11 16:39:31 +02:00
Beniamino Galvani
21c22f2f96 wifi: fix HT max rate calculation
The rates of MCSs are not monotonically increasing.
2017-04-10 13:37:24 +02:00
James Kalbfleisch
cd91b7e119 wifi: parse the first 77 bits of the supported mcs set 2017-04-10 13:37:24 +02:00
Thomas Haller
2b64961d05 wifi: avoid buffer overflow reading IEs 2017-04-10 13:37:24 +02:00
Thomas Haller
961d572472 wifi: rename ieee80211_eid capability defines
IEEE_80211_IE_VHT_CAP has zero hits searching the internet.
WLAN_EID_VHT_CAPABILITY is how the same define is called by
kernel's "include/linux/ieee80211.h".

Use the same name as kernel.

Also, collect the maximum of @max_rate.
2017-04-10 13:37:24 +02:00
Thomas Haller
0c6097ccbe wifi/trivial: rename get_max_rate*() functions 2017-04-10 13:37:24 +02:00
Thomas Haller
5bd7ff2ec0 wifi: collect maximum max-bitrate in nm_wifi_ap_update_from_properties() 2017-04-10 13:37:24 +02:00
Thomas Haller
b0016d47f1 wifi: fix unsigned error return value for get_max_rate()
Signal error via 0, not -1.

Also, if the length of the array is unexpected, error out.
2017-04-10 13:37:24 +02:00
Thomas Haller
3d8bc3bc01 wifi: replace "if" checks for rate with switch statement
Also, fix "if (mcs == (12 || 19 || 26))".
2017-04-10 13:37:24 +02:00
Thomas Haller
534a96d82a wifi: set changed flag for max-rate in nm_wifi_ap_update_from_properties() 2017-04-10 13:37:24 +02:00
Thomas Haller
6c534af4d7 wifi: fix compiler warnings 2017-04-10 13:37:24 +02:00
Thomas Haller
f27a0711e6 wifi/trivial: fix whitespace and style 2017-04-10 13:37:24 +02:00
James Kalbfleisch
f2b0092b5b wifi: parse BSS IEs for 80211n and 80211ac data rates
Currently, 'nmcli dev wifi list' does not show the user any rates above
54Mbps.  Now, we can check the IEs passed to NM from the wpa_supplicant,
pull the mcs rate and channel width information, and determine a maximum
possible data rate for 11n and 11ac APs.

https://bugzilla.gnome.org/show_bug.cgi?id=779771
2017-04-10 13:37:24 +02:00
Lubomir Rintel
583192d121 supplicant-config: correct the uri attribute/query separator 2017-04-10 10:33:24 +02:00
Lubomir Rintel
d4d6272fec ifcfg: don't complain if 8021x secrets are empty
The connection is still valid; and it's easily possible to create it. It would
be a shame if it couldn't be read back.
2017-04-10 10:33:24 +02:00
Lubomir Rintel
0812413c9d ifcfg-rh: fix loading the PKCS#11 client certificate
Contrary to the comment above, the reader would skip the client certificate
even if the key is on PKCS#11 token, not just in a PKCS#12 archive.
2017-04-10 10:33:22 +02:00
Dan Williams
f66de1dd0f device-bond: fix possible uninitialized variable
src/devices/nm-device-bond.c: In function 'check_changed_options':
src/devices/nm-device-bond.c:529:4: error: 'name' may be used uninitialized in this function [-Werror=maybe-uninitialized]
    g_set_error (error,
    ^
src/devices/nm-device-bond.c:505:14: note: 'name' was declared here
  const char *name, *value_a, *value_b;
              ^
src/devices/nm-device-bond.c:528:8: error: 'value_a' may be used uninitialized in this function [-Werror=maybe-uninitialized]
   if (!nm_streq0 (value_a, value_b)) {
        ^
src/devices/nm-device-bond.c:505:21: note: 'value_a' was declared here
  const char *name, *value_a, *value_b;
                     ^
2017-04-07 11:56:53 -05:00
Dan Williams
24ab2a4945 auth-utils: fix possibly uninitialized variables
src/nm-auth-utils.c:343:6: error: 'is_authorized' may be used uninitialized in this function [-Werror=maybe-uninitialized]
   if (is_authorized) {
      ^
src/nm-auth-utils.c:320:11: note: 'is_authorized' was declared here
  gboolean is_authorized, is_challenge;
           ^
src/nm-auth-utils.c:346:13: error: 'is_challenge' may be used uninitialized in this function [-Werror=maybe-uninitialized]
   } else if (is_challenge) {
             ^
src/nm-auth-utils.c:320:26: note: 'is_challenge' was declared here
  gboolean is_authorized, is_challenge;
                          ^
2017-04-07 11:52:16 -05:00
Dan Williams
857f26dd19 default-route-manager: fix possibly uninitialized variable
src/nm-default-route-manager.c: In function '_ipx_update_default_route':
src/nm-default-route-manager.c:769:23: error: 'is_assumed' may be used uninitialized in this function [-Werror=maybe-uninitialized]
    if (!default_route && !is_assumed) {
                       ^
src/nm-default-route-manager.c:763:13: note: 'is_assumed' was declared here
    gboolean is_assumed;
             ^
2017-04-07 11:33:06 -05:00
Beniamino Galvani
ad6930f052 config: fix assertion in nm_config_device_state_write()
Fixes: 142ebb1037
2017-04-07 16:56:33 +02:00
Thomas Haller
142ebb1037 core: only persist explicit managed state in device's state file
For example, when starting without Wi-Fi plugin, a generic device
is created. On stop, we should not store the unmanaged state
on the state file, otherwise after restart the device is unmanaged.

Only store explicit user decisions.

https://bugzilla.redhat.com/show_bug.cgi?id=1440171
2017-04-07 15:27:04 +02:00
Beniamino Galvani
fad2cf0721 pacrunner: remove failed and pending items from configuration list
If a configuration does not have a path it is because we are still
sending it to pacrunner or because we failed to do so. In both cases,
we have to remove the configuration from the list.

Fixes: 3ad89223d0
2017-04-07 15:15:27 +02:00
Beniamino Galvani
3cada7722d device: fix removal of pacrunner configurations
Don't try to remove the configuration if we haven't added it in the
first place, for example when the connection gets deactivated before
it completes or for slave connections without IP configuration.

Fixes: 3ad89223d0
2017-04-07 15:15:27 +02:00
Lubomir Rintel
b7b0227935 linux-platform: fix link_get_unmanaged() return value
The function is supposed to set *unamanged to NM_UNMANAGED's and indicate
whether NM_UNMANAGED was present in the return value.

Fixes: e32839838e
2017-04-06 13:23:19 +02:00
Beniamino Galvani
b139552255 pacrunner: specify domains only for VPNs
If a VPN provides a proxy, we want to restrict the usage of that proxy
to URLs in the VPN domain. For all other connections, the proxy should
be used for all domains.
2017-04-06 08:57:35 +02:00
Beniamino Galvani
752e906aa4 pacrunner: don't log pacrunner-manager address
It's a singleton, the address is not meaningful.
2017-04-06 08:57:35 +02:00
Beniamino Galvani
3ad89223d0 pacrunner: rework processing of configuration entries
Fix some issues in nm-pacrunner-manager.c:

 - when adding a configuration through nm_pacrunner_manager_send(), we
   kept an association between the interface name and the pacrunner
   configuration object path, so that the configuration for that
   interface could be removed later. Unfortunately not all
   configurations have an interface associated, so we need a more
   generic way to identify configurations. Introduce a new @tag
   argument that serves as key to match configurations

 - the interface name of the last pushed configuration was stored in
   the manager private config and reused later; this could cause
   issues when there are multiple outstanding D-Bus calls. The
   interface is not needed anymore after the previous point.

 - remove() didn't actually remove the configuration from the list
2017-04-06 08:57:35 +02:00
Beniamino Galvani
10f6854369 pacrunner: remove @domains from private struct
The domain list is not a property of the global pacrunner instance and
can be stored in a local variable.
2017-04-06 08:57:23 +02:00
Thomas Haller
d5bcc5826e shared: move NM_UTILS_LOOKUP() macro shared utils 2017-04-05 16:53:06 +02:00
Jonas Jonsson
fdf967592b dhcp: dhclient: remove fqdn.encoded for dhclient -6 conf
The option fqdn.encoded doesn't exist in DHCPv6, it's a DHCPv4 flag
only.
2017-04-05 16:21:51 +02:00
Thomas Haller
95e7914e67 systemd: merge branch systemd into master 2017-04-04 12:20:51 +02:00
Thomas Haller
ae172c89a6 systemd: update code from upstream (2017-04-04)
This is a direct dump from systemd git on 2017-04-04, git commit
91dacd4451309e1f4b06fb2628447ddc8425d972.

======

SYSTEMD_DIR=../systemd
COMMIT=91dacd4451309e1f4b06fb2628447ddc8425d972

(
  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-04-04 12:19:34 +02:00
Lubomir Rintel
2839da06db settings/secret-agent: add initializers
To make coverity a bit happier.
2017-04-03 13:28:26 +02:00
Beniamino Galvani
3fe144f934 device: emit IP_CONFIG_CHANGED signal when default route changes
We now update the default route metric based on the result of the
connectivity check. When we update the metric and there is no other
changes to the IP configuration, NMPolicy is not notified about it and
can't update the best device until an actual change in IP config
happens. This results in a wrong best device set in NMPolicy.

NMDevice has NM_DEVICE_IP[4,6]_CONFIG_CHANGED signals that are used
exclusively by NMPolicy to detect when there is a change in
configuration that requires an update of global DNS and routing
information. Emit those signals also when the default route changes.
2017-04-01 15:49:16 +02:00
Beniamino Galvani
74f7eff11b default-route-manager: return whether the default route changed 2017-04-01 15:49:16 +02:00
Thomas Haller
a8730c51c8 libnm: move enum utils to new shared file shared/nm-utils/nm-enum-utils.h
libnm contains the public function nm_utils_enum_from_str() et al.
The function is not flexible enough for nmcli's usecase. So, I would
need another public function like nm_utils_enum_from_str_full() that
has an extended API.

That was already required previously for ifcfg-rh writer, but in that
case I could just add it as internal API as libnm-core is linked statically
with NetworkManager.

I don't want to commit to a public API for an utility function. So move
the code instead to the shared directory, so that nmcli may link
statically against it and use the internal API.
2017-03-30 13:09:58 +02:00
Thomas Haller
b5c8622ad3 cli: split nm-meta-setting-desc out of settings
This part contains static functions and variables to describe
settings. It is distinct from the mechanism to use them, or
access them.

Split it out.

It still uses clients/cli/common.h and clients/cli/utils.h
which shall be fixed next.
2017-03-30 13:09:58 +02:00
Beniamino Galvani
166988264f device: update the address type in nm_device_hw_addr_set_cloned()
Commit 029a0a21ea ("device: split out cloned MAC decision from
nm_device_hw_addr_set_cloned()") accidentally removed the assignment
of the new device @hw_addr_type, which then was left to
HW_ADDR_TYPE_UNSET. As a consequence, we never restored the initial
MAC address when the connection was deactivated. Fix this.

Fixes: 029a0a21ea
2017-03-30 09:54:20 +02:00
Beniamino Galvani
e73c15eec9 device: don't update disconnected devices routes after connectivity check
When the device is not activated it does not make sense to try to
update its default route metric based on connectivity status.

Fixes the following:

 nm_ip4_config_commit: assertion 'ifindex > 0' failed

 #0  raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/pt-raise.c:37
 #1  g_logv (breakpoint=1) at gmessages.c:324
 #2  g_logv (log_domain=<> "NetworkManager", log_level=G_LOG_LEVEL_CRITICAL, format=<optimized out>, args=<optimized out>) at gmessages.c:1081
 #3  g_log (log_domain=<optimized out>, log_level=<optimized out>, format=<optimized out>) at gmessages.c:1119
 #4  g_return_if_fail_warning (log_domain=<optimized out>, pretty_function=<optimized out>, expression=<optimized out>) at gmessages.c:1128
 #5  nm_ip4_config_commit (config=<> [NMIP4Config], ifindex=<optimized out>, routes_full_sync=<optimized out>, default_route_metric=-1) at src/nm-ip4-config.c:339
 #6  nm_device_set_ip4_config (self=<> [NMDeviceTun], new_config=<> [NMIP4Config], default_route_metric=450, commit=1, routes_full_sync=<optimized out>) at src/devices/nm-device.c:9635
 #7  ip4_config_merge_and_apply (self=<> [NMDeviceTun], config=0x0, commit=1) at src/devices/nm-device.c:5541
 #8  update_connectivity_state (self=<> [NMDeviceTun], state=NM_CONNECTIVITY_NONE) at src/devices/nm-device.c:1743
 #9  concheck_periodic_update (self=<> [NMDeviceTun]) at src/devices/nm-device.c:1872
 #10 nm_device_set_ip4_config (self=<> [NMDeviceTun], new_config=0x0, default_route_metric=0, commit=1, routes_full_sync=1) at src/devices/nm-device.c:9669
 #11 _cleanup_generic_post (self=<> [NMDeviceTun], cleanup_type=CLEANUP_TYPE_KEEP) at src/devices/nm-device.c:11863
 #12 nm_device_cleanup (self=<> [NMDeviceTun], reason=NM_DEVICE_STATE_REASON_NOW_UNMANAGED, cleanup_type=<optimized out>) at src/devices/nm-device.c:12006
 #13 _set_state_full (self=<> [NMDeviceTun], state=<optimized out>, reason=<optimized out>, quitting=<optimized out>) at src/devices/nm-device.c:12376
 #14 nm_device_unrealize (self=<> [NMDeviceTun], remove_resources=<optimized out>, error=<>) at src/devices/nm-device.c:3183
 #15 _platform_link_cb_idle (data=<>) at src/nm-manager.c:2359
 #16 g_idle_dispatch (source=<optimized out>, callback=<optimized out>, user_data=<optimized out>) at gmain.c:5439
 #17 g_main_context_dispatch (context=<>) at gmain.c:3152
 #18 g_main_context_dispatch (context=<>) at gmain.c:3767
 #19 g_main_context_iterate (context=<>, block=1, dispatch=1, self=<optimized out>) a

Fixes: 6b7e9f9b22

https://bugzilla.redhat.com/show_bug.cgi?id=1436978
2017-03-29 14:27:57 +02:00