Commit Graph

17344 Commits

Author SHA1 Message Date
Thomas Haller
030d77d3e1 device: merge branch 'th/device-assume-guess-rh1443878'
https://bugzilla.redhat.com/show_bug.cgi?id=1443878

(cherry picked from commit c828277872)
2017-04-20 14:29:18 +02:00
Thomas Haller
e3f4c492e8 device: assume matching connections during first start
Since commit 2d1b85f (th/assume-vs-unmanaged-bgo746440), we clearly
distinguish between two modes when encountering devices with external
IP configuration:
 a) external devices. For those devices we generate a volatile in-memory
   connection and pretend it's active. However, the device must not be
   touched by NetworkManager in any way.
 b) assume, seamless take over. Mostly for restart of NetworkManager,
   we activate a connection gracefully without going through an down-up
   cycle. After the device reaches activated state, the device is
   considered fully managed. For this only an existing, non volatile
   connection can be used.

Before 'th/assume-vs-unmanaged-bgo746440', the behaviors were not
clearly separated.

Since then, we only choose to assume a connection (b) when the state
file indicates a matching connection. Now, extend this to also assume
connections when:

  - during first-start (not after a restart) when there is no
    state file yet.
  - and, if we have an existing, non volatile, connection which
    matches the device's configuration.

This patch lets NetworkManager assume connection also on first start.
That is for example useful when handing over network configuration from
initrd.

This only applies to existing, permanent, matching(!) connections, so it is a
good guess that the user wants NM to take over this interface. This brings us
closer to the previous behavior before 'th/assume-vs-unmanaged-bgo746440'.

https://bugzilla.redhat.com/show_bug.cgi?id=1439220
(cherry picked from commit 27b2477cb7)
2017-04-20 14:29:00 +02:00
Thomas Haller
7fa7d57a83 config: add first_start paramter to NMConfig to detect restart
(cherry picked from commit 2131954a19)
2017-04-20 14:29:00 +02:00
Thomas Haller
cd92ee58a6 config: remove unused NMConfig self argument from nm_config_device_state_*() API
nm_config_device_state_*() always access the file system directly,
they don't cache data in NMConfig. Hence, they don't use the
@self argument.

Maybe those functions don't belong to nm-config.h, anyway. For lack
of a better place they are there.

(cherry picked from commit 1940be410c)
2017-04-20 14:29:00 +02:00
Francesco Giudici
d4c8a3fbf2 nmcli: show secrets when the --show-secrets option is put after the connection id
'nmcli connection show <con_id1> --show-secrets'
secrets were not shown.
'nmcli connection show <con_id1> --show-secrets <con_id2>'
secrets were shown only for connection ids following the
"--show-secrets" option (so only for 'con_id2').

Fix these behaviors showing secrets for all connections also
if the "--show-secrets" option is put after the connection ids.

(cherry picked from commit 4bdb6b026a)
2017-04-20 14:15:42 +02:00
Piotr Drąg
b54c60c176 po: update Polish (pl) translation (bgo #780277)
https://bugzilla.gnome.org/show_bug.cgi?id=780277
2017-04-19 17:21:25 +02:00
Thomas Haller
e68b024fb6 po: make update-po 2017-04-19 14:48:54 +02:00
Piotr Drąg
a2f621265c po: update Polish (pl) translation (bgo #780277)
https://bugzilla.gnome.org/show_bug.cgi?id=780277
2017-04-19 14:48:07 +02:00
Thomas Haller
6207090e71 po: import Zanata translations 2017-04-19 14:46:54 +02:00
Thomas Haller
19626cabc9 po: make update-po 2017-04-19 12:10:38 +02:00
Thomas Haller
9b7c393246 po: fix project-version for nm-1-8 branch in zanata.xml 2017-04-19 11:53:31 +02:00
Thomas Haller
865205650b gitignore: ignore generated files from master branch 2017-04-19 11:53:31 +02:00
Thomas Haller
0f14c2bdcc gitignore: ignore .zanata-cache directory
(cherry picked from commit b4b8e81153)
2017-04-19 11:53:26 +02:00
Beniamino Galvani
3cabd60b96 merge: branch 'bg/sriov-numvfs-rh1398934'
https://bugzilla.redhat.com/show_bug.cgi?id=1398934
(cherry picked from commit 45e4cc67b3)
2017-04-19 08:50:48 +02:00
Beniamino Galvani
5413d3bcc7 device: re-apply sriov_numvfs after SIGHUP
(cherry picked from commit 264624f91d)
2017-04-19 08:49:37 +02:00
Beniamino Galvani
0c2576e4bf core: allow setting SR-IOV num_vfs
(cherry picked from commit 32975b6aa5)
2017-04-19 08:49:37 +02:00
Beniamino Galvani
2409de0bb1 all: detect SR-IOV device support
(cherry picked from commit f13fd4524c)
2017-04-19 08:49:37 +02:00
Beniamino Galvani
2511e27e76 platform: detect SR-IOV support and allow changing the number of VFs
(cherry picked from commit 0a7694cf81)
2017-04-18 23:28:59 +02:00
Thomas Haller
785b51ed02 device: leave device up when setting it as unmanaged by user
Before, setting a device to unmanaged causes it to go down and clear
the interface state.

It may be useful to instruct NetworkManager not to touch the device
anymore but leave the current state up. Changing behavior for

  nmcli device set "$DEV" managed no

To get the previous behavior, one has to first disconnect the interface
via

  nmcli device disconnect "$DEV"
  nmcli device set "$DEV" managed no

Note that non-permanent addresses like from DHCP will eventually time
out because NetworkManager stops the DHCP client. When instructing
NetworkManager to let go of the device, you have to take it over in
any way you see fit.

https://bugzilla.redhat.com/show_bug.cgi?id=1371433
(cherry picked from commit 9e8218f99a)
2017-04-18 21:48:01 +02:00
Thomas Haller
6d3ce7557e core: merge branch 'th/netns-singleton-rh1440089'
https://bugzilla.redhat.com/show_bug.cgi?id=1440089

(cherry picked from commit a31ddcfca5)
2017-04-18 15:53:28 +02:00
Thomas Haller
c2297fb66c core: enable "log-with-ptr" by default for platform and route-manager
Arguably, we currently only have one instance of NMPlatform,
NMRouteManager, NMDefaultRouteManager -- the one owned by the
NMNetns singleton.

Hence, all these instances we create with "log-with-ptr" set explicitly
to false.

In the future we want to support namespaces, and it will be be common to
have multiple instances. For that we have "log-with-ptr" so we are able
to disambiguiate the logging.

Change the default to TRUE because it makes more sense. It has currently
no effect as the default is never used.

(cherry picked from commit 41148caba8)
2017-04-18 15:53:11 +02:00
Thomas Haller
7b91e8b6db device: don't use platform singleton getter in device subclasses
Reduce the use of NM_PLATFORM_GET / nm_platform_get() to get
the platform singleton instance.

For one, this is a step towards supporting namespaces, where we need
to use different NMNetns/NMPlatform instances depending on in which
namespace the device lives.

Also, we should reduce our use of singletons. They are difficult to
coordinate on shutdown. Instead there should be a clear order of
dependencies, expressed by owning a reference to those singelton
instances. We already own a reference to the platform singelton,
so use it and avoid NM_PLATFORM_GET.

(cherry picked from commit 94d9ee129d)
2017-04-18 15:53:11 +02:00
Thomas Haller
8a6eef6aa7 device: keep NMNetns instance per device
This also ensures that we own a reference to the
NMPlatform, NMRouteManager and NMDefaultRouteManager
instances. See bug rh#1440089 where we might access
the singleton getter after destroing the singleton
instance of NMRouteManager. This is prevented by
keeping a reference to those instances -- indirectly
via the netns instance.

Later, we may add support for multiple namespaces. Then it might
make sense to swap the NMNetns instance of a device when moving
the device between namespaces.

Also, drop the use of singelton instances.

https://bugzilla.redhat.com/show_bug.cgi?id=1440089
(cherry picked from commit c48a19b7c6)
2017-04-18 15:53:11 +02:00
Thomas Haller
d37b9d79bc core: add NMNetns to bundle platform and route managers
NMPlatform, NMRouteManager and NMDefaultRouteManager are singletons
instances. Users of those are for example NMDevice, which registers
to GObject signals of both NMPlatform and NMRouteManager.

Hence, as NMDevice:dispose() disconnects the signal handlers, it must
ensure that those singleton instances live longer then the NMDevice
instance. That is usually accomplished by having users of singleton
instances own a reference to those instances.
For NMDevice that effectively means that it shall own a reference to
several singletons.

NMPlatform, NMRouteManager, and NMDefaultRouteManager are all
per-namespace. In general it doesn't make sense to have more then
one instances of these per name space. Nnote that currently we don't
support multiple namespaces yet. If we will ever support multiple
namespaces, then a NMDevice would have a reference to all of these
manager instances. Hence, introduce a new class NMNetns which bundles
them together.

(cherry picked from commit 0af2f5c28b)
2017-04-18 15:53:11 +02:00
Beniamino Galvani
a39fac2248 manager: set interface as removed when the link disappears
Set the device state as removed when the link disappears, so that in
the call to unrealize() when the device is unmanaged we also perform a
cleanup of it and especially, we terminate any DHCP client instances
running on the device.

If we keep DHCP clients running, we can hit assertions later when we
start another instance on the same interface, because we kill the old
dhclient from the pidfile, and the g_child_watch_add() done by the
first client instance is not able to waitpid() it, complaining with:

  GChildWatchSource: Exit status of a child process was requested but
  ECHILD was received by waitpid(). Most likely the process is
  ignoring SIGCHLD, or some other thread is invoking waitpid() with a
  nonpositive first argument; either behavior can break applications
  that use g_child_watch_add()/g_spawn_sync() either directly or
  indirectly.

https://bugzilla.redhat.com/show_bug.cgi?id=1436602
(cherry picked from commit df537d2eac)
2017-04-18 15:10:45 +02:00
Thomas Haller
297ad945f5 test: fix undefined behavior shifting signed integer in test
(cherry picked from commit d58d8d7518)
2017-04-18 09:45:03 +02:00
Lubomir Rintel
928d68d04a m4: disable -Wmissing-braces for newer clang
src/NetworkManagerUtils.c:347:18: error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces]
          NMIPAddr a1 = { 0 }, a2 = { 0 };
                          ^
                          {}

Should we initialize unions this way? I think it's all right -- the initializer
works well and { { { 0 } } } is probably not what we'd like to see.

(cherry picked from commit 43012156a3)
2017-04-18 09:44:45 +02:00
Lubomir Rintel
fcad4fba16 platform: fix a typo
(cherry picked from commit c76ee5883d)
2017-04-18 09:43:43 +02:00
Dan Williams
589fc0179e ppp: allow disabling IPv4 too
https://bugzilla.redhat.com/show_bug.cgi?id=1439360
(cherry picked from commit a12b3f06cb)
2017-04-18 09:41:44 +02:00
Thomas Haller
acdf3d10cb core: merge branch 'th/route-zero-host-part-rh1439376'
https://bugzilla.redhat.com/show_bug.cgi?id=1439376

(cherry picked from commit fff918ec5a)
2017-04-15 00:37:40 +02:00
Thomas Haller
be19ec0739 core: ignore host part when comparing routes for route-manager
(cherry picked from commit b78562570a)
2017-04-15 00:37:22 +02:00
Thomas Haller
674b224bc1 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.

(cherry picked from commit 5c54b7a31e)
2017-04-15 00:37:22 +02:00
Thomas Haller
b32bb36c61 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.

(cherry picked from commit 034b7fb51c)
2017-04-15 00:37:22 +02:00
Thomas Haller
ae8d98391a 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).

