Commit graph

1722 commits

Author SHA1 Message Date
Thomas Haller
80c0de7217
platform: workaround for old kernels that don't support IFLA_BR_VLAN_STATS_ENABLED
The kernel of Ubuntu 16.04 doesn't support IFLA_BR_VLAN_STATS_ENABLED.
If we want to run on such old kernels (which we probably do), we need to
detect that, and act accordingly.
2020-08-21 13:59:50 +02:00
Thomas Haller
1407d29b5e
platform/tests: add nmtstp_kernel_support_get() 2020-08-21 13:59:49 +02:00
Thomas Haller
195b406ac0
platform: extend nm_platform_kernel_support_get() and use atomic operations to access result
Add nm_platform_kernel_support_get_full() to allow fetching the support
state without setting it to the compile time default.

Also, use g_atomic_int_get() to access _nm_platform_kernel_support_state
values. We should not access static variables without synchronization.
Better get it correct in any case than fast.
2020-08-21 13:59:48 +02:00
Thomas Haller
e59259b3d5
platform/tests: remove unused argument "out_not_supported" from nmtstp_link_bridge_add() 2020-08-21 13:59:48 +02:00
Thomas Haller
9a5e8f1ea6
platform: use defines from libnm-core for setting defaults values for nm_platform_lnk_bridge_default 2020-08-21 13:59:47 +02:00
Thomas Haller
fdef0e8c62
platform: fix default for bridge setting "mcast_snooping"
The value defaults to TRUE. Also, use the #define for it.

Fixes: 58847f85a4 ('platform: use netlink for configuring bridge settings'):
2020-08-21 13:59:40 +02:00
Sayed Shah
58847f85a4 platform: use netlink for configuring bridge settings
NMDeviceBridge is currently using sysfs. The plan is to use netlink in
in the future
2020-08-20 14:03:10 -04:00
Thomas Haller
d2c58bc64d
platform: set default values for NMPlatformLnkBridge if unspecified on netlink
Older kernels may not support or send all bridge options in the netlink
message. In case the parameter is missing, set the default value.

Note that there may be future cases where we need to encode whether
the option is present or not. Currently we don't express that.
2020-08-17 11:07:43 +02:00
Thomas Haller
e9278d8659
platform/tests: ignore failure for adding bridge with iproute2
Older versions of iproute2 (Ubuntu 16.04) don't support all the requested
bridge options. We need to gracefully ignore a failure and try with our
own implementation.

While doing that, only set the command line arguments if they are
necessary (that is, if they requested value is not the default already).

Luckily, Ubuntu 16.04's kernel supports these properties just fine, so
we can avoid complicated compatibility code to cope with missing kernel
support. It's really just an iproute2 limitation and affects only the
tests.
2020-08-17 11:07:43 +02:00
Thomas Haller
0b81ea50fe
platform: add NMP_OBJECT_CAST_LNK_BRIDGE() helper macro 2020-08-17 11:07:40 +02:00
Sayed Shah
80c93b0e5e
platform: add support for configuring bridge settings via netlink (2)
NMDeviceBridge is currently using sysfs. The plan is to use netlink in
in the future.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/601
2020-08-14 21:26:10 +02:00
Sayed Shah
adf0420258
platform: add support for configuring bridge settings via netlink
NMDeviceBridge is currently using sysfs. The plan is to use netlink in
in the future
2020-08-07 13:20:54 +02:00
Sayed Shah
ec582d788c
nmp-object: add space before parentheses 2020-08-07 13:20:31 +02:00
Thomas Haller
6bf5f014c8
shared: change NM_SWAP() macro to take pointer arguments
This makes the macro more function like. Also, taking a pointer
makes it a bit clearer that this possibly changes the value.

Of course, it's not a big difference to before, but this
form seems slightly preferable to me.
2020-08-06 18:12:01 +02:00
Li-Hao Liao (Leon Liao)
3ba31aad58 platform: add the NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE status check
In some cases, the wow is not configured and the
NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE is set.
So, add the NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE status check.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/597
2020-08-06 11:02:54 +02:00
Thomas Haller
695ce608ba
l3cfg: add nm_l3_config_data_add_dependent_routes() 2020-07-31 08:53:06 +02:00
Thomas Haller
5ccfa38565
platform: move full-sync parameter away from nm_platform_ip_address_sync()
This parameter really affects whether a candidate in @addresses_prune will be
considered or not. Since we already construct the prune list separately, this
parameter is at the wrong place.

