Commit graph

8727 commits

Author SHA1 Message Date
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
Thomas Haller
ca3cb90fc2 ifcfg-rh: refactor svOpenFile() to use nm_utils_fd_get_contents()
Use nm_utils_fd_get_contents() which has precisely all the steps implemented
to read data from a file descriptor.

There is a downside to this: previously you could compile shvar.c without
nm-core-utils.c. Now, the ifcfg implementation gained a dependency
on NM core utils. That would matter if we one day would like to build
shvar.c without core NetworkManager utils (but that is not planned).
2017-01-02 17:00:52 +01:00
Thomas Haller
1bfbe9383f ifcfg-rh: add assertions for handling lines in "shvar.c"
Just assert that the shvarLine instances are in a valid state.
2017-01-02 17:00:52 +01:00
Thomas Haller
de9e78cc50 ifcfg-rh: refactor handling of lines in shvar.c
Pre-process each line and parse the key and value.
Thus, keep the key already prepared.

The point is to do the parsing early and keep the
data in a more suitable format in shvarLine.
2017-01-02 17:00:51 +01:00
Thomas Haller
a6a39af8ca ifcfg-rh: refactor searching and replacing shvarLine in svhar.c
The shlist_delete*() are now named wrong, as they don't delete
the list entry. Anyway, they have only one caller, it's clearer
to inline them.

This way, during svSetValue() we need to iterate the entire
list only once.
2017-01-01 22:16:44 +01:00
Beniamino Galvani
8adbeb821e manager: better handle failures in AddAndActivateConnection
nm_settings_add_connection_dbus() invokes the activation_add_done()
callback with a NULL @new_connection in case of error: add a check to
prevent a crash.
2016-12-23 14:20:15 +01:00
Beniamino Galvani
30a1e17cc0 policy: don't apply DNS configuration for non-active devices
Don't apply DNS configuration of non-active devices (for example
unmanaged ones which have a non-empty DNS configuration read from a
DHCP lease).

https://bugzilla.redhat.com/show_bug.cgi?id=1405431
2016-12-21 09:37:22 +01:00
Dan Williams
0c5aa6e48b wifi: don't request new PSK for locally-generated WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY errors
This usually indicates that the driver missed beacons from the AP, due to driver bugs
or faulty power-save management.  It doesn't mean that the PSK is wrong.
2016-12-20 10:06:42 -06:00
Thomas Haller
4c853e80f0 ethernet: cancel get-secrets request in ethernet device
Same as for NMDeviceWifi.
2016-12-20 15:53:41 +01:00
Thomas Haller
e6bf047ccc wifi: cancel get-secrets request in wifi device
I got an assertion failure:
    wifi_secrets_cb: assertion 'nm_device_get_state (device) == NM_DEVICE_STATE_NEED_AUTH' failed
with backtrace [1].

I think, we have to keep track of the pending secrets request
and cancel it when the device state changes.

[1]:
    #0  0x00007fad615a7a21 _g_log_abort (libglib-2.0.so.0)
    #1  0x00007fad615a8e2d g_logv (libglib-2.0.so.0)
    #2  0x00007fad615a8f8f g_log (libglib-2.0.so.0)
    #3  0x000055e45e3fc718 get_secrets_cb (NetworkManager)
    #4  0x000055e45e3dfada _get_secrets_info_callback (NetworkManager)
    #5  0x000055e45e460d8d req_complete_release (NetworkManager)
    #6  0x000055e45e462a7f _con_get_try_complete_early (NetworkManager)
    #7  0x000055e45e462cb6 request_start (NetworkManager)
    #8  0x00007fad6159e8e7 g_idle_dispatch (libglib-2.0.so.0)
    #9  0x00007fad615a1e42 g_main_dispatch (libglib-2.0.so.0)
    #10 0x00007fad615a21c0 g_main_context_iterate (libglib-2.0.so.0)
    #11 0x00007fad615a24e2 g_main_loop_run (libglib-2.0.so.0)
    #12 0x000055e45e2bf561 main (NetworkManager)
    #13 0x00007fad60d97401 __libc_start_main (libc.so.6)
    #14 0x000055e45e2bfc6a _start (NetworkManager)
