Commit graph

19813 commits

Author SHA1 Message Date
Javier Arteaga
56e79a4e07 platform: move genl_ctrl_resolve to nm-netlink.c
Move genl_ctrl_resolve out of the wifi code so it can be reused by other
interfaces based on genetlink.

https://mail.gnome.org/archives/networkmanager-list/2018-March/msg00044.html
2018-03-30 22:09:04 +02:00
AsciiWolf
ddc2c5f215 po: update Czech translation
https://github.com/NetworkManager/NetworkManager/pull/84
2018-03-30 22:01:50 +02:00
Thomas Haller
4d2e52e1f1 core: drop obsolete typedef for NMExportedObject
It doesn't exist anymore.
2018-03-30 22:00:15 +02:00
Lubomir Rintel
f84f0ce4f9 manager: drop an unused variable
src/nm-manager.c:5857:36: error: unused variable 'object' [-Werror,-Wunused-variable]
        gs_unref_object NMExportedObject *object = NULL;
                                          ^
2018-03-30 17:05:28 +02:00
Beniamino Galvani
d169cde872 libnm: don't use GTK-Doc comment in nm-autoptr.h
It generates the following warning:

libnm/nm-autoptr.h:25: Error: NM: identifier not found on the first line:
 * Note that you might use this header with older versions of libnm

Fixes: ff8e563365
2018-03-28 17:51:36 +02:00
Thomas Haller
a187585222 contrib/nm-live-vm: remove nm-live-vm scripts
They were not (notably) touched in more than 3 years.
I doubt anybody is using them.

Also, nowadays we have contrib/rpm to build NetworkManager
packages for Fedora/RPM. We have copr, we have automated CI
in CentOS CI and beaker.

Also, nowadays it should be easy to spawn a a fedora image
in a container or tools like vagrant.

I think there are better alternatives. Drop the scripts.
2018-03-27 11:13:41 +02:00
Thomas Haller
b2edcdc939 shared/nm-glib: add compat implementation for g_autofree
Eventually, we should replace our uses of libgsystem's gsystem-local-alloc.h
by glib's g_auto*. As a first tiny step, add a compat implementation for g_autofree,
so that we could at least go ahead and use it instead of gs_free.

https://bugzilla.gnome.org/show_bug.cgi?id=794294
2018-03-27 10:36:12 +02:00
Thomas Haller
ff8e563365 libnm: add nm-autoptr.h header
"nm-autoptr.h" is done in a way that allows you to copy the header
in your source tree to support older versions of libnm, that didn't
contain the header yet. For example, we might want to use it in
network-manager-applet, but we don't want to bump the libnm dependency
to 1.11.2+ only to get this functionality.

Note that G_DEFINE_AUTOPTR_CLEANUP_FUNC() was added in glib 2.43.4,
and requires compiler support for the cleanup attribute. The compiler
support is taken as given, because we rely on it already. However,
NetworkManager and network-manager-applet still don't depend on a glib
version recent enough to provide these macros. To actually use them
(*inside*) NetworkManager/network-manager-applet, we either would have
to bump the glib minimal dependency, or reimplement g_autoptr in
/shared/nm-utils/nm-glib.h compat header.

https://bugzilla.gnome.org/show_bug.cgi?id=794294
2018-03-27 10:36:12 +02:00
Thomas Haller
759f2bcedb core: merge branch 'th/dbus-cache-properties'
https://github.com/NetworkManager/NetworkManager/pull/82
2018-03-27 10:27:17 +02:00
Thomas Haller
e49a32936c all: use nm_utils_hash_keys_to_array() 2018-03-27 09:58:00 +02:00
Thomas Haller
cd48bc74b6 config: cleanup fields in NMGlobalDnsConfig
- consistently set options, searches, domains fields to %NULL,
  if there are no values.

- in nm_global_dns_config_update_checksum(), ensure that we uniquely
  hash values. E.g. a config with "searches[a], options=[b]" should
  hash differently from "searches=[ab], options=[]".

