diff --git a/src/eap.c b/src/eap.c index 1f91c7a4..3facc5cc 100644 --- a/src/eap.c +++ b/src/eap.c @@ -31,6 +31,7 @@ #include "eap.h" +static uint32_t default_mtu; struct l_queue *eap_methods; struct eap_state { @@ -58,7 +59,7 @@ struct eap_state *eap_new(eap_tx_packet_func_t tx_packet, eap = l_new(struct eap_state, 1); eap->last_id = -1; - eap->mtu = 1024; + eap->mtu = default_mtu; eap->tx_packet = tx_packet; eap->complete = complete; @@ -504,10 +505,20 @@ static void __eap_method_disable(struct eap_method_desc *start, extern struct eap_method_desc __start___eap[]; extern struct eap_method_desc __stop___eap[]; -void eap_init(void) +void eap_init(uint32_t mtu) { eap_methods = l_queue_new(); __eap_method_enable(__start___eap, __stop___eap); + + /* + * RFC 3748, Section 3.1, [4], "Minimum MTU": + * EAP is capable of functioning on lower layers that + * provide an EAP MTU size of 1020 octets or greater. + */ + if (mtu == 0) + default_mtu = 1020; + else + default_mtu = mtu; } void eap_exit(void) diff --git a/src/eap.h b/src/eap.h index 5ff7e8c3..4c9d6f13 100644 --- a/src/eap.h +++ b/src/eap.h @@ -59,7 +59,7 @@ size_t eap_get_mtu(struct eap_state *eap); void eap_rx_packet(struct eap_state *eap, const uint8_t *pkt, size_t len); -void eap_init(void); +void eap_init(uint32_t default_mtu); void eap_exit(void); /* EAP method API */ diff --git a/src/eapol.c b/src/eapol.c index bb207db9..f61782c0 100644 --- a/src/eapol.c +++ b/src/eapol.c @@ -1642,8 +1642,6 @@ bool eapol_init() { state_machines = l_queue_new(); - eap_init(); - return true; } @@ -1654,7 +1652,5 @@ bool eapol_exit() l_queue_destroy(state_machines, eapol_sm_destroy); - eap_exit(); - return true; } diff --git a/src/main.c b/src/main.c index 693eaa76..a75b3a34 100644 --- a/src/main.c +++ b/src/main.c @@ -37,6 +37,7 @@ #include "src/wiphy.h" #include "src/dbus.h" #include "src/network.h" +#include "src/eap.h" #include "src/eapol.h" #include "src/scan.h" #include "src/wsc.h" @@ -145,6 +146,7 @@ int main(int argc, char *argv[]) struct l_genl *genl; struct l_genl_family *nl80211; char *config_path; + uint32_t eap_mtu; for (;;) { int opt; @@ -244,6 +246,10 @@ int main(int argc, char *argv[]) l_genl_family_set_watches(nl80211, nl80211_appeared, nl80211_vanished, nl80211, NULL); + if (!l_settings_get_uint(iwd_config, "EAP", "mtu", &eap_mtu)) + eap_mtu = 1400; /* on WiFi the real MTU is around 2304 */ + + eap_init(eap_mtu); eapol_init(); network_init(); known_networks_init(); @@ -256,6 +262,7 @@ int main(int argc, char *argv[]) known_networks_exit(); network_exit(); eapol_exit(); + eap_exit(); l_genl_family_unref(nl80211);