mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-08 11:19:16 +02:00
core: merge branch 'th/nm-error'
https://github.com/NetworkManager/NetworkManager/pull/267
This commit is contained in:
commit
2d268b4da2
34 changed files with 902 additions and 850 deletions
|
|
@ -302,6 +302,8 @@ shared_nm_utils_libnm_utils_base_la_SOURCES = \
|
||||||
shared/nm-utils/nm-dedup-multi.h \
|
shared/nm-utils/nm-dedup-multi.h \
|
||||||
shared/nm-utils/nm-enum-utils.c \
|
shared/nm-utils/nm-enum-utils.c \
|
||||||
shared/nm-utils/nm-enum-utils.h \
|
shared/nm-utils/nm-enum-utils.h \
|
||||||
|
shared/nm-utils/nm-errno.c \
|
||||||
|
shared/nm-utils/nm-errno.h \
|
||||||
shared/nm-utils/nm-glib.h \
|
shared/nm-utils/nm-glib.h \
|
||||||
shared/nm-utils/nm-hash-utils.c \
|
shared/nm-utils/nm-hash-utils.c \
|
||||||
shared/nm-utils/nm-hash-utils.h \
|
shared/nm-utils/nm-hash-utils.h \
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,7 @@ shared_files_libnm_core = files('''
|
||||||
nm-utils/c-list-util.c
|
nm-utils/c-list-util.c
|
||||||
nm-utils/nm-dedup-multi.c
|
nm-utils/nm-dedup-multi.c
|
||||||
nm-utils/nm-enum-utils.c
|
nm-utils/nm-enum-utils.c
|
||||||
|
nm-utils/nm-errno.c
|
||||||
nm-utils/nm-hash-utils.c
|
nm-utils/nm-hash-utils.c
|
||||||
nm-utils/nm-io-utils.c
|
nm-utils/nm-io-utils.c
|
||||||
nm-utils/nm-random-utils.c
|
nm-utils/nm-random-utils.c
|
||||||
|
|
|
||||||
65
shared/nm-utils/nm-errno.c
Normal file
65
shared/nm-utils/nm-errno.c
Normal file
|
|
@ -0,0 +1,65 @@
|
||||||
|
/* NetworkManager -- Network link manager
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
|
* Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Copyright 2018 Red Hat, Inc.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "nm-default.h"
|
||||||
|
|
||||||
|
#include "nm-errno.h"
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
NM_UTILS_LOOKUP_STR_DEFINE_STATIC (_geterror, int,
|
||||||
|
NM_UTILS_LOOKUP_DEFAULT (NULL),
|
||||||
|
|
||||||
|
NM_UTILS_LOOKUP_STR_ITEM (NME_UNSPEC, "NME_UNSPEC"),
|
||||||
|
NM_UTILS_LOOKUP_STR_ITEM (NME_BUG, "NME_BUG"),
|
||||||
|
NM_UTILS_LOOKUP_STR_ITEM (NME_NATIVE_ERRNO, "NME_NATIVE_ERRNO"),
|
||||||
|
|
||||||
|
NM_UTILS_LOOKUP_STR_ITEM (NME_NL_ATTRSIZE, "NME_NL_ATTRSIZE"),
|
||||||
|
NM_UTILS_LOOKUP_STR_ITEM (NME_NL_BAD_SOCK, "NME_NL_BAD_SOCK"),
|
||||||
|
NM_UTILS_LOOKUP_STR_ITEM (NME_NL_DUMP_INTR, "NME_NL_DUMP_INTR"),
|
||||||
|
NM_UTILS_LOOKUP_STR_ITEM (NME_NL_MSG_OVERFLOW, "NME_NL_MSG_OVERFLOW"),
|
||||||
|
NM_UTILS_LOOKUP_STR_ITEM (NME_NL_MSG_TOOSHORT, "NME_NL_MSG_TOOSHORT"),
|
||||||
|
NM_UTILS_LOOKUP_STR_ITEM (NME_NL_MSG_TRUNC, "NME_NL_MSG_TRUNC"),
|
||||||
|
NM_UTILS_LOOKUP_STR_ITEM (NME_NL_SEQ_MISMATCH, "NME_NL_SEQ_MISMATCH"),
|
||||||
|
|
||||||
|
NM_UTILS_LOOKUP_STR_ITEM (NME_PL_NOT_FOUND, "not-found"),
|
||||||
|
NM_UTILS_LOOKUP_STR_ITEM (NME_PL_EXISTS, "exists"),
|
||||||
|
NM_UTILS_LOOKUP_STR_ITEM (NME_PL_WRONG_TYPE, "wrong-type"),
|
||||||
|
NM_UTILS_LOOKUP_STR_ITEM (NME_PL_NOT_SLAVE, "not-slave"),
|
||||||
|
NM_UTILS_LOOKUP_STR_ITEM (NME_PL_NO_FIRMWARE, "no-firmware"),
|
||||||
|
NM_UTILS_LOOKUP_STR_ITEM (NME_PL_OPNOTSUPP, "not-supported"),
|
||||||
|
NM_UTILS_LOOKUP_STR_ITEM (NME_PL_NETLINK, "netlink"),
|
||||||
|
NM_UTILS_LOOKUP_STR_ITEM (NME_PL_CANT_SET_MTU, "cant-set-mtu"),
|
||||||
|
);
|
||||||
|
|
||||||
|
const char *
|
||||||
|
nm_strerror (int nmerr)
|
||||||
|
{
|
||||||
|
const char *s;
|
||||||
|
|
||||||
|
nmerr = nm_errno (nmerr);
|
||||||
|
|
||||||
|
if (nmerr >= _NM_ERRNO_RESERVED_FIRST) {
|
||||||
|
s = _geterror (nmerr);
|
||||||
|
if (s)
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
return g_strerror (nmerr);
|
||||||
|
}
|
||||||
135
shared/nm-utils/nm-errno.h
Normal file
135
shared/nm-utils/nm-errno.h
Normal file
|
|
@ -0,0 +1,135 @@
|
||||||
|
/* NetworkManager -- Network link manager
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
|
* Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Copyright 2018 Red Hat, Inc.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __NM_ERRNO_H__
|
||||||
|
#define __NM_ERRNO_H__
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
enum {
|
||||||
|
_NM_ERRNO_MININT = G_MININT,
|
||||||
|
_NM_ERRNO_MAXINT = G_MAXINT,
|
||||||
|
_NM_ERRNO_RESERVED_FIRST = 100000,
|
||||||
|
|
||||||
|
/* an unspecified error. */
|
||||||
|
NME_UNSPEC = _NM_ERRNO_RESERVED_FIRST,
|
||||||
|
|
||||||
|
/* A bug, for example when an assertion failed.
|
||||||
|
* Should never happen. */
|
||||||
|
NME_BUG,
|
||||||
|
|
||||||
|
/* a native error number (from <errno.h>) cannot be mapped as
|
||||||
|
* an nm-error, because it is in the range [_NM_ERRNO_RESERVED_FIRST,
|
||||||
|
* _NM_ERRNO_RESERVED_LAST]. */
|
||||||
|
NME_NATIVE_ERRNO,
|
||||||
|
|
||||||
|
/* netlink errors. */
|
||||||
|
NME_NL_SEQ_MISMATCH,
|
||||||
|
NME_NL_MSG_TRUNC,
|
||||||
|
NME_NL_MSG_TOOSHORT,
|
||||||
|
NME_NL_DUMP_INTR,
|
||||||
|
NME_NL_ATTRSIZE,
|
||||||
|
NME_NL_BAD_SOCK,
|
||||||
|
NME_NL_NOADDR,
|
||||||
|
NME_NL_MSG_OVERFLOW,
|
||||||
|
|
||||||
|
/* platform errors. */
|
||||||
|
NME_PL_NOT_FOUND,
|
||||||
|
NME_PL_EXISTS,
|
||||||
|
NME_PL_WRONG_TYPE,
|
||||||
|
NME_PL_NOT_SLAVE,
|
||||||
|
NME_PL_NO_FIRMWARE,
|
||||||
|
NME_PL_OPNOTSUPP,
|
||||||
|
NME_PL_NETLINK,
|
||||||
|
NME_PL_CANT_SET_MTU,
|
||||||
|
|
||||||
|
_NM_ERRNO_RESERVED_LAST_PLUS_1,
|
||||||
|
_NM_ERRNO_RESERVED_LAST = _NM_ERRNO_RESERVED_LAST_PLUS_1 - 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
nm_errno_native (int errsv)
|
||||||
|
{
|
||||||
|
/* several API returns negative errno values as errors. Normalize
|
||||||
|
* negative values to positive values.
|
||||||
|
*
|
||||||
|
* As a special case, map G_MININT to G_MAXINT. If you care about the
|
||||||
|
* distinction, then check for G_MININT before.
|
||||||
|
*
|
||||||
|
* Basically, this normalizes a plain errno to be non-negative. */
|
||||||
|
return errsv >= 0
|
||||||
|
? errsv
|
||||||
|
: ((errsv == G_MININT) ? G_MAXINT : -errsv);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
nm_errno (int nmerr)
|
||||||
|
{
|
||||||
|
/* Normalizes an nm-error to be positive. Various API returns negative
|
||||||
|
* error codes, and this function converts the negative value to its
|
||||||
|
* positive.
|
||||||
|
*
|
||||||
|
* It's very similar to nm_errno_native(), but not exactly. The difference is that
|
||||||
|
* nm_errno_native() is for plain errno, while nm_errno() is for nm-error numbers.
|
||||||
|
* Yes, nm-error number are ~almost~ the same as errno, except that a particular
|
||||||
|
* range (_NM_ERRNO_RESERVED_FIRST, _NM_ERRNO_RESERVED_LAST) is reserved. The difference
|
||||||
|
* between the two functions is only how G_MININT is mapped.
|
||||||
|
*
|
||||||
|
* See also nm_errno_from_native() below. */
|
||||||
|
return nmerr >= 0
|
||||||
|
? nmerr
|
||||||
|
: ((nmerr == G_MININT) ? NME_BUG : -nmerr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
nm_errno_from_native (int errsv)
|
||||||
|
{
|
||||||
|
/* this maps a native errno to a (always non-negative) nm-error number.
|
||||||
|
*
|
||||||
|
* Note that nm-error numbers are embedded into the range of regular
|
||||||
|
* errno. The only difference is, that nm-error numbers reserve a
|
||||||
|
* range (_NM_ERRNO_RESERVED_FIRST, _NM_ERRNO_RESERVED_LAST) for their
|
||||||
|
* own purpose.
|
||||||
|
*
|
||||||
|
* That means, converting an errno to nm-error number means in
|
||||||
|
* most cases just returning itself (negative values are normalized
|
||||||
|
* to be positive). Only values G_MININT and [_NM_ERRNO_RESERVED_FIRST, _NM_ERRNO_RESERVED_LAST]
|
||||||
|
* are coerced to the special value NME_NATIVE_ERRNO, as they cannot
|
||||||
|
* otherwise be represented in nm-error number domain. */
|
||||||
|
if (errsv < 0) {
|
||||||
|
return G_UNLIKELY (errsv == G_MININT)
|
||||||
|
? NME_NATIVE_ERRNO
|
||||||
|
: -errsv;
|
||||||
|
}
|
||||||
|
return G_UNLIKELY ( errsv >= _NM_ERRNO_RESERVED_FIRST
|
||||||
|
&& errsv <= _NM_ERRNO_RESERVED_LAST)
|
||||||
|
? NME_NATIVE_ERRNO
|
||||||
|
: errsv;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *nm_strerror (int nmerr);
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
#endif /* __NM_ERRNO_H__ */
|
||||||
|
|
@ -614,19 +614,6 @@ _nm_g_slice_free_fcn_define (16)
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static inline int
|
|
||||||
nm_errno (int errsv)
|
|
||||||
{
|
|
||||||
/* several API returns negative errno values as errors. Normalize
|
|
||||||
* negative values to positive values.
|
|
||||||
*
|
|
||||||
* As a special case, map G_MININT to G_MAXINT. If you care about the
|
|
||||||
* distinction, then check for G_MININT before. */
|
|
||||||
return errsv >= 0
|
|
||||||
? errsv
|
|
||||||
: ((errsv == G_MININT) ? G_MAXINT : -errsv);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NMUtilsError:
|
* NMUtilsError:
|
||||||
* @NM_UTILS_ERROR_UNKNOWN: unknown or unclassified error
|
* @NM_UTILS_ERROR_UNKNOWN: unknown or unclassified error
|
||||||
|
|
@ -697,7 +684,15 @@ nm_utils_error_set_literal (GError **error, int error_code, const char *literal)
|
||||||
NM_UTILS_ERROR_UNKNOWN, \
|
NM_UTILS_ERROR_UNKNOWN, \
|
||||||
fmt, \
|
fmt, \
|
||||||
##__VA_ARGS__, \
|
##__VA_ARGS__, \
|
||||||
g_strerror (nm_errno (errsv)))
|
g_strerror (({ \
|
||||||
|
const int _errsv = (errsv); \
|
||||||
|
\
|
||||||
|
( _errsv >= 0 \
|
||||||
|
? _errsv \
|
||||||
|
: ( (_errsv == G_MININT) \
|
||||||
|
? G_MAXINT \
|
||||||
|
: -errsv)); \
|
||||||
|
})))
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -196,6 +196,25 @@
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
/* Our nm-error error numbers use negative values to signal failure.
|
||||||
|
* A non-negative value signals success. Hence, the correct way for checking
|
||||||
|
* is always (r < 0) vs. (r >= 0). Never (r == 0).
|
||||||
|
*
|
||||||
|
* For assertions in tests, we also want to assert that no positive values
|
||||||
|
* are returned. For a lot of functions, positive return values are unexpected
|
||||||
|
* and a bug. This macro evaluates @r to success or failure, while asserting
|
||||||
|
* that @r is not positive. */
|
||||||
|
#define NMTST_NM_ERR_SUCCESS(r) \
|
||||||
|
({ \
|
||||||
|
const int _r = (r); \
|
||||||
|
\
|
||||||
|
if (_r >= 0) \
|
||||||
|
g_assert_cmpint (_r, ==, 0); \
|
||||||
|
(_r >= 0); \
|
||||||
|
})
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
struct __nmtst_internal
|
struct __nmtst_internal
|
||||||
{
|
{
|
||||||
GRand *rand0;
|
GRand *rand0;
|
||||||
|
|
|
||||||
|
|
@ -110,9 +110,9 @@ create_and_realize (NMDevice *device,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
const char *iface = nm_device_get_iface (device);
|
const char *iface = nm_device_get_iface (device);
|
||||||
NMPlatformError plerr;
|
|
||||||
NMSetting6Lowpan *s_6lowpan;
|
NMSetting6Lowpan *s_6lowpan;
|
||||||
int parent_ifindex;
|
int parent_ifindex;
|
||||||
|
int r;
|
||||||
|
|
||||||
s_6lowpan = NM_SETTING_6LOWPAN (nm_connection_get_setting (connection, NM_TYPE_SETTING_6LOWPAN));
|
s_6lowpan = NM_SETTING_6LOWPAN (nm_connection_get_setting (connection, NM_TYPE_SETTING_6LOWPAN));
|
||||||
g_return_val_if_fail (s_6lowpan, FALSE);
|
g_return_val_if_fail (s_6lowpan, FALSE);
|
||||||
|
|
@ -126,13 +126,13 @@ create_and_realize (NMDevice *device,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
plerr = nm_platform_link_6lowpan_add (nm_device_get_platform (device), iface, parent_ifindex, out_plink);
|
r = nm_platform_link_6lowpan_add (nm_device_get_platform (device), iface, parent_ifindex, out_plink);
|
||||||
if (plerr != NM_PLATFORM_ERROR_SUCCESS) {
|
if (r < 0) {
|
||||||
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
||||||
"Failed to create 6lowpan interface '%s' for '%s': %s",
|
"Failed to create 6lowpan interface '%s' for '%s': %s",
|
||||||
iface,
|
iface,
|
||||||
nm_connection_get_id (connection),
|
nm_connection_get_id (connection),
|
||||||
nm_platform_error_to_string_a (plerr));
|
nm_strerror (r));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -459,17 +459,17 @@ create_and_realize (NMDevice *device,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
const char *iface = nm_device_get_iface (device);
|
const char *iface = nm_device_get_iface (device);
|
||||||
NMPlatformError plerr;
|
int r;
|
||||||
|
|
||||||
g_assert (iface);
|
g_assert (iface);
|
||||||
|
|
||||||
plerr = nm_platform_link_bond_add (nm_device_get_platform (device), iface, out_plink);
|
r = nm_platform_link_bond_add (nm_device_get_platform (device), iface, out_plink);
|
||||||
if (plerr != NM_PLATFORM_ERROR_SUCCESS) {
|
if (r < 0) {
|
||||||
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
||||||
"Failed to create bond interface '%s' for '%s': %s",
|
"Failed to create bond interface '%s' for '%s': %s",
|
||||||
iface,
|
iface,
|
||||||
nm_connection_get_id (connection),
|
nm_connection_get_id (connection),
|
||||||
nm_platform_error_to_string_a (plerr));
|
nm_strerror (r));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
|
||||||
|
|
@ -459,7 +459,7 @@ create_and_realize (NMDevice *device,
|
||||||
const char *hwaddr;
|
const char *hwaddr;
|
||||||
gs_free char *hwaddr_cloned = NULL;
|
gs_free char *hwaddr_cloned = NULL;
|
||||||
guint8 mac_address[NM_UTILS_HWADDR_LEN_MAX];
|
guint8 mac_address[NM_UTILS_HWADDR_LEN_MAX];
|
||||||
NMPlatformError plerr;
|
int r;
|
||||||
|
|
||||||
nm_assert (iface);
|
nm_assert (iface);
|
||||||
|
|
||||||
|
|
@ -486,17 +486,17 @@ create_and_realize (NMDevice *device,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
plerr = nm_platform_link_bridge_add (nm_device_get_platform (device),
|
r = nm_platform_link_bridge_add (nm_device_get_platform (device),
|
||||||
iface,
|
iface,
|
||||||
hwaddr ? mac_address : NULL,
|
hwaddr ? mac_address : NULL,
|
||||||
hwaddr ? ETH_ALEN : 0,
|
hwaddr ? ETH_ALEN : 0,
|
||||||
out_plink);
|
out_plink);
|
||||||
if (plerr != NM_PLATFORM_ERROR_SUCCESS) {
|
if (r < 0) {
|
||||||
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
||||||
"Failed to create bridge interface '%s' for '%s': %s",
|
"Failed to create bridge interface '%s' for '%s': %s",
|
||||||
iface,
|
iface,
|
||||||
nm_connection_get_id (connection),
|
nm_connection_get_id (connection),
|
||||||
nm_platform_error_to_string_a (plerr));
|
nm_strerror (r));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -98,19 +98,19 @@ create_and_realize (NMDevice *device,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
const char *iface = nm_device_get_iface (device);
|
const char *iface = nm_device_get_iface (device);
|
||||||
NMPlatformError plerr;
|
|
||||||
NMSettingDummy *s_dummy;
|
NMSettingDummy *s_dummy;
|
||||||
|
int r;
|
||||||
|
|
||||||
s_dummy = nm_connection_get_setting_dummy (connection);
|
s_dummy = nm_connection_get_setting_dummy (connection);
|
||||||
g_assert (s_dummy);
|
g_assert (s_dummy);
|
||||||
|
|
||||||
plerr = nm_platform_link_dummy_add (nm_device_get_platform (device), iface, out_plink);
|
r = nm_platform_link_dummy_add (nm_device_get_platform (device), iface, out_plink);
|
||||||
if (plerr != NM_PLATFORM_ERROR_SUCCESS) {
|
if (r < 0) {
|
||||||
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
||||||
"Failed to create dummy interface '%s' for '%s': %s",
|
"Failed to create dummy interface '%s' for '%s': %s",
|
||||||
iface,
|
iface,
|
||||||
nm_connection_get_id (connection),
|
nm_connection_get_id (connection),
|
||||||
nm_platform_error_to_string_a (plerr));
|
nm_strerror (r));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -235,7 +235,7 @@ create_and_realize (NMDevice *device,
|
||||||
{
|
{
|
||||||
NMDeviceInfinibandPrivate *priv = NM_DEVICE_INFINIBAND_GET_PRIVATE ((NMDeviceInfiniband *) device);
|
NMDeviceInfinibandPrivate *priv = NM_DEVICE_INFINIBAND_GET_PRIVATE ((NMDeviceInfiniband *) device);
|
||||||
NMSettingInfiniband *s_infiniband;
|
NMSettingInfiniband *s_infiniband;
|
||||||
NMPlatformError plerr;
|
int r;
|
||||||
|
|
||||||
s_infiniband = nm_connection_get_setting_infiniband (connection);
|
s_infiniband = nm_connection_get_setting_infiniband (connection);
|
||||||
g_assert (s_infiniband);
|
g_assert (s_infiniband);
|
||||||
|
|
@ -269,13 +269,13 @@ create_and_realize (NMDevice *device,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
plerr = nm_platform_link_infiniband_add (nm_device_get_platform (device), priv->parent_ifindex, priv->p_key, out_plink);
|
r = nm_platform_link_infiniband_add (nm_device_get_platform (device), priv->parent_ifindex, priv->p_key, out_plink);
|
||||||
if (plerr != NM_PLATFORM_ERROR_SUCCESS) {
|
if (r < 0) {
|
||||||
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
||||||
"Failed to create InfiniBand P_Key interface '%s' for '%s': %s",
|
"Failed to create InfiniBand P_Key interface '%s' for '%s': %s",
|
||||||
nm_device_get_iface (device),
|
nm_device_get_iface (device),
|
||||||
nm_connection_get_id (connection),
|
nm_connection_get_id (connection),
|
||||||
nm_platform_error_to_string_a (plerr));
|
nm_strerror (r));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -287,7 +287,7 @@ static gboolean
|
||||||
unrealize (NMDevice *device, GError **error)
|
unrealize (NMDevice *device, GError **error)
|
||||||
{
|
{
|
||||||
NMDeviceInfinibandPrivate *priv;
|
NMDeviceInfinibandPrivate *priv;
|
||||||
NMPlatformError plerr;
|
int r;
|
||||||
|
|
||||||
g_return_val_if_fail (NM_IS_DEVICE_INFINIBAND (device), FALSE);
|
g_return_val_if_fail (NM_IS_DEVICE_INFINIBAND (device), FALSE);
|
||||||
|
|
||||||
|
|
@ -299,12 +299,12 @@ unrealize (NMDevice *device, GError **error)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
plerr = nm_platform_link_infiniband_delete (nm_device_get_platform (device), priv->parent_ifindex, priv->p_key);
|
r = nm_platform_link_infiniband_delete (nm_device_get_platform (device), priv->parent_ifindex, priv->p_key);
|
||||||
if (plerr != NM_PLATFORM_ERROR_SUCCESS) {
|
if (r < 0) {
|
||||||
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
||||||
"Failed to remove InfiniBand P_Key interface '%s': %s",
|
"Failed to remove InfiniBand P_Key interface '%s': %s",
|
||||||
nm_device_get_iface (device),
|
nm_device_get_iface (device),
|
||||||
nm_platform_error_to_string_a (plerr));
|
nm_strerror (r));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -660,7 +660,6 @@ create_and_realize (NMDevice *device,
|
||||||
{
|
{
|
||||||
const char *iface = nm_device_get_iface (device);
|
const char *iface = nm_device_get_iface (device);
|
||||||
NMSettingIPTunnel *s_ip_tunnel;
|
NMSettingIPTunnel *s_ip_tunnel;
|
||||||
NMPlatformError plerr;
|
|
||||||
NMPlatformLnkGre lnk_gre = { };
|
NMPlatformLnkGre lnk_gre = { };
|
||||||
NMPlatformLnkSit lnk_sit = { };
|
NMPlatformLnkSit lnk_sit = { };
|
||||||
NMPlatformLnkIpIp lnk_ipip = { };
|
NMPlatformLnkIpIp lnk_ipip = { };
|
||||||
|
|
@ -668,6 +667,7 @@ create_and_realize (NMDevice *device,
|
||||||
const char *str;
|
const char *str;
|
||||||
gint64 val;
|
gint64 val;
|
||||||
NMIPTunnelMode mode;
|
NMIPTunnelMode mode;
|
||||||
|
int r;
|
||||||
|
|
||||||
s_ip_tunnel = nm_connection_get_setting_ip_tunnel (connection);
|
s_ip_tunnel = nm_connection_get_setting_ip_tunnel (connection);
|
||||||
g_assert (s_ip_tunnel);
|
g_assert (s_ip_tunnel);
|
||||||
|
|
@ -713,13 +713,13 @@ create_and_realize (NMDevice *device,
|
||||||
lnk_gre.output_flags = NM_GRE_KEY;
|
lnk_gre.output_flags = NM_GRE_KEY;
|
||||||
}
|
}
|
||||||
|
|
||||||
plerr = nm_platform_link_gre_add (nm_device_get_platform (device), iface, &lnk_gre, out_plink);
|
r = nm_platform_link_gre_add (nm_device_get_platform (device), iface, &lnk_gre, out_plink);
|
||||||
if (plerr != NM_PLATFORM_ERROR_SUCCESS) {
|
if (r < 0) {
|
||||||
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
||||||
"Failed to create GRE interface '%s' for '%s': %s",
|
"Failed to create GRE interface '%s' for '%s': %s",
|
||||||
iface,
|
iface,
|
||||||
nm_connection_get_id (connection),
|
nm_connection_get_id (connection),
|
||||||
nm_platform_error_to_string_a (plerr));
|
nm_strerror (r));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -739,13 +739,13 @@ create_and_realize (NMDevice *device,
|
||||||
lnk_sit.tos = nm_setting_ip_tunnel_get_tos (s_ip_tunnel);
|
lnk_sit.tos = nm_setting_ip_tunnel_get_tos (s_ip_tunnel);
|
||||||
lnk_sit.path_mtu_discovery = nm_setting_ip_tunnel_get_path_mtu_discovery (s_ip_tunnel);
|
lnk_sit.path_mtu_discovery = nm_setting_ip_tunnel_get_path_mtu_discovery (s_ip_tunnel);
|
||||||
|
|
||||||
plerr = nm_platform_link_sit_add (nm_device_get_platform (device), iface, &lnk_sit, out_plink);
|
r = nm_platform_link_sit_add (nm_device_get_platform (device), iface, &lnk_sit, out_plink);
|
||||||
if (plerr != NM_PLATFORM_ERROR_SUCCESS) {
|
if (r < 0) {
|
||||||
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
||||||
"Failed to create SIT interface '%s' for '%s': %s",
|
"Failed to create SIT interface '%s' for '%s': %s",
|
||||||
iface,
|
iface,
|
||||||
nm_connection_get_id (connection),
|
nm_connection_get_id (connection),
|
||||||
nm_platform_error_to_string_a (plerr));
|
nm_strerror (r));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -765,13 +765,13 @@ create_and_realize (NMDevice *device,
|
||||||
lnk_ipip.tos = nm_setting_ip_tunnel_get_tos (s_ip_tunnel);
|
lnk_ipip.tos = nm_setting_ip_tunnel_get_tos (s_ip_tunnel);
|
||||||
lnk_ipip.path_mtu_discovery = nm_setting_ip_tunnel_get_path_mtu_discovery (s_ip_tunnel);
|
lnk_ipip.path_mtu_discovery = nm_setting_ip_tunnel_get_path_mtu_discovery (s_ip_tunnel);
|
||||||
|
|
||||||
plerr = nm_platform_link_ipip_add (nm_device_get_platform (device), iface, &lnk_ipip, out_plink);
|
r = nm_platform_link_ipip_add (nm_device_get_platform (device), iface, &lnk_ipip, out_plink);
|
||||||
if (plerr != NM_PLATFORM_ERROR_SUCCESS) {
|
if (r < 0) {
|
||||||
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
||||||
"Failed to create IPIP interface '%s' for '%s': %s",
|
"Failed to create IPIP interface '%s' for '%s': %s",
|
||||||
iface,
|
iface,
|
||||||
nm_connection_get_id (connection),
|
nm_connection_get_id (connection),
|
||||||
nm_platform_error_to_string_a (plerr));
|
nm_strerror (r));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -820,21 +820,21 @@ create_and_realize (NMDevice *device,
|
||||||
lnk_ip6tnl.is_gre = TRUE;
|
lnk_ip6tnl.is_gre = TRUE;
|
||||||
lnk_ip6tnl.is_tap = (mode == NM_IP_TUNNEL_MODE_IP6GRETAP);
|
lnk_ip6tnl.is_tap = (mode == NM_IP_TUNNEL_MODE_IP6GRETAP);
|
||||||
|
|
||||||
plerr = nm_platform_link_ip6gre_add (nm_device_get_platform (device),
|
r = nm_platform_link_ip6gre_add (nm_device_get_platform (device),
|
||||||
iface, &lnk_ip6tnl, out_plink);
|
iface, &lnk_ip6tnl, out_plink);
|
||||||
} else {
|
} else {
|
||||||
lnk_ip6tnl.proto = nm_setting_ip_tunnel_get_mode (s_ip_tunnel) == NM_IP_TUNNEL_MODE_IPIP6
|
lnk_ip6tnl.proto = nm_setting_ip_tunnel_get_mode (s_ip_tunnel) == NM_IP_TUNNEL_MODE_IPIP6
|
||||||
? IPPROTO_IPIP
|
? IPPROTO_IPIP
|
||||||
: IPPROTO_IPV6;
|
: IPPROTO_IPV6;
|
||||||
plerr = nm_platform_link_ip6tnl_add (nm_device_get_platform (device),
|
r = nm_platform_link_ip6tnl_add (nm_device_get_platform (device),
|
||||||
iface, &lnk_ip6tnl, out_plink);
|
iface, &lnk_ip6tnl, out_plink);
|
||||||
}
|
}
|
||||||
if (plerr != NM_PLATFORM_ERROR_SUCCESS) {
|
if (r < 0) {
|
||||||
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
||||||
"Failed to create IPv6 tunnel interface '%s' for '%s': %s",
|
"Failed to create IPv6 tunnel interface '%s' for '%s': %s",
|
||||||
iface,
|
iface,
|
||||||
nm_connection_get_id (connection),
|
nm_connection_get_id (connection),
|
||||||
nm_platform_error_to_string_a (plerr));
|
nm_strerror (r));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -657,7 +657,6 @@ create_and_realize (NMDevice *device,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
const char *iface = nm_device_get_iface (device);
|
const char *iface = nm_device_get_iface (device);
|
||||||
NMPlatformError plerr;
|
|
||||||
NMSettingMacsec *s_macsec;
|
NMSettingMacsec *s_macsec;
|
||||||
NMPlatformLnkMacsec lnk = { };
|
NMPlatformLnkMacsec lnk = { };
|
||||||
int parent_ifindex;
|
int parent_ifindex;
|
||||||
|
|
@ -669,6 +668,7 @@ create_and_realize (NMDevice *device,
|
||||||
} s;
|
} s;
|
||||||
guint64 u;
|
guint64 u;
|
||||||
} sci;
|
} sci;
|
||||||
|
int r;
|
||||||
|
|
||||||
s_macsec = nm_connection_get_setting_macsec (connection);
|
s_macsec = nm_connection_get_setting_macsec (connection);
|
||||||
g_assert (s_macsec);
|
g_assert (s_macsec);
|
||||||
|
|
@ -697,13 +697,13 @@ create_and_realize (NMDevice *device,
|
||||||
parent_ifindex = nm_device_get_ifindex (parent);
|
parent_ifindex = nm_device_get_ifindex (parent);
|
||||||
g_warn_if_fail (parent_ifindex > 0);
|
g_warn_if_fail (parent_ifindex > 0);
|
||||||
|
|
||||||
plerr = nm_platform_link_macsec_add (nm_device_get_platform (device), iface, parent_ifindex, &lnk, out_plink);
|
r = nm_platform_link_macsec_add (nm_device_get_platform (device), iface, parent_ifindex, &lnk, out_plink);
|
||||||
if (plerr != NM_PLATFORM_ERROR_SUCCESS) {
|
if (r < 0) {
|
||||||
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
||||||
"Failed to create macsec interface '%s' for '%s': %s",
|
"Failed to create macsec interface '%s' for '%s': %s",
|
||||||
iface,
|
iface,
|
||||||
nm_connection_get_id (connection),
|
nm_connection_get_id (connection),
|
||||||
nm_platform_error_to_string_a (plerr));
|
nm_strerror (r));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -227,10 +227,10 @@ create_and_realize (NMDevice *device,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
const char *iface = nm_device_get_iface (device);
|
const char *iface = nm_device_get_iface (device);
|
||||||
NMPlatformError plerr;
|
|
||||||
NMSettingMacvlan *s_macvlan;
|
NMSettingMacvlan *s_macvlan;
|
||||||
NMPlatformLnkMacvlan lnk = { };
|
NMPlatformLnkMacvlan lnk = { };
|
||||||
int parent_ifindex;
|
int parent_ifindex;
|
||||||
|
int r;
|
||||||
|
|
||||||
s_macvlan = nm_connection_get_setting_macvlan (connection);
|
s_macvlan = nm_connection_get_setting_macvlan (connection);
|
||||||
g_return_val_if_fail (s_macvlan, FALSE);
|
g_return_val_if_fail (s_macvlan, FALSE);
|
||||||
|
|
@ -255,14 +255,14 @@ create_and_realize (NMDevice *device,
|
||||||
lnk.no_promisc = !nm_setting_macvlan_get_promiscuous (s_macvlan);
|
lnk.no_promisc = !nm_setting_macvlan_get_promiscuous (s_macvlan);
|
||||||
lnk.tap = nm_setting_macvlan_get_tap (s_macvlan);
|
lnk.tap = nm_setting_macvlan_get_tap (s_macvlan);
|
||||||
|
|
||||||
plerr = nm_platform_link_macvlan_add (nm_device_get_platform (device), iface, parent_ifindex, &lnk, out_plink);
|
r = nm_platform_link_macvlan_add (nm_device_get_platform (device), iface, parent_ifindex, &lnk, out_plink);
|
||||||
if (plerr != NM_PLATFORM_ERROR_SUCCESS) {
|
if (r < 0) {
|
||||||
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
||||||
"Failed to create %s interface '%s' for '%s': %s",
|
"Failed to create %s interface '%s' for '%s': %s",
|
||||||
lnk.tap ? "macvtap" : "macvlan",
|
lnk.tap ? "macvtap" : "macvlan",
|
||||||
iface,
|
iface,
|
||||||
nm_connection_get_id (connection),
|
nm_connection_get_id (connection),
|
||||||
nm_platform_error_to_string_a (plerr));
|
nm_strerror (r));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -231,9 +231,10 @@ create_and_realize (NMDevice *device,
|
||||||
{
|
{
|
||||||
const char *iface = nm_device_get_iface (device);
|
const char *iface = nm_device_get_iface (device);
|
||||||
NMPlatformLnkTun props = { };
|
NMPlatformLnkTun props = { };
|
||||||
NMPlatformError plerr;
|
|
||||||
NMSettingTun *s_tun;
|
NMSettingTun *s_tun;
|
||||||
gint64 owner, group;
|
gint64 owner;
|
||||||
|
gint64 group;
|
||||||
|
int r;
|
||||||
|
|
||||||
s_tun = nm_connection_get_setting_tun (connection);
|
s_tun = nm_connection_get_setting_tun (connection);
|
||||||
g_return_val_if_fail (s_tun, FALSE);
|
g_return_val_if_fail (s_tun, FALSE);
|
||||||
|
|
@ -261,17 +262,17 @@ create_and_realize (NMDevice *device,
|
||||||
props.multi_queue = nm_setting_tun_get_multi_queue (s_tun);
|
props.multi_queue = nm_setting_tun_get_multi_queue (s_tun);
|
||||||
props.persist = TRUE;
|
props.persist = TRUE;
|
||||||
|
|
||||||
plerr = nm_platform_link_tun_add (nm_device_get_platform (device),
|
r = nm_platform_link_tun_add (nm_device_get_platform (device),
|
||||||
iface,
|
iface,
|
||||||
&props,
|
&props,
|
||||||
out_plink,
|
out_plink,
|
||||||
NULL);
|
NULL);
|
||||||
if (plerr != NM_PLATFORM_ERROR_SUCCESS) {
|
if (r < 0) {
|
||||||
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
||||||
"Failed to create TUN/TAP interface '%s' for '%s': %s",
|
"Failed to create TUN/TAP interface '%s' for '%s': %s",
|
||||||
iface,
|
iface,
|
||||||
nm_connection_get_id (connection),
|
nm_connection_get_id (connection),
|
||||||
nm_platform_error_to_string_a (plerr));
|
nm_strerror (r));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -241,7 +241,7 @@ create_and_realize (NMDevice *device,
|
||||||
NMSettingVlan *s_vlan;
|
NMSettingVlan *s_vlan;
|
||||||
int parent_ifindex;
|
int parent_ifindex;
|
||||||
guint vlan_id;
|
guint vlan_id;
|
||||||
NMPlatformError plerr;
|
int r;
|
||||||
|
|
||||||
s_vlan = nm_connection_get_setting_vlan (connection);
|
s_vlan = nm_connection_get_setting_vlan (connection);
|
||||||
g_assert (s_vlan);
|
g_assert (s_vlan);
|
||||||
|
|
@ -271,18 +271,18 @@ create_and_realize (NMDevice *device,
|
||||||
|
|
||||||
vlan_id = nm_setting_vlan_get_id (s_vlan);
|
vlan_id = nm_setting_vlan_get_id (s_vlan);
|
||||||
|
|
||||||
plerr = nm_platform_link_vlan_add (nm_device_get_platform (device),
|
r = nm_platform_link_vlan_add (nm_device_get_platform (device),
|
||||||
iface,
|
iface,
|
||||||
parent_ifindex,
|
parent_ifindex,
|
||||||
vlan_id,
|
vlan_id,
|
||||||
nm_setting_vlan_get_flags (s_vlan),
|
nm_setting_vlan_get_flags (s_vlan),
|
||||||
out_plink);
|
out_plink);
|
||||||
if (plerr != NM_PLATFORM_ERROR_SUCCESS) {
|
if (r < 0) {
|
||||||
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
||||||
"Failed to create VLAN interface '%s' for '%s': %s",
|
"Failed to create VLAN interface '%s' for '%s': %s",
|
||||||
iface,
|
iface,
|
||||||
nm_connection_get_id (connection),
|
nm_connection_get_id (connection),
|
||||||
nm_platform_error_to_string_a (plerr));
|
nm_strerror (r));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -171,11 +171,11 @@ create_and_realize (NMDevice *device,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
const char *iface = nm_device_get_iface (device);
|
const char *iface = nm_device_get_iface (device);
|
||||||
NMPlatformError plerr;
|
|
||||||
NMPlatformLnkVxlan props = { };
|
NMPlatformLnkVxlan props = { };
|
||||||
NMSettingVxlan *s_vxlan;
|
NMSettingVxlan *s_vxlan;
|
||||||
const char *str;
|
const char *str;
|
||||||
int ret;
|
int ret;
|
||||||
|
int r;
|
||||||
|
|
||||||
s_vxlan = nm_connection_get_setting_vxlan (connection);
|
s_vxlan = nm_connection_get_setting_vxlan (connection);
|
||||||
g_assert (s_vxlan);
|
g_assert (s_vxlan);
|
||||||
|
|
@ -214,13 +214,13 @@ create_and_realize (NMDevice *device,
|
||||||
props.l2miss = nm_setting_vxlan_get_l2_miss (s_vxlan);
|
props.l2miss = nm_setting_vxlan_get_l2_miss (s_vxlan);
|
||||||
props.l3miss = nm_setting_vxlan_get_l3_miss (s_vxlan);
|
props.l3miss = nm_setting_vxlan_get_l3_miss (s_vxlan);
|
||||||
|
|
||||||
plerr = nm_platform_link_vxlan_add (nm_device_get_platform (device), iface, &props, out_plink);
|
r = nm_platform_link_vxlan_add (nm_device_get_platform (device), iface, &props, out_plink);
|
||||||
if (plerr != NM_PLATFORM_ERROR_SUCCESS) {
|
if (r < 0) {
|
||||||
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
||||||
"Failed to create VXLAN interface '%s' for '%s': %s",
|
"Failed to create VXLAN interface '%s' for '%s': %s",
|
||||||
iface,
|
iface,
|
||||||
nm_connection_get_id (connection),
|
nm_connection_get_id (connection),
|
||||||
nm_platform_error_to_string_a (plerr));
|
nm_strerror (r));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9143,7 +9143,10 @@ _commit_mtu (NMDevice *self, const NMIP4Config *config)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mtu_desired && mtu_desired != mtu_plat) {
|
if (mtu_desired && mtu_desired != mtu_plat) {
|
||||||
if (nm_platform_link_set_mtu (nm_device_get_platform (self), ifindex, mtu_desired) == NM_PLATFORM_ERROR_CANT_SET_MTU) {
|
int r;
|
||||||
|
|
||||||
|
r = nm_platform_link_set_mtu (nm_device_get_platform (self), ifindex, mtu_desired);
|
||||||
|
if (r == -NME_PL_CANT_SET_MTU) {
|
||||||
anticipated_failure = TRUE;
|
anticipated_failure = TRUE;
|
||||||
success = FALSE;
|
success = FALSE;
|
||||||
_LOGW (LOGD_DEVICE, "mtu: failure to set MTU. %s",
|
_LOGW (LOGD_DEVICE, "mtu: failure to set MTU. %s",
|
||||||
|
|
@ -9562,18 +9565,20 @@ set_nm_ipv6ll (NMDevice *self, gboolean enable)
|
||||||
|
|
||||||
priv->ipv6ll_handle = enable;
|
priv->ipv6ll_handle = enable;
|
||||||
if (ifindex > 0) {
|
if (ifindex > 0) {
|
||||||
NMPlatformError plerr;
|
|
||||||
const char *detail = enable ? "enable" : "disable";
|
const char *detail = enable ? "enable" : "disable";
|
||||||
|
int r;
|
||||||
|
|
||||||
_LOGD (LOGD_IP6, "will %s userland IPv6LL", detail);
|
_LOGD (LOGD_IP6, "will %s userland IPv6LL", detail);
|
||||||
plerr = nm_platform_link_set_user_ipv6ll_enabled (nm_device_get_platform (self), ifindex, enable);
|
r = nm_platform_link_set_user_ipv6ll_enabled (nm_device_get_platform (self), ifindex, enable);
|
||||||
if (plerr != NM_PLATFORM_ERROR_SUCCESS) {
|
if (r < 0) {
|
||||||
_NMLOG (( plerr == NM_PLATFORM_ERROR_NOT_FOUND
|
_NMLOG ( NM_IN_SET (r, -NME_PL_NOT_FOUND
|
||||||
|| plerr == NM_PLATFORM_ERROR_OPNOTSUPP) ? LOGL_DEBUG : LOGL_WARN,
|
-NME_PL_OPNOTSUPP)
|
||||||
|
? LOGL_DEBUG
|
||||||
|
: LOGL_WARN,
|
||||||
LOGD_IP6,
|
LOGD_IP6,
|
||||||
"failed to %s userspace IPv6LL address handling (%s)",
|
"failed to %s userspace IPv6LL address handling (%s)",
|
||||||
detail,
|
detail,
|
||||||
nm_platform_error_to_string_a (plerr));
|
nm_strerror (r));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enable) {
|
if (enable) {
|
||||||
|
|
@ -15467,7 +15472,7 @@ _hw_addr_set (NMDevice *self,
|
||||||
{
|
{
|
||||||
NMDevicePrivate *priv;
|
NMDevicePrivate *priv;
|
||||||
gboolean success = FALSE;
|
gboolean success = FALSE;
|
||||||
NMPlatformError plerr;
|
int r;
|
||||||
guint8 addr_bytes[NM_UTILS_HWADDR_LEN_MAX];
|
guint8 addr_bytes[NM_UTILS_HWADDR_LEN_MAX];
|
||||||
gsize addr_len;
|
gsize addr_len;
|
||||||
gboolean was_taken_down = FALSE;
|
gboolean was_taken_down = FALSE;
|
||||||
|
|
@ -15504,21 +15509,21 @@ _hw_addr_set (NMDevice *self,
|
||||||
}
|
}
|
||||||
|
|
||||||
again:
|
again:
|
||||||
plerr = nm_platform_link_set_address (nm_device_get_platform (self), nm_device_get_ip_ifindex (self), addr_bytes, addr_len);
|
r = nm_platform_link_set_address (nm_device_get_platform (self), nm_device_get_ip_ifindex (self), addr_bytes, addr_len);
|
||||||
success = (plerr == NM_PLATFORM_ERROR_SUCCESS);
|
success = (r >= 0);
|
||||||
if (!success) {
|
if (!success) {
|
||||||
retry_down = !was_taken_down
|
retry_down = !was_taken_down
|
||||||
&& plerr != NM_PLATFORM_ERROR_NOT_FOUND
|
&& r != -NME_PL_NOT_FOUND
|
||||||
&& nm_platform_link_is_up (nm_device_get_platform (self),
|
&& nm_platform_link_is_up (nm_device_get_platform (self),
|
||||||
nm_device_get_ip_ifindex (self));
|
nm_device_get_ip_ifindex (self));
|
||||||
_NMLOG ( retry_down
|
_NMLOG ( ( retry_down
|
||||||
|| plerr == NM_PLATFORM_ERROR_NOT_FOUND
|
|| r == -NME_PL_NOT_FOUND)
|
||||||
? LOGL_DEBUG
|
? LOGL_DEBUG
|
||||||
: LOGL_WARN,
|
: LOGL_WARN,
|
||||||
LOGD_DEVICE,
|
LOGD_DEVICE,
|
||||||
"set-hw-addr: failed to %s MAC address to %s (%s) (%s)%s",
|
"set-hw-addr: failed to %s MAC address to %s (%s) (%s)%s",
|
||||||
operation, addr, detail,
|
operation, addr, detail,
|
||||||
nm_platform_error_to_string_a (plerr),
|
nm_strerror (r),
|
||||||
retry_down ? " (retry with taking down)" : "");
|
retry_down ? " (retry with taking down)" : "");
|
||||||
} else {
|
} else {
|
||||||
/* MAC address successfully changed; update the current MAC to match */
|
/* MAC address successfully changed; update the current MAC to match */
|
||||||
|
|
|
||||||
|
|
@ -804,15 +804,15 @@ create_and_realize (NMDevice *device,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
const char *iface = nm_device_get_iface (device);
|
const char *iface = nm_device_get_iface (device);
|
||||||
NMPlatformError plerr;
|
int r;
|
||||||
|
|
||||||
plerr = nm_platform_link_team_add (nm_device_get_platform (device), iface, out_plink);
|
r = nm_platform_link_team_add (nm_device_get_platform (device), iface, out_plink);
|
||||||
if (plerr != NM_PLATFORM_ERROR_SUCCESS) {
|
if (r < 0) {
|
||||||
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
||||||
"Failed to create team master interface '%s' for '%s': %s",
|
"Failed to create team master interface '%s' for '%s': %s",
|
||||||
iface,
|
iface,
|
||||||
nm_connection_get_id (connection),
|
nm_connection_get_id (connection),
|
||||||
nm_platform_error_to_string_a (plerr));
|
nm_strerror (r));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -283,7 +283,7 @@ link_add_pre (NMPlatform *platform,
|
||||||
return device;
|
return device;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static int
|
||||||
link_add (NMPlatform *platform,
|
link_add (NMPlatform *platform,
|
||||||
const char *name,
|
const char *name,
|
||||||
NMLinkType type,
|
NMLinkType type,
|
||||||
|
|
@ -335,7 +335,7 @@ link_add (NMPlatform *platform,
|
||||||
if (veth_peer)
|
if (veth_peer)
|
||||||
link_changed (platform, device_veth, cache_op_veth, NULL);
|
link_changed (platform, device_veth, cache_op_veth, NULL);
|
||||||
|
|
||||||
return TRUE;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static NMFakePlatformLink *
|
static NMFakePlatformLink *
|
||||||
|
|
@ -563,7 +563,7 @@ link_set_noarp (NMPlatform *platform, int ifindex)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static NMPlatformError
|
static int
|
||||||
link_set_address (NMPlatform *platform, int ifindex, gconstpointer addr, size_t len)
|
link_set_address (NMPlatform *platform, int ifindex, gconstpointer addr, size_t len)
|
||||||
{
|
{
|
||||||
NMFakePlatformLink *device = link_get (platform, ifindex);
|
NMFakePlatformLink *device = link_get (platform, ifindex);
|
||||||
|
|
@ -572,10 +572,10 @@ link_set_address (NMPlatform *platform, int ifindex, gconstpointer addr, size_t
|
||||||
if ( len == 0
|
if ( len == 0
|
||||||
|| len > NM_UTILS_HWADDR_LEN_MAX
|
|| len > NM_UTILS_HWADDR_LEN_MAX
|
||||||
|| !addr)
|
|| !addr)
|
||||||
g_return_val_if_reached (NM_PLATFORM_ERROR_BUG);
|
g_return_val_if_reached (-NME_BUG);
|
||||||
|
|
||||||
if (!device)
|
if (!device)
|
||||||
return NM_PLATFORM_ERROR_EXISTS;
|
return -NME_PL_EXISTS;
|
||||||
|
|
||||||
obj_tmp = nmp_object_clone (device->obj, FALSE);
|
obj_tmp = nmp_object_clone (device->obj, FALSE);
|
||||||
obj_tmp->link.addr.len = len;
|
obj_tmp->link.addr.len = len;
|
||||||
|
|
@ -583,10 +583,10 @@ link_set_address (NMPlatform *platform, int ifindex, gconstpointer addr, size_t
|
||||||
memcpy (obj_tmp->link.addr.data, addr, len);
|
memcpy (obj_tmp->link.addr.data, addr, len);
|
||||||
|
|
||||||
link_set_obj (platform, device, obj_tmp);
|
link_set_obj (platform, device, obj_tmp);
|
||||||
return NM_PLATFORM_ERROR_SUCCESS;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static NMPlatformError
|
static int
|
||||||
link_set_mtu (NMPlatform *platform, int ifindex, guint32 mtu)
|
link_set_mtu (NMPlatform *platform, int ifindex, guint32 mtu)
|
||||||
{
|
{
|
||||||
NMFakePlatformLink *device = link_get (platform, ifindex);
|
NMFakePlatformLink *device = link_get (platform, ifindex);
|
||||||
|
|
@ -594,13 +594,13 @@ link_set_mtu (NMPlatform *platform, int ifindex, guint32 mtu)
|
||||||
|
|
||||||
if (!device) {
|
if (!device) {
|
||||||
_LOGE ("failure changing link: netlink error (No such device)");
|
_LOGE ("failure changing link: netlink error (No such device)");
|
||||||
return NM_PLATFORM_ERROR_EXISTS;
|
return -NME_PL_EXISTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
obj_tmp = nmp_object_clone (device->obj, FALSE);
|
obj_tmp = nmp_object_clone (device->obj, FALSE);
|
||||||
obj_tmp->link.mtu = mtu;
|
obj_tmp->link.mtu = mtu;
|
||||||
link_set_obj (platform, device, obj_tmp);
|
link_set_obj (platform, device, obj_tmp);
|
||||||
return NM_PLATFORM_ERROR_SUCCESS;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
|
|
@ -1187,7 +1187,7 @@ object_delete (NMPlatform *platform, const NMPObject *obj)
|
||||||
return ipx_route_delete (platform, AF_UNSPEC, -1, obj);
|
return ipx_route_delete (platform, AF_UNSPEC, -1, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
static NMPlatformError
|
static int
|
||||||
ip_route_add (NMPlatform *platform,
|
ip_route_add (NMPlatform *platform,
|
||||||
NMPNlmFlags flags,
|
NMPNlmFlags flags,
|
||||||
int addr_family,
|
int addr_family,
|
||||||
|
|
@ -1276,7 +1276,7 @@ ip_route_add (NMPlatform *platform,
|
||||||
nm_log_warn (LOGD_PLATFORM, "Fake platform: failure adding ip6-route '%d: %s/%d %d': Network Unreachable",
|
nm_log_warn (LOGD_PLATFORM, "Fake platform: failure adding ip6-route '%d: %s/%d %d': Network Unreachable",
|
||||||
r->ifindex, nm_utils_inet6_ntop (&r6->network, sbuf), r->plen, r->metric);
|
r->ifindex, nm_utils_inet6_ntop (&r6->network, sbuf), r->plen, r->metric);
|
||||||
}
|
}
|
||||||
return NM_PLATFORM_ERROR_UNSPECIFIED;
|
return -NME_UNSPEC;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1338,7 +1338,7 @@ ip_route_add (NMPlatform *platform,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NM_PLATFORM_ERROR_SUCCESS;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@
|
||||||
#include "nm-core-internal.h"
|
#include "nm-core-internal.h"
|
||||||
#include "nm-setting-vlan.h"
|
#include "nm-setting-vlan.h"
|
||||||
|
|
||||||
|
#include "nm-utils/nm-errno.h"
|
||||||
#include "nm-utils/nm-secret-utils.h"
|
#include "nm-utils/nm-secret-utils.h"
|
||||||
#include "nm-netlink.h"
|
#include "nm-netlink.h"
|
||||||
#include "nm-core-utils.h"
|
#include "nm-core-utils.h"
|
||||||
|
|
@ -474,14 +475,14 @@ static struct nl_sock *_genl_sock (NMLinuxPlatform *platform);
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static NMPlatformError
|
static int
|
||||||
wait_for_nl_response_to_plerr (WaitForNlResponseResult seq_result)
|
wait_for_nl_response_to_nmerr (WaitForNlResponseResult seq_result)
|
||||||
{
|
{
|
||||||
if (seq_result == WAIT_FOR_NL_RESPONSE_RESULT_RESPONSE_OK)
|
if (seq_result == WAIT_FOR_NL_RESPONSE_RESULT_RESPONSE_OK)
|
||||||
return NM_PLATFORM_ERROR_SUCCESS;
|
return 0;
|
||||||
if (seq_result < 0)
|
if (seq_result < 0)
|
||||||
return (NMPlatformError) seq_result;
|
return (int) seq_result;
|
||||||
return NM_PLATFORM_ERROR_NETLINK;
|
return -NME_PL_NETLINK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
|
|
@ -4746,7 +4747,7 @@ _nl_send_nlmsg (NMPlatform *platform,
|
||||||
|
|
||||||
nle = nl_send_auto (priv->nlh, nlmsg);
|
nle = nl_send_auto (priv->nlh, nlmsg);
|
||||||
if (nle < 0) {
|
if (nle < 0) {
|
||||||
_LOGD ("netlink: nl-send-nlmsg: failed sending message: %s (%d)", nl_geterror (nle), nle);
|
_LOGD ("netlink: nl-send-nlmsg: failed sending message: %s (%d)", nm_strerror (nle), nle);
|
||||||
return nle;
|
return nle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4792,7 +4793,7 @@ do_request_link_no_delayed_actions (NMPlatform *platform, int ifindex, const cha
|
||||||
if (nle < 0) {
|
if (nle < 0) {
|
||||||
_LOGE ("do-request-link: %d %s: failed sending netlink request \"%s\" (%d)",
|
_LOGE ("do-request-link: %d %s: failed sending netlink request \"%s\" (%d)",
|
||||||
ifindex, name ?: "",
|
ifindex, name ?: "",
|
||||||
nl_geterror (nle), -nle);
|
nm_strerror (nle), -nle);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -5122,7 +5123,7 @@ event_valid_msg (NMPlatform *platform, struct nl_msg *msg, gboolean handle_event
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static gboolean
|
static int
|
||||||
do_add_link_with_lookup (NMPlatform *platform,
|
do_add_link_with_lookup (NMPlatform *platform,
|
||||||
NMLinkType link_type,
|
NMLinkType link_type,
|
||||||
const char *name,
|
const char *name,
|
||||||
|
|
@ -5143,9 +5144,9 @@ do_add_link_with_lookup (NMPlatform *platform,
|
||||||
_LOGE ("do-add-link[%s/%s]: failed sending netlink request \"%s\" (%d)",
|
_LOGE ("do-add-link[%s/%s]: failed sending netlink request \"%s\" (%d)",
|
||||||
name,
|
name,
|
||||||
nm_link_type_to_string (link_type),
|
nm_link_type_to_string (link_type),
|
||||||
nl_geterror (nle), -nle);
|
nm_strerror (nle), -nle);
|
||||||
NM_SET_OUT (out_link, NULL);
|
NM_SET_OUT (out_link, NULL);
|
||||||
return FALSE;
|
return nle;
|
||||||
}
|
}
|
||||||
|
|
||||||
delayed_action_handle_all (platform, FALSE);
|
delayed_action_handle_all (platform, FALSE);
|
||||||
|
|
@ -5165,10 +5166,10 @@ do_add_link_with_lookup (NMPlatform *platform,
|
||||||
*out_link = NMP_OBJECT_CAST_LINK (obj);
|
*out_link = NMP_OBJECT_CAST_LINK (obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
return seq_result == WAIT_FOR_NL_RESPONSE_RESULT_RESPONSE_OK;
|
return wait_for_nl_response_to_nmerr (seq_result);
|
||||||
}
|
}
|
||||||
|
|
||||||
static NMPlatformError
|
static int
|
||||||
do_add_addrroute (NMPlatform *platform,
|
do_add_addrroute (NMPlatform *platform,
|
||||||
const NMPObject *obj_id,
|
const NMPObject *obj_id,
|
||||||
struct nl_msg *nlmsg,
|
struct nl_msg *nlmsg,
|
||||||
|
|
@ -5190,8 +5191,8 @@ do_add_addrroute (NMPlatform *platform,
|
||||||
_LOGE ("do-add-%s[%s]: failure sending netlink request \"%s\" (%d)",
|
_LOGE ("do-add-%s[%s]: failure sending netlink request \"%s\" (%d)",
|
||||||
NMP_OBJECT_GET_CLASS (obj_id)->obj_type_name,
|
NMP_OBJECT_GET_CLASS (obj_id)->obj_type_name,
|
||||||
nmp_object_to_string (obj_id, NMP_OBJECT_TO_STRING_ID, NULL, 0),
|
nmp_object_to_string (obj_id, NMP_OBJECT_TO_STRING_ID, NULL, 0),
|
||||||
nl_geterror (nle), -nle);
|
nm_strerror (nle), -nle);
|
||||||
return NM_PLATFORM_ERROR_NETLINK;
|
return -NME_PL_NETLINK;
|
||||||
}
|
}
|
||||||
|
|
||||||
delayed_action_handle_all (platform, FALSE);
|
delayed_action_handle_all (platform, FALSE);
|
||||||
|
|
@ -5220,7 +5221,7 @@ do_add_addrroute (NMPlatform *platform,
|
||||||
do_request_one_type (platform, NMP_OBJECT_GET_TYPE (obj_id));
|
do_request_one_type (platform, NMP_OBJECT_GET_TYPE (obj_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
return wait_for_nl_response_to_plerr (seq_result);
|
return wait_for_nl_response_to_nmerr (seq_result);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
@ -5240,7 +5241,7 @@ do_delete_object (NMPlatform *platform, const NMPObject *obj_id, struct nl_msg *
|
||||||
_LOGE ("do-delete-%s[%s]: failure sending netlink request \"%s\" (%d)",
|
_LOGE ("do-delete-%s[%s]: failure sending netlink request \"%s\" (%d)",
|
||||||
NMP_OBJECT_GET_CLASS (obj_id)->obj_type_name,
|
NMP_OBJECT_GET_CLASS (obj_id)->obj_type_name,
|
||||||
nmp_object_to_string (obj_id, NMP_OBJECT_TO_STRING_ID, NULL, 0),
|
nmp_object_to_string (obj_id, NMP_OBJECT_TO_STRING_ID, NULL, 0),
|
||||||
nl_geterror (nle), -nle);
|
nm_strerror (nle), -nle);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -5288,7 +5289,7 @@ do_delete_object (NMPlatform *platform, const NMPObject *obj_id, struct nl_msg *
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
static NMPlatformError
|
static int
|
||||||
do_change_link (NMPlatform *platform,
|
do_change_link (NMPlatform *platform,
|
||||||
ChangeLinkType change_link_type,
|
ChangeLinkType change_link_type,
|
||||||
int ifindex,
|
int ifindex,
|
||||||
|
|
@ -5300,7 +5301,7 @@ do_change_link (NMPlatform *platform,
|
||||||
WaitForNlResponseResult seq_result = WAIT_FOR_NL_RESPONSE_RESULT_UNKNOWN;
|
WaitForNlResponseResult seq_result = WAIT_FOR_NL_RESPONSE_RESULT_UNKNOWN;
|
||||||
gs_free char *errmsg = NULL;
|
gs_free char *errmsg = NULL;
|
||||||
char s_buf[256];
|
char s_buf[256];
|
||||||
NMPlatformError result = NM_PLATFORM_ERROR_SUCCESS;
|
int result = 0;
|
||||||
NMLogLevel log_level = LOGL_DEBUG;
|
NMLogLevel log_level = LOGL_DEBUG;
|
||||||
const char *log_result = "failure";
|
const char *log_result = "failure";
|
||||||
const char *log_detail = "";
|
const char *log_detail = "";
|
||||||
|
|
@ -5318,7 +5319,7 @@ retry:
|
||||||
if (nle < 0) {
|
if (nle < 0) {
|
||||||
log_level = LOGL_ERR;
|
log_level = LOGL_ERR;
|
||||||
log_detail_free = g_strdup_printf (", failure sending netlink request: %s (%d)",
|
log_detail_free = g_strdup_printf (", failure sending netlink request: %s (%d)",
|
||||||
nl_geterror (nle), -nle);
|
nm_strerror (nle), -nle);
|
||||||
log_detail = log_detail_free;
|
log_detail = log_detail_free;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
@ -5343,11 +5344,11 @@ retry:
|
||||||
/* */
|
/* */
|
||||||
} else if (NM_IN_SET (-((int) seq_result), ESRCH, ENOENT)) {
|
} else if (NM_IN_SET (-((int) seq_result), ESRCH, ENOENT)) {
|
||||||
log_detail = ", firmware not found";
|
log_detail = ", firmware not found";
|
||||||
result = NM_PLATFORM_ERROR_NO_FIRMWARE;
|
result = -NME_PL_NO_FIRMWARE;
|
||||||
} else if ( NM_IN_SET (-((int) seq_result), ERANGE)
|
} else if ( NM_IN_SET (-((int) seq_result), ERANGE)
|
||||||
&& change_link_type == CHANGE_LINK_TYPE_SET_MTU) {
|
&& change_link_type == CHANGE_LINK_TYPE_SET_MTU) {
|
||||||
log_detail = ", setting MTU to requested size is not possible";
|
log_detail = ", setting MTU to requested size is not possible";
|
||||||
result = NM_PLATFORM_ERROR_CANT_SET_MTU;
|
result = -NME_PL_CANT_SET_MTU;
|
||||||
} else if ( NM_IN_SET (-((int) seq_result), ENFILE)
|
} else if ( NM_IN_SET (-((int) seq_result), ENFILE)
|
||||||
&& change_link_type == CHANGE_LINK_TYPE_SET_ADDRESS
|
&& change_link_type == CHANGE_LINK_TYPE_SET_ADDRESS
|
||||||
&& (obj_cache = nmp_cache_lookup_link (nm_platform_get_cache (platform), ifindex))
|
&& (obj_cache = nmp_cache_lookup_link (nm_platform_get_cache (platform), ifindex))
|
||||||
|
|
@ -5357,16 +5358,16 @@ retry:
|
||||||
* If the MAC address is as expected, assume success? */
|
* If the MAC address is as expected, assume success? */
|
||||||
log_result = "success";
|
log_result = "success";
|
||||||
log_detail = " (assume success changing address)";
|
log_detail = " (assume success changing address)";
|
||||||
result = NM_PLATFORM_ERROR_SUCCESS;
|
result = 0;
|
||||||
} else if (NM_IN_SET (-((int) seq_result), ENODEV)) {
|
} else if (NM_IN_SET (-((int) seq_result), ENODEV)) {
|
||||||
log_level = LOGL_DEBUG;
|
log_level = LOGL_DEBUG;
|
||||||
result = NM_PLATFORM_ERROR_NOT_FOUND;
|
result = -NME_PL_NOT_FOUND;
|
||||||
} else if (-((int) seq_result) == EAFNOSUPPORT) {
|
} else if (-((int) seq_result) == EAFNOSUPPORT) {
|
||||||
log_level = LOGL_DEBUG;
|
log_level = LOGL_DEBUG;
|
||||||
result = NM_PLATFORM_ERROR_OPNOTSUPP;
|
result = -NME_PL_OPNOTSUPP;
|
||||||
} else {
|
} else {
|
||||||
log_level = LOGL_WARN;
|
log_level = LOGL_WARN;
|
||||||
result = NM_PLATFORM_ERROR_UNSPECIFIED;
|
result = -NME_UNSPEC;
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
|
@ -5379,7 +5380,7 @@ out:
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static int
|
||||||
link_add (NMPlatform *platform,
|
link_add (NMPlatform *platform,
|
||||||
const char *name,
|
const char *name,
|
||||||
NMLinkType type,
|
NMLinkType type,
|
||||||
|
|
@ -5409,17 +5410,17 @@ link_add (NMPlatform *platform,
|
||||||
0,
|
0,
|
||||||
0);
|
0);
|
||||||
if (!nlmsg)
|
if (!nlmsg)
|
||||||
return FALSE;
|
return -NME_UNSPEC;
|
||||||
|
|
||||||
if (address && address_len)
|
if (address && address_len)
|
||||||
NLA_PUT (nlmsg, IFLA_ADDRESS, address_len, address);
|
NLA_PUT (nlmsg, IFLA_ADDRESS, address_len, address);
|
||||||
|
|
||||||
if (!_nl_msg_new_link_set_linkinfo (nlmsg, type, veth_peer))
|
if (!_nl_msg_new_link_set_linkinfo (nlmsg, type, veth_peer))
|
||||||
return FALSE;
|
return -NME_UNSPEC;
|
||||||
|
|
||||||
return do_add_link_with_lookup (platform, type, name, nlmsg, out_link);
|
return do_add_link_with_lookup (platform, type, name, nlmsg, out_link);
|
||||||
nla_put_failure:
|
nla_put_failure:
|
||||||
g_return_val_if_reached (FALSE);
|
g_return_val_if_reached (-NME_BUG);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
@ -5474,13 +5475,13 @@ link_set_netns (NMPlatform *platform,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
NLA_PUT (nlmsg, IFLA_NET_NS_FD, 4, &netns_fd);
|
NLA_PUT (nlmsg, IFLA_NET_NS_FD, 4, &netns_fd);
|
||||||
return do_change_link (platform, CHANGE_LINK_TYPE_UNSPEC, ifindex, nlmsg, NULL) == NM_PLATFORM_ERROR_SUCCESS;
|
return (do_change_link (platform, CHANGE_LINK_TYPE_UNSPEC, ifindex, nlmsg, NULL) >= 0);
|
||||||
|
|
||||||
nla_put_failure:
|
nla_put_failure:
|
||||||
g_return_val_if_reached (FALSE);
|
g_return_val_if_reached (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static NMPlatformError
|
static int
|
||||||
link_change_flags (NMPlatform *platform,
|
link_change_flags (NMPlatform *platform,
|
||||||
int ifindex,
|
int ifindex,
|
||||||
unsigned flags_mask,
|
unsigned flags_mask,
|
||||||
|
|
@ -5503,37 +5504,36 @@ link_change_flags (NMPlatform *platform,
|
||||||
flags_mask,
|
flags_mask,
|
||||||
flags_set);
|
flags_set);
|
||||||
if (!nlmsg)
|
if (!nlmsg)
|
||||||
return NM_PLATFORM_ERROR_UNSPECIFIED;
|
return -NME_UNSPEC;
|
||||||
return do_change_link (platform, CHANGE_LINK_TYPE_UNSPEC, ifindex, nlmsg, NULL);
|
return do_change_link (platform, CHANGE_LINK_TYPE_UNSPEC, ifindex, nlmsg, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
link_set_up (NMPlatform *platform, int ifindex, gboolean *out_no_firmware)
|
link_set_up (NMPlatform *platform, int ifindex, gboolean *out_no_firmware)
|
||||||
{
|
{
|
||||||
NMPlatformError plerr;
|
int r;
|
||||||
|
|
||||||
plerr = link_change_flags (platform, ifindex, IFF_UP, IFF_UP);
|
r = link_change_flags (platform, ifindex, IFF_UP, IFF_UP);
|
||||||
if (out_no_firmware)
|
NM_SET_OUT (out_no_firmware, (r == -NME_PL_NO_FIRMWARE));
|
||||||
*out_no_firmware = plerr == NM_PLATFORM_ERROR_NO_FIRMWARE;
|
return r >= 0;
|
||||||
return plerr == NM_PLATFORM_ERROR_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
link_set_down (NMPlatform *platform, int ifindex)
|
link_set_down (NMPlatform *platform, int ifindex)
|
||||||
{
|
{
|
||||||
return link_change_flags (platform, ifindex, IFF_UP, 0) == NM_PLATFORM_ERROR_SUCCESS;
|
return (link_change_flags (platform, ifindex, IFF_UP, 0) >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
link_set_arp (NMPlatform *platform, int ifindex)
|
link_set_arp (NMPlatform *platform, int ifindex)
|
||||||
{
|
{
|
||||||
return link_change_flags (platform, ifindex, IFF_NOARP, 0) == NM_PLATFORM_ERROR_SUCCESS;
|
return (link_change_flags (platform, ifindex, IFF_NOARP, 0) >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
link_set_noarp (NMPlatform *platform, int ifindex)
|
link_set_noarp (NMPlatform *platform, int ifindex)
|
||||||
{
|
{
|
||||||
return link_change_flags (platform, ifindex, IFF_NOARP, IFF_NOARP) == NM_PLATFORM_ERROR_SUCCESS;
|
return (link_change_flags (platform, ifindex, IFF_NOARP, IFF_NOARP) >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
|
|
@ -5548,7 +5548,7 @@ link_get_udi (NMPlatform *platform, int ifindex)
|
||||||
return udev_device_get_syspath (obj->_link.udev.device);
|
return udev_device_get_syspath (obj->_link.udev.device);
|
||||||
}
|
}
|
||||||
|
|
||||||
static NMPlatformError
|
static int
|
||||||
link_set_user_ipv6ll_enabled (NMPlatform *platform, int ifindex, gboolean enabled)
|
link_set_user_ipv6ll_enabled (NMPlatform *platform, int ifindex, gboolean enabled)
|
||||||
{
|
{
|
||||||
nm_auto_nlmsg struct nl_msg *nlmsg = NULL;
|
nm_auto_nlmsg struct nl_msg *nlmsg = NULL;
|
||||||
|
|
@ -5560,7 +5560,7 @@ link_set_user_ipv6ll_enabled (NMPlatform *platform, int ifindex, gboolean enable
|
||||||
|
|
||||||
if (!_support_user_ipv6ll_get ()) {
|
if (!_support_user_ipv6ll_get ()) {
|
||||||
_LOGD ("link: change %d: user-ipv6ll: not supported", ifindex);
|
_LOGD ("link: change %d: user-ipv6ll: not supported", ifindex);
|
||||||
return NM_PLATFORM_ERROR_OPNOTSUPP;
|
return -NME_PL_OPNOTSUPP;
|
||||||
}
|
}
|
||||||
|
|
||||||
nlmsg = _nl_msg_new_link (RTM_NEWLINK,
|
nlmsg = _nl_msg_new_link (RTM_NEWLINK,
|
||||||
|
|
@ -5571,7 +5571,7 @@ link_set_user_ipv6ll_enabled (NMPlatform *platform, int ifindex, gboolean enable
|
||||||
0);
|
0);
|
||||||
if ( !nlmsg
|
if ( !nlmsg
|
||||||
|| !_nl_msg_new_link_set_afspec (nlmsg, mode, NULL))
|
|| !_nl_msg_new_link_set_afspec (nlmsg, mode, NULL))
|
||||||
g_return_val_if_reached (NM_PLATFORM_ERROR_BUG);
|
g_return_val_if_reached (-NME_BUG);
|
||||||
|
|
||||||
return do_change_link (platform, CHANGE_LINK_TYPE_UNSPEC, ifindex, nlmsg, NULL);
|
return do_change_link (platform, CHANGE_LINK_TYPE_UNSPEC, ifindex, nlmsg, NULL);
|
||||||
}
|
}
|
||||||
|
|
@ -5589,7 +5589,7 @@ link_set_token (NMPlatform *platform, int ifindex, NMUtilsIPv6IfaceId iid)
|
||||||
if (!nlmsg || !_nl_msg_new_link_set_afspec (nlmsg, -1, &iid))
|
if (!nlmsg || !_nl_msg_new_link_set_afspec (nlmsg, -1, &iid))
|
||||||
g_return_val_if_reached (FALSE);
|
g_return_val_if_reached (FALSE);
|
||||||
|
|
||||||
return do_change_link (platform, CHANGE_LINK_TYPE_UNSPEC, ifindex, nlmsg, NULL) == NM_PLATFORM_ERROR_SUCCESS;
|
return (do_change_link (platform, CHANGE_LINK_TYPE_UNSPEC, ifindex, nlmsg, NULL) >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
@ -5649,7 +5649,7 @@ link_supports_sriov (NMPlatform *platform, int ifindex)
|
||||||
return total > 0;
|
return total > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static NMPlatformError
|
static int
|
||||||
link_set_address (NMPlatform *platform, int ifindex, gconstpointer address, size_t length)
|
link_set_address (NMPlatform *platform, int ifindex, gconstpointer address, size_t length)
|
||||||
{
|
{
|
||||||
nm_auto_nlmsg struct nl_msg *nlmsg = NULL;
|
nm_auto_nlmsg struct nl_msg *nlmsg = NULL;
|
||||||
|
|
@ -5661,7 +5661,7 @@ link_set_address (NMPlatform *platform, int ifindex, gconstpointer address, size
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!address || !length)
|
if (!address || !length)
|
||||||
g_return_val_if_reached (NM_PLATFORM_ERROR_BUG);
|
g_return_val_if_reached (-NME_BUG);
|
||||||
|
|
||||||
nlmsg = _nl_msg_new_link (RTM_NEWLINK,
|
nlmsg = _nl_msg_new_link (RTM_NEWLINK,
|
||||||
0,
|
0,
|
||||||
|
|
@ -5670,16 +5670,16 @@ link_set_address (NMPlatform *platform, int ifindex, gconstpointer address, size
|
||||||
0,
|
0,
|
||||||
0);
|
0);
|
||||||
if (!nlmsg)
|
if (!nlmsg)
|
||||||
g_return_val_if_reached (NM_PLATFORM_ERROR_UNSPECIFIED);
|
g_return_val_if_reached (-NME_BUG);
|
||||||
|
|
||||||
NLA_PUT (nlmsg, IFLA_ADDRESS, length, address);
|
NLA_PUT (nlmsg, IFLA_ADDRESS, length, address);
|
||||||
|
|
||||||
return do_change_link (platform, CHANGE_LINK_TYPE_SET_ADDRESS, ifindex, nlmsg, &d);
|
return do_change_link (platform, CHANGE_LINK_TYPE_SET_ADDRESS, ifindex, nlmsg, &d);
|
||||||
nla_put_failure:
|
nla_put_failure:
|
||||||
g_return_val_if_reached (NM_PLATFORM_ERROR_UNSPECIFIED);
|
g_return_val_if_reached (-NME_BUG);
|
||||||
}
|
}
|
||||||
|
|
||||||
static NMPlatformError
|
static int
|
||||||
link_set_name (NMPlatform *platform, int ifindex, const char *name)
|
link_set_name (NMPlatform *platform, int ifindex, const char *name)
|
||||||
{
|
{
|
||||||
nm_auto_nlmsg struct nl_msg *nlmsg = NULL;
|
nm_auto_nlmsg struct nl_msg *nlmsg = NULL;
|
||||||
|
|
@ -5691,11 +5691,11 @@ link_set_name (NMPlatform *platform, int ifindex, const char *name)
|
||||||
0,
|
0,
|
||||||
0);
|
0);
|
||||||
if (!nlmsg)
|
if (!nlmsg)
|
||||||
g_return_val_if_reached (NM_PLATFORM_ERROR_UNSPECIFIED);
|
g_return_val_if_reached (-NME_BUG);
|
||||||
|
|
||||||
NLA_PUT (nlmsg, IFLA_IFNAME, strlen (name) + 1, name);
|
NLA_PUT (nlmsg, IFLA_IFNAME, strlen (name) + 1, name);
|
||||||
|
|
||||||
return do_change_link (platform, CHANGE_LINK_TYPE_UNSPEC, ifindex, nlmsg, NULL) == NM_PLATFORM_ERROR_SUCCESS;
|
return (do_change_link (platform, CHANGE_LINK_TYPE_UNSPEC, ifindex, nlmsg, NULL) >= 0);
|
||||||
nla_put_failure:
|
nla_put_failure:
|
||||||
g_return_val_if_reached (FALSE);
|
g_return_val_if_reached (FALSE);
|
||||||
}
|
}
|
||||||
|
|
@ -5714,7 +5714,7 @@ link_get_permanent_address (NMPlatform *platform,
|
||||||
return nmp_utils_ethtool_get_permanent_address (ifindex, buf, length);
|
return nmp_utils_ethtool_get_permanent_address (ifindex, buf, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
static NMPlatformError
|
static int
|
||||||
link_set_mtu (NMPlatform *platform, int ifindex, guint32 mtu)
|
link_set_mtu (NMPlatform *platform, int ifindex, guint32 mtu)
|
||||||
{
|
{
|
||||||
nm_auto_nlmsg struct nl_msg *nlmsg = NULL;
|
nm_auto_nlmsg struct nl_msg *nlmsg = NULL;
|
||||||
|
|
@ -5840,7 +5840,7 @@ link_set_sriov_vfs (NMPlatform *platform, int ifindex, const NMPlatformVF *const
|
||||||
0,
|
0,
|
||||||
0);
|
0);
|
||||||
if (!nlmsg)
|
if (!nlmsg)
|
||||||
g_return_val_if_reached (NM_PLATFORM_ERROR_UNSPECIFIED);
|
g_return_val_if_reached (-NME_BUG);
|
||||||
|
|
||||||
if (!(list = nla_nest_start (nlmsg, IFLA_VFINFO_LIST)))
|
if (!(list = nla_nest_start (nlmsg, IFLA_VFINFO_LIST)))
|
||||||
goto nla_put_failure;
|
goto nla_put_failure;
|
||||||
|
|
@ -5916,7 +5916,7 @@ link_set_sriov_vfs (NMPlatform *platform, int ifindex, const NMPlatformVF *const
|
||||||
}
|
}
|
||||||
nla_nest_end (nlmsg, list);
|
nla_nest_end (nlmsg, list);
|
||||||
|
|
||||||
return do_change_link (platform, CHANGE_LINK_TYPE_UNSPEC, ifindex, nlmsg, NULL) == NM_PLATFORM_ERROR_SUCCESS;
|
return (do_change_link (platform, CHANGE_LINK_TYPE_UNSPEC, ifindex, nlmsg, NULL) >= 0);
|
||||||
nla_put_failure:
|
nla_put_failure:
|
||||||
g_return_val_if_reached (FALSE);
|
g_return_val_if_reached (FALSE);
|
||||||
}
|
}
|
||||||
|
|
@ -5984,7 +5984,7 @@ vlan_add (NMPlatform *platform,
|
||||||
0))
|
0))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return do_add_link_with_lookup (platform, NM_LINK_TYPE_VLAN, name, nlmsg, out_link);
|
return (do_add_link_with_lookup (platform, NM_LINK_TYPE_VLAN, name, nlmsg, out_link) >= 0);
|
||||||
nla_put_failure:
|
nla_put_failure:
|
||||||
g_return_val_if_reached (FALSE);
|
g_return_val_if_reached (FALSE);
|
||||||
}
|
}
|
||||||
|
|
@ -6031,9 +6031,9 @@ link_gre_add (NMPlatform *platform,
|
||||||
nla_nest_end (nlmsg, data);
|
nla_nest_end (nlmsg, data);
|
||||||
nla_nest_end (nlmsg, info);
|
nla_nest_end (nlmsg, info);
|
||||||
|
|
||||||
return do_add_link_with_lookup (platform,
|
return (do_add_link_with_lookup (platform,
|
||||||
props->is_tap ? NM_LINK_TYPE_GRETAP : NM_LINK_TYPE_GRE,
|
props->is_tap ? NM_LINK_TYPE_GRETAP : NM_LINK_TYPE_GRE,
|
||||||
name, nlmsg, out_link);
|
name, nlmsg, out_link) >= 0);
|
||||||
nla_put_failure:
|
nla_put_failure:
|
||||||
g_return_val_if_reached (FALSE);
|
g_return_val_if_reached (FALSE);
|
||||||
}
|
}
|
||||||
|
|
@ -6089,7 +6089,7 @@ link_ip6tnl_add (NMPlatform *platform,
|
||||||
nla_nest_end (nlmsg, data);
|
nla_nest_end (nlmsg, data);
|
||||||
nla_nest_end (nlmsg, info);
|
nla_nest_end (nlmsg, info);
|
||||||
|
|
||||||
return do_add_link_with_lookup (platform, NM_LINK_TYPE_IP6TNL, name, nlmsg, out_link);
|
return (do_add_link_with_lookup (platform, NM_LINK_TYPE_IP6TNL, name, nlmsg, out_link) >= 0);
|
||||||
nla_put_failure:
|
nla_put_failure:
|
||||||
g_return_val_if_reached (FALSE);
|
g_return_val_if_reached (FALSE);
|
||||||
}
|
}
|
||||||
|
|
@ -6149,9 +6149,9 @@ link_ip6gre_add (NMPlatform *platform,
|
||||||
nla_nest_end (nlmsg, data);
|
nla_nest_end (nlmsg, data);
|
||||||
nla_nest_end (nlmsg, info);
|
nla_nest_end (nlmsg, info);
|
||||||
|
|
||||||
return do_add_link_with_lookup (platform,
|
return (do_add_link_with_lookup (platform,
|
||||||
props->is_tap ? NM_LINK_TYPE_IP6GRETAP : NM_LINK_TYPE_IP6GRE,
|
props->is_tap ? NM_LINK_TYPE_IP6GRETAP : NM_LINK_TYPE_IP6GRE,
|
||||||
name, nlmsg, out_link);
|
name, nlmsg, out_link) >= 0);
|
||||||
nla_put_failure:
|
nla_put_failure:
|
||||||
g_return_val_if_reached (FALSE);
|
g_return_val_if_reached (FALSE);
|
||||||
}
|
}
|
||||||
|
|
@ -6194,7 +6194,7 @@ link_ipip_add (NMPlatform *platform,
|
||||||
nla_nest_end (nlmsg, data);
|
nla_nest_end (nlmsg, data);
|
||||||
nla_nest_end (nlmsg, info);
|
nla_nest_end (nlmsg, info);
|
||||||
|
|
||||||
return do_add_link_with_lookup (platform, NM_LINK_TYPE_IPIP, name, nlmsg, out_link);
|
return (do_add_link_with_lookup (platform, NM_LINK_TYPE_IPIP, name, nlmsg, out_link) >= 0);
|
||||||
nla_put_failure:
|
nla_put_failure:
|
||||||
g_return_val_if_reached (FALSE);
|
g_return_val_if_reached (FALSE);
|
||||||
}
|
}
|
||||||
|
|
@ -6249,9 +6249,9 @@ link_macsec_add (NMPlatform *platform,
|
||||||
nla_nest_end (nlmsg, data);
|
nla_nest_end (nlmsg, data);
|
||||||
nla_nest_end (nlmsg, info);
|
nla_nest_end (nlmsg, info);
|
||||||
|
|
||||||
return do_add_link_with_lookup (platform,
|
return (do_add_link_with_lookup (platform,
|
||||||
NM_LINK_TYPE_MACSEC,
|
NM_LINK_TYPE_MACSEC,
|
||||||
name, nlmsg, out_link);
|
name, nlmsg, out_link) >= 0);
|
||||||
nla_put_failure:
|
nla_put_failure:
|
||||||
g_return_val_if_reached (FALSE);
|
g_return_val_if_reached (FALSE);
|
||||||
}
|
}
|
||||||
|
|
@ -6292,9 +6292,9 @@ link_macvlan_add (NMPlatform *platform,
|
||||||
nla_nest_end (nlmsg, data);
|
nla_nest_end (nlmsg, data);
|
||||||
nla_nest_end (nlmsg, info);
|
nla_nest_end (nlmsg, info);
|
||||||
|
|
||||||
return do_add_link_with_lookup (platform,
|
return (do_add_link_with_lookup (platform,
|
||||||
props->tap ? NM_LINK_TYPE_MACVTAP : NM_LINK_TYPE_MACVLAN,
|
props->tap ? NM_LINK_TYPE_MACVTAP : NM_LINK_TYPE_MACVLAN,
|
||||||
name, nlmsg, out_link);
|
name, nlmsg, out_link) >= 0);
|
||||||
nla_put_failure:
|
nla_put_failure:
|
||||||
g_return_val_if_reached (FALSE);
|
g_return_val_if_reached (FALSE);
|
||||||
}
|
}
|
||||||
|
|
@ -6337,7 +6337,7 @@ link_sit_add (NMPlatform *platform,
|
||||||
nla_nest_end (nlmsg, data);
|
nla_nest_end (nlmsg, data);
|
||||||
nla_nest_end (nlmsg, info);
|
nla_nest_end (nlmsg, info);
|
||||||
|
|
||||||
return do_add_link_with_lookup (platform, NM_LINK_TYPE_SIT, name, nlmsg, out_link);
|
return (do_add_link_with_lookup (platform, NM_LINK_TYPE_SIT, name, nlmsg, out_link) >= 0);
|
||||||
nla_put_failure:
|
nla_put_failure:
|
||||||
g_return_val_if_reached (FALSE);
|
g_return_val_if_reached (FALSE);
|
||||||
}
|
}
|
||||||
|
|
@ -6463,7 +6463,7 @@ link_vxlan_add (NMPlatform *platform,
|
||||||
nla_nest_end (nlmsg, data);
|
nla_nest_end (nlmsg, data);
|
||||||
nla_nest_end (nlmsg, info);
|
nla_nest_end (nlmsg, info);
|
||||||
|
|
||||||
return do_add_link_with_lookup (platform, NM_LINK_TYPE_VXLAN, name, nlmsg, out_link);
|
return (do_add_link_with_lookup (platform, NM_LINK_TYPE_VXLAN, name, nlmsg, out_link) >= 0);
|
||||||
nla_put_failure:
|
nla_put_failure:
|
||||||
g_return_val_if_reached (FALSE);
|
g_return_val_if_reached (FALSE);
|
||||||
}
|
}
|
||||||
|
|
@ -6495,9 +6495,9 @@ link_6lowpan_add (NMPlatform *platform,
|
||||||
|
|
||||||
nla_nest_end (nlmsg, info);
|
nla_nest_end (nlmsg, info);
|
||||||
|
|
||||||
return do_add_link_with_lookup (platform,
|
return (do_add_link_with_lookup (platform,
|
||||||
NM_LINK_TYPE_6LOWPAN,
|
NM_LINK_TYPE_6LOWPAN,
|
||||||
name, nlmsg, out_link);
|
name, nlmsg, out_link) >= 0);
|
||||||
nla_put_failure:
|
nla_put_failure:
|
||||||
g_return_val_if_reached (FALSE);
|
g_return_val_if_reached (FALSE);
|
||||||
}
|
}
|
||||||
|
|
@ -6644,7 +6644,7 @@ link_vlan_change (NMPlatform *platform,
|
||||||
new_n_egress_map))
|
new_n_egress_map))
|
||||||
g_return_val_if_reached (FALSE);
|
g_return_val_if_reached (FALSE);
|
||||||
|
|
||||||
return do_change_link (platform, CHANGE_LINK_TYPE_UNSPEC, ifindex, nlmsg, NULL) == NM_PLATFORM_ERROR_SUCCESS;
|
return (do_change_link (platform, CHANGE_LINK_TYPE_UNSPEC, ifindex, nlmsg, NULL) >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
@ -6664,7 +6664,7 @@ link_enslave (NMPlatform *platform, int master, int slave)
|
||||||
|
|
||||||
NLA_PUT_U32 (nlmsg, IFLA_MASTER, master);
|
NLA_PUT_U32 (nlmsg, IFLA_MASTER, master);
|
||||||
|
|
||||||
return do_change_link (platform, CHANGE_LINK_TYPE_UNSPEC, ifindex, nlmsg, NULL) == NM_PLATFORM_ERROR_SUCCESS;
|
return (do_change_link (platform, CHANGE_LINK_TYPE_UNSPEC, ifindex, nlmsg, NULL) >= 0);
|
||||||
nla_put_failure:
|
nla_put_failure:
|
||||||
g_return_val_if_reached (FALSE);
|
g_return_val_if_reached (FALSE);
|
||||||
}
|
}
|
||||||
|
|
@ -7032,7 +7032,7 @@ ip4_address_add (NMPlatform *platform,
|
||||||
label);
|
label);
|
||||||
|
|
||||||
nmp_object_stackinit_id_ip4_address (&obj_id, ifindex, addr, plen, peer_addr);
|
nmp_object_stackinit_id_ip4_address (&obj_id, ifindex, addr, plen, peer_addr);
|
||||||
return do_add_addrroute (platform, &obj_id, nlmsg, FALSE) == NM_PLATFORM_ERROR_SUCCESS;
|
return (do_add_addrroute (platform, &obj_id, nlmsg, FALSE) >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
@ -7062,7 +7062,7 @@ ip6_address_add (NMPlatform *platform,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
nmp_object_stackinit_id_ip6_address (&obj_id, ifindex, &addr);
|
nmp_object_stackinit_id_ip6_address (&obj_id, ifindex, &addr);
|
||||||
return do_add_addrroute (platform, &obj_id, nlmsg, FALSE) == NM_PLATFORM_ERROR_SUCCESS;
|
return (do_add_addrroute (platform, &obj_id, nlmsg, FALSE) >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
@ -7117,7 +7117,7 @@ ip6_address_delete (NMPlatform *platform, int ifindex, struct in6_addr addr, gui
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static NMPlatformError
|
static int
|
||||||
ip_route_add (NMPlatform *platform,
|
ip_route_add (NMPlatform *platform,
|
||||||
NMPNlmFlags flags,
|
NMPNlmFlags flags,
|
||||||
int addr_family,
|
int addr_family,
|
||||||
|
|
@ -7141,7 +7141,7 @@ ip_route_add (NMPlatform *platform,
|
||||||
|
|
||||||
nlmsg = _nl_msg_new_route (RTM_NEWROUTE, flags & NMP_NLM_FLAG_FMASK, &obj);
|
nlmsg = _nl_msg_new_route (RTM_NEWROUTE, flags & NMP_NLM_FLAG_FMASK, &obj);
|
||||||
if (!nlmsg)
|
if (!nlmsg)
|
||||||
g_return_val_if_reached (NM_PLATFORM_ERROR_BUG);
|
g_return_val_if_reached (-NME_BUG);
|
||||||
return do_add_addrroute (platform,
|
return do_add_addrroute (platform,
|
||||||
&obj,
|
&obj,
|
||||||
nlmsg,
|
nlmsg,
|
||||||
|
|
@ -7180,7 +7180,7 @@ object_delete (NMPlatform *platform,
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static NMPlatformError
|
static int
|
||||||
ip_route_get (NMPlatform *platform,
|
ip_route_get (NMPlatform *platform,
|
||||||
int addr_family,
|
int addr_family,
|
||||||
gconstpointer address,
|
gconstpointer address,
|
||||||
|
|
@ -7230,7 +7230,7 @@ ip_route_get (NMPlatform *platform,
|
||||||
if (nle < 0) {
|
if (nle < 0) {
|
||||||
_LOGE ("get-route: failure sending netlink request \"%s\" (%d)",
|
_LOGE ("get-route: failure sending netlink request \"%s\" (%d)",
|
||||||
g_strerror (-nle), -nle);
|
g_strerror (-nle), -nle);
|
||||||
return NM_PLATFORM_ERROR_UNSPECIFIED;
|
return -NME_UNSPEC;
|
||||||
}
|
}
|
||||||
|
|
||||||
delayed_action_handle_all (platform, FALSE);
|
delayed_action_handle_all (platform, FALSE);
|
||||||
|
|
@ -7242,24 +7242,24 @@ ip_route_get (NMPlatform *platform,
|
||||||
|
|
||||||
if (seq_result < 0) {
|
if (seq_result < 0) {
|
||||||
/* negative seq_result is an errno from kernel. Map it to negative
|
/* negative seq_result is an errno from kernel. Map it to negative
|
||||||
* NMPlatformError (which are also errno). */
|
* int (which are also errno). */
|
||||||
return (NMPlatformError) seq_result;
|
return (int) seq_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (seq_result == WAIT_FOR_NL_RESPONSE_RESULT_RESPONSE_OK) {
|
if (seq_result == WAIT_FOR_NL_RESPONSE_RESULT_RESPONSE_OK) {
|
||||||
if (route) {
|
if (route) {
|
||||||
NM_SET_OUT (out_route, g_steal_pointer (&route));
|
NM_SET_OUT (out_route, g_steal_pointer (&route));
|
||||||
return NM_PLATFORM_ERROR_SUCCESS;
|
return 0;
|
||||||
}
|
}
|
||||||
seq_result = WAIT_FOR_NL_RESPONSE_RESULT_RESPONSE_UNKNOWN;
|
seq_result = WAIT_FOR_NL_RESPONSE_RESULT_RESPONSE_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NM_PLATFORM_ERROR_UNSPECIFIED;
|
return -NME_UNSPEC;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static NMPlatformError
|
static int
|
||||||
qdisc_add (NMPlatform *platform,
|
qdisc_add (NMPlatform *platform,
|
||||||
NMPNlmFlags flags,
|
NMPNlmFlags flags,
|
||||||
const NMPlatformQdisc *qdisc)
|
const NMPlatformQdisc *qdisc)
|
||||||
|
|
@ -7277,8 +7277,8 @@ qdisc_add (NMPlatform *platform,
|
||||||
nle = _nl_send_nlmsg (platform, msg, &seq_result, &errmsg, DELAYED_ACTION_RESPONSE_TYPE_VOID, NULL);
|
nle = _nl_send_nlmsg (platform, msg, &seq_result, &errmsg, DELAYED_ACTION_RESPONSE_TYPE_VOID, NULL);
|
||||||
if (nle < 0) {
|
if (nle < 0) {
|
||||||
_LOGE ("do-add-qdisc: failed sending netlink request \"%s\" (%d)",
|
_LOGE ("do-add-qdisc: failed sending netlink request \"%s\" (%d)",
|
||||||
nl_geterror (nle), -nle);
|
nm_strerror (nle), -nle);
|
||||||
return NM_PLATFORM_ERROR_NETLINK;
|
return -NME_PL_NETLINK;
|
||||||
}
|
}
|
||||||
|
|
||||||
delayed_action_handle_all (platform, FALSE);
|
delayed_action_handle_all (platform, FALSE);
|
||||||
|
|
@ -7292,14 +7292,14 @@ qdisc_add (NMPlatform *platform,
|
||||||
wait_for_nl_response_to_string (seq_result, errmsg, s_buf, sizeof (s_buf)));
|
wait_for_nl_response_to_string (seq_result, errmsg, s_buf, sizeof (s_buf)));
|
||||||
|
|
||||||
if (seq_result == WAIT_FOR_NL_RESPONSE_RESULT_RESPONSE_OK)
|
if (seq_result == WAIT_FOR_NL_RESPONSE_RESULT_RESPONSE_OK)
|
||||||
return NM_PLATFORM_ERROR_SUCCESS;
|
return 0;
|
||||||
|
|
||||||
return NM_PLATFORM_ERROR_UNSPECIFIED;
|
return -NME_UNSPEC;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static NMPlatformError
|
static int
|
||||||
tfilter_add (NMPlatform *platform,
|
tfilter_add (NMPlatform *platform,
|
||||||
NMPNlmFlags flags,
|
NMPNlmFlags flags,
|
||||||
const NMPlatformTfilter *tfilter)
|
const NMPlatformTfilter *tfilter)
|
||||||
|
|
@ -7317,8 +7317,8 @@ tfilter_add (NMPlatform *platform,
|
||||||
nle = _nl_send_nlmsg (platform, msg, &seq_result, &errmsg, DELAYED_ACTION_RESPONSE_TYPE_VOID, NULL);
|
nle = _nl_send_nlmsg (platform, msg, &seq_result, &errmsg, DELAYED_ACTION_RESPONSE_TYPE_VOID, NULL);
|
||||||
if (nle < 0) {
|
if (nle < 0) {
|
||||||
_LOGE ("do-add-tfilter: failed sending netlink request \"%s\" (%d)",
|
_LOGE ("do-add-tfilter: failed sending netlink request \"%s\" (%d)",
|
||||||
nl_geterror (nle), -nle);
|
nm_strerror (nle), -nle);
|
||||||
return NM_PLATFORM_ERROR_NETLINK;
|
return -NME_PL_NETLINK;
|
||||||
}
|
}
|
||||||
|
|
||||||
delayed_action_handle_all (platform, FALSE);
|
delayed_action_handle_all (platform, FALSE);
|
||||||
|
|
@ -7332,9 +7332,9 @@ tfilter_add (NMPlatform *platform,
|
||||||
wait_for_nl_response_to_string (seq_result, errmsg, s_buf, sizeof (s_buf)));
|
wait_for_nl_response_to_string (seq_result, errmsg, s_buf, sizeof (s_buf)));
|
||||||
|
|
||||||
if (seq_result == WAIT_FOR_NL_RESPONSE_RESULT_RESPONSE_OK)
|
if (seq_result == WAIT_FOR_NL_RESPONSE_RESULT_RESPONSE_OK)
|
||||||
return NM_PLATFORM_ERROR_SUCCESS;
|
return 0;
|
||||||
|
|
||||||
return NM_PLATFORM_ERROR_UNSPECIFIED;
|
return -NME_UNSPEC;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
@ -7377,7 +7377,7 @@ continue_reading:
|
||||||
|
|
||||||
if (n <= 0) {
|
if (n <= 0) {
|
||||||
|
|
||||||
if (n == -NLE_MSG_TRUNC) {
|
if (n == -NME_NL_MSG_TRUNC) {
|
||||||
int buf_size;
|
int buf_size;
|
||||||
|
|
||||||
/* the message receive buffer was too small. We lost one message, which
|
/* the message receive buffer was too small. We lost one message, which
|
||||||
|
|
@ -7460,7 +7460,7 @@ continue_reading:
|
||||||
/* Data got lost, report back to user. The default action is to
|
/* Data got lost, report back to user. The default action is to
|
||||||
* quit parsing. The user may overrule this action by retuning
|
* quit parsing. The user may overrule this action by retuning
|
||||||
* NL_SKIP or NL_PROCEED (dangerous) */
|
* NL_SKIP or NL_PROCEED (dangerous) */
|
||||||
err = -NLE_MSG_OVERFLOW;
|
err = -NME_NL_MSG_OVERFLOW;
|
||||||
abort_parsing = TRUE;
|
abort_parsing = TRUE;
|
||||||
} else if (hdr->nlmsg_type == NLMSG_ERROR) {
|
} else if (hdr->nlmsg_type == NLMSG_ERROR) {
|
||||||
/* Message carries a nlmsgerr */
|
/* Message carries a nlmsgerr */
|
||||||
|
|
@ -7471,7 +7471,7 @@ continue_reading:
|
||||||
* is to stop parsing. The user may overrule
|
* is to stop parsing. The user may overrule
|
||||||
* this action by returning NL_SKIP or
|
* this action by returning NL_SKIP or
|
||||||
* NL_PROCEED (dangerous) */
|
* NL_PROCEED (dangerous) */
|
||||||
err = -NLE_MSG_TRUNC;
|
err = -NME_NL_MSG_TRUNC;
|
||||||
abort_parsing = TRUE;
|
abort_parsing = TRUE;
|
||||||
} else if (e->error) {
|
} else if (e->error) {
|
||||||
int errsv = e->error > 0 ? e->error : -e->error;
|
int errsv = e->error > 0 ? e->error : -e->error;
|
||||||
|
|
@ -7548,7 +7548,7 @@ stop:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (interrupted)
|
if (interrupted)
|
||||||
return -NLE_DUMP_INTR;
|
return -NME_NL_DUMP_INTR;
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -7585,16 +7585,16 @@ event_handler_read_netlink (NMPlatform *platform, gboolean wait_for_acks)
|
||||||
switch (nle) {
|
switch (nle) {
|
||||||
case -EAGAIN:
|
case -EAGAIN:
|
||||||
goto after_read;
|
goto after_read;
|
||||||
case -NLE_DUMP_INTR:
|
case -NME_NL_DUMP_INTR:
|
||||||
_LOGD ("netlink: read: uncritical failure to retrieve incoming events: %s (%d)", nl_geterror (nle), nle);
|
_LOGD ("netlink: read: uncritical failure to retrieve incoming events: %s (%d)", nm_strerror (nle), nle);
|
||||||
break;
|
break;
|
||||||
case -NLE_MSG_TRUNC:
|
case -NME_NL_MSG_TRUNC:
|
||||||
case -ENOBUFS:
|
case -ENOBUFS:
|
||||||
_LOGI ("netlink: read: %s. Need to resynchronize platform cache",
|
_LOGI ("netlink: read: %s. Need to resynchronize platform cache",
|
||||||
({
|
({
|
||||||
const char *_reason = "unknown";
|
const char *_reason = "unknown";
|
||||||
switch (nle) {
|
switch (nle) {
|
||||||
case -NLE_MSG_TRUNC: _reason = "message truncated"; break;
|
case -NME_NL_MSG_TRUNC: _reason = "message truncated"; break;
|
||||||
case -ENOBUFS: _reason = "too many netlink events"; break;
|
case -ENOBUFS: _reason = "too many netlink events"; break;
|
||||||
}
|
}
|
||||||
_reason;
|
_reason;
|
||||||
|
|
@ -7614,7 +7614,7 @@ event_handler_read_netlink (NMPlatform *platform, gboolean wait_for_acks)
|
||||||
NULL);
|
NULL);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
_LOGE ("netlink: read: failed to retrieve incoming events: %s (%d)", nl_geterror (nle), nle);
|
_LOGE ("netlink: read: failed to retrieve incoming events: %s (%d)", nm_strerror (nle), nle);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -7842,7 +7842,7 @@ constructed (GObject *_object)
|
||||||
nle = nl_connect (priv->genl, NETLINK_GENERIC);
|
nle = nl_connect (priv->genl, NETLINK_GENERIC);
|
||||||
if (nle) {
|
if (nle) {
|
||||||
_LOGE ("unable to connect the generic netlink socket \"%s\" (%d)",
|
_LOGE ("unable to connect the generic netlink socket \"%s\" (%d)",
|
||||||
nl_geterror (nle), -nle);
|
nm_strerror (nle), -nle);
|
||||||
nl_socket_free (priv->genl);
|
nl_socket_free (priv->genl);
|
||||||
priv->genl = NULL;
|
priv->genl = NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -7868,7 +7868,7 @@ constructed (GObject *_object)
|
||||||
_LOGD ("could not enable extended acks on netlink socket");
|
_LOGD ("could not enable extended acks on netlink socket");
|
||||||
|
|
||||||
/* explicitly set the msg buffer size and disable MSG_PEEK.
|
/* explicitly set the msg buffer size and disable MSG_PEEK.
|
||||||
* If we later encounter NLE_MSG_TRUNC, we will adjust the buffer size. */
|
* If we later encounter NME_NL_MSG_TRUNC, we will adjust the buffer size. */
|
||||||
nl_socket_disable_msg_peek (priv->nlh);
|
nl_socket_disable_msg_peek (priv->nlh);
|
||||||
nle = nl_socket_set_msg_buf_size (priv->nlh, 32 * 1024);
|
nle = nl_socket_set_msg_buf_size (priv->nlh, 32 * 1024);
|
||||||
g_assert (!nle);
|
g_assert (!nle);
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,8 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
#include "nm-utils/nm-errno.h"
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
#ifndef SOL_NETLINK
|
#ifndef SOL_NETLINK
|
||||||
|
|
@ -67,38 +69,6 @@ struct nl_sock {
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
NM_UTILS_LOOKUP_STR_DEFINE_STATIC (_geterror, int,
|
|
||||||
NM_UTILS_LOOKUP_DEFAULT (NULL),
|
|
||||||
NM_UTILS_LOOKUP_ITEM (NLE_UNSPEC, "NLE_UNSPEC"),
|
|
||||||
NM_UTILS_LOOKUP_ITEM (NLE_BUG, "NLE_BUG"),
|
|
||||||
NM_UTILS_LOOKUP_ITEM (NLE_NATIVE_ERRNO, "NLE_NATIVE_ERRNO"),
|
|
||||||
|
|
||||||
NM_UTILS_LOOKUP_ITEM (NLE_ATTRSIZE, "NLE_ATTRSIZE"),
|
|
||||||
NM_UTILS_LOOKUP_ITEM (NLE_BAD_SOCK, "NLE_BAD_SOCK"),
|
|
||||||
NM_UTILS_LOOKUP_ITEM (NLE_DUMP_INTR, "NLE_DUMP_INTR"),
|
|
||||||
NM_UTILS_LOOKUP_ITEM (NLE_MSG_OVERFLOW, "NLE_MSG_OVERFLOW"),
|
|
||||||
NM_UTILS_LOOKUP_ITEM (NLE_MSG_TOOSHORT, "NLE_MSG_TOOSHORT"),
|
|
||||||
NM_UTILS_LOOKUP_ITEM (NLE_MSG_TRUNC, "NLE_MSG_TRUNC"),
|
|
||||||
NM_UTILS_LOOKUP_ITEM (NLE_SEQ_MISMATCH, "NLE_SEQ_MISMATCH"),
|
|
||||||
)
|
|
||||||
|
|
||||||
const char *
|
|
||||||
nl_geterror (int nlerr)
|
|
||||||
{
|
|
||||||
const char *s;
|
|
||||||
|
|
||||||
nlerr = nl_errno (nlerr);
|
|
||||||
|
|
||||||
if (nlerr >= _NLE_BASE) {
|
|
||||||
s = _geterror (nlerr);
|
|
||||||
if (s)
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
return g_strerror (nlerr);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
NM_UTILS_ENUM2STR_DEFINE (nl_nlmsgtype2str, int,
|
NM_UTILS_ENUM2STR_DEFINE (nl_nlmsgtype2str, int,
|
||||||
NM_UTILS_ENUM2STR (NLMSG_NOOP, "NOOP"),
|
NM_UTILS_ENUM2STR (NLMSG_NOOP, "NOOP"),
|
||||||
NM_UTILS_ENUM2STR (NLMSG_ERROR, "ERROR"),
|
NM_UTILS_ENUM2STR (NLMSG_ERROR, "ERROR"),
|
||||||
|
|
@ -385,7 +355,7 @@ nlmsg_parse (struct nlmsghdr *nlh, int hdrlen, struct nlattr *tb[],
|
||||||
int maxtype, const struct nla_policy *policy)
|
int maxtype, const struct nla_policy *policy)
|
||||||
{
|
{
|
||||||
if (!nlmsg_valid_hdr (nlh, hdrlen))
|
if (!nlmsg_valid_hdr (nlh, hdrlen))
|
||||||
return -NLE_MSG_TOOSHORT;
|
return -NME_NL_MSG_TOOSHORT;
|
||||||
|
|
||||||
return nla_parse (tb, maxtype, nlmsg_attrdata (nlh, hdrlen),
|
return nla_parse (tb, maxtype, nlmsg_attrdata (nlh, hdrlen),
|
||||||
nlmsg_attrlen (nlh, hdrlen), policy);
|
nlmsg_attrlen (nlh, hdrlen), policy);
|
||||||
|
|
@ -465,7 +435,7 @@ nla_put (struct nl_msg *msg, int attrtype, int datalen, const void *data)
|
||||||
nla = nla_reserve (msg, attrtype, datalen);
|
nla = nla_reserve (msg, attrtype, datalen);
|
||||||
if (!nla) {
|
if (!nla) {
|
||||||
if (datalen < 0)
|
if (datalen < 0)
|
||||||
g_return_val_if_reached (-NLE_BUG);
|
g_return_val_if_reached (-NME_BUG);
|
||||||
|
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
@ -531,7 +501,7 @@ _nest_end (struct nl_msg *msg, struct nlattr *start, int keep_empty)
|
||||||
nla_nest_cancel (msg, start);
|
nla_nest_cancel (msg, start);
|
||||||
|
|
||||||
/* Return error only if nlattr size was exceeded */
|
/* Return error only if nlattr size was exceeded */
|
||||||
return (len == NLA_HDRLEN) ? 0 : -NLE_ATTRSIZE;
|
return (len == NLA_HDRLEN) ? 0 : -NME_NL_ATTRSIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
start->nla_len = len;
|
start->nla_len = len;
|
||||||
|
|
@ -545,7 +515,7 @@ _nest_end (struct nl_msg *msg, struct nlattr *start, int keep_empty)
|
||||||
* the allocate message buffer must be a multiple of NLMSG_ALIGNTO.
|
* the allocate message buffer must be a multiple of NLMSG_ALIGNTO.
|
||||||
*/
|
*/
|
||||||
if (!nlmsg_reserve (msg, pad, 0))
|
if (!nlmsg_reserve (msg, pad, 0))
|
||||||
g_return_val_if_reached (-NLE_BUG);
|
g_return_val_if_reached (-NME_BUG);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -580,7 +550,7 @@ validate_nla (const struct nlattr *nla, int maxtype,
|
||||||
pt = &policy[type];
|
pt = &policy[type];
|
||||||
|
|
||||||
if (pt->type > NLA_TYPE_MAX)
|
if (pt->type > NLA_TYPE_MAX)
|
||||||
g_return_val_if_reached (-NLE_BUG);
|
g_return_val_if_reached (-NME_BUG);
|
||||||
|
|
||||||
if (pt->minlen)
|
if (pt->minlen)
|
||||||
minlen = pt->minlen;
|
minlen = pt->minlen;
|
||||||
|
|
@ -588,15 +558,15 @@ validate_nla (const struct nlattr *nla, int maxtype,
|
||||||
minlen = nla_attr_minlen[pt->type];
|
minlen = nla_attr_minlen[pt->type];
|
||||||
|
|
||||||
if (nla_len (nla) < minlen)
|
if (nla_len (nla) < minlen)
|
||||||
return -NLE_UNSPEC;
|
return -NME_UNSPEC;
|
||||||
|
|
||||||
if (pt->maxlen && nla_len (nla) > pt->maxlen)
|
if (pt->maxlen && nla_len (nla) > pt->maxlen)
|
||||||
return -NLE_UNSPEC;
|
return -NME_UNSPEC;
|
||||||
|
|
||||||
if (pt->type == NLA_STRING) {
|
if (pt->type == NLA_STRING) {
|
||||||
const char *data = nla_data (nla);
|
const char *data = nla_data (nla);
|
||||||
if (data[nla_len (nla) - 1] != '\0')
|
if (data[nla_len (nla) - 1] != '\0')
|
||||||
return -NLE_UNSPEC;
|
return -NME_UNSPEC;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -607,7 +577,7 @@ nla_parse (struct nlattr *tb[], int maxtype, struct nlattr *head, int len,
|
||||||
const struct nla_policy *policy)
|
const struct nla_policy *policy)
|
||||||
{
|
{
|
||||||
struct nlattr *nla;
|
struct nlattr *nla;
|
||||||
int rem, nlerr;
|
int rem, nmerr;
|
||||||
|
|
||||||
memset (tb, 0, sizeof (struct nlattr *) * (maxtype + 1));
|
memset (tb, 0, sizeof (struct nlattr *) * (maxtype + 1));
|
||||||
|
|
||||||
|
|
@ -618,17 +588,17 @@ nla_parse (struct nlattr *tb[], int maxtype, struct nlattr *head, int len,
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (policy) {
|
if (policy) {
|
||||||
nlerr = validate_nla (nla, maxtype, policy);
|
nmerr = validate_nla (nla, maxtype, policy);
|
||||||
if (nlerr < 0)
|
if (nmerr < 0)
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
tb[type] = nla;
|
tb[type] = nla;
|
||||||
}
|
}
|
||||||
|
|
||||||
nlerr = 0;
|
nmerr = 0;
|
||||||
errout:
|
errout:
|
||||||
return nlerr;
|
return nmerr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
@ -754,7 +724,7 @@ genlmsg_parse (struct nlmsghdr *nlh, int hdrlen, struct nlattr *tb[],
|
||||||
struct genlmsghdr *ghdr;
|
struct genlmsghdr *ghdr;
|
||||||
|
|
||||||
if (!genlmsg_valid_hdr (nlh, hdrlen))
|
if (!genlmsg_valid_hdr (nlh, hdrlen))
|
||||||
return -NLE_MSG_TOOSHORT;
|
return -NME_NL_MSG_TOOSHORT;
|
||||||
|
|
||||||
ghdr = nlmsg_data (nlh);
|
ghdr = nlmsg_data (nlh);
|
||||||
return nla_parse (tb, maxtype, genlmsg_attrdata (ghdr, hdrlen),
|
return nla_parse (tb, maxtype, genlmsg_attrdata (ghdr, hdrlen),
|
||||||
|
|
@ -791,7 +761,7 @@ int
|
||||||
genl_ctrl_resolve (struct nl_sock *sk, const char *name)
|
genl_ctrl_resolve (struct nl_sock *sk, const char *name)
|
||||||
{
|
{
|
||||||
nm_auto_nlmsg struct nl_msg *msg = NULL;
|
nm_auto_nlmsg struct nl_msg *msg = NULL;
|
||||||
int nlerr;
|
int nmerr;
|
||||||
gint32 response_data = -1;
|
gint32 response_data = -1;
|
||||||
const struct nl_cb cb = {
|
const struct nl_cb cb = {
|
||||||
.valid_cb = _genl_parse_getfamily,
|
.valid_cb = _genl_parse_getfamily,
|
||||||
|
|
@ -804,25 +774,25 @@ genl_ctrl_resolve (struct nl_sock *sk, const char *name)
|
||||||
0, 0, CTRL_CMD_GETFAMILY, 1))
|
0, 0, CTRL_CMD_GETFAMILY, 1))
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
nlerr = nla_put_string (msg, CTRL_ATTR_FAMILY_NAME, name);
|
nmerr = nla_put_string (msg, CTRL_ATTR_FAMILY_NAME, name);
|
||||||
if (nlerr < 0)
|
if (nmerr < 0)
|
||||||
return nlerr;
|
return nmerr;
|
||||||
|
|
||||||
nlerr = nl_send_auto (sk, msg);
|
nmerr = nl_send_auto (sk, msg);
|
||||||
if (nlerr < 0)
|
if (nmerr < 0)
|
||||||
return nlerr;
|
return nmerr;
|
||||||
|
|
||||||
nlerr = nl_recvmsgs (sk, &cb);
|
nmerr = nl_recvmsgs (sk, &cb);
|
||||||
if (nlerr < 0)
|
if (nmerr < 0)
|
||||||
return nlerr;
|
return nmerr;
|
||||||
|
|
||||||
/* If search was successful, request may be ACKed after data */
|
/* If search was successful, request may be ACKed after data */
|
||||||
nlerr = nl_wait_for_ack (sk, NULL);
|
nmerr = nl_wait_for_ack (sk, NULL);
|
||||||
if (nlerr < 0)
|
if (nmerr < 0)
|
||||||
return nlerr;
|
return nmerr;
|
||||||
|
|
||||||
if (response_data < 0)
|
if (response_data < 0)
|
||||||
return -NLE_UNSPEC;
|
return -NME_UNSPEC;
|
||||||
|
|
||||||
return response_data;
|
return response_data;
|
||||||
}
|
}
|
||||||
|
|
@ -879,12 +849,12 @@ nl_socket_set_passcred (struct nl_sock *sk, int state)
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (sk->s_fd == -1)
|
if (sk->s_fd == -1)
|
||||||
return -NLE_BAD_SOCK;
|
return -NME_NL_BAD_SOCK;
|
||||||
|
|
||||||
err = setsockopt (sk->s_fd, SOL_SOCKET, SO_PASSCRED,
|
err = setsockopt (sk->s_fd, SOL_SOCKET, SO_PASSCRED,
|
||||||
&state, sizeof (state));
|
&state, sizeof (state));
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return -nl_syserr2nlerr (errno);
|
return -nm_errno_from_native (errno);
|
||||||
|
|
||||||
if (state)
|
if (state)
|
||||||
sk->s_flags |= NL_SOCK_PASSCRED;
|
sk->s_flags |= NL_SOCK_PASSCRED;
|
||||||
|
|
@ -912,10 +882,10 @@ int
|
||||||
nl_socket_set_nonblocking (const struct nl_sock *sk)
|
nl_socket_set_nonblocking (const struct nl_sock *sk)
|
||||||
{
|
{
|
||||||
if (sk->s_fd == -1)
|
if (sk->s_fd == -1)
|
||||||
return -NLE_BAD_SOCK;
|
return -NME_NL_BAD_SOCK;
|
||||||
|
|
||||||
if (fcntl (sk->s_fd, F_SETFL, O_NONBLOCK) < 0)
|
if (fcntl (sk->s_fd, F_SETFL, O_NONBLOCK) < 0)
|
||||||
return -nl_syserr2nlerr (errno);
|
return -nm_errno_from_native (errno);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -932,18 +902,18 @@ nl_socket_set_buffer_size (struct nl_sock *sk, int rxbuf, int txbuf)
|
||||||
txbuf = 32768;
|
txbuf = 32768;
|
||||||
|
|
||||||
if (sk->s_fd == -1)
|
if (sk->s_fd == -1)
|
||||||
return -NLE_BAD_SOCK;
|
return -NME_NL_BAD_SOCK;
|
||||||
|
|
||||||
err = setsockopt (sk->s_fd, SOL_SOCKET, SO_SNDBUF,
|
err = setsockopt (sk->s_fd, SOL_SOCKET, SO_SNDBUF,
|
||||||
&txbuf, sizeof (txbuf));
|
&txbuf, sizeof (txbuf));
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
return -nl_syserr2nlerr (errno);
|
return -nm_errno_from_native (errno);
|
||||||
}
|
}
|
||||||
|
|
||||||
err = setsockopt (sk->s_fd, SOL_SOCKET, SO_RCVBUF,
|
err = setsockopt (sk->s_fd, SOL_SOCKET, SO_RCVBUF,
|
||||||
&rxbuf, sizeof (rxbuf));
|
&rxbuf, sizeof (rxbuf));
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
return -nl_syserr2nlerr (errno);
|
return -nm_errno_from_native (errno);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -956,14 +926,14 @@ nl_socket_add_memberships (struct nl_sock *sk, int group, ...)
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
if (sk->s_fd == -1)
|
if (sk->s_fd == -1)
|
||||||
return -NLE_BAD_SOCK;
|
return -NME_NL_BAD_SOCK;
|
||||||
|
|
||||||
va_start (ap, group);
|
va_start (ap, group);
|
||||||
|
|
||||||
while (group != 0) {
|
while (group != 0) {
|
||||||
if (group < 0) {
|
if (group < 0) {
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
g_return_val_if_reached (-NLE_BUG);
|
g_return_val_if_reached (-NME_BUG);
|
||||||
}
|
}
|
||||||
|
|
||||||
err = setsockopt (sk->s_fd, SOL_NETLINK, NETLINK_ADD_MEMBERSHIP,
|
err = setsockopt (sk->s_fd, SOL_NETLINK, NETLINK_ADD_MEMBERSHIP,
|
||||||
|
|
@ -972,7 +942,7 @@ nl_socket_add_memberships (struct nl_sock *sk, int group, ...)
|
||||||
int errsv = errno;
|
int errsv = errno;
|
||||||
|
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
return -nl_syserr2nlerr (errsv);
|
return -nm_errno_from_native (errsv);
|
||||||
}
|
}
|
||||||
|
|
||||||
group = va_arg (ap, int);
|
group = va_arg (ap, int);
|
||||||
|
|
@ -989,12 +959,12 @@ nl_socket_set_ext_ack (struct nl_sock *sk, gboolean enable)
|
||||||
int err, val;
|
int err, val;
|
||||||
|
|
||||||
if (sk->s_fd == -1)
|
if (sk->s_fd == -1)
|
||||||
return -NLE_BAD_SOCK;
|
return -NME_NL_BAD_SOCK;
|
||||||
|
|
||||||
val = !!enable;
|
val = !!enable;
|
||||||
err = setsockopt (sk->s_fd, SOL_NETLINK, NETLINK_EXT_ACK, &val, sizeof (val));
|
err = setsockopt (sk->s_fd, SOL_NETLINK, NETLINK_EXT_ACK, &val, sizeof (val));
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return -nl_syserr2nlerr (errno);
|
return -nm_errno_from_native (errno);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -1008,21 +978,21 @@ void nl_socket_disable_msg_peek (struct nl_sock *sk)
|
||||||
int
|
int
|
||||||
nl_connect (struct nl_sock *sk, int protocol)
|
nl_connect (struct nl_sock *sk, int protocol)
|
||||||
{
|
{
|
||||||
int err, nlerr;
|
int err, nmerr;
|
||||||
socklen_t addrlen;
|
socklen_t addrlen;
|
||||||
struct sockaddr_nl local = { 0 };
|
struct sockaddr_nl local = { 0 };
|
||||||
|
|
||||||
if (sk->s_fd != -1)
|
if (sk->s_fd != -1)
|
||||||
return -NLE_BAD_SOCK;
|
return -NME_NL_BAD_SOCK;
|
||||||
|
|
||||||
sk->s_fd = socket (AF_NETLINK, SOCK_RAW | SOCK_CLOEXEC, protocol);
|
sk->s_fd = socket (AF_NETLINK, SOCK_RAW | SOCK_CLOEXEC, protocol);
|
||||||
if (sk->s_fd < 0) {
|
if (sk->s_fd < 0) {
|
||||||
nlerr = -nl_syserr2nlerr (errno);
|
nmerr = -nm_errno_from_native (errno);
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
nlerr = nl_socket_set_buffer_size (sk, 0, 0);
|
nmerr = nl_socket_set_buffer_size (sk, 0, 0);
|
||||||
if (nlerr < 0)
|
if (nmerr < 0)
|
||||||
goto errout;
|
goto errout;
|
||||||
|
|
||||||
nm_assert (sk->s_local.nl_pid == 0);
|
nm_assert (sk->s_local.nl_pid == 0);
|
||||||
|
|
@ -1030,7 +1000,7 @@ nl_connect (struct nl_sock *sk, int protocol)
|
||||||
err = bind (sk->s_fd, (struct sockaddr*) &sk->s_local,
|
err = bind (sk->s_fd, (struct sockaddr*) &sk->s_local,
|
||||||
sizeof (sk->s_local));
|
sizeof (sk->s_local));
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
nlerr = -nl_syserr2nlerr (errno);
|
nmerr = -nm_errno_from_native (errno);
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1038,17 +1008,17 @@ nl_connect (struct nl_sock *sk, int protocol)
|
||||||
err = getsockname (sk->s_fd, (struct sockaddr *) &local,
|
err = getsockname (sk->s_fd, (struct sockaddr *) &local,
|
||||||
&addrlen);
|
&addrlen);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
nlerr = -nl_syserr2nlerr (errno);
|
nmerr = -nm_errno_from_native (errno);
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (addrlen != sizeof (local)) {
|
if (addrlen != sizeof (local)) {
|
||||||
nlerr = -NLE_UNSPEC;
|
nmerr = -NME_UNSPEC;
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (local.nl_family != AF_NETLINK) {
|
if (local.nl_family != AF_NETLINK) {
|
||||||
nlerr = -NLE_UNSPEC;
|
nmerr = -NME_UNSPEC;
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1062,7 +1032,7 @@ errout:
|
||||||
close (sk->s_fd);
|
close (sk->s_fd);
|
||||||
sk->s_fd = -1;
|
sk->s_fd = -1;
|
||||||
}
|
}
|
||||||
return nlerr;
|
return nmerr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
@ -1101,19 +1071,19 @@ do { \
|
||||||
if (_cb->type##_cb) { \
|
if (_cb->type##_cb) { \
|
||||||
/* the returned value here must be either a negative
|
/* the returned value here must be either a negative
|
||||||
* netlink error number, or one of NL_SKIP, NL_STOP, NL_OK. */ \
|
* netlink error number, or one of NL_SKIP, NL_STOP, NL_OK. */ \
|
||||||
nlerr = _cb->type##_cb ((msg), _cb->type##_arg); \
|
nmerr = _cb->type##_cb ((msg), _cb->type##_arg); \
|
||||||
switch (nlerr) { \
|
switch (nmerr) { \
|
||||||
case NL_OK: \
|
case NL_OK: \
|
||||||
nlerr = 0; \
|
nmerr = 0; \
|
||||||
break; \
|
break; \
|
||||||
case NL_SKIP: \
|
case NL_SKIP: \
|
||||||
goto skip; \
|
goto skip; \
|
||||||
case NL_STOP: \
|
case NL_STOP: \
|
||||||
goto stop; \
|
goto stop; \
|
||||||
default: \
|
default: \
|
||||||
if (nlerr >= 0) { \
|
if (nmerr >= 0) { \
|
||||||
nm_assert_not_reached (); \
|
nm_assert_not_reached (); \
|
||||||
nlerr = -NLE_BUG; \
|
nmerr = -NME_BUG; \
|
||||||
} \
|
} \
|
||||||
goto out; \
|
goto out; \
|
||||||
} \
|
} \
|
||||||
|
|
@ -1123,7 +1093,7 @@ do { \
|
||||||
int
|
int
|
||||||
nl_recvmsgs (struct nl_sock *sk, const struct nl_cb *cb)
|
nl_recvmsgs (struct nl_sock *sk, const struct nl_cb *cb)
|
||||||
{
|
{
|
||||||
int n, nlerr = 0, multipart = 0, interrupted = 0, nrecv = 0;
|
int n, nmerr = 0, multipart = 0, interrupted = 0, nrecv = 0;
|
||||||
gs_free unsigned char *buf = NULL;
|
gs_free unsigned char *buf = NULL;
|
||||||
struct nlmsghdr *hdr;
|
struct nlmsghdr *hdr;
|
||||||
struct sockaddr_nl nla = { 0 };
|
struct sockaddr_nl nla = { 0 };
|
||||||
|
|
@ -1150,7 +1120,7 @@ continue_reading:
|
||||||
/* Only do sequence checking if auto-ack mode is enabled */
|
/* Only do sequence checking if auto-ack mode is enabled */
|
||||||
if (! (sk->s_flags & NL_NO_AUTO_ACK)) {
|
if (! (sk->s_flags & NL_NO_AUTO_ACK)) {
|
||||||
if (hdr->nlmsg_seq != sk->s_seq_expect) {
|
if (hdr->nlmsg_seq != sk->s_seq_expect) {
|
||||||
nlerr = -NLE_SEQ_MISMATCH;
|
nmerr = -NME_NL_SEQ_MISMATCH;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1196,7 +1166,7 @@ continue_reading:
|
||||||
* quit parsing. The user may overrule this action by retuning
|
* quit parsing. The user may overrule this action by retuning
|
||||||
* NL_SKIP or NL_PROCEED (dangerous) */
|
* NL_SKIP or NL_PROCEED (dangerous) */
|
||||||
else if (hdr->nlmsg_type == NLMSG_OVERRUN) {
|
else if (hdr->nlmsg_type == NLMSG_OVERRUN) {
|
||||||
nlerr = -NLE_MSG_OVERFLOW;
|
nmerr = -NME_NL_MSG_OVERFLOW;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1209,7 +1179,7 @@ continue_reading:
|
||||||
* is to stop parsing. The user may overrule
|
* is to stop parsing. The user may overrule
|
||||||
* this action by returning NL_SKIP or
|
* this action by returning NL_SKIP or
|
||||||
* NL_PROCEED (dangerous) */
|
* NL_PROCEED (dangerous) */
|
||||||
nlerr = -NLE_MSG_TRUNC;
|
nmerr = -NME_NL_MSG_TRUNC;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
if (e->error) {
|
if (e->error) {
|
||||||
|
|
@ -1217,19 +1187,19 @@ continue_reading:
|
||||||
if (cb->err_cb) {
|
if (cb->err_cb) {
|
||||||
/* the returned value here must be either a negative
|
/* the returned value here must be either a negative
|
||||||
* netlink error number, or one of NL_SKIP, NL_STOP, NL_OK. */
|
* netlink error number, or one of NL_SKIP, NL_STOP, NL_OK. */
|
||||||
nlerr = cb->err_cb (&nla, e,
|
nmerr = cb->err_cb (&nla, e,
|
||||||
cb->err_arg);
|
cb->err_arg);
|
||||||
if (nlerr < 0)
|
if (nmerr < 0)
|
||||||
goto out;
|
goto out;
|
||||||
else if (nlerr == NL_SKIP)
|
else if (nmerr == NL_SKIP)
|
||||||
goto skip;
|
goto skip;
|
||||||
else if (nlerr == NL_STOP) {
|
else if (nmerr == NL_STOP) {
|
||||||
nlerr = -nl_syserr2nlerr (e->error);
|
nmerr = -nm_errno_from_native (e->error);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
nm_assert (nlerr == NL_OK);
|
nm_assert (nmerr == NL_OK);
|
||||||
} else {
|
} else {
|
||||||
nlerr = -nl_syserr2nlerr (e->error);
|
nmerr = -nm_errno_from_native (e->error);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
|
|
@ -1241,7 +1211,7 @@ continue_reading:
|
||||||
NL_CB_CALL (cb, valid, msg);
|
NL_CB_CALL (cb, valid, msg);
|
||||||
}
|
}
|
||||||
skip:
|
skip:
|
||||||
nlerr = 0;
|
nmerr = 0;
|
||||||
hdr = nlmsg_next (hdr, &n);
|
hdr = nlmsg_next (hdr, &n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1254,14 +1224,14 @@ skip:
|
||||||
}
|
}
|
||||||
|
|
||||||
stop:
|
stop:
|
||||||
nlerr = 0;
|
nmerr = 0;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (interrupted)
|
if (interrupted)
|
||||||
nlerr = -NLE_DUMP_INTR;
|
nmerr = -NME_NL_DUMP_INTR;
|
||||||
|
|
||||||
nm_assert (nlerr <= 0);
|
nm_assert (nmerr <= 0);
|
||||||
return nlerr ?: nrecv;
|
return nmerr ?: nrecv;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
@ -1270,13 +1240,13 @@ nl_sendmsg (struct nl_sock *sk, struct nl_msg *msg, struct msghdr *hdr)
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (sk->s_fd < 0)
|
if (sk->s_fd < 0)
|
||||||
return -NLE_BAD_SOCK;
|
return -NME_NL_BAD_SOCK;
|
||||||
|
|
||||||
nlmsg_set_src (msg, &sk->s_local);
|
nlmsg_set_src (msg, &sk->s_local);
|
||||||
|
|
||||||
ret = sendmsg (sk->s_fd, hdr, 0);
|
ret = sendmsg (sk->s_fd, hdr, 0);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return -nl_syserr2nlerr (errno);
|
return -nm_errno_from_native (errno);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
@ -1407,13 +1377,13 @@ retry:
|
||||||
if (errno == EINTR)
|
if (errno == EINTR)
|
||||||
goto retry;
|
goto retry;
|
||||||
|
|
||||||
retval = -nl_syserr2nlerr (errno);
|
retval = -nm_errno_from_native (errno);
|
||||||
goto abort;
|
goto abort;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg.msg_flags & MSG_CTRUNC) {
|
if (msg.msg_flags & MSG_CTRUNC) {
|
||||||
if (msg.msg_controllen == 0) {
|
if (msg.msg_controllen == 0) {
|
||||||
retval = -NLE_MSG_TRUNC;
|
retval = -NME_NL_MSG_TRUNC;
|
||||||
goto abort;
|
goto abort;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1426,7 +1396,7 @@ retry:
|
||||||
|| (msg.msg_flags & MSG_TRUNC)) {
|
|| (msg.msg_flags & MSG_TRUNC)) {
|
||||||
/* respond with error to an incomplete message */
|
/* respond with error to an incomplete message */
|
||||||
if (flags == 0) {
|
if (flags == 0) {
|
||||||
retval = -NLE_MSG_TRUNC;
|
retval = -NME_NL_MSG_TRUNC;
|
||||||
goto abort;
|
goto abort;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1446,7 +1416,7 @@ retry:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg.msg_namelen != sizeof (struct sockaddr_nl)) {
|
if (msg.msg_namelen != sizeof (struct sockaddr_nl)) {
|
||||||
retval = -NLE_UNSPEC;
|
retval = -NME_UNSPEC;
|
||||||
goto abort;
|
goto abort;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,20 +26,6 @@
|
||||||
#include <linux/genetlink.h>
|
#include <linux/genetlink.h>
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
#define _NLE_BASE 100000
|
|
||||||
#define NLE_UNSPEC (_NLE_BASE + 0)
|
|
||||||
#define NLE_BUG (_NLE_BASE + 1)
|
|
||||||
#define NLE_NATIVE_ERRNO (_NLE_BASE + 2)
|
|
||||||
#define NLE_SEQ_MISMATCH (_NLE_BASE + 3)
|
|
||||||
#define NLE_MSG_TRUNC (_NLE_BASE + 4)
|
|
||||||
#define NLE_MSG_TOOSHORT (_NLE_BASE + 5)
|
|
||||||
#define NLE_DUMP_INTR (_NLE_BASE + 6)
|
|
||||||
#define NLE_ATTRSIZE (_NLE_BASE + 7)
|
|
||||||
#define NLE_BAD_SOCK (_NLE_BASE + 8)
|
|
||||||
#define NLE_NOADDR (_NLE_BASE + 9)
|
|
||||||
#define NLE_MSG_OVERFLOW (_NLE_BASE + 10)
|
|
||||||
|
|
||||||
#define _NLE_BASE_END (_NLE_BASE + 11)
|
|
||||||
|
|
||||||
#define NLMSGERR_ATTR_UNUSED 0
|
#define NLMSGERR_ATTR_UNUSED 0
|
||||||
#define NLMSGERR_ATTR_MSG 1
|
#define NLMSGERR_ATTR_MSG 1
|
||||||
|
|
@ -51,50 +37,6 @@
|
||||||
#define NLM_F_ACK_TLVS 0x200
|
#define NLM_F_ACK_TLVS 0x200
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static inline int
|
|
||||||
nl_errno (int nlerr)
|
|
||||||
{
|
|
||||||
/* Normalizes an netlink error to be positive. Various API returns negative
|
|
||||||
* error codes, and this function converts the negative value to its
|
|
||||||
* positive.
|
|
||||||
*
|
|
||||||
* It's very similar to nm_errno(), but not exactly. The difference is that
|
|
||||||
* nm_errno() is for plain errno, while nl_errno() is for netlink error numbers.
|
|
||||||
* Yes, netlink error number are ~almost~ the same as errno, except that a particular
|
|
||||||
* range (_NLE_BASE, _NLE_BASE_END) is reserved. The difference between the two
|
|
||||||
* functions is only how G_MININT is mapped.
|
|
||||||
*
|
|
||||||
* See also nl_syserr2nlerr() below. */
|
|
||||||
return nlerr >= 0
|
|
||||||
? nlerr
|
|
||||||
: ((nlerr == G_MININT) ? NLE_BUG : -nlerr);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int
|
|
||||||
nl_syserr2nlerr (int errsv)
|
|
||||||
{
|
|
||||||
/* this maps a native errno to a (always non-negative) netlink error number.
|
|
||||||
*
|
|
||||||
* Note that netlink error numbers are embedded into the range of regular
|
|
||||||
* errno. The only difference is, that netlink error numbers reserve a
|
|
||||||
* range (_NLE_BASE, _NLE_BASE_END) for their own purpose.
|
|
||||||
*
|
|
||||||
* That means, converting an errno to netlink error number means in
|
|
||||||
* most cases just returning itself (negative values are normalized
|
|
||||||
* to be positive). Only values G_MININT and [_NLE_BASE, _NLE_BASE_END]
|
|
||||||
* are coerced to the special value NLE_NATIVE_ERRNO, as they cannot
|
|
||||||
* otherwise be represented in netlink error number domain. */
|
|
||||||
if (errsv == G_MININT)
|
|
||||||
return NLE_NATIVE_ERRNO;
|
|
||||||
if (errsv < 0)
|
|
||||||
errsv = -errsv;
|
|
||||||
return (errsv >= _NLE_BASE && errsv < _NLE_BASE_END)
|
|
||||||
? NLE_NATIVE_ERRNO
|
|
||||||
: errsv;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *nl_geterror (int nlerr);
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
/* Basic attribute data types */
|
/* Basic attribute data types */
|
||||||
|
|
|
||||||
|
|
@ -1277,7 +1277,6 @@ nmp_utils_sysctl_open_netdir (int ifindex,
|
||||||
for (try_count = 0; try_count < 10; try_count++, ifname = NULL) {
|
for (try_count = 0; try_count < 10; try_count++, ifname = NULL) {
|
||||||
nm_auto_close int fd_dir = -1;
|
nm_auto_close int fd_dir = -1;
|
||||||
nm_auto_close int fd_ifindex = -1;
|
nm_auto_close int fd_ifindex = -1;
|
||||||
int fd;
|
|
||||||
|
|
||||||
if (!ifname) {
|
if (!ifname) {
|
||||||
ifname = nmp_utils_if_indextoname (ifindex, ifname_buf);
|
ifname = nmp_utils_if_indextoname (ifindex, ifname_buf);
|
||||||
|
|
@ -1310,15 +1309,13 @@ nmp_utils_sysctl_open_netdir (int ifindex,
|
||||||
continue;
|
continue;
|
||||||
fd_buf[nn] = '\0';
|
fd_buf[nn] = '\0';
|
||||||
|
|
||||||
if (ifindex != _nm_utils_ascii_str_to_int64 (fd_buf, 10, 1, G_MAXINT, -1))
|
if (ifindex != (int) _nm_utils_ascii_str_to_int64 (fd_buf, 10, 1, G_MAXINT, -1))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (out_ifname)
|
if (out_ifname)
|
||||||
strcpy (out_ifname, ifname);
|
strcpy (out_ifname, ifname);
|
||||||
|
|
||||||
fd = fd_dir;
|
return nm_steal_fd (&fd_dir);
|
||||||
fd_dir = -1;
|
|
||||||
return fd;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -29,6 +29,7 @@
|
||||||
#include "nm-setting-wired.h"
|
#include "nm-setting-wired.h"
|
||||||
#include "nm-setting-wireless.h"
|
#include "nm-setting-wireless.h"
|
||||||
#include "nm-setting-ip-tunnel.h"
|
#include "nm-setting-ip-tunnel.h"
|
||||||
|
#include "nm-utils/nm-errno.h"
|
||||||
|
|
||||||
#define NM_TYPE_PLATFORM (nm_platform_get_type ())
|
#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(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_PLATFORM, NMPlatform))
|
||||||
|
|
@ -149,29 +150,6 @@ typedef enum {
|
||||||
|
|
||||||
} NMPlatformIPRouteCmpType;
|
} NMPlatformIPRouteCmpType;
|
||||||
|
|
||||||
typedef enum { /*< skip >*/
|
|
||||||
|
|
||||||
/* 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,
|
|
||||||
|
|
||||||
NM_PLATFORM_ERROR_NOT_FOUND,
|
|
||||||
NM_PLATFORM_ERROR_EXISTS,
|
|
||||||
NM_PLATFORM_ERROR_WRONG_TYPE,
|
|
||||||
NM_PLATFORM_ERROR_NOT_SLAVE,
|
|
||||||
NM_PLATFORM_ERROR_NO_FIRMWARE,
|
|
||||||
NM_PLATFORM_ERROR_OPNOTSUPP,
|
|
||||||
NM_PLATFORM_ERROR_NETLINK,
|
|
||||||
NM_PLATFORM_ERROR_CANT_SET_MTU,
|
|
||||||
} NMPlatformError;
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
|
||||||
/* match-flags are strictly inclusive. That means,
|
/* match-flags are strictly inclusive. That means,
|
||||||
|
|
@ -792,13 +770,14 @@ typedef struct {
|
||||||
|
|
||||||
void (*refresh_all) (NMPlatform *self, NMPObjectType obj_type);
|
void (*refresh_all) (NMPlatform *self, NMPObjectType obj_type);
|
||||||
|
|
||||||
gboolean (*link_add) (NMPlatform *,
|
int (*link_add) (NMPlatform *,
|
||||||
const char *name,
|
const char *name,
|
||||||
NMLinkType type,
|
NMLinkType type,
|
||||||
const char *veth_peer,
|
const char *veth_peer,
|
||||||
const void *address,
|
const void *address,
|
||||||
size_t address_len,
|
size_t address_len,
|
||||||
const NMPlatformLink **out_link);
|
const NMPlatformLink **out_link);
|
||||||
|
|
||||||
gboolean (*link_delete) (NMPlatform *, int ifindex);
|
gboolean (*link_delete) (NMPlatform *, int ifindex);
|
||||||
|
|
||||||
gboolean (*link_refresh) (NMPlatform *, int ifindex);
|
gboolean (*link_refresh) (NMPlatform *, int ifindex);
|
||||||
|
|
@ -815,15 +794,15 @@ typedef struct {
|
||||||
const char *(*link_get_udi) (NMPlatform *self, int ifindex);
|
const char *(*link_get_udi) (NMPlatform *self, int ifindex);
|
||||||
struct udev_device *(*link_get_udev_device) (NMPlatform *self, int ifindex);
|
struct udev_device *(*link_get_udev_device) (NMPlatform *self, int ifindex);
|
||||||
|
|
||||||
NMPlatformError (*link_set_user_ipv6ll_enabled) (NMPlatform *, int ifindex, gboolean enabled);
|
int (*link_set_user_ipv6ll_enabled) (NMPlatform *, int ifindex, gboolean enabled);
|
||||||
gboolean (*link_set_token) (NMPlatform *, int ifindex, NMUtilsIPv6IfaceId iid);
|
gboolean (*link_set_token) (NMPlatform *, int ifindex, NMUtilsIPv6IfaceId iid);
|
||||||
|
|
||||||
gboolean (*link_get_permanent_address) (NMPlatform *,
|
gboolean (*link_get_permanent_address) (NMPlatform *,
|
||||||
int ifindex,
|
int ifindex,
|
||||||
guint8 *buf,
|
guint8 *buf,
|
||||||
size_t *length);
|
size_t *length);
|
||||||
NMPlatformError (*link_set_address) (NMPlatform *, int ifindex, gconstpointer address, size_t length);
|
int (*link_set_address) (NMPlatform *, int ifindex, gconstpointer address, size_t length);
|
||||||
NMPlatformError (*link_set_mtu) (NMPlatform *, int ifindex, guint32 mtu);
|
int (*link_set_mtu) (NMPlatform *, int ifindex, guint32 mtu);
|
||||||
gboolean (*link_set_name) (NMPlatform *, int ifindex, const char *name);
|
gboolean (*link_set_name) (NMPlatform *, int ifindex, const char *name);
|
||||||
gboolean (*link_set_sriov_params) (NMPlatform *, int ifindex, guint num_vfs, int autoprobe);
|
gboolean (*link_set_sriov_params) (NMPlatform *, int ifindex, guint num_vfs, int autoprobe);
|
||||||
gboolean (*link_set_sriov_vfs) (NMPlatform *self, int ifindex, const NMPlatformVF *const *vfs);
|
gboolean (*link_set_sriov_vfs) (NMPlatform *self, int ifindex, const NMPlatformVF *const *vfs);
|
||||||
|
|
@ -951,23 +930,23 @@ typedef struct {
|
||||||
gboolean (*ip4_address_delete) (NMPlatform *, int ifindex, in_addr_t address, guint8 plen, in_addr_t peer_address);
|
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);
|
gboolean (*ip6_address_delete) (NMPlatform *, int ifindex, struct in6_addr address, guint8 plen);
|
||||||
|
|
||||||
NMPlatformError (*ip_route_add) (NMPlatform *,
|
int (*ip_route_add) (NMPlatform *,
|
||||||
NMPNlmFlags flags,
|
NMPNlmFlags flags,
|
||||||
int addr_family,
|
int addr_family,
|
||||||
const NMPlatformIPRoute *route);
|
const NMPlatformIPRoute *route);
|
||||||
NMPlatformError (*ip_route_get) (NMPlatform *self,
|
int (*ip_route_get) (NMPlatform *self,
|
||||||
int addr_family,
|
int addr_family,
|
||||||
gconstpointer address,
|
gconstpointer address,
|
||||||
int oif_ifindex,
|
int oif_ifindex,
|
||||||
NMPObject **out_route);
|
NMPObject **out_route);
|
||||||
|
|
||||||
NMPlatformError (*qdisc_add) (NMPlatform *self,
|
int (*qdisc_add) (NMPlatform *self,
|
||||||
NMPNlmFlags flags,
|
NMPNlmFlags flags,
|
||||||
const NMPlatformQdisc *qdisc);
|
const NMPlatformQdisc *qdisc);
|
||||||
|
|
||||||
NMPlatformError (*tfilter_add) (NMPlatform *self,
|
int (*tfilter_add) (NMPlatform *self,
|
||||||
NMPNlmFlags flags,
|
NMPNlmFlags flags,
|
||||||
const NMPlatformTfilter *tfilter);
|
const NMPlatformTfilter *tfilter);
|
||||||
|
|
||||||
NMPlatformKernelSupportFlags (*check_kernel_support) (NMPlatform * self,
|
NMPlatformKernelSupportFlags (*check_kernel_support) (NMPlatform * self,
|
||||||
NMPlatformKernelSupportFlags request_flags);
|
NMPlatformKernelSupportFlags request_flags);
|
||||||
|
|
@ -1096,12 +1075,6 @@ gboolean nm_platform_netns_push (NMPlatform *platform, NMPNetns **netns);
|
||||||
|
|
||||||
const char *nm_link_type_to_string (NMLinkType link_type);
|
const char *nm_link_type_to_string (NMLinkType link_type);
|
||||||
|
|
||||||
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))
|
|
||||||
|
|
||||||
#define NMP_SYSCTL_PATHID_ABSOLUTE(path) \
|
#define NMP_SYSCTL_PATHID_ABSOLUTE(path) \
|
||||||
((const char *) NULL), -1, (path)
|
((const char *) NULL), -1, (path)
|
||||||
|
|
||||||
|
|
@ -1171,11 +1144,11 @@ const NMPlatformLink *nm_platform_link_get_by_ifname (NMPlatform *self, const ch
|
||||||
const NMPlatformLink *nm_platform_link_get_by_address (NMPlatform *self, NMLinkType link_type, gconstpointer address, size_t length);
|
const NMPlatformLink *nm_platform_link_get_by_address (NMPlatform *self, NMLinkType link_type, gconstpointer address, size_t length);
|
||||||
|
|
||||||
GPtrArray *nm_platform_link_get_all (NMPlatform *self, gboolean sort_by_name);
|
GPtrArray *nm_platform_link_get_all (NMPlatform *self, gboolean sort_by_name);
|
||||||
NMPlatformError nm_platform_link_dummy_add (NMPlatform *self, const char *name, const NMPlatformLink **out_link);
|
int 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);
|
int 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);
|
int 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);
|
int nm_platform_link_team_add (NMPlatform *self, const char *name, const NMPlatformLink **out_link);
|
||||||
NMPlatformError nm_platform_link_veth_add (NMPlatform *self, const char *name, const char *peer, const NMPlatformLink **out_link);
|
int nm_platform_link_veth_add (NMPlatform *self, const char *name, const char *peer, const NMPlatformLink **out_link);
|
||||||
|
|
||||||
gboolean nm_platform_link_delete (NMPlatform *self, int ifindex);
|
gboolean nm_platform_link_delete (NMPlatform *self, int ifindex);
|
||||||
|
|
||||||
|
|
@ -1246,12 +1219,12 @@ const char *nm_platform_link_get_udi (NMPlatform *self, int ifindex);
|
||||||
|
|
||||||
struct udev_device *nm_platform_link_get_udev_device (NMPlatform *self, int ifindex);
|
struct udev_device *nm_platform_link_get_udev_device (NMPlatform *self, int ifindex);
|
||||||
|
|
||||||
NMPlatformError nm_platform_link_set_user_ipv6ll_enabled (NMPlatform *self, int ifindex, gboolean enabled);
|
int nm_platform_link_set_user_ipv6ll_enabled (NMPlatform *self, int ifindex, gboolean enabled);
|
||||||
gboolean nm_platform_link_set_ipv6_token (NMPlatform *self, int ifindex, NMUtilsIPv6IfaceId iid);
|
gboolean nm_platform_link_set_ipv6_token (NMPlatform *self, int ifindex, NMUtilsIPv6IfaceId iid);
|
||||||
|
|
||||||
gboolean nm_platform_link_get_permanent_address (NMPlatform *self, int ifindex, guint8 *buf, size_t *length);
|
gboolean nm_platform_link_get_permanent_address (NMPlatform *self, int ifindex, guint8 *buf, size_t *length);
|
||||||
NMPlatformError nm_platform_link_set_address (NMPlatform *self, int ifindex, const void *address, size_t length);
|
int nm_platform_link_set_address (NMPlatform *self, int ifindex, const void *address, size_t length);
|
||||||
NMPlatformError nm_platform_link_set_mtu (NMPlatform *self, int ifindex, guint32 mtu);
|
int nm_platform_link_set_mtu (NMPlatform *self, int ifindex, guint32 mtu);
|
||||||
gboolean nm_platform_link_set_name (NMPlatform *self, int ifindex, const char *name);
|
gboolean nm_platform_link_set_name (NMPlatform *self, int ifindex, const char *name);
|
||||||
gboolean nm_platform_link_set_sriov_params (NMPlatform *self, int ifindex, guint num_vfs, int autoprobe);
|
gboolean nm_platform_link_set_sriov_params (NMPlatform *self, int ifindex, guint num_vfs, int autoprobe);
|
||||||
gboolean nm_platform_link_set_sriov_vfs (NMPlatform *self, int ifindex, const NMPlatformVF *const *vfs);
|
gboolean nm_platform_link_set_sriov_vfs (NMPlatform *self, int ifindex, const NMPlatformVF *const *vfs);
|
||||||
|
|
@ -1295,12 +1268,12 @@ const NMPlatformLnkVlan *nm_platform_link_get_lnk_vlan (NMPlatform *self, int if
|
||||||
const NMPlatformLnkVxlan *nm_platform_link_get_lnk_vxlan (NMPlatform *self, int ifindex, const NMPlatformLink **out_link);
|
const NMPlatformLnkVxlan *nm_platform_link_get_lnk_vxlan (NMPlatform *self, int ifindex, const NMPlatformLink **out_link);
|
||||||
const NMPlatformLnkWireGuard *nm_platform_link_get_lnk_wireguard (NMPlatform *self, int ifindex, const NMPlatformLink **out_link);
|
const NMPlatformLnkWireGuard *nm_platform_link_get_lnk_wireguard (NMPlatform *self, int ifindex, const NMPlatformLink **out_link);
|
||||||
|
|
||||||
NMPlatformError nm_platform_link_vlan_add (NMPlatform *self,
|
int nm_platform_link_vlan_add (NMPlatform *self,
|
||||||
const char *name,
|
const char *name,
|
||||||
int parent,
|
int parent,
|
||||||
int vlanid,
|
int vlanid,
|
||||||
guint32 vlanflags,
|
guint32 vlanflags,
|
||||||
const NMPlatformLink **out_link);
|
const NMPlatformLink **out_link);
|
||||||
gboolean nm_platform_link_vlan_set_ingress_map (NMPlatform *self, int ifindex, int from, int to);
|
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);
|
gboolean nm_platform_link_vlan_set_egress_map (NMPlatform *self, int ifindex, int from, int to);
|
||||||
gboolean nm_platform_link_vlan_change (NMPlatform *self,
|
gboolean nm_platform_link_vlan_change (NMPlatform *self,
|
||||||
|
|
@ -1314,18 +1287,18 @@ gboolean nm_platform_link_vlan_change (NMPlatform *self,
|
||||||
const NMVlanQosMapping *egress_map,
|
const NMVlanQosMapping *egress_map,
|
||||||
gsize n_egress_map);
|
gsize n_egress_map);
|
||||||
|
|
||||||
NMPlatformError nm_platform_link_vxlan_add (NMPlatform *self,
|
int nm_platform_link_vxlan_add (NMPlatform *self,
|
||||||
const char *name,
|
const char *name,
|
||||||
const NMPlatformLnkVxlan *props,
|
const NMPlatformLnkVxlan *props,
|
||||||
const NMPlatformLink **out_link);
|
const NMPlatformLink **out_link);
|
||||||
|
|
||||||
NMPlatformError nm_platform_link_infiniband_add (NMPlatform *self,
|
int nm_platform_link_infiniband_add (NMPlatform *self,
|
||||||
int parent,
|
int parent,
|
||||||
int p_key,
|
int p_key,
|
||||||
const NMPlatformLink **out_link);
|
const NMPlatformLink **out_link);
|
||||||
NMPlatformError nm_platform_link_infiniband_delete (NMPlatform *self,
|
int nm_platform_link_infiniband_delete (NMPlatform *self,
|
||||||
int parent,
|
int parent,
|
||||||
int p_key);
|
int p_key);
|
||||||
gboolean nm_platform_link_infiniband_get_properties (NMPlatform *self, int ifindex, int *parent, int *p_key, const char **mode);
|
gboolean nm_platform_link_infiniband_get_properties (NMPlatform *self, int ifindex, int *parent, int *p_key, const char **mode);
|
||||||
|
|
||||||
gboolean nm_platform_link_veth_get_properties (NMPlatform *self, int ifindex, int *out_peer_ifindex);
|
gboolean nm_platform_link_veth_get_properties (NMPlatform *self, int ifindex, int *out_peer_ifindex);
|
||||||
|
|
@ -1361,45 +1334,45 @@ const struct in6_addr *nm_platform_ip6_address_get_peer (const NMPlatformIP6Addr
|
||||||
|
|
||||||
const NMPlatformIP4Address *nm_platform_ip4_address_get (NMPlatform *self, int ifindex, in_addr_t address, guint8 plen, in_addr_t peer_address);
|
const NMPlatformIP4Address *nm_platform_ip4_address_get (NMPlatform *self, int ifindex, in_addr_t address, guint8 plen, in_addr_t peer_address);
|
||||||
|
|
||||||
NMPlatformError nm_platform_link_gre_add (NMPlatform *self,
|
int nm_platform_link_gre_add (NMPlatform *self,
|
||||||
const char *name,
|
const char *name,
|
||||||
const NMPlatformLnkGre *props,
|
const NMPlatformLnkGre *props,
|
||||||
const NMPlatformLink **out_link);
|
const NMPlatformLink **out_link);
|
||||||
NMPlatformError nm_platform_link_ip6tnl_add (NMPlatform *self,
|
int nm_platform_link_ip6tnl_add (NMPlatform *self,
|
||||||
const char *name,
|
const char *name,
|
||||||
const NMPlatformLnkIp6Tnl *props,
|
const NMPlatformLnkIp6Tnl *props,
|
||||||
const NMPlatformLink **out_link);
|
const NMPlatformLink **out_link);
|
||||||
NMPlatformError nm_platform_link_ip6gre_add (NMPlatform *self,
|
int nm_platform_link_ip6gre_add (NMPlatform *self,
|
||||||
const char *name,
|
const char *name,
|
||||||
const NMPlatformLnkIp6Tnl *props,
|
const NMPlatformLnkIp6Tnl *props,
|
||||||
const NMPlatformLink **out_link);
|
const NMPlatformLink **out_link);
|
||||||
NMPlatformError nm_platform_link_ipip_add (NMPlatform *self,
|
int nm_platform_link_ipip_add (NMPlatform *self,
|
||||||
const char *name,
|
const char *name,
|
||||||
const NMPlatformLnkIpIp *props,
|
const NMPlatformLnkIpIp *props,
|
||||||
const NMPlatformLink **out_link);
|
const NMPlatformLink **out_link);
|
||||||
NMPlatformError nm_platform_link_macsec_add (NMPlatform *self,
|
int nm_platform_link_macsec_add (NMPlatform *self,
|
||||||
const char *name,
|
const char *name,
|
||||||
int parent,
|
int parent,
|
||||||
const NMPlatformLnkMacsec *props,
|
const NMPlatformLnkMacsec *props,
|
||||||
const NMPlatformLink **out_link);
|
const NMPlatformLink **out_link);
|
||||||
NMPlatformError nm_platform_link_macvlan_add (NMPlatform *self,
|
int nm_platform_link_macvlan_add (NMPlatform *self,
|
||||||
const char *name,
|
const char *name,
|
||||||
int parent,
|
int parent,
|
||||||
const NMPlatformLnkMacvlan *props,
|
const NMPlatformLnkMacvlan *props,
|
||||||
const NMPlatformLink **out_link);
|
const NMPlatformLink **out_link);
|
||||||
NMPlatformError nm_platform_link_sit_add (NMPlatform *self,
|
int nm_platform_link_sit_add (NMPlatform *self,
|
||||||
const char *name,
|
const char *name,
|
||||||
const NMPlatformLnkSit *props,
|
const NMPlatformLnkSit *props,
|
||||||
const NMPlatformLink **out_link);
|
const NMPlatformLink **out_link);
|
||||||
NMPlatformError nm_platform_link_tun_add (NMPlatform *self,
|
int nm_platform_link_tun_add (NMPlatform *self,
|
||||||
const char *name,
|
const char *name,
|
||||||
const NMPlatformLnkTun *props,
|
const NMPlatformLnkTun *props,
|
||||||
const NMPlatformLink **out_link,
|
const NMPlatformLink **out_link,
|
||||||
int *out_fd);
|
int *out_fd);
|
||||||
NMPlatformError nm_platform_link_6lowpan_add (NMPlatform *self,
|
int nm_platform_link_6lowpan_add (NMPlatform *self,
|
||||||
const char *name,
|
const char *name,
|
||||||
int parent,
|
int parent,
|
||||||
const NMPlatformLink **out_link);
|
const NMPlatformLink **out_link);
|
||||||
gboolean nm_platform_link_6lowpan_get_properties (NMPlatform *self,
|
gboolean nm_platform_link_6lowpan_get_properties (NMPlatform *self,
|
||||||
int ifindex,
|
int ifindex,
|
||||||
int *out_parent);
|
int *out_parent);
|
||||||
|
|
@ -1436,11 +1409,11 @@ gboolean nm_platform_ip_address_flush (NMPlatform *self,
|
||||||
void nm_platform_ip_route_normalize (int addr_family,
|
void nm_platform_ip_route_normalize (int addr_family,
|
||||||
NMPlatformIPRoute *route);
|
NMPlatformIPRoute *route);
|
||||||
|
|
||||||
NMPlatformError nm_platform_ip_route_add (NMPlatform *self,
|
int nm_platform_ip_route_add (NMPlatform *self,
|
||||||
NMPNlmFlags flags,
|
NMPNlmFlags flags,
|
||||||
const NMPObject *route);
|
const NMPObject *route);
|
||||||
NMPlatformError nm_platform_ip4_route_add (NMPlatform *self, NMPNlmFlags flags, const NMPlatformIP4Route *route);
|
int 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);
|
int nm_platform_ip6_route_add (NMPlatform *self, NMPNlmFlags flags, const NMPlatformIP6Route *route);
|
||||||
|
|
||||||
GPtrArray *nm_platform_ip_route_get_prune_list (NMPlatform *self,
|
GPtrArray *nm_platform_ip_route_get_prune_list (NMPlatform *self,
|
||||||
int addr_family,
|
int addr_family,
|
||||||
|
|
@ -1458,22 +1431,22 @@ gboolean nm_platform_ip_route_flush (NMPlatform *self,
|
||||||
int addr_family,
|
int addr_family,
|
||||||
int ifindex);
|
int ifindex);
|
||||||
|
|
||||||
NMPlatformError nm_platform_ip_route_get (NMPlatform *self,
|
int nm_platform_ip_route_get (NMPlatform *self,
|
||||||
int addr_family,
|
int addr_family,
|
||||||
gconstpointer address,
|
gconstpointer address,
|
||||||
int oif_ifindex,
|
int oif_ifindex,
|
||||||
NMPObject **out_route);
|
NMPObject **out_route);
|
||||||
|
|
||||||
NMPlatformError nm_platform_qdisc_add (NMPlatform *self,
|
int nm_platform_qdisc_add (NMPlatform *self,
|
||||||
NMPNlmFlags flags,
|
NMPNlmFlags flags,
|
||||||
const NMPlatformQdisc *qdisc);
|
const NMPlatformQdisc *qdisc);
|
||||||
gboolean nm_platform_qdisc_sync (NMPlatform *self,
|
gboolean nm_platform_qdisc_sync (NMPlatform *self,
|
||||||
int ifindex,
|
int ifindex,
|
||||||
GPtrArray *known_qdiscs);
|
GPtrArray *known_qdiscs);
|
||||||
|
|
||||||
NMPlatformError nm_platform_tfilter_add (NMPlatform *self,
|
int nm_platform_tfilter_add (NMPlatform *self,
|
||||||
NMPNlmFlags flags,
|
NMPNlmFlags flags,
|
||||||
const NMPlatformTfilter *tfilter);
|
const NMPlatformTfilter *tfilter);
|
||||||
gboolean nm_platform_tfilter_sync (NMPlatform *self,
|
gboolean nm_platform_tfilter_sync (NMPlatform *self,
|
||||||
int ifindex,
|
int ifindex,
|
||||||
GPtrArray *known_tfilters);
|
GPtrArray *known_tfilters);
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ test_cleanup_internal (void)
|
||||||
inet_pton (AF_INET6, "2001:db8:e:f:1:2:3:4", &gateway6);
|
inet_pton (AF_INET6, "2001:db8:e:f:1:2:3:4", &gateway6);
|
||||||
|
|
||||||
/* Create and set up device */
|
/* Create and set up device */
|
||||||
g_assert (nm_platform_link_dummy_add (NM_PLATFORM_GET, DEVICE_NAME, NULL) == NM_PLATFORM_ERROR_SUCCESS);
|
g_assert (NMTST_NM_ERR_SUCCESS (nm_platform_link_dummy_add (NM_PLATFORM_GET, DEVICE_NAME, NULL)));
|
||||||
accept_signal (link_added);
|
accept_signal (link_added);
|
||||||
free_signal (link_added);
|
free_signal (link_added);
|
||||||
g_assert (nm_platform_link_set_up (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME), NULL));
|
g_assert (nm_platform_link_set_up (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME), NULL));
|
||||||
|
|
|
||||||
|
|
@ -1010,7 +1010,7 @@ void nmtstp_ip4_route_add (NMPlatform *platform,
|
||||||
route.metric = metric;
|
route.metric = metric;
|
||||||
route.mss = mss;
|
route.mss = mss;
|
||||||
|
|
||||||
g_assert_cmpint (nm_platform_ip4_route_add (platform, NMP_NLM_FLAG_REPLACE, &route), ==, NM_PLATFORM_ERROR_SUCCESS);
|
g_assert (NMTST_NM_ERR_SUCCESS (nm_platform_ip4_route_add (platform, NMP_NLM_FLAG_REPLACE, &route)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void nmtstp_ip6_route_add (NMPlatform *platform,
|
void nmtstp_ip6_route_add (NMPlatform *platform,
|
||||||
|
|
@ -1034,7 +1034,7 @@ void nmtstp_ip6_route_add (NMPlatform *platform,
|
||||||
route.metric = metric;
|
route.metric = metric;
|
||||||
route.mss = mss;
|
route.mss = mss;
|
||||||
|
|
||||||
g_assert_cmpint (nm_platform_ip6_route_add (platform, NMP_NLM_FLAG_REPLACE, &route), ==, NM_PLATFORM_ERROR_SUCCESS);
|
g_assert (NMTST_NM_ERR_SUCCESS (nm_platform_ip6_route_add (platform, NMP_NLM_FLAG_REPLACE, &route)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
@ -1203,7 +1203,7 @@ nmtstp_link_veth_add (NMPlatform *platform,
|
||||||
nmtstp_assert_wait_for_link (platform, peer, NM_LINK_TYPE_VETH, 10);
|
nmtstp_assert_wait_for_link (platform, peer, NM_LINK_TYPE_VETH, 10);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
success = nm_platform_link_veth_add (platform, name, peer, &pllink) == NM_PLATFORM_ERROR_SUCCESS;
|
success = NMTST_NM_ERR_SUCCESS (nm_platform_link_veth_add (platform, name, peer, &pllink));
|
||||||
|
|
||||||
g_assert (success);
|
g_assert (success);
|
||||||
_assert_pllink (platform, success, pllink, name, NM_LINK_TYPE_VETH);
|
_assert_pllink (platform, success, pllink, name, NM_LINK_TYPE_VETH);
|
||||||
|
|
@ -1230,7 +1230,7 @@ nmtstp_link_dummy_add (NMPlatform *platform,
|
||||||
if (success)
|
if (success)
|
||||||
pllink = nmtstp_assert_wait_for_link (platform, name, NM_LINK_TYPE_DUMMY, 100);
|
pllink = nmtstp_assert_wait_for_link (platform, name, NM_LINK_TYPE_DUMMY, 100);
|
||||||
} else
|
} else
|
||||||
success = nm_platform_link_dummy_add (platform, name, &pllink) == NM_PLATFORM_ERROR_SUCCESS;
|
success = NMTST_NM_ERR_SUCCESS (nm_platform_link_dummy_add (platform, name, &pllink));
|
||||||
|
|
||||||
g_assert (success);
|
g_assert (success);
|
||||||
_assert_pllink (platform, success, pllink, name, NM_LINK_TYPE_DUMMY);
|
_assert_pllink (platform, success, pllink, name, NM_LINK_TYPE_DUMMY);
|
||||||
|
|
@ -1279,7 +1279,7 @@ nmtstp_link_gre_add (NMPlatform *platform,
|
||||||
if (success)
|
if (success)
|
||||||
pllink = nmtstp_assert_wait_for_link (platform, name, link_type, 100);
|
pllink = nmtstp_assert_wait_for_link (platform, name, link_type, 100);
|
||||||
} else
|
} else
|
||||||
success = nm_platform_link_gre_add (platform, name, lnk, &pllink) == NM_PLATFORM_ERROR_SUCCESS;
|
success = NMTST_NM_ERR_SUCCESS (nm_platform_link_gre_add (platform, name, lnk, &pllink));
|
||||||
|
|
||||||
_assert_pllink (platform, success, pllink, name, link_type);
|
_assert_pllink (platform, success, pllink, name, link_type);
|
||||||
|
|
||||||
|
|
@ -1342,7 +1342,7 @@ nmtstp_link_ip6tnl_add (NMPlatform *platform,
|
||||||
if (success)
|
if (success)
|
||||||
pllink = nmtstp_assert_wait_for_link (platform, name, NM_LINK_TYPE_IP6TNL, 100);
|
pllink = nmtstp_assert_wait_for_link (platform, name, NM_LINK_TYPE_IP6TNL, 100);
|
||||||
} else
|
} else
|
||||||
success = nm_platform_link_ip6tnl_add (platform, name, lnk, &pllink) == NM_PLATFORM_ERROR_SUCCESS;
|
success = NMTST_NM_ERR_SUCCESS (nm_platform_link_ip6tnl_add (platform, name, lnk, &pllink));
|
||||||
|
|
||||||
_assert_pllink (platform, success, pllink, name, NM_LINK_TYPE_IP6TNL);
|
_assert_pllink (platform, success, pllink, name, NM_LINK_TYPE_IP6TNL);
|
||||||
|
|
||||||
|
|
@ -1393,7 +1393,7 @@ nmtstp_link_ip6gre_add (NMPlatform *platform,
|
||||||
100);
|
100);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
success = nm_platform_link_ip6gre_add (platform, name, lnk, &pllink) == NM_PLATFORM_ERROR_SUCCESS;
|
success = NMTST_NM_ERR_SUCCESS (nm_platform_link_ip6gre_add (platform, name, lnk, &pllink));
|
||||||
|
|
||||||
_assert_pllink (platform, success, pllink, name, lnk->is_tap ? NM_LINK_TYPE_IP6GRETAP : NM_LINK_TYPE_IP6GRE);
|
_assert_pllink (platform, success, pllink, name, lnk->is_tap ? NM_LINK_TYPE_IP6GRETAP : NM_LINK_TYPE_IP6GRE);
|
||||||
|
|
||||||
|
|
@ -1434,7 +1434,7 @@ nmtstp_link_ipip_add (NMPlatform *platform,
|
||||||
if (success)
|
if (success)
|
||||||
pllink = nmtstp_assert_wait_for_link (platform, name, NM_LINK_TYPE_IPIP, 100);
|
pllink = nmtstp_assert_wait_for_link (platform, name, NM_LINK_TYPE_IPIP, 100);
|
||||||
} else
|
} else
|
||||||
success = nm_platform_link_ipip_add (platform, name, lnk, &pllink) == NM_PLATFORM_ERROR_SUCCESS;
|
success = NMTST_NM_ERR_SUCCESS (nm_platform_link_ipip_add (platform, name, lnk, &pllink));
|
||||||
|
|
||||||
_assert_pllink (platform, success, pllink, name, NM_LINK_TYPE_IPIP);
|
_assert_pllink (platform, success, pllink, name, NM_LINK_TYPE_IPIP);
|
||||||
|
|
||||||
|
|
@ -1482,7 +1482,7 @@ nmtstp_link_macvlan_add (NMPlatform *platform,
|
||||||
if (success)
|
if (success)
|
||||||
pllink = nmtstp_assert_wait_for_link (platform, name, link_type, 100);
|
pllink = nmtstp_assert_wait_for_link (platform, name, link_type, 100);
|
||||||
} else
|
} else
|
||||||
success = nm_platform_link_macvlan_add (platform, name, parent, lnk, &pllink) == NM_PLATFORM_ERROR_SUCCESS;
|
success = NMTST_NM_ERR_SUCCESS (nm_platform_link_macvlan_add (platform, name, parent, lnk, &pllink));
|
||||||
|
|
||||||
_assert_pllink (platform, success, pllink, name, link_type);
|
_assert_pllink (platform, success, pllink, name, link_type);
|
||||||
|
|
||||||
|
|
@ -1528,7 +1528,7 @@ nmtstp_link_sit_add (NMPlatform *platform,
|
||||||
if (success)
|
if (success)
|
||||||
pllink = nmtstp_assert_wait_for_link (platform, name, NM_LINK_TYPE_SIT, 100);
|
pllink = nmtstp_assert_wait_for_link (platform, name, NM_LINK_TYPE_SIT, 100);
|
||||||
} else
|
} else
|
||||||
success = nm_platform_link_sit_add (platform, name, lnk, &pllink) == NM_PLATFORM_ERROR_SUCCESS;
|
success = NMTST_NM_ERR_SUCCESS (nm_platform_link_sit_add (platform, name, lnk, &pllink));
|
||||||
|
|
||||||
_assert_pllink (platform, success, pllink, name, NM_LINK_TYPE_SIT);
|
_assert_pllink (platform, success, pllink, name, NM_LINK_TYPE_SIT);
|
||||||
|
|
||||||
|
|
@ -1543,8 +1543,8 @@ nmtstp_link_tun_add (NMPlatform *platform,
|
||||||
int *out_fd)
|
int *out_fd)
|
||||||
{
|
{
|
||||||
const NMPlatformLink *pllink = NULL;
|
const NMPlatformLink *pllink = NULL;
|
||||||
NMPlatformError plerr;
|
|
||||||
int err;
|
int err;
|
||||||
|
int r;
|
||||||
|
|
||||||
g_assert (nm_utils_is_valid_iface_name (name, NULL));
|
g_assert (nm_utils_is_valid_iface_name (name, NULL));
|
||||||
g_assert (lnk);
|
g_assert (lnk);
|
||||||
|
|
@ -1589,8 +1589,8 @@ nmtstp_link_tun_add (NMPlatform *platform,
|
||||||
g_error ("failure to add tun/tap device via ip-route");
|
g_error ("failure to add tun/tap device via ip-route");
|
||||||
} else {
|
} else {
|
||||||
g_assert (lnk->persist || out_fd);
|
g_assert (lnk->persist || out_fd);
|
||||||
plerr = nm_platform_link_tun_add (platform, name, lnk, &pllink, out_fd);
|
r = nm_platform_link_tun_add (platform, name, lnk, &pllink, out_fd);
|
||||||
g_assert_cmpint (plerr, ==, NM_PLATFORM_ERROR_SUCCESS);
|
g_assert_cmpint (r, ==, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_assert (pllink);
|
g_assert (pllink);
|
||||||
|
|
@ -1606,8 +1606,8 @@ nmtstp_link_vxlan_add (NMPlatform *platform,
|
||||||
const NMPlatformLnkVxlan *lnk)
|
const NMPlatformLnkVxlan *lnk)
|
||||||
{
|
{
|
||||||
const NMPlatformLink *pllink = NULL;
|
const NMPlatformLink *pllink = NULL;
|
||||||
NMPlatformError plerr;
|
|
||||||
int err;
|
int err;
|
||||||
|
int r;
|
||||||
|
|
||||||
g_assert (nm_utils_is_valid_iface_name (name, NULL));
|
g_assert (nm_utils_is_valid_iface_name (name, NULL));
|
||||||
|
|
||||||
|
|
@ -1656,8 +1656,8 @@ nmtstp_link_vxlan_add (NMPlatform *platform,
|
||||||
_LOGI ("Adding vxlan device via iproute2 failed. Assume iproute2 is not up to the task.");
|
_LOGI ("Adding vxlan device via iproute2 failed. Assume iproute2 is not up to the task.");
|
||||||
}
|
}
|
||||||
if (!pllink) {
|
if (!pllink) {
|
||||||
plerr = nm_platform_link_vxlan_add (platform, name, lnk, &pllink);
|
r = nm_platform_link_vxlan_add (platform, name, lnk, &pllink);
|
||||||
g_assert_cmpint (plerr, ==, NM_PLATFORM_ERROR_SUCCESS);
|
g_assert (NMTST_NM_ERR_SUCCESS (r));
|
||||||
g_assert (pllink);
|
g_assert (pllink);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -352,7 +352,7 @@ _nmtstp_env1_wrapper_setup (const NmtstTestData *test_data)
|
||||||
|
|
||||||
nmtstp_link_delete (NM_PLATFORM_GET, -1, -1, DEVICE_NAME, FALSE);
|
nmtstp_link_delete (NM_PLATFORM_GET, -1, -1, DEVICE_NAME, FALSE);
|
||||||
|
|
||||||
g_assert_cmpint (nm_platform_link_dummy_add (NM_PLATFORM_GET, DEVICE_NAME, NULL), ==, NM_PLATFORM_ERROR_SUCCESS);
|
g_assert (NMTST_NM_ERR_SUCCESS (nm_platform_link_dummy_add (NM_PLATFORM_GET, DEVICE_NAME, NULL)));
|
||||||
|
|
||||||
*p_ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME);
|
*p_ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME);
|
||||||
g_assert_cmpint (*p_ifindex, >, 0);
|
g_assert_cmpint (*p_ifindex, >, 0);
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@
|
||||||
#define MTU 1357
|
#define MTU 1357
|
||||||
|
|
||||||
#define _ADD_DUMMY(platform, name) \
|
#define _ADD_DUMMY(platform, name) \
|
||||||
g_assert_cmpint (nm_platform_link_dummy_add ((platform), (name), NULL), ==, NM_PLATFORM_ERROR_SUCCESS)
|
g_assert (NMTST_NM_ERR_SUCCESS (nm_platform_link_dummy_add ((platform), (name), NULL)))
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_bogus(void)
|
test_bogus(void)
|
||||||
|
|
@ -77,7 +77,7 @@ test_bogus(void)
|
||||||
g_assert (!addrlen);
|
g_assert (!addrlen);
|
||||||
g_assert (!nm_platform_link_get_address (NM_PLATFORM_GET, BOGUS_IFINDEX, NULL));
|
g_assert (!nm_platform_link_get_address (NM_PLATFORM_GET, BOGUS_IFINDEX, NULL));
|
||||||
|
|
||||||
g_assert (nm_platform_link_set_mtu (NM_PLATFORM_GET, BOGUS_IFINDEX, MTU) != NM_PLATFORM_ERROR_SUCCESS);
|
g_assert (!NMTST_NM_ERR_SUCCESS (nm_platform_link_set_mtu (NM_PLATFORM_GET, BOGUS_IFINDEX, MTU)));
|
||||||
|
|
||||||
g_assert (!nm_platform_link_get_mtu (NM_PLATFORM_GET, BOGUS_IFINDEX));
|
g_assert (!nm_platform_link_get_mtu (NM_PLATFORM_GET, BOGUS_IFINDEX));
|
||||||
|
|
||||||
|
|
@ -107,30 +107,30 @@ software_add (NMLinkType link_type, const char *name)
|
||||||
{
|
{
|
||||||
switch (link_type) {
|
switch (link_type) {
|
||||||
case NM_LINK_TYPE_DUMMY:
|
case NM_LINK_TYPE_DUMMY:
|
||||||
return nm_platform_link_dummy_add (NM_PLATFORM_GET, name, NULL) == NM_PLATFORM_ERROR_SUCCESS;
|
return NMTST_NM_ERR_SUCCESS (nm_platform_link_dummy_add (NM_PLATFORM_GET, name, NULL));
|
||||||
case NM_LINK_TYPE_BRIDGE:
|
case NM_LINK_TYPE_BRIDGE:
|
||||||
return nm_platform_link_bridge_add (NM_PLATFORM_GET, name, NULL, 0, NULL) == NM_PLATFORM_ERROR_SUCCESS;
|
return NMTST_NM_ERR_SUCCESS (nm_platform_link_bridge_add (NM_PLATFORM_GET, name, NULL, 0, NULL));
|
||||||
case NM_LINK_TYPE_BOND:
|
case NM_LINK_TYPE_BOND:
|
||||||
{
|
{
|
||||||
gboolean bond0_exists = !!nm_platform_link_get_by_ifname (NM_PLATFORM_GET, "bond0");
|
gboolean bond0_exists = !!nm_platform_link_get_by_ifname (NM_PLATFORM_GET, "bond0");
|
||||||
NMPlatformError plerr;
|
int r;
|
||||||
|
|
||||||
plerr = nm_platform_link_bond_add (NM_PLATFORM_GET, name, NULL);
|
r = nm_platform_link_bond_add (NM_PLATFORM_GET, name, NULL);
|
||||||
|
|
||||||
/* Check that bond0 is *not* automatically created. */
|
/* Check that bond0 is *not* automatically created. */
|
||||||
if (!bond0_exists)
|
if (!bond0_exists)
|
||||||
g_assert (!nm_platform_link_get_by_ifname (NM_PLATFORM_GET, "bond0"));
|
g_assert (!nm_platform_link_get_by_ifname (NM_PLATFORM_GET, "bond0"));
|
||||||
return plerr == NM_PLATFORM_ERROR_SUCCESS;
|
return r >= 0;
|
||||||
}
|
}
|
||||||
case NM_LINK_TYPE_TEAM:
|
case NM_LINK_TYPE_TEAM:
|
||||||
return nm_platform_link_team_add (NM_PLATFORM_GET, name, NULL) == NM_PLATFORM_ERROR_SUCCESS;
|
return NMTST_NM_ERR_SUCCESS (nm_platform_link_team_add (NM_PLATFORM_GET, name, NULL));
|
||||||
case NM_LINK_TYPE_VLAN: {
|
case NM_LINK_TYPE_VLAN: {
|
||||||
SignalData *parent_added;
|
SignalData *parent_added;
|
||||||
SignalData *parent_changed;
|
SignalData *parent_changed;
|
||||||
|
|
||||||
/* Don't call link_callback for the bridge interface */
|
/* Don't call link_callback for the bridge interface */
|
||||||
parent_added = add_signal_ifname (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_ADDED, link_callback, PARENT_NAME);
|
parent_added = add_signal_ifname (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_ADDED, link_callback, PARENT_NAME);
|
||||||
if (nm_platform_link_bridge_add (NM_PLATFORM_GET, PARENT_NAME, NULL, 0, NULL) == NM_PLATFORM_ERROR_SUCCESS)
|
if (NMTST_NM_ERR_SUCCESS (nm_platform_link_bridge_add (NM_PLATFORM_GET, PARENT_NAME, NULL, 0, NULL)))
|
||||||
accept_signal (parent_added);
|
accept_signal (parent_added);
|
||||||
free_signal (parent_added);
|
free_signal (parent_added);
|
||||||
|
|
||||||
|
|
@ -147,7 +147,7 @@ software_add (NMLinkType link_type, const char *name)
|
||||||
accept_signals (parent_changed, 1, 2);
|
accept_signals (parent_changed, 1, 2);
|
||||||
free_signal (parent_changed);
|
free_signal (parent_changed);
|
||||||
|
|
||||||
return nm_platform_link_vlan_add (NM_PLATFORM_GET, name, parent_ifindex, VLAN_ID, 0, NULL) == NM_PLATFORM_ERROR_SUCCESS;
|
return NMTST_NM_ERR_SUCCESS (nm_platform_link_vlan_add (NM_PLATFORM_GET, name, parent_ifindex, VLAN_ID, 0, NULL));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
@ -502,7 +502,7 @@ test_bridge_addr (void)
|
||||||
|
|
||||||
nm_utils_hwaddr_aton ("de:ad:be:ef:00:11", addr, sizeof (addr));
|
nm_utils_hwaddr_aton ("de:ad:be:ef:00:11", addr, sizeof (addr));
|
||||||
|
|
||||||
g_assert_cmpint (nm_platform_link_bridge_add (NM_PLATFORM_GET, DEVICE_NAME, addr, sizeof (addr), &plink), ==, NM_PLATFORM_ERROR_SUCCESS);
|
g_assert (NMTST_NM_ERR_SUCCESS (nm_platform_link_bridge_add (NM_PLATFORM_GET, DEVICE_NAME, addr, sizeof (addr), &plink)));
|
||||||
g_assert (plink);
|
g_assert (plink);
|
||||||
link = *plink;
|
link = *plink;
|
||||||
g_assert_cmpstr (link.name, ==, DEVICE_NAME);
|
g_assert_cmpstr (link.name, ==, DEVICE_NAME);
|
||||||
|
|
@ -518,13 +518,13 @@ test_bridge_addr (void)
|
||||||
g_assert (!nm_platform_link_get_user_ipv6ll_enabled (NM_PLATFORM_GET, link.ifindex));
|
g_assert (!nm_platform_link_get_user_ipv6ll_enabled (NM_PLATFORM_GET, link.ifindex));
|
||||||
g_assert_cmpint (_nm_platform_uint8_inv (plink->inet6_addr_gen_mode_inv), ==, NM_IN6_ADDR_GEN_MODE_EUI64);
|
g_assert_cmpint (_nm_platform_uint8_inv (plink->inet6_addr_gen_mode_inv), ==, NM_IN6_ADDR_GEN_MODE_EUI64);
|
||||||
|
|
||||||
g_assert (nm_platform_link_set_user_ipv6ll_enabled (NM_PLATFORM_GET, link.ifindex, TRUE) == NM_PLATFORM_ERROR_SUCCESS);
|
g_assert (NMTST_NM_ERR_SUCCESS (nm_platform_link_set_user_ipv6ll_enabled (NM_PLATFORM_GET, link.ifindex, TRUE)));
|
||||||
g_assert (nm_platform_link_get_user_ipv6ll_enabled (NM_PLATFORM_GET, link.ifindex));
|
g_assert (nm_platform_link_get_user_ipv6ll_enabled (NM_PLATFORM_GET, link.ifindex));
|
||||||
plink = nm_platform_link_get (NM_PLATFORM_GET, link.ifindex);
|
plink = nm_platform_link_get (NM_PLATFORM_GET, link.ifindex);
|
||||||
g_assert (plink);
|
g_assert (plink);
|
||||||
g_assert_cmpint (_nm_platform_uint8_inv (plink->inet6_addr_gen_mode_inv), ==, NM_IN6_ADDR_GEN_MODE_NONE);
|
g_assert_cmpint (_nm_platform_uint8_inv (plink->inet6_addr_gen_mode_inv), ==, NM_IN6_ADDR_GEN_MODE_NONE);
|
||||||
|
|
||||||
g_assert (nm_platform_link_set_user_ipv6ll_enabled (NM_PLATFORM_GET, link.ifindex, FALSE) == NM_PLATFORM_ERROR_SUCCESS);
|
g_assert (NMTST_NM_ERR_SUCCESS (nm_platform_link_set_user_ipv6ll_enabled (NM_PLATFORM_GET, link.ifindex, FALSE)));
|
||||||
g_assert (!nm_platform_link_get_user_ipv6ll_enabled (NM_PLATFORM_GET, link.ifindex));
|
g_assert (!nm_platform_link_get_user_ipv6ll_enabled (NM_PLATFORM_GET, link.ifindex));
|
||||||
plink = nm_platform_link_get (NM_PLATFORM_GET, link.ifindex);
|
plink = nm_platform_link_get (NM_PLATFORM_GET, link.ifindex);
|
||||||
g_assert (plink);
|
g_assert (plink);
|
||||||
|
|
@ -554,11 +554,11 @@ test_internal (void)
|
||||||
g_assert (!nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME));
|
g_assert (!nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME));
|
||||||
|
|
||||||
/* Add device */
|
/* Add device */
|
||||||
g_assert (nm_platform_link_dummy_add (NM_PLATFORM_GET, DEVICE_NAME, NULL) == NM_PLATFORM_ERROR_SUCCESS);
|
g_assert (NMTST_NM_ERR_SUCCESS (nm_platform_link_dummy_add (NM_PLATFORM_GET, DEVICE_NAME, NULL)));
|
||||||
accept_signal (link_added);
|
accept_signal (link_added);
|
||||||
|
|
||||||
/* Try to add again */
|
/* Try to add again */
|
||||||
g_assert (nm_platform_link_dummy_add (NM_PLATFORM_GET, DEVICE_NAME, NULL) == NM_PLATFORM_ERROR_EXISTS);
|
g_assert (nm_platform_link_dummy_add (NM_PLATFORM_GET, DEVICE_NAME, NULL) == -NME_PL_EXISTS);
|
||||||
|
|
||||||
/* Check device index, name and type */
|
/* Check device index, name and type */
|
||||||
ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME);
|
ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME);
|
||||||
|
|
@ -595,7 +595,7 @@ test_internal (void)
|
||||||
g_assert (nm_platform_link_supports_vlans (NM_PLATFORM_GET, ifindex));
|
g_assert (nm_platform_link_supports_vlans (NM_PLATFORM_GET, ifindex));
|
||||||
|
|
||||||
/* Set MAC address */
|
/* Set MAC address */
|
||||||
g_assert (nm_platform_link_set_address (NM_PLATFORM_GET, ifindex, mac, sizeof (mac)) == NM_PLATFORM_ERROR_SUCCESS);
|
g_assert (NMTST_NM_ERR_SUCCESS (nm_platform_link_set_address (NM_PLATFORM_GET, ifindex, mac, sizeof (mac))));
|
||||||
address = nm_platform_link_get_address (NM_PLATFORM_GET, ifindex, &addrlen);
|
address = nm_platform_link_get_address (NM_PLATFORM_GET, ifindex, &addrlen);
|
||||||
g_assert (addrlen == sizeof(mac));
|
g_assert (addrlen == sizeof(mac));
|
||||||
g_assert (!memcmp (address, mac, addrlen));
|
g_assert (!memcmp (address, mac, addrlen));
|
||||||
|
|
@ -604,7 +604,7 @@ test_internal (void)
|
||||||
accept_signal (link_changed);
|
accept_signal (link_changed);
|
||||||
|
|
||||||
/* Set MTU */
|
/* Set MTU */
|
||||||
g_assert (nm_platform_link_set_mtu (NM_PLATFORM_GET, ifindex, MTU) == NM_PLATFORM_ERROR_SUCCESS);
|
g_assert (NMTST_NM_ERR_SUCCESS (nm_platform_link_set_mtu (NM_PLATFORM_GET, ifindex, MTU)));
|
||||||
g_assert_cmpint (nm_platform_link_get_mtu (NM_PLATFORM_GET, ifindex), ==, MTU);
|
g_assert_cmpint (nm_platform_link_get_mtu (NM_PLATFORM_GET, ifindex), ==, MTU);
|
||||||
accept_signal (link_changed);
|
accept_signal (link_changed);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -427,7 +427,7 @@ test_ip4_route_get (void)
|
||||||
{
|
{
|
||||||
int ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME);
|
int ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME);
|
||||||
in_addr_t a;
|
in_addr_t a;
|
||||||
NMPlatformError result;
|
int result;
|
||||||
nm_auto_nmpobj NMPObject *route = NULL;
|
nm_auto_nmpobj NMPObject *route = NULL;
|
||||||
const NMPlatformIP4Route *r;
|
const NMPlatformIP4Route *r;
|
||||||
|
|
||||||
|
|
@ -446,7 +446,7 @@ test_ip4_route_get (void)
|
||||||
nmtst_get_rand_int () % 2 ? 0 : ifindex,
|
nmtst_get_rand_int () % 2 ? 0 : ifindex,
|
||||||
&route);
|
&route);
|
||||||
|
|
||||||
g_assert (result == NM_PLATFORM_ERROR_SUCCESS);
|
g_assert (NMTST_NM_ERR_SUCCESS (result));
|
||||||
g_assert (NMP_OBJECT_GET_TYPE (route) == NMP_OBJECT_TYPE_IP4_ROUTE);
|
g_assert (NMP_OBJECT_GET_TYPE (route) == NMP_OBJECT_TYPE_IP4_ROUTE);
|
||||||
g_assert (!NMP_OBJECT_IS_STACKINIT (route));
|
g_assert (!NMP_OBJECT_IS_STACKINIT (route));
|
||||||
g_assert (route->parent._ref_count == 1);
|
g_assert (route->parent._ref_count == 1);
|
||||||
|
|
@ -565,7 +565,7 @@ test_ip4_route_options (gconstpointer test_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < rts_n; i++)
|
for (i = 0; i < rts_n; i++)
|
||||||
g_assert (nm_platform_ip4_route_add (NM_PLATFORM_GET, NMP_NLM_FLAG_REPLACE, &rts_add[i]) == NM_PLATFORM_ERROR_SUCCESS);
|
g_assert (NMTST_NM_ERR_SUCCESS (nm_platform_ip4_route_add (NM_PLATFORM_GET, NMP_NLM_FLAG_REPLACE, &rts_add[i])));
|
||||||
|
|
||||||
for (i = 0; i < rts_n; i++) {
|
for (i = 0; i < rts_n; i++) {
|
||||||
rts_cmp[i] = rts_add[i];
|
rts_cmp[i] = rts_add[i];
|
||||||
|
|
@ -589,7 +589,7 @@ test_ip6_route_get (void)
|
||||||
{
|
{
|
||||||
int ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME);
|
int ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME);
|
||||||
const struct in6_addr *a;
|
const struct in6_addr *a;
|
||||||
NMPlatformError result;
|
int result;
|
||||||
nm_auto_nmpobj NMPObject *route = NULL;
|
nm_auto_nmpobj NMPObject *route = NULL;
|
||||||
const NMPlatformIP6Route *r;
|
const NMPlatformIP6Route *r;
|
||||||
|
|
||||||
|
|
@ -608,7 +608,7 @@ test_ip6_route_get (void)
|
||||||
nmtst_get_rand_int () % 2 ? 0 : ifindex,
|
nmtst_get_rand_int () % 2 ? 0 : ifindex,
|
||||||
&route);
|
&route);
|
||||||
|
|
||||||
g_assert (result == NM_PLATFORM_ERROR_SUCCESS);
|
g_assert (NMTST_NM_ERR_SUCCESS (result));
|
||||||
g_assert (NMP_OBJECT_GET_TYPE (route) == NMP_OBJECT_TYPE_IP6_ROUTE);
|
g_assert (NMP_OBJECT_GET_TYPE (route) == NMP_OBJECT_TYPE_IP6_ROUTE);
|
||||||
g_assert (!NMP_OBJECT_IS_STACKINIT (route));
|
g_assert (!NMP_OBJECT_IS_STACKINIT (route));
|
||||||
g_assert (route->parent._ref_count == 1);
|
g_assert (route->parent._ref_count == 1);
|
||||||
|
|
@ -724,7 +724,7 @@ test_ip6_route_options (gconstpointer test_data)
|
||||||
_wait_for_ipv6_addr_non_tentative (NM_PLATFORM_GET, 400, IFINDEX, addr_n, addr_in6);
|
_wait_for_ipv6_addr_non_tentative (NM_PLATFORM_GET, 400, IFINDEX, addr_n, addr_in6);
|
||||||
|
|
||||||
for (i = 0; i < rts_n; i++)
|
for (i = 0; i < rts_n; i++)
|
||||||
g_assert (nm_platform_ip6_route_add (NM_PLATFORM_GET, NMP_NLM_FLAG_REPLACE, &rts_add[i]) == NM_PLATFORM_ERROR_SUCCESS);
|
g_assert (NMTST_NM_ERR_SUCCESS (nm_platform_ip6_route_add (NM_PLATFORM_GET, NMP_NLM_FLAG_REPLACE, &rts_add[i])));
|
||||||
|
|
||||||
for (i = 0; i < rts_n; i++) {
|
for (i = 0; i < rts_n; i++) {
|
||||||
rts_cmp[i] = rts_add[i];
|
rts_cmp[i] = rts_add[i];
|
||||||
|
|
@ -823,7 +823,7 @@ again_find_idx:
|
||||||
order_idx[order_len++] = idx;
|
order_idx[order_len++] = idx;
|
||||||
|
|
||||||
r->ifindex = iface_data[idx].ifindex;
|
r->ifindex = iface_data[idx].ifindex;
|
||||||
g_assert (nm_platform_ip4_route_add (platform, NMP_NLM_FLAG_APPEND, r) == NM_PLATFORM_ERROR_SUCCESS);
|
g_assert (NMTST_NM_ERR_SUCCESS (nm_platform_ip4_route_add (platform, NMP_NLM_FLAG_APPEND, r)));
|
||||||
} else {
|
} else {
|
||||||
i = nmtst_get_rand_int () % order_len;
|
i = nmtst_get_rand_int () % order_len;
|
||||||
idx = order_idx[i];
|
idx = order_idx[i];
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@
|
||||||
#include <linux/nl80211.h>
|
#include <linux/nl80211.h>
|
||||||
#include <linux/if.h>
|
#include <linux/if.h>
|
||||||
|
|
||||||
|
#include "nm-utils/nm-errno.h"
|
||||||
#include "platform/nm-netlink.h"
|
#include "platform/nm-netlink.h"
|
||||||
#include "nm-wifi-utils-private.h"
|
#include "nm-wifi-utils-private.h"
|
||||||
#include "platform/nm-platform.h"
|
#include "platform/nm-platform.h"
|
||||||
|
|
@ -150,11 +151,11 @@ nl80211_send_and_recv (NMWifiUtilsNl80211 *self,
|
||||||
* and we don't need consistent view of whole scan list. Hence do
|
* and we don't need consistent view of whole scan list. Hence do
|
||||||
* not warn on DUMP_INTR error for get scan command.
|
* not warn on DUMP_INTR error for get scan command.
|
||||||
*/
|
*/
|
||||||
if (err == -NLE_DUMP_INTR &&
|
if (err == -NME_NL_DUMP_INTR &&
|
||||||
genlmsg_hdr (nlmsg_hdr (msg))->cmd == NL80211_CMD_GET_SCAN)
|
genlmsg_hdr (nlmsg_hdr (msg))->cmd == NL80211_CMD_GET_SCAN)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
_LOGW ("nl_recvmsgs() error: (%d) %s", err, nl_geterror (err));
|
_LOGW ("nl_recvmsgs() error: (%d) %s", err, nm_strerror (err));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
#include <linux/if.h>
|
#include <linux/if.h>
|
||||||
|
|
||||||
|
#include "nm-utils/nm-errno.h"
|
||||||
#include "platform/linux/nl802154.h"
|
#include "platform/linux/nl802154.h"
|
||||||
#include "platform/nm-netlink.h"
|
#include "platform/nm-netlink.h"
|
||||||
#include "platform/nm-platform-utils.h"
|
#include "platform/nm-platform-utils.h"
|
||||||
|
|
@ -133,7 +134,7 @@ nl802154_send_and_recv (NMWpanUtils *self,
|
||||||
err = nl_recvmsgs (self->nl_sock, &cb);
|
err = nl_recvmsgs (self->nl_sock, &cb);
|
||||||
if (err < 0 && err != -EAGAIN) {
|
if (err < 0 && err != -EAGAIN) {
|
||||||
_LOGW (LOGD_PLATFORM, "nl_recvmsgs() error: (%d) %s",
|
_LOGW (LOGD_PLATFORM, "nl_recvmsgs() error: (%d) %s",
|
||||||
err, nl_geterror (err));
|
err, nm_strerror (err));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -725,7 +725,7 @@ add_ip4_vpn_gateway_route (NMIP4Config *config,
|
||||||
AF_INET,
|
AF_INET,
|
||||||
&vpn_gw,
|
&vpn_gw,
|
||||||
ifindex,
|
ifindex,
|
||||||
(NMPObject **) &route_resolved) == NM_PLATFORM_ERROR_SUCCESS) {
|
(NMPObject **) &route_resolved) >= 0) {
|
||||||
const NMPlatformIP4Route *r = NMP_OBJECT_CAST_IP4_ROUTE (route_resolved);
|
const NMPlatformIP4Route *r = NMP_OBJECT_CAST_IP4_ROUTE (route_resolved);
|
||||||
|
|
||||||
if (r->ifindex == ifindex) {
|
if (r->ifindex == ifindex) {
|
||||||
|
|
@ -799,7 +799,7 @@ add_ip6_vpn_gateway_route (NMIP6Config *config,
|
||||||
AF_INET6,
|
AF_INET6,
|
||||||
vpn_gw,
|
vpn_gw,
|
||||||
ifindex,
|
ifindex,
|
||||||
(NMPObject **) &route_resolved) == NM_PLATFORM_ERROR_SUCCESS) {
|
(NMPObject **) &route_resolved) >= 0) {
|
||||||
const NMPlatformIP6Route *r = NMP_OBJECT_CAST_IP6_ROUTE (route_resolved);
|
const NMPlatformIP6Route *r = NMP_OBJECT_CAST_IP6_ROUTE (route_resolved);
|
||||||
|
|
||||||
if (r->ifindex == ifindex) {
|
if (r->ifindex == ifindex) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue