Commit graph

903 commits

Author SHA1 Message Date
Thomas Haller
c930b7b4fe platform: silence error reading sysctl for non existing device
https://bugzilla.gnome.org/show_bug.cgi?id=770378
2016-08-25 15:38:28 +02:00
Thomas Haller
6c4447520d platform: disable debug logging for NMPObject ref-couting
These logging lines are already disabled by default as _LOGt()
is a NOP unless configured --with-more-logging.

However, the logging is still very verbose also for debug-builds
and currently there are no known issues there. Disable the logging
statements (but leave them in so they can easily be enabled).

(cherry picked from commit 4cb845558e)
2016-08-22 18:37:04 +02:00
Thomas Haller
ed20625309 platform/tests: relax condition for test
Got a test failure for /link/software/bond

(cherry picked from commit bdd0f722b8)
2016-08-18 15:26:57 +02:00
Thomas Haller
0bdcab100c all: cleanup includes in header files
- don't include "nm-default.h" in header files. Every source file must
  include as first header "nm-default.h", thus our headers get the
  default include already implicitly.

- we don't support compiling NetworkManager itself with a C++ compiler. Remove
  G_BEGIN_DECLS/G_END_DECLS from internal headers. We do however support
  users of libnm to use C++, thus they stay in public headers.

(cherry picked from commit f19aff8909)
2016-08-17 19:51:17 +02:00
Thomas Haller
3d9d91b2be platform: print rx/tx counters in nm_platform_link_to_string() 2016-08-17 16:08:21 +02:00
Thomas Haller
9c5405eba4 platform: drop nm_platform_link_get_stats()
No need to add accessors for fields of NMPlatformLink. Just access
them directly.
2016-08-17 16:08:21 +02:00
Thomas Haller
178bb25a03 platform: let _new_from_nl_link() lookup missing tb[IFLA_STATS64] data from cache 2016-08-17 16:08:21 +02:00
Thomas Haller
b3c376cd29 platform: fix sorting order for nm_platform_link_cmp()
nm_platform_link_cmp() shall first compare the ifindex, otherwise
the sort-order first considers rather unimportant fields instead
of the primary key: the ifindex.

Fixes: a3185f22e55484b819859cb4cef8f54385dac1a9
2016-08-17 16:08:21 +02:00
Thomas Haller
85834a6675 platform/tests: relax condition in platform test
With device-statistics counters in NMPlatformLink we may get an additional
link-changed event. Relax the assertion in the test.
2016-08-17 15:50:20 +02:00
Alfonso Sanchez-Beato
6ed939e841 platform: add network statistics
Make network traffic statistics data available through the platform.
2016-08-17 15:50:20 +02:00
Thomas Haller
663c85a41a bulid: don't link NMFakePlatform into NetworkManager binary
It's only used for testing. Add a new object libNetworkManagerTest.la
that contains libNetworkManager.la including the test stubs.
2016-08-11 11:54:07 +02:00
Beniamino Galvani
45484af2af platform: wifi: drop old wifi data when an interface is renamed
Drop the old wifi data when the interface is renamed, otherwise WEXT
methods would use the old name.

