Commit graph

1011 commits

Author SHA1 Message Date
Francesco Giudici
23bc781063 all/trivial: fix few comment typos 2017-05-15 15:52:21 +02:00
Nikolay Martynov
58f7813283 platform: ignore RTM_GETLINK messages sent by wireless extentions
We listen to all RTM_GETLINK messages to get updates on interfaces statuses.
Unfortunately wireless code in the kernel sends those messages with wireless information included
and all other information excluded. When we receive such message we wipe out our valid cached entry
with new object that is almost empty because netlink message didn't contain any information.

Solution to this is to check that incoming message contains MTU field: this field is always
set for complete messages about interfaces and is not set by wireless code.

Signed-off-by: Nikolay Martynov <mar.kolya@gmail.com>

https://github.com/NetworkManager/NetworkManager/pull/17
2017-05-11 17:41:10 +02:00
Beniamino Galvani
e6ff7f211d platform: fix double initialization
(cherry picked from commit 708ee92c29)
2017-05-08 15:05:01 +02:00
Beniamino Galvani
1d08391ed1 all: fix typo 'entires' -> 'entries'
(cherry picked from commit a4cbfe6f0a)
2017-05-05 19:16:39 +02:00
Thomas Haller
8ac1bf76bd core: move NMIPAddr to nm-core-utils.h
(cherry picked from commit 67da0a28db)
2017-04-27 17:21:33 +02:00
Beniamino Galvani
2511e27e76 platform: detect SR-IOV support and allow changing the number of VFs
(cherry picked from commit 0a7694cf81)
2017-04-18 23:28:59 +02:00
Thomas Haller
c2297fb66c core: enable "log-with-ptr" by default for platform and route-manager
Arguably, we currently only have one instance of NMPlatform,
NMRouteManager, NMDefaultRouteManager -- the one owned by the
NMNetns singleton.

Hence, all these instances we create with "log-with-ptr" set explicitly
to false.

In the future we want to support namespaces, and it will be be common to
have multiple instances. For that we have "log-with-ptr" so we are able
to disambiguiate the logging.

Change the default to TRUE because it makes more sense. It has currently
no effect as the default is never used.

(cherry picked from commit 41148caba8)
2017-04-18 15:53:11 +02:00
Thomas Haller
d37b9d79bc core: add NMNetns to bundle platform and route managers
NMPlatform, NMRouteManager and NMDefaultRouteManager are singletons
instances. Users of those are for example NMDevice, which registers
to GObject signals of both NMPlatform and NMRouteManager.

Hence, as NMDevice:dispose() disconnects the signal handlers, it must
ensure that those singleton instances live longer then the NMDevice
instance. That is usually accomplished by having users of singleton
instances own a reference to those instances.
For NMDevice that effectively means that it shall own a reference to
several singletons.

NMPlatform, NMRouteManager, and NMDefaultRouteManager are all
per-namespace. In general it doesn't make sense to have more then
one instances of these per name space. Nnote that currently we don't
support multiple namespaces yet. If we will ever support multiple
namespaces, then a NMDevice would have a reference to all of these
manager instances. Hence, introduce a new class NMNetns which bundles
them together.

(cherry picked from commit 0af2f5c28b)
2017-04-18 15:53:11 +02:00
Lubomir Rintel
fcad4fba16 platform: fix a typo
(cherry picked from commit c76ee5883d)
2017-04-18 09:43:43 +02:00
Thomas Haller
be19ec0739 core: ignore host part when comparing routes for route-manager
(cherry picked from commit b78562570a)
2017-04-15 00:37:22 +02:00
Thomas Haller
ae8d98391a platform: only consider net part of routes for route cache's ID
Routes with a non-zero host part are not allowed by kernel and
don't really exist. We didn't reject such routes in users configuration,
so various part of NM allow such routes. NM should silently strip
the host part.

Extend the cache's route ID to clear the host part too.

