Commit graph

11952 commits

Author SHA1 Message Date
Thomas Haller
d45bb6d461 platform: implement NMPObject and NMPCache
NMPObject is a simple "object" implemenation around NMPlatformObject.
They are ref-counted and have a class-pointer. Several basic functions
like equality, hash, to-string are implemented.

NMPCache is can be used to store the NMPObject. Objects are indexed
via their primary id, but there is also multi-lookup via NMCacheId
and NMMultiIndex.

Part of the implementation is inside "nm-linux-platform.c",
because it depends on utility functions from there.

(cherry picked from commit 53f98e7f9e)
2015-06-21 15:21:56 +02:00
Thomas Haller
9842f292c1 platform: move ObjectType to nmp-object.h
(cherry picked from commit d1e7554a90)
2015-06-21 15:21:56 +02:00
Thomas Haller
d4899efd49 platform: add nmp-object.h file
(cherry picked from commit 359fe9f8c1)
2015-06-21 15:21:56 +02:00
Thomas Haller
9bd4cf340d core: add NMMultiIndex class
A class to do efficient lookup for multiple values based on a key.

The values are opaque pointers (void*). These values can be
associated with keys. The keys are an opaque type NMMultiIndexId
with arbitrary hash/equal functions.

Think of the keys being a set of buckets. A value can be associated with multiple
keys, just like with a regular GHashTable (i.e. it can be in multiple buckets).
But one key can also be associated with multiple values (i.e. one bucket can contain
multiple values). Hence the name "multi".
One bucket can only either contain a value or not. It cannot contain the same
value multiple times.

This is implemented as a hash of hashes with the outer keys being
NMMultiIndexId. The inner hashes are the "buckets".

This class will be used as an efficient lookup index to find all values
that belong to a certain key (bucket). Later we will ask for example
"Which IP4-Addresses are associated with a certain ifindex" and
efficiently retrieve the cached result list.

(cherry picked from commit f99723eda5)
2015-06-21 15:21:56 +02:00
Thomas Haller
d0e2937006 core: add NMRefString
NMRefString is a simple, refcounted, immutable string. Increasing/decreasing
the refcount does not affect const-ness.

It can be used just like a regular 'const char *' pointer. The only
difference is that you need special alloc/free functions.

(cherry picked from commit 430658b17a)
2015-06-21 15:21:54 +02:00
Thomas Haller
a87231abbc glib-compat: add nm_g_hash_table_replace() compat function
The newer version of g_hash_table_replace() is useful, because it
saves an additional hash table lookup.

(cherry picked from commit 2bea70e750)
2015-06-21 15:19:01 +02:00
Thomas Haller
fa7acaef83 platform: add _NM_IP_CONFIG_SOURCE_RTPROT_KERNEL source
Later we will need this flag to distinguish routes from kernel
that have source RTPROT_KERNEL.

This flag is still unused.

(cherry picked from commit 64d918293b)
2015-06-21 15:19:01 +02:00
Thomas Haller
01d20783ed platform: implement dispose() in NMLinuxPlatform
(cherry picked from commit 304abc909a)
2015-06-21 15:19:01 +02:00
Thomas Haller
4ac1889a86 platform: print more fields in nm_platform_link_to_string()
(cherry picked from commit c34598fa23)
2015-06-21 15:19:01 +02:00
Thomas Haller
27c87c75b8 platform: expose internal buffer for to_string() functions
I'd like to reuse this buffer for other to-string functions that
are platform related.

