device: set Ethernet MTU for PPPoE connections in stage2/config

Try to set the MTU of the parent Ethernet interface to match the
requested PPP MTU and MRU. This allows the negotiation of a PPP MTU
and MRU greater than 1492.
This commit is contained in:
Beniamino Galvani 2015-04-28 10:05:42 +02:00
parent 6fdfb03107
commit 1d3eff45d2

View file

@ -68,6 +68,7 @@ G_DEFINE_TYPE (NMDeviceEthernet, nm_device_ethernet, NM_TYPE_DEVICE)
#define WIRED_SECRETS_TRIES "wired-secrets-tries"
#define PPPOE_RECONNECT_DELAY 7
#define PPPOE_ENCAP_OVERHEAD 8 /* 2 bytes for PPP, 6 for PPPoE */
static NMSetting *device_get_setting (NMDevice *device, GType setting_type);
@ -1239,6 +1240,28 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
ret = NM_ACT_STAGE_RETURN_POSTPONE;
}
/* PPPoE setup */
if (nm_connection_is_type (nm_device_get_connection (device),
NM_SETTING_PPPOE_SETTING_NAME)) {
NMSettingPpp *s_ppp;
s_ppp = (NMSettingPpp *) device_get_setting (device, NM_TYPE_SETTING_PPP);
if (s_ppp) {
guint32 mtu = 0, mru = 0, mxu;
mtu = nm_setting_ppp_get_mtu (s_ppp);
mru = nm_setting_ppp_get_mru (s_ppp);
mxu = mru > mtu ? mru : mtu;
if (mxu) {
_LOGD (LOGD_PPP, "set MTU to %u (PPP interface MRU %u, MTU %u)",
mxu + PPPOE_ENCAP_OVERHEAD, mru, mtu);
nm_platform_link_set_mtu (NM_PLATFORM_GET,
nm_device_get_ifindex (device),
mxu + PPPOE_ENCAP_OVERHEAD);
}
}
}
return ret;
}