2013-03-27 22:23:24 +01:00
|
|
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
|
|
|
|
/* nm-platform.c - Handle runtime kernel networking configuration
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
|
* any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2009 - 2010 Red Hat, Inc.
|
|
|
|
|
*/
|
|
|
|
|
|
all: fix up multiple-include-guard defines
Previously, src/nm-ip4-config.h, libnm/nm-ip4-config.h, and
libnm-glib/nm-ip4-config.h all used "NM_IP4_CONFIG_H" as an include
guard, which meant that nm-test-utils.h could not tell which of them
was being included (and so, eg, if you tried to include
nm-ip4-config.h in a libnm test, it would fail to compile because
nm-test-utils.h was referring to symbols in src/nm-ip4-config.h).
Fix this by changing the include guards in the non-API-stable parts of
the tree:
- libnm-glib/nm-ip4-config.h remains NM_IP4_CONFIG_H
- libnm/nm-ip4-config.h now uses __NM_IP4_CONFIG_H__
- src/nm-ip4-config.h now uses __NETWORKMANAGER_IP4_CONFIG_H__
And likewise for all other headers.
The two non-"nm"-prefixed headers, libnm/NetworkManager.h and
src/NetworkManagerUtils.h are now __NETWORKMANAGER_H__ and
__NETWORKMANAGER_UTILS_H__ respectively, which, while not entirely
consistent with the general scheme, do still mostly make sense in
isolation.
2014-08-13 14:10:11 -04:00
|
|
|
#ifndef __NETWORKMANAGER_PLATFORM_H__
|
|
|
|
|
#define __NETWORKMANAGER_PLATFORM_H__
|
2013-03-27 22:23:24 +01:00
|
|
|
|
|
|
|
|
#include <netinet/in.h>
|
|
|
|
|
#include <linux/if.h>
|
2013-10-15 20:44:59 +02:00
|
|
|
#include <linux/if_addr.h>
|
2015-12-03 15:44:33 +01:00
|
|
|
#include <linux/if_link.h>
|
2013-03-27 22:23:24 +01:00
|
|
|
|
2015-10-27 16:14:54 +01:00
|
|
|
#include "nm-dbus-interface.h"
|
|
|
|
|
#include "nm-core-types-internal.h"
|
2014-02-04 14:27:03 +01:00
|
|
|
|
2016-03-01 09:56:51 +01:00
|
|
|
#include "nm-core-utils.h"
|
|
|
|
|
#include "nm-setting-vlan.h"
|
2016-02-19 23:34:25 +01:00
|
|
|
#include "nm-setting-wired.h"
|
2016-03-01 09:56:51 +01:00
|
|
|
|
2013-03-27 22:23:24 +01:00
|
|
|
#define NM_TYPE_PLATFORM (nm_platform_get_type ())
|
|
|
|
|
#define NM_PLATFORM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_PLATFORM, NMPlatform))
|
|
|
|
|
#define NM_PLATFORM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_PLATFORM, NMPlatformClass))
|
|
|
|
|
#define NM_IS_PLATFORM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_PLATFORM))
|
|
|
|
|
#define NM_IS_PLATFORM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_PLATFORM))
|
|
|
|
|
#define NM_PLATFORM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_PLATFORM, NMPlatformClass))
|
|
|
|
|
|
2016-04-07 12:22:44 +02:00
|
|
|
#define NM_PLATFORM_NETNS_SUPPORT_DEFAULT FALSE
|
|
|
|
|
|
2016-10-02 18:22:50 +02:00
|
|
|
/*****************************************************************************/
|
2013-03-27 22:23:24 +01:00
|
|
|
|
2016-02-19 01:06:28 +01:00
|
|
|
#define NM_PLATFORM_NETNS_SUPPORT "netns-support"
|
2017-06-29 10:51:38 +02:00
|
|
|
#define NM_PLATFORM_USE_UDEV "use-udev"
|
2017-04-17 18:40:52 +02:00
|
|
|
#define NM_PLATFORM_LOG_WITH_PTR "log-with-ptr"
|
2015-05-12 07:34:56 +02:00
|
|
|
|
2016-10-02 18:22:50 +02:00
|
|
|
/*****************************************************************************/
|
2015-05-12 07:34:56 +02:00
|
|
|
|
2017-03-12 15:54:02 +01:00
|
|
|
struct udev_device;
|
|
|
|
|
|
2017-08-14 14:52:55 +02:00
|
|
|
typedef gboolean (*NMPObjectPredicateFunc) (const NMPObject *obj,
|
|
|
|
|
gpointer user_data);
|
|
|
|
|
|
2014-03-04 14:30:01 +01:00
|
|
|
/* workaround for older libnl version, that does not define these flags. */
|
|
|
|
|
#ifndef IFA_F_MANAGETEMPADDR
|
|
|
|
|
#define IFA_F_MANAGETEMPADDR 0x100
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef IFA_F_NOPREFIXROUTE
|
|
|
|
|
#define IFA_F_NOPREFIXROUTE 0x200
|
|
|
|
|
#endif
|
|
|
|
|
|
platform: add non-exclusive routes and drop route-manager
Previously, we would add exclusive routes via netlink message flags
NLM_F_CREATE | NLM_F_REPLACE for RTM_NEWROUTE. Similar to `ip route replace`.
Using that form of RTM_NEWROUTE message, we could only add a certain
route with a certain network/plen,metric triple once. That was already
hugely inconvenient, because
- when configuring routes, multiple (managed) interfaces may get
conflicting routes (multihoming). Only one of the routes can be actually
configured using `ip route replace`, so we need to track routes that are
currently shadowed.
- when configuring routes, we might replace externally configured
routes on unmanaged interfaces. We should not interfere with such
routes.
That was worked around by having NMRouteManager (and NMDefaultRouteManager).
NMRouteManager would keep a list of the routes which NetworkManager would like
to configure, even if momentarily being unable to do so due to conflicting routes.
This worked mostly well but was complicated. It involved bumping metrics to
avoid conflicts for device routes, as we might require them for gateway routes.
Drop that now. Instead, use the corresponding of `ip route append` to configure
routes. This allows NetworkManager to confiure (almost) all routes that we care.
Especially, it can configure all routes on a managed interface, without
replacing/interfering with routes on other interfaces. Hence, NMRouteManager
becomes obsolete.
It practice it is a bit more complicated because:
- when adding an IPv4 address, kernel will automatically create a device route
for the subnet. We should avoid that by using the IFA_F_NOPREFIXROUTE flag for
IPv4 addresses (still to-do). But as kernel may not support that flag for IPv4
addresses yet (and we don't require such a kernel yet), we still need functionality
similar to nm_route_manager_ip4_route_register_device_route_purge_list().
This functionality is now handled via nm_platform_ip4_dev_route_blacklist_set().
- trying to configure an IPv6 route with a source address will be rejected
by kernel as long as the address is tentative (see related bug rh#1457196).
Preferably, NMDevice would keep the list of routes which should be configured,
while kernel would have the list of what actually is configured. There is a
feed-back loop where both affect each other (for example, when externally deleting
a route, NMDevice must forget about it too). Previously, NMRouteManager would have
the task of remembering all routes which we currently want to configure, but cannot
due to conflicting routes.
We get rid of that, because now we configure non-exclusive routes. We however still
will need to remember IPv6 routes with a source address, that currently cannot be
configured yet. Hence, we will need to keep track of routes that
currently cannot be configured, but later may be.
That is still not done yet, as NMRouteManager didn't handle this
correctly either.
2017-08-14 14:18:53 +02:00
|
|
|
#define NM_RT_SCOPE_LINK 253 /* RT_SCOPE_LINK */
|
|
|
|
|
|
2015-10-12 16:07:01 +02:00
|
|
|
/* Define of the IN6_ADDR_GEN_MODE_* values to workaround old kernel headers
|
|
|
|
|
* that don't define it. */
|
|
|
|
|
#define NM_IN6_ADDR_GEN_MODE_UNKNOWN 255 /* no corresponding value. */
|
|
|
|
|
#define NM_IN6_ADDR_GEN_MODE_EUI64 0 /* IN6_ADDR_GEN_MODE_EUI64 */
|
|
|
|
|
#define NM_IN6_ADDR_GEN_MODE_NONE 1 /* IN6_ADDR_GEN_MODE_NONE */
|
|
|
|
|
#define NM_IN6_ADDR_GEN_MODE_STABLE_PRIVACY 2 /* IN6_ADDR_GEN_MODE_STABLE_PRIVACY */
|
2016-02-17 14:19:17 +01:00
|
|
|
#define NM_IN6_ADDR_GEN_MODE_RANDOM 3 /* IN6_ADDR_GEN_MODE_RANDOM */
|
2015-10-12 16:07:01 +02:00
|
|
|
|
2015-09-15 15:07:37 +02:00
|
|
|
#define NM_IFF_MULTI_QUEUE 0x0100 /* IFF_MULTI_QUEUE */
|
|
|
|
|
|
2015-09-01 22:11:47 +02:00
|
|
|
/* Redefine this in host's endianness */
|
|
|
|
|
#define NM_GRE_KEY 0x2000
|
|
|
|
|
|
2017-08-02 10:27:32 +02:00
|
|
|
typedef enum {
|
|
|
|
|
/* use our own platform enum for the nlmsg-flags. Otherwise, we'd have
|
|
|
|
|
* to include <linux/netlink.h> */
|
|
|
|
|
NMP_NLM_FLAG_F_REPLACE = 0x100, /* NLM_F_REPLACE, Override existing */
|
|
|
|
|
NMP_NLM_FLAG_F_EXCL = 0x200, /* NLM_F_EXCL, Do not touch, if it exists */
|
|
|
|
|
NMP_NLM_FLAG_F_CREATE = 0x400, /* NLM_F_CREATE, Create, if it does not exist */
|
|
|
|
|
NMP_NLM_FLAG_F_APPEND = 0x800, /* NLM_F_APPEND, Add to end of list */
|
|
|
|
|
|
2017-08-21 18:02:08 +02:00
|
|
|
NMP_NLM_FLAG_FMASK = 0xFFFF, /* a mask for all NMP_NLM_FLAG_F_* flags */
|
|
|
|
|
|
|
|
|
|
/* instructs NM to suppress logging an error message for any failures
|
|
|
|
|
* received from kernel.
|
|
|
|
|
*
|
|
|
|
|
* It will still log with debug-level, and it will still log
|
|
|
|
|
* other failures aside the kernel response. */
|
|
|
|
|
NMP_NLM_FLAG_SUPPRESS_NETLINK_FAILURE = 0x10000,
|
|
|
|
|
|
2017-08-02 10:27:32 +02:00
|
|
|
/* the following aliases correspond to iproute2's `ip route CMD` for
|
|
|
|
|
* RTM_NEWROUTE, with CMD being one of add, change, replace, prepend,
|
|
|
|
|
* append and test. */
|
|
|
|
|
NMP_NLM_FLAG_ADD = NMP_NLM_FLAG_F_CREATE | NMP_NLM_FLAG_F_EXCL,
|
|
|
|
|
NMP_NLM_FLAG_CHANGE = NMP_NLM_FLAG_F_REPLACE,
|
|
|
|
|
NMP_NLM_FLAG_REPLACE = NMP_NLM_FLAG_F_CREATE | NMP_NLM_FLAG_F_REPLACE,
|
|
|
|
|
NMP_NLM_FLAG_PREPEND = NMP_NLM_FLAG_F_CREATE,
|
|
|
|
|
NMP_NLM_FLAG_APPEND = NMP_NLM_FLAG_F_CREATE | NMP_NLM_FLAG_F_APPEND,
|
|
|
|
|
NMP_NLM_FLAG_TEST = NMP_NLM_FLAG_F_EXCL,
|
|
|
|
|
} NMPNlmFlags;
|
|
|
|
|
|
2017-07-26 10:50:23 +02:00
|
|
|
typedef enum {
|
|
|
|
|
/* compare fields which kernel considers as similar routes.
|
|
|
|
|
* It is a looser comparisong then NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID
|
|
|
|
|
* and means that `ip route add` would fail to add two routes
|
|
|
|
|
* that have the same NM_PLATFORM_IP_ROUTE_CMP_TYPE_WEAK_ID.
|
|
|
|
|
* On the other hand, `ip route append` would allow that, as
|
|
|
|
|
* long as NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID differs. */
|
|
|
|
|
NM_PLATFORM_IP_ROUTE_CMP_TYPE_WEAK_ID,
|
|
|
|
|
|
|
|
|
|
/* compare two routes as kernel would allow to add them with
|
|
|
|
|
* `ip route append`. In other words, kernel does not allow you to
|
|
|
|
|
* add two routes (at the same time) which compare equal according
|
|
|
|
|
* to NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID.
|
|
|
|
|
*
|
|
|
|
|
* For the ID we can only recognize route fields that we actually implement.
|
|
|
|
|
* However, kernel supports more routing options, some of them also part of
|
|
|
|
|
* the ID. NetworkManager is oblivious to these options and will wrongly think
|
|
|
|
|
* that two routes are idential, while they are not. That can lead to an
|
|
|
|
|
* inconsistent platform cache. Not much what we can do about that, except
|
|
|
|
|
* implementing all options that kernel supports *sigh*. See rh#1337860.
|
|
|
|
|
*/
|
|
|
|
|
NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID,
|
|
|
|
|
|
|
|
|
|
/* compare all fields as they make sense for kernel. For example,
|
|
|
|
|
* a route destination 192.168.1.5/24 is not accepted by kernel and
|
|
|
|
|
* we treat it identical to 192.168.1.0/24. Semantically these
|
|
|
|
|
* routes are identical, but NM_PLATFORM_IP_ROUTE_CMP_TYPE_FULL will
|
2017-09-02 16:56:27 +02:00
|
|
|
* report them as different.
|
|
|
|
|
*
|
|
|
|
|
* The result shall be identical to call first nm_platform_ip_route_normalize()
|
|
|
|
|
* on both routes and then doing a full comparison. */
|
2017-07-26 10:50:23 +02:00
|
|
|
NM_PLATFORM_IP_ROUTE_CMP_TYPE_SEMANTICALLY,
|
|
|
|
|
|
|
|
|
|
/* compare all fields. This should have the same effect as memcmp(),
|
|
|
|
|
* except allowing for undefined data in holes between field alignment.
|
|
|
|
|
*/
|
|
|
|
|
NM_PLATFORM_IP_ROUTE_CMP_TYPE_FULL,
|
|
|
|
|
|
|
|
|
|
} NMPlatformIPRouteCmpType;
|
|
|
|
|
|
2015-07-02 15:43:26 +02:00
|
|
|
typedef enum { /*< skip >*/
|
2015-06-15 15:50:59 +02:00
|
|
|
|
|
|
|
|
/* dummy value, to enforce that the enum type is signed and has a size
|
|
|
|
|
* to hold an integer. We want to encode errno from <errno.h> as negative
|
|
|
|
|
* values. */
|
|
|
|
|
_NM_PLATFORM_ERROR_MININT = G_MININT,
|
|
|
|
|
|
|
|
|
|
NM_PLATFORM_ERROR_SUCCESS = 0,
|
|
|
|
|
|
|
|
|
|
NM_PLATFORM_ERROR_BUG,
|
|
|
|
|
|
|
|
|
|
NM_PLATFORM_ERROR_UNSPECIFIED,
|
|
|
|
|
|
2013-04-29 13:57:58 +02:00
|
|
|
NM_PLATFORM_ERROR_NOT_FOUND,
|
|
|
|
|
NM_PLATFORM_ERROR_EXISTS,
|
2013-06-10 16:21:08 -03:00
|
|
|
NM_PLATFORM_ERROR_WRONG_TYPE,
|
2013-05-24 00:29:21 +02:00
|
|
|
NM_PLATFORM_ERROR_NOT_SLAVE,
|
2015-06-15 15:50:59 +02:00
|
|
|
NM_PLATFORM_ERROR_NO_FIRMWARE,
|
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 15:04:37 +02:00
|
|
|
NM_PLATFORM_ERROR_OPNOTSUPP,
|
2017-08-21 15:33:57 +02:00
|
|
|
NM_PLATFORM_ERROR_NETLINK,
|
2013-04-29 13:57:58 +02:00
|
|
|
} NMPlatformError;
|
|
|
|
|
|
2015-08-17 17:48:37 +02:00
|
|
|
#define NM_PLATFORM_LINK_OTHER_NETNS (-1)
|
|
|
|
|
|
2014-04-03 11:02:48 +02:00
|
|
|
#define __NMPlatformObject_COMMON \
|
|
|
|
|
int ifindex; \
|
|
|
|
|
;
|
|
|
|
|
|
2014-07-17 17:06:44 -04:00
|
|
|
struct _NMPlatformLink {
|
2014-04-03 11:02:48 +02:00
|
|
|
__NMPlatformObject_COMMON;
|
2013-03-27 22:23:24 +01:00
|
|
|
char name[IFNAMSIZ];
|
|
|
|
|
NMLinkType type;
|
2015-04-28 10:11:04 +02:00
|
|
|
|
2015-04-29 09:19:15 +02:00
|
|
|
/* rtnl_link_get_type(), IFLA_INFO_KIND. */
|
|
|
|
|
/* NMPlatform initializes this field with a static string. */
|
2015-04-28 10:11:04 +02:00
|
|
|
const char *kind;
|
|
|
|
|
|
2015-04-29 09:19:15 +02:00
|
|
|
/* NMPlatform initializes this field with a static string. */
|
2013-05-29 12:00:50 -03:00
|
|
|
const char *driver;
|
2015-04-29 09:19:15 +02:00
|
|
|
|
2013-03-27 22:53:55 +01:00
|
|
|
int master;
|
2015-08-17 17:48:37 +02:00
|
|
|
|
|
|
|
|
/* rtnl_link_get_link(), IFLA_LINK.
|
|
|
|
|
* If IFLA_LINK_NETNSID indicates that the parent is in another namespace,
|
|
|
|
|
* this field be set to (negative) NM_PLATFORM_LINK_OTHER_NETNS. */
|
2013-06-03 11:49:55 -03:00
|
|
|
int parent;
|
2015-04-25 16:42:26 +02:00
|
|
|
|
2016-02-29 15:57:37 +01:00
|
|
|
/* IFF_* flags. Note that the flags in 'struct ifinfomsg' are declared as 'unsigned'. */
|
|
|
|
|
guint n_ifi_flags;
|
|
|
|
|
|
|
|
|
|
guint mtu;
|
|
|
|
|
|
2015-04-27 18:45:23 +02:00
|
|
|
/* rtnl_link_get_arptype(), ifinfomsg.ifi_type. */
|
|
|
|
|
guint32 arptype;
|
|
|
|
|
|
2016-05-25 11:16:17 +02:00
|
|
|
/* rtnl_link_get_addr(), IFLA_ADDRESS */
|
2015-04-27 18:06:59 +02:00
|
|
|
struct {
|
|
|
|
|
guint8 data[20]; /* NM_UTILS_HWADDR_LEN_MAX */
|
|
|
|
|
guint8 len;
|
|
|
|
|
} addr;
|
|
|
|
|
|
2016-04-29 21:25:43 +02:00
|
|
|
/* rtnl_link_inet6_get_token(), IFLA_INET6_TOKEN */
|
|
|
|
|
NMUtilsIPv6IfaceId inet6_token;
|
2015-04-27 21:05:13 +02:00
|
|
|
|
2015-04-27 18:32:43 +02:00
|
|
|
/* The bitwise inverse of rtnl_link_inet6_get_addr_gen_mode(). It is inverse
|
|
|
|
|
* to have a default of 0 -- meaning: unspecified. That way, a struct
|
|
|
|
|
* initialized with memset(0) has and unset value.*/
|
|
|
|
|
guint8 inet6_addr_gen_mode_inv;
|
|
|
|
|
|
2016-08-10 11:54:30 +02:00
|
|
|
/* Statistics */
|
|
|
|
|
guint64 rx_packets;
|
|
|
|
|
guint64 rx_bytes;
|
|
|
|
|
guint64 tx_packets;
|
|
|
|
|
guint64 tx_bytes;
|
|
|
|
|
|
2016-02-29 15:52:27 +01:00
|
|
|
/* @connected is mostly identical to (@n_ifi_flags & IFF_UP). Except for bridge/bond masters,
|
2015-04-25 16:42:26 +02:00
|
|
|
* where we coerce the link as disconnect if it has no slaves. */
|
2016-02-29 15:57:37 +01:00
|
|
|
bool connected:1;
|
2015-04-25 16:42:26 +02:00
|
|
|
|
2016-02-29 15:57:37 +01:00
|
|
|
bool initialized:1;
|
2014-07-17 17:06:44 -04:00
|
|
|
};
|
2013-03-27 22:23:24 +01:00
|
|
|
|
2015-11-27 12:54:31 +01:00
|
|
|
typedef enum { /*< skip >*/
|
|
|
|
|
NM_PLATFORM_SIGNAL_ID_NONE,
|
|
|
|
|
NM_PLATFORM_SIGNAL_ID_LINK,
|
|
|
|
|
NM_PLATFORM_SIGNAL_ID_IP4_ADDRESS,
|
|
|
|
|
NM_PLATFORM_SIGNAL_ID_IP6_ADDRESS,
|
|
|
|
|
NM_PLATFORM_SIGNAL_ID_IP4_ROUTE,
|
|
|
|
|
NM_PLATFORM_SIGNAL_ID_IP6_ROUTE,
|
|
|
|
|
_NM_PLATFORM_SIGNAL_ID_LAST,
|
|
|
|
|
} NMPlatformSignalIdType;
|
|
|
|
|
|
|
|
|
|
guint _nm_platform_signal_id_get (NMPlatformSignalIdType signal_type);
|
|
|
|
|
|
2015-07-02 16:57:28 +02:00
|
|
|
typedef enum {
|
2015-04-13 18:55:59 +02:00
|
|
|
NM_PLATFORM_SIGNAL_NONE,
|
2014-03-07 19:04:38 +01:00
|
|
|
NM_PLATFORM_SIGNAL_ADDED,
|
|
|
|
|
NM_PLATFORM_SIGNAL_CHANGED,
|
|
|
|
|
NM_PLATFORM_SIGNAL_REMOVED,
|
|
|
|
|
} NMPlatformSignalChangeType;
|
|
|
|
|
|
2017-07-07 23:34:41 +02:00
|
|
|
struct _NMPlatformObject {
|
2014-04-03 11:02:48 +02:00
|
|
|
__NMPlatformObject_COMMON;
|
2017-07-07 23:34:41 +02:00
|
|
|
};
|
2014-04-03 11:02:48 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
#define __NMPlatformIPAddress_COMMON \
|
|
|
|
|
__NMPlatformObject_COMMON; \
|
2016-04-11 13:09:52 +02:00
|
|
|
NMIPConfigSource addr_source; \
|
platform: fix preferred and valid lifetimes for addresses from netlink/kernel
The kernel tells the address lifetimes in the 'struct ifa_cacheinfo'
attribute. This contains two timestamps (cstamp and tstamp) and two
relative lifetimes (ifa_prefered and ifa_valid).
The timestamps are equal to clock_gettime(CLOCK_MONOTONIC) scale in
1/100th of a second (wrapping every 497 days).
The preferred/valid times are re-adjusted everytime when sending the
message and count down as the time goes by. In other words, they are
anchored relatively to the moment of when kernel creates the netlink
message.
As platform is caching the rtnl_addr object, the information of *when* the
lifetimes started counting is not available.
This patch fixes reading these values by hacking the libnl object
when it gets received, so that valid and preferred are instead absolute
expiration timestamps in scale nm_utils_get_monotonic_timestamp_s() --
which NM internally is used for address timestamps.
There are two minor downsides to this hack:
- the valid and preferred properties of a cached rtnl_addr object have
an unexpected meaning, i.e. they are absolute and in a different time
scale.
- later when converting rtnl_addr to NMPlatformIPAddress, the base
timestamp is set to "1", i.e. an NMPlatformIPAddress has no knowledge
of when the address was created or last modified. The timestamp
property of NMPlatformIPAddress is solely there to anchor the relative
timestamps lifetime and preferred. Do not use it for anything
else.
Another reason the timestamp property is meaningless is that
its scale nm_utils_get_monotonic_timestamp_s() starts counting at
process start. So addresses that existed before would have a negative
or zero timestamp, which we avoid. This in turn could be solved by either
allowing negative timestamps or by shifting
nm_utils_get_monotonic_timestamp_*(). Both is viable, but not
necessary (ATM), because the age of an address has no other apparent
use then to anchor the relative timestamps.
Another implication is, that we potentially could get rid of the
timestamp completely, and insteat make preferred and lifetime be
absolute expiries.
This will be fixed properly later, by not caching libnl objects but instead
native NMPlatform objects. For those we have full control over their properties.
https://bugzilla.gnome.org/show_bug.cgi?id=727382
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-04-02 13:35:21 +02:00
|
|
|
\
|
|
|
|
|
/* Timestamp in seconds in the reference system of nm_utils_get_monotonic_timestamp_*().
|
2014-06-09 10:03:01 +02:00
|
|
|
*
|
|
|
|
|
* The rules are:
|
|
|
|
|
* 1 @lifetime==0: @timestamp and @preferred is irrelevant (but mostly set to 0 too). Such addresses
|
|
|
|
|
* are permanent. This rule is so that unset addresses (calloc) are permanent by default.
|
|
|
|
|
* 2 @lifetime==@preferred==NM_PLATFORM_LIFETIME_PERMANENT: @timestamp is irrelevant (but mostly
|
|
|
|
|
* set to 0). Such addresses are permanent.
|
|
|
|
|
* 3 Non permanent addreses should (almost) always have @timestamp > 0. 0 is not a valid timestamp
|
|
|
|
|
* and never returned by nm_utils_get_monotonic_timestamp_s(). In this case @valid/@preferred
|
|
|
|
|
* is anchored at @timestamp.
|
|
|
|
|
* 4 Non permanent addresses with @timestamp == 0 are implicitely anchored at *now*, thus the time
|
|
|
|
|
* moves as time goes by. This is usually not useful, except e.g. nm_platform_ip[46]_address_add().
|
|
|
|
|
*
|
|
|
|
|
* Non permanent addresses from DHCP/RA might have the @timestamp set to the moment of when the
|
|
|
|
|
* lease was received. Addresses from kernel might have the @timestamp based on the last modification
|
|
|
|
|
* time of the addresses. But don't rely on this behaviour, the @timestamp is only defined for anchoring
|
|
|
|
|
* @lifetime and @preferred.
|
platform: fix preferred and valid lifetimes for addresses from netlink/kernel
The kernel tells the address lifetimes in the 'struct ifa_cacheinfo'
attribute. This contains two timestamps (cstamp and tstamp) and two
relative lifetimes (ifa_prefered and ifa_valid).
The timestamps are equal to clock_gettime(CLOCK_MONOTONIC) scale in
1/100th of a second (wrapping every 497 days).
The preferred/valid times are re-adjusted everytime when sending the
message and count down as the time goes by. In other words, they are
anchored relatively to the moment of when kernel creates the netlink
message.
As platform is caching the rtnl_addr object, the information of *when* the
lifetimes started counting is not available.
This patch fixes reading these values by hacking the libnl object
when it gets received, so that valid and preferred are instead absolute
expiration timestamps in scale nm_utils_get_monotonic_timestamp_s() --
which NM internally is used for address timestamps.
There are two minor downsides to this hack:
- the valid and preferred properties of a cached rtnl_addr object have
an unexpected meaning, i.e. they are absolute and in a different time
scale.
- later when converting rtnl_addr to NMPlatformIPAddress, the base
timestamp is set to "1", i.e. an NMPlatformIPAddress has no knowledge
of when the address was created or last modified. The timestamp
property of NMPlatformIPAddress is solely there to anchor the relative
timestamps lifetime and preferred. Do not use it for anything
else.
Another reason the timestamp property is meaningless is that
its scale nm_utils_get_monotonic_timestamp_s() starts counting at
process start. So addresses that existed before would have a negative
or zero timestamp, which we avoid. This in turn could be solved by either
allowing negative timestamps or by shifting
nm_utils_get_monotonic_timestamp_*(). Both is viable, but not
necessary (ATM), because the age of an address has no other apparent
use then to anchor the relative timestamps.
Another implication is, that we potentially could get rid of the
timestamp completely, and insteat make preferred and lifetime be
absolute expiries.
This will be fixed properly later, by not caching libnl objects but instead
native NMPlatform objects. For those we have full control over their properties.
https://bugzilla.gnome.org/show_bug.cgi?id=727382
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-04-02 13:35:21 +02:00
|
|
|
*/ \
|
|
|
|
|
guint32 timestamp; \
|
|
|
|
|
guint32 lifetime; /* seconds since timestamp */ \
|
|
|
|
|
guint32 preferred; /* seconds since timestamp */ \
|
2016-02-29 16:50:55 +01:00
|
|
|
\
|
|
|
|
|
/* ifa_flags in 'struct ifaddrmsg' from <linux/if_addr.h>, extended to 32 bit by
|
|
|
|
|
* IFA_FLAGS attribute. */ \
|
|
|
|
|
guint32 n_ifa_flags; \
|
|
|
|
|
\
|
2016-04-06 18:04:26 +02:00
|
|
|
guint8 plen; \
|
2014-04-03 11:02:48 +02:00
|
|
|
;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* NMPlatformIPAddress:
|
|
|
|
|
*
|
|
|
|
|
* Common parts of NMPlatformIP4Address and NMPlatformIP6Address.
|
|
|
|
|
**/
|
|
|
|
|
typedef struct {
|
|
|
|
|
__NMPlatformIPAddress_COMMON;
|
|
|
|
|
union {
|
|
|
|
|
guint8 address_ptr[1];
|
|
|
|
|
guint32 __dummy_for_32bit_alignment;
|
|
|
|
|
};
|
|
|
|
|
} NMPlatformIPAddress;
|
|
|
|
|
|
2013-12-10 19:04:22 +01:00
|
|
|
/**
|
|
|
|
|
* NMPlatformIP4Address:
|
|
|
|
|
* @timestamp: timestamp as returned by nm_utils_get_monotonic_timestamp_s()
|
|
|
|
|
**/
|
2014-07-17 17:06:44 -04:00
|
|
|
struct _NMPlatformIP4Address {
|
2014-04-03 11:02:48 +02:00
|
|
|
__NMPlatformIPAddress_COMMON;
|
2015-10-21 23:17:11 +02:00
|
|
|
|
|
|
|
|
/* The local address IFA_LOCAL. */
|
2013-03-27 22:23:24 +01:00
|
|
|
in_addr_t address;
|
2015-10-21 23:17:11 +02:00
|
|
|
|
|
|
|
|
/* The IFA_ADDRESS PTP peer address. This field is rather important, because
|
|
|
|
|
* it constitutes the identifier for the IPv4 address (e.g. you can add two
|
|
|
|
|
* addresses that only differ by their peer's network-part.
|
|
|
|
|
*
|
|
|
|
|
* Beware that for most cases, NetworkManager doesn't want to set an explicit
|
|
|
|
|
* peer-address. Hoever, that corresponds to setting the peer address to @address
|
|
|
|
|
* itself. Leaving peer-address unset/zero, means explicitly setting the peer
|
|
|
|
|
* address to 0.0.0.0, which you probably don't want.
|
|
|
|
|
* */
|
2013-12-02 10:20:26 -05:00
|
|
|
in_addr_t peer_address; /* PTP peer address */
|
2015-10-21 23:17:11 +02:00
|
|
|
|
2014-02-19 16:10:59 -05:00
|
|
|
char label[IFNAMSIZ];
|
2014-07-17 17:06:44 -04:00
|
|
|
};
|
2013-03-27 22:23:24 +01:00
|
|
|
|
2013-12-10 19:04:22 +01:00
|
|
|
/**
|
|
|
|
|
* NMPlatformIP6Address:
|
|
|
|
|
* @timestamp: timestamp as returned by nm_utils_get_monotonic_timestamp_s()
|
|
|
|
|
**/
|
2014-07-17 17:06:44 -04:00
|
|
|
struct _NMPlatformIP6Address {
|
2014-04-03 11:02:48 +02:00
|
|
|
__NMPlatformIPAddress_COMMON;
|
2013-03-27 22:23:24 +01:00
|
|
|
struct in6_addr address;
|
2013-12-02 10:20:26 -05:00
|
|
|
struct in6_addr peer_address;
|
2014-07-17 17:06:44 -04:00
|
|
|
};
|
2014-04-03 11:02:48 +02:00
|
|
|
|
2014-11-10 14:23:44 +01:00
|
|
|
typedef union {
|
|
|
|
|
NMPlatformIPAddress ax;
|
|
|
|
|
NMPlatformIP4Address a4;
|
|
|
|
|
NMPlatformIP6Address a6;
|
|
|
|
|
} NMPlatformIPXAddress;
|
|
|
|
|
|
2014-04-03 11:02:48 +02:00
|
|
|
#undef __NMPlatformIPAddress_COMMON
|
|
|
|
|
|
2013-03-27 22:23:24 +01:00
|
|
|
|
2014-11-26 20:47:44 +01:00
|
|
|
/* Default value for adding an IPv4 route. This is also what iproute2 does.
|
|
|
|
|
* Note that contrary to IPv6, you can add routes with metric 0 and it is even
|
|
|
|
|
* the default.
|
|
|
|
|
*/
|
|
|
|
|
#define NM_PLATFORM_ROUTE_METRIC_DEFAULT_IP4 0
|
|
|
|
|
|
|
|
|
|
/* Default value for adding an IPv6 route. This is also what iproute2 does.
|
|
|
|
|
* Adding an IPv6 route with metric 0, kernel translates to IP6_RT_PRIO_USER (1024). */
|
|
|
|
|
#define NM_PLATFORM_ROUTE_METRIC_DEFAULT_IP6 1024
|
2014-01-06 15:15:55 -06:00
|
|
|
|
2014-11-11 14:55:07 +01:00
|
|
|
/* For IPv4, kernel adds a device route (subnet routes) with metric 0 when user
|
|
|
|
|
* configures addresses. */
|
|
|
|
|
#define NM_PLATFORM_ROUTE_METRIC_IP4_DEVICE_ROUTE 0
|
|
|
|
|
|
2014-04-03 11:02:48 +02:00
|
|
|
#define __NMPlatformIPRoute_COMMON \
|
|
|
|
|
__NMPlatformObject_COMMON; \
|
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-11 17:35:29 +02:00
|
|
|
\
|
|
|
|
|
/* The NMIPConfigSource. For routes that we receive from cache this corresponds
|
|
|
|
|
* to the rtm_protocol field (and is one of the NM_IP_CONFIG_SOURCE_RTPROT_* values).
|
|
|
|
|
* When adding a route, the source will be coerced to the protocol using
|
2017-07-19 12:51:22 +02:00
|
|
|
* nmp_utils_ip_config_source_coerce_to_rtprot().
|
|
|
|
|
*
|
|
|
|
|
* rtm_protocol is part of the primary key of an IPv4 route (meaning, you can add
|
|
|
|
|
* two IPv4 routes that only differ in their rtm_protocol. For IPv6, that is not
|
|
|
|
|
* the case.
|
|
|
|
|
*
|
|
|
|
|
* When deleting an IPv4/IPv6 route, the rtm_protocol field must match (even
|
|
|
|
|
* if it is not part of the primary key for IPv6) -- unless rtm_protocol is set
|
|
|
|
|
* to zero, in which case the first matching route (with proto ignored) is deleted. */ \
|
2016-04-11 13:09:52 +02:00
|
|
|
NMIPConfigSource rt_source; \
|
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-11 17:35:29 +02:00
|
|
|
\
|
2016-04-06 14:19:05 +02:00
|
|
|
guint8 plen; \
|
2016-04-11 15:32:45 +02:00
|
|
|
\
|
|
|
|
|
/* the route has rtm_flags set to RTM_F_CLONED. Such a route
|
|
|
|
|
* is hidden by platform and does not exist from the point-of-view
|
|
|
|
|
* of platform users. This flag is internal to track those hidden
|
|
|
|
|
* routes. Such a route is not alive, according to nmp_object_is_alive(). */ \
|
|
|
|
|
bool rt_cloned:1; \
|
2017-07-27 06:47:11 +02:00
|
|
|
\
|
|
|
|
|
\
|
|
|
|
|
/* RTA_METRICS:
|
|
|
|
|
*
|
|
|
|
|
* For IPv4 routes, these properties are part of their
|
2017-07-26 07:26:18 +02:00
|
|
|
* ID (meaning: you can add otherwise idential IPv4 routes that
|
2017-07-27 06:47:11 +02:00
|
|
|
* only differ by the metric property).
|
|
|
|
|
* On the other hand, for IPv6 you cannot add two IPv6 routes that only differ
|
|
|
|
|
* by an RTA_METRICS property.
|
2017-07-26 07:26:18 +02:00
|
|
|
*
|
2017-07-27 06:47:11 +02:00
|
|
|
* When deleting a route, kernel seems to ignore the RTA_METRICS propeties.
|
|
|
|
|
* That is a problem/bug for IPv4 because you cannot explicitly select which
|
|
|
|
|
* route to delete. Kernel just picks the first. See rh#1475642. */ \
|
|
|
|
|
\
|
2017-07-27 07:21:01 +02:00
|
|
|
/* RTA_METRICS.RTAX_LOCK (iproute2: "lock" arguments) */ \
|
|
|
|
|
bool lock_window:1; \
|
|
|
|
|
bool lock_cwnd:1; \
|
|
|
|
|
bool lock_initcwnd:1; \
|
|
|
|
|
bool lock_initrwnd:1; \
|
|
|
|
|
bool lock_mtu:1; \
|
|
|
|
|
\
|
2017-07-27 06:47:11 +02:00
|
|
|
/* RTA_METRICS.RTAX_ADVMSS (iproute2: advmss) */ \
|
2014-08-28 17:25:36 +02:00
|
|
|
guint32 mss; \
|
2017-07-26 07:26:18 +02:00
|
|
|
\
|
2017-07-27 06:47:11 +02:00
|
|
|
/* RTA_METRICS.RTAX_WINDOW (iproute2: window) */ \
|
2017-02-15 14:00:44 +01:00
|
|
|
guint32 window; \
|
2017-07-27 06:47:11 +02:00
|
|
|
\
|
2017-07-31 15:42:52 +02:00
|
|
|
/* RTA_METRICS.RTAX_CWND (iproute2: cwnd) */ \
|
2017-02-15 14:00:44 +01:00
|
|
|
guint32 cwnd; \
|
2017-07-31 15:42:52 +02:00
|
|
|
\
|
|
|
|
|
/* RTA_METRICS.RTAX_INITCWND (iproute2: initcwnd) */ \
|
2017-02-15 14:00:44 +01:00
|
|
|
guint32 initcwnd; \
|
2017-07-31 15:42:52 +02:00
|
|
|
\
|
|
|
|
|
/* RTA_METRICS.RTAX_INITRWND (iproute2: initrwnd) */ \
|
2017-02-15 14:00:44 +01:00
|
|
|
guint32 initrwnd; \
|
2017-07-31 15:42:52 +02:00
|
|
|
\
|
|
|
|
|
/* RTA_METRICS.RTAX_MTU (iproute2: mtu) */ \
|
2017-02-15 14:00:44 +01:00
|
|
|
guint32 mtu; \
|
2017-07-31 15:42:52 +02:00
|
|
|
\
|
|
|
|
|
\
|
2017-08-02 07:16:35 +02:00
|
|
|
/* RTA_PRIORITY (iproute2: metric) */ \
|
2017-07-27 07:21:01 +02:00
|
|
|
guint32 metric; \
|
|
|
|
|
\
|
2017-08-21 23:17:12 +02:00
|
|
|
/* rtm_table, RTA_TABLE.
|
|
|
|
|
*
|
|
|
|
|
* This is not the original table ID. Instead, 254 (RT_TABLE_MAIN) and
|
|
|
|
|
* zero (RT_TABLE_UNSPEC) are swapped, so that the default is the main
|
2017-09-22 15:26:56 +02:00
|
|
|
* table. Use nm_platform_route_table_coerce()/nm_platform_route_table_uncoerce(). */ \
|
2017-08-21 23:17:12 +02:00
|
|
|
guint32 table_coerced; \
|
|
|
|
|
\
|
2017-07-27 07:21:01 +02:00
|
|
|
/*end*/
|
|
|
|
|
|
2014-04-03 11:02:48 +02:00
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
__NMPlatformIPRoute_COMMON;
|
|
|
|
|
union {
|
|
|
|
|
guint8 network_ptr[1];
|
|
|
|
|
guint32 __dummy_for_32bit_alignment;
|
|
|
|
|
};
|
|
|
|
|
} NMPlatformIPRoute;
|
|
|
|
|
|
2017-08-22 16:38:05 +02:00
|
|
|
#if _NM_CC_SUPPORT_GENERIC
|
|
|
|
|
#define NM_PLATFORM_IP_ROUTE_IS_DEFAULT(route) \
|
|
|
|
|
(_Generic ((route), \
|
|
|
|
|
const NMPlatformIPRoute *: ((const NMPlatformIPRoute *) (route))->plen, \
|
|
|
|
|
NMPlatformIPRoute *: ((const NMPlatformIPRoute *) (route))->plen, \
|
|
|
|
|
const NMPlatformIPXRoute *: ((const NMPlatformIPRoute *) (route))->plen, \
|
|
|
|
|
NMPlatformIPXRoute *: ((const NMPlatformIPRoute *) (route))->plen, \
|
|
|
|
|
const NMPlatformIP4Route *: ((const NMPlatformIPRoute *) (route))->plen, \
|
|
|
|
|
NMPlatformIP4Route *: ((const NMPlatformIPRoute *) (route))->plen, \
|
|
|
|
|
const NMPlatformIP6Route *: ((const NMPlatformIPRoute *) (route))->plen, \
|
|
|
|
|
NMPlatformIP6Route *: ((const NMPlatformIPRoute *) (route))->plen, \
|
|
|
|
|
const void *: ((const NMPlatformIPRoute *) (route))->plen, \
|
|
|
|
|
void *: ((const NMPlatformIPRoute *) (route))->plen) == 0)
|
|
|
|
|
#else
|
2014-07-29 19:10:08 +02:00
|
|
|
#define NM_PLATFORM_IP_ROUTE_IS_DEFAULT(route) \
|
|
|
|
|
( ((const NMPlatformIPRoute *) (route))->plen <= 0 )
|
2017-08-22 16:38:05 +02:00
|
|
|
#endif
|
2014-07-29 19:10:08 +02:00
|
|
|
|
2014-07-17 17:06:44 -04:00
|
|
|
struct _NMPlatformIP4Route {
|
2014-04-03 11:02:48 +02:00
|
|
|
__NMPlatformIPRoute_COMMON;
|
2013-03-27 22:23:24 +01:00
|
|
|
in_addr_t network;
|
2017-07-19 13:03:28 +02:00
|
|
|
|
|
|
|
|
/* RTA_GATEWAY. The gateway is part of the primary key for a route */
|
2013-03-27 22:23:24 +01:00
|
|
|
in_addr_t gateway;
|
2015-05-03 10:47:41 +02:00
|
|
|
|
2017-07-26 09:25:21 +02:00
|
|
|
/* RTA_PREFSRC (called "src" by iproute2).
|
|
|
|
|
*
|
|
|
|
|
* pref_src is part of the ID of an IPv4 route. When deleting a route,
|
|
|
|
|
* pref_src must match, unless set to 0.0.0.0 to match any. */
|
2015-10-29 09:26:10 +01:00
|
|
|
in_addr_t pref_src;
|
2017-07-19 13:03:28 +02:00
|
|
|
|
2017-08-02 07:16:35 +02:00
|
|
|
/* rtm_tos (iproute2: tos)
|
|
|
|
|
*
|
|
|
|
|
* For IPv4, tos is part of the weak-id (like metric).
|
|
|
|
|
*
|
|
|
|
|
* For IPv6, tos is ignored by kernel. */
|
|
|
|
|
guint8 tos;
|
|
|
|
|
|
2017-07-19 13:03:28 +02:00
|
|
|
/* The bitwise inverse of the route scope rtm_scope. It is inverted so that the
|
|
|
|
|
* default value (RT_SCOPE_NOWHERE) is zero. Use nm_platform_route_scope_inv()
|
|
|
|
|
* to convert back and forth between the inverese representation and the
|
|
|
|
|
* real value.
|
|
|
|
|
*
|
|
|
|
|
* rtm_scope is part of the primary key for IPv4 routes. When deleting a route,
|
|
|
|
|
* the scope must match, unless it is left at RT_SCOPE_NOWHERE, in which case the first
|
|
|
|
|
* matching route is deleted.
|
|
|
|
|
*
|
|
|
|
|
* For IPv6 routes, the scope is ignored and kernel always assumes global scope.
|
|
|
|
|
* Hence, this field is only in NMPlatformIP4Route. */
|
|
|
|
|
guint8 scope_inv;
|
2014-07-17 17:06:44 -04:00
|
|
|
};
|
2013-03-27 22:23:24 +01:00
|
|
|
|
2014-07-17 17:06:44 -04:00
|
|
|
struct _NMPlatformIP6Route {
|
2014-04-03 11:02:48 +02:00
|
|
|
__NMPlatformIPRoute_COMMON;
|
2013-03-27 22:23:24 +01:00
|
|
|
struct in6_addr network;
|
2017-07-19 13:03:28 +02:00
|
|
|
|
|
|
|
|
/* RTA_GATEWAY. The gateway is part of the primary key for a route */
|
2013-03-27 22:23:24 +01:00
|
|
|
struct in6_addr gateway;
|
2017-07-19 13:03:28 +02:00
|
|
|
|
2017-07-26 09:25:21 +02:00
|
|
|
/* RTA_PREFSRC (called "src" by iproute2).
|
|
|
|
|
*
|
|
|
|
|
* pref_src is not part of the ID for an IPv6 route. You cannot add two
|
|
|
|
|
* routes that only differ by pref_src.
|
|
|
|
|
*
|
|
|
|
|
* When deleting a route, pref_src is ignored by kernel. */
|
2017-02-09 17:26:04 +01:00
|
|
|
struct in6_addr pref_src;
|
2017-07-26 09:25:21 +02:00
|
|
|
|
2017-07-26 09:25:21 +02:00
|
|
|
/* RTA_SRC and rtm_src_len (called "from" by iproute2).
|
|
|
|
|
*
|
|
|
|
|
* Kernel clears the host part of src/src_plen.
|
|
|
|
|
*
|
|
|
|
|
* src/src_plen is part of the ID of a route just like network/plen. That is,
|
|
|
|
|
* Not only `ip route append`, but also `ip route add` allows to add routes that only
|
|
|
|
|
* differ in their src/src_plen.
|
|
|
|
|
*/
|
2017-02-15 14:00:44 +01:00
|
|
|
struct in6_addr src;
|
|
|
|
|
guint8 src_plen;
|
2017-10-09 11:09:16 +02:00
|
|
|
|
|
|
|
|
/* RTA_PREF router preference.
|
|
|
|
|
*
|
|
|
|
|
* The type is guint8 to keep the struct size small. But the values are compatible with
|
|
|
|
|
* the NMIcmpv6RouterPref enum. */
|
|
|
|
|
guint8 rt_pref;
|
2014-07-17 17:06:44 -04:00
|
|
|
};
|
2014-04-03 11:02:48 +02:00
|
|
|
|
2014-11-10 14:23:44 +01:00
|
|
|
typedef union {
|
|
|
|
|
NMPlatformIPRoute rx;
|
|
|
|
|
NMPlatformIP4Route r4;
|
|
|
|
|
NMPlatformIP6Route r6;
|
|
|
|
|
} NMPlatformIPXRoute;
|
|
|
|
|
|
2014-04-03 11:02:48 +02:00
|
|
|
#undef __NMPlatformIPRoute_COMMON
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#undef __NMPlatformObject_COMMON
|
|
|
|
|
|
2013-03-27 22:23:24 +01:00
|
|
|
|
2015-03-25 11:28:19 +01:00
|
|
|
typedef struct {
|
|
|
|
|
gboolean is_ip4;
|
2017-06-29 15:19:35 +02:00
|
|
|
NMPObjectType obj_type;
|
2015-03-25 11:28:19 +01:00
|
|
|
int addr_family;
|
|
|
|
|
gsize sizeof_route;
|
2017-07-26 10:50:23 +02:00
|
|
|
int (*route_cmp) (const NMPlatformIPXRoute *a, const NMPlatformIPXRoute *b, NMPlatformIPRouteCmpType cmp_type);
|
2015-10-12 10:27:33 +02:00
|
|
|
const char *(*route_to_string) (const NMPlatformIPXRoute *route, char *buf, gsize len);
|
2015-03-25 11:28:19 +01:00
|
|
|
guint32 (*metric_normalize) (guint32 metric);
|
|
|
|
|
} NMPlatformVTableRoute;
|
|
|
|
|
|
|
|
|
|
extern const NMPlatformVTableRoute nm_platform_vtable_route_v4;
|
|
|
|
|
extern const NMPlatformVTableRoute nm_platform_vtable_route_v6;
|
|
|
|
|
|
2015-10-15 15:47:14 +02:00
|
|
|
typedef struct {
|
2016-02-29 15:57:37 +01:00
|
|
|
in_addr_t local;
|
|
|
|
|
in_addr_t remote;
|
2015-10-16 18:26:38 +02:00
|
|
|
int parent_ifindex;
|
|
|
|
|
guint16 input_flags;
|
|
|
|
|
guint16 output_flags;
|
|
|
|
|
guint32 input_key;
|
|
|
|
|
guint32 output_key;
|
|
|
|
|
guint8 ttl;
|
|
|
|
|
guint8 tos;
|
2016-02-29 15:57:37 +01:00
|
|
|
bool path_mtu_discovery:1;
|
2015-10-16 18:26:38 +02:00
|
|
|
} NMPlatformLnkGre;
|
2015-10-12 13:44:44 +02:00
|
|
|
|
2013-04-25 15:46:39 -04:00
|
|
|
typedef struct {
|
2015-10-16 18:26:38 +02:00
|
|
|
int p_key;
|
2013-04-25 15:46:39 -04:00
|
|
|
const char *mode;
|
2015-10-16 18:26:38 +02:00
|
|
|
} NMPlatformLnkInfiniband;
|
2013-04-25 15:46:39 -04:00
|
|
|
|
2015-11-27 22:22:25 +01:00
|
|
|
typedef struct {
|
|
|
|
|
struct in6_addr local;
|
|
|
|
|
struct in6_addr remote;
|
2016-02-29 15:57:37 +01:00
|
|
|
int parent_ifindex;
|
2015-11-27 22:22:25 +01:00
|
|
|
guint8 ttl;
|
|
|
|
|
guint8 tclass;
|
|
|
|
|
guint8 encap_limit;
|
|
|
|
|
guint8 proto;
|
2016-02-29 15:57:37 +01:00
|
|
|
guint flow_label;
|
2015-11-27 22:22:25 +01:00
|
|
|
} NMPlatformLnkIp6Tnl;
|
|
|
|
|
|
2015-11-27 14:01:56 +01:00
|
|
|
typedef struct {
|
|
|
|
|
in_addr_t local;
|
|
|
|
|
in_addr_t remote;
|
2016-02-29 15:57:37 +01:00
|
|
|
int parent_ifindex;
|
2015-11-27 14:01:56 +01:00
|
|
|
guint8 ttl;
|
|
|
|
|
guint8 tos;
|
2016-02-29 15:57:37 +01:00
|
|
|
bool path_mtu_discovery:1;
|
2015-11-27 14:01:56 +01:00
|
|
|
} NMPlatformLnkIpIp;
|
|
|
|
|
|
2016-06-30 18:20:09 +02:00
|
|
|
typedef struct {
|
|
|
|
|
int parent_ifindex;
|
2017-06-27 19:08:05 +02:00
|
|
|
guint64 sci; /* host byte order */
|
2016-06-30 18:20:09 +02:00
|
|
|
guint64 cipher_suite;
|
|
|
|
|
guint32 window;
|
|
|
|
|
guint8 icv_length;
|
|
|
|
|
guint8 encoding_sa;
|
|
|
|
|
guint8 validation;
|
|
|
|
|
bool encrypt:1;
|
|
|
|
|
bool protect:1;
|
|
|
|
|
bool include_sci:1;
|
|
|
|
|
bool es:1;
|
|
|
|
|
bool scb:1;
|
|
|
|
|
bool replay_protect:1;
|
|
|
|
|
} NMPlatformLnkMacsec;
|
|
|
|
|
|
2013-05-06 09:16:17 -04:00
|
|
|
typedef struct {
|
2015-12-03 15:44:33 +01:00
|
|
|
guint mode;
|
2016-02-29 15:57:37 +01:00
|
|
|
bool no_promisc:1;
|
|
|
|
|
bool tap:1;
|
2015-10-12 15:15:21 +02:00
|
|
|
} NMPlatformLnkMacvlan;
|
2013-05-06 09:16:17 -04:00
|
|
|
|
2015-12-04 09:49:39 +01:00
|
|
|
typedef NMPlatformLnkMacvlan NMPlatformLnkMacvtap;
|
|
|
|
|
|
2015-11-11 18:41:48 +01:00
|
|
|
typedef struct {
|
|
|
|
|
in_addr_t local;
|
|
|
|
|
in_addr_t remote;
|
2016-02-29 15:57:37 +01:00
|
|
|
int parent_ifindex;
|
2015-11-11 18:41:48 +01:00
|
|
|
guint8 ttl;
|
|
|
|
|
guint8 tos;
|
|
|
|
|
guint8 proto;
|
2016-02-29 15:57:37 +01:00
|
|
|
bool path_mtu_discovery:1;
|
|
|
|
|
guint16 flags;
|
2015-11-11 18:41:48 +01:00
|
|
|
} NMPlatformLnkSit;
|
|
|
|
|
|
2015-10-16 18:26:38 +02:00
|
|
|
typedef struct {
|
|
|
|
|
/* rtnl_link_vlan_get_id(), IFLA_VLAN_ID */
|
|
|
|
|
guint16 id;
|
2015-10-27 16:14:54 +01:00
|
|
|
NMVlanFlags flags;
|
2015-10-16 18:26:38 +02:00
|
|
|
} NMPlatformLnkVlan;
|
|
|
|
|
|
2013-06-04 10:31:22 -03:00
|
|
|
typedef struct {
|
|
|
|
|
struct in6_addr group6;
|
|
|
|
|
struct in6_addr local6;
|
2016-02-29 15:57:37 +01:00
|
|
|
in_addr_t group;
|
|
|
|
|
in_addr_t local;
|
|
|
|
|
int parent_ifindex;
|
|
|
|
|
guint32 id;
|
2013-06-04 10:31:22 -03:00
|
|
|
guint32 ageing;
|
|
|
|
|
guint32 limit;
|
|
|
|
|
guint16 dst_port;
|
|
|
|
|
guint16 src_port_min;
|
|
|
|
|
guint16 src_port_max;
|
2016-02-29 15:57:37 +01:00
|
|
|
guint8 tos;
|
|
|
|
|
guint8 ttl;
|
|
|
|
|
bool learning:1;
|
|
|
|
|
bool proxy:1;
|
|
|
|
|
bool rsc:1;
|
|
|
|
|
bool l2miss:1;
|
|
|
|
|
bool l3miss:1;
|
2015-10-12 15:15:21 +02:00
|
|
|
} NMPlatformLnkVxlan;
|
2013-06-04 10:31:22 -03:00
|
|
|
|
2013-05-21 12:49:24 -03:00
|
|
|
typedef struct {
|
2015-10-16 18:26:38 +02:00
|
|
|
gint64 owner;
|
|
|
|
|
gint64 group;
|
|
|
|
|
const char *mode;
|
2016-02-29 15:57:37 +01:00
|
|
|
bool no_pi:1;
|
|
|
|
|
bool vnet_hdr:1;
|
|
|
|
|
bool multi_queue:1;
|
2015-10-16 18:26:38 +02:00
|
|
|
} NMPlatformTunProperties;
|
2013-05-21 12:49:24 -03:00
|
|
|
|
2016-09-10 16:48:01 +02:00
|
|
|
typedef enum {
|
2016-11-22 12:59:11 +01:00
|
|
|
NM_PLATFORM_LINK_DUPLEX_UNKNOWN,
|
2016-09-10 16:48:01 +02:00
|
|
|
NM_PLATFORM_LINK_DUPLEX_HALF,
|
|
|
|
|
NM_PLATFORM_LINK_DUPLEX_FULL,
|
|
|
|
|
} NMPlatformLinkDuplexType;
|
|
|
|
|
|
2017-10-10 18:20:05 +02:00
|
|
|
typedef enum {
|
|
|
|
|
NM_PLATFORM_KERNEL_SUPPORT_EXTENDED_IFA_FLAGS = (1LL << 0),
|
|
|
|
|
NM_PLATFORM_KERNEL_SUPPORT_USER_IPV6LL = (1LL << 1),
|
2017-10-11 09:15:04 +02:00
|
|
|
NM_PLATFORM_KERNEL_SUPPORT_RTA_PREF = (1LL << 2),
|
2017-10-10 18:20:05 +02:00
|
|
|
} NMPlatformKernelSupportFlags;
|
|
|
|
|
|
2016-10-02 18:22:50 +02:00
|
|
|
/*****************************************************************************/
|
2013-03-27 22:23:24 +01:00
|
|
|
|
2016-09-28 15:58:24 +02:00
|
|
|
struct _NMPlatformPrivate;
|
|
|
|
|
|
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".
2015-04-18 12:36:09 +02:00
|
|
|
struct _NMPlatform {
|
2013-03-27 22:23:24 +01:00
|
|
|
GObject parent;
|
2016-02-19 01:06:28 +01:00
|
|
|
NMPNetns *_netns;
|
2016-09-28 15:58:24 +02:00
|
|
|
struct _NMPlatformPrivate *_priv;
|
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".
2015-04-18 12:36:09 +02:00
|
|
|
};
|
2013-03-27 22:23:24 +01:00
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
GObjectClass parent;
|
|
|
|
|
|
2016-12-08 14:29:00 +01:00
|
|
|
gboolean (*sysctl_set) (NMPlatform *, const char *pathid, int dirfd, const char *path, const char *value);
|
|
|
|
|
char * (*sysctl_get) (NMPlatform *, const char *pathid, int dirfd, const char *path);
|
2013-04-03 16:10:38 +02:00
|
|
|
|
2014-09-18 12:53:19 -05:00
|
|
|
gboolean (*link_add) (NMPlatform *,
|
|
|
|
|
const char *name,
|
|
|
|
|
NMLinkType type,
|
2017-05-26 14:00:29 +02:00
|
|
|
const char *veth_peer,
|
2014-09-18 12:53:19 -05:00
|
|
|
const void *address,
|
|
|
|
|
size_t address_len,
|
2015-12-09 15:13:57 +01:00
|
|
|
const NMPlatformLink **out_link);
|
2013-03-27 22:23:24 +01:00
|
|
|
gboolean (*link_delete) (NMPlatform *, int ifindex);
|
2013-03-27 22:23:24 +01:00
|
|
|
|
2014-02-11 13:58:00 +01:00
|
|
|
gboolean (*link_refresh) (NMPlatform *, int ifindex);
|
2016-03-08 13:02:58 +01:00
|
|
|
|
|
|
|
|
gboolean (*link_set_netns) (NMPlatform *, int ifindex, int netns_fd);
|
|
|
|
|
|
2015-06-19 15:38:41 +02:00
|
|
|
void (*process_events) (NMPlatform *self);
|
2014-02-11 13:58:00 +01:00
|
|
|
|
2015-06-15 17:41:27 +02:00
|
|
|
gboolean (*link_set_up) (NMPlatform *, int ifindex, gboolean *out_no_firmware);
|
2013-03-27 22:23:24 +01:00
|
|
|
gboolean (*link_set_down) (NMPlatform *, int ifindex);
|
|
|
|
|
gboolean (*link_set_arp) (NMPlatform *, int ifindex);
|
|
|
|
|
gboolean (*link_set_noarp) (NMPlatform *, int ifindex);
|
2013-03-27 22:23:24 +01:00
|
|
|
|
2015-06-15 14:41:35 +02:00
|
|
|
const char *(*link_get_udi) (NMPlatform *self, int ifindex);
|
2017-03-12 15:54:02 +01:00
|
|
|
struct udev_device *(*link_get_udev_device) (NMPlatform *self, int ifindex);
|
2014-09-27 09:03:56 +02:00
|
|
|
|
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 15:04:37 +02:00
|
|
|
NMPlatformError (*link_set_user_ipv6ll_enabled) (NMPlatform *, int ifindex, gboolean enabled);
|
2016-04-30 16:48:32 +02:00
|
|
|
gboolean (*link_set_token) (NMPlatform *, int ifindex, NMUtilsIPv6IfaceId iid);
|
2014-07-24 15:57:08 -05:00
|
|
|
|
2014-10-03 17:37:26 -05:00
|
|
|
gboolean (*link_get_permanent_address) (NMPlatform *,
|
|
|
|
|
int ifindex,
|
|
|
|
|
guint8 *buf,
|
|
|
|
|
size_t *length);
|
2016-07-05 10:41:18 +02:00
|
|
|
NMPlatformError (*link_set_address) (NMPlatform *, int ifindex, gconstpointer address, size_t length);
|
2013-04-15 21:48:12 +02:00
|
|
|
gboolean (*link_set_mtu) (NMPlatform *, int ifindex, guint32 mtu);
|
2017-07-03 10:10:34 +02:00
|
|
|
gboolean (*link_set_name) (NMPlatform *, int ifindex, const char *name);
|
2017-04-14 23:03:33 +02:00
|
|
|
gboolean (*link_set_sriov_num_vfs) (NMPlatform *, int ifindex, guint num_vfs);
|
2013-03-27 22:53:55 +01:00
|
|
|
|
2015-03-24 12:35:36 -05:00
|
|
|
char * (*link_get_physical_port_id) (NMPlatform *, int ifindex);
|
|
|
|
|
guint (*link_get_dev_id) (NMPlatform *, int ifindex);
|
2014-02-05 11:56:44 +01:00
|
|
|
gboolean (*link_get_wake_on_lan) (NMPlatform *, int ifindex);
|
2014-10-03 13:41:49 -05:00
|
|
|
gboolean (*link_get_driver_info) (NMPlatform *,
|
|
|
|
|
int ifindex,
|
|
|
|
|
char **out_driver_name,
|
|
|
|
|
char **out_driver_version,
|
|
|
|
|
char **out_fw_version);
|
2013-10-11 14:59:26 -04:00
|
|
|
|
2013-03-27 22:53:55 +01:00
|
|
|
gboolean (*link_supports_carrier_detect) (NMPlatform *, int ifindex);
|
|
|
|
|
gboolean (*link_supports_vlans) (NMPlatform *, int ifindex);
|
2017-04-14 23:03:33 +02:00
|
|
|
gboolean (*link_supports_sriov) (NMPlatform *, int ifindex);
|
2013-03-27 22:53:55 +01:00
|
|
|
|
2013-03-27 22:53:55 +01:00
|
|
|
gboolean (*link_enslave) (NMPlatform *, int master, int slave);
|
|
|
|
|
gboolean (*link_release) (NMPlatform *, int master, int slave);
|
|
|
|
|
|
2016-03-21 15:22:10 +01:00
|
|
|
gboolean (*link_can_assume) (NMPlatform *, int ifindex);
|
|
|
|
|
|
2015-12-09 15:13:57 +01:00
|
|
|
gboolean (*vlan_add) (NMPlatform *, const char *name, int parent, int vlanid, guint32 vlanflags, const NMPlatformLink **out_link);
|
2015-10-27 16:14:54 +01:00
|
|
|
gboolean (*link_vlan_change) (NMPlatform *self,
|
|
|
|
|
int ifindex,
|
|
|
|
|
NMVlanFlags flags_mask,
|
|
|
|
|
NMVlanFlags flags_set,
|
|
|
|
|
gboolean ingress_reset_all,
|
|
|
|
|
const NMVlanQosMapping *ingress_map,
|
|
|
|
|
gsize n_ingress_map,
|
|
|
|
|
gboolean egress_reset_all,
|
|
|
|
|
const NMVlanQosMapping *egress_map,
|
|
|
|
|
gsize n_egress_map);
|
2015-12-11 13:34:50 +01:00
|
|
|
gboolean (*link_vxlan_add) (NMPlatform *,
|
|
|
|
|
const char *name,
|
|
|
|
|
const NMPlatformLnkVxlan *props,
|
2015-12-09 15:13:57 +01:00
|
|
|
const NMPlatformLink **out_link);
|
2015-12-11 13:34:50 +01:00
|
|
|
gboolean (*link_gre_add) (NMPlatform *,
|
|
|
|
|
const char *name,
|
|
|
|
|
const NMPlatformLnkGre *props,
|
2015-12-09 15:13:57 +01:00
|
|
|
const NMPlatformLink **out_link);
|
2015-12-11 13:34:50 +01:00
|
|
|
gboolean (*link_ip6tnl_add) (NMPlatform *,
|
|
|
|
|
const char *name,
|
|
|
|
|
const NMPlatformLnkIp6Tnl *props,
|
2015-12-09 15:13:57 +01:00
|
|
|
const NMPlatformLink **out_link);
|
2015-12-11 13:34:50 +01:00
|
|
|
gboolean (*link_ipip_add) (NMPlatform *,
|
|
|
|
|
const char *name,
|
|
|
|
|
const NMPlatformLnkIpIp *props,
|
2015-12-09 15:13:57 +01:00
|
|
|
const NMPlatformLink **out_link);
|
2016-06-30 18:20:09 +02:00
|
|
|
gboolean (*link_macsec_add) (NMPlatform *,
|
|
|
|
|
const char *name,
|
|
|
|
|
int parent,
|
|
|
|
|
const NMPlatformLnkMacsec *props,
|
|
|
|
|
const NMPlatformLink **out_link);
|
2015-12-11 13:34:50 +01:00
|
|
|
gboolean (*link_macvlan_add) (NMPlatform *,
|
|
|
|
|
const char *name,
|
|
|
|
|
int parent,
|
|
|
|
|
const NMPlatformLnkMacvlan *props,
|
2015-12-09 15:13:57 +01:00
|
|
|
const NMPlatformLink **out_link);
|
2015-12-11 13:34:50 +01:00
|
|
|
gboolean (*link_sit_add) (NMPlatform *,
|
|
|
|
|
const char *name,
|
|
|
|
|
const NMPlatformLnkSit *props,
|
2015-12-09 15:13:57 +01:00
|
|
|
const NMPlatformLink **out_link);
|
2015-09-01 22:11:47 +02:00
|
|
|
|
2015-12-09 15:13:57 +01:00
|
|
|
gboolean (*infiniband_partition_add) (NMPlatform *, int parent, int p_key, const NMPlatformLink **out_link);
|
2016-04-20 09:16:21 +02:00
|
|
|
gboolean (*infiniband_partition_delete) (NMPlatform *, int parent, int p_key);
|
2013-06-10 16:21:08 -03:00
|
|
|
|
2015-09-15 15:07:37 +02:00
|
|
|
gboolean (*tun_add) (NMPlatform *platform, const char *name, gboolean tap, gint64 owner, gint64 group, gboolean pi,
|
2015-12-09 15:13:57 +01:00
|
|
|
gboolean vnet_hdr, gboolean multi_queue, const NMPlatformLink **out_link);
|
2015-09-15 15:07:37 +02:00
|
|
|
|
2014-02-04 14:27:03 +01:00
|
|
|
gboolean (*wifi_get_capabilities) (NMPlatform *, int ifindex, NMDeviceWifiCapabilities *caps);
|
2014-07-07 12:04:14 -04:00
|
|
|
gboolean (*wifi_get_bssid) (NMPlatform *, int ifindex, guint8 *bssid);
|
2014-02-04 14:27:03 +01:00
|
|
|
GByteArray *(*wifi_get_ssid) (NMPlatform *, int ifindex);
|
|
|
|
|
guint32 (*wifi_get_frequency) (NMPlatform *, int ifindex);
|
|
|
|
|
int (*wifi_get_quality) (NMPlatform *, int ifindex);
|
|
|
|
|
guint32 (*wifi_get_rate) (NMPlatform *, int ifindex);
|
|
|
|
|
NM80211Mode (*wifi_get_mode) (NMPlatform *, int ifindex);
|
|
|
|
|
void (*wifi_set_mode) (NMPlatform *, int ifindex, NM80211Mode mode);
|
2014-10-23 14:19:59 -04:00
|
|
|
void (*wifi_set_powersave) (NMPlatform *, int ifindex, guint32 powersave);
|
2014-02-04 14:27:03 +01:00
|
|
|
guint32 (*wifi_find_frequency) (NMPlatform *, int ifindex, const guint32 *freqs);
|
|
|
|
|
void (*wifi_indicate_addressing_running) (NMPlatform *, int ifindex, gboolean running);
|
|
|
|
|
|
|
|
|
|
guint32 (*mesh_get_channel) (NMPlatform *, int ifindex);
|
|
|
|
|
gboolean (*mesh_set_channel) (NMPlatform *, int ifindex, guint32 channel);
|
2014-06-26 10:42:11 -04:00
|
|
|
gboolean (*mesh_set_ssid) (NMPlatform *, int ifindex, const guint8 *ssid, gsize len);
|
2014-02-04 14:27:03 +01:00
|
|
|
|
2015-10-10 19:58:59 +02:00
|
|
|
gboolean (*ip4_address_add) (NMPlatform *,
|
|
|
|
|
int ifindex,
|
|
|
|
|
in_addr_t address,
|
2016-04-06 18:04:26 +02:00
|
|
|
guint8 plen,
|
2015-10-10 19:58:59 +02:00
|
|
|
in_addr_t peer_address,
|
|
|
|
|
guint32 lifetime,
|
|
|
|
|
guint32 preferred_lft,
|
2016-02-29 17:06:21 +01:00
|
|
|
guint32 flags,
|
2014-02-19 16:10:59 -05:00
|
|
|
const char *label);
|
2015-10-10 19:58:59 +02:00
|
|
|
gboolean (*ip6_address_add) (NMPlatform *,
|
|
|
|
|
int ifindex,
|
|
|
|
|
struct in6_addr address,
|
2016-04-06 18:04:26 +02:00
|
|
|
guint8 plen,
|
2015-10-10 19:58:59 +02:00
|
|
|
struct in6_addr peer_address,
|
|
|
|
|
guint32 lifetime,
|
|
|
|
|
guint32 preferred_lft,
|
2016-02-29 15:36:12 +01:00
|
|
|
guint32 flags);
|
2016-04-06 18:04:26 +02:00
|
|
|
gboolean (*ip4_address_delete) (NMPlatform *, int ifindex, in_addr_t address, guint8 plen, in_addr_t peer_address);
|
|
|
|
|
gboolean (*ip6_address_delete) (NMPlatform *, int ifindex, struct in6_addr address, guint8 plen);
|
2013-03-27 22:23:24 +01:00
|
|
|
|
2017-08-21 15:33:57 +02:00
|
|
|
NMPlatformError (*ip_route_add) (NMPlatform *,
|
|
|
|
|
NMPNlmFlags flags,
|
|
|
|
|
int addr_family,
|
|
|
|
|
const NMPlatformIPRoute *route);
|
platform: pass full route object to platform delete function
Contrary to addresses, routes have no ID. When deleting a route,
you cannot just specify certain properties like network/plen,metric.
Well, actually you can specify only certain properties, but then kernel
will treat unspecified properties as wildcard and delete the first matching
route. That is not something we want, because we need to be in control which
exact route shall be deleted.
Also, rtm_tos *must* match. Even if we like the wildcard behavior,
we would need to pass TOS to nm_platform_ip4_route_delete() to be
able to delete routes with non-zero TOS. So, while certain properties
may be omitted, some must not. See how test_ip4_route_options() was
broken.
For NetworkManager it only makes ever sense to call delete on a route,
if the route is already fully known. Which means, we only delete routes
that we have already in the platform cache (otherwise, how would we know
that there is something to delete). Because of that, no longer have separate
IPv4 and IPv6 functions. Instead, have nm_platform_ip_route_delete() which
accepts a full NMPObject from the platform cache.
The code in core doesn't jet make use of this new functionality. It will
in the future.
At least, it fixes deleting routes with differing TOS.
2017-07-11 16:38:49 +02:00
|
|
|
gboolean (*ip_route_delete) (NMPlatform *, const NMPObject *obj);
|
2014-01-07 17:21:12 +01:00
|
|
|
|
2017-08-16 16:13:24 +02:00
|
|
|
NMPlatformError (*ip_route_get) (NMPlatform *self,
|
|
|
|
|
int addr_family,
|
|
|
|
|
gconstpointer address,
|
2017-09-07 11:11:32 +02:00
|
|
|
int oif_ifindex,
|
2017-08-16 16:13:24 +02:00
|
|
|
NMPObject **out_route);
|
|
|
|
|
|
2017-10-10 18:20:05 +02:00
|
|
|
NMPlatformKernelSupportFlags (*check_kernel_support) (NMPlatform * self,
|
|
|
|
|
NMPlatformKernelSupportFlags request_flags);
|
2013-03-27 22:23:24 +01:00
|
|
|
} NMPlatformClass;
|
|
|
|
|
|
|
|
|
|
/* NMPlatform signals
|
|
|
|
|
*
|
|
|
|
|
* Each signal handler is called with a type-specific object that provides
|
|
|
|
|
* key attributes that constitute identity of the object. They may also
|
|
|
|
|
* provide additional attributes for convenience.
|
|
|
|
|
*
|
|
|
|
|
* The object only intended to be used by the signal handler to determine
|
|
|
|
|
* the current values. It is no longer valid after the signal handler exits
|
|
|
|
|
* but you are free to copy the provided information and use it for later
|
|
|
|
|
* reference.
|
|
|
|
|
*/
|
2014-03-07 19:04:38 +01:00
|
|
|
#define NM_PLATFORM_SIGNAL_LINK_CHANGED "link-changed"
|
|
|
|
|
#define NM_PLATFORM_SIGNAL_IP4_ADDRESS_CHANGED "ip4-address-changed"
|
|
|
|
|
#define NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED "ip6-address-changed"
|
|
|
|
|
#define NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED "ip4-route-changed"
|
|
|
|
|
#define NM_PLATFORM_SIGNAL_IP6_ROUTE_CHANGED "ip6-route-changed"
|
2013-03-27 22:23:24 +01:00
|
|
|
|
2015-04-24 12:28:07 +02:00
|
|
|
const char *nm_platform_signal_change_type_to_string (NMPlatformSignalChangeType change_type);
|
|
|
|
|
|
2016-10-02 18:22:50 +02:00
|
|
|
/*****************************************************************************/
|
2013-03-27 22:23:24 +01:00
|
|
|
|
|
|
|
|
GType nm_platform_get_type (void);
|
|
|
|
|
|
2015-04-18 13:37:36 +02:00
|
|
|
void nm_platform_setup (NMPlatform *instance);
|
2013-03-27 22:23:24 +01:00
|
|
|
NMPlatform *nm_platform_get (void);
|
|
|
|
|
|
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".
2015-04-18 12:36:09 +02:00
|
|
|
#define NM_PLATFORM_GET (nm_platform_get ())
|
|
|
|
|
|
2016-10-02 18:22:50 +02:00
|
|
|
/*****************************************************************************/
|
2013-03-27 22:23:24 +01:00
|
|
|
|
2017-08-21 23:17:12 +02:00
|
|
|
/**
|
|
|
|
|
* nm_platform_route_table_coerce:
|
2017-09-22 15:26:56 +02:00
|
|
|
* @table: the route table, in its original value as received
|
|
|
|
|
* from rtm_table/RTA_TABLE.
|
2017-08-21 23:17:12 +02:00
|
|
|
*
|
2017-09-22 15:26:56 +02:00
|
|
|
* Returns: returns the coerced table id, that can be stored in
|
|
|
|
|
* NMPlatformIPRoute.table_coerced.
|
2017-08-21 23:17:12 +02:00
|
|
|
*/
|
|
|
|
|
static inline guint32
|
|
|
|
|
nm_platform_route_table_coerce (guint32 table)
|
|
|
|
|
{
|
2017-09-22 15:26:56 +02:00
|
|
|
/* For kernel, the default table is RT_TABLE_MAIN (254).
|
|
|
|
|
* We want that in NMPlatformIPRoute.table_coerced a numeric
|
|
|
|
|
* zero is the default. Hence, @table_coerced swaps the
|
|
|
|
|
* value 0 and 254. Use nm_platform_route_table_coerce()
|
|
|
|
|
* and nm_platform_route_table_uncoerce() to convert between
|
|
|
|
|
* the two domains. */
|
2017-08-21 23:17:12 +02:00
|
|
|
switch (table) {
|
|
|
|
|
case 0 /* RT_TABLE_UNSPEC */:
|
|
|
|
|
return 254;
|
|
|
|
|
case 254 /* RT_TABLE_MAIN */:
|
|
|
|
|
return 0;
|
|
|
|
|
default:
|
|
|
|
|
return table;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-22 15:26:56 +02:00
|
|
|
/**
|
|
|
|
|
* nm_platform_route_table_uncoerce:
|
|
|
|
|
* @table: the route table, in its coerced value
|
|
|
|
|
* @normalize: whether to normalize RT_TABLE_UNSPEC to
|
|
|
|
|
* RT_TABLE_MAIN. For kernel, routes with a table id
|
|
|
|
|
* RT_TABLE_UNSPEC do not exist and are treated like
|
|
|
|
|
* RT_TABLE_MAIN.
|
|
|
|
|
*
|
|
|
|
|
* Returns: reverts the coerced table ID in NMPlatformIPRoute.table_coerced
|
|
|
|
|
* to the original value as kernel understands it.
|
|
|
|
|
*/
|
|
|
|
|
static inline guint32
|
|
|
|
|
nm_platform_route_table_uncoerce (guint32 table_coerced, gboolean normalize)
|
|
|
|
|
{
|
|
|
|
|
/* this undoes nm_platform_route_table_coerce(). */
|
|
|
|
|
switch (table_coerced) {
|
|
|
|
|
case 0 /* RT_TABLE_UNSPEC */:
|
|
|
|
|
return 254;
|
|
|
|
|
case 254 /* RT_TABLE_MAIN */:
|
|
|
|
|
return normalize ? 254 : 0;
|
|
|
|
|
default:
|
|
|
|
|
return table_coerced;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline gboolean
|
|
|
|
|
nm_platform_route_table_is_main (guint32 table)
|
|
|
|
|
{
|
|
|
|
|
/* same as
|
|
|
|
|
* nm_platform_route_table_uncoerce (table, TRUE) == RT_TABLE_MAIN
|
|
|
|
|
* and
|
|
|
|
|
* nm_platform_route_table_uncoerce (nm_platform_route_table_coerce (table), TRUE) == RT_TABLE_MAIN
|
|
|
|
|
*
|
|
|
|
|
* That is, the function operates the same on @table and its coerced
|
|
|
|
|
* form.
|
|
|
|
|
*/
|
|
|
|
|
return table == 0 || table == 254;
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-03 10:47:41 +02:00
|
|
|
/**
|
|
|
|
|
* nm_platform_route_scope_inv:
|
|
|
|
|
* @scope: the route scope, either its original value, or its inverse.
|
|
|
|
|
*
|
|
|
|
|
* This function is useful, because the constants such as RT_SCOPE_NOWHERE
|
|
|
|
|
* are 'int', so ~scope also gives an 'int'. This function gets the type
|
|
|
|
|
* casts to guint8 right.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the bitwise inverse of the route scope.
|
|
|
|
|
* */
|
2015-06-25 18:44:58 +02:00
|
|
|
#define nm_platform_route_scope_inv _nm_platform_uint8_inv
|
2015-05-03 10:47:41 +02:00
|
|
|
static inline guint8
|
2015-06-25 18:44:58 +02:00
|
|
|
_nm_platform_uint8_inv (guint8 scope)
|
2015-05-03 10:47:41 +02:00
|
|
|
{
|
|
|
|
|
return (guint8) ~scope;
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-29 10:51:38 +02:00
|
|
|
gboolean nm_platform_get_use_udev (NMPlatform *self);
|
2017-04-17 18:40:52 +02:00
|
|
|
gboolean nm_platform_get_log_with_ptr (NMPlatform *self);
|
|
|
|
|
|
2016-02-19 01:06:28 +01:00
|
|
|
NMPNetns *nm_platform_netns_get (NMPlatform *self);
|
|
|
|
|
gboolean nm_platform_netns_push (NMPlatform *platform, NMPNetns **netns);
|
|
|
|
|
|
2015-04-28 07:55:30 +02:00
|
|
|
const char *nm_link_type_to_string (NMLinkType link_type);
|
|
|
|
|
|
2017-08-21 19:18:45 +02:00
|
|
|
const char *nm_platform_error_to_string (NMPlatformError error,
|
|
|
|
|
char *buf,
|
|
|
|
|
gsize buf_len);
|
|
|
|
|
#define nm_platform_error_to_string_a(error) \
|
|
|
|
|
(nm_platform_error_to_string ((error), g_alloca (30), 30))
|
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".
2015-04-18 12:36:09 +02:00
|
|
|
|
2016-12-08 14:29:00 +01:00
|
|
|
#define NMP_SYSCTL_PATHID_ABSOLUTE(path) \
|
|
|
|
|
((const char *) NULL), -1, (path)
|
|
|
|
|
|
2016-12-08 15:12:52 +01:00
|
|
|
#define NMP_SYSCTL_PATHID_NETDIR_unsafe(dirfd, ifname, path) \
|
|
|
|
|
nm_sprintf_bufa (NM_STRLEN ("net:/sys/class/net//\0") + IFNAMSIZ + strlen (path), \
|
|
|
|
|
"net:/sys/class/net/%s/%s", (ifname), (path)), \
|
|
|
|
|
(dirfd), (path)
|
|
|
|
|
|
|
|
|
|
#define NMP_SYSCTL_PATHID_NETDIR(dirfd, ifname, path) \
|
|
|
|
|
nm_sprintf_bufa (NM_STRLEN ("net:/sys/class/net//"path"/\0") + IFNAMSIZ, \
|
|
|
|
|
"net:/sys/class/net/%s/%s", (ifname), path), \
|
|
|
|
|
(dirfd), (""path"")
|
|
|
|
|
|
|
|
|
|
int nm_platform_sysctl_open_netdir (NMPlatform *self, int ifindex, char *out_ifname);
|
2016-12-08 14:29:00 +01:00
|
|
|
gboolean nm_platform_sysctl_set (NMPlatform *self, const char *pathid, int dirfd, const char *path, const char *value);
|
|
|
|
|
char *nm_platform_sysctl_get (NMPlatform *self, const char *pathid, int dirfd, const char *path);
|
|
|
|
|
gint32 nm_platform_sysctl_get_int32 (NMPlatform *self, const char *pathid, int dirfd, const char *path, gint32 fallback);
|
|
|
|
|
gint64 nm_platform_sysctl_get_int_checked (NMPlatform *self, const char *pathid, int dirfd, const char *path, guint base, gint64 min, gint64 max, gint64 fallback);
|
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".
2015-04-18 12:36:09 +02:00
|
|
|
|
2015-04-08 15:54:30 +02:00
|
|
|
gboolean nm_platform_sysctl_set_ip6_hop_limit_safe (NMPlatform *self, const char *iface, int value);
|
|
|
|
|
|
2016-12-26 11:54:30 +01:00
|
|
|
const char *nm_platform_if_indextoname (NMPlatform *self, int ifindex, char *out_ifname/* of size IFNAMSIZ */);
|
|
|
|
|
int nm_platform_if_nametoindex (NMPlatform *self, const char *ifname);
|
|
|
|
|
|
2017-07-04 12:49:47 +02:00
|
|
|
const NMPObject *nm_platform_link_get_obj (NMPlatform *self,
|
|
|
|
|
int ifindex,
|
|
|
|
|
gboolean visible_only);
|
2015-06-20 12:05:01 +02:00
|
|
|
const NMPlatformLink *nm_platform_link_get (NMPlatform *self, int ifindex);
|
|
|
|
|
const NMPlatformLink *nm_platform_link_get_by_ifname (NMPlatform *self, const char *ifname);
|
|
|
|
|
const NMPlatformLink *nm_platform_link_get_by_address (NMPlatform *self, gconstpointer address, size_t length);
|
|
|
|
|
|
2017-07-04 22:29:27 +02:00
|
|
|
GPtrArray *nm_platform_link_get_all (NMPlatform *self, gboolean sort_by_name);
|
2015-12-09 16:14:49 +01:00
|
|
|
NMPlatformError nm_platform_link_dummy_add (NMPlatform *self, const char *name, const NMPlatformLink **out_link);
|
|
|
|
|
NMPlatformError nm_platform_link_bridge_add (NMPlatform *self, const char *name, const void *address, size_t address_len, const NMPlatformLink **out_link);
|
|
|
|
|
NMPlatformError nm_platform_link_bond_add (NMPlatform *self, const char *name, const NMPlatformLink **out_link);
|
|
|
|
|
NMPlatformError nm_platform_link_team_add (NMPlatform *self, const char *name, const NMPlatformLink **out_link);
|
2017-05-26 14:00:29 +02:00
|
|
|
NMPlatformError nm_platform_link_veth_add (NMPlatform *self, const char *name, const char *peer, const NMPlatformLink **out_link);
|
|
|
|
|
|
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".
2015-04-18 12:36:09 +02:00
|
|
|
gboolean nm_platform_link_delete (NMPlatform *self, int ifindex);
|
2015-06-20 12:05:01 +02:00
|
|
|
|
2016-03-08 13:02:58 +01:00
|
|
|
gboolean nm_platform_link_set_netns (NMPlatform *self, int ifindex, int netns_fd);
|
|
|
|
|
|
2017-06-29 14:46:32 +02:00
|
|
|
struct _NMDedupMultiHeadEntry;
|
|
|
|
|
struct _NMPLookup;
|
|
|
|
|
const struct _NMDedupMultiHeadEntry *nm_platform_lookup (NMPlatform *platform,
|
|
|
|
|
const struct _NMPLookup *lookup);
|
|
|
|
|
|
2017-09-12 15:27:59 +02:00
|
|
|
gboolean nm_platform_lookup_predicate_routes_main (const NMPObject *obj,
|
|
|
|
|
gpointer user_data);
|
2017-08-21 23:17:12 +02:00
|
|
|
gboolean nm_platform_lookup_predicate_routes_main_skip_rtprot_kernel (const NMPObject *obj,
|
|
|
|
|
gpointer user_data);
|
2017-06-29 15:19:35 +02:00
|
|
|
|
|
|
|
|
GPtrArray *nm_platform_lookup_clone (NMPlatform *platform,
|
|
|
|
|
const struct _NMPLookup *lookup,
|
2017-08-14 14:52:55 +02:00
|
|
|
NMPObjectPredicateFunc predicate,
|
2017-06-29 15:19:35 +02:00
|
|
|
gpointer user_data);
|
|
|
|
|
|
2015-06-20 12:05:01 +02:00
|
|
|
/* convienience methods to lookup the link and access fields of NMPlatformLink. */
|
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".
2015-04-18 12:36:09 +02:00
|
|
|
int nm_platform_link_get_ifindex (NMPlatform *self, const char *name);
|
|
|
|
|
const char *nm_platform_link_get_name (NMPlatform *self, int ifindex);
|
|
|
|
|
NMLinkType nm_platform_link_get_type (NMPlatform *self, int ifindex);
|
|
|
|
|
gboolean nm_platform_link_is_software (NMPlatform *self, int ifindex);
|
2015-06-20 12:05:01 +02:00
|
|
|
gboolean nm_platform_link_is_up (NMPlatform *self, int ifindex);
|
|
|
|
|
gboolean nm_platform_link_is_connected (NMPlatform *self, int ifindex);
|
|
|
|
|
gboolean nm_platform_link_uses_arp (NMPlatform *self, int ifindex);
|
|
|
|
|
guint32 nm_platform_link_get_mtu (NMPlatform *self, int ifindex);
|
|
|
|
|
gboolean nm_platform_link_get_user_ipv6ll_enabled (NMPlatform *self, int ifindex);
|
|
|
|
|
gconstpointer nm_platform_link_get_address (NMPlatform *self, int ifindex, size_t *length);
|
|
|
|
|
int nm_platform_link_get_master (NMPlatform *self, int slave);
|
|
|
|
|
|
2016-03-21 15:22:10 +01:00
|
|
|
gboolean nm_platform_link_can_assume (NMPlatform *self, int ifindex);
|
|
|
|
|
|
2015-06-24 14:21:27 +02:00
|
|
|
gboolean nm_platform_link_get_unmanaged (NMPlatform *self, int ifindex, gboolean *unmanaged);
|
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".
2015-04-18 12:36:09 +02:00
|
|
|
gboolean nm_platform_link_supports_slaves (NMPlatform *self, int ifindex);
|
2015-06-20 12:05:01 +02:00
|
|
|
const char *nm_platform_link_get_type_name (NMPlatform *self, int ifindex);
|
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".
2015-04-18 12:36:09 +02:00
|
|
|
|
|
|
|
|
gboolean nm_platform_link_refresh (NMPlatform *self, int ifindex);
|
2015-06-19 15:38:41 +02:00
|
|
|
void nm_platform_process_events (NMPlatform *self);
|
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".
2015-04-18 12:36:09 +02:00
|
|
|
|
2015-06-15 17:41:27 +02:00
|
|
|
gboolean nm_platform_link_set_up (NMPlatform *self, int ifindex, gboolean *out_no_firmware);
|
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".
2015-04-18 12:36:09 +02:00
|
|
|
gboolean nm_platform_link_set_down (NMPlatform *self, int ifindex);
|
|
|
|
|
gboolean nm_platform_link_set_arp (NMPlatform *self, int ifindex);
|
|
|
|
|
gboolean nm_platform_link_set_noarp (NMPlatform *self, int ifindex);
|
|
|
|
|
|
2015-06-15 14:41:35 +02:00
|
|
|
const char *nm_platform_link_get_udi (NMPlatform *self, int ifindex);
|
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".
2015-04-18 12:36:09 +02:00
|
|
|
|
2017-03-12 15:54:02 +01:00
|
|
|
struct udev_device *nm_platform_link_get_udev_device (NMPlatform *self, int ifindex);
|
2015-06-15 15:19:28 +02:00
|
|
|
|
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 15:04:37 +02:00
|
|
|
NMPlatformError nm_platform_link_set_user_ipv6ll_enabled (NMPlatform *self, int ifindex, gboolean enabled);
|
2016-04-30 16:48:32 +02:00
|
|
|
gboolean nm_platform_link_set_ipv6_token (NMPlatform *self, int ifindex, NMUtilsIPv6IfaceId iid);
|
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".
2015-04-18 12:36:09 +02:00
|
|
|
|
2014-10-03 17:37:26 -05:00
|
|
|
gboolean nm_platform_link_get_permanent_address (NMPlatform *self, int ifindex, guint8 *buf, size_t *length);
|
2016-07-05 10:41:18 +02:00
|
|
|
NMPlatformError nm_platform_link_set_address (NMPlatform *self, int ifindex, const void *address, size_t length);
|
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".
2015-04-18 12:36:09 +02:00
|
|
|
gboolean nm_platform_link_set_mtu (NMPlatform *self, int ifindex, guint32 mtu);
|
2017-07-03 10:10:34 +02:00
|
|
|
gboolean nm_platform_link_set_name (NMPlatform *self, int ifindex, const char *name);
|
2017-04-14 23:03:33 +02:00
|
|
|
gboolean nm_platform_link_set_sriov_num_vfs (NMPlatform *self, int ifindex, guint num_vfs);
|
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".
2015-04-18 12:36:09 +02:00
|
|
|
|
|
|
|
|
char *nm_platform_link_get_physical_port_id (NMPlatform *self, int ifindex);
|
|
|
|
|
guint nm_platform_link_get_dev_id (NMPlatform *self, int ifindex);
|
|
|
|
|
gboolean nm_platform_link_get_wake_on_lan (NMPlatform *self, int ifindex);
|
2014-10-03 13:41:49 -05:00
|
|
|
gboolean nm_platform_link_get_driver_info (NMPlatform *self,
|
|
|
|
|
int ifindex,
|
|
|
|
|
char **out_driver_name,
|
|
|
|
|
char **out_driver_version,
|
|
|
|
|
char **out_fw_version);
|
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".
2015-04-18 12:36:09 +02:00
|
|
|
|
|
|
|
|
gboolean nm_platform_link_supports_carrier_detect (NMPlatform *self, int ifindex);
|
|
|
|
|
gboolean nm_platform_link_supports_vlans (NMPlatform *self, int ifindex);
|
2017-04-14 23:03:33 +02:00
|
|
|
gboolean nm_platform_link_supports_sriov (NMPlatform *self, int ifindex);
|
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".
2015-04-18 12:36:09 +02:00
|
|
|
|
|
|
|
|
gboolean nm_platform_link_enslave (NMPlatform *self, int master, int slave);
|
|
|
|
|
gboolean nm_platform_link_release (NMPlatform *self, int master, int slave);
|
2015-12-09 16:14:49 +01:00
|
|
|
|
2015-12-09 17:33:30 +01:00
|
|
|
gboolean nm_platform_sysctl_master_set_option (NMPlatform *self, int ifindex, const char *option, const char *value);
|
|
|
|
|
char *nm_platform_sysctl_master_get_option (NMPlatform *self, int ifindex, const char *option);
|
|
|
|
|
gboolean nm_platform_sysctl_slave_set_option (NMPlatform *self, int ifindex, const char *option, const char *value);
|
|
|
|
|
char *nm_platform_sysctl_slave_get_option (NMPlatform *self, int ifindex, const char *option);
|
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".
2015-04-18 12:36:09 +02:00
|
|
|
|
2015-10-29 11:27:55 +01:00
|
|
|
const NMPObject *nm_platform_link_get_lnk (NMPlatform *self, int ifindex, NMLinkType link_type, const NMPlatformLink **out_link);
|
2015-10-12 15:15:21 +02:00
|
|
|
const NMPlatformLnkGre *nm_platform_link_get_lnk_gre (NMPlatform *self, int ifindex, const NMPlatformLink **out_link);
|
2015-11-27 22:22:25 +01:00
|
|
|
const NMPlatformLnkIp6Tnl *nm_platform_link_get_lnk_ip6tnl (NMPlatform *self, int ifindex, const NMPlatformLink **out_link);
|
|
|
|
|
const NMPlatformLnkIpIp *nm_platform_link_get_lnk_ipip (NMPlatform *self, int ifindex, const NMPlatformLink **out_link);
|
2015-10-15 15:47:14 +02:00
|
|
|
const NMPlatformLnkInfiniband *nm_platform_link_get_lnk_infiniband (NMPlatform *self, int ifindex, const NMPlatformLink **out_link);
|
2015-11-27 14:01:56 +01:00
|
|
|
const NMPlatformLnkIpIp *nm_platform_link_get_lnk_ipip (NMPlatform *self, int ifindex, const NMPlatformLink **out_link);
|
2016-06-30 18:20:09 +02:00
|
|
|
const NMPlatformLnkMacsec *nm_platform_link_get_lnk_macsec (NMPlatform *self, int ifindex, const NMPlatformLink **out_link);
|
2015-10-12 15:15:21 +02:00
|
|
|
const NMPlatformLnkMacvlan *nm_platform_link_get_lnk_macvlan (NMPlatform *self, int ifindex, const NMPlatformLink **out_link);
|
2015-12-04 09:49:39 +01:00
|
|
|
const NMPlatformLnkMacvtap *nm_platform_link_get_lnk_macvtap (NMPlatform *self, int ifindex, const NMPlatformLink **out_link);
|
2015-11-11 18:41:48 +01:00
|
|
|
const NMPlatformLnkSit *nm_platform_link_get_lnk_sit (NMPlatform *self, int ifindex, const NMPlatformLink **out_link);
|
2015-10-12 13:44:44 +02:00
|
|
|
const NMPlatformLnkVlan *nm_platform_link_get_lnk_vlan (NMPlatform *self, int ifindex, const NMPlatformLink **out_link);
|
2015-10-12 15:15:21 +02:00
|
|
|
const NMPlatformLnkVxlan *nm_platform_link_get_lnk_vxlan (NMPlatform *self, int ifindex, const NMPlatformLink **out_link);
|
2015-10-12 13:44:44 +02:00
|
|
|
|
2015-12-11 13:34:50 +01:00
|
|
|
NMPlatformError nm_platform_link_vlan_add (NMPlatform *self,
|
|
|
|
|
const char *name,
|
|
|
|
|
int parent,
|
|
|
|
|
int vlanid,
|
|
|
|
|
guint32 vlanflags,
|
|
|
|
|
const NMPlatformLink **out_link);
|
2015-12-09 16:14:49 +01:00
|
|
|
gboolean nm_platform_link_vlan_set_ingress_map (NMPlatform *self, int ifindex, int from, int to);
|
|
|
|
|
gboolean nm_platform_link_vlan_set_egress_map (NMPlatform *self, int ifindex, int from, int to);
|
2015-10-27 16:14:54 +01:00
|
|
|
gboolean nm_platform_link_vlan_change (NMPlatform *self,
|
|
|
|
|
int ifindex,
|
|
|
|
|
NMVlanFlags flags_mask,
|
|
|
|
|
NMVlanFlags flags_set,
|
|
|
|
|
gboolean ingress_reset_all,
|
|
|
|
|
const NMVlanQosMapping *ingress_map,
|
|
|
|
|
gsize n_ingress_map,
|
|
|
|
|
gboolean egress_reset_all,
|
|
|
|
|
const NMVlanQosMapping *egress_map,
|
|
|
|
|
gsize n_egress_map);
|
|
|
|
|
|
2015-12-11 13:34:50 +01:00
|
|
|
NMPlatformError nm_platform_link_vxlan_add (NMPlatform *self,
|
|
|
|
|
const char *name,
|
|
|
|
|
const NMPlatformLnkVxlan *props,
|
|
|
|
|
const NMPlatformLink **out_link);
|
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".
2015-04-18 12:36:09 +02:00
|
|
|
|
2015-12-09 16:14:49 +01:00
|
|
|
NMPlatformError nm_platform_link_tun_add (NMPlatform *self,
|
|
|
|
|
const char *name,
|
|
|
|
|
gboolean tap,
|
|
|
|
|
gint64 owner,
|
|
|
|
|
gint64 group,
|
|
|
|
|
gboolean pi,
|
|
|
|
|
gboolean vnet_hdr,
|
|
|
|
|
gboolean multi_queue,
|
|
|
|
|
const NMPlatformLink **out_link);
|
2015-09-15 15:07:37 +02:00
|
|
|
|
2015-12-11 13:34:50 +01:00
|
|
|
NMPlatformError nm_platform_link_infiniband_add (NMPlatform *self,
|
|
|
|
|
int parent,
|
|
|
|
|
int p_key,
|
|
|
|
|
const NMPlatformLink **out_link);
|
2016-04-20 09:16:21 +02:00
|
|
|
NMPlatformError nm_platform_link_infiniband_delete (NMPlatform *self,
|
|
|
|
|
int parent,
|
|
|
|
|
int p_key);
|
2015-12-09 16:14:49 +01:00
|
|
|
gboolean nm_platform_link_infiniband_get_properties (NMPlatform *self, int ifindex, int *parent, int *p_key, const char **mode);
|
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".
2015-04-18 12:36:09 +02:00
|
|
|
|
2015-12-09 16:14:49 +01:00
|
|
|
gboolean nm_platform_link_veth_get_properties (NMPlatform *self, int ifindex, int *out_peer_ifindex);
|
2017-01-16 15:51:05 +01:00
|
|
|
gboolean nm_platform_link_tun_get_properties (NMPlatform *self, int ifindex, NMPlatformTunProperties *properties);
|
2015-10-13 16:08:30 +02:00
|
|
|
|
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".
2015-04-18 12:36:09 +02:00
|
|
|
gboolean nm_platform_wifi_get_capabilities (NMPlatform *self, int ifindex, NMDeviceWifiCapabilities *caps);
|
|
|
|
|
gboolean nm_platform_wifi_get_bssid (NMPlatform *self, int ifindex, guint8 *bssid);
|
|
|
|
|
guint32 nm_platform_wifi_get_frequency (NMPlatform *self, int ifindex);
|
|
|
|
|
int nm_platform_wifi_get_quality (NMPlatform *self, int ifindex);
|
|
|
|
|
guint32 nm_platform_wifi_get_rate (NMPlatform *self, int ifindex);
|
|
|
|
|
NM80211Mode nm_platform_wifi_get_mode (NMPlatform *self, int ifindex);
|
|
|
|
|
void nm_platform_wifi_set_mode (NMPlatform *self, int ifindex, NM80211Mode mode);
|
|
|
|
|
void nm_platform_wifi_set_powersave (NMPlatform *self, int ifindex, guint32 powersave);
|
|
|
|
|
guint32 nm_platform_wifi_find_frequency (NMPlatform *self, int ifindex, const guint32 *freqs);
|
|
|
|
|
void nm_platform_wifi_indicate_addressing_running (NMPlatform *self, int ifindex, gboolean running);
|
|
|
|
|
|
|
|
|
|
guint32 nm_platform_mesh_get_channel (NMPlatform *self, int ifindex);
|
|
|
|
|
gboolean nm_platform_mesh_set_channel (NMPlatform *self, int ifindex, guint32 channel);
|
|
|
|
|
gboolean nm_platform_mesh_set_ssid (NMPlatform *self, int ifindex, const guint8 *ssid, gsize len);
|
|
|
|
|
|
2016-04-06 18:04:26 +02:00
|
|
|
void nm_platform_ip4_address_set_addr (NMPlatformIP4Address *addr, in_addr_t address, guint8 plen);
|
2015-10-10 17:48:32 +02:00
|
|
|
const struct in6_addr *nm_platform_ip6_address_get_peer (const NMPlatformIP6Address *addr);
|
|
|
|
|
|
2016-04-06 18:04:26 +02:00
|
|
|
const NMPlatformIP4Address *nm_platform_ip4_address_get (NMPlatform *self, int ifindex, in_addr_t address, guint8 plen, in_addr_t peer_address);
|
2015-09-01 22:11:47 +02:00
|
|
|
|
2015-12-11 13:34:50 +01:00
|
|
|
NMPlatformError nm_platform_link_gre_add (NMPlatform *self,
|
|
|
|
|
const char *name,
|
|
|
|
|
const NMPlatformLnkGre *props,
|
2015-12-09 15:13:57 +01:00
|
|
|
const NMPlatformLink **out_link);
|
2015-12-11 13:34:50 +01:00
|
|
|
NMPlatformError nm_platform_link_ip6tnl_add (NMPlatform *self,
|
|
|
|
|
const char *name,
|
|
|
|
|
const NMPlatformLnkIp6Tnl *props,
|
2015-12-09 15:13:57 +01:00
|
|
|
const NMPlatformLink **out_link);
|
2015-12-11 13:34:50 +01:00
|
|
|
NMPlatformError nm_platform_link_ipip_add (NMPlatform *self,
|
|
|
|
|
const char *name,
|
|
|
|
|
const NMPlatformLnkIpIp *props,
|
2015-12-09 15:13:57 +01:00
|
|
|
const NMPlatformLink **out_link);
|
2016-06-30 18:20:09 +02:00
|
|
|
NMPlatformError nm_platform_link_macsec_add (NMPlatform *self,
|
|
|
|
|
const char *name,
|
|
|
|
|
int parent,
|
|
|
|
|
const NMPlatformLnkMacsec *props,
|
|
|
|
|
const NMPlatformLink **out_link);
|
2015-12-11 13:34:50 +01:00
|
|
|
NMPlatformError nm_platform_link_macvlan_add (NMPlatform *self,
|
|
|
|
|
const char *name,
|
|
|
|
|
int parent,
|
|
|
|
|
const NMPlatformLnkMacvlan *props,
|
2015-12-09 15:13:57 +01:00
|
|
|
const NMPlatformLink **out_link);
|
2015-12-11 13:34:50 +01:00
|
|
|
NMPlatformError nm_platform_link_sit_add (NMPlatform *self,
|
|
|
|
|
const char *name,
|
|
|
|
|
const NMPlatformLnkSit *props,
|
2015-12-09 15:13:57 +01:00
|
|
|
const NMPlatformLink **out_link);
|
2015-09-01 22:11:47 +02:00
|
|
|
|
2017-05-26 21:49:00 +02:00
|
|
|
const NMPlatformIP6Address *nm_platform_ip6_address_get (NMPlatform *self, int ifindex, struct in6_addr address);
|
platform: pass full route object to platform delete function
Contrary to addresses, routes have no ID. When deleting a route,
you cannot just specify certain properties like network/plen,metric.
Well, actually you can specify only certain properties, but then kernel
will treat unspecified properties as wildcard and delete the first matching
route. That is not something we want, because we need to be in control which
exact route shall be deleted.
Also, rtm_tos *must* match. Even if we like the wildcard behavior,
we would need to pass TOS to nm_platform_ip4_route_delete() to be
able to delete routes with non-zero TOS. So, while certain properties
may be omitted, some must not. See how test_ip4_route_options() was
broken.
For NetworkManager it only makes ever sense to call delete on a route,
if the route is already fully known. Which means, we only delete routes
that we have already in the platform cache (otherwise, how would we know
that there is something to delete). Because of that, no longer have separate
IPv4 and IPv6 functions. Instead, have nm_platform_ip_route_delete() which
accepts a full NMPObject from the platform cache.
The code in core doesn't jet make use of this new functionality. It will
in the future.
At least, it fixes deleting routes with differing TOS.
2017-07-11 16:38:49 +02:00
|
|
|
|
2015-10-10 19:58:59 +02:00
|
|
|
gboolean nm_platform_ip4_address_add (NMPlatform *self,
|
|
|
|
|
int ifindex,
|
|
|
|
|
in_addr_t address,
|
2016-04-06 18:04:26 +02:00
|
|
|
guint8 plen,
|
2015-10-10 19:58:59 +02:00
|
|
|
in_addr_t peer_address,
|
|
|
|
|
guint32 lifetime,
|
|
|
|
|
guint32 preferred_lft,
|
2016-02-29 17:06:21 +01:00
|
|
|
guint32 flags,
|
2014-02-19 16:10:59 -05:00
|
|
|
const char *label);
|
2015-10-10 19:58:59 +02:00
|
|
|
gboolean nm_platform_ip6_address_add (NMPlatform *self,
|
|
|
|
|
int ifindex,
|
|
|
|
|
struct in6_addr address,
|
2016-04-06 18:04:26 +02:00
|
|
|
guint8 plen,
|
2015-10-10 19:58:59 +02:00
|
|
|
struct in6_addr peer_address,
|
|
|
|
|
guint32 lifetime,
|
|
|
|
|
guint32 preferred_lft,
|
2016-02-29 15:36:12 +01:00
|
|
|
guint32 flags);
|
2016-04-06 18:04:26 +02:00
|
|
|
gboolean nm_platform_ip4_address_delete (NMPlatform *self, int ifindex, in_addr_t address, guint8 plen, in_addr_t peer_address);
|
|
|
|
|
gboolean nm_platform_ip6_address_delete (NMPlatform *self, int ifindex, struct in6_addr address, guint8 plen);
|
2017-07-11 14:25:08 +02:00
|
|
|
gboolean nm_platform_ip4_address_sync (NMPlatform *self, int ifindex, GPtrArray *known_addresse);
|
|
|
|
|
gboolean nm_platform_ip6_address_sync (NMPlatform *self, int ifindex, const GPtrArray *known_addresses, gboolean keep_link_local);
|
2017-08-14 18:13:10 +02:00
|
|
|
gboolean nm_platform_ip_address_flush (NMPlatform *self,
|
|
|
|
|
int addr_family,
|
|
|
|
|
int ifindex);
|
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".
2015-04-18 12:36:09 +02:00
|
|
|
|
2017-08-17 13:37:21 +02:00
|
|
|
void nm_platform_ip_route_normalize (int addr_family,
|
|
|
|
|
NMPlatformIPRoute *route);
|
|
|
|
|
|
2017-08-21 15:33:57 +02:00
|
|
|
NMPlatformError nm_platform_ip_route_add (NMPlatform *self,
|
|
|
|
|
NMPNlmFlags flags,
|
|
|
|
|
const NMPObject *route);
|
|
|
|
|
NMPlatformError nm_platform_ip4_route_add (NMPlatform *self, NMPNlmFlags flags, const NMPlatformIP4Route *route);
|
|
|
|
|
NMPlatformError nm_platform_ip6_route_add (NMPlatform *self, NMPNlmFlags flags, const NMPlatformIP6Route *route);
|
2017-08-02 10:27:32 +02:00
|
|
|
|
platform: pass full route object to platform delete function
Contrary to addresses, routes have no ID. When deleting a route,
you cannot just specify certain properties like network/plen,metric.
Well, actually you can specify only certain properties, but then kernel
will treat unspecified properties as wildcard and delete the first matching
route. That is not something we want, because we need to be in control which
exact route shall be deleted.
Also, rtm_tos *must* match. Even if we like the wildcard behavior,
we would need to pass TOS to nm_platform_ip4_route_delete() to be
able to delete routes with non-zero TOS. So, while certain properties
may be omitted, some must not. See how test_ip4_route_options() was
broken.
For NetworkManager it only makes ever sense to call delete on a route,
if the route is already fully known. Which means, we only delete routes
that we have already in the platform cache (otherwise, how would we know
that there is something to delete). Because of that, no longer have separate
IPv4 and IPv6 functions. Instead, have nm_platform_ip_route_delete() which
accepts a full NMPObject from the platform cache.
The code in core doesn't jet make use of this new functionality. It will
in the future.
At least, it fixes deleting routes with differing TOS.
2017-07-11 16:38:49 +02:00
|
|
|
gboolean nm_platform_ip_route_delete (NMPlatform *self, const NMPObject *route);
|
2013-03-27 22:23:24 +01:00
|
|
|
|
core: inject route list to delete for nm_platform_ip_route_sync()
Whenever we call a platform operation that reads or writes the netlink
socket, there is the possibility that the cache gets updated, as we
receive netlink events.
It is thus racy, if nm_platform_ip_route_sync() *first* adds routes, and
then obtains a list of routes to delete. The correct approach is to
determine which routes to delete first (and keep it in a list
@routes_prune), and pass that list down to nm_platform_ip_route_sync().
Arguably, this doesn't yet solve every race. For example, NMDevice
calls update_ext_ip_config() during ip4_config_merge_and_apply().
That is good, as it resyncs with platform. However, before calling
nm_ip4_config_commit() it calls other platform operations, like
_commit_mtu(). So, the race is still there.
2017-09-22 12:37:12 +02:00
|
|
|
GPtrArray *nm_platform_ip_route_get_prune_list (NMPlatform *self,
|
|
|
|
|
int addr_family,
|
2017-09-13 17:42:41 +02:00
|
|
|
int ifindex,
|
|
|
|
|
NMIPRouteTableSyncMode route_table_sync);
|
core: inject route list to delete for nm_platform_ip_route_sync()
Whenever we call a platform operation that reads or writes the netlink
socket, there is the possibility that the cache gets updated, as we
receive netlink events.
It is thus racy, if nm_platform_ip_route_sync() *first* adds routes, and
then obtains a list of routes to delete. The correct approach is to
determine which routes to delete first (and keep it in a list
@routes_prune), and pass that list down to nm_platform_ip_route_sync().
Arguably, this doesn't yet solve every race. For example, NMDevice
calls update_ext_ip_config() during ip4_config_merge_and_apply().
That is good, as it resyncs with platform. However, before calling
nm_ip4_config_commit() it calls other platform operations, like
_commit_mtu(). So, the race is still there.
2017-09-22 12:37:12 +02:00
|
|
|
|
platform: add non-exclusive routes and drop route-manager
Previously, we would add exclusive routes via netlink message flags
NLM_F_CREATE | NLM_F_REPLACE for RTM_NEWROUTE. Similar to `ip route replace`.
Using that form of RTM_NEWROUTE message, we could only add a certain
route with a certain network/plen,metric triple once. That was already
hugely inconvenient, because
- when configuring routes, multiple (managed) interfaces may get
conflicting routes (multihoming). Only one of the routes can be actually
configured using `ip route replace`, so we need to track routes that are
currently shadowed.
- when configuring routes, we might replace externally configured
routes on unmanaged interfaces. We should not interfere with such
routes.
That was worked around by having NMRouteManager (and NMDefaultRouteManager).
NMRouteManager would keep a list of the routes which NetworkManager would like
to configure, even if momentarily being unable to do so due to conflicting routes.
This worked mostly well but was complicated. It involved bumping metrics to
avoid conflicts for device routes, as we might require them for gateway routes.
Drop that now. Instead, use the corresponding of `ip route append` to configure
routes. This allows NetworkManager to confiure (almost) all routes that we care.
Especially, it can configure all routes on a managed interface, without
replacing/interfering with routes on other interfaces. Hence, NMRouteManager
becomes obsolete.
It practice it is a bit more complicated because:
- when adding an IPv4 address, kernel will automatically create a device route
for the subnet. We should avoid that by using the IFA_F_NOPREFIXROUTE flag for
IPv4 addresses (still to-do). But as kernel may not support that flag for IPv4
addresses yet (and we don't require such a kernel yet), we still need functionality
similar to nm_route_manager_ip4_route_register_device_route_purge_list().
This functionality is now handled via nm_platform_ip4_dev_route_blacklist_set().
- trying to configure an IPv6 route with a source address will be rejected
by kernel as long as the address is tentative (see related bug rh#1457196).
Preferably, NMDevice would keep the list of routes which should be configured,
while kernel would have the list of what actually is configured. There is a
feed-back loop where both affect each other (for example, when externally deleting
a route, NMDevice must forget about it too). Previously, NMRouteManager would have
the task of remembering all routes which we currently want to configure, but cannot
due to conflicting routes.
We get rid of that, because now we configure non-exclusive routes. We however still
will need to remember IPv6 routes with a source address, that currently cannot be
configured yet. Hence, we will need to keep track of routes that
currently cannot be configured, but later may be.
That is still not done yet, as NMRouteManager didn't handle this
correctly either.
2017-08-14 14:18:53 +02:00
|
|
|
gboolean nm_platform_ip_route_sync (NMPlatform *self,
|
|
|
|
|
int addr_family,
|
|
|
|
|
int ifindex,
|
|
|
|
|
GPtrArray *routes,
|
core: inject route list to delete for nm_platform_ip_route_sync()
Whenever we call a platform operation that reads or writes the netlink
socket, there is the possibility that the cache gets updated, as we
receive netlink events.
It is thus racy, if nm_platform_ip_route_sync() *first* adds routes, and
then obtains a list of routes to delete. The correct approach is to
determine which routes to delete first (and keep it in a list
@routes_prune), and pass that list down to nm_platform_ip_route_sync().
Arguably, this doesn't yet solve every race. For example, NMDevice
calls update_ext_ip_config() during ip4_config_merge_and_apply().
That is good, as it resyncs with platform. However, before calling
nm_ip4_config_commit() it calls other platform operations, like
_commit_mtu(). So, the race is still there.
2017-09-22 12:37:12 +02:00
|
|
|
GPtrArray *routes_prune,
|
2017-09-13 16:45:22 +02:00
|
|
|
GPtrArray **out_temporary_not_available);
|
core: inject route list to delete for nm_platform_ip_route_sync()
Whenever we call a platform operation that reads or writes the netlink
socket, there is the possibility that the cache gets updated, as we
receive netlink events.
It is thus racy, if nm_platform_ip_route_sync() *first* adds routes, and
then obtains a list of routes to delete. The correct approach is to
determine which routes to delete first (and keep it in a list
@routes_prune), and pass that list down to nm_platform_ip_route_sync().
Arguably, this doesn't yet solve every race. For example, NMDevice
calls update_ext_ip_config() during ip4_config_merge_and_apply().
That is good, as it resyncs with platform. However, before calling
nm_ip4_config_commit() it calls other platform operations, like
_commit_mtu(). So, the race is still there.
2017-09-22 12:37:12 +02:00
|
|
|
|
platform: add non-exclusive routes and drop route-manager
Previously, we would add exclusive routes via netlink message flags
NLM_F_CREATE | NLM_F_REPLACE for RTM_NEWROUTE. Similar to `ip route replace`.
Using that form of RTM_NEWROUTE message, we could only add a certain
route with a certain network/plen,metric triple once. That was already
hugely inconvenient, because
- when configuring routes, multiple (managed) interfaces may get
conflicting routes (multihoming). Only one of the routes can be actually
configured using `ip route replace`, so we need to track routes that are
currently shadowed.
- when configuring routes, we might replace externally configured
routes on unmanaged interfaces. We should not interfere with such
routes.
That was worked around by having NMRouteManager (and NMDefaultRouteManager).
NMRouteManager would keep a list of the routes which NetworkManager would like
to configure, even if momentarily being unable to do so due to conflicting routes.
This worked mostly well but was complicated. It involved bumping metrics to
avoid conflicts for device routes, as we might require them for gateway routes.
Drop that now. Instead, use the corresponding of `ip route append` to configure
routes. This allows NetworkManager to confiure (almost) all routes that we care.
Especially, it can configure all routes on a managed interface, without
replacing/interfering with routes on other interfaces. Hence, NMRouteManager
becomes obsolete.
It practice it is a bit more complicated because:
- when adding an IPv4 address, kernel will automatically create a device route
for the subnet. We should avoid that by using the IFA_F_NOPREFIXROUTE flag for
IPv4 addresses (still to-do). But as kernel may not support that flag for IPv4
addresses yet (and we don't require such a kernel yet), we still need functionality
similar to nm_route_manager_ip4_route_register_device_route_purge_list().
This functionality is now handled via nm_platform_ip4_dev_route_blacklist_set().
- trying to configure an IPv6 route with a source address will be rejected
by kernel as long as the address is tentative (see related bug rh#1457196).
Preferably, NMDevice would keep the list of routes which should be configured,
while kernel would have the list of what actually is configured. There is a
feed-back loop where both affect each other (for example, when externally deleting
a route, NMDevice must forget about it too). Previously, NMRouteManager would have
the task of remembering all routes which we currently want to configure, but cannot
due to conflicting routes.
We get rid of that, because now we configure non-exclusive routes. We however still
will need to remember IPv6 routes with a source address, that currently cannot be
configured yet. Hence, we will need to keep track of routes that
currently cannot be configured, but later may be.
That is still not done yet, as NMRouteManager didn't handle this
correctly either.
2017-08-14 14:18:53 +02:00
|
|
|
gboolean nm_platform_ip_route_flush (NMPlatform *self,
|
|
|
|
|
int addr_family,
|
|
|
|
|
int ifindex);
|
2017-08-16 16:13:24 +02:00
|
|
|
|
|
|
|
|
NMPlatformError nm_platform_ip_route_get (NMPlatform *self,
|
|
|
|
|
int addr_family,
|
|
|
|
|
gconstpointer address,
|
2017-09-07 11:11:32 +02:00
|
|
|
int oif_ifindex,
|
2017-08-16 16:13:24 +02:00
|
|
|
NMPObject **out_route);
|
platform: add non-exclusive routes and drop route-manager
Previously, we would add exclusive routes via netlink message flags
NLM_F_CREATE | NLM_F_REPLACE for RTM_NEWROUTE. Similar to `ip route replace`.
Using that form of RTM_NEWROUTE message, we could only add a certain
route with a certain network/plen,metric triple once. That was already
hugely inconvenient, because
- when configuring routes, multiple (managed) interfaces may get
conflicting routes (multihoming). Only one of the routes can be actually
configured using `ip route replace`, so we need to track routes that are
currently shadowed.
- when configuring routes, we might replace externally configured
routes on unmanaged interfaces. We should not interfere with such
routes.
That was worked around by having NMRouteManager (and NMDefaultRouteManager).
NMRouteManager would keep a list of the routes which NetworkManager would like
to configure, even if momentarily being unable to do so due to conflicting routes.
This worked mostly well but was complicated. It involved bumping metrics to
avoid conflicts for device routes, as we might require them for gateway routes.
Drop that now. Instead, use the corresponding of `ip route append` to configure
routes. This allows NetworkManager to confiure (almost) all routes that we care.
Especially, it can configure all routes on a managed interface, without
replacing/interfering with routes on other interfaces. Hence, NMRouteManager
becomes obsolete.
It practice it is a bit more complicated because:
- when adding an IPv4 address, kernel will automatically create a device route
for the subnet. We should avoid that by using the IFA_F_NOPREFIXROUTE flag for
IPv4 addresses (still to-do). But as kernel may not support that flag for IPv4
addresses yet (and we don't require such a kernel yet), we still need functionality
similar to nm_route_manager_ip4_route_register_device_route_purge_list().
This functionality is now handled via nm_platform_ip4_dev_route_blacklist_set().
- trying to configure an IPv6 route with a source address will be rejected
by kernel as long as the address is tentative (see related bug rh#1457196).
Preferably, NMDevice would keep the list of routes which should be configured,
while kernel would have the list of what actually is configured. There is a
feed-back loop where both affect each other (for example, when externally deleting
a route, NMDevice must forget about it too). Previously, NMRouteManager would have
the task of remembering all routes which we currently want to configure, but cannot
due to conflicting routes.
We get rid of that, because now we configure non-exclusive routes. We however still
will need to remember IPv6 routes with a source address, that currently cannot be
configured yet. Hence, we will need to keep track of routes that
currently cannot be configured, but later may be.
That is still not done yet, as NMRouteManager didn't handle this
correctly either.
2017-08-14 14:18:53 +02:00
|
|
|
|
2015-10-12 10:27:33 +02:00
|
|
|
const char *nm_platform_link_to_string (const NMPlatformLink *link, char *buf, gsize len);
|
2015-10-12 15:15:21 +02:00
|
|
|
const char *nm_platform_lnk_gre_to_string (const NMPlatformLnkGre *lnk, char *buf, gsize len);
|
2015-10-15 15:47:14 +02:00
|
|
|
const char *nm_platform_lnk_infiniband_to_string (const NMPlatformLnkInfiniband *lnk, char *buf, gsize len);
|
2015-11-27 22:22:25 +01:00
|
|
|
const char *nm_platform_lnk_ip6tnl_to_string (const NMPlatformLnkIp6Tnl *lnk, char *buf, gsize len);
|
2015-11-27 14:01:56 +01:00
|
|
|
const char *nm_platform_lnk_ipip_to_string (const NMPlatformLnkIpIp *lnk, char *buf, gsize len);
|
2016-06-30 18:20:09 +02:00
|
|
|
const char *nm_platform_lnk_macsec_to_string (const NMPlatformLnkMacsec *lnk, char *buf, gsize len);
|
2015-10-12 15:15:21 +02:00
|
|
|
const char *nm_platform_lnk_macvlan_to_string (const NMPlatformLnkMacvlan *lnk, char *buf, gsize len);
|
2015-11-11 18:41:48 +01:00
|
|
|
const char *nm_platform_lnk_sit_to_string (const NMPlatformLnkSit *lnk, char *buf, gsize len);
|
2015-10-12 13:44:44 +02:00
|
|
|
const char *nm_platform_lnk_vlan_to_string (const NMPlatformLnkVlan *lnk, char *buf, gsize len);
|
2015-10-12 15:15:21 +02:00
|
|
|
const char *nm_platform_lnk_vxlan_to_string (const NMPlatformLnkVxlan *lnk, char *buf, gsize len);
|
2015-10-12 10:27:33 +02:00
|
|
|
const char *nm_platform_ip4_address_to_string (const NMPlatformIP4Address *address, char *buf, gsize len);
|
|
|
|
|
const char *nm_platform_ip6_address_to_string (const NMPlatformIP6Address *address, char *buf, gsize len);
|
|
|
|
|
const char *nm_platform_ip4_route_to_string (const NMPlatformIP4Route *route, char *buf, gsize len);
|
|
|
|
|
const char *nm_platform_ip6_route_to_string (const NMPlatformIP6Route *route, char *buf, gsize len);
|
2013-08-26 22:10:11 +02:00
|
|
|
|
2015-10-27 16:14:54 +01:00
|
|
|
const char *nm_platform_vlan_qos_mapping_to_string (const char *name,
|
|
|
|
|
const NMVlanQosMapping *map,
|
|
|
|
|
gsize n_map,
|
|
|
|
|
char *buf,
|
|
|
|
|
gsize len);
|
|
|
|
|
|
2014-04-05 18:35:20 +02:00
|
|
|
int nm_platform_link_cmp (const NMPlatformLink *a, const NMPlatformLink *b);
|
2015-10-12 15:15:21 +02:00
|
|
|
int nm_platform_lnk_gre_cmp (const NMPlatformLnkGre *a, const NMPlatformLnkGre *b);
|
2015-10-15 15:47:14 +02:00
|
|
|
int nm_platform_lnk_infiniband_cmp (const NMPlatformLnkInfiniband *a, const NMPlatformLnkInfiniband *b);
|
2015-11-27 22:22:25 +01:00
|
|
|
int nm_platform_lnk_ip6tnl_cmp (const NMPlatformLnkIp6Tnl *a, const NMPlatformLnkIp6Tnl *b);
|
2015-11-27 14:01:56 +01:00
|
|
|
int nm_platform_lnk_ipip_cmp (const NMPlatformLnkIpIp *a, const NMPlatformLnkIpIp *b);
|
2016-06-30 18:20:09 +02:00
|
|
|
int nm_platform_lnk_macsec_cmp (const NMPlatformLnkMacsec *a, const NMPlatformLnkMacsec *b);
|
2015-10-12 15:15:21 +02:00
|
|
|
int nm_platform_lnk_macvlan_cmp (const NMPlatformLnkMacvlan *a, const NMPlatformLnkMacvlan *b);
|
2015-11-11 18:41:48 +01:00
|
|
|
int nm_platform_lnk_sit_cmp (const NMPlatformLnkSit *a, const NMPlatformLnkSit *b);
|
2015-10-12 13:44:44 +02:00
|
|
|
int nm_platform_lnk_vlan_cmp (const NMPlatformLnkVlan *a, const NMPlatformLnkVlan *b);
|
2015-10-12 15:15:21 +02:00
|
|
|
int nm_platform_lnk_vxlan_cmp (const NMPlatformLnkVxlan *a, const NMPlatformLnkVxlan *b);
|
2013-09-06 09:58:55 +02:00
|
|
|
int nm_platform_ip4_address_cmp (const NMPlatformIP4Address *a, const NMPlatformIP4Address *b);
|
|
|
|
|
int nm_platform_ip6_address_cmp (const NMPlatformIP6Address *a, const NMPlatformIP6Address *b);
|
2017-07-26 10:50:23 +02:00
|
|
|
|
|
|
|
|
int nm_platform_ip4_route_cmp (const NMPlatformIP4Route *a, const NMPlatformIP4Route *b, NMPlatformIPRouteCmpType cmp_type);
|
|
|
|
|
int nm_platform_ip6_route_cmp (const NMPlatformIP6Route *a, const NMPlatformIP6Route *b, NMPlatformIPRouteCmpType cmp_type);
|
2017-04-13 22:34:32 +02:00
|
|
|
|
|
|
|
|
static inline int
|
2017-07-26 10:50:23 +02:00
|
|
|
nm_platform_ip4_route_cmp_full (const NMPlatformIP4Route *a, const NMPlatformIP4Route *b)
|
2017-04-13 22:34:32 +02:00
|
|
|
{
|
2017-07-26 10:50:23 +02:00
|
|
|
return nm_platform_ip4_route_cmp (a, b, NM_PLATFORM_IP_ROUTE_CMP_TYPE_FULL);
|
2017-04-13 22:34:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline int
|
2017-07-26 10:50:23 +02:00
|
|
|
nm_platform_ip6_route_cmp_full (const NMPlatformIP6Route *a, const NMPlatformIP6Route *b)
|
2017-04-13 22:34:32 +02:00
|
|
|
{
|
2017-07-26 10:50:23 +02:00
|
|
|
return nm_platform_ip6_route_cmp (a, b, NM_PLATFORM_IP_ROUTE_CMP_TYPE_FULL);
|
2017-04-13 22:34:32 +02:00
|
|
|
}
|
2013-09-06 09:58:55 +02:00
|
|
|
|
2017-10-17 11:53:08 +02:00
|
|
|
void nm_platform_link_hash_update (const NMPlatformLink *obj, NMHashState *h);
|
|
|
|
|
void nm_platform_ip4_address_hash_update (const NMPlatformIP4Address *obj, NMHashState *h);
|
|
|
|
|
void nm_platform_ip6_address_hash_update (const NMPlatformIP6Address *obj, NMHashState *h);
|
|
|
|
|
void nm_platform_ip4_route_hash_update (const NMPlatformIP4Route *obj, NMPlatformIPRouteCmpType cmp_type, NMHashState *h);
|
|
|
|
|
void nm_platform_ip6_route_hash_update (const NMPlatformIP6Route *obj, NMPlatformIPRouteCmpType cmp_type, NMHashState *h);
|
|
|
|
|
void nm_platform_lnk_gre_hash_update (const NMPlatformLnkGre *obj, NMHashState *h);
|
|
|
|
|
void nm_platform_lnk_infiniband_hash_update (const NMPlatformLnkInfiniband *obj, NMHashState *h);
|
|
|
|
|
void nm_platform_lnk_ip6tnl_hash_update (const NMPlatformLnkIp6Tnl *obj, NMHashState *h);
|
|
|
|
|
void nm_platform_lnk_ipip_hash_update (const NMPlatformLnkIpIp *obj, NMHashState *h);
|
|
|
|
|
void nm_platform_lnk_macsec_hash_update (const NMPlatformLnkMacsec *obj, NMHashState *h);
|
|
|
|
|
void nm_platform_lnk_macvlan_hash_update (const NMPlatformLnkMacvlan *obj, NMHashState *h);
|
|
|
|
|
void nm_platform_lnk_sit_hash_update (const NMPlatformLnkSit *obj, NMHashState *h);
|
|
|
|
|
void nm_platform_lnk_vlan_hash_update (const NMPlatformLnkVlan *obj, NMHashState *h);
|
|
|
|
|
void nm_platform_lnk_vxlan_hash_update (const NMPlatformLnkVxlan *obj, NMHashState *h);
|
2017-07-26 10:50:23 +02:00
|
|
|
|
2017-10-10 18:20:05 +02:00
|
|
|
NMPlatformKernelSupportFlags nm_platform_check_kernel_support (NMPlatform *self,
|
|
|
|
|
NMPlatformKernelSupportFlags request_flags);
|
2014-01-03 16:07:36 +01:00
|
|
|
|
2015-10-26 21:35:18 +01:00
|
|
|
const char *nm_platform_link_flags2str (unsigned flags, char *buf, gsize len);
|
|
|
|
|
const char *nm_platform_link_inet6_addrgenmode2str (guint8 mode, char *buf, gsize len);
|
|
|
|
|
const char *nm_platform_addr_flags2str (unsigned flags, char *buf, gsize len);
|
|
|
|
|
const char *nm_platform_route_scope2str (int scope, char *buf, gsize len);
|
2014-03-04 22:00:24 +01:00
|
|
|
|
2014-04-03 11:42:00 +02:00
|
|
|
int nm_platform_ip_address_cmp_expiry (const NMPlatformIPAddress *a, const NMPlatformIPAddress *b);
|
|
|
|
|
|
2016-12-11 22:46:14 +01:00
|
|
|
gboolean nm_platform_ethtool_set_wake_on_lan (NMPlatform *self, int ifindex, NMSettingWiredWakeOnLan wol, const char *wol_password);
|
|
|
|
|
gboolean nm_platform_ethtool_set_link_settings (NMPlatform *self, int ifindex, gboolean autoneg, guint32 speed, NMPlatformLinkDuplexType duplex);
|
|
|
|
|
gboolean nm_platform_ethtool_get_link_settings (NMPlatform *self, int ifindex, gboolean *out_autoneg, guint32 *out_speed, NMPlatformLinkDuplexType *out_duplex);
|
2016-02-19 23:34:25 +01:00
|
|
|
|
platform: add non-exclusive routes and drop route-manager
Previously, we would add exclusive routes via netlink message flags
NLM_F_CREATE | NLM_F_REPLACE for RTM_NEWROUTE. Similar to `ip route replace`.
Using that form of RTM_NEWROUTE message, we could only add a certain
route with a certain network/plen,metric triple once. That was already
hugely inconvenient, because
- when configuring routes, multiple (managed) interfaces may get
conflicting routes (multihoming). Only one of the routes can be actually
configured using `ip route replace`, so we need to track routes that are
currently shadowed.
- when configuring routes, we might replace externally configured
routes on unmanaged interfaces. We should not interfere with such
routes.
That was worked around by having NMRouteManager (and NMDefaultRouteManager).
NMRouteManager would keep a list of the routes which NetworkManager would like
to configure, even if momentarily being unable to do so due to conflicting routes.
This worked mostly well but was complicated. It involved bumping metrics to
avoid conflicts for device routes, as we might require them for gateway routes.
Drop that now. Instead, use the corresponding of `ip route append` to configure
routes. This allows NetworkManager to confiure (almost) all routes that we care.
Especially, it can configure all routes on a managed interface, without
replacing/interfering with routes on other interfaces. Hence, NMRouteManager
becomes obsolete.
It practice it is a bit more complicated because:
- when adding an IPv4 address, kernel will automatically create a device route
for the subnet. We should avoid that by using the IFA_F_NOPREFIXROUTE flag for
IPv4 addresses (still to-do). But as kernel may not support that flag for IPv4
addresses yet (and we don't require such a kernel yet), we still need functionality
similar to nm_route_manager_ip4_route_register_device_route_purge_list().
This functionality is now handled via nm_platform_ip4_dev_route_blacklist_set().
- trying to configure an IPv6 route with a source address will be rejected
by kernel as long as the address is tentative (see related bug rh#1457196).
Preferably, NMDevice would keep the list of routes which should be configured,
while kernel would have the list of what actually is configured. There is a
feed-back loop where both affect each other (for example, when externally deleting
a route, NMDevice must forget about it too). Previously, NMRouteManager would have
the task of remembering all routes which we currently want to configure, but cannot
due to conflicting routes.
We get rid of that, because now we configure non-exclusive routes. We however still
will need to remember IPv6 routes with a source address, that currently cannot be
configured yet. Hence, we will need to keep track of routes that
currently cannot be configured, but later may be.
That is still not done yet, as NMRouteManager didn't handle this
correctly either.
2017-08-14 14:18:53 +02:00
|
|
|
void nm_platform_ip4_dev_route_blacklist_set (NMPlatform *self,
|
|
|
|
|
int ifindex,
|
|
|
|
|
GPtrArray *ip4_dev_route_blacklist);
|
|
|
|
|
|
core: pass NMDedupMultiIndex instance to NMIP4Config and other
NMIP4Config, NMIP6Config, and NMPlatform shall share one
NMDedupMultiIndex instance.
For that, pass an NMDedupMultiIndex instance to NMPlatform and NMNetns.
NMNetns than passes it on to NMDevice, NMDhcpClient, NMIP4Config and NMIP6Config.
So currently NMNetns is the access point to the shared NMDedupMultiIndex
instance, and it gets it from it's NMPlatform instance.
The NMDedupMultiIndex instance is really a singleton, we don't want
multiple instances of it. However, for testing, instead of adding a
singleton instance, pass the instance explicitly around.
2017-06-12 08:16:47 +02:00
|
|
|
struct _NMDedupMultiIndex *nm_platform_get_multi_idx (NMPlatform *self);
|
|
|
|
|
|
all: fix up multiple-include-guard defines
Previously, src/nm-ip4-config.h, libnm/nm-ip4-config.h, and
libnm-glib/nm-ip4-config.h all used "NM_IP4_CONFIG_H" as an include
guard, which meant that nm-test-utils.h could not tell which of them
was being included (and so, eg, if you tried to include
nm-ip4-config.h in a libnm test, it would fail to compile because
nm-test-utils.h was referring to symbols in src/nm-ip4-config.h).
Fix this by changing the include guards in the non-API-stable parts of
the tree:
- libnm-glib/nm-ip4-config.h remains NM_IP4_CONFIG_H
- libnm/nm-ip4-config.h now uses __NM_IP4_CONFIG_H__
- src/nm-ip4-config.h now uses __NETWORKMANAGER_IP4_CONFIG_H__
And likewise for all other headers.
The two non-"nm"-prefixed headers, libnm/NetworkManager.h and
src/NetworkManagerUtils.h are now __NETWORKMANAGER_H__ and
__NETWORKMANAGER_UTILS_H__ respectively, which, while not entirely
consistent with the general scheme, do still mostly make sense in
isolation.
2014-08-13 14:10:11 -04:00
|
|
|
#endif /* __NETWORKMANAGER_PLATFORM_H__ */
|