Commit graph

5996 commits

Author SHA1 Message Date
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
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
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
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
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
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
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š
5318aec2c2 core: 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
autoconnect-slaves property.

https://bugzilla.gnome.org/show_bug.cgi?id=735052
https://bugzilla.redhat.com/show_bug.cgi?id=1158529
(cherry picked from commit f4582d812c)
2015-06-19 12:18:52 +02:00
Jiří Klimeš
8aa0b5b17d ifcfg-rh: read/write autoconnect-slaves property as AUTOCONNECT_SLAVES
AUTOCONNECT_SLAVES is an NetworkManager extension. initscripts always activate
slaves with the master connection for bond and team, and doesn't activate
automatically slaves for bridge.
NetworkManager behaviour is controlled by this variable. If the variable is
missing the default value from configuration file is used.

(cherry picked from commit 2a497eeadc)
2015-06-19 12:18:52 +02:00
Thomas Haller
1468f4edd2 device: remove reading ipv6 privacy setting from sysctl
Since introduction for support of ip6-privacy (use_tempaddr,
RFC4941) with commit d376270bfe,
the sysctl value from /etc was always read first.

This is problematic, because an explicit setting in the
connection should not be ignored over a global configuration.

Drop that old behavior. It was also problematic, because we did
not read any files under /etc/sysctl.d (except for sysctl.conf).
Also, we did not honor per-interface configurations.

Now we also use as last fallback the value from
/proc/sys/net/ipv6/conf/default/use_tempaddr
That has the advantage of falling back to the system default value
so that NM doesn't need to have it's own default policy
(Related: https://bugzilla.redhat.com/show_bug.cgi?id=1187525).

This is a change in behavior.

(cherry picked from commit f3c61f8141)
2015-06-19 12:10:52 +02:00
Thomas Haller
a6630e4fad device: add global configuration default for ip6-privacy (use_tempaddr, RFC4941)
Support default value for setting 'ipv6.ip6-privacy' in
NetworkManager.conf.

If the global value is unset, preserve old behavior of looking into
/etc/sycctl.conf first. That behavior was introduced with commit
d376270bfe, since we support ip6-privacy
setting.

If the global value is set to "unknown", add a new fallback
that instead reads the runtime value from
  "/proc/sys/net/ipv6/conf/default/use_tempaddr"
This seems more sensible behavior because we fallback to sysctl,
but instead of looking at static files in /etc, read /proc.
But to preserve the old behavior, we only do that when a global
value is configured at all.

https://bugzilla.gnome.org/show_bug.cgi?id=721200
(cherry picked from commit e729dd70ae)
2015-06-19 12:10:52 +02:00
Thomas Haller
923aa9d727 device: make route-metric configurable per-device
The route-metric can be configured per connection via the
ipv4.route-metric and ipv6.route-metric fields. When the
value is left at -1 (the default), we would determine the
route-metric based on the device type (nm_device_get_priority()).

Extend that scheme by making the default value overwritable in
NetworkManager.conf.

(cherry picked from commit 59a991725a)
2015-06-19 12:10:52 +02:00
Thomas Haller
a64e81703e config: support a [connection] section to NetworkManager.conf to specify connection defaults
Add support for a new section [connection] in NetworkManager.conf.
If the connection leaves an option at "unknown"/"default", we can
support overwriting the value from global configuration.

We also support other sections that are named with "connection"
as a prefix, such as [connection2], [connection-wifi]. This is
to support multiple default values that can be applied depending
on the used device.

I think this has great potential. Only downside is that when
the user looks at a connection value, it will see that it is
unspecified. But the actually used value depends on the device
type and might not be obvious.

https://bugzilla.gnome.org/show_bug.cgi?id=695383
https://bugzilla.redhat.com/show_bug.cgi?id=1164677

(cherry picked from commit dc0193ac02)
2015-06-19 12:10:51 +02:00
Thomas Haller
a76deff2f6 config: publish nm_config_keyfile_get_boolean() utility function
(cherry picked from commit f031b926c4)
2015-06-19 12:10:51 +02:00
Thomas Haller
1429ef7249 device: add device-spec "type:"
Support a device-spec to match by device-type.
This matches on the value as shown by

  nmcli -f GENERAL.TYPE device show

(cherry picked from commit 3fb60edf9f)
2015-06-19 12:10:51 +02:00