platform: implement link_ip6tnl_add via nm_platform_link_add()
This commit is contained in:
@@ -3829,6 +3829,35 @@ _nl_msg_new_link_set_linkinfo (struct nl_msg *msg,
|
|||||||
NLA_PUT_U8 (msg, IFLA_IPTUN_PMTUDISC, !!props->path_mtu_discovery);
|
NLA_PUT_U8 (msg, IFLA_IPTUN_PMTUDISC, !!props->path_mtu_discovery);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case NM_LINK_TYPE_IP6TNL: {
|
||||||
|
const NMPlatformLnkIp6Tnl *props = extra_data;
|
||||||
|
guint32 flowinfo;
|
||||||
|
|
||||||
|
nm_assert (props);
|
||||||
|
nm_assert (!props->is_gre);
|
||||||
|
|
||||||
|
if (!(data = nla_nest_start (msg, IFLA_INFO_DATA)))
|
||||||
|
goto nla_put_failure;
|
||||||
|
|
||||||
|
if (props->parent_ifindex)
|
||||||
|
NLA_PUT_U32 (msg, IFLA_IPTUN_LINK, props->parent_ifindex);
|
||||||
|
|
||||||
|
if (memcmp (&props->local, &in6addr_any, sizeof (in6addr_any)))
|
||||||
|
NLA_PUT (msg, IFLA_IPTUN_LOCAL, sizeof (props->local), &props->local);
|
||||||
|
if (memcmp (&props->remote, &in6addr_any, sizeof (in6addr_any)))
|
||||||
|
NLA_PUT (msg, IFLA_IPTUN_REMOTE, sizeof (props->remote), &props->remote);
|
||||||
|
|
||||||
|
NLA_PUT_U8 (msg, IFLA_IPTUN_TTL, props->ttl);
|
||||||
|
NLA_PUT_U8 (msg, IFLA_IPTUN_ENCAP_LIMIT, props->encap_limit);
|
||||||
|
|
||||||
|
flowinfo = props->flow_label & IP6_FLOWINFO_FLOWLABEL_MASK;
|
||||||
|
flowinfo |= (props->tclass << IP6_FLOWINFO_TCLASS_SHIFT)
|
||||||
|
& IP6_FLOWINFO_TCLASS_MASK;
|
||||||
|
NLA_PUT_U32 (msg, IFLA_IPTUN_FLOWINFO, htonl (flowinfo));
|
||||||
|
NLA_PUT_U8 (msg, IFLA_IPTUN_PROTO, props->proto);
|
||||||
|
NLA_PUT_U32 (msg, IFLA_IPTUN_FLAGS, props->flags);
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
nm_assert (!extra_data);
|
nm_assert (!extra_data);
|
||||||
break;
|
break;
|
||||||
@@ -7282,60 +7311,6 @@ link_get_dev_id (NMPlatform *platform, int ifindex)
|
|||||||
16, 0, G_MAXUINT16, 0);
|
16, 0, G_MAXUINT16, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
|
||||||
link_ip6tnl_add (NMPlatform *platform,
|
|
||||||
const char *name,
|
|
||||||
const NMPlatformLnkIp6Tnl *props,
|
|
||||||
const NMPlatformLink **out_link)
|
|
||||||
{
|
|
||||||
nm_auto_nlmsg struct nl_msg *nlmsg = NULL;
|
|
||||||
struct nlattr *info;
|
|
||||||
struct nlattr *data;
|
|
||||||
guint32 flowinfo;
|
|
||||||
|
|
||||||
g_return_val_if_fail (!props->is_gre, FALSE);
|
|
||||||
|
|
||||||
nlmsg = _nl_msg_new_link (RTM_NEWLINK,
|
|
||||||
NLM_F_CREATE | NLM_F_EXCL,
|
|
||||||
0,
|
|
||||||
name);
|
|
||||||
if (!nlmsg)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
if (!(info = nla_nest_start (nlmsg, IFLA_LINKINFO)))
|
|
||||||
goto nla_put_failure;
|
|
||||||
|
|
||||||
NLA_PUT_STRING (nlmsg, IFLA_INFO_KIND, "ip6tnl");
|
|
||||||
|
|
||||||
if (!(data = nla_nest_start (nlmsg, IFLA_INFO_DATA)))
|
|
||||||
goto nla_put_failure;
|
|
||||||
|
|
||||||
if (props->parent_ifindex)
|
|
||||||
NLA_PUT_U32 (nlmsg, IFLA_IPTUN_LINK, props->parent_ifindex);
|
|
||||||
|
|
||||||
if (memcmp (&props->local, &in6addr_any, sizeof (in6addr_any)))
|
|
||||||
NLA_PUT (nlmsg, IFLA_IPTUN_LOCAL, sizeof (props->local), &props->local);
|
|
||||||
if (memcmp (&props->remote, &in6addr_any, sizeof (in6addr_any)))
|
|
||||||
NLA_PUT (nlmsg, IFLA_IPTUN_REMOTE, sizeof (props->remote), &props->remote);
|
|
||||||
|
|
||||||
NLA_PUT_U8 (nlmsg, IFLA_IPTUN_TTL, props->ttl);
|
|
||||||
NLA_PUT_U8 (nlmsg, IFLA_IPTUN_ENCAP_LIMIT, props->encap_limit);
|
|
||||||
|
|
||||||
flowinfo = props->flow_label & IP6_FLOWINFO_FLOWLABEL_MASK;
|
|
||||||
flowinfo |= (props->tclass << IP6_FLOWINFO_TCLASS_SHIFT)
|
|
||||||
& IP6_FLOWINFO_TCLASS_MASK;
|
|
||||||
NLA_PUT_U32 (nlmsg, IFLA_IPTUN_FLOWINFO, htonl (flowinfo));
|
|
||||||
NLA_PUT_U8 (nlmsg, IFLA_IPTUN_PROTO, props->proto);
|
|
||||||
NLA_PUT_U32 (nlmsg, IFLA_IPTUN_FLAGS, props->flags);
|
|
||||||
|
|
||||||
nla_nest_end (nlmsg, data);
|
|
||||||
nla_nest_end (nlmsg, info);
|
|
||||||
|
|
||||||
return (do_add_link_with_lookup (platform, NM_LINK_TYPE_IP6TNL, name, nlmsg, out_link) >= 0);
|
|
||||||
nla_put_failure:
|
|
||||||
g_return_val_if_reached (FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
link_ip6gre_add (NMPlatform *platform,
|
link_ip6gre_add (NMPlatform *platform,
|
||||||
const char *name,
|
const char *name,
|
||||||
@@ -9219,7 +9194,6 @@ nm_linux_platform_class_init (NMLinuxPlatformClass *klass)
|
|||||||
platform_class->wpan_set_short_addr = wpan_set_short_addr;
|
platform_class->wpan_set_short_addr = wpan_set_short_addr;
|
||||||
platform_class->wpan_set_channel = wpan_set_channel;
|
platform_class->wpan_set_channel = wpan_set_channel;
|
||||||
|
|
||||||
platform_class->link_ip6tnl_add = link_ip6tnl_add;
|
|
||||||
platform_class->link_ip6gre_add = link_ip6gre_add;
|
platform_class->link_ip6gre_add = link_ip6gre_add;
|
||||||
platform_class->link_macsec_add = link_macsec_add;
|
platform_class->link_macsec_add = link_macsec_add;
|
||||||
platform_class->link_macvlan_add = link_macvlan_add;
|
platform_class->link_macvlan_add = link_macvlan_add;
|
||||||
|
@@ -1234,6 +1234,10 @@ nm_platform_link_add (NMPlatform *self,
|
|||||||
nm_utils_strbuf_append_str (&buf_p, &buf_len, ", ");
|
nm_utils_strbuf_append_str (&buf_p, &buf_len, ", ");
|
||||||
nm_platform_lnk_sit_to_string ((const NMPlatformLnkSit *) extra_data, buf_p, buf_len);
|
nm_platform_lnk_sit_to_string ((const NMPlatformLnkSit *) extra_data, buf_p, buf_len);
|
||||||
break;
|
break;
|
||||||
|
case NM_LINK_TYPE_IP6TNL:
|
||||||
|
nm_utils_strbuf_append_str (&buf_p, &buf_len, ", ");
|
||||||
|
nm_platform_lnk_ip6tnl_to_string ((const NMPlatformLnkIp6Tnl *) extra_data, buf_p, buf_len);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
nm_assert (!extra_data);
|
nm_assert (!extra_data);
|
||||||
break;
|
break;
|
||||||
@@ -2739,40 +2743,6 @@ nm_platform_link_infiniband_get_properties (NMPlatform *self,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* nm_platform_ip6tnl_add:
|
|
||||||
* @self: platform instance
|
|
||||||
* @name: name of the new interface
|
|
||||||
* @props: interface properties
|
|
||||||
* @out_link: on success, the link object
|
|
||||||
*
|
|
||||||
* Create an IPv6 tunnel.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
nm_platform_link_ip6tnl_add (NMPlatform *self,
|
|
||||||
const char *name,
|
|
||||||
const NMPlatformLnkIp6Tnl *props,
|
|
||||||
const NMPlatformLink **out_link)
|
|
||||||
{
|
|
||||||
int r;
|
|
||||||
|
|
||||||
_CHECK_SELF (self, klass, -NME_BUG);
|
|
||||||
|
|
||||||
g_return_val_if_fail (props, -NME_BUG);
|
|
||||||
g_return_val_if_fail (name, -NME_BUG);
|
|
||||||
g_return_val_if_fail (!props->is_gre, -NME_BUG);
|
|
||||||
|
|
||||||
r = _link_add_check_existing (self, name, NM_LINK_TYPE_IP6TNL, out_link);
|
|
||||||
if (r < 0)
|
|
||||||
return r;
|
|
||||||
|
|
||||||
_LOG2D ("adding link %s", nm_platform_lnk_ip6tnl_to_string (props, NULL, 0));
|
|
||||||
|
|
||||||
if (!klass->link_ip6tnl_add (self, name, props, out_link))
|
|
||||||
return -NME_UNSPEC;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* nm_platform_ip6gre_add:
|
* nm_platform_ip6gre_add:
|
||||||
* @self: platform instance
|
* @self: platform instance
|
||||||
|
@@ -1039,10 +1039,6 @@ typedef struct {
|
|||||||
gboolean egress_reset_all,
|
gboolean egress_reset_all,
|
||||||
const NMVlanQosMapping *egress_map,
|
const NMVlanQosMapping *egress_map,
|
||||||
gsize n_egress_map);
|
gsize n_egress_map);
|
||||||
gboolean (*link_ip6tnl_add) (NMPlatform *self,
|
|
||||||
const char *name,
|
|
||||||
const NMPlatformLnkIp6Tnl *props,
|
|
||||||
const NMPlatformLink **out_link);
|
|
||||||
gboolean (*link_ip6gre_add) (NMPlatform *self,
|
gboolean (*link_ip6gre_add) (NMPlatform *self,
|
||||||
const char *name,
|
const char *name,
|
||||||
const NMPlatformLnkIp6Tnl *props,
|
const NMPlatformLnkIp6Tnl *props,
|
||||||
@@ -1470,6 +1466,18 @@ nm_platform_link_6lowpan_add (NMPlatform *self,
|
|||||||
return nm_platform_link_add (self, NM_LINK_TYPE_6LOWPAN, name, parent, NULL, 0, NULL, out_link);
|
return nm_platform_link_add (self, NM_LINK_TYPE_6LOWPAN, name, parent, NULL, 0, NULL, out_link);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
nm_platform_link_ip6tnl_add (NMPlatform *self,
|
||||||
|
const char *name,
|
||||||
|
const NMPlatformLnkIp6Tnl *props,
|
||||||
|
const NMPlatformLink **out_link)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (props, -NME_BUG);
|
||||||
|
g_return_val_if_fail (!props->is_gre, -NME_BUG);
|
||||||
|
|
||||||
|
return nm_platform_link_add (self, NM_LINK_TYPE_IP6TNL, name, 0, NULL, 0, props, out_link);
|
||||||
|
}
|
||||||
|
|
||||||
gboolean nm_platform_link_delete (NMPlatform *self, int ifindex);
|
gboolean nm_platform_link_delete (NMPlatform *self, int ifindex);
|
||||||
|
|
||||||
gboolean nm_platform_link_set_netns (NMPlatform *self, int ifindex, int netns_fd);
|
gboolean nm_platform_link_set_netns (NMPlatform *self, int ifindex, int netns_fd);
|
||||||
@@ -1640,10 +1648,6 @@ 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);
|
||||||
|
|
||||||
int nm_platform_link_ip6tnl_add (NMPlatform *self,
|
|
||||||
const char *name,
|
|
||||||
const NMPlatformLnkIp6Tnl *props,
|
|
||||||
const NMPlatformLink **out_link);
|
|
||||||
int 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,
|
||||||
|
Reference in New Issue
Block a user