2016-12-20 15:53:41 +01:00
Thomas Haller
bd89c8a924 act-request: allow omitting the @self argument in nm_act_request_cancel_secrets()
Previously, we would require a @self argument and the @call_id in
nm_act_request_cancel_secrets(), although the @call_id already has
a pointer to @self.
In principle that is not necessary, but it makes the API a bit
more robust as you need to care about the lifetime of the @req
as well.

However it is a bit inconvenient, because it requires that caller to
track both the activation request and the call-id.

Now, allow nm_act_request_get_secrets() to instruct the call-id to
take an additional reference to @self. Later on, we would allow to omit
the argument during cancelling. We only allow this, if the call-id
takes a reference to @self.
2016-12-20 15:53:41 +01:00
Thomas Haller
3b95cf68e2 act-request: use NULL return value instead of "0" 2016-12-20 15:53:41 +01:00
Beniamino Galvani
9d589046f9 exported-object: fix memory leak
Fixes: 8c4e824997
2016-12-20 11:40:12 +01:00
Beniamino Galvani
e4edef8fe2 dns: fix memory leak
Fixes: e3c67177ac
2016-12-20 11:40:12 +01:00
Beniamino Galvani
4ec6481695 dns: remove duplicate declaration of singleton instance 2016-12-20 11:40:12 +01:00
Beniamino Galvani
fa15543179 device: don't try to get carrier detection support when unrealizing
get_generic_capabilities() is called with a 0 ifindex when unrealizing:
don't call nm_platform_link_supports_carrier_detect() is such case.
2016-12-19 12:12:14 +01:00
Thomas Haller
0dfb5d2452 build: remove "src/NetworkManager.ver-orig"
Generating "src/NetworkManager.ver" each time seems to work well.
Thus, src/NetworkManager.ver-orig is unused an gets easily out
of date. Just remove it. It's not useful anymore.
2016-12-18 17:45:15 +01:00
Francesco Giudici
f124048b80 ifcfg-rh/tests: avoid using g_assert_null() API
Fixes: 2852b50945
2016-12-15 13:34:54 +01:00
Lubomir Rintel
8b7b0d3fc2 ifcfg-rh: write the master device name even if the master property is an UUID
We used MASTER, BRIDGE and TEAM_MASTER keys for a differnet purpose than the
network.service did, confusing the legacy tooling. Let's do our best to write
compatible configuration files:

* Add *_UUID properties that won't clash with initscripts
* Ignore non-*_UUID keys on read if *_UUID is present
* If the connection.master is an UUID of a connection with a
  connection.interface-name, write the uuid into the *_UUID key while setting
  the non-*_UUID key to the interface name for compatibility

https://bugzilla.redhat.com/show_bug.cgi?id=1369091
2016-12-15 11:45:34 +01:00
Lubomir Rintel
96988f8deb ifcfg-rh: add test case for remembering the unset values
Validates the previous commit.
2016-12-15 11:45:34 +01:00
Lubomir Rintel
d36c6d2892 ifcfg-rh: remember where the keys have been when we remove them
We may want to re-add them right away, let's remember the original
contents so that we can add it at the right place.
2016-12-15 11:45:34 +01:00
Francesco Giudici
2ee6b7bf82 ifcfg-rh: merge branch 'fg/dhcp_hostname_bgo775622'
https://bugzilla.gnome.org/show_bug.cgi?id=775622
2016-12-15 11:29:05 +01:00
Thomas Haller
c1c5149ced platform/trivial: rename macro offset_plus_sizeof() to offsetofend()
Linux kernel names this very macor offsetofend(), so name it the
same name to be more recognizable.
2016-12-14 23:16:06 +01:00
Thomas Haller
dfeebfb3e1 python: make test-secret-agent.py python3 ready
Co-authored-by: Lubomir Rintel <lkundrak@v3.sk>
2016-12-14 19:00:42 +01:00
Francesco Giudici
6bf69d0fa1 ifcfg-rh/tests: add ipv6 hostname legacy support read test 2016-12-14 16:21:26 +01:00
Francesco Giudici
2852b50945 ifcfg-rh: add DHCPV6_HOSTNAME and DHCPV6_SEND_HOSTNAME vars
Currently ipv4 and ipv6 settings share the ifcfg plugin vars for the
dhcp-hostname and dhcp-send-hostname options (DHCP_HOSTNAME and
DHCP_SEND_HOSTNAME). Add brand new vars DHCPV6_HOSTNAME and
DHCPV6_SEND_HOSTNAME to have var-property one to one mappings.
2016-12-14 16:21:26 +01:00
Francesco Giudici
08bd3feed0 ifcfg-rh: write [IPV6_]PEERDNS and [IPV6_]PEERROUTES only when they are "no"
When those values are missing they are already considered as TRUE.
As they are written also when DHCP is not enabled, write them only
if they have a value different from the default.
2016-12-14 16:14:24 +01:00
Francesco Giudici
dbb9cd3ca8 ifcfg-rh: save/restore dhcp related properties also when ip method != DHCP/AUTO
affected properties are: ipv4.dhcp-client-id, ipv4.fqdn,
ipv4.dhcp-timeout, ipvX.ignore-auto-routes, ipvX.ignore-auto-dns,
ipvX.dhcp-hostname and ipvX.dhcp-send-hostname.
2016-12-14 15:27:42 +01:00
Beniamino Galvani
7375822c95 manager: don't upgrade the state when connectivity check fails
If a connection is ACTIVATED and another one is ACTIVATING but there
is no global connectivity, we currently set the manager state to
CONNECTING and start a connectivity check to verify whether the
manager state can be promoted to CONNECTED_GLOBAL.

