diff options
author | Lubomir Rintel <lkundrak@v3.sk> | 2017-08-01 19:34:03 +0200 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2017-09-11 23:56:47 +0200 |
commit | 45cf408f7ce53b8c7ca4fd704346a75a364d70b9 (patch) | |
tree | 0e656d4fb74feab9ab61ce4b7830e12e377b1535 | |
parent | 5ecb2d16804e214373f0c4290ef1a4838313df72 (diff) | |
download | NetworkManager-45cf408f7ce53b8c7ca4fd704346a75a364d70b9.tar.gz |
libnm: add support for openvswitch devices
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | libnm-core/nm-dbus-interface.h | 50 | ||||
-rw-r--r-- | libnm/NetworkManager.h | 3 | ||||
-rw-r--r-- | libnm/libnm.ver | 1 | ||||
-rw-r--r-- | libnm/nm-client.c | 3 | ||||
-rw-r--r-- | libnm/nm-device-openvswitch.c | 91 | ||||
-rw-r--r-- | libnm/nm-device-openvswitch.h | 42 | ||||
-rw-r--r-- | libnm/nm-device.c | 3 | ||||
-rw-r--r-- | libnm/nm-types.h | 1 | ||||
-rw-r--r-- | po/POTFILES.in | 1 |
10 files changed, 173 insertions, 24 deletions
diff --git a/Makefile.am b/Makefile.am index 62f1819bf5..43f250a213 100644 --- a/Makefile.am +++ b/Makefile.am @@ -733,6 +733,7 @@ libnm_lib_h_pub_real = \ libnm/nm-device-macvlan.h \ libnm/nm-device-modem.h \ libnm/nm-device-olpc-mesh.h \ + libnm/nm-device-openvswitch.h \ libnm/nm-device-ppp.h \ libnm/nm-device-team.h \ libnm/nm-device-tun.h \ @@ -786,6 +787,7 @@ libnm_lib_c_real = \ libnm/nm-device-macvlan.c \ libnm/nm-device-modem.c \ libnm/nm-device-olpc-mesh.c \ + libnm/nm-device-openvswitch.c \ libnm/nm-device-ppp.c \ libnm/nm-device-team.c \ libnm/nm-device-tun.c \ diff --git a/libnm-core/nm-dbus-interface.h b/libnm-core/nm-dbus-interface.h index 2411245169..303c36cd6a 100644 --- a/libnm-core/nm-dbus-interface.h +++ b/libnm-core/nm-dbus-interface.h @@ -206,35 +206,37 @@ typedef enum { * @NM_DEVICE_TYPE_MACSEC: a MACsec interface * @NM_DEVICE_TYPE_DUMMY: a dummy interface * @NM_DEVICE_TYPE_PPP: a PPP interface + * @NM_DEVICE_TYPE_OPENVSWITCH: a OpenVSwitch interface * * #NMDeviceType values indicate the type of hardware represented by a * device object. **/ typedef enum { - NM_DEVICE_TYPE_UNKNOWN = 0, - NM_DEVICE_TYPE_ETHERNET = 1, - NM_DEVICE_TYPE_WIFI = 2, - NM_DEVICE_TYPE_UNUSED1 = 3, - NM_DEVICE_TYPE_UNUSED2 = 4, - NM_DEVICE_TYPE_BT = 5, /* Bluetooth */ - NM_DEVICE_TYPE_OLPC_MESH = 6, - NM_DEVICE_TYPE_WIMAX = 7, - NM_DEVICE_TYPE_MODEM = 8, - NM_DEVICE_TYPE_INFINIBAND = 9, - NM_DEVICE_TYPE_BOND = 10, - NM_DEVICE_TYPE_VLAN = 11, - NM_DEVICE_TYPE_ADSL = 12, - NM_DEVICE_TYPE_BRIDGE = 13, - NM_DEVICE_TYPE_GENERIC = 14, - NM_DEVICE_TYPE_TEAM = 15, - NM_DEVICE_TYPE_TUN = 16, - NM_DEVICE_TYPE_IP_TUNNEL = 17, - NM_DEVICE_TYPE_MACVLAN = 18, - NM_DEVICE_TYPE_VXLAN = 19, - NM_DEVICE_TYPE_VETH = 20, - NM_DEVICE_TYPE_MACSEC = 21, - NM_DEVICE_TYPE_DUMMY = 22, - NM_DEVICE_TYPE_PPP = 23, + NM_DEVICE_TYPE_UNKNOWN = 0, + NM_DEVICE_TYPE_ETHERNET = 1, + NM_DEVICE_TYPE_WIFI = 2, + NM_DEVICE_TYPE_UNUSED1 = 3, + NM_DEVICE_TYPE_UNUSED2 = 4, + NM_DEVICE_TYPE_BT = 5, /* Bluetooth */ + NM_DEVICE_TYPE_OLPC_MESH = 6, + NM_DEVICE_TYPE_WIMAX = 7, + NM_DEVICE_TYPE_MODEM = 8, + NM_DEVICE_TYPE_INFINIBAND = 9, + NM_DEVICE_TYPE_BOND = 10, + NM_DEVICE_TYPE_VLAN = 11, + NM_DEVICE_TYPE_ADSL = 12, + NM_DEVICE_TYPE_BRIDGE = 13, + NM_DEVICE_TYPE_GENERIC = 14, + NM_DEVICE_TYPE_TEAM = 15, + NM_DEVICE_TYPE_TUN = 16, + NM_DEVICE_TYPE_IP_TUNNEL = 17, + NM_DEVICE_TYPE_MACVLAN = 18, + NM_DEVICE_TYPE_VXLAN = 19, + NM_DEVICE_TYPE_VETH = 20, + NM_DEVICE_TYPE_MACSEC = 21, + NM_DEVICE_TYPE_DUMMY = 22, + NM_DEVICE_TYPE_PPP = 23, + NM_DEVICE_TYPE_OPENVSWITCH = 24, } NMDeviceType; /** diff --git a/libnm/NetworkManager.h b/libnm/NetworkManager.h index 97327f92d6..8bbb65891a 100644 --- a/libnm/NetworkManager.h +++ b/libnm/NetworkManager.h @@ -41,6 +41,7 @@ #include "nm-device-macvlan.h" #include "nm-device-modem.h" #include "nm-device-olpc-mesh.h" +#include "nm-device-openvswitch.h" #include "nm-device-team.h" #include "nm-device-tun.h" #include "nm-device-vlan.h" @@ -73,6 +74,8 @@ #include "nm-setting-macsec.h" #include "nm-setting-macvlan.h" #include "nm-setting-olpc-mesh.h" +#include "nm-setting-ovs-bridge.h" +#include "nm-setting-ovs-port.h" #include "nm-setting-ppp.h" #include "nm-setting-pppoe.h" #include "nm-setting-proxy.h" diff --git a/libnm/libnm.ver b/libnm/libnm.ver index adeb349df2..d52450eac4 100644 --- a/libnm/libnm.ver +++ b/libnm/libnm.ver @@ -1184,6 +1184,7 @@ global: nm_client_connectivity_check_get_enabled; nm_client_connectivity_check_set_enabled; nm_device_dummy_get_hw_address; + nm_device_openvswitch_get_type; nm_device_ppp_get_type; nm_setting_bridge_get_group_forward_mask; nm_setting_ovs_bridge_get_type; diff --git a/libnm/nm-client.c b/libnm/nm-client.c index 8912a5f419..e802217199 100644 --- a/libnm/nm-client.c +++ b/libnm/nm-client.c @@ -63,6 +63,7 @@ #include "nm-device-macvlan.h" #include "nm-device-modem.h" #include "nm-device-olpc-mesh.h" +#include "nm-device-openvswitch.h" #include "nm-device-ppp.h" #include "nm-device-team.h" #include "nm-device-tun.h" @@ -2147,6 +2148,8 @@ obj_nm_for_gdbus_object (NMClient *self, GDBusObject *object, GDBusObjectManager type = NM_TYPE_DEVICE_MODEM; else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_OLPC_MESH) == 0) type = NM_TYPE_DEVICE_OLPC_MESH; + else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_OPENVSWITCH) == 0) + type = NM_TYPE_DEVICE_OPENVSWITCH; else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_PPP) == 0) type = NM_TYPE_DEVICE_PPP; else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_TEAM) == 0) diff --git a/libnm/nm-device-openvswitch.c b/libnm/nm-device-openvswitch.c new file mode 100644 index 0000000000..2b33b220c6 --- /dev/null +++ b/libnm/nm-device-openvswitch.c @@ -0,0 +1,91 @@ +/* + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + * Copyright 2017 Red Hat, Inc. + */ + +#include "nm-default.h" + +#include <string.h> + +#include "nm-device-openvswitch.h" +#include "nm-object-private.h" +#include "nm-setting-ovs-bridge.h" +#include "nm-setting-ovs-port.h" +#include "nm-setting-connection.h" + +/** + * NMDeviceOpenvswitch: + */ +struct _NMDeviceOpenvswitch { + NMDevice parent; +}; + +typedef struct { + NMDeviceClass parent; +} NMDeviceOpenvswitchClass; + +G_DEFINE_TYPE (NMDeviceOpenvswitch, nm_device_openvswitch, NM_TYPE_DEVICE) + +/*****************************************************************************/ + +static gboolean +connection_compatible (NMDevice *device, NMConnection *connection, GError **error) +{ + const char *iface_name; + + if (!NM_DEVICE_CLASS (nm_device_openvswitch_parent_class)->connection_compatible (device, connection, error)) + return FALSE; + + if ( !nm_connection_is_type (connection, NM_SETTING_OVS_BRIDGE_SETTING_NAME) + && !nm_connection_is_type (connection, NM_SETTING_OVS_PORT_SETTING_NAME)) { + g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, + _("The connection was not a openvswitch connection.")); + return FALSE; + } + + iface_name = nm_connection_get_interface_name (connection); + if (!iface_name) { + g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INVALID_CONNECTION, + _("The connection did not specify an interface name.")); + return FALSE; + } + + return TRUE; +} + +static GType +get_setting_type (NMDevice *device) +{ + // XXX + return NM_TYPE_SETTING_OVS_PORT; +} + +/*****************************************************************************/ + +static void +nm_device_openvswitch_init (NMDeviceOpenvswitch *device) +{ +} + +static void +nm_device_openvswitch_class_init (NMDeviceOpenvswitchClass *openvswitch_class) +{ + NMDeviceClass *device_class = NM_DEVICE_CLASS (openvswitch_class); + + device_class->connection_compatible = connection_compatible; + device_class->get_setting_type = get_setting_type; +} diff --git a/libnm/nm-device-openvswitch.h b/libnm/nm-device-openvswitch.h new file mode 100644 index 0000000000..126f488b62 --- /dev/null +++ b/libnm/nm-device-openvswitch.h @@ -0,0 +1,42 @@ +/* + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + * Copyright 2017 Red Hat, Inc. + */ + +#ifndef __NM_DEVICE_OPENVSWITCH_H__ +#define __NM_DEVICE_OPENVSWITCH_H__ + +#if !defined (__NETWORKMANAGER_H_INSIDE__) && !defined (NETWORKMANAGER_COMPILATION) +#error "Only <NetworkManager.h> can be included directly." +#endif + +#include "nm-device.h" + +G_BEGIN_DECLS + +#define NM_TYPE_DEVICE_OPENVSWITCH (nm_device_openvswitch_get_type ()) +#define NM_DEVICE_OPENVSWITCH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_OPENVSWITCH, NMDeviceOpenvswitch)) +#define NM_DEVICE_OPENVSWITCH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DEVICE_OPENVSWITCH, NMDeviceOpenvswitchClass)) +#define NM_IS_DEVICE_OPENVSWITCH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DEVICE_OPENVSWITCH)) +#define NM_IS_DEVICE_OPENVSWITCH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_OPENVSWITCH)) +#define NM_DEVICE_OPENVSWITCH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_OPENVSWITCH, NMDeviceOpenvswitchClass)) + +GType nm_device_openvswitch_get_type (void); + +G_END_DECLS + +#endif /* __NM_DEVICE_OPENVSWITCH_H__ */ diff --git a/libnm/nm-device.c b/libnm/nm-device.c index 7f15436638..85ea4e02a6 100644 --- a/libnm/nm-device.c +++ b/libnm/nm-device.c @@ -261,6 +261,7 @@ coerce_type (NMDeviceType type) case NM_DEVICE_TYPE_WIFI: case NM_DEVICE_TYPE_BT: case NM_DEVICE_TYPE_OLPC_MESH: + case NM_DEVICE_TYPE_OPENVSWITCH: case NM_DEVICE_TYPE_WIMAX: case NM_DEVICE_TYPE_MODEM: case NM_DEVICE_TYPE_INFINIBAND: @@ -1522,6 +1523,8 @@ get_type_name (NMDevice *device) return _("Bluetooth"); case NM_DEVICE_TYPE_OLPC_MESH: return _("OLPC Mesh"); + case NM_DEVICE_TYPE_OPENVSWITCH: + return _("OpenVSwitch"); case NM_DEVICE_TYPE_WIMAX: return _("WiMAX"); case NM_DEVICE_TYPE_MODEM: diff --git a/libnm/nm-types.h b/libnm/nm-types.h index 1e06d15feb..0b9a4c3b53 100644 --- a/libnm/nm-types.h +++ b/libnm/nm-types.h @@ -43,6 +43,7 @@ typedef struct _NMDeviceMacsec NMDeviceMacsec; typedef struct _NMDeviceMacvlan NMDeviceMacvlan; typedef struct _NMDeviceModem NMDeviceModem; typedef struct _NMDeviceOlpcMesh NMDeviceOlpcMesh; +typedef struct _NMDeviceOpenvswitch NMDeviceOpenvswitch; typedef struct _NMDevicePpp NMDevicePpp; typedef struct _NMDeviceTeam NMDeviceTeam; typedef struct _NMDeviceTun NMDeviceTun; diff --git a/po/POTFILES.in b/po/POTFILES.in index d4dfc496bb..ff7e149ba7 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -137,6 +137,7 @@ libnm/nm-device-ip-tunnel.c libnm/nm-device-macvlan.c libnm/nm-device-modem.c libnm/nm-device-olpc-mesh.c +libnm/nm-device-openvswitch.c libnm/nm-device-team.c libnm/nm-device-vlan.c libnm/nm-device-vxlan.c |