mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-04 10:40:58 +01:00
platform: add nm_platform_link_set_name()
We'll need it to rename the new PPP interface to a given name.
This commit is contained in:
parent
f83e56ec6d
commit
d5c2c3f6d7
3 changed files with 50 additions and 0 deletions
|
|
@ -4463,6 +4463,29 @@ nla_put_failure:
|
|||
g_return_val_if_reached (NM_PLATFORM_ERROR_UNSPECIFIED);
|
||||
}
|
||||
|
||||
static NMPlatformError
|
||||
link_set_name (NMPlatform *platform, int ifindex, const char *name)
|
||||
{
|
||||
nm_auto_nlmsg struct nl_msg *nlmsg = NULL;
|
||||
|
||||
_LOGD ("link: change %d: name: %s", ifindex, name);
|
||||
|
||||
nlmsg = _nl_msg_new_link (RTM_NEWLINK,
|
||||
0,
|
||||
ifindex,
|
||||
NULL,
|
||||
0,
|
||||
0);
|
||||
if (!nlmsg)
|
||||
g_return_val_if_reached (NM_PLATFORM_ERROR_UNSPECIFIED);
|
||||
|
||||
NLA_PUT (nlmsg, IFLA_IFNAME, strlen (name) + 1, name);
|
||||
|
||||
return do_change_link (platform, ifindex, nlmsg) == NM_PLATFORM_ERROR_SUCCESS;
|
||||
nla_put_failure:
|
||||
g_return_val_if_reached (FALSE);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
link_get_permanent_address (NMPlatform *platform,
|
||||
int ifindex,
|
||||
|
|
@ -6461,6 +6484,7 @@ nm_linux_platform_class_init (NMLinuxPlatformClass *klass)
|
|||
platform_class->link_set_address = link_set_address;
|
||||
platform_class->link_get_permanent_address = link_get_permanent_address;
|
||||
platform_class->link_set_mtu = link_set_mtu;
|
||||
platform_class->link_set_name = link_set_name;
|
||||
platform_class->link_set_sriov_num_vfs = link_set_sriov_num_vfs;
|
||||
|
||||
platform_class->link_get_physical_port_id = link_get_physical_port_id;
|
||||
|
|
|
|||
|
|
@ -1461,6 +1461,30 @@ nm_platform_link_get_mtu (NMPlatform *self, int ifindex)
|
|||
return pllink ? pllink->mtu : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_platform_link_set_name:
|
||||
* @self: platform instance
|
||||
* @ifindex: Interface index
|
||||
* @name: The new interface name
|
||||
*
|
||||
* Set interface name.
|
||||
*/
|
||||
gboolean
|
||||
nm_platform_link_set_name (NMPlatform *self, int ifindex, const char *name)
|
||||
{
|
||||
_CHECK_SELF (self, klass, FALSE);
|
||||
|
||||
g_return_val_if_fail (ifindex >= 0, FALSE);
|
||||
g_return_val_if_fail (name, FALSE);
|
||||
|
||||
_LOGD ("link: setting '%s' (%d) name %s", nm_platform_link_get_name (self, ifindex), ifindex, name);
|
||||
|
||||
if (strlen (name) + 1 > IFNAMSIZ)
|
||||
return FALSE;
|
||||
|
||||
return klass->link_set_name (self, ifindex, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_platform_link_get_physical_port_id:
|
||||
* @self: platform instance
|
||||
|
|
|
|||
|
|
@ -682,6 +682,7 @@ typedef struct {
|
|||
size_t *length);
|
||||
NMPlatformError (*link_set_address) (NMPlatform *, int ifindex, gconstpointer address, size_t length);
|
||||
gboolean (*link_set_mtu) (NMPlatform *, int ifindex, guint32 mtu);
|
||||
gboolean (*link_set_name) (NMPlatform *, int ifindex, const char *name);
|
||||
gboolean (*link_set_sriov_num_vfs) (NMPlatform *, int ifindex, guint num_vfs);
|
||||
|
||||
char * (*link_get_physical_port_id) (NMPlatform *, int ifindex);
|
||||
|
|
@ -946,6 +947,7 @@ gboolean nm_platform_link_set_ipv6_token (NMPlatform *self, int ifindex, NMUtils
|
|||
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);
|
||||
gboolean 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_sriov_num_vfs (NMPlatform *self, int ifindex, guint num_vfs);
|
||||
|
||||
char *nm_platform_link_get_physical_port_id (NMPlatform *self, int ifindex);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue