Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix network down up process #1030

Merged
merged 25 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
5058d3f
Disable DHCP timer when network goes down
bjsowa Sep 25, 2023
f5d8d98
Don't stop checking the Network Timer
bjsowa Sep 22, 2023
9132077
Fix network down when using RA
bjsowa Sep 25, 2023
9e17182
Merge branch 'main' into fix-network-down-up
Skptak Sep 26, 2023
3c69c91
Revert "Don't stop checking the Network Timer"
bjsowa Sep 22, 2023
0975315
Add vSetNotAllNetworksUp function
bjsowa Sep 27, 2023
07b23ea
Fix unit tests
bjsowa Sep 27, 2023
83a3d9e
Update comments
bjsowa Sep 27, 2023
4bb3d52
Store DHCPv4 socket locally for all endpoints
bjsowa Oct 5, 2023
6e7f2b9
Add vDHCPStop and vDHCPv6Stop functions
bjsowa Oct 5, 2023
47a5d02
Fix IP Utils tests
bjsowa Oct 5, 2023
6b304cd
Fix most of DHCP unit tests
bjsowa Oct 5, 2023
e0a861d
Fix formatting
bjsowa Oct 5, 2023
6408ee7
Merge branch 'main' into fix-network-down-up
bjsowa Oct 5, 2023
5a70705
Change vSetNotAllNetworksUp into a more generic vSetAllNetworksUp
bjsowa Oct 5, 2023
21ca710
Fix almost all of DHCP unit tests
bjsowa Oct 6, 2023
3f49d08
Fix formatting
bjsowa Oct 6, 2023
a645291
Add tests for vDHCPStop and vDHCPv6Stop functions
bjsowa Oct 6, 2023
04a6ad2
Fix formatting
bjsowa Oct 6, 2023
e9dddae
Merge branch 'main' into fix-network-down-up
tony-josi-aws Oct 9, 2023
f92294a
Remove redundant MISRA comment
bjsowa Oct 9, 2023
26ecb07
Set all fields of xAddress when binding DHCP socket
bjsowa Oct 9, 2023
cb86c13
Fix unit test coverage of prvCreateDHCPSocket
bjsowa Oct 9, 2023
65517de
Fix DHCP CBMC memory proof
tony-josi-aws Oct 10, 2023
919f450
Merge branch 'main' into fix-network-down-up
tony-josi-aws Oct 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions source/FreeRTOS_IP_Timers.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
#include "FreeRTOS_DNS.h"
/*-----------------------------------------------------------*/

/** @brief 'xAllNetworksUp' becomes pdTRUE as soon as all network interfaces have
* been initialised. */
/** @brief 'xAllNetworksUp' becomes pdTRUE when all network interfaces are initialised
* and becomes pdFALSE when any network interface goes down. */
/* MISRA Ref 8.9.1 [File scoped variables] */
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-89 */
/* coverity[misra_c_2012_rule_8_9_violation] */
Expand Down Expand Up @@ -604,3 +604,13 @@ void vIPSetARPResolutionTimerEnableState( BaseType_t xEnableState )

#endif /* ipconfigDNS_USE_CALLBACKS == 1 */
/*-----------------------------------------------------------*/

/**
* @brief Mark that at least one interface is down so that the 'xNetworkTimer' is checked.
* Whenever the timer expires, all interfaces that are down will get a new NetworkDown
* event.
*/
void vSetNotAllNetworksUp( void )
bjsowa marked this conversation as resolved.
Show resolved Hide resolved
{
xAllNetworksUp = pdFALSE;
}
20 changes: 19 additions & 1 deletion source/FreeRTOS_IP_Utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,22 @@ void prvProcessNetworkDownEvent( struct xNetworkInterface * pxInterface )
* treat network down as a "delivery problem" and flush the ARP cache for this
* interface. */
FreeRTOS_ClearARP( pxEndPoint );

#if ( ( ipconfigUSE_DHCP != 0 ) || ( ipconfigUSE_DHCPv6 != 0 ) )
if( END_POINT_USES_DHCP( pxEndPoint ) )
{
/* Stop the DHCP process for this end-point. */
vIPSetDHCP_RATimerEnableState( pxEndPoint, pdFALSE );
bjsowa marked this conversation as resolved.
Show resolved Hide resolved
}
#endif /* ( ( ipconfigUSE_DHCP != 0 ) || ( ipconfigUSE_DHCPv6 != 0 ) ) */

