CHERIoT-Platform / network-stack

5 stars 1 forks source link

Three bug fixes in the TCP/IP stack. #15

Closed hlef closed 6 months ago

hlef commented 6 months ago

This PR fixes three issues in the TCP/IP stack:

hlef commented 6 months ago

Alright, I have tested the fix for the DHCP issue and everything is good now.

For the record, this patch to third_party/freertos-plus-tcp is sufficient to reliably trigger the DHCP lease renewal issue with a high rate in the demo:

diff --git a/source/FreeRTOS_DHCP.c b/source/FreeRTOS_DHCP.c
index 5ebeebc..632fd4d 100644
--- a/source/FreeRTOS_DHCP.c
+++ b/source/FreeRTOS_DHCP.c
@@ -1092,7 +1092,8 @@

                     /* The DHCP parameter is in seconds, convert
                      * to host-endian format. */
-                    EP_DHCPData.ulLeaseTime = FreeRTOS_ntohl( pxSet->ulParameter );
+                    //EP_DHCPData.ulLeaseTime = FreeRTOS_ntohl( pxSet->ulParameter );
+                    EP_DHCPData.ulLeaseTime = 10;

                     /* Divide the lease time by two to ensure a renew
                      * request is sent before the lease actually expires. */
diff --git a/source/include/FreeRTOS_DHCP.h b/source/include/FreeRTOS_DHCP.h
index 26fef7d..e0e6c7f 100644
--- a/source/include/FreeRTOS_DHCP.h
+++ b/source/include/FreeRTOS_DHCP.h
@@ -108,12 +108,10 @@
 //#define EP_DHCPData                     xDHCPData              /**< Temporary define to make /single source similar to /multi version. */
 //#define EP_IPv4_SETTINGS                xNetworkAddressing     /**< Temporary define to make /single source similar to /multi version. */

-/** @brief If a lease time is not received, use the default of two days (48 hours in ticks).
- * Can not use pdMS_TO_TICKS() as integer overflow can occur. */
-#define dhcpDEFAULT_LEASE_TIME          ( ( 48UL * 60UL * 60UL ) * configTICK_RATE_HZ )
+#define dhcpDEFAULT_LEASE_TIME          ( pdMS_TO_TICKS( 10000UL ) )       /* 10 seconds in ticks. */

 /** @brief Don't allow the lease time to be too short. */
-#define dhcpMINIMUM_LEASE_TIME          ( pdMS_TO_TICKS( 60000UL ) )            /* 60 seconds in ticks. */
+#define dhcpMINIMUM_LEASE_TIME          ( pdMS_TO_TICKS( 10000UL ) )            /* 10 seconds in ticks. */

 /** @brief Marks the end of the variable length options field in the DHCP packet. */
 #define dhcpOPTION_END_BYTE             0xffu