This requires us to re-implement nm_platform_lookup_clone(). While the
function has a predicate callback that we could use for this purpose,
I will later add a separate predicate argument to
nm_platform_ip_address_get_prune_list(). When that happens, it would
be cumbersome to chain the two function pointers. Instead, reimplement
nm_platform_lookup_clone().
2020-07-31 08:53:06 +02:00
Thomas Haller
dadfc3abd5
platform: allow injecting the list of addresses to prune
Follow the pattern of nm_platform_ip_route_sync(), which also accepts
the list of addresses that are potential candidates for removal.

This allows the caller to carefully construct the list of addresses
which are possibly removed, so that sync (possibly) only adds new
addresses.
2020-07-31 08:53:05 +02:00
Thomas Haller
0acb577320
platform: minor cleanup in nm_platform_ip_address_sync()
The known address must not have a zero lifetime,
because we filter those addresses out first.
2020-07-31 08:53:05 +02:00
Thomas Haller
dca62c06fd
platform: merge nm_platform_ip_address_sync() implementations
It is beneficial to have both address families side by side.

A lot of operations are exactly the same, so it's preferable to see
that. Especially in the cases where they differ, it's preferable to see
how they differ (and why).
2020-07-31 08:53:05 +02:00
Thomas Haller
30a8b1c713
platform: add NMP_OBJECT_TYPE_TO_ADDR_FAMILY() helper 2020-07-31 08:53:05 +02:00
Thomas Haller
1a4cc800f6
platform: add nmp_object_indirect_id_*() helpers 2020-07-31 08:53:04 +02:00
Thomas Haller
14fa487a60
platform: add static assertion to check NMPlatformIP{Address,Route} struct layout 2020-07-31 08:53:04 +02:00
Thomas Haller
7eb94b7dcc
platform: add nm_platform_ip_route_get_gateway() helper 2020-07-31 08:53:04 +02:00
Thomas Haller
a2a69a2dab
l3cfg: add more API to NML3ConfigData 2020-07-24 16:12:23 +02:00
Thomas Haller
b44f7dce40
core: add nm_platform_dedup_multi_iter_next_*() helpers to "nmp-object.h"
This code is not specific to "nm-ip4-config.h"/"nm-ip6-config.h".
It applies to everybody who wants to iterate over a dedup-multi-index of
certain NMPObjects. Move it.
2020-07-24 16:10:05 +02:00
Thomas Haller
67bfcb49c9
core: use nm_platform_ip[46]_address_pretty_sort_cmp() in "nm-ip[46]-config.c" 2020-07-24 16:10:04 +02:00
Thomas Haller
83bc1e8d60
platform: use NM_CMP_*() macros in nm_platform_ip[46]_address_pretty_sort_cmp()
They ensure to consistently return -1, 0, 1. Also, I think they are
easier to understand.

What is in general hard to understand, whether a comparison sorts
ascending or descending. The macros maybe make that easier too, but it's
still confusing. That's why we have a test.
2020-07-24 16:10:04 +02:00
Thomas Haller
d7608f32a6
platform: add nm_platform_ip[46]_address_pretty_sort_cmp()
This is the code from _addresses_sort_cmp() in "nm-ip[46]-config.h"
and will replace it soon.
2020-07-24 16:10:04 +02:00
Thomas Haller
84d93315d8
platform: add nmp_object_ip_route_is_best_defaut_route() helper 2020-07-23 15:29:24 +02:00
Thomas Haller
d4b7a3c27e
platform: add nmp_object_ref_set() helper 2020-07-23 15:29:24 +02:00
Thomas Haller
04be1dbd80
platform: add NMP_OBJECT_GET_ADDR_FAMILY() helper 2020-07-23 15:29:23 +02:00
Thomas Haller
bc3439d14f
platform: add nmp_object_link_get_ifname() helper 2020-07-23 15:29:23 +02:00
Thomas Haller
b17e3cf707
all: add trailing semicolon to NM_AUTO_DEFINE_FCN_*() uses 2020-07-19 12:01:56 +02:00
Beniamino Galvani
63a932b851 platform: do not rely on the presence of sriov_totalvfs sysfs file
The file doesn't exist for all interfaces that support SR-IOV. In
particular, netdevsim devices support SR-IOV but don't expose the
file.
2020-07-10 10:19:08 +02:00
Antonio Cardace
3e5fc04df3
core: add dependent local routes configured by kernel
Pre-generate routes in the local table that are configured
by kernel when an ip-address is assigned to an interface.

This helps NM taking into account routes that are not to be deleted
when a connection is reapplied (or deactivated) on an interface instead of only
ignoring (when pruning) IPv6 routes having metric 0 and routes belonging
to the local table having 'kernel' as proto.

https://bugzilla.redhat.com/show_bug.cgi?id=1821787
2020-07-08 18:01:55 +02:00
Thomas Haller
a83622f7d0
platform: skip metric-0 IPv6 routes in nm_platform_ip_route_sync()
@routes are the list of routes we want to configure. This contains
routes from DHCP and manual routes in the profile. It also contains
externally present routes, including the metric=0 routes in the local
table.

Trying to add an IPv6 route with metric zero adds instead a route with
metric 1024.

Usually, we wouldn't do that, because that route was present externally,
so it possibly is still present (in the platform cache) during sync and
we skip the addition. However, there is a race where the external route
might just disappear and we'd add a route with metric 1024.

Avoid that.
2020-07-08 17:18:44 +02:00
Antonio Cardace
9ecc27f6d3
platform: do not prune kernel added routes
IPv6 routes having metric 0 and routes having rt_source == kernel
are entirely managed by kernel, NM should not try to remove them.

https://bugzilla.redhat.com/show_bug.cgi?id=1821787
2020-07-08 15:10:36 +02:00
Antonio Cardace
04878193f7
platform: parse route type from netlink messages
https://bugzilla.redhat.com/show_bug.cgi?id=1821787
2020-07-08 15:10:36 +02:00
Antonio Cardace
d67ad4c86b
platform: always display route type when calling nmp_object_to_string()
https://bugzilla.redhat.com/show_bug.cgi?id=1821787
2020-07-08 15:10:35 +02:00
Beniamino Galvani
d0d35aa278 platform: support creation of prio qdisc
Support the creation of parameterless 'prio' qdiscs. The kernel needs
a TCA_OPTIONS attribute initialized with default values. We currently
don't support modifying the qdisc parameters.
2020-07-08 09:43:06 +02:00
Thomas Haller
1b408e243d
core: fix treating route metric zero of IPv6 routes special
Userspace cannot add IPv6 routes with metric 0. Trying to do that, will
be coerced by kernel to route metric 1024. For IPv4 this is different,
and metric zero is commonly allowed.

However, kernel itself can add IPv6 routes with metric zero:

  # ip -6 route show table local
  local fe80::2029:c7ff:fec9:698a dev v proto kernel metric 0 pref medium

That means, we must not treat route metric zero special for most cases.
Only, when we want to add routes (based on user configuration), we must
coerce a route metric of zero to 1024.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/563
2020-07-07 16:14:58 +02:00
Yuri Chornoivan
4e33f8cd89
all: fix minor typos
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/565
2020-07-07 11:33:46 +02:00
Sayed Shah
7337ab8959
all: fix typo in man pages
There should be a comma after 'Otherwise' and 'Currently'.

https://bugzilla.redhat.com/show_bug.cgi?id=1852452

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/560
2020-07-03 10:48:04 +02:00
Thomas Haller
3d542b55ed
platform/tests: avoid test failures accepting route added signals
/route/ip6: NMPlatformSignalAssert: ../src/platform/tests/test-route.c:331, test_ip6_route(): failure to accept signal [0,2] times: ip6-route-changed-added ifindex 0 (3 times received)
2020-06-30 17:23:45 +02:00
Antonio Cardace
5d0d13f570
platform: add support for local routes
Also update unit tests.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/407
https://bugzilla.redhat.com/show_bug.cgi?id=1821787
2020-06-16 10:01:22 +02:00
Beniamino Galvani
755e894b91 platform: add nm_platform_link_get_path()
Add a function to obtain the link path as exported by the ID_PATH udev
property.
2020-06-12 16:04:06 +02:00
Beniamino Galvani
3d9e2650c1 platform: rework nm_platform_link_get_unmanaged()
Split out the code to get udev properties. It will be reused in the next
commit.
2020-06-12 16:04:06 +02:00
Beniamino Galvani
2f21a52eeb platform: rework nm_platform_link_get_udi()
Implement the function directly in nm-platform.c without virtual
functions.
2020-06-12 16:04:05 +02:00
Beniamino Galvani
934777120b tc: add support for tbf qdisc
Add support for Token Bucket Filter queueing discipline.
2020-06-08 15:31:42 +02:00