core: implement update_connection() for bridging

This commit is contained in:
Pavel Šimerda
2013-08-23 23:02:54 +02:00
committed by Dan Williams
parent 12fb2519af
commit a3af5cfe9d

View File

@@ -24,6 +24,7 @@
#include <glib/gi18n.h>
#include <netinet/ether.h>
#include <stdlib.h>
#include "gsystem-local-alloc.h"
#include "nm-device-bridge.h"
@@ -180,13 +181,6 @@ complete_connection (NMDevice *device,
return TRUE;
}
static gboolean
match_l2_config (NMDevice *self, NMConnection *connection)
{
/* FIXME */
return TRUE;
}
/******************************************************************/
typedef struct {
@@ -290,6 +284,32 @@ commit_slave_options (NMDevice *device, NMSettingBridgePort *setting)
g_clear_object (&s_clear);
}
static void
update_connection (NMDevice *device, NMConnection *connection)
{
NMSettingBridge *s_bridge = nm_connection_get_setting_bridge (connection);
const char *ifname = nm_device_get_iface (device);
int ifindex = nm_device_get_ifindex (device);
const Option *option;
if (!s_bridge) {
s_bridge = (NMSettingBridge *) nm_setting_bridge_new ();
nm_connection_add_setting (connection, (NMSetting *) s_bridge);
g_object_set (s_bridge, NM_SETTING_BRIDGE_INTERFACE_NAME, ifname, NULL);
}
for (option = master_options; option->name; option++) {
gs_free char *str = nm_platform_master_get_option (ifindex, option->sysname);
int value = strtol (str, NULL, 10);
/* See comments in set_sysfs_uint() about centiseconds. */
if (option->user_hz_compensate)
value /= 100;
g_object_set (s_bridge, option->name, value, NULL);
}
}
static NMActStageReturn
act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason)
{
@@ -439,6 +459,8 @@ nm_device_bridge_class_init (NMDeviceBridgeClass *klass)
g_type_class_add_private (object_class, sizeof (NMDeviceBridgePrivate));
parent_class->connection_type = NM_SETTING_BRIDGE_SETTING_NAME;
/* virtual methods */
object_class->constructed = constructed;
object_class->get_property = get_property;
@@ -450,7 +472,7 @@ nm_device_bridge_class_init (NMDeviceBridgeClass *klass)
parent_class->check_connection_available = check_connection_available;
parent_class->complete_connection = complete_connection;
parent_class->match_l2_config = match_l2_config;
parent_class->update_connection = update_connection;
parent_class->act_stage1_prepare = act_stage1_prepare;
parent_class->enslave_slave = enslave_slave;