If this connectivity check fails, we shouldn't promote a CONNECTING
state to CONNECTED_SITE.

Fixes: 084da69a30
2016-12-14 10:07:04 +01:00
Beniamino Galvani
4cc45ee291 manager: don't update the manager state in get_property()
The manager state is already computed every time an active connection
changes state, it is not necessary to call nm_manager_update_state()
also when the property is read.

Moreover, nm_manager_update_state() emits a "notify::state" signal
which causes a re-read of the property by the nm-exported-object,
resulting in a nested execution of nm_manager_update_state().
2016-12-14 10:07:04 +01:00
Thomas Haller
396d90e744 platform: assume ifname is present in _linktype_get_type()
_linktype_get_type() only has one caller, and ifname is *never*
NULL.
2016-12-13 11:26:59 +01:00
Thomas Haller
d32fb8158b platform: avoid copying arguments for nmp_utils_ethtool_get_driver_info()
We call nmp_utils_ethtool_get_driver_info() twice when receiving a
netlink message, but we don't need a clone of the string values.
Instead, expose a data structure that should be stack allocated
by the caller.
2016-12-13 11:26:59 +01:00
Thomas Haller
16ad046c87 platform: remove unused nmp_utils_device_exists() util 2016-12-13 11:26:59 +01:00
Thomas Haller
3641178508 platform: lookup ifname for ethtool/mii ioctl immediately before use
The ioctl APIs ethtool/mii require an interface ifname. That is inherrently
racy as interfaces can be renamed. This cannot be fixed, we can only
minimize the time between verifying the ifname and calling ioctl.

We already had problems with that when ethtool would access an interface
by name that didn't exists. See commit ab41c13b06 .
Checking for an existing interface only helps avoiding races when an interface
gets deleted. It does not help against renaming.

Go one step further, and instead of checking whether such an ifname
exists, try to get the ifname based on the ifindex immediately before
we need it.

This brings an additional overhead for each ethtool access.
2016-12-13 11:26:59 +01:00
Thomas Haller
da7b8dd850 wifi: remove check for existing device in wifi_wext_is_wifi()
See also commit ab41c13b06.
2016-12-13 11:26:59 +01:00
Thomas Haller
4bdee37771 all: use O_CLOEXEC for file descriptors 2016-12-13 11:26:59 +01:00
Thomas Haller
e332c27824 platform/tests: add tests for nmp_utils_sysctl_open_netdir() 2016-12-13 11:26:59 +01:00
Thomas Haller
6b132a2bd0 platform/tests: use nmtstp_netns_select_random() util 2016-12-13 11:26:59 +01:00
Thomas Haller
5eb4dfe7ab platform/tests: add nmtstp_netns_select_random() util 2016-12-13 11:26:59 +01:00
Thomas Haller
22be2ae865 core: use nmp_utils_sysctl_open_netdir() for platform master/slave options 2016-12-13 11:26:59 +01:00
Thomas Haller
a9a41edcbd core: use nmp_utils_sysctl_open_netdir() in platform link operations 2016-12-13 11:26:59 +01:00
Thomas Haller
7fc3eace31 core: use nmp_utils_sysctl_open_netdir() to detect link-type 2016-12-13 11:26:59 +01:00