(cherry picked from commit 655a0e71d4)
2015-06-21 15:19:01 +02:00
Thomas Haller
988e8139d0 platform/trivial: rename to_string_buffer variable
(cherry picked from commit 806109c245)
2015-06-21 15:19:01 +02:00
Thomas Haller
79f2c30099 platform: add inet6_token parameter to NMPlatformLink
(cherry picked from commit 32ab8c18f5)
2015-06-21 15:19:01 +02:00
Thomas Haller
0acc868baa platform: add arptype parameter to NMPlatformLink
(cherry picked from commit 3ce4431695)
2015-06-21 15:19:01 +02:00
Thomas Haller
0ee58d136a platform: add inet6_addr_get_mode_inv parameter to NMPlatformLink
(cherry picked from commit 5b2b62ff51)
2015-06-21 15:19:00 +02:00
Thomas Haller
a0cb0b6b08 platform: add addr parameter to NMPlatformLink
(cherry picked from commit 36e77218a0)
2015-06-21 15:19:00 +02:00
Thomas Haller
607b69bbc0 platform: add vlan_id parameter to NMPlatformLink
(cherry picked from commit 3cdde18f52)
2015-06-21 15:19:00 +02:00
Thomas Haller
4e2ef48a21 platform: add flags parameter to NMPlatformLink
(cherry picked from commit b307abc010)
2015-06-21 15:19:00 +02:00
Thomas Haller
980d6f4b78 platform: add scope parameter to NMPlatformIP4Route
Cache the scope as part of the NMPlatformIP4Route and
no longer read it from libnl object when needed. Later
there will be no more libnl objects around, and we need
to scope when deleting an IPv4 route.

(cherry picked from commit 619f660a3e)
2015-06-21 15:18:56 +02:00
Thomas Haller
4e5a11f229 platform: return @now from _rtnl_addr_last_update_time_to_nm()
Will be used later.

(cherry picked from commit 4c49d78f49)
2015-06-21 15:18:15 +02:00
Jiří Klimeš
0380c53c39 core/cli: add missing device state-reason to string conversions
for NM_DEVICE_STATE_REASON_PARENT_CHANGED
and NM_DEVICE_STATE_REASON_PARENT_MANAGED_CHANGED

Fixes: cd3df12c8f
(cherry picked from commit bfd502a9b1)
2015-06-20 11:38:35 +02:00
Thomas Haller
8366b9f60d device: fix wrong assert in NMDeviceFactory
nm_device_factory_manager_find_factory_for_link_type()
easily can see a link-type NM_LINK_TYPE_UNKNOWN because
there are many link types that NetworkManager cannot detect.

Just return NULL early.

Fixes: 71bde20c30
(cherry picked from commit eb2efaa228)
2015-06-20 11:38:17 +02:00
Beniamino Galvani
435dec420f wifi: fix memleak in nm_ap_update_from_properties()
Fixes: 59c8192b22
(cherry picked from commit 3e8d828008)
2015-06-20 11:36:55 +02:00
Dan Williams
5fa0b8a222 wifi: fix recognition of AP RSN capabilities
Stupid C&P error made everything look like WPA1.

Fixes: 59c8192b22
(cherry picked from commit fce2fa57a5)
2015-06-20 11:30:17 +02:00
Dan Williams
21b382f292 supplicant: disconnect properties handler on dispose
The supplicant interface's proxy may outlive the interface object
itself, so we must ensure that all signal handlers are disconnected.
Fixes a crash on suspend/resume.

Fixes: 59c8192b22
(cherry picked from commit e5e0fa566b)
2015-06-20 11:28:48 +02:00
Dan Winship
57818c0b77 core: merge branch 'danw/signals-bgo743052'
https://bugzilla.gnome.org/show_bug.cgi?id=743052

(cherry picked from commit 1970f59b6f)
2015-06-20 11:03:52 +02:00
Dan Winship
8656c18690 core: add nm_utils_setpgid(), and use it
Add nm_utils_setpgid() as a g_spawn*() child setup function for
calling setpgid(), and use it where appropriate rather than
reimplementing it every time.

(cherry picked from commit fb792af7cb)
2015-06-20 11:01:27 +02:00
Dan Winship
baacd13bd6 core, dispatcher: drop unnecessary setpgid() calls
There's no point in calling setpgid() on short-lived processes, so
remove the setpgid() calls when spawning dispatcher scripts, iptables,
iscsiadmin, and netconf.