https://bugzilla.gnome.org/show_bug.cgi?id=768433
2016-07-08 13:40:10 +02:00
Thomas Haller
8fcd4798f4 platform/tests: fix link tests
Fixes: 6f31f87871
2016-07-05 23:21:03 +02:00
Thomas Haller
e8518b2a37 device: tune down warning about failure to set userspace IPv6LL on non-existing device
When a device gets removed externally, we still try to clear userspace IPv6LL address handling.
That fails, due to non-existing device. Such a failure should not be logged as warning.

    <debug> [1467723214.2078] device[0x558c59335ca0] (enp0s25): disposing
    <debug> [1467723214.2079] device[0x558c59335ca0] (enp0s25): remove_pending_action (0): 'dhcp6' not pending (expected)
    <debug> [1467723214.2079] device[0x558c59335ca0] (enp0s25): remove_pending_action (0): 'autoconf6' not pending (expected)
    <debug> [1467723214.2079] device[0x558c59335ca0] (enp0s25): will disable userland IPv6LL
    <debug> [1467723214.2079] platform-linux: link: change 20: user-ipv6ll: set IPv6 address generation mode to eui64
    <trace> [1467723214.2080] platform-linux: delayed-action: schedule wait-for-nl-response (seq 92, timeout in 0.199998611)
    <trace> [1467723214.2080] platform-linux: delayed-action: schedule refresh-link (ifindex 20)
    <trace> [1467723214.2080] platform-linux: delayed-action: handle refresh-link (ifindex 20)
    <debug> [1467723214.2080] platform-linux: do-request-link: 20
    <trace> [1467723214.2080] platform-linux: netlink: recvmsg: new message type 2, seq 92
    <debug> [1467723214.2080] platform-linux: netlink: recvmsg: error message from kernel: No such device (19) for request 92
    <trace> [1467723214.2081] platform-linux: delayed-action: complete wait-for-nl-response (seq 92, timeout in 0.199895684, failure 19 (No such device))
    <trace> [1467723214.2081] platform-linux: delayed-action: schedule wait-for-nl-response (seq 93, timeout in 0.199999306)
    <trace> [1467723214.2081] platform-linux: delayed-action: handle wait-for-nl-response (any)
    <trace> [1467723214.2081] platform-linux: netlink: recvmsg: new message type 2, seq 93
    <debug> [1467723214.2081] platform-linux: netlink: recvmsg: error message from kernel: No such device (19) for request 93
    <trace> [1467723214.2082] platform-linux: delayed-action: complete wait-for-nl-response (seq 93, timeout in 0.199921142, failure 19 (No such device))
    <debug> [1467723214.2082] platform-linux: do-change-link[20]: failure changing link: failure 19 (No such device)
    <warn>  [1467723214.2082] device (enp0s25): failed to disable userspace IPv6LL address handling

https://bugzilla.redhat.com/show_bug.cgi?id=1323571
2016-07-05 23:11:57 +02:00
Thomas Haller
f9852821e3 core: don't warn when setting address of non-existing link
Trying to set a property on a device that does not exist is not something
necessarily wrong. Don't print error/warning messages.

    <trace> [1467707267.2887] device[0x55a74adbdaf0] (enp0s25): set-hw-addr: setting MAC address to 'AA:BB:CC:DD:EE:FF' (reset, unmanage)...
    <debug> [1467707267.2887] platform: link: setting '(null)' (2) hardware address
    <debug> [1467707267.2887] platform-linux: link: change 2: address: 68:F7:28:61:68:F7 (6 bytes)
    <debug> [1467707267.2887] platform-linux: do-request-link: 2
    <debug> [1467707267.2888] platform-linux: netlink: recvmsg: error message from kernel: No such device (19) for request 226
    <debug> [1467707267.2888] platform-linux: netlink: recvmsg: error message from kernel: No such device (19) for request 227
    <error> [1467707267.2888] platform-linux: do-change-link[2]: failure changing link: failure 19 (No such device)
    <warn>  [1467707267.2888] device (enp0s25): set-hw-addr: failed to reset MAC address to 68:F7:28:61:68:F7 (unmanage)
2016-07-05 23:08:22 +02:00
Thomas Haller
66715515dc platform: avoid crash after calling nl_recv() for old libnl3 version
nl_recv() in libnl3 before version 3.2.15 would return dangling pointers
if nl_recv() fails or has nothing to read [1].

Workaround that by explicitly clearing @buf and @creds.

https://bugzilla.gnome.org/show_bug.cgi?id=767986

[1] 69468517d0
2016-06-24 19:10:03 +02:00
Dan Williams
16c368b8eb platform: recognize rmnet and ccmni interfaces as WWAN network devices
https://mail.gnome.org/archives/networkmanager-list/2016-June/msg00087.html
2016-06-17 11:08:51 +02:00
Dan Williams
f969193db4 platform/trivial: rename NM_LINK_TYPE_WWAN_ETHERNET to NM_LINK_TYPE_WWAN_NET
Some newer WWAN netdev types are "rawip" which don't bother with
ethernet framing.
2016-06-17 11:00:10 +02:00
Beniamino Galvani
21bdb82555 platform: tests: skip already used macvtap ifindexes
In old kernel versions the creation of a macvtap can fail if its
ifindex is already used by a macvtap in another namespace, because of
a conflict in sysfs entries generation [1].

Try to detect this situation in platform tests and skip an ifindex if
already in use.

[1] http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=17af2bce88d31e65ed73d638bb752d2e13c66ced
2016-06-07 14:44:30 +02:00
Thomas Haller
348e505b3a macros: add macro _nm_printf() for function attribute 2016-06-05 12:22:01 +02:00
Beniamino Galvani
74a0e74d12 platform/tests: fix memory leaks 2016-06-03 22:19:38 +02:00
Lubomir Rintel
60e2a3ea76 platform: add capability to set the tokenized interface identifier
We don't need the token set in platform for our address mode generation,
but having it set makes it possible to correctly generate and assume
connections that use tokens.
2016-05-30 16:32:07 +02:00
Lubomir Rintel
24f428f768 platform: use utility functionality to stringify link 2016-05-30 16:32:06 +02:00
Thomas Haller
e88f5a6c23 platform: remove nm_platform_link_get_ipv6_token()
No need for the extra cache lookup.
2016-05-30 16:32:06 +02:00
Thomas Haller
e5f63f2a50 platform: remove unnecessary NMPlatformLink.inet6_token.is_valid field
The only user of platform who accesses this field is NMDevice,
when calling nm_platform_link_get_ipv6_token(). It cares more
about whether the token is all-zero or set to something.

Another use of inet6_token.is_valid was so that when we receive a
netlink message without IFLA_INET6_TOKEN attribute, that we don't
treat the value as zero, although it is just unknown. Fix that
instead in a better way by setting the value from the cache, if
IFLA_AF_SPEC doesn't provide it.

Also, when printing the token in nm_platform_link_to_string()
treat it as an IPv6 address (inet_ntop).
2016-05-30 16:19:20 +02:00
Lubomir Rintel
76ee40cb58 linux: use the utility functionality to convert the token from platform 2016-05-30 16:14:04 +02:00
Thomas Haller
791cbd0817 platform: handle missing netlink attribute IFLA_ADDRESS by cache-lookup
Sometimes the netlink event lacks the IFLA_ADDRESS attribute with
the MAC address of the link. In this case, take the value from
the cached link instance. A missing netlink attribute should have the
meaning of reusing the previous value, not clearing the address.
2016-05-25 15:11:47 +02:00
Thomas Haller
82f2fbf78d platform: reuse nm_ip_addr_zero for a all-zero ethernet MAC address 2016-05-24 16:01:59 +02:00
Thomas Haller
a4a75b638f platform: refactor comparing for all-zero,all-ones MAC address in nmp_utils_ethtool_get_permanent_address()
Don't like the static fields.

Also, don't assert against return values from the ethtool call.
And check that the length is positive.
2016-05-24 16:01:59 +02:00
Thomas Haller
d71ba919af device: use NM_PLATFORM_GET instead of "nm_platform_get ()"
We use basically everywhere else the NM_PLATFORM_GET macro.
2016-05-22 14:20:05 +02:00
Lubomir Rintel
5f849faa15 platform: fix the typedef-redefinition warnings
The configure script disabled the warning by accident.
2016-05-18 20:53:05 +02:00
Thomas Haller
a2c843499c all/tests: split core part out of "nm-test-utils.h"
A large part of "nm-test-utils.h" is only relevant for tests inside "src/"
directory, as they are helpers related to NetworkManager core part.

Split this part out of "nm-test-utils.h" header.
2016-05-17 16:48:52 +02:00
Thomas Haller
f8fb670c6f platform: declare nmp_utils_ip_config_source_*() functions as const 2016-05-16 13:16:49 +02:00
Thomas Haller
02e84ba1e8 platform: ensure refetching routes when link goes down
It's not enough to consider IF_LOWER_UP flag. Instead,
the important flag is actually IF_UP.

Actually, I suspect that IF_LOWER_UP is not needed. But for
now leave it, in order not to break something.
2016-05-12 14:50:01 +02:00
Thomas Haller
aaa28d4d40 platform: add nm_linux_platform_lookup()
Give a direct access to the cache to lookup values there. This is only
useful for testing.
2016-04-28 12:53:21 +02:00
Thomas Haller
d933164087 platform: change order in which fields are compared in nm_platform_ip4_route_cmp()
..., nm_platform_ip6_route_cmp(), nm_platform_ip4_address_cmp() and
nm_platform_ip6_address_cmp().

Compare those fields first, for which we expect that their properties
differ. E.g. usually, each route destination in a set is unique, thus by
comparing those fields first we shortcut some comparisons.
2016-04-28 12:53:21 +02:00
Thomas Haller
4c2410bc92 platform: extend NMIPConfigSource to preserve the rtm_protocol field
For addresses (NMPlatformIPAddress) the @addr_source field is ignored
on a platform level. That is, all addresses inside the platform cache
have this value set to NM_IP_CONFIG_SOURCE_KERNEL. Maybe, for that reason,
the source should not be a part of the NMPlatformIPAddress structure, but
it is convenient for users to piggy back the source inside the platform
address structure.

