Commit Graph

17533 Commits

Author SHA1 Message Date
Thomas Haller
a31ddcfca5 core: merge branch 'th/netns-singleton-rh1440089'
https://bugzilla.redhat.com/show_bug.cgi?id=1440089
2017-04-18 15:52:01 +02:00
Thomas Haller
41148caba8 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.
2017-04-18 15:49:14 +02:00
Thomas Haller
94d9ee129d 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.
2017-04-18 15:49:14 +02:00
Thomas Haller
c48a19b7c6 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
2017-04-18 15:49:14 +02:00
Thomas Haller
0af2f5c28b 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.
2017-04-18 15:49:14 +02:00
Beniamino Galvani
df537d2eac 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
2017-04-18 15:09:15 +02:00
Beniamino Galvani
afca8a4c0f clients: fix setting of enum properties
Ensure we call G_IS_ENUM_CLASS() or G_IS_FLAGS_CLASS() only on classed
types.

 $ nmcli connection modify foobar wifi.powersave 1
 Thread 1 "nmcli" received signal SIGSEGV, Segmentation fault.
 0x0000000000440a4d in _set_fcn_gobject_enum at
 clients/common/nm-meta-setting-desc.c:985
 985                 || G_IS_ENUM_CLASS (gtype_prop)) {

Fixes: f53218ed7c
2017-04-18 13:40:02 +02:00
Dan Williams
a12b3f06cb ppp: allow disabling IPv4 too
https://bugzilla.redhat.com/show_bug.cgi?id=1439360
2017-04-18 09:40:31 +02:00
Thomas Haller
d58d8d7518 test: fix undefined behavior shifting signed integer in test 2017-04-17 13:19:47 +02:00
Lubomir Rintel
bacb68f3f6 wifi/test-general: don't do g_message() in test
An unexpected message causes the test to abort after the first line of
output.
2017-04-15 12:30:05 +02:00
Lubomir Rintel
738c2fcefc clients/meta-setting-desc: fix an unintentional fallthrough
Fixes: ddfff04a45
2017-04-15 12:30:02 +02:00
Lubomir Rintel
43012156a3 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.
2017-04-15 12:29:59 +02:00
Lubomir Rintel
c76ee5883d platform: fix a typo 2017-04-15 12:29:57 +02:00
Beniamino Galvani
03c2949a2c wifi: merge branch 'bg/wifi-pmf-bgo748367'
Support for 802.11w (Protected Management Frames).

https://bugzilla.gnome.org/show_bug.cgi?id=748367
2017-04-15 10:38:39 +02:00
Beniamino Galvani
72cfa1f458 supplicant: enable stronger AKMs when PMF is enabled 2017-04-15 10:37:33 +02:00
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
fff918ec5a core: merge branch 'th/route-zero-host-part-rh1439376'
https://bugzilla.redhat.com/show_bug.cgi?id=1439376
2017-04-15 00:35:46 +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
6e67f7f30b vpn: merge branch 'th/vpn-disconnect-rh1442064'
https://bugzilla.redhat.com/show_bug.cgi?id=1442064
2017-04-15 00:31:34 +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
67d144dd1e 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
2017-04-13 17:18:34 +02:00
Lubomir Rintel
c4a0002f05 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
2017-04-13 14:43:17 +02:00
Thomas Haller
ecec03c8b7 cli: merge branch 'th/cli-meta-3' 2017-04-13 10:10:58 +02:00
Thomas Haller
275ab5fb8f cli: make properties list a list of pointers
That allows for the property list to contain derived
property types. Also, the list can be directly passed
off as a "const NMMetaAbstractInfo *const*" list.
2017-04-13 10:10:12 +02:00
Thomas Haller
f2b5a42c7c cli: let NMMetaNestedPropertyInfo derive NMMetaPropertyInfo 2017-04-13 10:10:12 +02:00
Thomas Haller
886dad49d4 cli: move parsing of meta data fields 2017-04-13 10:10:12 +02:00
Thomas Haller
39bc8dbdf9 cli/trivial: rename NmcOutputSelectionItem type 2017-04-13 10:10:12 +02:00
Thomas Haller
2026d52f11 cli: use virtual get_nested method in _output_selection_select_one() 2017-04-13 10:10:12 +02:00
Beniamino Galvani
8b52e506a7 cli: fix addition of slave connection types
$ nmcli connection add type bond-slave ifname aoeu master aoeu
 Error: bad connection type: 'bond-slave' not among [802-1x, adsl,
 bluetooth, bond, bridge, bridge-port, cdma, connection, dcb, dummy,
 generic, gsm, infiniband, ipv4, ipv6, ip-tunnel, macsec, macvlan,
 802-11-olpc-mesh (olpc-mesh), ppp, pppoe, proxy, serial, team,
 team-port, tun, user, vlan, vpn, vxlan, wimax, 802-3-ethernet
 (ethernet), 802-11-wireless (wifi), 802-11-wireless-security
 (wifi-sec)].

Fixes: d32817999c
2017-04-13 08:43:17 +02:00
Thomas Haller
8acb2b1151 cli: merge branch 'th/cli-meta-2' 2017-04-12 14:15:27 +02:00
Thomas Haller
6d12d2f3a0 cli: move setting creation to meta data 2017-04-12 14:12:20 +02:00
Thomas Haller
b629b98687 cli: move completion for connection type to meta data 2017-04-12 14:12:20 +02:00
Thomas Haller
2a760897f2 cli: move completion for master connections to meta data
This change (improves) behavior.

Before, we would only complete
  if (g_strcmp0 (con_type, nmc_tab_completion.con_type) != 0)
which doesn't really make sense as it depends on the slave-type,
not nmc_tab_completion.con_type.
2017-04-12 14:12:20 +02:00
Thomas Haller
1e4bc51a4a cli: move completion for devices names to meta data 2017-04-12 14:12:20 +02:00
Thomas Haller
d32817999c cli: move information about valid connection settings to common 2017-04-12 14:12:20 +02:00
Thomas Haller
3ed0fc1b45 cli: move setting alias to meta data 2017-04-12 14:12:20 +02:00
Thomas Haller
6c2727af14 cli: add meta data for NMSettingGeneric 2017-04-12 14:12:20 +02:00
Thomas Haller
88f100e176 cli: move completing static-value types to meta data 2017-04-12 14:12:19 +02:00
Thomas Haller
0fa5fc3f51 cli: move completing VPN service types to meta data 2017-04-12 14:12:19 +02:00
Thomas Haller
7ef23e5c0a cli: move prompting for enum values to meta data 2017-04-12 14:12:19 +02:00
Thomas Haller
218f46ebcc cli: use meta data's completion in nmcli_con_add_tab_completion() 2017-04-12 14:12:19 +02:00
Thomas Haller
0b7e9c3bef cli: move prompting for boolean values to meta data
This changes behavior, in that yes|no prompt and answer is no longer
localized.

For command line arguments, I think it is always wrong for nmcli to
behave differently based on the localization. That is, input properties
on command line should not be translated.

One could make an argument, that in interactive mode that is different
and the user can be prompted in the his language.

But I think for consistency, it is wrong to ask for localized nmcli input.
2017-04-12 14:12:19 +02:00
Thomas Haller
cfd9f66ae9 cli: add property completion to meta-data
(not used yet).
2017-04-12 14:12:19 +02:00