(cherry picked from commit c22e3f327a)
2015-06-20 10:56:58 +02:00
Dan Winship
2397d776f5 nm-iface-helper: small signal handling fixup
nm-iface-helper originally used the same pthread_sigmask()-based
signal handling as NetworkManager, but was then switched to using
g_unix_signal_add(). But a little bit of unnecessary code remained.

(cherry picked from commit 3d068724da)
2015-06-20 10:53:12 +02:00
Dan Winship
4213815d6b core: use GUnixSignalWatchSource to simplify signal handling
Replace the pthread_sigwait()-based signal handling with
g_unix_signal_add()-based handling, and get rid of all the
now-unnecessary calls to nm_unblock_posix_signals() when spawning
subprocesses.

As a bonus, this also fixes the "^C in gdb kills NM too" bug.

(cherry picked from commit c5b3e93792)
2015-06-20 10:48:21 +02:00
Thomas Haller
265b1d2b2a default-route-manager: backport changes from master
- some spell fixes in comments
- improve logging
- fix bug that triggers an assert
2015-06-19 13:45:03 +02:00
Thomas Haller
27edd58bd4 default-route-manager: fix syncing routes to consider non-synced routes
We already protected route-metrics that are configured as default-routes
in platform. For most cases, that list is identical to our internal list
of non-synced routes.
But if for some reason that is not the case, we must also protect the
metric of routs that we currently track as "non-synced".

(cherry picked from commit 6849050ad9)
2015-06-19 13:43:02 +02:00
Thomas Haller
7be6d96440 default-route-manager: disambiguate logging statements
(cherry picked from commit 8da17c3a19)
2015-06-19 13:42:57 +02:00
Thomas Haller
76e5d55a98 default-route: add @out_is_never_default argument to has_default_route()
Also accept a NULL connection in
nm_default_route_manager_ip4_connection_has_default_route() and
nm_default_route_manager_ip6_connection_has_default_route().

(cherry picked from commit 49227a07f3)
2015-06-19 13:42:21 +02:00
Thomas Haller
9bac91eb69 trivial: fix spelling in comments
(cherry picked from commit ccba1b1e2d)
2015-06-19 13:39:33 +02:00
Jiří Klimeš
a022cf7c76 core: (trivial) fix spelling in comments
(cherry picked from commit 8257940606)
2015-06-19 13:38:49 +02:00
Thomas Haller
a7742aeeeb trivial: fix spelling in comment
(cherry picked from commit 9d6b67012c)
2015-06-19 13:37:44 +02:00
Thomas Haller
10537699fb default-route: improve logging format for default route entries
The previous syntax (s/S for synced, n/N for never-default) is confusing.
Indicate 'never-default' by '0', vs. '1'.
Indicated synced/non-synced as '+sync' and '-sync'.

(cherry picked from commit df9533d045)
2015-06-19 13:37:39 +02:00
Thomas Haller
be851ba0b2 core: use NM_DEFINE_SINGLETON_GETTER() macro
(cherry picked from commit eecc440351)
2015-06-19 13:34:32 +02:00
Thomas Haller
3f2d861614 ifcfg-rh,cli: merge partical backport of branch 'th/default-dns-options-bgo749648'
- some enhancements and bugfixes to ifcfg-rh utils
- fix and refactoring nmcli value-to-string conversion

(cherry picked from commit ec972ad305)
2015-06-19 13:31:08 +02:00
Thomas Haller
c741edaf76 cli: stack allocate search string in nmc_properties_find()
(cherry picked from commit 350900d0a5)
2015-06-19 13:23:29 +02:00
Thomas Haller
77fa56a5e7 cli: refactor nmc_add_prop_funcs() to use variadic macro
The advantage of this is that if we later add another function
pointer we don't have to touch any existing calls which would
only pass NULL to that argument.

Using a variadic argument and partial initialization of an
auto variable gives us that flexibility.

