Commit Graph

18211 Commits

Author SHA1 Message Date
Beniamino Galvani
4b51f5b1a8 libnm-core: improve documentation for ipv4.dhcp-client-id property
https://bugzilla.redhat.com/show_bug.cgi?id=1468358
2017-07-25 17:47:01 +02:00
Thomas Haller
e260f2a08a travis: fix travis build to use Ubuntu 12.04 LTS (Precise Pangolin)
Travis used by default Ubuntu 12.04 which is now EOL. Hence, the default
changed.

Eventually, we may want to upgrade the tests to run on Ubuntu 14.04.5
LTS (Trusty Tahr). But for that we need to adjust the travis test
script.

For now, explicitly select precise.

https://blog.travis-ci.com/2017-07-11-trusty-as-default-linux-is-coming?utm_source=web&utm_medium=banner&&utm_campaign=trusty-default
2017-07-25 16:24:34 +02:00
Thomas Haller
230287a5a4 libnm: fix settings-doc after update in libnm-core doc string
Fixes: 51e1215c85
2017-07-25 16:21:38 +02:00
Thomas Haller
51e1215c85 device: deprecate "bridge.mac-address" for "ethernet.cloned-mac-address" setting
The settings "bridge.mac-address" and "ethernet.cloned-mac-address" have an
overlapping meaning. If the former is unset, fallback to the latter.

Effectively, "bridge.mac-address" is deprecated in favor of
"ethernet.cloned-mac-address", which is more powerful as it supports
various modes like "stable". However, if a connection specifies
"bridge.mac-address", it is used when creating the bridge interface,
while "ethernet.cloned-mac-address" is used shortly after, during
activation.
2017-07-25 15:38:30 +02:00
Thomas Haller
459e76bdfe platform: consolidate debug logging during link-add
Don't log both in NMPlatform and NMLinuxPlatform.
Also, log all provided arguments.
2017-07-25 15:20:30 +02:00
Thomas Haller
f0adca00f3 core: fix creating lower-case MAC address with nm_utils_hwaddr_ntoa_buf()
There is only one caller at the moment, and he passes TRUE anyway.
2017-07-25 15:17:50 +02:00
Beniamino Galvani
25f2f33273 device: fix address check in start_sharing()
Fixes: 22edeb5b69
2017-07-25 14:49:50 +02:00
Beniamino Galvani
24b8429ee3 core: emit notify signals for addresses/routes in nm_ipX_config_replace
Fixes: 22edeb5b69
Fixes: 935411e5c0
Fixes: cfd1851c00
2017-07-25 14:49:50 +02:00
Thomas Haller
b2d21817ad core: fix setting output argument in nm_utils_stable_id_parse()
This bug has no consequences, as the only caller already initialized
the output variable to NULL.

Fixes: f0d40525df
2017-07-25 13:09:45 +02:00
Beniamino Galvani
81b2d77795 platform: nmp-object: fix memory leak
Fixes: 9440eefb6d
2017-07-25 09:03:54 +02:00
Richard Fontana
0c6f88d4f0 Make licensing of contributions more explicit
Signed-off-by: Richard Fontana <rfontana@redhat.com>

https://mail.gnome.org/archives/networkmanager-list/2017-July/msg00034.html
2017-07-25 07:16:35 +02:00
Thomas Haller
394ed959f4 core: merge branch 'th/dedup-multi-v2-bgo785004'
https://bugzilla.gnome.org/show_bug.cgi?id=785004
2017-07-25 06:44:34 +02:00
Thomas Haller
5f99512366 core: prevent invalid routes in NMIP4Config/NMIP6Config
Kernel requires that the host part of a route (based on network/plen)
is zero. Routes with non-zero host part don't really exist.

In settings (NMIPRoute), we don't enforce that. Hence we must ensure
that we don't let such invalid routes into NMIP4Config/NMIP6Config.

Also at other places where we obtain routes from untrusted sources,
we must sanitize them first.

