Commit graph

5970 commits

Author SHA1 Message Date
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
Thomas Haller
ddfa354400 device: add nm_device_get_type_description() function
Add a function to get a concise representation of the
device type.

libnm already has nm_device_get_type_description() for that
and it is shown by

  nmcli -f GENERAL.TYPE device show

Reimplement that function for nm-core. Just take care that the
two implementations don't diverge.

(cherry picked from commit e9e9d44468)
2015-06-19 12:10:51 +02:00
Thomas Haller
517e9fa0f0 ibft: avoid logging multiple lines when ibft fails
In case of error, ibft prints an error message to stderr
with two trailing newlines. This causes multiple lines
in our logfile. Replace newlines in the error message
by whitespaces.

(cherry picked from commit 205c109741)
2015-06-19 12:05:50 +02:00
Thomas Haller
060f7a463e build: add compile option to disable building of Wi-Fi plugin
Before, the Wi-Fi plugin was always build. Users who didn't want
to use it would simply drop "libnm-device-plugin-wifi.so".

Add a compile time option to disable needlessly building the plugin.

https://bugzilla.gnome.org/show_bug.cgi?id=743388
(cherry picked from commit 5439fbd77c)
2015-06-19 12:05:50 +02:00
Lubomir Rintel
0f95b5c345 builds: only enable TAP driver for glib >= 2.37.6
No TAP support for previous versions and --tap argument is silently ignored,
confusing the TAP driver.

(cherry picked from commit c47c06470a)
2015-06-19 11:52:50 +02:00
Lubomir Rintel
fe3e32c034 tests: use the TAP formatter
The test results in standard format are easily integrated into CI systems.

(cherry picked from commit 6463ce5dd9)
2015-06-19 11:52:50 +02:00
Lubomir Rintel
30d37abbc0 tests: call g_test_run() even when skipping the test
It will return the 77 exit code itself. For TAP output it will also generate
the proper test skip marker.

(cherry picked from commit 14f4674f64)
2015-06-19 11:52:50 +02:00
Lubomir Rintel
62172a9a9e tests: move all asserts into tests
Otherwise the TAP formatter would produce a plan-less output.

(cherry picked from commit f627d6db8e)
2015-06-19 11:52:49 +02:00
Thomas Haller
274be6cf88 supplicant: remove unused variable
(cherry picked from commit 02130cc157)
2015-06-19 11:51:25 +02:00
Dan Williams
9db6d6ad42 supplicant: remove unused nm-call-store.c/.h
(cherry picked from commit 9adbc05e1b)
2015-06-19 11:51:25 +02:00
Dan Williams
0de28bd08b supplicant: convert interface/config to GDBus
(cherry picked from commit 59c8192b22)
2015-06-19 11:51:25 +02:00
Dan Williams
7ea33e5c92 supplicant: clean up some whitespace
(cherry picked from commit 47fe1b3196)
2015-06-19 11:51:25 +02:00
Dan Williams
7b9cc94e66 supplicant: make NMSupplicantInterface independent of NMSupplicantManager
The Interface held a reference to the manager to listen for the 'available'
signal.  Instead of that, let's make the child unaware of the master to
keep the inheritance cleaner.

(cherry picked from commit 7ed2d7a809)
2015-06-19 11:51:25 +02:00
Dan Williams
42870c8ee5 supplicant: clean up NMSupplicantInterface::dispose()
(cherry picked from commit 0e8f5b2e57)
2015-06-19 11:51:25 +02:00
Dan Williams
669b8f70bb supplicant: convert NMSupplicantManager to GDBus
(cherry picked from commit 9f5f141100)
2015-06-19 11:51:24 +02:00
Dan Williams
fae1a4f864 supplicant: clean up NMSupplicantManager::dispose()
(cherry picked from commit 742b28fb1f)
2015-06-19 11:51:24 +02:00
Lubomir Rintel
8cffaf3bf5 vxlan: o.fd.NM.Device.Proxy is a boolean
(cherry picked from commit 203e48033b)
2015-06-18 22:27:41 +02:00
Lubomir Rintel
55e402e5ac manager: use proper reason when stealing a connection
The user-requested reason is not really appropriate and blocks autoreconnect.
We added a new reason precisely for that.

Fixes: 4cb97cf66f
(cherry picked from commit 2bfbf33720)
2015-06-18 21:45:52 +02:00
Lubomir Rintel
7f84150e9f 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

(cherry picked from commit 3811a68389)
2015-06-18 13:23:56 +02:00
Lubomir Rintel
9e6a02d7a1 build: use compat version of g_clear_pointer()
Ubuntu 12.04 has an ancient version of glib, which we nevertheless support.

(cherry picked from commit eb2b8c2798)
2015-06-18 12:11:37 +02:00
Dan Williams
eb396b8fb6 core: rearrange some VLAN code and clean up dispose()
Move parent-related stuff before its callers and clean up dispose
so that we no longer need priv->disposed.

(cherry picked from commit 2a7a19e767)
2015-06-17 18:52:43 +02:00
Dan Williams
b5f5aa0960 platform: move InfiniBand property reading into the platform and prefer netlink
Add a netlink implementation for reading InfiniBand properties, but fall back to
sysfs when that isn't supported by the kernel.

(cherry picked from commit 5cf226463a)
2015-06-17 18:52:43 +02:00
Dan Williams
2236cc5eb8 core: earlier software capability detection
We need to know whether we can create interfaces of any given
NMDevice subclass or not.  So don't rely on just the NMPlatformLink
for that information, because we won't have a platform link for
software devices before we create them.

(cherry picked from commit d4e0a1e8cc)
2015-06-17 18:52:42 +02:00
Dan Williams
dee7f89b62 core: check duplicate devices by interface name not UDI
We can't have devices with duplicate interface names so we might
as well use that for dupe checking instead of the (mostly useless)
UDI.

(cherry picked from commit 81db512997)
2015-06-17 18:52:42 +02:00
Thomas Haller
a81830c766 platform/test: fix valgrind warning about NULL arguments to mount()
==21573== Syscall param mount(type) points to unaddressable byte(s)
    ==21573==    at 0x854B9BA: mount (syscall-template.S:81)
    ==21573==    by 0x158922: main (test-common.c:295)
    ==21573==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
    ==21573==
    {
       <insert_a_suppression_name_here>
       Memcheck:Param
       mount(type)
       fun:mount
       fun:main
    }

Fixes: d6aef9c188
(cherry picked from commit 0d7012faab)
2015-06-17 18:47:45 +02:00
Lubomir Rintel
faf46ad316 linux-platforms: don't enumerate devices via udev if udevd is not running
We'd be able to do so for already existing devices, but not for devices that
are added afterwards, since gudev is hardwired not to listen for events from
kernel.

(cherry picked from commit 26aeb12749)
2015-06-17 18:47:45 +02:00
Lubomir Rintel
2ba6845a6e platform/test: unshare the netns namespace so that root tests don't mess with the system
Mount a private sysfs instance. Otherwise gudev sees the devices from the
parent netns as opposed to our netns.

We do, however need a writable /sys/devices subtree for testing the bridge
code. There doesn't seem to be any other way to get a writable subtree of a
read-only filesystem than remounting it with no parameters after the initial
mount. We use this to get a writable sysfs instance and then bindmount it so
that it fits properly in the sysfs hierarchy.

Co-Authored-By: Thomas Haller <thaller@redhat.com>
(cherry picked from commit d6aef9c188)
2015-06-17 18:47:45 +02:00