For routes, the source is stored in NMPlatformIPRoute's @rt_source
field. When adding a route to kernel, we set the @rtm_protocol of the
route depending on the source. However, we want to map different source
values to the same protocol value.

On the other hand, when kernel sends us a route that gets put inside
the cache, we must preserve the protocol value and must not map
different protocol values to the same source.
The reason is, that a user can add two routes that only differ by
@rtm_protocol. In that sense, the @rtm_protocol fields is part of the
unique ID of a kernel route, and thus different values must map to
different sources.

Fix this, by extending the range of NMIPConfigSource to contain
a range of protocol fields.
2016-04-28 12:53:21 +02:00
Thomas Haller
e26fcce0f8 platform: refactor marking cloned routes in platform
We handle cloned routes (that have rtm_flags RTM_F_CLONED) differently.
We used to mark such routes by hacking NMIPConfigSource to have a special
value. No longer do this, because it mixes different concepts.

Note that the rt_cloned filed fits into a hole in the aligment
of NMPlatformIPRoute. Thus there is almost no overhead to this
change.
2016-04-28 12:53:21 +02:00
Thomas Haller
9e83383223 platform: add nmp_utils_ip_config_source_to_string()
Expose nmp_utils_ip_config_source_to_string() in the header file and
implement it via NM_UTILS_ENUM2STR_DEFINE().
2016-04-28 12:53:21 +02:00
Thomas Haller
6bf022359f core/trivial: rename "source" field of addresses and routes
The "source" field of NMPlatformIPRoute (now "rt_source") maps to the
protocol field of the route. The source of NMPlatformIPAddress (now
"addr_source") has no direct equivalent in the kernel.

As their use is different, they should have different names. Also,
the name "source" is used all over the place. Hence give the fields
a more distinct name.
2016-04-28 12:53:21 +02:00
Thomas Haller
44753a590e platform: sort links by ifindex in nm_platform_link_get_all()
This way, we get a defined order at startup.

Also, get rid of the logging statements. It was used for
debugging, but a "getter" really should not log the stuff it
is returning.
2016-04-28 12:53:21 +02:00
Thomas Haller
5fe99a1d1a core: add nm_utils_ipx_address_clear_host_address() util 2016-04-28 12:53:21 +02:00
Lubomir Rintel
dd4d8b24da linux-platform: re-read the link type if the name changed
For some device types, we use the DEVTYPE from sysfs to determine the
link type. However, the way we read from sysfs can race with device
renames and we could miss the chance to read DEVTYPE correctly.

This doesn't completely fix the sysfs race, but cures the boot-time race
with systemd renaming the device while we are initializing the link.

We ideally should use GUDev for all sysfs accesses, but that would need
some more work for this particular case as currently we need the link type
before we have an udev device instance.

https://bugzilla.gnome.org/show_bug.cgi?id=764803

Co-Authored-By: Beniamino Galvani <bgalvani@redhat.com>
2016-04-26 12:20:42 +02:00
Thomas Haller
a6477fca48 platform: stack-allocate anycast_mask path in _linktype_get_type() 2016-04-21 15:05:34 +02:00
Thomas Haller
e714a20bc2 platform: refactor wifi_utils_is_wifi() not to pass sysfs_path
wifi_utils_is_wifi() only has one caller, so it's very clear
what the passed in @sysfs_path contains. Instead of accepting
a redundant argument, compute the sysfs path internally based
on @iface alone.
2016-04-21 15:05:34 +02:00
Thomas Haller
aa509fd8fe platform: stack-allocate temporary string in _linktype_read_devtype()
And while at it, don't pass the sysfs_path but instead the ifname to it.
2016-04-21 15:02:22 +02:00
Thomas Haller
d52a88a3f8 platform: request link after deleting inifiniband partition
After issuing the sysctl "delete_child", we must request the
link to get the platform cache in sync.
2016-04-20 13:21:05 +02:00
Thomas Haller
b103af0f1e platform: stack allocate string buffers in _infiniband_partition_action() 2016-04-20 12:09:40 +02:00
Thomas Haller
9c323261ea platform: use nm_utils_new_infiniband_name() 2016-04-20 12:09:40 +02:00
Thomas Haller
67d45ea1d3 platform: preserve errno in nm_platform_sysctl_set()
We want to preserve the relevant errno during nm_platform_sysctl_set().
Also, if the final close() fails, fail altogether.
2016-04-20 12:09:40 +02:00