- in nm_global_dns_config_to_dbus(), reuse the sorted domain list.
  We already have it, and it guarantees a consistent ordering of
  fields.

- in global_dns_domain_from_dbus(), fix memleaks if D-Bus strdict
  contains duplicate entries.
2018-03-27 09:58:00 +02:00
Thomas Haller
0f1dc3bca3 config/trivial: rename dns_config local variable
The variable serves a similar purpose, but is called "dns",
"conf", and "dns_config". Choose one name: "dns_config".
2018-03-27 09:58:00 +02:00
Thomas Haller
938d9a82cf shared: add nm_utils_hash_keys_to_array() helper 2018-03-27 09:58:00 +02:00
Thomas Haller
d7b1a911d9 wifi: rework tracking of wifi-aps to use CList
- no longer track APs in a hash table with their exported path
  as key. The exported path is already tracked by NMDBusManager's
  lookup index, so we can reuse that for fast lookup by path. Otherwise,
  track the APs in a CList per device.

- as we now track APs in a CList, their order is well defined.
  We no longer need to sort APs and obsoletes nm_wifi_aps_get_sorted()
  and simplifies nm_wifi_aps_find_first_compatible().
2018-03-27 09:58:00 +02:00
Thomas Haller
9fafd26f68 core: rework lookup for exported objects by path to use index
We already track an index of exported objects in NMDBusManager.
Actually, that index was unused previously. We either could drop
it, or use it. Let's use it.
2018-03-27 09:58:00 +02:00
Thomas Haller
199f2df50f manager: convert hwaddr to binary once in find_device_by_permanent_hw_addr()
For comparing MAC addresses, they anyway have to be normalized
to binary. Convert it once outside the loop and pass the binary
form to nm_utils_hwaddr_matches(). Otherwise, we need to re-convert
it every time.
2018-03-27 09:58:00 +02:00
Thomas Haller
4a705e1a0c core: track devices in manager via embedded CList
Instead of using a GSList for tracking the devices, use a CList.
I think a CList is in most cases the more suitable data structure
then GSList:

 - you can find out in O(1) whether the object is linked. That
   is nice, for example to assert in NMDevice's destructor that
   the object was unlinked, and we will use that later in
   nm_manager_get_device_by_path().
 - you can unlink the element in O(1) and you can unlink the
   element without having access to the link's head
 - Contrary to GSList, this does not require an extra slice
   allocation for the link node. It quite possibliy consumes
   slightly less memory because the CList structure is embedded
   in a struct that we already allocate. Even if slice allocation
   would be perfect to only consume 2*sizeof(gpointer) for the link
   note, it would at most be as-good as CList. Quite possibly,
   there is an overhead though.
 - CList possibly has better memory locality, because the link
   structure and the data are close to each other.

Something which could be seen as disavantage, is that with CList
one device can only be tracked in one NMManager instance at a time.
But that is fine. There exists only one NMManager instance for now,
and even if we would ever introduce multiple managers, we probably
would not associate one NMDevice instance with multiple managers.

The advantages are arguably not huge, but CList is IMHO clearly the
more suited data structure. No need to stick to a suboptimal data
structure for the job. Refactor it.
2018-03-27 09:49:43 +02:00
Thomas Haller
987c584bb5 core/dbus: manually inline helper function to emit InterfacesAdded signal 2018-03-26 19:35:26 +02:00
Thomas Haller
640736ff65 core/dbus: cache variants for D-Bus exported properties
GVariant is immutable and can nicely be shared and cached.
Cache the property variants. This makes getting the properties
faster, at the expense of using some extra memory.

