From ae4e82c30fa674a26fb4f921cc95bac3f108dbd3 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Mon, 1 Jul 2019 13:45:27 +0200 Subject: [PATCH] device: ppp: check that connection has a PPPoE parent NMDevicePPP only handles connections with the pppoe.parent property set. match_connection() already checks this when we creating a new device. We should also perform the same check in check_connection_compatible(). Fixes: 6c3195931e94 ('core: implement activation of PPP devices') https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/203 (cherry picked from commit 17f4a1e794a526557a7c964466cdacc5a6c1d1b8) (cherry picked from commit 5ca888d693b9868b36a47923e3407274a3a5788d) --- src/devices/nm-device-ppp.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/devices/nm-device-ppp.c b/src/devices/nm-device-ppp.c index 3c310146bf..a0722f7192 100644 --- a/src/devices/nm-device-ppp.c +++ b/src/devices/nm-device-ppp.c @@ -117,6 +117,25 @@ ppp_ip4_config (NMPPPManager *ppp_manager, } } +static gboolean +check_connection_compatible (NMDevice *device, NMConnection *connection, GError **error) +{ + NMSettingPppoe *s_pppoe; + + if (!NM_DEVICE_CLASS (nm_device_ppp_parent_class)->check_connection_compatible (device, connection, error)) + return FALSE; + + s_pppoe = nm_connection_get_setting_pppoe (connection); + if ( !s_pppoe + || !nm_setting_pppoe_get_parent (s_pppoe)) { + nm_utils_error_set_literal (error, NM_UTILS_ERROR_CONNECTION_AVAILABLE_INCOMPATIBLE, + "the connection doesn't specify a PPPoE parent interface"); + return FALSE; + } + + return TRUE; +} + static NMActStageReturn act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason) { @@ -280,6 +299,7 @@ nm_device_ppp_class_init (NMDevicePppClass *klass) device_class->act_stage2_config = act_stage2_config; device_class->act_stage3_ip_config_start = act_stage3_ip_config_start; + device_class->check_connection_compatible = check_connection_compatible; device_class->create_and_realize = create_and_realize; device_class->deactivate = deactivate; device_class->get_generic_capabilities = get_generic_capabilities;