Note that NM's handling of routes is fundamentally flawed, as
for kernels routes don't have an "id" (or rather: all properties
of a route are part of it's ID, not only the family,ifindex,
network/plen and metric tuple (see related bug rh#1337855).

(cherry picked from commit 57b0dce083)
2017-04-15 00:37:22 +02:00
Thomas Haller
514d79fc85 platform: cleanup possibly non-zero host part for route operations
Platform's add/remove operations accept a "network" argument.
Kernel requires that the host part (based on plen) is all zero.
For NetworkManager we are more resilient to user configuration.

Cleanup the input argument already before calling _nl_msg_new_route().
Note that we use the same "network" argument to construct a obj_id
instance and to find the route in the cache (do_add_addrroute()).
Without cleaning the host part, the added object cannot be found
and the add-route command seemingly fails.

(cherry picked from commit 11d8c41898)
2017-04-15 00:37:22 +02:00
Lubomir Rintel
d77449314a linux-platform: fix link_get_unmanaged() return value
The function is supposed to set *unamanged to NM_UNMANAGED's and indicate
whether NM_UNMANAGED was present in the return value.

Fixes: e32839838e
(cherry picked from commit b7b0227935)
2017-04-06 13:25:48 +02:00
Beniamino Galvani
39d0559d9a platform: sort links by name instead of ifindex
We should try to guarantee a stable activation order of connections
across reboots; this is required, for example, for bonds because they
get assigned the MAC address of the first device enslaved, and thus
changing the activation order of slaves means also changing the MAC
address of the bond. Since we activate connections in the order links
are discovered, having a stable sorting of links returned by platform
is enough.

The ifindex of interfaces can change between reboots as it depends on
the order in which kernel discover interfaces. Provided that the
system uses a mechanism to enforce persistent interface naming (as
udev rules or systemd-udevd predictable names), and that NM starts
after all interfaces have been announced by udev, using the interface
name instead of ifindex will guarantee a consistent order.
2017-03-27 21:51:55 +02:00
Lubomir Rintel
0f5cf595a0 devices/arping-manager: log the device context 2017-03-24 12:42:09 +01:00
Lubomir Rintel
ed552c732c logging: log device and connection along with the message 2017-03-24 12:42:09 +01:00
Thomas Haller
0a34ae55a2 core/trivial: rename nm_utils_10pow() to nm_utils_exp10()
nm_utils_exp10() is a better name, because it reminds of the function
exp10() from <math.h> which has a similar purpose (but whose argument
is double, not gint16).
2017-03-24 11:28:57 +01:00
Thomas Haller
0fefcbfb2d build: don't link against libm.so
There are very few places where we actually use floating point
or #include <math.h>.

Drop that library, although we very likely still get it as indirect
dependency (e.g. on my system it is still dragged in by libsystemd.so,
libudev.so and libnl-3.so).
2017-03-23 19:06:02 +01:00
Thomas Haller
8ddc3e308c platform: remove debug logging messages from "nmp-object.c" 2017-03-23 11:55:34 +01:00
Thomas Haller
e32839838e udev: drop libgudev in favor of libudev
libgudev is just a wrapper around libudev. We can
use libudev directly and drop the dependency for
libgudev.
2017-03-22 12:41:06 +01:00
Beniamino Galvani
c26471e7de wifi-utils: nl80211: use logging macros 2017-03-21 18:46:52 +01:00
Beniamino Galvani
dda2b84ccc wifi-utils: wext: use logging macros 2017-03-21 18:46:52 +01:00
Beniamino Galvani
ed8da2cd25 wifi-utils: fix use of errno
It can be overwritten when other arguments are evaluated.
2017-03-21 18:46:52 +01:00
Beniamino Galvani
3860c2fbe3 wifi-utils: don't cache interface name
For nl80211, we don't care about the interface name and only use it
when formatting error messages. For wext, an up-to-date interface name
should be obtained every time to minimize the chance of race
conditions when the interface is renamed.
2017-03-21 18:46:52 +01:00
Thomas Haller
22b7282d84 all: use "unsigned" instead of "unsigned int" 2017-03-14 11:26:29 +01:00
Thomas Haller
b1eeb00937 all: use "unsigned long" instead of "long unsigned" 2017-03-14 11:23:46 +01:00
Thomas Haller
6aa4dc1958 platform: implement NM_LINUX_PLATFORM_GET_PRIVATE() via _NM_GET_PRIVATE_VOID() macro
We should implement all our private-getters with the very same pattern
(i.e. their type structure contains a field "_priv" and nm_assert()
with a GObject type check).

NM_LINUX_PLATFORM_GET_PRIVATE() was already doing all of that. Now just
use the _NM_GET_PRIVATE_VOID() macro which formally follows the
intended pattern.
2017-03-10 11:43:41 +01:00
Thomas Haller
3ce22c7319 platform/tests: use NMTST_WAIT_ASSERT() to wait for address 2017-03-09 23:06:08 +01:00
Beniamino Galvani
686fea6562 platform: tests: wait for non-tentative address before adding route
Wait that the address becomes non-tentative before adding the route
with RTA_PREFSRC.  Dummy interfaces are NOARP and thus don't do DAD,
but the kernel sets the address as tentative for a small amount of
time, which prevents the immediate addition of the route with
preferred source.

Fixes: 36d9e252d2
2017-03-09 19:01:59 +01:00
Thomas Haller
74f62d21ce platform/tests: add test code to initialize NMPCacheId with bogus data 2017-03-09 15:50:20 +01:00
Thomas Haller
f0e295d3d7 platform: filter out invisible links for cache lookup by name
Fixes: ad1d74d142
2017-03-09 15:12:43 +01:00
Thomas Haller
3799874664 platform: fix check in NMP_CLASS_IS_VALID
Maybe it was not wrong before, but this looks more
correct.
2017-03-09 15:12:43 +01:00
Thomas Haller
2972fd55bf platform/trivial: remove obsolete code comment 2017-03-09 14:57:00 +01:00
Francesco Giudici
b17d28cb42 test: platform: remove the source parameter from the ip6 route option test
The test fails on some kernels. Needs more investigations.
In the meanwhile, remove the src option from the test.

Fixes 45dc2feded
2017-03-08 19:04:48 +01:00
Beniamino Galvani
45dc2feded platform: add support for some route options
Add support for new route options: window, cwnd, initcwnd, initrwnd,
mtu (and their related *-lock flag), tos and src (RTA_SRC).
2017-03-06 15:20:25 +01:00
Beniamino Galvani
63951cad7f platform: change signature of nm_platform_ip{4,6}_route_add()
Change the functions to accept a platform route as argument. This will
make it easier to add new route options.
2017-03-06 15:20:25 +01:00
Beniamino Galvani
36d9e252d2 platform: support preferred source option for IPv6 routes
Extend the support for the preferred source route option (RTA_PREFSRC)
to IPv6.
2017-03-06 15:20:25 +01:00
Lubomir Rintel
4752ef20d6 wifi: error check nla_parse_nested()
Makes coverity happy.
2017-02-16 18:12:46 +01:00
Lubomir Rintel
9b1c6e9497 tests: drop a dead case branch
It seems to annoy coverity.
2017-02-16 18:12:45 +01:00
Thomas Haller
ed07de8667 platform: avoid printing "(null)" interface name during logging
Avoids:

    platform: link: setting up '(null)' (11)

Use nm_strquote_a() to quote the string if it is not NULL.
2017-02-10 17:31:16 +01:00
Thomas Haller
6ad8011e2d platform: use IFA_FLAGS name instead of numeric value
Originally, IFA_FLAGS might not have been present in the headers.
In the mean time, we explicitly define it outself to be "8".
2017-02-10 15:14:15 +01:00
Thomas Haller
95f9b0266c platform: unify logging messages about kernel support
Give them a common prefix.
2017-02-10 15:14:15 +01:00
Thomas Haller
6b03eacb34 platform: downgrade warning about failure to detect kernel support to debug
Also, as time goes by it is less likely to encounter a user
where the kernel has no support. The most likely reason nowadays
is that the user booted with "ipv6.disabled=1".

https://bugzilla.redhat.com/show_bug.cgi?id=1421019
2017-02-10 15:02:28 +01:00
Beniamino Galvani
a347962831 platform: fix detection of primary/secondary addresses
ip4_addr_subnets_is_secondary() should fill the list of addresses in
the same subnet also when returning FALSE, because
nm_platform_ip4_address_sync() uses it.

Fixes: 2f68a50041
2017-02-08 14:47:14 +01:00
Thomas Haller
ca5f915ac2 platform: cleanup _log_dbg_sysctl_set_impl() and _log_dbg_sysctl_get_impl()
- use gs_free attribute
- move printing the logging cache warning inside the place
  where we actuall add a new item to the cache.

It's really a minor cleanup of stuff that come to my mind reviewing the
function.
2017-02-07 15:28:14 +01:00
Lubomir Rintel
5b51a5f260 platform/tun: don't passing around the ifname guess
nm_platform_sysctl_open_netdir() doesn't take it anyways, gets it from
the cache.

CID 160209 (#1 of 1): Unused value (UNUSED_VALUE)
2017-01-16 22:14:47 +01:00
Beniamino Galvani
85103656e9 platform: add support for macsec links
Add support for a new macsec link type and its netlink attributes to
the platform code.
2017-01-16 17:37:14 +01:00
Thomas Haller
0bb1e9a116 ip[46]-config/trivial: move code around
Move the GObject related functions to the end of the source file.
Similar to how it's done for most other implementations.
2017-01-16 17:24:36 +01:00
Thomas Haller
f8227029fe platform: avoid one memset() in nmp_cache_id_init()
We end up calling nmp_cache_id_init_*() a lot to initialize stack-allocated
cache-ids to lookup the NMMultiIndex. There is no need to memset() it to
zero, because all relevant fields are supposed to be set explicitly.
2017-01-16 17:20:35 +01:00
Thomas Haller
953afd681a core: use nm_offsetofend() macro 2017-01-16 17:20:35 +01:00