Commit graph

11804 commits

Author SHA1 Message Date
Dan Williams
4b9f506bfd platform: return link objects from add functions
(cherry picked from commit 2abda4bfa5)
2015-06-17 16:19:19 +02:00
Dan Williams
19aa9f1325 core: move virtual interface name handling into device plugins
Instead of having a bunch of logic in the Manager for determining the
VLAN and Infiniband virtual interface names, move the type-specific
logic into the plugins themselves.

(cherry picked from commit 179d56c73c)
2015-06-17 16:19:19 +02:00
Dan Williams
7473a248f4 trivial: move code
(cherry picked from commit 42b272b604)
2015-06-17 16:19:19 +02:00
Dan Williams
c174da8e13 core: let device plugins advertise supported link and setting types
Instead of looping over all plugins and asking each plugin whether it
can handle a link or a connection, have them advertise the link and
connection types they support, and use that when creating new devices.

(cherry picked from commit 71bde20c30)
2015-06-17 16:19:19 +02:00
Dan Williams
998f1cf732 vlan: don't fail if parent isn't found at construct time for existing devices
For existing devices, depending on the order that netlink sends interfaces to
us, the parent may be found after the VLAN interface and not be available when
the VLAN interface is constructed.  Instead of failing construction, when a
NMDeviceVlan has no parent keep it unavailable for activation.  Then have
the Manager notify existing devices when a new device is found, and let
NMDeviceVlan find the parent later and become available via that mechanism.

This doesn't apply to VLANs created by NM itself, because the kernel requires
a parent ifindex when creating a VLAN device.  Thus this fix only applies to
VLANs created outside NetworkManager, or existing when NM starts up.

(cherry picked from commit cd3df12c8f)
2015-06-17 16:11:56 +02:00
Dan Williams
826d69cbe2 trivial: move code
(cherry picked from commit 477cbc848a)
2015-06-17 16:11:55 +02:00
Dan Williams
41c92739bd platform: recognize Bluetooth BNEP devices via DEVTYPE
Instead of strcmp()-ing the device name, recognize these devices from their
driver's DEVTYPE.

(cherry picked from commit baee9080b7)
2015-06-17 16:11:55 +02:00
Dan Williams
cf044faf13 settings: ignore incompatible connections when looking for existing ones
beb18050 made this code run for all devices instead of just ethernet
devices, which means any kind of connection gets compared to any
device.  But only compatible connections should be considered.

(cherry picked from commit 77d01c9094)
2015-06-17 16:11:55 +02:00
Dan Williams
23d285f308 core: don't activate failed queued activation requests
If the queued activation request failed before the device is
finished deactiving the old request, don't start activating
the failed queued request.

(cherry picked from commit fb1d04099f)
2015-06-17 16:11:55 +02:00
Dan Williams
ac8d1f1caa api: add missing device state reason for NewActivation
Fixes: 1ad193a017
Fixes: 994136e142
(cherry picked from commit e165463964)
2015-06-17 16:10:57 +02:00
Thomas Haller
5efa7b012b platform: re-enable the platform link test
The link test was disabled in commit 67ad3fcb5b.

The previous issues are not fixed, but apparently disabling the test doesn't
help to get it fixed.

Re-enable it and if it fails we have a better reason to fix it.
Or maybe it works now (?). Didn't fail for me...

(cherry picked from commit f614ebe6f5)
2015-06-17 15:38:05 +02:00
Thomas Haller
ac99f69809 platform: keep udev-device in udev_device_added() even if there is no netlink object
Throwing away the udev_device instance is wrong. There are two cases:

- the udev-device appears, and the netlink object will never appear
  (or is already gone). In this case, keeping the udev-device is ok
  because we will eventually get a signal from UDev to cleanup the
  device instance.

- the udev-device appears before the netlink object. In this case we
  want to keep the udev instance to have it ready.

Fixes: 388b7830f3
(cherry picked from commit 7572837375)
2015-06-17 15:38:05 +02:00
Thomas Haller
6c67406b41 test/trivial: use new EXIT_SKIP return value instead of 77
(cherry picked from commit 575d8186e4)
2015-06-17 15:38:04 +02:00
Dan Williams
752f55d80b merge: don't wait for udev before announcing links; other cleanups (bgo #747628) (bgo #743209)
(cherry picked from commit 4f05261af8)
2015-06-17 15:29:33 +02:00
Thomas Haller
7b6ffb1e5f platform: intern driver string for NMPlatformLink
Always intern string from udev_get_driver().