(cherry picked from commit 035e31327b)
2015-06-19 13:23:29 +02:00
Thomas Haller
8d6cced2c5 cli: do not create a copy of static strings for nmc_properties hash
The keys of the hash are static strings. No need to make a copy of it.
If we ever need dynamics properties, we should intern those strings.

(cherry picked from commit 16f089ce64)
2015-06-19 13:19:26 +02:00
Thomas Haller
b81bbc134c cli: refactor property to string conversion
Instead of having a get_func() and out2in_func(), have only one
get_func() that accepts an argument of the output format.

This way, a conversion to parsable input format, doesn't have to go
first thourgh get_func() and mangle the pretty string in out2in_func().

This fixes conversions via nmc_property_out2in_cut_paren().
For example, nmc_property_802_1X_get_private_key_password_flags()
would return a localized string _("0 (none)"). There is no guarantee
that out2in_func() would find the expected output format after
localizing.

This also fixes nmc_property_out2in_routes() which expected
a format "dst =" (would be "ip =") and expects mandatory
'nh' and 'mt' arguments. In fact, the regex didn't match and
nmc_property_out2in_routes() always failed.

While at it, also combine the implementation of
nmc_property_ipv4_get_routes() and nmc_property_ipv6_get_routes().

(cherry picked from commit 8a14851f93)
2015-06-19 13:18:16 +02:00
Thomas Haller
c933bacd4a ifcfg-rh: add svSetValueFull() to support writing empty values
svSetValue() treated the empty word like %NULL.
Handle empty differently from unset.

(cherry picked from commit 0348bc9195)
2015-06-19 13:08:55 +02:00
Thomas Haller
7a98e481d9 ifcfg-rh: fix svSetValue() to properly handle empty variables
svSetValue() called svGetValue() which would return %NULL
for empty variables. That is wrong, because it caused svSetValue()
to add the variable anew.

(cherry picked from commit 51255d8b64)
2015-06-19 13:08:46 +02:00
Thomas Haller
5ad85e17db ifcfg-rh: use svGetValueFull() in svGetValueInt64()
Previously, it would silently accept a value set to "empty".
This is however not a valid number and we should raise a
warning just like for any other invalid number.

(cherry picked from commit c6efbeccf3)
2015-06-19 13:08:37 +02:00
Thomas Haller
1cce24f346 ifcfg-rh: add svGetValueFull() function
(cherry picked from commit 33aaa730c5)
2015-06-19 13:08:30 +02:00
Thomas Haller
e3a76a4f3d ifcfg-rh: refactor svSetValue() and svEscape() not to clone string needlessly
In the most cases we don't expect that our values need
escaping. No need to do an additional copy of the unmodified
string.

(cherry picked from commit 32871deecc)
2015-06-19 13:07:45 +02:00
Thomas Haller
6861cd1f2b libnm: fix compare_property() to handle default values
Before, get_property_for_dbus() would @ignore_defaults.
That is for example wrong for properties of type G_TYPE_STRV.

In this case, if one operand has the property at its default
(NULL) and the other has it to an empty string list, both would
compare equal.

This has the effect that different settings might compare equal.

(cherry picked from commit 7478c4b54a)
2015-06-19 13:06:37 +02:00
Thomas Haller
217c012595 ifcfg-rh: better detect alias files
Alias files have a ':' to separate the base name from their
alias. But we didn't always ensure not to write-out files without
colon, and also initscripts doesn't have that restriction.

We should detect alias files and handle them properly (e.g. by
reloading the base file).

This fixes an error that a `nmcli con load` would have tried to
load the alias file. Also extend load_connection() to support
passing filenames other then the base file.

We only have to handle this in plugin.c. Inside reader.c we always
have the normalized base filename.

Or detection of alias files only looks whether the filename has a ':'
and whether a corresponding base file exists.

(cherry picked from commit 0aed4e2388)
2015-06-19 13:02:24 +02:00