Commit d9e0a7cb authored by Dan Winship's avatar Dan Winship

platform, devices: add support for gre and gretap devices

parent 7f0f04d1
......@@ -58,6 +58,7 @@
#define NM_DBUS_INTERFACE_DEVICE_TUN NM_DBUS_INTERFACE_DEVICE ".Tun"
#define NM_DBUS_INTERFACE_DEVICE_MACVLAN NM_DBUS_INTERFACE_DEVICE ".Macvlan"
#define NM_DBUS_INTERFACE_DEVICE_VXLAN NM_DBUS_INTERFACE_DEVICE ".Vxlan"
#define NM_DBUS_INTERFACE_DEVICE_GRE NM_DBUS_INTERFACE_DEVICE ".Gre"
#define NM_DBUS_IFACE_SETTINGS "org.freedesktop.NetworkManager.Settings"
......
......@@ -20,6 +20,7 @@ EXTRA_DIST = \
nm-device-tun.xml \
nm-device-macvlan.xml \
nm-device-vxlan.xml \
nm-device-gre.xml \
nm-device.xml \
nm-ip4-config.xml \
nm-ip6-config.xml \
......
<?xml version="1.0" encoding="UTF-8" ?>
<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
<interface name="org.freedesktop.NetworkManager.Device.Gre">
<property name="Parent" type="o" access="read">
<tp:docstring>
The object path of the parent device.
</tp:docstring>
</property>
<property name="InputFlags" type="q" access="read">
<tp:docstring>
The expected set of GRE flags for incoming packets. (The
values are specified by the GRE specification. On Linux, they
are defined in &lt;linux/if_tunnel.h&gt;. Eg, GRE_KEY for the
'Key Present' bit.)
</tp:docstring>
</property>
<property name="OutputFlags" type="q" access="read">
<tp:docstring>
The set of GRE flags to use for outgoing packets. (The
values are specified by the GRE specification. On Linux, they
are defined in &lt;linux/if_tunnel.h&gt;. Eg, GRE_KEY for the
'Key Present' bit.)
</tp:docstring>
</property>
<property name="InputKey" type="u" access="read">
<tp:docstring>
Expected input key (if the "Key Present" bit is set in the input flags).
</tp:docstring>
</property>
<property name="OutputKey" type="u" access="read">
<tp:docstring>
Output key (if the "Key Present" bit is set in the output flags).
</tp:docstring>
</property>
<property name="Local" type="s" access="read">
<tp:docstring>
The local end of the tunnel.
</tp:docstring>
</property>
<property name="Remote" type="s" access="read">
<tp:docstring>
The remote end of the tunnel.
</tp:docstring>
</property>
<property name="Ttl" type="y" access="read">
<tp:docstring>
The value to use in the IP TTL field for tunnel packets.
</tp:docstring>
</property>
<property name="Tos" type="y" access="read">
<tp:docstring>
The value to use in the IP ToS field for tunnel packets.
</tp:docstring>
</property>
<property name="PathMtuDiscovery" type="b" access="read">
<tp:docstring>
Whether path MTU discovery is performed.
</tp:docstring>
</property>
<signal name="PropertiesChanged">
<arg name="properties" type="a{sv}" tp:type="String_Variant_Map">
<tp:docstring>
A dictionary mapping property names to variant boxed values
</tp:docstring>
</arg>
</signal>
</interface>
</node>
......@@ -76,6 +76,8 @@ nm_sources = \
devices/nm-device-factory.h \
devices/nm-device-generic.c \
devices/nm-device-generic.h \
devices/nm-device-gre.c \
devices/nm-device-gre.h \
devices/nm-device-infiniband.c \
devices/nm-device-infiniband.h \
devices/nm-device-macvlan.c \
......@@ -316,6 +318,7 @@ glue_sources = \
nm-device-ethernet-glue.h \
nm-device-generic-glue.h \
nm-device-glue.h \
nm-device-gre-glue.h \
nm-device-infiniband-glue.h \
nm-device-macvlan-glue.h \
nm-device-modem-glue.h \
......
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager -- Network link manager
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright 2013 Red Hat, Inc.
*/
#include "config.h"
#include <string.h>
#include "nm-device-gre.h"
#include "nm-dbus-manager.h"
#include "nm-logging.h"
#include "nm-manager.h"
#include "nm-platform.h"
#include "nm-device-gre-glue.h"
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 {
NMDevice *parent;
NMPlatformGreProperties props;
} NMDeviceGrePrivate;
enum {
PROP_0,
PROP_PARENT,
PROP_INPUT_FLAGS,
PROP_OUTPUT_FLAGS,
PROP_INPUT_KEY,
PROP_OUTPUT_KEY,
PROP_LOCAL,
PROP_REMOTE,
PROP_TTL,
PROP_TOS,
PROP_PATH_MTU_DISCOVERY,
LAST_PROP
};
/**************************************************************/
static void
link_changed (NMDevice *device)
{
NMDeviceGrePrivate *priv = NM_DEVICE_GRE_GET_PRIVATE (device);
GObject *object = G_OBJECT (device);
NMPlatformGreProperties props;
if (!nm_platform_gre_get_properties (nm_device_get_ifindex (device), &props)) {
nm_log_warn (LOGD_HW, "(%s): could not read gre properties",
nm_device_get_iface (device));
return;
}
g_object_freeze_notify (object);
if (priv->props.parent_ifindex != props.parent_ifindex) {
g_object_notify (object, NM_DEVICE_GRE_PARENT);
if (priv->parent)
g_object_remove_weak_pointer (G_OBJECT (priv->parent), (gpointer *) &priv->parent);
priv->parent = nm_manager_get_device_by_ifindex (nm_manager_get (), props.parent_ifindex);
if (priv->parent)
g_object_add_weak_pointer (G_OBJECT (priv->parent), (gpointer *) &priv->parent);
}
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)
g_object_notify (object, NM_DEVICE_GRE_OUTPUT_FLAGS);
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)
g_object_notify (object, NM_DEVICE_GRE_OUTPUT_KEY);
if (priv->props.local != props.local)
g_object_notify (object, NM_DEVICE_GRE_LOCAL);
if (priv->props.remote != props.remote)
g_object_notify (object, NM_DEVICE_GRE_REMOTE);
if (priv->props.ttl != props.ttl)
g_object_notify (object, NM_DEVICE_GRE_TTL);
if (priv->props.tos != props.tos)
g_object_notify (object, NM_DEVICE_GRE_TOS);
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));
g_object_thaw_notify (object);
}
/**************************************************************/
NMDevice *
nm_device_gre_new (const char *udi,
const char *iface,
const char *driver)
{
g_return_val_if_fail (udi != NULL, NULL);
return (NMDevice *) g_object_new (NM_TYPE_DEVICE_GRE,
NM_DEVICE_UDI, udi,
NM_DEVICE_IFACE, iface,
NM_DEVICE_DRIVER, driver,
NM_DEVICE_TYPE_DESC, "Gre",
NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_GENERIC,
NULL);
}
static void
nm_device_gre_init (NMDeviceGre *self)
{
}
static void
constructed (GObject *object)
{
link_changed (NM_DEVICE (object));
G_OBJECT_CLASS (nm_device_gre_parent_class)->constructed (object);
}
static void
get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
NMDeviceGrePrivate *priv = NM_DEVICE_GRE_GET_PRIVATE (object);
char buf[INET_ADDRSTRLEN];
switch (prop_id) {
case PROP_PARENT:
g_value_set_boxed (value, priv->parent ? nm_device_get_path (priv->parent) : "/");
break;
case PROP_INPUT_FLAGS:
g_value_set_uint (value, priv->props.input_flags);
break;
case PROP_OUTPUT_FLAGS:
g_value_set_uint (value, priv->props.output_flags);
break;
case PROP_INPUT_KEY:
g_value_set_uint (value, priv->props.input_key);
break;
case PROP_OUTPUT_KEY:
g_value_set_uint (value, priv->props.output_key);
break;
case PROP_LOCAL:
g_value_set_string (value, inet_ntop (AF_INET, &priv->props.local, buf, sizeof (buf)));
break;
case PROP_REMOTE:
g_value_set_string (value, inet_ntop (AF_INET, &priv->props.remote, buf, sizeof (buf)));
break;
case PROP_TTL:
g_value_set_uchar (value, priv->props.ttl);
break;
case PROP_TOS:
g_value_set_uchar (value, priv->props.tos);
break;
case PROP_PATH_MTU_DISCOVERY:
g_value_set_boolean (value, priv->props.path_mtu_discovery);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
nm_device_gre_class_init (NMDeviceGreClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
NMDeviceClass *device_class = NM_DEVICE_CLASS (klass);
g_type_class_add_private (klass, sizeof (NMDeviceGrePrivate));
object_class->constructed = constructed;
object_class->get_property = get_property;
device_class->link_changed = link_changed;
/* properties */
g_object_class_install_property
(object_class, PROP_PARENT,
g_param_spec_boxed (NM_DEVICE_GRE_PARENT,
"Parent",
"Parent device",
DBUS_TYPE_G_OBJECT_PATH,
G_PARAM_READABLE));
g_object_class_install_property
(object_class, PROP_INPUT_FLAGS,
g_param_spec_uint (NM_DEVICE_GRE_INPUT_FLAGS,
"Input flags",
"Input flags",
0, G_MAXUINT16, 0,
G_PARAM_READABLE));
g_object_class_install_property
(object_class, PROP_OUTPUT_FLAGS,
g_param_spec_uint (NM_DEVICE_GRE_OUTPUT_FLAGS,
"Output flags",
"Output flags",
0, G_MAXUINT16, 0,
G_PARAM_READABLE));
g_object_class_install_property
(object_class, PROP_INPUT_KEY,
g_param_spec_uint (NM_DEVICE_GRE_INPUT_KEY,
"Input key",
"Input key",
0, G_MAXUINT32, 0,
G_PARAM_READABLE));
g_object_class_install_property
(object_class, PROP_OUTPUT_KEY,
g_param_spec_uint (NM_DEVICE_GRE_OUTPUT_KEY,
"Output key",
"Output key",
0, G_MAXUINT32, 0,
G_PARAM_READABLE));
g_object_class_install_property
(object_class, PROP_LOCAL,
g_param_spec_string (NM_DEVICE_GRE_LOCAL,
"Local",
"Local",
NULL,
G_PARAM_READABLE));
g_object_class_install_property
(object_class, PROP_REMOTE,
g_param_spec_string (NM_DEVICE_GRE_REMOTE,
"Remote",
"Remote",
NULL,
G_PARAM_READABLE));
g_object_class_install_property
(object_class, PROP_TTL,
g_param_spec_uchar (NM_DEVICE_GRE_TTL,
"TTL",
"TTL",
0, 255, 0,
G_PARAM_READABLE));
g_object_class_install_property
(object_class, PROP_TOS,
g_param_spec_uchar (NM_DEVICE_GRE_TOS,
"ToS",
"ToS",
0, 255, 0,
G_PARAM_READABLE));
g_object_class_install_property
(object_class, PROP_PATH_MTU_DISCOVERY,
g_param_spec_boolean (NM_DEVICE_GRE_PATH_MTU_DISCOVERY,
"Path MTU Discovery",
"Path MTU Discovery",
FALSE,
G_PARAM_READABLE));
nm_dbus_manager_register_exported_type (nm_dbus_manager_get (),
G_TYPE_FROM_CLASS (klass),
&dbus_glib_nm_device_gre_object_info);
}
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager -- Network link manager
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright 2013 Red Hat, Inc.
*/
#ifndef NM_DEVICE_GRE_H
#define NM_DEVICE_GRE_H
#include <glib-object.h>
#include "nm-device-generic.h"
G_BEGIN_DECLS
#define NM_TYPE_DEVICE_GRE (nm_device_gre_get_type ())
#define NM_DEVICE_GRE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_GRE, NMDeviceGre))
#define NM_DEVICE_GRE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DEVICE_GRE, NMDeviceGreClass))
#define NM_IS_DEVICE_GRE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DEVICE_GRE))
#define NM_IS_DEVICE_GRE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_GRE))
#define NM_DEVICE_GRE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_GRE, NMDeviceGreClass))
#define NM_DEVICE_GRE_PARENT "parent"
#define NM_DEVICE_GRE_INPUT_FLAGS "input-flags"
#define NM_DEVICE_GRE_OUTPUT_FLAGS "output-flags"
#define NM_DEVICE_GRE_INPUT_KEY "input-key"
#define NM_DEVICE_GRE_OUTPUT_KEY "output-key"
#define NM_DEVICE_GRE_LOCAL "local"
#define NM_DEVICE_GRE_REMOTE "remote"
#define NM_DEVICE_GRE_TTL "ttl"
#define NM_DEVICE_GRE_TOS "tos"
#define NM_DEVICE_GRE_PATH_MTU_DISCOVERY "path-mtu-discovery"
typedef struct {
NMDeviceGeneric parent;
} NMDeviceGre;
typedef struct {
NMDeviceGenericClass parent;
} NMDeviceGreClass;
GType nm_device_gre_get_type (void);
NMDevice *nm_device_gre_new (const char *udi,
const char *iface,
const char *driver);
G_END_DECLS
#endif /* NM_DEVICE_GRE_H */
......@@ -56,6 +56,7 @@
#include "nm-device-tun.h"
#include "nm-device-macvlan.h"
#include "nm-device-vxlan.h"
#include "nm-device-gre.h"
#include "nm-system.h"
#include "nm-setting-bluetooth.h"
#include "nm-setting-connection.h"
......@@ -2306,6 +2307,10 @@ udev_device_added_cb (NMUdevManager *udev_mgr,
case NM_LINK_TYPE_VXLAN:
device = nm_device_vxlan_new (sysfs_path, iface, driver);
break;
case NM_LINK_TYPE_GRE:
case NM_LINK_TYPE_GRETAP:
device = nm_device_gre_new (sysfs_path, iface, driver);
break;
default:
device = nm_device_generic_new (sysfs_path, iface, driver);
......
......@@ -582,6 +582,12 @@ vxlan_get_properties (NMPlatform *platform, int ifindex, NMPlatformVxlanProperti
return FALSE;
}
static gboolean
gre_get_properties (NMPlatform *platform, int ifindex, NMPlatformGreProperties *props)
{
return FALSE;
}
/******************************************************************/
static GArray *
......@@ -1043,6 +1049,7 @@ nm_fake_platform_class_init (NMFakePlatformClass *klass)
platform_class->tun_get_properties = tun_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->ip4_address_get_all = ip4_address_get_all;
platform_class->ip6_address_get_all = ip6_address_get_all;
......
......@@ -25,9 +25,11 @@
#include <fcntl.h>
#include <netinet/icmp6.h>
#include <netinet/in.h>
#include <linux/ip.h>
#include <linux/if_arp.h>
#include <linux/if_link.h>
#include <linux/if_tun.h>
#include <linux/if_tunnel.h>
#include <sys/ioctl.h>
#include <linux/sockios.h>
#include <linux/ethtool.h>
......@@ -353,6 +355,10 @@ type_to_string (NMLinkType type)
switch (type) {
case NM_LINK_TYPE_DUMMY:
return "dummy";
case NM_LINK_TYPE_GRE:
return "gre";
case NM_LINK_TYPE_GRETAP:
return "gretap";
case NM_LINK_TYPE_IFB:
return "ifb";
case NM_LINK_TYPE_MACVLAN:
......@@ -420,6 +426,10 @@ link_extract_type (struct rtnl_link *rtnllink, const char **out_name)
return_type (NM_LINK_TYPE_INFINIBAND, "infiniband");
else if (!strcmp (type, "dummy"))
return_type (NM_LINK_TYPE_DUMMY, "dummy");
else if (!strcmp (type, "gre"))
return_type (NM_LINK_TYPE_GRE, "gre");
else if (!strcmp (type, "gretap"))
return_type (NM_LINK_TYPE_GRETAP, "gretap");
else if (!strcmp (type, "ifb"))
return_type (NM_LINK_TYPE_IFB, "ifb");
else if (!strcmp (type, "macvlan"))
......@@ -1703,6 +1713,56 @@ vxlan_get_properties (NMPlatform *platform, int ifindex, NMPlatformVxlanProperti
return (err == 0);
}
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 = nm_rtnl_link_parse_info_data (priv->nlh, ifindex,
gre_info_data_parser, props);
return (err == 0);
}
/******************************************************************/
static int
......@@ -2189,6 +2249,7 @@ nm_linux_platform_class_init (NMLinuxPlatformClass *klass)
platform_class->tun_get_properties = tun_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->ip4_address_get_all = ip4_address_get_all;
platform_class->ip6_address_get_all = ip6_address_get_all;
......
......@@ -945,6 +945,17 @@ nm_platform_vxlan_get_properties (int ifindex, NMPlatformVxlanProperties *props)
return klass->vxlan_get_properties (platform, ifindex, props);
}
gboolean
nm_platform_gre_get_properties (int ifindex, NMPlatformGreProperties *props)
{
reset_error ();
g_return_val_if_fail (ifindex > 0, FALSE);
g_return_val_if_fail (props != NULL, FALSE);
return klass->gre_get_properties (platform, ifindex, props);
}
/******************************************************************/
GArray *
......
......@@ -57,6 +57,8 @@ typedef enum {
/* Virtual types */
NM_LINK_TYPE_DUMMY,
NM_LINK_TYPE_GRE,
NM_LINK_TYPE_GRETAP,
NM_LINK_TYPE_IFB,
NM_LINK_TYPE_LOOPBACK,
NM_LINK_TYPE_MACVLAN,
......@@ -153,6 +155,19 @@ typedef struct {
gboolean l3miss;
} NMPlatformVxlanProperties;
typedef struct {
int parent_ifindex;
guint16 input_flags;
guint16 output_flags;
guint32 input_key;
guint32 output_key;
in_addr_t local;
in_addr_t remote;
guint8 ttl;
guint8 tos;
gboolean path_mtu_discovery;
} NMPlatformGreProperties;
/******************************************************************/
/* NMPlatform abstract class and its implementations provide a layer between
......@@ -238,6 +253,7 @@ typedef struct {
gboolean (*tun_get_properties) (NMPlatform *, int ifindex, NMPlatformTunProperties *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);
GArray * (*ip4_address_get_all) (NMPlatform *, int ifindex);
GArray * (*ip6_address_get_all) (NMPlatform *, int ifindex);
......@@ -350,6 +366,7 @@ gboolean nm_platform_veth_get_properties (int ifindex, NMPlatformVethProperties
gboolean nm_platform_tun_get_properties (int ifindex, NMPlatformTunProperties *properties);
gboolean nm_platform_macvlan_get_properties (int ifindex, NMPlatformMacvlanProperties *props);
gboolean nm_platform_vxlan_get_properties (int ifindex, NMPlatformVxlanProperties *props);
gboolean nm_platform_gre_get_properties (int ifindex, NMPlatformGreProperties *props);
GArray *nm_platform_ip4_address_get_all (int ifindex);
GArray *nm_platform_ip6_address_get_all (int ifindex);
......
......@@ -442,6 +442,39 @@ do_vxlan_get_properties (char **argv)
return TRUE;
}
static gboolean
do_gre_get_properties (char **argv)
{
int ifindex = parse_ifindex (*argv++);
NMPlatformGreProperties props;
char addrstr[INET_ADDRSTRLEN];
if (!nm_platform_gre_get_properties (ifindex, &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));
else
strcpy (addrstr, "-");
printf ("local: %s\n", 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 ("path-mtu-discovery: ");
print_boolean (props.path_mtu_discovery);
return TRUE;
}
static gboolean
do_ip4_address_get_all (char **argv)
{
......@@ -734,6 +767,8 @@ static const command_t commands[] = {
"<ifname/ifindex>" },
{ "vxlan-get-properties", "get vxlan properties", do_vxlan_get_properties, 1,
"<ifname/ifindex>" },
{ "gre-get-properties", "get gre properties", do_gre_get_properties, 1,
"<ifname/ifindex>" },
{ "ip4-address-get-all", "print all IPv4 addresses", do_ip4_address_get_all, 1, "<ifname/ifindex>" },
{ "ip6-address-get-all", "print all IPv6 addresses", do_ip6_address_get_all, 1, "<ifname/ifindex>" },
{ "ip4-address-add", "add IPv4 address", do_ip4_address_add, 2, "<ifname/ifindex> <address>/<plen>" },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment