Commit Graph

12792 Commits

Author SHA1 Message Date
Thomas Haller
230099aa52 cli: show dns-options default value
You can reset the default value via

  $ nmcli connection modify id CON ipv4.dns-options ""

and set an empty value with

  $ nmcli connection modify id CON ipv4.dns-options " "
2015-06-05 12:26:48 +02:00
Thomas Haller
f81d7242c3 cli: add DEFINE_GETTER_WITH_DEFAULT() macro 2015-06-05 12:26:48 +02:00
Thomas Haller
350900d0a5 cli: stack allocate search string in nmc_properties_find() 2015-06-05 12:26:48 +02:00
Thomas Haller
035e31327b 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.
2015-06-05 12:26:48 +02:00
Thomas Haller
16f089ce64 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.
2015-06-05 12:26:48 +02:00
Thomas Haller
8a14851f93 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().
2015-06-05 12:26:48 +02:00
Thomas Haller
51b1fd976f ifcfg-rh: distinguish in reader and writer between unset and empty dns-options 2015-06-05 12:26:48 +02:00
Thomas Haller
d5e948e482 libnm/test: test compare_property() to handle default values
Add a test case to check whether compare/diff works correctly.
2015-06-05 12:26:48 +02:00
Thomas Haller
a8dd1b5358 libnm: make dns-options support an "undefined" default value
We want to distinguish between "no-options/empty" and "unset/default".
The latter can be interpreted by NM to use a default set of options.
2015-06-05 12:26:48 +02:00
Thomas Haller
0348bc9195 ifcfg-rh: add svSetValueFull() to support writing empty values
svSetValue() treated the empty word like %NULL.
Handle empty differently from unset.
2015-06-05 12:26:48 +02:00
Thomas Haller
51255d8b64 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.
2015-06-05 12:26:48 +02:00
Thomas Haller
c6efbeccf3 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.
2015-06-05 12:26:48 +02:00
Thomas Haller
33aaa730c5 ifcfg-rh: add svGetValueFull() function 2015-06-05 12:26:48 +02:00
Thomas Haller
32871deecc 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.
2015-06-05 12:26:48 +02:00
Thomas Haller
7478c4b54a 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.
2015-06-05 12:26:48 +02:00
Thomas Haller
bc75cd53a8 core: detect route-metric when creating nm-generated-assumed connection
When generating a connection to assume it, also record the route-metric.
Do that by looking at the metric of the (best) default-route.

This is especially important since d51975ed92.
Now NM would also manage the default-route for assumed connections.
So the generated assumed connection would have a route metric based on
the device type, which might differ from the external configuration.
This caused NM to replace the externally configured default-route.

https://bugzilla.gnome.org/show_bug.cgi?id=750405
2015-06-05 11:08:03 +02:00
Thomas Haller
2a5d17eb5f valgrind: rework run-test-valgrind.sh script not to print unrelated message
If the valgrind logfile is empty, don't log an error message with
the location of the logfile.

Also, if the test didn't fail due to memleaks, log a different message.
2015-06-04 17:48:34 +02:00
Thomas Haller
ca3fb3edcd trival: add code comment 2015-06-04 17:48:34 +02:00
Lubomir Rintel
6a841c0cd1 core: avoid loading GIO modules
Turns out the dconf modules is leaky and breaks the valgrind run. In any case,
it's not a good idea to load the modules for the daemon, it just takes time
and memory.

On a Fedora/x86_64 desktop it adds up to 5M to the RSS.
2015-06-04 14:29:10 +02:00
Lubomir Rintel
df0676ab00 tests: delete the valgrind logs if they're empty 2015-06-04 14:29:10 +02:00
Lubomir Rintel
d909e76d9e tests: don't limit the valgrind tracebacks to 12 frames
The glib tracebacks are typically longer.
2015-06-04 14:29:10 +02:00
Thomas Haller
0554474720 valgrind: add comment to valgrind suppression explaining how to reproduce 2015-06-04 13:08:16 +02:00
Thomas Haller
d84ac1baca valgrind: add valgrind suppression for Fedora 22
Fixes for example valgrind tests for ./libnm/tests/test-nm-client:

    ==25772== Conditional jump or move depends on uninitialised value(s)
    ==25772==    at 0x40198D8: index (strchr.S:106)
    ==25772==    by 0x400777C: expand_dynamic_string_token (dl-load.c:369)
    ==25772==    by 0x400777C: fillin_rpath (dl-load.c:439)
    ==25772==    by 0x4007FCF: _dl_init_paths (dl-load.c:816)
    ==25772==    by 0x4002F38: dl_main (rtld.c:1194)
    ==25772==    by 0x401750F: _dl_sysdep_start (dl-sysdep.c:249)
    ==25772==    by 0x4004C20: _dl_start_final (rtld.c:306)
    ==25772==    by 0x4004C20: _dl_start (rtld.c:412)
    ==25772==    by 0x4000C97: ??? (in /usr/lib64/ld-2.21.so)
    ==25772==    by 0x1: ???
    ==25772==    by 0xFFEFFF6B2: ???
    ==25772==    by 0xFFEFFF6EF: ???
    ==25772==
    {
       <insert_a_suppression_name_here>
       Memcheck:Cond
       fun:index
       fun:expand_dynamic_string_token
       fun:fillin_rpath
       fun:_dl_init_paths
       fun:dl_main
       fun:_dl_sysdep_start
       fun:_dl_start_final
       fun:_dl_start
       obj:/usr/lib64/ld-2.21.so
       obj:*
       obj:*
       obj:*
    }
