Commit graph

11936 commits

Author SHA1 Message Date
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
Thomas Haller
14e2e57acd 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:00 +02:00
Thomas Haller
da112cc0cc ifcfg-rh: escape colon in generated filename
A colon indicates an alias file. It should be escaped.

(cherry picked from commit 2e87df8408)
2015-06-19 13:02:00 +02:00
Thomas Haller
9feb02d185 ifcfg-rh: refactor utils_should_ignore_file() to return early
(cherry picked from commit 8be9e832b5)
2015-06-19 13:02:00 +02:00
Thomas Haller
144093fa03 ifcfg-rh: also read alias file for dhcp connections
Previously, if the main ifcfg file doesn't define any
static ip addresses, any alias files would be ignored.

We should also allow alias files with (pure) 'dhcp' connections,
just like initscripts do.

Reported-by: Marek Hulan <mhulan@redhat.com>
(cherry picked from commit 4ef8c0c90c)
2015-06-19 13:02:00 +02:00
Thomas Haller
99eb598c34 ifcfg-rh: log warning when loading of connection fails
connection_from_file() used to log a warning about failure,
but only when an @error argument was given.

update_connection() didn't ensure that in several cases,
so we would not log any failure reason when an ifcfg file
failed to read.

This behavior of controlling logging by passing @error (or not)
is unexpected. Instead, refactor the code so that the caller
can do appropriate logging.
Another reason for this refactoring is that PARSE_WARNING() does
not mention the file for which the failure is and uses some extra
indention that looks wrong. IOW, connection_from_file() doesn't
have the context to give the logging line a proper formatting.

(cherry picked from commit 900aa016b1)
2015-06-19 13:02:00 +02:00
Thomas Haller
fd80b02405 ifcfg: refactor utils_get_ifcfg_name()
No need to allocate a temporary "base" variable. Just
search for the last '/' ourselves.
All the special handling that g_path_get_basename() does,
for example handling empty filenames and removing trailing
slashes, is not needed.

Thereby fix not to return empty names such as from "ifcfg-".

(cherry picked from commit 2ef8f6edfe)
2015-06-19 13:02:00 +02:00
Jiří Klimeš
eb07137bec main: fix a compiler warning about function declaration
warning: function declaration isn’t a prototype [-Wstrict-prototypes]

In C function() and function(void) are two different prototypes (as opposed to
C++).
function()     accepts an arbitrary number of arguments
function(void) accepts zero arguments
2015-06-19 12:54:59 +02:00
Thomas Haller
713065b880 libnm/utils: add _nm_utils_strv_find_first() function
(cherry picked from commit ef4e017cfa)
2015-06-19 12:43:03 +02:00
Thomas Haller
832b2bdff4 gitignore: ignore temporary files during build
If you type `git status` a certain times during build,
you see some temporary (untracked) files. Ignore them.

(cherry picked from commit 176b13374a)
2015-06-19 12:43:03 +02:00
Jiří Klimeš
60080377a2 all: fix a compiler warning about function declarations
warning: function declaration isn’t a prototype [-Wstrict-prototypes]

In C function() and function(void) are two different prototypes (as opposed to
C++).
function()     accepts an arbitrary number of arguments
function(void) accepts zero arguments

(cherry picked from commit 94a393e9ed)
2015-06-19 12:40:54 +02:00
Thomas Haller
c7a343117f platform: merge branch 'th/platform_refact_caching-bgo747981' (early part)
- add new file 'nm-platform-utils.c' and moves some independent utility
  functions there (ethtool, udev).
- some refactoring of platform code, including initialization of
  NMPlatform instance.
- run platform tests in a separate user namespace, which allow
  us to run root-tests as non-root.

https://bugzilla.gnome.org/show_bug.cgi?id=747981

(cherry picked from commit d38c3851f8)
2015-06-19 12:26:39 +02:00
Thomas Haller
072296750c platform: expose nm_platform_signal_change_type_to_string()
(cherry picked from commit d4f828c887)
2015-06-19 12:26:03 +02:00
Thomas Haller
8f6a883c73 platform: refactor support_kernel_extended_ifa_flags to static variable
Whether we have support depends on the kernel, and is not
per NMLinuxPlatform instance.

(cherry picked from commit 2f3fd86dc5)
2015-06-19 12:26:03 +02:00
Thomas Haller
adcd51065b platform: move ethtool_get_link_speed() to nm-platform-utils
(cherry picked from commit 95333d84bc)
2015-06-19 12:26:03 +02:00
Thomas Haller
f9760da1a1 platform: move supports_mii_carrier_detect() to nmp_utils_mii_supports_carrier_detect()
(cherry picked from commit 299af02e40)
2015-06-19 12:26:03 +02:00
Thomas Haller
8ad91fa6d0 platform: move ethtool_*() to nmp_utils_ethtool_*()
(cherry picked from commit ac84b22fc7)
2015-06-19 12:26:03 +02:00