We use the result of udev_get_driver() for setting NMPlatformLink.driver.
In all other cases, we already set that value to an interned string,
which simplifies memory handling.

As it was, the lifetime of that string was tied to the lifetime of the
GUdevDevice.

This is not a stelar solution, but we assume that the overall numbers
of different drivers is limited so we don't leak large amounts of
memory.

(cherry picked from commit 3171b543dc)
2015-06-17 15:28:01 +02:00
Thomas Haller
efec4b42e2 platform: refactor extraction of type-name for link
link_extract_type() would return the NMLinkType and a
@type_name string. If the type was unknown, this string
was rtnl_link_get_type() (IFLA_INFO_KIND).

Split up this behavior and treat those values independently.
link_extract_type() now only detects the NMLinkType. Most users
don't care about unknown types and can just use nm_link_type_to_string()
to get a string represenation.

Only nm_platform_link_get_type_name() (and NMDeviceGeneric:type_description)
cared about a more descriptive type. For that, modify link_get_type_name()
to return nm_link_type_to_string() if NMLinkType could be detected.
As fallback, return rtnl_link_get_type().

Also, rename the field NMPlatformLink:link_type to "kind". For now this
field is mostly unused. It will be used later when refactoring platform
caching.

(cherry picked from commit e2c742c77b)
2015-06-17 15:28:01 +02:00
Thomas Haller
3d1ab669e3 platform: expose nm_link_type_to_string() function
Given the name nm_link_type_to_string(), we would not expect
to find it in nm-linux-platform.c. It either should be named
nm_platform_link_type_to_string() and be put in a new
nm-platform-utils.c file, or it should be named
nm_utils_link_type_to_string() and be put in NetworkManagerUtils.h.

For now, just leave it here.

(cherry picked from commit b538adf123)
2015-06-17 15:28:01 +02:00
Thomas Haller
bae47558ba platform: detect TUN/TAP device in link_extract_type() independently of platform cache
link_extract_type() would call tun_get_properties() to determine whether
the link if a TAP or TUN device. The previous implementation would
receive the ifindex, and resolve the ifname via lookup in the platform
cache.
This means, the call on link_extract_type() will only succeed to detect
the TUN/TAP properties, if the libnl object is already in the cache.
Currently that is always the case and there is no problem.

It is desireable, that we can resolve the link type of an object without
consulting the platform cache first.

(cherry picked from commit 18d611d5d2)
2015-06-17 15:28:01 +02:00
Thomas Haller
b4a88db19e core: remove G_GNUC_WARN_UNUSED_RESULT from ASSERT_VALID_PATH_COMPONENT()
ASSERT_VALID_PATH_COMPONENT() always returns the input argument --
unless it fails an assertion and terminates the program. No need
to require the user to use the return value.

(cherry picked from commit 63bb33b534)
2015-06-17 15:28:01 +02:00
Dan Williams
251193490a core: change activation failure messages to debug level
Otherwise any user with network control privileges can spam the logs.

