mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-29 12:40:11 +01:00
platform: detect TUN/TAP device in link_extract_type() independently of platform cache
link_extract_type() would call tun_get_properties() to determine whether
the link if a TAP or TUN device. The previous implementation would
receive the ifindex, and resolve the ifname via lookup in the platform
cache.
This means, the call on link_extract_type() will only succeed to detect
the TUN/TAP properties, if the libnl object is already in the cache.
Currently that is always the case and there is no problem.
It is desireable, that we can resolve the link type of an object without
consulting the platform cache first.
(cherry picked from commit 18d611d5d2)
This commit is contained in:
parent
b4a88db19e
commit
bae47558ba
1 changed files with 10 additions and 4 deletions
|
|
@ -120,6 +120,8 @@
|
|||
return t; \
|
||||
} G_STMT_END
|
||||
|
||||
static gboolean tun_get_properties_ifname (NMPlatform *platform, const char *ifname, NMPlatformTunProperties *props);
|
||||
|
||||
/******************************************************************
|
||||
* libnl unility functions and wrappers
|
||||
******************************************************************/
|
||||
|
|
@ -968,7 +970,7 @@ link_extract_type (NMPlatform *platform, struct rtnl_link *rtnllink, const char
|
|||
NMPlatformTunProperties props;
|
||||
guint flags;
|
||||
|
||||
if (nm_platform_tun_get_properties (platform, rtnl_link_get_ifindex (rtnllink), &props)) {
|
||||
if (tun_get_properties_ifname (platform, rtnl_link_get_name (rtnllink), &props)) {
|
||||
if (!g_strcmp0 (props.mode, "tap"))
|
||||
return_type (NM_LINK_TYPE_TAP, "tap");
|
||||
if (!g_strcmp0 (props.mode, "tun"))
|
||||
|
|
@ -3064,9 +3066,8 @@ veth_get_properties (NMPlatform *platform, int ifindex, NMPlatformVethProperties
|
|||
}
|
||||
|
||||
static gboolean
|
||||
tun_get_properties (NMPlatform *platform, int ifindex, NMPlatformTunProperties *props)
|
||||
tun_get_properties_ifname (NMPlatform *platform, const char *ifname, NMPlatformTunProperties *props)
|
||||
{
|
||||
const char *ifname;
|
||||
char *path, *val;
|
||||
gboolean success = TRUE;
|
||||
|
||||
|
|
@ -3076,7 +3077,6 @@ tun_get_properties (NMPlatform *platform, int ifindex, NMPlatformTunProperties *
|
|||
props->owner = -1;
|
||||
props->group = -1;
|
||||
|
||||
ifname = nm_platform_link_get_name (platform, ifindex);
|
||||
if (!ifname || !nm_utils_iface_valid_name (ifname))
|
||||
return FALSE;
|
||||
ifname = ASSERT_VALID_PATH_COMPONENT (ifname);
|
||||
|
|
@ -3127,6 +3127,12 @@ tun_get_properties (NMPlatform *platform, int ifindex, NMPlatformTunProperties *
|
|||
return success;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
tun_get_properties (NMPlatform *platform, int ifindex, NMPlatformTunProperties *props)
|
||||
{
|
||||
return tun_get_properties_ifname (platform, nm_platform_link_get_name (platform, ifindex), props);
|
||||
}
|
||||
|
||||
static const struct nla_policy macvlan_info_policy[IFLA_MACVLAN_MAX + 1] = {
|
||||
[IFLA_MACVLAN_MODE] = { .type = NLA_U32 },
|
||||
#ifdef MACVLAN_FLAG_NOPROMISC
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue