diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2022-03-15 17:49:01 +0100 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2022-03-16 10:43:46 +0100 |
commit | 7b2bea7ceb2cb95cf6f45b7d17abc552490c68a5 (patch) | |
tree | 8e0b709ea08105f3b3f77248d807c74cf444a744 | |
parent | 041df05f3cad687b3aa30879687d9c1eb3de5746 (diff) |
ethernet: don't do DHCPv4 on PPPoE
It's not going to work.
Fixes: 58287cbcc0c8 ('core: rework IP configuration in NetworkManager using layer 3 configuration')
-rw-r--r-- | src/core/devices/nm-device-ethernet.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/core/devices/nm-device-ethernet.c b/src/core/devices/nm-device-ethernet.c index 842d863e8f..7cddf9d838 100644 --- a/src/core/devices/nm-device-ethernet.c +++ b/src/core/devices/nm-device-ethernet.c @@ -1892,6 +1892,32 @@ is_available(NMDevice *device, NMDeviceCheckDevAvailableFlags flags) return !!nm_device_get_initial_hw_address(device); } +static const char * +get_ip_method_auto(NMDevice *device, int addr_family) +{ + NMSettingConnection *s_con; + + s_con = nm_device_get_applied_setting(device, NM_TYPE_SETTING_CONNECTION); + g_return_val_if_fail(s_con, + NM_IS_IPv4(addr_family) ? NM_SETTING_IP4_CONFIG_METHOD_AUTO + : NM_SETTING_IP6_CONFIG_METHOD_AUTO); + + if (!nm_streq(nm_setting_connection_get_connection_type(s_con), + NM_SETTING_PPPOE_SETTING_NAME)) { + return NM_DEVICE_CLASS(nm_device_ethernet_parent_class) + ->get_ip_method_auto(device, addr_family); + } + + if (NM_IS_IPv4(addr_family)) { + /* We cannot do DHCPv4 on a PPP link, instead we get "auto" IP addresses + * by pppd. Return "manual" here, which has the suitable effect to a + * (zero) manual addresses in addition. */ + return NM_SETTING_IP6_CONFIG_METHOD_MANUAL; + } + + return NM_SETTING_IP6_CONFIG_METHOD_AUTO; +} + static gboolean can_reapply_change(NMDevice *device, const char *setting_name, @@ -2047,6 +2073,7 @@ nm_device_ethernet_class_init(NMDeviceEthernetClass *klass) device_class->act_stage2_config = act_stage2_config; device_class->act_stage3_ip_config = act_stage3_ip_config; device_class->get_configured_mtu = get_configured_mtu; + device_class->get_ip_method_auto = get_ip_method_auto; device_class->deactivate = deactivate; device_class->get_s390_subchannels = get_s390_subchannels; device_class->update_connection = update_connection; |