diff --git a/src/devices/nm-device-bridge.c b/src/devices/nm-device-bridge.c index 856eb83b3..92a6d8a85 100644 --- a/src/devices/nm-device-bridge.c +++ b/src/devices/nm-device-bridge.c @@ -24,6 +24,7 @@ #include #include +#include #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;