(cherry picked from commit 57b0dce083)
2017-04-15 00:37:22 +02:00
Thomas Haller
514d79fc85 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.

(cherry picked from commit 11d8c41898)
2017-04-15 00:37:22 +02:00
Thomas Haller
0a3fdf6604 vpn: merge branch 'th/vpn-disconnect-rh1442064'
https://bugzilla.redhat.com/show_bug.cgi?id=1442064

(cherry picked from commit 6e67f7f30b)
2017-04-15 00:32:52 +02:00
Thomas Haller
6bfd9b4e85 vpn: inline call_plugin_disconnect()
There is only one caller. Don't bother moving the logic to a separate
function.

(cherry picked from commit b23484be72)
2017-04-15 00:32:23 +02:00
Thomas Haller
e6b1a31106 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
(cherry picked from commit bc1d1c9df4)
2017-04-15 00:32:22 +02:00
Beniamino Galvani
9029dabb87 cli: check for deactivation failures
If the D-Bus call to DeactivateConnection() fails, don't wait for the
connection to change state because this is not going to
happen. Instead, notify the user of the error and, if necessary, wait
for remaining connections to be deactivated.

https://bugzilla.redhat.com/show_bug.cgi?id=1422786
(cherry picked from commit 67d144dd1e)
2017-04-13 17:19:40 +02:00
Beniamino Galvani
45bef0ad17 cli: fix evaluation of supported settings for *-slave connections
To determine the valid settings we must consider the actual connection
type, not the user-supplied one because, for example, "bridge-slave"
is in fact an ethernet connection.