#if ( ( ipconfigUSE_RA != 0 ) && ( ipconfigUSE_IPv6 != 0 ) )
if( END_POINT_USES_RA( pxEndPoint ) )
{
/* Stop the RA/SLAAC process for this end-point. */
vIPSetDHCP_RATimerEnableState( pxEndPoint, pdFALSE );
}
#endif /* ( ( ipconfigUSE_RA != 0 ) && ( ipconfigUSE_IPv6 != 0 ) ) */
}

/* The network has been disconnected (or is being initialised for the first
Expand Down Expand Up @@ -936,7 +952,9 @@ void prvProcessNetworkDownEvent( struct xNetworkInterface * pxInterface )
}
else
{
/* Nothing to do. When the 'xNetworkTimer' expires, all interfaces
vSetNotAllNetworksUp();

/* Nothing else to do. When the 'xNetworkTimer' expires, all interfaces
* with bits.bInterfaceUp cleared will get a new 'eNetworkDownEvent' */
}
}
Expand Down
3 changes: 3 additions & 0 deletions source/include/FreeRTOS_IP_Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -882,6 +882,9 @@ BaseType_t xIsCallingFromIPTask( void );
/* Send the network-up event and start the ARP timer. */
void vIPNetworkUpCalls( struct xNetworkEndPoint * pxEndPoint );

/* Mark that at least one interface is down to trigger repeated NetworkDown events. */
void vSetNotAllNetworksUp( void );

/* *INDENT-OFF* */
#ifdef __cplusplus
} /* extern "C" */
Expand Down
12 changes: 12 additions & 0 deletions test/unit-test/FreeRTOS_IP_Utils/FreeRTOS_IP_Utils_utest.c
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,8 @@ void test_prvProcessNetworkDownEvent_Pass( void )

FreeRTOS_ClearARP_ExpectAnyArgs();

vIPSetDHCP_RATimerEnableState_Expect( &xEndPoint, pdFALSE );

vDHCPProcess_Expect( pdTRUE, &xEndPoint );

prvProcessNetworkDownEvent( &xInterfaces[ 0 ] );
Expand All @@ -497,6 +499,8 @@ void test_prvProcessNetworkDownEvent_Pass( void )

FreeRTOS_ClearARP_Expect( &xEndPoint );

vIPSetDHCP_RATimerEnableState_Expect( &xEndPoint, pdFALSE );

vDHCPProcess_Expect( pdTRUE, &xEndPoint );

prvProcessNetworkDownEvent( &xInterfaces[ 0 ] );
Expand Down Expand Up @@ -575,6 +579,10 @@ void test_prvProcessNetworkDownEvent_InterfaceInitFail( void )

FreeRTOS_ClearARP_ExpectAnyArgs();

vIPSetDHCP_RATimerEnableState_Expect( &xEndPoint, pdFALSE );

vSetNotAllNetworksUp_Expect();

prvProcessNetworkDownEvent( &xInterface );
}

Expand All @@ -601,6 +609,8 @@ void test_prvProcessNetworkDownEvent_PassDHCPv6( void )

FreeRTOS_ClearARP_ExpectAnyArgs();

vIPSetDHCP_RATimerEnableState_Expect( &xEndPoint, pdFALSE );

vDHCPv6Process_Expect( pdTRUE, &xEndPoint );

prvProcessNetworkDownEvent( &xInterface );
Expand Down Expand Up @@ -629,6 +639,8 @@ void test_prvProcessNetworkDownEvent_PassRA( void )

FreeRTOS_ClearARP_ExpectAnyArgs();

vIPSetDHCP_RATimerEnableState_Expect( &xEndPoint, pdFALSE );

vRAProcess_Expect( pdTRUE, &xEndPoint );

prvProcessNetworkDownEvent( &xInterface );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ void test_prvProcessNetworkDownEvent_Pass_DHCP_Enabled( void )

FreeRTOS_ClearARP_Expect( &xEndPoint );

vIPSetDHCP_RATimerEnableState_Expect( &xEndPoint, pdFALSE );

FreeRTOS_NextEndPoint_ExpectAndReturn( &xInterface, &xEndPoint, NULL );

xInterface.pfInitialise = xNetworkInterfaceInitialise_test;
Expand Down