]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[eapol] Limit number of EAPoL-Start packets transmitted per attempt 1073/head
authorMichael Brown <mcb30@ipxe.org>
Tue, 7 Nov 2023 13:50:15 +0000 (13:50 +0000)
committerMichael Brown <mcb30@ipxe.org>
Tue, 7 Nov 2023 13:51:16 +0000 (13:51 +0000)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/include/ipxe/eapol.h
src/net/eapol.c

index d4ea392089a8f87d6ac53291785b430a364bd81b..dcf392946eac5a9fc18f870073203ddcd9a424d2 100644 (file)
@@ -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 */
index ce7be55d5960e10c13da51b0127b3f17d59faa1b..8b09ca231bb0fe530d7f01a702a5d830d3077946 100644 (file)
@@ -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 );
 }