Commit graph

934 commits

Author SHA1 Message Date
Thomas Haller
ed82b6bcb3 platform: increase initial buffer size of libnl's nl_recvmsg() to 32K
Since commit 9fafb382db, we would
explicitly set libnl's socket buffer size to 4*getpagesize().
That is also the default of libnl itself. Additionally, we would
workaround too small buffers by increasing the buffer size up to 512K.

A too small buffer causes messages to be lost. Usually, that only
results in a cache-resync, which isn't too bad. Lost messages are however
a problem if the lost message was an ACK that we were waiting for.
However, it is rather unlikely to happen, because it's expected that
the buffer size gets adjusted already when the cache is filled initially,
before any other requests are pending.

Still, let's increase the default buffer size to 32K, hoping that this
initial value is already large enough to avoid the problem altogether.

Note that iproute2 also uses a buffer size of 32K [1] [2].

Alternatively, we could use MSG_PEEK like systemd does [3]. However,
that requires two syscalls per message.

[1] https://patchwork.ozlabs.org/patch/592178/
[2] https://git.kernel.org/cgit/linux/kernel/git/shemminger/iproute2.git/tree/lib/libnetlink.c?id=f5f760b81250630da23a4021c30e802695be79d2#n274
[3] cd66af2274/src/libsystemd/sd-netlink/netlink-socket.c (L323)
2016-12-02 15:23:11 +01:00
Thomas Haller
ce2d1f062b platform: don't use static temporary cache_id
This only saves some typing at a few places. In general, avoid
static variables, so drop it in favor of a stack-allocated
cache_id.
2016-12-01 10:57:35 +01:00
Thomas Haller
9fafb382db platform: workaround NLE_MSG_TRUNC failure of nl_recv() with too small buffer size
We don't want to enable MSG_PEEK due to the overhead. But when we detect
that we just lost a message due to MSG_TRUNC, increase the buffer size and
retry.

See-also: 55ea6e6b6c
2016-11-30 17:01:35 +01:00
Thomas Haller
d5a743a619 core: merge NM_PLATFORM_LINK_DUPLEX_UNSET and UNKNOWN
They have basically the same use, except that certain places handled
one but not the other.
2016-11-22 15:24:47 +01:00
Francesco Giudici
ab0954b0e5 platform: add APIs to allow link negotiation management
Added platform functions to retrieve device link mode status and to
switch from auto to manual link negotiation:
nm_platform_ethtool_get_link_settings
nm_platform_ethtool_set_link_settings
2016-11-22 15:24:47 +01:00
Thomas Haller
44ecb41593 build: don't add subdirectories to include search path but require qualified include
Keep the include paths clean and separate. We use directories to group source
files together. That makes sense (I guess), but then we should use this
grouping also when including files. Thus require to #include files with their
path relative to "src/".

Also, we build various artifacts from the "src/" tree. Instead of having
individual CFLAGS for each artifact in Makefile.am, the CFLAGS should be
unified. Previously, the CFLAGS for each artifact differ and are inconsistent
in which paths they add to the search path. Fix the inconsistency by just
don't add the paths at all.
2016-11-21 14:26:37 +01:00
Lubomir Rintel
44fca246a7 rdisc: rename to ndisc
We'll soon not only do the router discovery, but announce ourselves as a
reouter. "Neighbor discovery" sounds to be a more appropriate name for
the class than "Router discovery".
2016-11-09 17:16:47 +01:00
Lubomir Rintel
b49c194f84 linux: don't assume short write when the kernel ignores the trailing whitespace
Certain sysctls don't appreciate the final newline. That's completely
fine.

  17941 open("/proc/sys/net/ipv6/conf/eth2/forwarding", O_WRONLY|O_TRUNC) = 21
  17941 write(21, "1\n", 2)               = 1
2016-11-09 15:06:20 +01:00
Thomas Haller
6df24ee8cc platform/tests: relax assertion for expected link-changed signal 2016-10-24 15:15:15 +02:00
Thomas Haller
002f17c25d src: drop generated nm-src-enum-types.h
We only needed proper glib enum types for having properties
and signal arguments. These got all converted to plain int,
so no longer generate such an enum type.
2016-10-22 17:16:17 +02:00
Thomas Haller
3bbc55fd9c core: don't use generated glib enum for platform types 2016-10-22 17:16:17 +02:00
Thomas Haller
04eb0afd28 build: merge "src/platform/tests/Makefile.am" into toplevel Makefile 2016-10-21 17:04:06 +02:00
Thomas Haller
b219eb19f1 build: merge "src/Makefile.am" into toplevel Makefile
Had to rename "nm-enum-types.h" because it works badly with
"libnm/nm-enum-types.h". Maybe I could fix that differently,
but duplicate names is anyway error prone.

Note that "nm-core-enum-types.h" is already taken too, so
"nm-src-enum-types.h" it is.
2016-10-19 17:16:08 +02:00
Thomas Haller
274de2555b build/trivial: rename VALGRIND_RULES in Makefile.am to NM_LOG_COMPILER 2016-10-19 15:26:30 +02:00
Thomas Haller
068dd41df9 platform/tests: relax assertion in software_add
Avoid failure

    NMPlatformSignalAssert: test-link.c:146, software_add(): failure to accept signal one time: link-changed-changed ifindex 15 (2 times received)
2016-10-19 15:23:49 +02:00
Beniamino Galvani
956f0be2f9 platform: fix lifetime check 2016-10-18 16:48:27 +02:00
Lubomir Rintel
2c43862b2d platform/tests: don't attempt to mount anything to /sys/devices
More recent kernels won't allow that in userns when /sys itself
is read-only.
2016-10-17 15:45:59 +02:00
Lubomir Rintel
0acdcc348c Revert "platform/tests: skip root tests when we can't mount /sys/devices"
This was plain stupid. We don't care about sysfs being writable or
anything *before* entering the namespace.

This reverts commit 15a26d6192.
2016-10-17 15:45:59 +02:00
Beniamino Galvani
89bcf50f61 platform: avoid unaligned access to link stats on 64bit architectures
The undefined behavior sanitizer complains with:

platform/nm-linux-platform.c:1482:31: runtime error: member access within misaligned address 0x61a000016fac for type 'struct rtnl_link_stats64', which requires 8 byte alignment
0x61a000016fac: note: pointer points here
  bc 00 17 00 bf 05 00 00  00 00 00 00 bf 05 00 00  00 00 00 00 b5 68 02 00  00 00 00 00 b5 68 02 00
              ^
platform/nm-linux-platform.c:1483:29: runtime error: member access within misaligned address 0x61a000016fac for type 'struct rtnl_link_stats64', which requires 8 byte alignment
0x61a000016fac: note: pointer points here
  bc 00 17 00 bf 05 00 00  00 00 00 00 bf 05 00 00  00 00 00 00 b5 68 02 00  00 00 00 00 b5 68 02 00
              ^
platform/nm-linux-platform.c:1484:31: runtime error: member access within misaligned address 0x61a000016fac for type 'struct rtnl_link_stats64', which requires 8 byte alignment
0x61a000016fac: note: pointer points here
  bc 00 17 00 bf 05 00 00  00 00 00 00 bf 05 00 00  00 00 00 00 b5 68 02 00  00 00 00 00 b5 68 02 00
              ^
platform/nm-linux-platform.c:1485:29: runtime error: member access within misaligned address 0x61a000016fac for type 'struct rtnl_link_stats64', which requires 8 byte alignment
0x61a000016fac: note: pointer points here
  bc 00 17 00 bf 05 00 00  00 00 00 00 bf 05 00 00  00 00 00 00 b5 68 02 00  00 00 00 00 b5 68 02 00
              ^

That's because the pointer returned by nla_data() is only
32bit-aligned and using it to access structure members can cause
issues on some 64bit architectures.

Use the unaligned_read_ne64() macro to access the structure members.

https://bugzilla.gnome.org/show_bug.cgi?id=772605
2016-10-14 11:16:13 +02:00
Thomas Haller
64951f07fb logging: remove LOGD_HW alias for LOGD_PLATFORM
Since commit 1495853e01, LOGD_HW is renamed to
LOGD_PLATFORM. Remove the internal usage of the deprecated name.
2016-10-11 11:29:52 +02:00
Lubomir Rintel
15a26d6192 platform/tests: skip root tests when we can't mount /sys/devices 2016-10-11 10:36:15 +02:00
Thomas Haller
3ceaef90fe core: remove unnecessary includes to netlink/route library
We no longer use libnl-route-3 library in NetworkManager. Remove the
unnecessary includes.
2016-10-07 21:37:17 +02:00
Thomas Haller
4d37f7a1e9 core: refactor private data in "src"
- use _NM_GET_PRIVATE() and _NM_GET_PRIVATE_PTR() everywhere.

- reorder statements, to have GObject related functions (init, dispose,
  constructed) at the bottom of each file and in a consistent order w.r.t.
  each other.

- unify whitespaces in signal and properties declarations.

- use NM_GOBJECT_PROPERTIES_DEFINE() and _notify()

- drop unused signal slots in class structures

- drop unused header files for device factories
2016-10-04 09:50:56 +02:00
Thomas Haller
0aa3a6dbfb core: refactor private data for NMExportedObject and others 2016-10-03 12:04:14 +02:00
Thomas Haller
a83eb773ce all: modify line separator comments to be 80 chars wide
sed 's#^/\*\{5\}\*\+/$#/*****************************************************************************/#' $(git grep -l '\*\{5\}' | grep '\.[hc]$') -i
2016-10-03 12:01:15 +02:00
Thomas Haller
08f5681b0e core: const arguments for _nm_utils_ptrarray_find_*() functions 2016-09-23 15:34:17 +02:00
Thomas Haller
145d199589 platform: fix return value for error case in do_change_link_request()
There is a "goto retry" in do_change_link_request(), at that point,
seq_result has the value -EOPNOTSUPP, instead of
WAIT_FOR_NL_RESPONSE_RESULT_UNKNOWN.

Fixes: 02fb3eff48
2016-08-30 16:22:42 +02:00
Lubomir Rintel
02fb3eff48 platform: fix build
Fixes: 471521ca84
2016-08-30 15:05:41 +02:00
Thomas Haller
2bef71611b platform: workaround kernel wrongly returning ENFILE when changing MAC address
https://bugzilla.gnome.org/show_bug.cgi?id=770456
2016-08-29 11:36:01 +02:00
Thomas Haller
3dc0944677 platform: split processing result from do_change_link() 2016-08-29 11:30:50 +02:00
Thomas Haller
895c61a742 platform/tests: avoid test failure setting bridge forward_delay
Seems odd numbers may be coerced to the next-smaller even number.
Avoid that by using an even number for the test, as the number
has no particular meaning.

https://bugzilla.gnome.org/show_bug.cgi?id=765835
2016-08-28 17:59:42 +02:00
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