mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-07-22 10:46:59 +00:00
libnm-core: add ovs-port setting
This commit is contained in:
parent
27790fa976
commit
8a1ae40a80
|
@ -395,6 +395,7 @@ libnm_core_lib_h_pub_real = \
|
|||
libnm-core/nm-setting-olpc-mesh.h \
|
||||
libnm-core/nm-setting-ovs-interface.h \
|
||||
libnm-core/nm-setting-ovs-patch.h \
|
||||
libnm-core/nm-setting-ovs-port.h \
|
||||
libnm-core/nm-setting-ppp.h \
|
||||
libnm-core/nm-setting-pppoe.h \
|
||||
libnm-core/nm-setting-proxy.h \
|
||||
|
@ -478,6 +479,7 @@ libnm_core_lib_c_real = \
|
|||
libnm-core/nm-setting-olpc-mesh.c \
|
||||
libnm-core/nm-setting-ovs-interface.c \
|
||||
libnm-core/nm-setting-ovs-patch.c \
|
||||
libnm-core/nm-setting-ovs-port.c \
|
||||
libnm-core/nm-setting-ppp.c \
|
||||
libnm-core/nm-setting-pppoe.c \
|
||||
libnm-core/nm-setting-proxy.c \
|
||||
|
|
|
@ -266,6 +266,13 @@
|
|||
#define DESCRIBE_DOC_NM_SETTING_OVS_INTERFACE_TYPE N_("The interface type. Either \"internal\", or empty.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_OVS_PATCH_NAME N_("The setting's name, which uniquely identifies the setting within the connection. Each setting type has a name unique to that type, for example \"ppp\" or \"wireless\" or \"wired\".")
|
||||
#define DESCRIBE_DOC_NM_SETTING_OVS_PATCH_PEER N_("Specifies the unicast destination IP address of a remote OpenVSwitch bridge port to connect to.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_OVS_PORT_BOND_DOWNDELAY N_("The time port must be inactive in order to be considered down.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_OVS_PORT_BOND_MODE N_("Bonding mode. One of \"active-backup\", \"balance-slb\", or \"balance-tcp\".")
|
||||
#define DESCRIBE_DOC_NM_SETTING_OVS_PORT_BOND_UPDELAY N_("The time port must be active befor it starts forwarding traffic.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_OVS_PORT_LACP N_("LACP mode. One of \"active\", \"off\", or \"passive\".")
|
||||
#define DESCRIBE_DOC_NM_SETTING_OVS_PORT_NAME N_("The setting's name, which uniquely identifies the setting within the connection. Each setting type has a name unique to that type, for example \"ppp\" or \"wireless\" or \"wired\".")
|
||||
#define DESCRIBE_DOC_NM_SETTING_OVS_PORT_TAG N_("The VLAN tag in the range 0-4095.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_OVS_PORT_VLAN_MODE N_("The VLAN mode. One of \"access\", \"native-tagged\", \"native-untagged\", \"trunk\" or unset.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_PPP_BAUD N_("If non-zero, instruct pppd to set the serial port to the specified baudrate. This value should normally be left as 0 to automatically choose the speed.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_PPP_CRTSCTS N_("If TRUE, specify that pppd should set the serial port to use hardware flow control with RTS and CTS signals. This value should normally be set to FALSE.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_PPP_LCP_ECHO_FAILURE N_("If non-zero, instruct pppd to presume the connection to the peer has failed if the specified number of LCP echo-requests go unanswered by the peer. The \"lcp-echo-interval\" property must also be set to a non-zero value if this property is used.")
|
||||
|
|
|
@ -1099,6 +1099,7 @@ static gboolean
|
|||
_normalize_ovs_interface_type (NMConnection *self, GHashTable *parameters)
|
||||
{
|
||||
NMSettingOvsInterface *s_ovs_interface = nm_connection_get_setting_ovs_interface (self);
|
||||
NMSettingConnection *s_con = nm_connection_get_setting_connection (self);
|
||||
const char *interface_type;
|
||||
|
||||
if (strcmp (nm_connection_get_connection_type (self), NM_SETTING_OVS_INTERFACE_SETTING_NAME) == 0) {
|
||||
|
@ -1107,6 +1108,9 @@ _normalize_ovs_interface_type (NMConnection *self, GHashTable *parameters)
|
|||
interface_type = "patch";
|
||||
else
|
||||
interface_type = "internal";
|
||||
} else if (g_strcmp0 (nm_setting_connection_get_slave_type (s_con), NM_SETTING_OVS_PORT_SETTING_NAME) == 0) {
|
||||
/* A regular device enslaved to a port. */
|
||||
interface_type = "";
|
||||
} else {
|
||||
/* Something else. */
|
||||
return FALSE;
|
||||
|
@ -2014,6 +2018,7 @@ nm_connection_is_virtual (NMConnection *connection)
|
|||
|| !strcmp (type, NM_SETTING_MACSEC_SETTING_NAME)
|
||||
|| !strcmp (type, NM_SETTING_MACVLAN_SETTING_NAME)
|
||||
|| !strcmp (type, NM_SETTING_OVS_INTERFACE_SETTING_NAME)
|
||||
|| !strcmp (type, NM_SETTING_OVS_PORT_SETTING_NAME)
|
||||
|| !strcmp (type, NM_SETTING_VXLAN_SETTING_NAME))
|
||||
return TRUE;
|
||||
|
||||
|
@ -2397,6 +2402,22 @@ nm_connection_get_setting_ovs_patch (NMConnection *connection)
|
|||
{
|
||||
return _connection_get_setting_check (connection, NM_TYPE_SETTING_OVS_PATCH);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_connection_get_setting_ovs_port:
|
||||
* @connection: the #NMConnection
|
||||
*
|
||||
* A shortcut to return any #NMSettingOvsPort the connection might contain.
|
||||
*
|
||||
* Returns: (transfer none): an #NMSettingOvsPort if the connection contains one, otherwise %NULL
|
||||
*
|
||||
* Since: 1.10
|
||||
**/
|
||||
NMSettingOvsPort *
|
||||
nm_connection_get_setting_ovs_port (NMConnection *connection)
|
||||
{
|
||||
return _connection_get_setting_check (connection, NM_TYPE_SETTING_OVS_PORT);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_connection_get_setting_ppp:
|
||||
|
|
|
@ -216,6 +216,8 @@ NMSettingOlpcMesh * nm_connection_get_setting_olpc_mesh (NMConnec
|
|||
NM_AVAILABLE_IN_1_10
|
||||
NMSettingOvsInterface * nm_connection_get_setting_ovs_interface (NMConnection *connection);
|
||||
NMSettingOvsPatch * nm_connection_get_setting_ovs_patch (NMConnection *connection);
|
||||
NM_AVAILABLE_IN_1_10
|
||||
NMSettingOvsPort * nm_connection_get_setting_ovs_port (NMConnection *connection);
|
||||
NMSettingPpp * nm_connection_get_setting_ppp (NMConnection *connection);
|
||||
NMSettingPppoe * nm_connection_get_setting_pppoe (NMConnection *connection);
|
||||
NM_AVAILABLE_IN_1_6
|
||||
|
|
|
@ -58,6 +58,7 @@
|
|||
#include "nm-setting-olpc-mesh.h"
|
||||
#include "nm-setting-ovs-interface.h"
|
||||
#include "nm-setting-ovs-patch.h"
|
||||
#include "nm-setting-ovs-port.h"
|
||||
#include "nm-setting-ppp.h"
|
||||
#include "nm-setting-pppoe.h"
|
||||
#include "nm-setting-serial.h"
|
||||
|
|
|
@ -52,6 +52,7 @@ typedef struct _NMSettingMacvlan NMSettingMacvlan;
|
|||
typedef struct _NMSettingOlpcMesh NMSettingOlpcMesh;
|
||||
typedef struct _NMSettingOvsInterface NMSettingOvsInterface;
|
||||
typedef struct _NMSettingOvsPatch NMSettingOvsPatch;
|
||||
typedef struct _NMSettingOvsPort NMSettingOvsPort;
|
||||
typedef struct _NMSettingPpp NMSettingPpp;
|
||||
typedef struct _NMSettingPppoe NMSettingPppoe;
|
||||
typedef struct _NMSettingSerial NMSettingSerial;
|
||||
|
|
|
@ -85,6 +85,7 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
|
|||
|
||||
if (connection) {
|
||||
NMSettingConnection *s_con;
|
||||
const char *slave_type;
|
||||
|
||||
s_con = nm_connection_get_setting_connection (connection);
|
||||
if (!s_con) {
|
||||
|
@ -105,6 +106,20 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
|
|||
g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_MASTER);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
slave_type = nm_setting_connection_get_slave_type (s_con);
|
||||
if ( slave_type
|
||||
&& strcmp (slave_type, NM_SETTING_OVS_PORT_SETTING_NAME)) {
|
||||
g_set_error (error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
_("A connection with a '%s' setting must have the slave-type set to '%s'. Instead it is '%s'"),
|
||||
NM_SETTING_OVS_INTERFACE_SETTING_NAME,
|
||||
NM_SETTING_OVS_PORT_SETTING_NAME,
|
||||
slave_type);
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_SLAVE_TYPE);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!NM_IN_STRSET (self->type, "internal", "system", "patch", "", NULL)) {
|
||||
|
|
456
libnm-core/nm-setting-ovs-port.c
Normal file
456
libnm-core/nm-setting-ovs-port.c
Normal file
|
@ -0,0 +1,456 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* 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 "nm-setting-ovs-port.h"
|
||||
|
||||
#include "nm-connection-private.h"
|
||||
#include "nm-setting-connection.h"
|
||||
#include "nm-setting-private.h"
|
||||
|
||||
/**
|
||||
* SECTION:nm-setting-ovs-port
|
||||
* @short_description: Describes connection properties for OpenVSwitch ports.
|
||||
*
|
||||
* The #NMSettingOvsPort object is a #NMSetting subclass that describes properties
|
||||
* necessary for OpenVSwitch ports.
|
||||
**/
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_VLAN_MODE,
|
||||
PROP_TAG,
|
||||
PROP_LACP,
|
||||
PROP_BOND_MODE,
|
||||
PROP_BOND_UPDELAY,
|
||||
PROP_BOND_DOWNDELAY,
|
||||
LAST_PROP
|
||||
};
|
||||
|
||||
/**
|
||||
* NMSettingOvsPort:
|
||||
*
|
||||
* OvsPort Link Settings
|
||||
*/
|
||||
struct _NMSettingOvsPort {
|
||||
NMSetting parent;
|
||||
|
||||
char *vlan_mode;
|
||||
guint tag;
|
||||
char *lacp;
|
||||
char *bond_mode;
|
||||
guint bond_updelay;
|
||||
guint bond_downdelay;
|
||||
};
|
||||
|
||||
struct _NMSettingOvsPortClass {
|
||||
NMSettingClass parent;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (NMSettingOvsPort, nm_setting_ovs_port, NM_TYPE_SETTING,
|
||||
_nm_register_setting (OVS_PORT, NM_SETTING_PRIORITY_HW_BASE))
|
||||
NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_OVS_PORT)
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
* nm_setting_ovs_port_get_vlan_mode:
|
||||
* @self: the #NMSettingOvsPort
|
||||
*
|
||||
* Returns: the #NMSettingOvsPort:vlan-mode property of the setting
|
||||
*
|
||||
* Since: 1.10
|
||||
**/
|
||||
const char *
|
||||
nm_setting_ovs_port_get_vlan_mode (NMSettingOvsPort *self)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_OVS_PORT (self), NULL);
|
||||
|
||||
return self->vlan_mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_ovs_port_get_tag:
|
||||
* @self: the #NMSettingOvsPort
|
||||
*
|
||||
* Returns: the #NMSettingOvsPort:tag property of the setting
|
||||
*
|
||||
* Since: 1.10
|
||||
**/
|
||||
guint
|
||||
nm_setting_ovs_port_get_tag (NMSettingOvsPort *self)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_OVS_PORT (self), 0);
|
||||
|
||||
return self->tag;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_ovs_port_get_lacp:
|
||||
* @self: the #NMSettingOvsPort
|
||||
*
|
||||
* Returns: the #NMSettingOvsPort:lacp property of the setting
|
||||
*
|
||||
* Since: 1.10
|
||||
**/
|
||||
const char *
|
||||
nm_setting_ovs_port_get_lacp (NMSettingOvsPort *self)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_OVS_PORT (self), NULL);
|
||||
|
||||
return self->lacp;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_ovs_port_get_bond_mode:
|
||||
* @self: the #NMSettingOvsPort
|
||||
*
|
||||
* Returns: the #NMSettingOvsPort:bond-mode property of the setting
|
||||
*
|
||||
* Since: 1.10
|
||||
**/
|
||||
const char *
|
||||
nm_setting_ovs_port_get_bond_mode (NMSettingOvsPort *self)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_OVS_PORT (self), NULL);
|
||||
|
||||
return self->bond_mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_ovs_port_get_bond_updelay:
|
||||
* @self: the #NMSettingOvsPort
|
||||
*
|
||||
* Returns: the #NMSettingOvsPort:bond-updelay property of the setting
|
||||
*
|
||||
* Since: 1.10
|
||||
**/
|
||||
guint
|
||||
nm_setting_ovs_port_get_bond_updelay (NMSettingOvsPort *self)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_OVS_PORT (self), 0);
|
||||
|
||||
return self->bond_updelay;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_ovs_port_get_bond_downdelay:
|
||||
* @self: the #NMSettingOvsPort
|
||||
*
|
||||
* Returns: the #NMSettingOvsPort:bond-downdelay property of the setting
|
||||
*
|
||||
* Since: 1.10
|
||||
**/
|
||||
guint
|
||||
nm_setting_ovs_port_get_bond_downdelay (NMSettingOvsPort *self)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_OVS_PORT (self), 0);
|
||||
|
||||
return self->bond_downdelay;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static int
|
||||
verify (NMSetting *setting, NMConnection *connection, GError **error)
|
||||
{
|
||||
NMSettingOvsPort *self = NM_SETTING_OVS_PORT (setting);
|
||||
|
||||
if (!_nm_connection_verify_required_interface_name (connection, error))
|
||||
return FALSE;
|
||||
|
||||
if (connection) {
|
||||
NMSettingConnection *s_con;
|
||||
|
||||
s_con = nm_connection_get_setting_connection (connection);
|
||||
if (!s_con) {
|
||||
g_set_error (error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_MISSING_SETTING,
|
||||
_("missing setting"));
|
||||
g_prefix_error (error, "%s: ", NM_SETTING_CONNECTION_SETTING_NAME);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!nm_setting_connection_get_master (s_con)) {
|
||||
g_set_error (error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
_("A connection with a '%s' setting must have a master."),
|
||||
NM_SETTING_OVS_PORT_SETTING_NAME);
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_MASTER);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!NM_IN_STRSET (self->vlan_mode, "access", "native-tagged", "native-untagged", "trunk", NULL)) {
|
||||
g_set_error (error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
_("'%s' is not allowed in vlan_mode"),
|
||||
self->vlan_mode);
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_OVS_PORT_SETTING_NAME, NM_SETTING_OVS_PORT_VLAN_MODE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (self->tag >= 4095) {
|
||||
g_set_error (error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
_("the tag id must be in range 0-4094 but is %u"),
|
||||
self->tag);
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_OVS_PORT_SETTING_NAME, NM_SETTING_OVS_PORT_TAG);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!NM_IN_STRSET (self->lacp, "active", "off", "passive", NULL)) {
|
||||
g_set_error (error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
_("'%s' is not allowed in lacp"),
|
||||
self->lacp);
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_OVS_PORT_SETTING_NAME, NM_SETTING_OVS_PORT_LACP);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!NM_IN_STRSET (self->bond_mode, "active-backup", "balance-slb", "balance-tcp", NULL)) {
|
||||
g_set_error (error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
_("'%s' is not allowed in bond_mode"),
|
||||
self->bond_mode);
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_OVS_PORT_SETTING_NAME, NM_SETTING_OVS_PORT_BOND_MODE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
get_property (GObject *object, guint prop_id,
|
||||
GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
NMSettingOvsPort *self = NM_SETTING_OVS_PORT (object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_VLAN_MODE:
|
||||
g_value_set_string (value, self->vlan_mode);
|
||||
break;
|
||||
case PROP_TAG:
|
||||
g_value_set_uint (value, self->tag);
|
||||
break;
|
||||
case PROP_LACP:
|
||||
g_value_set_string (value, self->lacp);
|
||||
break;
|
||||
case PROP_BOND_MODE:
|
||||
g_value_set_string (value, self->bond_mode);
|
||||
break;
|
||||
case PROP_BOND_UPDELAY:
|
||||
g_value_set_uint (value, self->bond_updelay);
|
||||
break;
|
||||
case PROP_BOND_DOWNDELAY:
|
||||
g_value_set_uint (value, self->bond_downdelay);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
set_property (GObject *object, guint prop_id,
|
||||
const GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
NMSettingOvsPort *self = NM_SETTING_OVS_PORT (object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_VLAN_MODE:
|
||||
g_free (self->vlan_mode);
|
||||
self->vlan_mode = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_TAG:
|
||||
self->tag = g_value_get_uint (value);
|
||||
break;
|
||||
case PROP_LACP:
|
||||
g_free (self->lacp);
|
||||
self->lacp = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_BOND_MODE:
|
||||
g_free (self->bond_mode);
|
||||
self->bond_mode = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_BOND_UPDELAY:
|
||||
self->bond_updelay = g_value_get_uint (value);
|
||||
break;
|
||||
case PROP_BOND_DOWNDELAY:
|
||||
self->bond_downdelay = g_value_get_uint (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
nm_setting_ovs_port_init (NMSettingOvsPort *self)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_ovs_port_new:
|
||||
*
|
||||
* Creates a new #NMSettingOvsPort object with default values.
|
||||
*
|
||||
* Returns: (transfer full): the new empty #NMSettingOvsPort object
|
||||
*
|
||||
* Since: 1.10
|
||||
**/
|
||||
NMSetting *
|
||||
nm_setting_ovs_port_new (void)
|
||||
{
|
||||
return (NMSetting *) g_object_new (NM_TYPE_SETTING_OVS_PORT, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
finalize (GObject *object)
|
||||
{
|
||||
NMSettingOvsPort *self = NM_SETTING_OVS_PORT (object);
|
||||
|
||||
g_free (self->vlan_mode);
|
||||
g_free (self->lacp);
|
||||
g_free (self->bond_mode);
|
||||
|
||||
G_OBJECT_CLASS (nm_setting_ovs_port_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
nm_setting_ovs_port_class_init (NMSettingOvsPortClass *setting_class)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
|
||||
NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class);
|
||||
|
||||
object_class->set_property = set_property;
|
||||
object_class->get_property = get_property;
|
||||
object_class->finalize = finalize;
|
||||
parent_class->verify = verify;
|
||||
|
||||
/**
|
||||
* NMSettingOvsPort:vlan-mode:
|
||||
*
|
||||
* The VLAN mode. One of "access", "native-tagged", "native-untagged",
|
||||
* "trunk" or unset.
|
||||
*
|
||||
* Since: 1.10
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_VLAN_MODE,
|
||||
g_param_spec_string (NM_SETTING_OVS_PORT_VLAN_MODE, "", "",
|
||||
NULL,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* NMSettingOvsPort:tag:
|
||||
*
|
||||
* The VLAN tag in the range 0-4095.
|
||||
*
|
||||
* Since: 1.10
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_TAG,
|
||||
g_param_spec_uint (NM_SETTING_OVS_PORT_TAG, "", "",
|
||||
0, 4095, 0,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* NMSettingOvsPort:lacp:
|
||||
*
|
||||
* LACP mode. One of "active", "off", or "passive".
|
||||
*
|
||||
* Since: 1.10
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_LACP,
|
||||
g_param_spec_string (NM_SETTING_OVS_PORT_LACP, "", "",
|
||||
NULL,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* NMSettingOvsPort:bond-mode:
|
||||
*
|
||||
* Bonding mode. One of "active-backup", "balance-slb", or "balance-tcp".
|
||||
*
|
||||
* Since: 1.10
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_BOND_MODE,
|
||||
g_param_spec_string (NM_SETTING_OVS_PORT_BOND_MODE, "", "",
|
||||
NULL,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
|
||||
/**
|
||||
* NMSettingOvsPort:bond-updelay:
|
||||
*
|
||||
* The time port must be active befor it starts forwarding traffic.
|
||||
*
|
||||
* Since: 1.10
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_BOND_UPDELAY,
|
||||
g_param_spec_uint (NM_SETTING_OVS_PORT_BOND_UPDELAY, "", "",
|
||||
0, G_MAXUINT, 0,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* NMSettingOvsPort:bond-downdelay:
|
||||
*
|
||||
* The time port must be inactive in order to be considered down.
|
||||
*
|
||||
* Since: 1.10
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_BOND_DOWNDELAY,
|
||||
g_param_spec_uint (NM_SETTING_OVS_PORT_BOND_DOWNDELAY, "", "",
|
||||
0, G_MAXUINT, 0,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
}
|
69
libnm-core/nm-setting-ovs-port.h
Normal file
69
libnm-core/nm-setting-ovs-port.h
Normal file
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* 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_SETTING_OVS_PORT_H__
|
||||
#define __NM_SETTING_OVS_PORT_H__
|
||||
|
||||
#if !defined (__NETWORKMANAGER_H_INSIDE__) && !defined (NETWORKMANAGER_COMPILATION)
|
||||
#error "Only <NetworkManager.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include "nm-setting.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define NM_TYPE_SETTING_OVS_PORT (nm_setting_ovs_port_get_type ())
|
||||
#define NM_SETTING_OVS_PORT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_OVS_PORT, NMSettingOvsPort))
|
||||
#define NM_SETTING_OVS_PORT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_OVS_PORTCONFIG, NMSettingOvsPortClass))
|
||||
#define NM_IS_SETTING_OVS_PORT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTING_OVS_PORT))
|
||||
#define NM_IS_SETTING_OVS_PORT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SETTING_OVS_PORT))
|
||||
#define NM_SETTING_OVS_PORT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING_OVS_PORT, NMSettingOvsPortClass))
|
||||
|
||||
#define NM_SETTING_OVS_PORT_SETTING_NAME "ovs-port"
|
||||
|
||||
#define NM_SETTING_OVS_PORT_VLAN_MODE "vlan-mode"
|
||||
#define NM_SETTING_OVS_PORT_TAG "tag"
|
||||
#define NM_SETTING_OVS_PORT_LACP "lacp"
|
||||
#define NM_SETTING_OVS_PORT_BOND_MODE "bond-mode"
|
||||
#define NM_SETTING_OVS_PORT_BOND_UPDELAY "bond-updelay"
|
||||
#define NM_SETTING_OVS_PORT_BOND_DOWNDELAY "bond-downdelay"
|
||||
|
||||
typedef struct _NMSettingOvsPortClass NMSettingOvsPortClass;
|
||||
|
||||
NM_AVAILABLE_IN_1_10
|
||||
GType nm_setting_ovs_port_get_type (void);
|
||||
NM_AVAILABLE_IN_1_10
|
||||
NMSetting *nm_setting_ovs_port_new (void);
|
||||
|
||||
NM_AVAILABLE_IN_1_10
|
||||
const char *nm_setting_ovs_port_get_vlan_mode (NMSettingOvsPort *self);
|
||||
NM_AVAILABLE_IN_1_10
|
||||
guint nm_setting_ovs_port_get_tag (NMSettingOvsPort *self);
|
||||
NM_AVAILABLE_IN_1_10
|
||||
const char *nm_setting_ovs_port_get_lacp (NMSettingOvsPort *self);
|
||||
NM_AVAILABLE_IN_1_10
|
||||
const char *nm_setting_ovs_port_get_bond_mode (NMSettingOvsPort *self);
|
||||
NM_AVAILABLE_IN_1_10
|
||||
guint nm_setting_ovs_port_get_bond_updelay (NMSettingOvsPort *self);
|
||||
NM_AVAILABLE_IN_1_10
|
||||
guint nm_setting_ovs_port_get_bond_downdelay (NMSettingOvsPort *self);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __NM_SETTING_OVS_PORT_H__ */
|
|
@ -258,8 +258,8 @@ _nm_setting_slave_type_is_valid (const char *slave_type, const char **out_port_t
|
|||
;
|
||||
else if (!strcmp (slave_type, NM_SETTING_BRIDGE_SETTING_NAME))
|
||||
port_type = NM_SETTING_BRIDGE_PORT_SETTING_NAME;
|
||||
else if (!strcmp (slave_type, NM_SETTING_OVS_INTERFACE_SETTING_NAME))
|
||||
;
|
||||
else if (!strcmp (slave_type, NM_SETTING_OVS_PORT_SETTING_NAME))
|
||||
port_type = NM_SETTING_OVS_INTERFACE_SETTING_NAME;
|
||||
else if (!strcmp (slave_type, NM_SETTING_TEAM_SETTING_NAME))
|
||||
port_type = NM_SETTING_TEAM_PORT_SETTING_NAME;
|
||||
else
|
||||
|
|
|
@ -1196,6 +1196,14 @@ global:
|
|||
nm_setting_ovs_patch_get_peer;
|
||||
nm_setting_ovs_patch_get_type;
|
||||
nm_setting_ovs_patch_new;
|
||||
nm_setting_ovs_port_get_bond_downdelay;
|
||||
nm_setting_ovs_port_get_bond_mode;
|
||||
nm_setting_ovs_port_get_bond_updelay;
|
||||
nm_setting_ovs_port_get_lacp;
|
||||
nm_setting_ovs_port_get_tag;
|
||||
nm_setting_ovs_port_get_type;
|
||||
nm_setting_ovs_port_get_vlan_mode;
|
||||
nm_setting_ovs_port_new;
|
||||
nm_setting_pppoe_get_parent;
|
||||
nm_setting_wireless_security_get_pmf;
|
||||
nm_setting_wireless_security_get_wps_method;
|
||||
|
|
|
@ -77,6 +77,7 @@ libnm-core/nm-setting-macvlan.c
|
|||
libnm-core/nm-setting-olpc-mesh.c
|
||||
libnm-core/nm-setting-ovs-interface.c
|
||||
libnm-core/nm-setting-ovs-patch.c
|
||||
libnm-core/nm-setting-ovs-port.c
|
||||
libnm-core/nm-setting-ppp.c
|
||||
libnm-core/nm-setting-pppoe.c
|
||||
libnm-core/nm-setting-proxy.c
|
||||
|
|
Loading…
Reference in a new issue