2015-06-03 20:11:01 +02:00
Thomas Haller
2071e4794f libnm: fix take ownership of floating argument in NMSecretAgentOld:get_secrets_cb()
The previous patch 9ffcecf86a was
completely wrong.

It tried to fix callers that provided a floating GVariant reference.
We require the caller to unref @secrets, so the correct fix it to
ensure that the reference is not floating.

Fixes: 9ffcecf86a
Fixes: 6793a32a8c
2015-06-03 19:34:38 +02:00
Thomas Haller
9ffcecf86a libnm: don't take ownership of input argument in NMSecretAgentOld:get_secrets_cb()
Fixes: 6793a32a8c
2015-06-03 18:07:21 +02:00
Lubomir Rintel
5a3eb7aee3 build: correctly set DISTCHECK_CONFIGURE_FLAGS
Fixes: 84021454eb
2015-06-03 09:44:51 +02:00
Beniamino Galvani
3bc097b084 device: don't assume by default IPv6LL-only connections
Add the new configuration option 'assume-ipv6ll-only' which specifies
the devices for which NM will try to assume an existing IPv6LL-only
configuration.

The new default behavior is to ignore such configurations since IPv6LL
addresses are automatically assigned by the kernel when the device is
brought up and thus the presence of an IPv6LL address doesn't mean
that the device was configured by the administrator.

The previous behavior was to always assume IPv6LL-only configurations
but this often had the unwanted effect of preventing other on-disk
configurations to be activated. To preserve the old behavior the
option must be set to '*'.

https://bugzilla.redhat.com/show_bug.cgi?id=1138426
2015-06-02 14:04:54 +02:00
Thomas Haller
231e9e3968 ifcfg-rh: merge branch 'th/ifcfg-rh-fixes-bgo750231'
Some fixes for loading ifcfg-rh files, related to
alias files.
2015-06-02 13:05:23 +02:00
Thomas Haller
0aed4e2388 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.
2015-06-02 12:57:52 +02:00
Thomas Haller
2e87df8408 ifcfg-rh: escape colon in generated filename
A colon indicates an alias file. It should be escaped.
2015-06-02 12:57:52 +02:00
Thomas Haller
8be9e832b5 ifcfg-rh: refactor utils_should_ignore_file() to return early 2015-06-02 12:57:52 +02:00
Thomas Haller
4ef8c0c90c 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>
2015-06-02 12:57:52 +02:00
Thomas Haller
900aa016b1 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.
2015-06-02 12:57:52 +02:00
Lubomir Rintel
83a82b4489 merge: fix build & tests with older tooling 2015-06-02 12:31:08 +02:00
Lubomir Rintel
84021454eb build: don't default to -Werror
It seems like a poor default for various downstream toolchains. We can't
anticipate the compiler warnings for future compiler versions and older
ones are prone to false positives. Also, older gdbus-codegen is known
to generate code that triggers compiler warnings.

Let's keep it enabled for maintainer builds and distcheck so that we're
sure a tool chain that builds releases without warnings exists.
2015-06-02 12:30:03 +02:00
Lubomir Rintel
e486a3803d build: don't abort configure if there's no systemd devel headers
Just disable systemd-logind session tracking instead.
2015-06-02 12:30:03 +02:00
Lubomir Rintel
b9b7bb1958 tests: avoid calling GLib.IOChannel.unix_new()
The Ubuntu 12.04 introspection data don't contain it. However, the default
constructor works just well and even looks a bit more Python-y.
2015-06-02 12:30:03 +02:00
Lubomir Rintel
ccb0ca4493 libnm-core,libnm-util: avoid calling a constructor
It yields completely unpredictable results on Ubuntu 12.04 (the global variable
successfully comparing to NULL despite demonstrably not NULL). Possibly a
toolchain bug.
2015-06-02 12:30:03 +02:00
Lubomir Rintel
3811a68389 systemd-dhcp: fix build with Linux 3.2.0 headers
Fixes build on Ubuntu 12.04.

