diff options
author | Thomas Haller <thaller@redhat.com> | 2015-10-12 15:15:21 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2015-11-01 17:28:09 +0100 |
commit | 4ab3d71d70fac095aeb407d7752e6ba9bf3666a9 (patch) | |
tree | cbd58771faad7e43cd8d3f310114c9b2a027748c /src | |
parent | db5d00d396289fe882847ee904fc57e1b6dc77fd (diff) | |
download | NetworkManager-4ab3d71d70fac095aeb407d7752e6ba9bf3666a9.tar.gz |
platform: implement gre properties as lnk data
Diffstat (limited to 'src')
-rw-r--r-- | src/devices/nm-device-gre.c | 29 | ||||
-rw-r--r-- | src/nm-types.h | 1 | ||||
-rw-r--r-- | src/platform/nm-fake-platform.c | 7 | ||||
-rw-r--r-- | src/platform/nm-linux-platform.c | 110 | ||||
-rw-r--r-- | src/platform/nm-platform.c | 84 | ||||
-rw-r--r-- | src/platform/nm-platform.h | 7 | ||||
-rw-r--r-- | src/platform/nmp-object.c | 8 | ||||
-rw-r--r-- | src/platform/nmp-object.h | 7 | ||||
-rw-r--r-- | src/platform/tests/platform.c | 29 |
9 files changed, 176 insertions, 106 deletions
diff --git a/src/devices/nm-device-gre.c b/src/devices/nm-device-gre.c index ddd913b586..9b9ffc9be1 100644 --- a/src/devices/nm-device-gre.c +++ b/src/devices/nm-device-gre.c @@ -41,7 +41,7 @@ G_DEFINE_TYPE (NMDeviceGre, nm_device_gre, NM_TYPE_DEVICE_GENERIC) #define NM_DEVICE_GRE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_GRE, NMDeviceGrePrivate)) typedef struct { - NMPlatformGreProperties props; + NMPlatformLnkGre props; } NMDeviceGrePrivate; enum { @@ -68,37 +68,38 @@ update_properties (NMDevice *device) NMDeviceGre *self = NM_DEVICE_GRE (device); NMDeviceGrePrivate *priv = NM_DEVICE_GRE_GET_PRIVATE (self); GObject *object = G_OBJECT (device); - NMPlatformGreProperties props; + const NMPlatformLnkGre *props; - if (!nm_platform_gre_get_properties (NM_PLATFORM_GET, nm_device_get_ifindex (device), &props)) { + props = nm_platform_link_get_lnk_gre (NM_PLATFORM_GET, nm_device_get_ifindex (device), NULL); + if (!props) { _LOGW (LOGD_HW, "could not read gre properties"); return; } g_object_freeze_notify (object); - if (priv->props.parent_ifindex != props.parent_ifindex) + if (priv->props.parent_ifindex != props->parent_ifindex) g_object_notify (object, NM_DEVICE_GRE_PARENT); - if (priv->props.input_flags != props.input_flags) + if (priv->props.input_flags != props->input_flags) g_object_notify (object, NM_DEVICE_GRE_INPUT_FLAGS); - if (priv->props.output_flags != props.output_flags) + if (priv->props.output_flags != props->output_flags) g_object_notify (object, NM_DEVICE_GRE_OUTPUT_FLAGS); - if (priv->props.input_key != props.input_key) + if (priv->props.input_key != props->input_key) g_object_notify (object, NM_DEVICE_GRE_INPUT_KEY); - if (priv->props.output_key != props.output_key) + if (priv->props.output_key != props->output_key) g_object_notify (object, NM_DEVICE_GRE_OUTPUT_KEY); - if (priv->props.local != props.local) + if (priv->props.local != props->local) g_object_notify (object, NM_DEVICE_GRE_LOCAL); - if (priv->props.remote != props.remote) + if (priv->props.remote != props->remote) g_object_notify (object, NM_DEVICE_GRE_REMOTE); - if (priv->props.ttl != props.ttl) + if (priv->props.ttl != props->ttl) g_object_notify (object, NM_DEVICE_GRE_TTL); - if (priv->props.tos != props.tos) + if (priv->props.tos != props->tos) g_object_notify (object, NM_DEVICE_GRE_TOS); - if (priv->props.path_mtu_discovery != props.path_mtu_discovery) + if (priv->props.path_mtu_discovery != props->path_mtu_discovery) g_object_notify (object, NM_DEVICE_GRE_PATH_MTU_DISCOVERY); - memcpy (&priv->props, &props, sizeof (NMPlatformGreProperties)); + priv->props = *props; g_object_thaw_notify (object); } diff --git a/src/nm-types.h b/src/nm-types.h index a8dea579ea..8088262572 100644 --- a/src/nm-types.h +++ b/src/nm-types.h @@ -131,6 +131,7 @@ typedef enum { NMP_OBJECT_TYPE_IP4_ROUTE, NMP_OBJECT_TYPE_IP6_ROUTE, + NMP_OBJECT_TYPE_LNK_GRE, NMP_OBJECT_TYPE_LNK_VLAN, __NMP_OBJECT_TYPE_LAST, diff --git a/src/platform/nm-fake-platform.c b/src/platform/nm-fake-platform.c index 02b2b73eed..3bdbc1cf72 100644 --- a/src/platform/nm-fake-platform.c +++ b/src/platform/nm-fake-platform.c @@ -736,12 +736,6 @@ vxlan_get_properties (NMPlatform *platform, int ifindex, NMPlatformVxlanProperti } static gboolean -gre_get_properties (NMPlatform *platform, int ifindex, NMPlatformGreProperties *props) -{ - return FALSE; -} - -static gboolean wifi_get_capabilities (NMPlatform *platform, int ifindex, NMDeviceWifiCapabilities *caps) { NMFakePlatformLink *device = link_get (platform, ifindex); @@ -1476,7 +1470,6 @@ nm_fake_platform_class_init (NMFakePlatformClass *klass) platform_class->veth_get_properties = veth_get_properties; platform_class->macvlan_get_properties = macvlan_get_properties; platform_class->vxlan_get_properties = vxlan_get_properties; - platform_class->gre_get_properties = gre_get_properties; platform_class->wifi_get_capabilities = wifi_get_capabilities; platform_class->wifi_get_bssid = wifi_get_bssid; diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c index 3e1bbe29de..9649b50903 100644 --- a/src/platform/nm-linux-platform.c +++ b/src/platform/nm-linux-platform.c @@ -882,6 +882,52 @@ errout: /*****************************************************************************/ +static NMPObject * +_parse_lnk_gre (const char *kind, struct nlattr *info_data) +{ + static struct nla_policy policy[IFLA_GRE_MAX + 1] = { + [IFLA_GRE_LINK] = { .type = NLA_U32 }, + [IFLA_GRE_IFLAGS] = { .type = NLA_U16 }, + [IFLA_GRE_OFLAGS] = { .type = NLA_U16 }, + [IFLA_GRE_IKEY] = { .type = NLA_U32 }, + [IFLA_GRE_OKEY] = { .type = NLA_U32 }, + [IFLA_GRE_LOCAL] = { .type = NLA_U32 }, + [IFLA_GRE_REMOTE] = { .type = NLA_U32 }, + [IFLA_GRE_TTL] = { .type = NLA_U8 }, + [IFLA_GRE_TOS] = { .type = NLA_U8 }, + [IFLA_GRE_PMTUDISC] = { .type = NLA_U8 }, + }; + struct nlattr *tb[IFLA_GRE_MAX + 1]; + int err; + NMPObject *obj; + NMPlatformLnkGre *props; + + if (!info_data || g_strcmp0 (kind, "gre")) + return NULL; + + err = nla_parse_nested (tb, IFLA_GRE_MAX, info_data, policy); + if (err < 0) + return NULL; + + obj = nmp_object_new (NMP_OBJECT_TYPE_LNK_GRE, NULL); + props = &obj->lnk_gre; + + props->parent_ifindex = tb[IFLA_GRE_LINK] ? nla_get_u32 (tb[IFLA_GRE_LINK]) : 0; + props->input_flags = tb[IFLA_GRE_IFLAGS] ? nla_get_u16 (tb[IFLA_GRE_IFLAGS]) : 0; + props->output_flags = tb[IFLA_GRE_OFLAGS] ? nla_get_u16 (tb[IFLA_GRE_OFLAGS]) : 0; + props->input_key = (props->input_flags & GRE_KEY) && tb[IFLA_GRE_IKEY] ? nla_get_u32 (tb[IFLA_GRE_IKEY]) : 0; + props->output_key = (props->output_flags & GRE_KEY) && tb[IFLA_GRE_OKEY] ? nla_get_u32 (tb[IFLA_GRE_OKEY]) : 0; + props->local = tb[IFLA_GRE_LOCAL] ? nla_get_u32 (tb[IFLA_GRE_LOCAL]) : 0; + props->remote = tb[IFLA_GRE_REMOTE] ? nla_get_u32 (tb[IFLA_GRE_REMOTE]) : 0; + props->tos = tb[IFLA_GRE_TOS] ? nla_get_u8 (tb[IFLA_GRE_TOS]) : 0; + props->ttl = tb[IFLA_GRE_TTL] ? nla_get_u8 (tb[IFLA_GRE_TTL]) : 0; + props->path_mtu_discovery = !tb[IFLA_GRE_PMTUDISC] || !!nla_get_u8 (tb[IFLA_GRE_PMTUDISC]); + + return obj; +} + +/*****************************************************************************/ + /* Copied and heavily modified from libnl3's vlan_parse() */ static NMPObject * _parse_lnk_vlan (const char *kind, struct nlattr *info_data) @@ -1054,6 +1100,9 @@ _new_from_nl_link (NMPlatform *platform, const NMPCache *cache, struct nlmsghdr obj->link.mtu = nla_get_u32 (tb[IFLA_MTU]); switch (obj->link.type) { + case NM_LINK_TYPE_GRE: + lnk_data = _parse_lnk_gre (nl_info_kind, nl_info_data); + break; case NM_LINK_TYPE_VLAN: lnk_data = _parse_lnk_vlan (nl_info_kind, nl_info_data); break; @@ -3037,6 +3086,10 @@ link_get_lnk (NMPlatform *platform, int ifindex, NMLinkType link_type, const NMP return NULL; switch (link_type) { + case NM_LINK_TYPE_GRE: + if (NMP_OBJECT_GET_TYPE (obj->_link.netlink.lnk) == NMP_OBJECT_TYPE_LNK_GRE) + return &obj->_link.netlink.lnk->lnk_gre; + break; case NM_LINK_TYPE_VLAN: if (NMP_OBJECT_GET_TYPE (obj->_link.netlink.lnk) == NMP_OBJECT_TYPE_LNK_VLAN) return &obj->_link.netlink.lnk->lnk_vlan; @@ -4063,62 +4116,6 @@ vxlan_get_properties (NMPlatform *platform, int ifindex, NMPlatformVxlanProperti /******************************************************************/ -static const struct nla_policy gre_info_policy[IFLA_GRE_MAX + 1] = { - [IFLA_GRE_LINK] = { .type = NLA_U32 }, - [IFLA_GRE_IFLAGS] = { .type = NLA_U16 }, - [IFLA_GRE_OFLAGS] = { .type = NLA_U16 }, - [IFLA_GRE_IKEY] = { .type = NLA_U32 }, - [IFLA_GRE_OKEY] = { .type = NLA_U32 }, - [IFLA_GRE_LOCAL] = { .type = NLA_U32 }, - [IFLA_GRE_REMOTE] = { .type = NLA_U32 }, - [IFLA_GRE_TTL] = { .type = NLA_U8 }, - [IFLA_GRE_TOS] = { .type = NLA_U8 }, - [IFLA_GRE_PMTUDISC] = { .type = NLA_U8 }, -}; - -static int -gre_info_data_parser (struct nlattr *info_data, gpointer parser_data) -{ - NMPlatformGreProperties *props = parser_data; - struct nlattr *tb[IFLA_GRE_MAX + 1]; - int err; - - err = nla_parse_nested (tb, IFLA_GRE_MAX, info_data, - (struct nla_policy *) gre_info_policy); - if (err < 0) - return err; - - props->parent_ifindex = tb[IFLA_GRE_LINK] ? nla_get_u32 (tb[IFLA_GRE_LINK]) : 0; - props->input_flags = nla_get_u16 (tb[IFLA_GRE_IFLAGS]); - props->output_flags = nla_get_u16 (tb[IFLA_GRE_OFLAGS]); - props->input_key = (props->input_flags & GRE_KEY) ? nla_get_u32 (tb[IFLA_GRE_IKEY]) : 0; - props->output_key = (props->output_flags & GRE_KEY) ? nla_get_u32 (tb[IFLA_GRE_OKEY]) : 0; - props->local = nla_get_u32 (tb[IFLA_GRE_LOCAL]); - props->remote = nla_get_u32 (tb[IFLA_GRE_REMOTE]); - props->tos = nla_get_u8 (tb[IFLA_GRE_TOS]); - props->ttl = nla_get_u8 (tb[IFLA_GRE_TTL]); - props->path_mtu_discovery = !!nla_get_u8 (tb[IFLA_GRE_PMTUDISC]); - - return 0; -} - -static gboolean -gre_get_properties (NMPlatform *platform, int ifindex, NMPlatformGreProperties *props) -{ - NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform); - int err; - - err = _nl_link_parse_info_data (priv->nlh, ifindex, - gre_info_data_parser, props); - if (err != 0) { - _LOGW ("(%s) could not read gre properties: %s", - nm_platform_link_get_name (platform, ifindex), nl_geterror (err)); - } - return (err == 0); -} - -/******************************************************************/ - static WifiData * wifi_get_wifi_data (NMPlatform *platform, int ifindex) { @@ -5350,7 +5347,6 @@ nm_linux_platform_class_init (NMLinuxPlatformClass *klass) platform_class->veth_get_properties = veth_get_properties; platform_class->macvlan_get_properties = macvlan_get_properties; platform_class->vxlan_get_properties = vxlan_get_properties; - platform_class->gre_get_properties = gre_get_properties; platform_class->wifi_get_capabilities = wifi_get_capabilities; platform_class->wifi_get_bssid = wifi_get_bssid; diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c index 6f069a6a4b..c3f55b4ab3 100644 --- a/src/platform/nm-platform.c +++ b/src/platform/nm-platform.c @@ -28,7 +28,9 @@ #include <string.h> #include <netlink/route/addr.h> #include <netlink/route/rtnl.h> +#include <linux/ip.h> #include <linux/if_tun.h> +#include <linux/if_tunnel.h> #include "NetworkManagerUtils.h" #include "nm-utils.h" @@ -68,6 +70,8 @@ G_STATIC_ASSERT (G_STRUCT_OFFSET (NMPlatformIPRoute, network_ptr) == G_STRUCT_OF } \ } G_STMT_END +/*****************************************************************************/ + #define NM_PLATFORM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_PLATFORM, NMPlatformPrivate)) G_DEFINE_TYPE (NMPlatform, nm_platform, G_TYPE_OBJECT) @@ -1396,6 +1400,12 @@ nm_platform_link_get_lnk (NMPlatform *self, int ifindex, NMLinkType link_type, c return klass->link_get_lnk (self, ifindex, link_type, out_link); } +const NMPlatformLnkGre * +nm_platform_link_get_lnk_gre (NMPlatform *self, int ifindex, const NMPlatformLink **out_link) +{ + return nm_platform_link_get_lnk (self, ifindex, NM_LINK_TYPE_GRE, out_link); +} + const NMPlatformLnkVlan * nm_platform_link_get_lnk_vlan (NMPlatform *self, int ifindex, const NMPlatformLink **out_link) { @@ -1716,17 +1726,6 @@ nm_platform_vxlan_get_properties (NMPlatform *self, int ifindex, NMPlatformVxlan } gboolean -nm_platform_gre_get_properties (NMPlatform *self, int ifindex, NMPlatformGreProperties *props) -{ - _CHECK_SELF (self, klass, FALSE); - - g_return_val_if_fail (ifindex > 0, FALSE); - g_return_val_if_fail (props != NULL, FALSE); - - return klass->gre_get_properties (self, ifindex, props); -} - -gboolean nm_platform_wifi_get_capabilities (NMPlatform *self, int ifindex, NMDeviceWifiCapabilities *caps) { _CHECK_SELF (self, klass, FALSE); @@ -2561,6 +2560,52 @@ nm_platform_link_to_string (const NMPlatformLink *link, char *buf, gsize len) } const char * +nm_platform_lnk_gre_to_string (const NMPlatformLnkGre *lnk, char *buf, gsize len) +{ + char str_local[30]; + char str_local1[NM_UTILS_INET_ADDRSTRLEN]; + char str_remote[30]; + char str_remote1[NM_UTILS_INET_ADDRSTRLEN]; + char str_ttl[30]; + char str_tos[30]; + char str_parent_ifindex[30]; + char str_input_flags[30]; + char str_output_flags[30]; + char str_input_key[30]; + char str_input_key1[NM_UTILS_INET_ADDRSTRLEN]; + char str_output_key[30]; + char str_output_key1[NM_UTILS_INET_ADDRSTRLEN]; + + if (!_to_string_buffer_init (lnk, &buf, &len)) + return buf; + + g_snprintf (buf, len, + "gre" + "%s" /* remote */ + "%s" /* local */ + "%s" /* parent_ifindex */ + "%s" /* ttl */ + "%s" /* tos */ + "%s" /* path_mtu_discovery */ + "%s" /* iflags */ + "%s" /* oflags */ + "%s" /* ikey */ + "%s" /* okey */ + "", + lnk->remote ? nm_sprintf_buf (str_remote, " remote %s", nm_utils_inet4_ntop (lnk->remote, str_remote1)) : "", + lnk->local ? nm_sprintf_buf (str_local, " local %s", nm_utils_inet4_ntop (lnk->local, str_local1)) : "", + lnk->parent_ifindex ? nm_sprintf_buf (str_parent_ifindex, " dev %d", lnk->parent_ifindex) : "", + lnk->ttl ? nm_sprintf_buf (str_ttl, " ttl %u", lnk->ttl) : " ttl inherit", + lnk->tos ? (lnk->tos == 1 ? " tos inherit" : nm_sprintf_buf (str_tos, " tos 0x%x", lnk->tos)) : "", + lnk->path_mtu_discovery ? "" : " nopmtudisc", + lnk->input_flags ? nm_sprintf_buf (str_input_flags, " iflags 0x%x", lnk->input_flags) : "", + lnk->output_flags ? nm_sprintf_buf (str_output_flags, " oflags 0x%x", lnk->output_flags) : "", + NM_FLAGS_HAS (lnk->input_flags, GRE_KEY) || lnk->input_key ? nm_sprintf_buf (str_input_key, " ikey %s", nm_utils_inet4_ntop (lnk->input_key, str_input_key1)) : "", + NM_FLAGS_HAS (lnk->output_flags, GRE_KEY) || lnk->output_key ? nm_sprintf_buf (str_output_key, " okey %s", nm_utils_inet4_ntop (lnk->output_key, str_output_key1)) : ""); + return buf; +} + +const char * nm_platform_lnk_vlan_to_string (const NMPlatformLnkVlan *lnk, char *buf, gsize len) { if (!_to_string_buffer_init (lnk, &buf, &len)) @@ -2935,6 +2980,23 @@ nm_platform_link_cmp (const NMPlatformLink *a, const NMPlatformLink *b) } int +nm_platform_lnk_gre_cmp (const NMPlatformLnkGre *a, const NMPlatformLnkGre *b) +{ + _CMP_SELF (a, b); + _CMP_FIELD (a, b, parent_ifindex); + _CMP_FIELD (a, b, input_flags); + _CMP_FIELD (a, b, output_flags); + _CMP_FIELD (a, b, input_key); + _CMP_FIELD (a, b, output_key); + _CMP_FIELD (a, b, local); + _CMP_FIELD (a, b, remote); + _CMP_FIELD (a, b, ttl); + _CMP_FIELD (a, b, tos); + _CMP_FIELD_BOOL (a, b, path_mtu_discovery); + return 0; +} + +int nm_platform_lnk_vlan_cmp (const NMPlatformLnkVlan *a, const NMPlatformLnkVlan *b) { _CMP_SELF (a, b); diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h index c401d11176..b171035bab 100644 --- a/src/platform/nm-platform.h +++ b/src/platform/nm-platform.h @@ -396,7 +396,7 @@ typedef struct { guint8 ttl; guint8 tos; gboolean path_mtu_discovery; -} NMPlatformGreProperties; +} NMPlatformLnkGre; /******************************************************************/ @@ -508,7 +508,6 @@ typedef struct { gboolean (*veth_get_properties) (NMPlatform *, int ifindex, NMPlatformVethProperties *properties); gboolean (*macvlan_get_properties) (NMPlatform *, int ifindex, NMPlatformMacvlanProperties *props); gboolean (*vxlan_get_properties) (NMPlatform *, int ifindex, NMPlatformVxlanProperties *props); - gboolean (*gre_get_properties) (NMPlatform *, int ifindex, NMPlatformGreProperties *props); gboolean (*wifi_get_capabilities) (NMPlatform *, int ifindex, NMDeviceWifiCapabilities *caps); gboolean (*wifi_get_bssid) (NMPlatform *, int ifindex, guint8 *bssid); @@ -692,6 +691,7 @@ gboolean nm_platform_slave_set_option (NMPlatform *self, int ifindex, const char char *nm_platform_slave_get_option (NMPlatform *self, int ifindex, const char *option); gconstpointer nm_platform_link_get_lnk (NMPlatform *self, int ifindex, NMLinkType link_type, const NMPlatformLink **out_link); +const NMPlatformLnkGre *nm_platform_link_get_lnk_gre (NMPlatform *self, int ifindex, const NMPlatformLink **out_link); const NMPlatformLnkVlan *nm_platform_link_get_lnk_vlan (NMPlatform *self, int ifindex, const NMPlatformLink **out_link); NMPlatformError nm_platform_vlan_add (NMPlatform *self, const char *name, int parent, int vlanid, guint32 vlanflags, NMPlatformLink *out_link); @@ -705,7 +705,6 @@ gboolean nm_platform_veth_get_properties (NMPlatform *self, int ifindex, gboolean nm_platform_tun_get_properties (NMPlatform *self, int ifindex, NMPlatformTunProperties *properties); gboolean nm_platform_macvlan_get_properties (NMPlatform *self, int ifindex, NMPlatformMacvlanProperties *props); gboolean nm_platform_vxlan_get_properties (NMPlatform *self, int ifindex, NMPlatformVxlanProperties *props); -gboolean nm_platform_gre_get_properties (NMPlatform *self, int ifindex, NMPlatformGreProperties *props); gboolean nm_platform_tun_get_properties_ifname (NMPlatform *platform, const char *ifname, NMPlatformTunProperties *props); @@ -771,6 +770,7 @@ gboolean nm_platform_ip6_route_delete (NMPlatform *self, int ifindex, struct in6 extern char _nm_platform_to_string_buffer[1024]; const char *nm_platform_link_to_string (const NMPlatformLink *link, char *buf, gsize len); +const char *nm_platform_lnk_gre_to_string (const NMPlatformLnkGre *lnk, char *buf, gsize len); const char *nm_platform_lnk_vlan_to_string (const NMPlatformLnkVlan *lnk, char *buf, gsize len); const char *nm_platform_ip4_address_to_string (const NMPlatformIP4Address *address, char *buf, gsize len); const char *nm_platform_ip6_address_to_string (const NMPlatformIP6Address *address, char *buf, gsize len); @@ -778,6 +778,7 @@ const char *nm_platform_ip4_route_to_string (const NMPlatformIP4Route *route, ch const char *nm_platform_ip6_route_to_string (const NMPlatformIP6Route *route, char *buf, gsize len); int nm_platform_link_cmp (const NMPlatformLink *a, const NMPlatformLink *b); +int nm_platform_lnk_gre_cmp (const NMPlatformLnkGre *a, const NMPlatformLnkGre *b); int nm_platform_lnk_vlan_cmp (const NMPlatformLnkVlan *a, const NMPlatformLnkVlan *b); int nm_platform_ip4_address_cmp (const NMPlatformIP4Address *a, const NMPlatformIP4Address *b); int nm_platform_ip6_address_cmp (const NMPlatformIP6Address *a, const NMPlatformIP6Address *b); diff --git a/src/platform/nmp-object.c b/src/platform/nmp-object.c index 888afc058f..79688c162e 100644 --- a/src/platform/nmp-object.c +++ b/src/platform/nmp-object.c @@ -1897,6 +1897,14 @@ const NMPClass _nmp_classes[NMP_OBJECT_TYPE_MAX] = { .cmd_plobj_to_string = (const char *(*) (const NMPlatformObject *obj, char *buf, gsize len)) nm_platform_ip6_route_to_string, .cmd_plobj_cmp = (int (*) (const NMPlatformObject *obj1, const NMPlatformObject *obj2)) nm_platform_ip6_route_cmp, }, + [NMP_OBJECT_TYPE_LNK_GRE - 1] = { + .obj_type = NMP_OBJECT_TYPE_LNK_GRE, + .sizeof_data = sizeof (NMPObjectLnkGre), + .sizeof_public = sizeof (NMPlatformLnkGre), + .obj_type_name = "gre", + .cmd_plobj_to_string = (const char *(*) (const NMPlatformObject *obj, char *buf, gsize len)) nm_platform_lnk_gre_to_string, + .cmd_plobj_cmp = (int (*) (const NMPlatformObject *obj1, const NMPlatformObject *obj2)) nm_platform_lnk_gre_cmp, + }, [NMP_OBJECT_TYPE_LNK_VLAN - 1] = { .obj_type = NMP_OBJECT_TYPE_LNK_VLAN, .sizeof_data = sizeof (NMPObjectLnkVlan), diff --git a/src/platform/nmp-object.h b/src/platform/nmp-object.h index 03cface7af..2cc81d1920 100644 --- a/src/platform/nmp-object.h +++ b/src/platform/nmp-object.h @@ -158,6 +158,10 @@ typedef struct { } NMPObjectLink; typedef struct { + NMPlatformLnkGre _public; +} NMPObjectLnkGre; + +typedef struct { NMPlatformLnkVlan _public; } NMPObjectLnkVlan; @@ -187,6 +191,9 @@ struct _NMPObject { NMPlatformLink link; NMPObjectLink _link; + NMPlatformLnkGre lnk_gre; + NMPObjectLnkGre _lnk_gre; + NMPlatformLnkVlan lnk_vlan; NMPObjectLnkVlan _lnk_vlan; diff --git a/src/platform/tests/platform.c b/src/platform/tests/platform.c index 43d1b1579f..5a1f5f56a6 100644 --- a/src/platform/tests/platform.c +++ b/src/platform/tests/platform.c @@ -465,31 +465,32 @@ static gboolean do_gre_get_properties (char **argv) { int ifindex = parse_ifindex (*argv++); - NMPlatformGreProperties props; + const NMPlatformLnkGre *props; char addrstr[INET_ADDRSTRLEN]; - if (!nm_platform_gre_get_properties (NM_PLATFORM_GET, ifindex, &props)) + props = nm_platform_link_get_lnk_gre (NM_PLATFORM_GET, ifindex, NULL); + if (!props) return FALSE; - printf ("parent-ifindex: %u\n", props.parent_ifindex); - printf ("input-flags: %u\n", props.input_flags); - printf ("output-flags: %u\n", props.input_flags); - printf ("input-key: %u\n", props.input_key); - printf ("output-key: %u\n", props.output_key); - if (props.local) - inet_ntop (AF_INET, &props.local, addrstr, sizeof (addrstr)); + printf ("parent-ifindex: %u\n", props->parent_ifindex); + printf ("input-flags: %u\n", props->input_flags); + printf ("output-flags: %u\n", props->input_flags); + printf ("input-key: %u\n", props->input_key); + printf ("output-key: %u\n", props->output_key); + if (props->local) + inet_ntop (AF_INET, &props->local, addrstr, sizeof (addrstr)); else strcpy (addrstr, "-"); printf ("local: %s\n", addrstr); - if (props.remote) - inet_ntop (AF_INET, &props.remote, addrstr, sizeof (addrstr)); + if (props->remote) + inet_ntop (AF_INET, &props->remote, addrstr, sizeof (addrstr)); else strcpy (addrstr, "-"); printf ("remote: %s\n", addrstr); - printf ("ttl: %u\n", props.ttl); - printf ("tos: %u\n", props.tos); + printf ("ttl: %u\n", props->ttl); + printf ("tos: %u\n", props->tos); printf ("path-mtu-discovery: "); - print_boolean (props.path_mtu_discovery); + print_boolean (props->path_mtu_discovery); return TRUE; } |