Fixes: fb8fe1d8cb

https://bugzilla.redhat.com/show_bug.cgi?id=1440957
2017-04-13 15:35:37 +02:00
Lubomir Rintel
55ad538cfb libnm-glib/secret-agent: don't error out on missing out_connection
It's perfectly valid to call the function with out_connection == NULL
when connection_hash == NULL too, as cancel_get_secrets() does.

Fixes: fbb1662269
(cherry picked from commit c4a0002f05)
2017-04-13 14:45:58 +02:00
Beniamino Galvani
ed6991145a 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
(cherry picked from commit 69fd96118e)
2017-04-11 20:28:31 +02:00
Lubomir Rintel
345bc90b4e 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
(cherry picked from commit 0234172923)
2017-04-11 16:41:27 +02:00
Francesco Giudici
d9ca557c1f nmcli: fix "nmcli device monitor <dev>"
Call get_device_list() after next_arg(); call it only after checking
that there are other arguments after "monitor".

Fixes: 6a3d77fbe6
(cherry picked from commit 2c4e991aba)
2017-04-11 15:53:40 +02:00
Beniamino Galvani
12d16e8a89 pacrunner: merge branch 'bg/pacrunner-domains-bgo780558'
https://bugzilla.gnome.org/show_bug.cgi?id=780558
(cherry picked from commit bac864725b)
2017-04-11 10:43:10 +02:00
Beniamino Galvani
c6f2173f10 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
(cherry picked from commit fad2cf0721)
2017-04-11 10:37:10 +02:00
Beniamino Galvani
0dead63886 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
(cherry picked from commit 3cada7722d)
2017-04-11 10:37:04 +02:00
Beniamino Galvani
1fe0b781fd 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.

(cherry picked from commit b139552255)
2017-04-11 10:37:00 +02:00
Beniamino Galvani
e4b323100e pacrunner: don't log pacrunner-manager address
It's a singleton, the address is not meaningful.

(cherry picked from commit 752e906aa4)
2017-04-11 10:36:57 +02:00
Beniamino Galvani
e895beb0da 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

(cherry picked from commit 3ad89223d0)
2017-04-11 10:36:56 +02:00