systemd/src/libsystemd-network/dhcp-network.c: In function '_bind_raw_socket':
systemd/src/libsystemd-network/dhcp-network.c:75:17: error: 'BPF_XOR' undeclared (first use in this function)
systemd/src/libsystemd-network/dhcp-network.c:75:17: note: each undeclared identifier is reported only once for each function it appears in
make[4]: *** [libsystemd_nm_la-dhcp-network.lo] Error 1
2015-06-02 12:30:03 +02:00
Lubomir Rintel
22b99e3bbb ppp-manager: fix build with Linux 3.2.0 headers
Fixes build with Ubuntu 12.04.

In file included from ppp-manager/nm-ppp-manager.c:42:0:
/usr/include/linux/if_ppp.h:103:16: error: field 'b' has incomplete type
/usr/include/linux/if_ppp.h:108:21: error: field 'b' has incomplete type
2015-06-02 12:30:03 +02:00
Lubomir Rintel
eb2b8c2798 build: use compat version of g_clear_pointer()
Ubuntu 12.04 has an ancient version of glib, which we nevertheless support.
2015-06-02 12:30:03 +02:00
Lubomir Rintel
36f7669a4c core: don't assume the loopback interface is called "lo"
I did a "ip link set lo name yolo" and now my NetworkManager triggers an
assertion failure. :( Nevertheless, the loopback interface is always ifindex=1.
2015-06-01 17:30:24 +00:00
Lubomir Rintel
ef295ddeef platform-linux: allow netlink messages from non-privileged user namespaces
Just check they're from kernel.
2015-06-01 17:30:20 +00:00
Thomas Haller
b8b1a01d96 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.
2015-06-01 14:47:08 +02:00
Thomas Haller
dce00f0d10 utils: move NM_FLAGS_*() macros to header file "include/nm-utils-internal.h" 2015-05-29 16:28:33 +02:00
Thomas Haller
2297333bb1 default-route: merge branch 'th/default-route-fixes-rh1205405'
Two improvements for handling default-routes.

https://bugzilla.redhat.com/show_bug.cgi?id=1224291
https://bugzilla.redhat.com/show_bug.cgi?id=1205405
2015-05-29 11:50:10 +02:00
Thomas Haller
d51975ed92 default-route: also configure default-routes for assumed connections
Previously for assumed connections we would never configure a default route.
That has serious problems for example in the following two scenarios:

  - the default-route might have a limited lifetime from a previous
    SLAAC/accept_ra setting. In this case, once we assume the connection
    we must also ensure that we extend the lifetime of the default
    route.
  - the gateway could be received via DHCP/RA and it might change.
    If we ignore default-routes for assumed connection we miss that
    change.

The problem is that the notion of "assumed connection" wrongly combines
two conflicting goals (related bug bgo#746440):
  a) have an external device that is entirely unmanged by NM.
  b) do a seamless takeover of a previously managed connection at start,
     but still fully manage.

This patch changes the handling of default-routes towards meaning b).

https://bugzilla.redhat.com/show_bug.cgi?id=1224291
2015-05-29 11:48:57 +02:00
Thomas Haller
98e50e358b default-route: for devices with 'never-default' enforce the default-route only once
Since da708059da, we would pickup the
default-route as configured externally, except at those moments when
NM re-applys the IP configuration of the interface, such as during a
DHCP lease.

That allows the user to add/remove the default-route externally (iproute).
But still, at random times (DHCP lease), we will revert those external
changes.

Extend this, that if the connection is explicitly configured as
'never-default=yes', that it tells NM not to interfere with externally
added default-routes on this device. That means, NM will only remove
any preexisting default-routes when configuring the device a first
time.
On any later attempts, NM will assume whatever is configured there.
That makes sense because the user indicated not wanting NM to
manage a default-route on that device, so if something externally
added a default-route, assume that is what the user wants.

This only affects non-assumed connections, with 'never-default=yes'.

https://bugzilla.redhat.com/show_bug.cgi?id=1205405
2015-05-29 11:45:48 +02:00
Thomas Haller
49227a07f3 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().
2015-05-29 11:43:58 +02:00
Jiří Klimeš
242fe0bfb0 merge: increase 'max_replies_per_connection' limit in D-Bus configuration
The limit seems to be too low and causes problems in libnm-glib. We increase
the limit and warn in libnm-glib if it was exceeded.
2015-05-29 08:09:53 +02:00