Also add an assertion to catch such bugs.
2017-07-25 06:44:13 +02:00
Thomas Haller
5e5aa39c97 core: allow omitting @src argument in nm_utils_ip6_address_clear_host_address()
For convenience, to clear the address inplace, allow to leave @src NULL,
instead of requiring to set @src to @dst.

The only problem is, if you make use of this extended behavior and later backport
the use to an older branch, ensure that you cherry-pick this commit too.
That is easy to miss, but you are testing the backport, right?
2017-07-25 06:44:13 +02:00
Thomas Haller
4057a31017 core: simplify NMDedupMultiIter by storing CList pointer
Let next and head pointers point to the CList value, instead of
NMDedupMultiEntry.
2017-07-25 06:44:12 +02:00
Thomas Haller
2861c59116 platform: pass full route object to platform delete function
Contrary to addresses, routes have no ID. When deleting a route,
you cannot just specify certain properties like network/plen,metric.

Well, actually you can specify only certain properties, but then kernel
will treat unspecified properties as wildcard and delete the first matching
route. That is not something we want, because we need to be in control which
exact route shall be deleted.

Also, rtm_tos *must* match. Even if we like the wildcard behavior,
we would need to pass TOS to nm_platform_ip4_route_delete() to be
able to delete routes with non-zero TOS. So, while certain properties
may be omitted, some must not. See how test_ip4_route_options() was
broken.

For NetworkManager it only makes ever sense to call delete on a route,
if the route is already fully known. Which means, we only delete routes
that we have already in the platform cache (otherwise, how would we know
that there is something to delete). Because of that, no longer have separate
IPv4 and IPv6 functions. Instead, have nm_platform_ip_route_delete() which
accepts a full NMPObject from the platform cache.

The code in core doesn't jet make use of this new functionality. It will
in the future.

At least, it fixes deleting routes with differing TOS.
2017-07-25 06:44:12 +02:00
Thomas Haller
5b09f7151b platform: fix return value for do_delete_object()
The return value for the delete methods checks whether the object
is actually deleted. That is questionable behavior, because if the netlink
request succeeds, there is little point in checking with the platform cache.
As it is, it is racy.

Anyway, the previous value was totally wrong.

But it also uncovers another platform bug, which currently breaks
route tests. Will be fixed next.
2017-07-25 06:44:12 +02:00
Thomas Haller
5fcca9ba3e platform: refactor nm_platform_ip4_address_sync()
To reuse array of NMPObject instances instead of creating
a GArray clone.

Also get rid of the nm_platform_ipx_address_get_all() functions.
2017-07-25 06:44:12 +02:00
Thomas Haller
f749920f9c core: cache GVariant for NMIP4Config/NMIP6Config's "route-data" and "routes" 2017-07-25 06:44:12 +02:00
Thomas Haller
22edeb5b69 core: track addresses for NMIP4Config/NMIP6Config via NMDedupMultiIndex
Reasons:

 - it adds an O(1) lookup index for accessing NMIPxConfig's addresses.
   Hence, operations like merge/intersect have now runtime O(n) instead
   of O(n^2).
   Arguably, we expect low numbers of addresses in general. For low
   numbers, the O(n^2) doesn't matter and quite likely in those cases
   the previous implementation was just fine -- maybe even faster.
   But the simple case works fine either way. It's important to scale
   well in the exceptional case.
 - the tracked objects can be shared between the various NMPI4Config,
   NMIP6Config instances with NMPlatform and everybody else.
 - the NMPObject can be treated generically, meaning it enables code to
   handle both IPv4 and IPv6, or addresses and routes. See for example
   _nm_ip_config_add_obj().
 - I want core to evolve to somewhere where we don't keep copies of
   NMPlatformIP4Address, et al. instances. Instead they shall all be
   shared. I hope this will reduce memory consumption (although tracking a
   reference consumes some memory too). Also, it shortcuts nmp_object_equal()
   when comparing the same object. Calling nmp_object_equal() on the
   identical objects would be a common case after the hash function
   pre-evaluates equality.
