aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2023-11-07 13:50:15 +0000
committerMichael Brown <mcb30@ipxe.org>2023-11-07 13:51:16 +0000
commit595b1796f6dc980cf27ca3883cde3baa23655528 (patch)
treee00ed7398c4bc85b412fbfeb21f42161b33123cb
parent1bd01b761f1f33723f0b07d277863b3284dfe232 (diff)
downloadipxe-595b1796f6dc980cf27ca3883cde3baa23655528.zip
ipxe-595b1796f6dc980cf27ca3883cde3baa23655528.tar.gz
ipxe-595b1796f6dc980cf27ca3883cde3baa23655528.tar.bz2
[eapol] Limit number of EAPoL-Start packets transmitted per attempt
Signed-off-by: Michael Brown <mcb30@ipxe.org>
-rw-r--r--src/include/ipxe/eapol.h5
-rw-r--r--src/net/eapol.c8
2 files changed, 13 insertions, 0 deletions
diff --git a/src/include/ipxe/eapol.h b/src/include/ipxe/eapol.h
index d4ea392..dcf3929 100644
--- a/src/include/ipxe/eapol.h
+++ b/src/include/ipxe/eapol.h
@@ -42,11 +42,16 @@ struct eapol_supplicant {
struct eap_supplicant eap;
/** EAPoL-Start retransmission timer */
struct retry_timer timer;
+ /** EAPoL-Start transmission count */
+ unsigned int count;
};
/** Delay between EAPoL-Start packets */
#define EAPOL_START_INTERVAL ( 2 * TICKS_PER_SEC )
+/** Maximum number of EAPoL-Start packets to transmit */
+#define EAPOL_START_COUNT 3
+
/** An EAPoL handler */
struct eapol_handler {
/** Type */
diff --git a/src/net/eapol.c b/src/net/eapol.c
index ce7be55..8b09ca2 100644
--- a/src/net/eapol.c
+++ b/src/net/eapol.c
@@ -167,6 +167,7 @@ static int eapol_eap_rx ( struct eapol_supplicant *supplicant,
/* Delay EAPoL-Start until after next expected packet */
DBGC ( netdev, "EAPOL %s deferring Start\n", netdev->name );
start_timer_fixed ( &supplicant->timer, EAP_WAIT_TIMEOUT );
+ supplicant->count = 0;
}
drop:
@@ -250,6 +251,12 @@ static void eapol_expired ( struct retry_timer *timer, int fail __unused ) {
container_of ( timer, struct eapol_supplicant, timer );
struct net_device *netdev = supplicant->eap.netdev;
+ /* Stop transmitting after maximum number of attempts */
+ if ( supplicant->count++ >= EAPOL_START_COUNT ) {
+ DBGC ( netdev, "EAPOL %s giving up\n", netdev->name );
+ return;
+ }
+
/* Schedule next transmission */
start_timer_fixed ( timer, EAPOL_START_INTERVAL );
@@ -317,6 +324,7 @@ static void eapol_notify ( struct net_device *netdev, void *priv ) {
/* Otherwise, start sending EAPoL-Start */
start_timer_nodelay ( &supplicant->timer );
+ supplicant->count = 0;
DBGC ( netdev, "EAPOL %s starting up\n", netdev->name );
}