(cherry picked from commit 8a5910c25c)
2015-06-17 15:28:01 +02:00
Dan Williams
19cdd7d9a1 platform: rework link type detection for better fallback (bgo #743209)
See "Revert "wireless: Support of IFLA_INFO_KIND rtnl attribute""
http://www.spinics.net/lists/linux-wireless/msg132219.html

The reverted kernel patch caused rtnl_link_get_type() to return "wlan"
for WiFi devices.  Since NM depends on this function returning
NULL for WiFi devices so that it goes on to check the sysfs DEVTYPE
attribute, the kernel patch caused WiFi devices to show up as Generic
ones instead.  That's wrong, and NM should be able to more easily
handle changes in the kernel drivers from NULL to a more descriptive
rtnl_link_get_type() return, since that's the kernel trend.

What NM should be doing here is to fall back to other detection
schemes if the type is NULL or unrecognized. Make that happen and
clean things up to use a table instead of a giant if(strcmp()) block.

https://bugzilla.gnome.org/show_bug.cgi?id=743209
(cherry picked from commit 2d527b30ff)
2015-06-17 15:28:01 +02:00
Dan Williams
0ab54aeb47 platform: refactor link-type to string conversion
(cherry picked from commit b484b03acf)
2015-06-17 15:28:01 +02:00
Thomas Haller
7c4a657efa platform: fix root-tests after adding link detection without udev
Co-Authored-By: Lubomir Rintel <lkundrak@v3.sk>

Fixes: 388b7830f3
Fixes: 285ee1fda2
(cherry picked from commit b22bf15c1d)
2015-06-17 15:27:52 +02:00
Dan Williams
285ee1fda2 platform: don't wait for udev before announcing links
(cherry picked from commit 388b7830f3)
2015-06-17 14:54:02 +02:00
Dan Williams
fab106c912 core: add generic NMDevice function to recheck availability
And use it everywhere.

(cherry picked from commit 3006df940c)
2015-06-17 14:54:02 +02:00
Dan Williams
e43bd9228c platform: don't use udev for link type determination
This allows us to always announce links when the kernel advertises
them, instead of waiting for udev.

(cherry picked from commit 2599dadc28)
2015-06-17 14:54:02 +02:00
Thomas Haller
093b29a618 logging: define _LOGT() macro to check valid arguments
With NM_MORE_LOGGING disabled, we still want the compiler to evaluate
the argument list. By wrapping it in "if(FALSE)", we get compile time
checks, but the logging statement will be optimized out.

(cherry picked from commit cb6bafb9af)
2015-06-17 14:45:46 +02:00
Thomas Haller
72c0379708 build/trivial: reorder and break lines in Makefile.am
(cherry picked from commit 245720819e)
2015-06-17 14:45:46 +02:00
Thomas Haller
dbf8bb85b8 platform: merge branch 'th/platform-div-bgo748131'
https://bugzilla.gnome.org/show_bug.cgi?id=748131

(cherry picked from commit 2316d233e3)
2015-06-17 14:40:02 +02:00
Thomas Haller
594b8e829d platform: add NM_PLATFORM_SIGNAL_NONE enum value
(cherry picked from commit ea5865cf45)
2015-06-17 14:39:35 +02:00
Thomas Haller
0a8511582d platform: refactor detection of support_user_ipv6ll
Move detection of @support_user_ipv6ll to a separate function
_support_user_ipv6ll_detect() and call it immediately after the
places where we receive libnl objects from kernel, i.e.
get_kernel_object(), event_notification(), and cache_repopulate_all().

Also, whether we have support depends on the kernel and is per-system,
not per-platform-instance. Make @_support_user_ipv6ll a global variable.
This way, we don't need to pass around a NMLinuxPlatform instance.

(cherry picked from commit f15a27f9c1)
2015-06-17 14:39:35 +02:00
Thomas Haller
a989eadec0 platform: don't assert against success of nl_msg_parse()
(cherry picked from commit a319aea9f4)
2015-06-17 14:39:35 +02:00
Thomas Haller
fa666781e5 platform: use new _LOG() logging macros in nm-linux-platform.c
(cherry picked from commit 0c03db4e8e)
2015-06-17 14:39:35 +02:00
Thomas Haller
3ded80d143 platform: add _LOG() logging macros to linux platform
(cherry picked from commit 7db9306aa3)
2015-06-17 14:39:35 +02:00
Thomas Haller
2f4db91fcc platform: add nm_platform_try_get() function
(cherry picked from commit 90caa93582)
2015-06-17 14:39:35 +02:00
Thomas Haller
e43baa1481 platform: drop nm_platform_free() and register weak-ref
Instead of having a nm_platform_free() function, use NM_DEFINE_SINGLETON_WEAK_REF()
and register a weak reference. That way, users who want to free the platform
instance can just unref it.

(cherry picked from commit 04ed48e5a0)
2015-06-17 14:39:34 +02:00
Thomas Haller
3a437a8e55 platform: drop virtual setup() initalization function
We already have nm_*_platform_setup() that gets specified
via -DSETUP. This SETUP() hook gives us all the flexiblity
we need to customize our singleton, so just do any required
setup there.

Also, it would be easier to add an alternative (hypotetical)
nm_fake_platform_setup_custom() to customize the singleton then to
parametrize the NMPlatform:setup() implementation. So this virtual
function is less flexible and redundant.

(cherry picked from commit fe2608c903)
2015-06-17 14:39:34 +02:00
Thomas Haller
c61901d24c platform: pass singleton instance to nm_platform_setup()
We have two hooks to modify setup of the platform singleton:
nm_linux_platform_setup() and the virtual setup() function.

On the other hand, nm_platform_setup() limits us by accepting
only a GType, instead of a prepeared platform instance.
Make the nm_platform_setup() method more flexible, so that we can
later drop the setup() hook.

(cherry picked from commit a50d77d952)
2015-06-17 14:37:32 +02:00
Thomas Haller
2cbcb6df51 platform: initialize NMLinuxPlatform in constructed() method
setup() can be used to initialize a NMPlatform instance that is
registered as singleton via nm_platform_setup(). It should not
be used to initialize the object.

Prior to c6529a9d74, this change was
not possible because constructed() will call back into nm_platform_*()
functions, without having the singleton instance setup.

(cherry picked from commit dc9b25f161)
2015-06-17 14:37:32 +02:00
Thomas Haller
b3cbb768a3 platform: merge several platform backports from master into nm-1-0
Backport these patches to have everything in platform up to a
certain point of master.
2015-06-17 14:36:10 +02:00
Thomas Haller
704e9dbdc2 platform: pass @platform instance to build_rtnl_addr()
(cherry picked from commit bdb2f94519)
2015-06-17 14:32:30 +02:00
Thomas Haller
3a30ccacc7 platform: add self argument to platform functions
Most nm_platform_*() functions operate on the platform
singleton nm_platform_get(). That made sense because the
NMPlatform instance was mainly to hook fake platform for
testing.

While the implicit argument saved some typing, I think explicit is
better. Especially, because NMPlatform could become a more usable
object then just a hook for testing.

With this change, NMPlatform instances can be used individually, not
only as a singleton instance.

Before this change, the constructor of NMLinuxPlatform could not
call any nm_platform_*() functions because the singleton was not
yet initialized. We could only instantiate an incomplete instance,
register it via nm_platform_setup(), and then complete initialization
via singleton->setup().
With this change, we can create and fully initialize NMPlatform instances
before/without setting them up them as singleton.

Also, currently there is no clear distinction between functions
that operate on the NMPlatform instance, and functions that can
be used stand-alone (e.g. nm_platform_ip4_address_to_string()).
The latter can not be mocked for testing. With this change, the
distinction becomes obvious. That is also useful because it becomes
clearer which functions make use of the platform cache and which not.

Inside nm-linux-platform.c, continue the pattern that the
self instance is named @platform. That makes sense because
its type is NMPlatform, and not NMLinuxPlatform what we
would expect from a paramter named @self.

This is a major diff that causes some pain when rebasing. Try
to rebase to the parent commit of this commit as a first step.
Then rebase on top of this commit using merge-strategy "ours".

(cherry picked from commit c6529a9d74)
2015-06-17 14:32:30 +02:00
Dan Williams
fd40f223bf platform: prevent warning when udev is clueless about a device
udev doesn't know about the device yet when NM creates it internally.

NetworkManager[9275]: <info>  (team0): carrier is OFF
NetworkManager[9275]: <info>  (team0): new Team device (driver: 'team' ifindex: 16)
(NetworkManager:9275): GUdev-CRITICAL **: g_udev_device_get_property: assertion 'G_UDEV_IS_DEVICE (device)' failed
NetworkManager[9275]: <info>  (team0): exported as /org/freedesktop/NetworkManager/Devices/5

(cherry picked from commit 8173f0f9e8)
2015-06-17 13:50:36 +02:00
Thomas Haller
130252f55e platform/trivial: move ethtool code
(cherry picked from commit 2bb44d91d8)
2015-06-17 13:50:36 +02:00
Thomas Haller
710a34c12a platform/trivial: move udev_detect_link_type_from_device()
(cherry picked from commit dffb18cb34)
2015-06-17 13:50:36 +02:00
Thomas Haller
bd7209b04a platform: split link_type_from_udev()
Also change link_extract_type() to accept NULL as @platform
argument.

(cherry picked from commit 34d82d0df1)
2015-06-17 13:50:36 +02:00
Thomas Haller
f5569eb961 platform/trivial: move udev code closer to beginning of nm-linux-platform.c
(cherry picked from commit d695776d48)
2015-06-17 13:50:36 +02:00
Thomas Haller
f59cda06ce platform/trivial: remove unused argument from udev_get_driver()
(cherry picked from commit 7354dc4c58)
2015-06-17 13:50:36 +02:00
Thomas Haller
fd61283fb0 platform/trivial: rename object_type_from_nl_object() to _nlo_get_object_type()
The function names in linux-platform should get better prefixes
indicating whether they are related to libnl or nm objects.

Add a prefix _nlo_ for functions that operate on libnl objects.

(cherry picked from commit 7c5d361c66)
2015-06-17 13:50:36 +02:00
Thomas Haller
fc499ffd14 platform/trivial: move code around so that libnl related stuff is together
Reorder some functions in nm-platform, so that we first have independent
libnl wrappers/utils, then NMPlatform type definition, and then the
rest.

(cherry picked from commit 850af91f22)
2015-06-17 13:50:36 +02:00