2017-07-25 06:44:12 +02:00
Thomas Haller
74816a2237 core: rename self argument for NMIP4Config and NMIP6Config
The @config name is inconsistent. We name the self argument
commonly @self.
2017-07-25 06:44:12 +02:00
Thomas Haller
1c5d98292a c-list: add c_list_sort()
Add a stable, recursive merge sort for CList.

This could be improved by doing an iterative implementation.
The recursive implementation's stack depth is not an issue,
as it is bound by O(ln(n)). But an iterative implementation
would safe the overhead of O(n*log(n)) function calls and be
potentially faster.
2017-07-25 06:42:14 +02:00
Thomas Haller
824c8aba3d route-manager: fix timeout for cleanup device-route monitoring
The timeout was wrongly set to a huge number, and would never hit.
This leaked some data, that we could instead clean up. It's not
serious however.
2017-07-25 06:26:34 +02:00
Thomas Haller
c528a89519 contrib/rpm: skip tests for -Q build option
Previously, the --quick option only mattered when creating
the source tarball, to run `make dist` instead of the slower
`make distcheck`.

Extend its meaning to also skip unit tests while building the RPM.
You still can enable them with

  $ ./contrib/fedora/rpm/build_clean.sh -Q -w test
2017-07-25 06:18:36 +02:00
Lubomir Rintel
1ac92ac355 contrib/rpm: provide NetworkManager-devel
The package no longer exists.

Fixes: 03586743f0
2017-07-21 17:30:49 +02:00
Stephen Gallagher
03586743f0 contrib/rpm: fix Requires/Provides on subpackages
NetworkManager-wifi and NetworkManager-glib-devel should require
NetworkManager, not provide it.

https://bugzilla.redhat.com/show_bug.cgi?id=1454505
2017-07-20 20:44:06 +02:00
Beniamino Galvani
7204472de5 connectivity: fix memory leak
Fixes: 9d43869e47
2017-07-19 22:14:05 +02:00
Beniamino Galvani
8469d77e2b core: fix detection of relevant changes in nm_ipX_config_replace()
The @relevant_changes output value must match the result of
!nm_ipX_config_equal(), so route metric and gateway must be taken into
account too.

Fixes: 935411e5c0
Fixes: cfd1851c00

https://bugzilla.redhat.com/show_bug.cgi?id=1471244
2017-07-17 22:18:48 +02:00
Beniamino Galvani
5aa22ed8c9 dns: perform the public-suffix check only for the hostname-derived domain
The DNS manager drops from the search list domains that are public
suffixes to prevent a possible domain hijack when using two-labels
hostnames [1].

This is a problem now that every single-label domain can be a TLD
since this means that such domains can't be used in the search list.

While it's useful to apply such restriction to the domain
automatically derived from the system hostname, it seems wrong to drop
domains specified by users in the configuration or provided by DHCP.

This commit keeps the public-suffix check only for the
hostname-derived domain

[1] https://bugzilla.redhat.com/show_bug.cgi?id=812394

https://bugzilla.redhat.com/show_bug.cgi?id=1404350
2017-07-17 17:01:51 +02:00
Thomas Haller
d61eaf2545 service: don't install dependency for "NetworkManager-wait-online.service" to "network-online.target.wants"
If we install "NetworkManager-wait-online.service" in the
"network-online.target.wants" directory, network-online.target always
pulls in NetworkManager-wait-online.service. As it was, it could only
be disabled by masking the service.

Instead, we should enable NetworkManager-wait-online.sevice via
systemd's preset. That is already done for Fedora 26 and newer.

Note that NetworkManager-wait-online.sevice already has Install.WantedBy.
This way, the dependency is created automatically when enabling the service.

