platform/tun: don't passing around the ifname guess

nm_platform_sysctl_open_netdir() doesn't take it anyways, gets it from
the cache.

CID 160209 (#1 of 1): Unused value (UNUSED_VALUE)
This commit is contained in:
Lubomir Rintel
2017-01-16 15:51:05 +01:00
parent cb8e70546b
commit 5b51a5f260
4 changed files with 7 additions and 21 deletions

View File

@@ -80,7 +80,7 @@ update_properties (NMDeviceTun *self)
ifindex = nm_device_get_ifindex (NM_DEVICE (self)); ifindex = nm_device_get_ifindex (NM_DEVICE (self));
if (ifindex > 0) { if (ifindex > 0) {
if (!nm_platform_link_tun_get_properties (NM_PLATFORM_GET, ifindex, NULL, &props)) { if (!nm_platform_link_tun_get_properties (NM_PLATFORM_GET, ifindex, &props)) {
_LOGD (LOGD_DEVICE, "tun-properties: cannot loading tun properties from platform for ifindex %d", ifindex); _LOGD (LOGD_DEVICE, "tun-properties: cannot loading tun properties from platform for ifindex %d", ifindex);
ifindex = 0; ifindex = 0;
} else if (g_strcmp0 (priv->mode, props.mode) != 0) { } else if (g_strcmp0 (priv->mode, props.mode) != 0) {
@@ -181,7 +181,7 @@ update_connection (NMDevice *device, NMConnection *connection)
nm_connection_add_setting (connection, (NMSetting *) s_tun); nm_connection_add_setting (connection, (NMSetting *) s_tun);
} }
if (!nm_platform_link_tun_get_properties (NM_PLATFORM_GET, nm_device_get_ifindex (device), NULL, &props)) { if (!nm_platform_link_tun_get_properties (NM_PLATFORM_GET, nm_device_get_ifindex (device), &props)) {
_LOGW (LOGD_PLATFORM, "failed to get TUN interface info while updating connection."); _LOGW (LOGD_PLATFORM, "failed to get TUN interface info while updating connection.");
return; return;
} }

View File

@@ -672,7 +672,7 @@ _linktype_get_type (NMPlatform *platform,
NMPlatformTunProperties props; NMPlatformTunProperties props;
if ( platform if ( platform
&& nm_platform_link_tun_get_properties (platform, ifindex, ifname, &props)) { && nm_platform_link_tun_get_properties (platform, ifindex, &props)) {
if (!g_strcmp0 (props.mode, "tap")) if (!g_strcmp0 (props.mode, "tap"))
return NM_LINK_TYPE_TAP; return NM_LINK_TYPE_TAP;
if (!g_strcmp0 (props.mode, "tun")) if (!g_strcmp0 (props.mode, "tun"))

View File

@@ -2328,11 +2328,10 @@ nm_platform_link_veth_get_properties (NMPlatform *self, int ifindex, int *out_pe
} }
gboolean gboolean
nm_platform_link_tun_get_properties (NMPlatform *self, int ifindex, const char *ifname_guess, NMPlatformTunProperties *props) nm_platform_link_tun_get_properties (NMPlatform *self, int ifindex, NMPlatformTunProperties *props)
{ {
nm_auto_close int dirfd = -1; nm_auto_close int dirfd = -1;
const char *ifname; char ifname[IFNAMSIZ];
char ifname_verified[IFNAMSIZ];
gint64 flags; gint64 flags;
gboolean success = TRUE; gboolean success = TRUE;
_CHECK_SELF (self, klass, FALSE); _CHECK_SELF (self, klass, FALSE);
@@ -2340,27 +2339,14 @@ nm_platform_link_tun_get_properties (NMPlatform *self, int ifindex, const char *
g_return_val_if_fail (ifindex > 0, FALSE); g_return_val_if_fail (ifindex > 0, FALSE);
g_return_val_if_fail (props, FALSE); g_return_val_if_fail (props, FALSE);
/* ifname_guess is an optional argument to find a guess for the ifname corresponding to
* ifindex. */
if (!ifname_guess) {
/* if NULL, obtain the guess from the platform cache. */
ifname = nm_platform_link_get_name (self, ifindex);
} else if (!ifname_guess[0]) {
/* if empty, don't use a guess. That means to use if_indextoname(). */
ifname = NULL;
} else
ifname = ifname_guess;
memset (props, 0, sizeof (*props)); memset (props, 0, sizeof (*props));
props->owner = -1; props->owner = -1;
props->group = -1; props->group = -1;
dirfd = nm_platform_sysctl_open_netdir (self, ifindex, ifname_verified); dirfd = nm_platform_sysctl_open_netdir (self, ifindex, ifname);
if (dirfd < 0) if (dirfd < 0)
return FALSE; return FALSE;
ifname = ifname_verified;
props->owner = nm_platform_sysctl_get_int_checked (self, NMP_SYSCTL_PATHID_NETDIR (dirfd, ifname, "owner"), 10, -1, G_MAXINT64, -1); props->owner = nm_platform_sysctl_get_int_checked (self, NMP_SYSCTL_PATHID_NETDIR (dirfd, ifname, "owner"), 10, -1, G_MAXINT64, -1);
if (errno) if (errno)
success = FALSE; success = FALSE;

View File

@@ -890,7 +890,7 @@ NMPlatformError nm_platform_link_infiniband_delete (NMPlatform *self,
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);
gboolean nm_platform_link_tun_get_properties (NMPlatform *self, int ifindex, const char *ifname_guess, NMPlatformTunProperties *properties); gboolean nm_platform_link_tun_get_properties (NMPlatform *self, int ifindex, NMPlatformTunProperties *properties);
gboolean nm_platform_wifi_get_capabilities (NMPlatform *self, int ifindex, NMDeviceWifiCapabilities *caps); gboolean nm_platform_wifi_get_capabilities (NMPlatform *self, int ifindex, NMDeviceWifiCapabilities *caps);
gboolean nm_platform_wifi_get_bssid (NMPlatform *self, int ifindex, guint8 *bssid); gboolean nm_platform_wifi_get_bssid (NMPlatform *self, int ifindex, guint8 *bssid);