Tested with https://tratt.net/laurie/src/multitime/

  $ multitime -n 200 -s 0 bash -c 'echo -n .; exec busctl call org.freedesktop.NetworkManager /org/freedesktop org.freedesktop.DBus.ObjectManager GetManagedObjects &>/dev/null'
  #                     Mean                Std.Dev.    Min         Median      Max
  # real(before)        0.013+/-0.0000      0.001       0.012       0.013       0.019
  # real(after)         0.013+/-0.0000      0.002       0.011       0.012       0.034

  $ multitime -n 100 -s 0 bash -c 'for i in {1..5}; do busctl call org.freedesktop.NetworkManager /org/freedesktop org.freedesktop.DBus.ObjectManager GetManagedObjects &>/dev/null & done; wait; echo -n .'
  #                     Mean                Std.Dev.    Min         Median      Max
  # real(before)        0.040+/-0.0000      0.002       0.037       0.040       0.049
  # real(after)         0.037+/-0.0000      0.002       0.034       0.036       0.045

  $ multitime -n 30 -s 0 bash -c 'for i in {1..100}; do busctl call org.freedesktop.NetworkManager /org/freedesktop org.freedesktop.DBus.ObjectManager GetManagedObjects &>/dev/null & done; wait; echo -n .'
  #                     Mean                Std.Dev.    Min         Median      Max
  # real(before)        0.704+/-0.0000      0.016       0.687       0.701       0.766
  # real(after)         0.639+/-0.0000      0.013       0.622       0.637       0.687

  $ multitime -n 200 -s 0 bash -c 'echo -n .; exec nmcli &>/dev/null'
  #                     Mean                Std.Dev.    Min         Median      Max
  # real(before)        0.092+/-0.0000      0.005       0.081       0.092       0.119
  # real(after)         0.092+/-0.0000      0.005       0.080       0.091       0.123

  $ multitime -n 100 -s 0 bash -c 'for i in {1..5}; do nmcli &>/dev/null & done; wait; echo -n .'
  #                     Mean                Std.Dev.    Min         Median      Max
  # real(before)        0.436+/-0.0000      0.043       0.375       0.424       0.600
  # real(after)         0.413+/-0.0000      0.022       0.380       0.410       0.558

  $ multitime -n 20 -s 0 bash -c 'for i in {1..100}; do nmcli &>/dev/null & done; wait; echo -n .'
  #                     Mean                Std.Dev.    Min         Median      Max
  # real(before)        8.796+/-0.1070      0.291       8.073       8.818       9.247
  # real(after)         8.736+/-0.0893      0.243       8.017       8.780       9.101

The time savings are small, but that is because caching mostly speeds up
the GetManagedObjects calls, and that is only a small part of the entire
nmcli call from client side.
2018-03-26 19:35:26 +02:00
Francesco Giudici
0ed5cd5442 libnm-core: trivial: fix indentation 2018-03-26 18:03:07 +02:00
Thomas Haller
dee6dd6e4e platform: reorder failure checks in nm_platform_ip_route_sync()
Move handling non-NM_IP_CONFIG_SOURCE_USER routes first. These are
routes that were added manually by the user in the connection.

Note that there is no change in behavior, because of how
_err_inval_due_to_ipv6_tentative_pref_src() would only accept
user routes already.
2018-03-26 16:56:05 +02:00
Thomas Haller
9ff6134814 ndisc/trivial: indentation and add "const" to auto variable 2018-03-26 13:13:19 +02:00
Thomas Haller
fc813d1c9e libnm: don't use deprecated tags for GOobject introspection
https://bugzilla.gnome.org/show_bug.cgi?id=744250
https://bugzilla.gnome.org/show_bug.cgi?id=794658
2018-03-26 12:50:43 +02:00
Jiří Klimeš
a751398785 libnm-glib: do not use deprecated Gtk-Doc Type: and Virtual: tags
Signed-off-by: Jiří Klimeš <jklimes@redhat.com>

https://bugzilla.gnome.org/show_bug.cgi?id=744250
2018-03-26 12:46:22 +02:00
Jiří Klimeš
aea3593a43 libnm: don't use deprecated tags for GOobject introspection
Top level tags are deprecated in favour of identifier annotations.
https://mail.gnome.org/archives/commits-list/2013-October/msg03220.html
https://wiki.gnome.org/action/show/Projects/GObjectIntrospection/Annotations?action=show&redirect=GObjectIntrospection%2FAnnotations#Type_signature

Signed-off-by: Jiří Klimeš <jklimes@redhat.com>

https://bugzilla.gnome.org/show_bug.cgi?id=744250
2018-03-26 12:46:22 +02:00
Corentin Noël
468a019333 gobject-introspection: made several fixes to the annotations
https://bugzilla.gnome.org/show_bug.cgi?id=794658
2018-03-26 12:45:49 +02:00
Thomas Haller
03a9bb88aa platform: improve logging message for failure to add route
The errno for this particular failure differs between IPv4 and IPv6.
Of course it does.
2018-03-22 16:56:28 +01:00
Thomas Haller
de750acee7 platform: assert for valid argument in nmp_object_unref() 2018-03-22 16:49:38 +01:00
Beniamino Galvani
6493bd443f manager: retry activating devices when the parent becomes managed
Since commit ed640f857a ("manager: ignore unmanaged devices when
looking for parent by UUID"), unmanaged devices are ignored when
looking for potential parent connection matches. Therefore, a software
device can fail autoactivation because the parent is not managed yet
and NM never tries to reactivate it. Ensure that we retry other
devices when a parent device becomes managed.

Fixes: ed640f857a

https://bugzilla.redhat.com/show_bug.cgi?id=1553595
2018-03-22 10:15:27 +01:00
Thomas Haller
217a7ad55a core: merge branch 'th/ipv6-ll-reapply-rh1552069' (#75)
A larger branch of refactoring and cleanups. This was a spin-off
of pr#75, as the branch grew too large.

https://github.com/NetworkManager/NetworkManager/pull/75
2018-03-21 18:58:42 +01:00
Thomas Haller
1010cc777f device: merge IPv4 and IPv6 versions of _cleanup_ip_pre() 2018-03-20 21:03:20 +01:00
Thomas Haller
b95f974144 device: merge IPv4 and IPv6 versions of queued_ip_config_change() 2018-03-20 21:03:20 +01:00
Thomas Haller
9c330ab320 device: merge IPv4 and IPv6 versions of nm_device_set_ip_config() (pt2) 2018-03-20 21:03:20 +01:00
Thomas Haller
3de79deb1a device: merge IPv4 and IPv6 versions of nm_device_set_ip_config() (pt1)
Almost on change, just merge the functions in one, with a top-level
if/else.
2018-03-20 21:03:20 +01:00
Thomas Haller
7f0b43108d device/trivial: rename IPv4/IPv6 related fields in NMDevicePrivate struct
These fields have the same purpose for IPv4 and IPv6. Also, they have an alias
with name _x, that can be indexed by an IS_IPv4 1/0 value.

Rename the fields so that the distinguisher 4/6/x is at the end. The point
is to make the name more similar.
2018-03-20 21:03:20 +01:00
Thomas Haller
d0de8cb6d1 device: merge IPv4 and IPv6 versions of ip_config_merge_and_apply() (pt3) 2018-03-20 21:03:20 +01:00
Thomas Haller
259cd24f48 device: merge IPv4 and IPv6 versions of ip_config_merge_and_apply() (pt2) 2018-03-20 21:03:20 +01:00
Thomas Haller
d77485e36b core: add ip-config implementation for NMIP4Config vs. NMIP6Config 2018-03-20 21:03:20 +01:00
Thomas Haller
d7d8611e72 device: merge IPv4 and IPv6 versions of ip_config_merge_and_apply() (pt1)
Functions like these are conceptually very similar. Commonly,
what we want to do for one address family we also want to do
for the other.

Merge the two functions. This moves the similar parts closer
to each other and stand beside it. This is only the first part
of the merge, which is pretty trivial without larger changes
(to keep the diff simple). More next.
2018-03-20 21:03:20 +01:00
Thomas Haller
868c3cedfd dhcp: remove unused nm_utils_resolve_conf_parse() function 2018-03-20 21:03:20 +01:00
Thomas Haller
c77784b5ea dhcp: remove unused nm_dhcp_dhclient_read_lease_ip_configs() function 2018-03-20 21:03:20 +01:00
Thomas Haller
e762eba05a dns: remove unused nm_dns_manager_get_resolv_conf_explicit() function 2018-03-20 21:03:20 +01:00
Thomas Haller
512fa33ef4 dhcp: remove unused nm_dhcp_manager_get_lease_ip_configs() function 2018-03-20 21:03:20 +01:00
Thomas Haller
745d60c06e device: in nm_device_capture_initial_config() only update config once
Now that there is no difference between initial capturing of
the configuration, and a later update_ip_config() call during
a signal from platform, we only need to make sure that the
IP config instances are initialized at least once.

In case we are called multiple times, there is nothing to do.
2018-03-20 21:03:20 +01:00
Thomas Haller
454195c09d device: don't capture resolve.conf for initial device config
This was called by via

  ...
  - manager:recheck_assume_connection()
    - manager:get_existing_connection()
      - nm_device_capture_initial_config()
        - update_ext_ip_config(initial=TRUE)

and would parse resolv.conf, and try to fill the device IP config
with nameservers and dns-options.

But why? It would only have effect if NM was started with
nm_dns_manager_get_resolv_conf_explicit(), but is that really sensible?
And it would only take effect on devices that have a default route.
And for what is this information even used?

Let's not do it this way. If we need this information for assuming or
external sys-iface mode, then it should be explicitly loaded at the
appropriate moment.

For now, drop it and see what breaks. Then we can fix it properly. If
it even matters.
2018-03-20 21:02:52 +01:00
Thomas Haller
453f9e5140 device: drop capture_lease_config() during connection assumption
Drop capture_lease_config(). It was added by commit
0321073b3c.

Note that it was only called by

  ...
  - manager:recheck_assume_connection()
    - manager:get_existing_connection()
      - nm_device_capture_initial_config()
        - update_ext_ip_config(addr_family=AF_INET, initial=TRUE)
          - capture_lease_config()

It had only effect when the device had IPv4 permanent addresses.
But then, capture_lease_config() would go on and iterate over
all connections (sorted by last-connect timestamp). It would
consider connection candidates that are compatible with the device,
and try to read the lease information from disk

It's really unclear what this means. For assuming (graceful take over),
do we need the lease information in the device? I don't think so,
because we will match an existing connection. The lease information
shall be read while activating (if necessary).

For external connections, we don't even have a matching connection
and we always generate a new one. It doesn't seem right to consider
leases from disk, for a different connection.

Just drop this. It's really ugly. If this causes an issue, it must be
fixed differently. We want to behave determinstically and well defined.
I don't even comprehend all the implications of what this had.

Also note that update_ext_ip_config() no longer clears
priv->dev_ip4_config.
2018-03-20 21:00:31 +01:00
Thomas Haller
19e657474d device: fix assertion in queued_ip6_config_change()
Fixes: 31ca7962f8
2018-03-20 15:24:38 +01:00
Thomas Haller
1d88f50443 device: also export NMIPxConfig on error in nm_device_set_ipx_config()
A failure to configure an address family does not mean that the connection
is going to fail. It depends, for example on ipvx.may-fail.

Always export the NMIPxConfig instance in that case.
2018-03-20 15:24:38 +01:00
Thomas Haller
5fd82a2035 device: cleanup completing wait for linklocal6
linklocal6_complete() had only one caller. The caller would check
whether the conditions for linklocal6_complete() are satisfied, and
then call it. Note that linklocal6_complete() would again assert
that these conditions hold. Don't do this. Just move the check
inside linklocal6_complete(), and rename to linklocal6_check_complete().

Also, linklocal6_complete() was called by update_ip_config(),
which was called by nm_device_capture_initial_config() and
queued_ip6_config_change().
It doesn't make sense to call linklocal6_complete() during
nm_device_capture_initial_config(). Move the call to
queued_ip6_config_change().
2018-03-20 15:24:38 +01:00
Thomas Haller
6cdf0b1820 device: fix check for existing addresses to ignore DADFAILED
Likewise, in ndisc_ra_timeout() we also want to include tentative
addresses. Looking into priv->ip6_config to determine whether
an other IP configuration is active, is anyway odd, and likely
a bug.
2018-03-20 15:24:38 +01:00