https://bugzilla.redhat.com/show_bug.cgi?id=1455704
2017-07-17 16:04:21 +02:00
Thomas Haller
f42b4960f8 cli: warn when adding connection with a name that already exists
As far as NetworkManager is concerned, the "connection.id" (also called
"con-name" in nmcli) is a pretty name and does not need to be unique.

UI components usually show the "connection.id" instead of the
"connection.uuid" identifier. It is hence likely, that the user
would not intentionally re-use the same name for multiple connection
profiles.

Print a warning to stderr when the user adds such a connection.

This only affects `nmcli connection add` and `nmcli connection import`,
but not `nmcli connection clone` and not interactive edit mode.

https://bugzilla.redhat.com/show_bug.cgi?id=1460796
2017-07-17 14:49:31 +02:00
Thomas Haller
45a58c3811 trivial: fix whitespace 2017-07-17 12:49:58 +02:00
Beniamino Galvani
7a14757595 core: fix route synchronization
Fixes: 667c50f5d9
2017-07-15 09:55:58 +02:00
Thomas Haller
ad5f5c81ef core: shortcut equal operator for identical object reference in NMDedupMultiIndex
And get rid of the unused obj_full_equality_allows_different_class.
It's hard to grasp how to implement different object types that can compare
despite having different klasses. The idea was, that stack allocated
objects (used as lookup needles), are some small lightweight objects,
that still compare equal to the full instance. But it's unused. Drop it.
2017-07-10 21:55:00 +02:00
Thomas Haller
930da031b2 core: fix NMDedupMultiIndex's _dict_idx_entries_hash()
Don't overwrite @h.

Fixes: f9202c2ac1
2017-07-10 21:55:00 +02:00
Thomas Haller
67bc29bed1 core: fix heap overflow accessing NMIP4Config's idx_ip4_routes
and NMIP6Config.

Fixes: 935411e5c0
2017-07-10 21:53:59 +02:00
Thomas Haller
0c23191b01 dhcp/tests: add test parsing dhclient config 2017-07-10 11:44:33 +02:00
Jonathan Kang
3646ed083d dhcp/dhclient: improve "interface" statement parsing
In commit d405cfd908, parsing "interface"
statement is introduced. But it leads to uncommplete parsing of the
"request" entry, if one of the lines in "request" entry is prefixed with
word "interface". For example, the default configuration of openSUSE
distribution:

request subnet-mask, broadcast-address, routers,
	rfc3442-classless-static-routes,
	interface-mtu, host-name, domain-name, domain-search,
	domain-name-servers, nis-domain, nis-servers,
	nds-context, nds-servers, nds-tree-name,
	netbios-name-servers, netbios-dd-server,
	netbios-node-type, netbios-scope, ntp-servers;

Fixes: d405cfd908

https://bugzilla.opensuse.org/show_bug.cgi?id=1047004
https://mail.gnome.org/archives/networkmanager-list/2017-July/msg00015.html
2017-07-10 11:35:12 +02:00
Beniamino Galvani
f395a0c29b cli: don't track device state for VPN connections
Currently nmcli considers the state of the device associated to a
connection to determine the success of an activation; for VPNs the
device is the parent interface on which the VPN is established.

This means that VPNs on bond/bridge/team interfaces are reported as
connected immediately because of the special handling of master
devices state in check_activated().

