platform: implement link_6lowpan_add via nm_platform_link_add()

This commit is contained in:
Thomas Haller 2019-12-31 13:19:53 +01:00
parent d3963e4ac7
commit 8b417300ca
3 changed files with 9 additions and 74 deletions

View file

@ -7589,39 +7589,6 @@ link_tun_add (NMPlatform *platform,
return TRUE;
}
static gboolean
link_6lowpan_add (NMPlatform *platform,
const char *name,
int parent,
const NMPlatformLink **out_link)
{
nm_auto_nlmsg struct nl_msg *nlmsg = NULL;
struct nlattr *info;
nlmsg = _nl_msg_new_link (RTM_NEWLINK,
NLM_F_CREATE | NLM_F_EXCL,
0,
name);
if (!nlmsg)
return FALSE;
NLA_PUT_U32 (nlmsg, IFLA_LINK, parent);
if (!(info = nla_nest_start (nlmsg, IFLA_LINKINFO)))
goto nla_put_failure;
NLA_PUT_STRING (nlmsg, IFLA_INFO_KIND, "lowpan");
nla_nest_end (nlmsg, info);
return (do_add_link_with_lookup (platform,
NM_LINK_TYPE_6LOWPAN,
name, nlmsg, out_link) >= 0);
nla_put_failure:
g_return_val_if_reached (FALSE);
}
static void
_vlan_change_vlan_qos_mapping_create (gboolean is_ingress_map,
gboolean reset_all,
@ -9258,7 +9225,6 @@ nm_linux_platform_class_init (NMLinuxPlatformClass *klass)
platform_class->link_macvlan_add = link_macvlan_add;
platform_class->link_ipip_add = link_ipip_add;
platform_class->link_tun_add = link_tun_add;
platform_class->link_6lowpan_add = link_6lowpan_add;
platform_class->object_delete = object_delete;
platform_class->ip4_address_add = ip4_address_add;

View file

@ -2375,38 +2375,6 @@ nm_platform_link_tun_add (NMPlatform *self,
return 0;
}
/**
* nm_platform_6lowpan_add:
* @self: platform instance
* @parent: parent link
* @name: name of the new interface
* @out_link: on success, the link object
*
* Create a 6LoWPAN interface.
*/
int
nm_platform_link_6lowpan_add (NMPlatform *self,
const char *name,
int parent,
const NMPlatformLink **out_link)
{
int r;
_CHECK_SELF (self, klass, -NME_BUG);
g_return_val_if_fail (name, -NME_BUG);
r = _link_add_check_existing (self, name, NM_LINK_TYPE_6LOWPAN, out_link);
if (r < 0)
return r;
_LOG2D ("adding link 6lowpan parent %u", parent);
if (!klass->link_6lowpan_add (self, name, parent, out_link))
return -NME_UNSPEC;
return 0;
}
gboolean
nm_platform_link_6lowpan_get_properties (NMPlatform *self, int ifindex, int *out_parent)
{

View file

@ -1066,10 +1066,6 @@ typedef struct {
const NMPlatformLnkTun *props,
const NMPlatformLink **out_link,
int *out_fd);
gboolean (*link_6lowpan_add) (NMPlatform *self,
const char *name,
int parent,
const NMPlatformLink **out_link);
gboolean (*infiniband_partition_add) (NMPlatform *self, int parent, int p_key, const NMPlatformLink **out_link);
gboolean (*infiniband_partition_delete) (NMPlatform *self, int parent, int p_key);
@ -1465,6 +1461,15 @@ nm_platform_link_vxlan_add (NMPlatform *self,
return nm_platform_link_add (self, NM_LINK_TYPE_VXLAN, name, 0, NULL, 0, props, out_link);
}
static inline int
nm_platform_link_6lowpan_add (NMPlatform *self,
const char *name,
int parent,
const NMPlatformLink **out_link)
{
return nm_platform_link_add (self, NM_LINK_TYPE_6LOWPAN, name, parent, NULL, 0, NULL, out_link);
}
gboolean nm_platform_link_delete (NMPlatform *self, int ifindex);
gboolean nm_platform_link_set_netns (NMPlatform *self, int ifindex, int netns_fd);
@ -1666,10 +1671,6 @@ int nm_platform_link_tun_add (NMPlatform *self,
const NMPlatformLnkTun *props,
const NMPlatformLink **out_link,
int *out_fd);
int nm_platform_link_6lowpan_add (NMPlatform *self,
const char *name,
int parent,
const NMPlatformLink **out_link);
gboolean nm_platform_link_6lowpan_get_properties (NMPlatform *self,
int ifindex,
int *out_parent);