diff options
| author | Michael Biebl <biebl@debian.org> | 2019-03-26 23:25:23 +0100 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2019-03-26 23:25:23 +0100 |
| commit | 9a6dcbf895f9da01768e64b73cec88c16157d91e (patch) | |
| tree | a359958930d731e9f1b59344642e10754419fe84 /src/devices/nm-device-ethernet.c | |
| parent | 964ae8cc391520440cf5aa13e2b9cc34850ea6c2 (diff) | |
New upstream version 1.16.0 upstream/1.16.0
Diffstat (limited to 'src/devices/nm-device-ethernet.c')
| -rw-r--r-- | src/devices/nm-device-ethernet.c | 75 |
1 files changed, 42 insertions, 33 deletions
diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c index e7262683..24c99f76 100644 --- a/src/devices/nm-device-ethernet.c +++ b/src/devices/nm-device-ethernet.c @@ -24,10 +24,8 @@ #include "nm-device-ethernet.h" #include <netinet/in.h> -#include <string.h> #include <stdlib.h> #include <unistd.h> -#include <errno.h> #include <libudev.h> #include "nm-device-private.h" @@ -556,7 +554,9 @@ build_supplicant_config (NMDeviceEthernet *self, guint32 mtu; connection = nm_device_get_applied_connection (NM_DEVICE (self)); - g_assert (connection); + + g_return_val_if_fail (connection, NULL); + con_uuid = nm_connection_get_uuid (connection); mtu = nm_platform_link_get_mtu (nm_device_get_platform (NM_DEVICE (self)), nm_device_get_ifindex (NM_DEVICE (self))); @@ -790,7 +790,7 @@ link_negotiation_set (NMDevice *device) guint32 speed = 0; guint32 link_speed; - s_wired = (NMSettingWired *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_WIRED); + s_wired = nm_device_get_applied_setting (device, NM_TYPE_SETTING_WIRED); if (s_wired) { autoneg = nm_setting_wired_get_auto_negotiate (s_wired); speed = nm_setting_wired_get_speed (s_wired); @@ -880,8 +880,8 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *out_failure_reason) delay); g_assert (!priv->pppoe_wait_id); priv->pppoe_wait_id = g_timeout_add_seconds (delay, - pppoe_reconnect_delay, - self); + pppoe_reconnect_delay, + self); return NM_ACT_STAGE_RETURN_POSTPONE; } priv->last_pppoe_time = 0; @@ -900,6 +900,7 @@ nm_8021x_stage2_config (NMDeviceEthernet *self, NMDeviceStateReason *out_failure NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE; connection = nm_device_get_applied_connection (NM_DEVICE (self)); + g_return_val_if_fail (connection, NM_ACT_STAGE_RETURN_FAILURE); security = nm_connection_get_setting_802_1x (connection); @@ -981,9 +982,8 @@ ppp_ip4_config (NMPPPManager *ppp_manager, NMDevice *device = NM_DEVICE (user_data); /* Ignore PPP IP4 events that come in after initial configuration */ - if (nm_device_activate_ip4_state_in_conf (device)) { - nm_device_activate_schedule_ip4_config_result (device, config); - } + if (nm_device_activate_ip4_state_in_conf (device)) + nm_device_activate_schedule_ip_config_result (device, AF_INET, NM_IP_CONFIG_CAST (config)); } static NMActStageReturn @@ -995,10 +995,12 @@ pppoe_stage3_ip4_config_start (NMDeviceEthernet *self, NMDeviceStateReason *out_ NMActRequest *req; GError *err = NULL; - req = nm_device_get_act_request (NM_DEVICE (self)); + req = nm_device_get_act_request (device); + g_return_val_if_fail (req, NM_ACT_STAGE_RETURN_FAILURE); - s_pppoe = (NMSettingPppoe *) nm_device_get_applied_setting ((NMDevice *) self, NM_TYPE_SETTING_PPPOE); + s_pppoe = nm_device_get_applied_setting (device, NM_TYPE_SETTING_PPPOE); + g_return_val_if_fail (s_pppoe, NM_ACT_STAGE_RETURN_FAILURE); priv->ppp_manager = nm_ppp_manager_create (nm_device_get_iface (device), @@ -1069,8 +1071,10 @@ dcb_configure (NMDevice *device) nm_clear_g_source (&priv->dcb_timeout_id); - s_dcb = (NMSettingDcb *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_DCB); - g_assert (s_dcb); + s_dcb = nm_device_get_applied_setting (device, NM_TYPE_SETTING_DCB); + + g_return_val_if_fail (s_dcb, FALSE); + if (!nm_dcb_setup (nm_device_get_iface (device), s_dcb, &error)) { _LOGW (LOGD_DCB, "Activation: (ethernet) failed to enable DCB/FCoE: %s", error->message); @@ -1199,7 +1203,8 @@ wake_on_lan_enable (NMDevice *device) NMSettingWired *s_wired; const char *password = NULL; - s_wired = (NMSettingWired *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_WIRED); + s_wired = nm_device_get_applied_setting (device, NM_TYPE_SETTING_WIRED); + if (s_wired) { wol = nm_setting_wired_get_wake_on_lan (s_wired); password = nm_setting_wired_get_wake_on_lan_password (s_wired); @@ -1208,7 +1213,7 @@ wake_on_lan_enable (NMDevice *device) } wol = nm_config_data_get_connection_default_int64 (NM_CONFIG_GET_DATA, - "ethernet.wake-on-lan", + NM_CON_DEFAULT ("ethernet.wake-on-lan"), device, NM_SETTING_WIRED_WAKE_ON_LAN_NONE, G_MAXINT32, @@ -1240,8 +1245,8 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason) NMActStageReturn ret = NM_ACT_STAGE_RETURN_SUCCESS; NMSettingDcb *s_dcb; - s_con = NM_SETTING_CONNECTION (nm_device_get_applied_setting (device, - NM_TYPE_SETTING_CONNECTION)); + s_con = nm_device_get_applied_setting (device, NM_TYPE_SETTING_CONNECTION); + g_return_val_if_fail (s_con, NM_ACT_STAGE_RETURN_FAILURE); nm_clear_g_source (&priv->dcb_timeout_id); @@ -1254,8 +1259,8 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason) if (!strcmp (connection_type, NM_SETTING_WIRED_SETTING_NAME)) { NMSetting8021x *security; - security = (NMSetting8021x *) nm_device_get_applied_setting (device, - NM_TYPE_SETTING_802_1X); + security = nm_device_get_applied_setting (device, NM_TYPE_SETTING_802_1X); + if (security) { /* FIXME: for now 802.1x is mutually exclusive with DCB */ return nm_8021x_stage2_config (self, out_failure_reason); @@ -1265,7 +1270,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason) wake_on_lan_enable (device); /* DCB and FCoE setup */ - s_dcb = (NMSettingDcb *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_DCB); + s_dcb = nm_device_get_applied_setting (device, NM_TYPE_SETTING_DCB); if (s_dcb) { /* lldpad really really wants the carrier to be up */ if (nm_platform_link_is_connected (nm_device_get_platform (device), nm_device_get_ifindex (device))) { @@ -1288,7 +1293,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason) NM_SETTING_PPPOE_SETTING_NAME)) { NMSettingPpp *s_ppp; - s_ppp = (NMSettingPpp *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_PPP); + s_ppp = nm_device_get_applied_setting (device, NM_TYPE_SETTING_PPP); if (s_ppp) { guint32 mtu = 0, mru = 0, mxu; @@ -1309,21 +1314,25 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason) } static NMActStageReturn -act_stage3_ip4_config_start (NMDevice *device, - NMIP4Config **out_config, - NMDeviceStateReason *out_failure_reason) +act_stage3_ip_config_start (NMDevice *device, + int addr_family, + gpointer *out_config, + NMDeviceStateReason *out_failure_reason) { NMSettingConnection *s_con; const char *connection_type; - s_con = NM_SETTING_CONNECTION (nm_device_get_applied_setting (device, NM_TYPE_SETTING_CONNECTION)); - g_return_val_if_fail (s_con, NM_ACT_STAGE_RETURN_FAILURE); + if (addr_family == AF_INET) { + s_con = nm_device_get_applied_setting (device, NM_TYPE_SETTING_CONNECTION); - connection_type = nm_setting_connection_get_connection_type (s_con); - if (!strcmp (connection_type, NM_SETTING_PPPOE_SETTING_NAME)) - return pppoe_stage3_ip4_config_start (NM_DEVICE_ETHERNET (device), out_failure_reason); + g_return_val_if_fail (s_con, NM_ACT_STAGE_RETURN_FAILURE); + + connection_type = nm_setting_connection_get_connection_type (s_con); + if (!strcmp (connection_type, NM_SETTING_PPPOE_SETTING_NAME)) + return pppoe_stage3_ip4_config_start (NM_DEVICE_ETHERNET (device), out_failure_reason); + } - return NM_DEVICE_CLASS (nm_device_ethernet_parent_class)->act_stage3_ip4_config_start (device, out_config, out_failure_reason); + return NM_DEVICE_CLASS (nm_device_ethernet_parent_class)->act_stage3_ip_config_start (device, addr_family, out_config, out_failure_reason); } static guint32 @@ -1347,7 +1356,7 @@ deactivate (NMDevice *device) nm_clear_g_source (&priv->pppoe_wait_id); if (priv->ppp_manager) { - nm_ppp_manager_stop (priv->ppp_manager, NULL, NULL); + nm_ppp_manager_stop (priv->ppp_manager, NULL, NULL, NULL); g_clear_object (&priv->ppp_manager); } @@ -1358,7 +1367,7 @@ deactivate (NMDevice *device) priv->dcb_handle_carrier_changes = FALSE; /* Tear down DCB/FCoE if it was enabled */ - s_dcb = (NMSettingDcb *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_DCB); + s_dcb = nm_device_get_applied_setting (device, NM_TYPE_SETTING_DCB); if (s_dcb) { if (!nm_dcb_cleanup (nm_device_get_iface (device), &error)) { _LOGW (LOGD_DEVICE | LOGD_PLATFORM, "failed to disable DCB/FCoE: %s", @@ -1785,7 +1794,7 @@ nm_device_ethernet_class_init (NMDeviceEthernetClass *klass) device_class->act_stage1_prepare = act_stage1_prepare; device_class->act_stage2_config = act_stage2_config; - device_class->act_stage3_ip4_config_start = act_stage3_ip4_config_start; + device_class->act_stage3_ip_config_start = act_stage3_ip_config_start; device_class->get_configured_mtu = get_configured_mtu; device_class->deactivate = deactivate; device_class->get_s390_subchannels = get_s390_subchannels; |