The parent device state is not meaningful for VPNs, so don't track it.
2017-07-09 16:10:54 +02:00
Yuri Chornoivan
b535ecc23a po: update Ukrainian (uk) translation (bgo#784529)
https://bugzilla.gnome.org/show_bug.cgi?id=784529
2017-07-07 13:28:50 +02:00
Thomas Haller
22cd73d3aa all: merge branch 'th/dedup-multi-bgo784220'
Refactor platform cache to track objects via a doubly linked
list, with each element indexed via a hash table.

This preserves the order of the objects, which will be needed
for improving the route cache.

Also, the NMPObjects are now immuable, ref-counted and can be
shared. This will allow other parts to reuse the same objects.

NMPIP4Config and NMPIP6Config now uses the same data structure
for tracking their routes. This changes the O(n^2) runtime for
intersect, merge and subtract to O(n).

https://bugzilla.gnome.org/show_bug.cgi?id=784220
2017-07-07 10:21:58 +02:00
Thomas Haller
b2112ff471 platform: refactor NMPObject cast macros using _Generic()
This way, we also accept void pointers, while preserving constness.
2017-07-05 22:17:42 +02:00
Thomas Haller
06598700fe platform: refactor nm_platform_link_get_all() to return GPtrArray
Instead of doing a full clone, return a pointer array (with references
owned). The NMPlatformLink instances are now immutable.
2017-07-05 19:03:46 +02:00
Thomas Haller
ac60b0ce60 platform: move link accessors to NMPlatform base class
and refactor NMFakePlatform to also track links via NMPCache.

For one, now NMFakePlatform also tests NMPCache, increasing the
coverage of what we care about.

Also, all our NMPlatform implementations now use NMPObject and NMPCache.
That means, we can expose those as part of the public API. Which is
great, because callers can keep a reference to the NMPObject object
and make use of generic functions like nmp_object_to_string().
2017-07-05 18:37:39 +02:00
Thomas Haller
71cf60e852 platform: refactor fake platform to use NMPCache for addresses
And move some code from NMLinuxPlatform to NMPlatform, where it belongs.

The advantage is that we reuse (and test!) the NMPCache implementation for
tracking addresses.

Also, we now always expose proper NMPObjects from both linux and fake
platform.

For example,

  obj = NMP_OBJECT_UP_CAST (nm_platform_ip4_address_get (...));

will work as expected. Also, the caller is now by NMPlatform API
allowed to take and keep a reference to the returned objects.
2017-07-05 18:37:39 +02:00
Thomas Haller
8b3b148fda platform/trivial: rename cache-id-type indexes 2017-07-05 18:37:39 +02:00
Thomas Haller
17f02318ad platform: drop separate index for visible objects
Routes and addresses don't implement cmd_obj_is_visible(),
hence they are always visible, and NMP_CACHE_ID_TYPE_OBJECT_TYPE_VISIBLE_ONLY
is identical to NMP_CACHE_ID_TYPE_OBJECT_TYPE.

Only link objects can be alive but invisible. Still, drop the index
for looking up visible links entirely. Let callers do the filtering,
if they care.
2017-07-05 18:37:39 +02:00
Thomas Haller
beb0b9b1ad platform: reduce number of route indexes
Maintaining an index is expensive.Not so much in term of runtime, but
in term of memory.

Drop some indexes, and require the caller to use a more broad index (and
filter out unwanted elements).

Dropped:

 - can no longer lookup visible default-routes by ifindex.
   If you care about default-routes, lookup all and search for the
   desired ifindex. The overall number of default-routes is expected
   to be small.
   We drop NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_BY_IFINDEX_WITH_DEFAULT
   entirely.

 - no longer have a separate index for non-default routes. We
   expect that the most routes are non-default routes. So, don't
   have an index without default-routes, instead let the caller
   just lookup all routes, and reject default-routes themself.
   We keep NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_BY_DEFAULT, but it
   now no longer tracks non-default routes.

This drops 1 out of 6 route indexes, and modifes another one, so
that we expect that there are almost no entires tracked by it.
2017-07-05 18:37:39 +02:00
Thomas Haller
35f52aafc1 platform: drop nm_platform_ip6_route_get_all()
We no longer need a full clone of routes. The only remaining uses
are in test code. Rework it.
2017-07-05 18:37:39 +02:00
Thomas Haller
aeaa1b3b98 platform: refactor nm_dedup_multi_objs_to_ptr_array_head()
by moving the core functionality to "nm-dedup-multi.c".

As the ref-counting mechanism now is part of "nm-dedup-multi.c",
this works better and is reusable outside of platform.
2017-07-05 18:37:39 +02:00