Commit graph

11920 commits

Author SHA1 Message Date
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
Thomas Haller
ddd9884bcf platform: factor out ethtool_get_wake_on_lan() function
(cherry picked from commit 398819c3ac)
2015-06-19 12:26:03 +02:00
Thomas Haller
345b73fa1b platform: factor out ethtool_get_peer_ifindex() function
(cherry picked from commit ba084b5b90)
2015-06-19 12:26:03 +02:00
Thomas Haller
6c76801190 platform: factor out ethtool_supports_vlans() function
(cherry picked from commit 4be9394864)
2015-06-19 12:26:03 +02:00
Thomas Haller
a72350c4da platform/trivial: move ethtool_supports_carrier_detect() code
(cherry picked from commit 2b8f3331d7)
2015-06-19 12:26:03 +02:00
Thomas Haller
716dd795de platform: move code udev_get_driver() to nmp_utils_udev_get_driver()
(cherry picked from commit 77a3767d1e)
2015-06-19 12:26:02 +02:00
Thomas Haller
cd2d241fb7 platform: add nm-platform-utils.[ch] files
There is no general purpose file for platform utilities.
We only have nm-platform.h, which contains (mostly) functions
that operate on a NMPlatform instance (and that can be mocked
using NMFakePlatform).

Add a new file for independent utility functions. nm-platform-utils.c
should not call into functions having a NMPlatform instance, to
have them independent from platform caching and the platform
singleton.

(cherry picked from commit ce700d94f5)
2015-06-19 12:26:02 +02:00
Thomas Haller
4e0af0aa52 platform: move nm_platform_query_devices() to nm-manager
nm_platform_query_devices() would raise an 'added' signal
for all its links. That is bad style because it could
confuse other listeners for platform signals which don't
expect such artificial change signals.

The public API of NMPlatform already gives NMManager the ability
to 'pull' all the links and iterate them itself.

Before, nm_platform_query_devices() would also initialize udev
devices, so there was a more compelling reason for this function.

(cherry picked from commit d7a312d17a)
2015-06-19 12:26:02 +02:00
Thomas Haller
acb39d4b31 platform: merge setup_devices() function into constructed()
We already populate the netlink cache in constructed(). No need
to wait with udev devices until nm_platform_query_devices(). Just
do it right away.

Add a hack to keep 'lo' default-unmanaged. Now that we load
udev devices earlier, we end up clearing the default-unmanged
flag on 'lo', which has bad consequences.

(cherry picked from commit d6ce01f115)
2015-06-19 12:26:02 +02:00
Lubomir Rintel
cf0a0ed576 tests: use a user ns to fake root
(cherry picked from commit ed01c975d8)
2015-06-19 12:26:02 +02:00
Lubomir Rintel
a030ac36d3 tests: allow running the link test without a writeable sysfs
This fixes the test run in a container/our NETNS/NEWUSER test jail.

(cherry picked from commit f9dd7f0d84)
2015-06-19 12:26:02 +02:00
Thomas Haller
90eb13a111 core: add option to suppress error logging if nm_utils_modprobe() fails
We don't want error logging for nm_platform_link_add() which
tries to load the bonding module. Later we will run tests as non-root,
where modprobe will fail. Logging an error would break the tests.

(cherry picked from commit 39f2b51abb)
2015-06-19 12:26:02 +02:00
Thomas Haller
baf5f63374 utils: add NM_FLAGS_SET(), NM_FLAGS_UNSET() and NM_FLAGS_ASSIGN() macros
(cherry picked from commit 57958b93b6)
2015-06-19 12:26:02 +02:00
Thomas Haller
1d3c143948 build: rename file "include/nm-utils-internal.h" to "nm-macros-internal.h"
We already have "nm-utils*.h" and "NetworkManagerUtils.h" headers. Rename
"include/nm-utils-internal.h" to "nm-macros-internal.h". I think that
name is better, because this file is header-only, internal, and
repository-wide.

Also, it will never contain non-header-only declarations because
there is no backing object file under "include/".
It will only contain macros and inline functions.

(cherry picked from commit b8b1a01d96)
2015-06-19 12:21:58 +02:00
Thomas Haller
88bdeecf7c utils: move NM_FLAGS_*() macros to header file "include/nm-utils-internal.h"
(cherry picked from commit dce00f0d10)
2015-06-19 12:21:58 +02:00
Jiří Klimeš
b7b47941c0 merge: activate slaves when master is activated (bgo #735052) (rh #1158529)
When a master connection is activated, check all its slaves and decide whether
they should be activated as well. This is done according to the
connection.autoconnect-slaves property.

https://bugzilla.gnome.org/show_bug.cgi?id=735052
https://bugzilla.redhat.com/show_bug.cgi?id=1158529

(cherry-picked from b18f328967)
2015-06-19 12:19:18 +02:00
Jiří Klimeš
94337e58b7 man: mention that connection.autoconnect-slaves property supports default value
(cherry picked from commit f05d41d358)
2015-06-19 12:18:52 +02:00