From b22d4130cbf708b7c57aba8d1b3b4bcdad0ee7a7 Mon Sep 17 00:00:00 2001 From: Tinic Uro Date: Thu, 1 Oct 2026 23:18:09 -0700 Subject: [PATCH 1/2] Fixed static-route compaction during interface detach Detaching an interface with a full static-route table read one entry past the array. The removal loop also skipped a route shifted into the current slot, leaving adjacent routes bound to the detached interface. Stop shifting at the last entry and recheck the current slot after removal. Extend the interface-detach regression to fill the table, remove adjacent routes, and verify that a route on the surviving interface remains. Clang C99 syntax checks passed for IPv4 and IPv6 variants. The Linux v4_full_build regression suite is selected by upstream CI. Assisted-by: Claude Code (Opus 5.5) Assisted-by: Codex (gpt-6.1-sol) --- common/src/nx_ip_interface_detach.c | 20 ++++++--- .../netx_ip_interface_detachment_test.c | 42 +++++++++++++++++++ 2 files changed, 56 insertions(+), 6 deletions(-) diff --git a/common/src/nx_ip_interface_detach.c b/common/src/nx_ip_interface_detach.c index 244832680..3c9d412fa 100644 --- a/common/src/nx_ip_interface_detach.c +++ b/common/src/nx_ip_interface_detach.c @@ -9,6 +9,8 @@ * SPDX-License-Identifier: MIT **************************************************************************/ +/* Portions of this file were generated with AI assistance. */ + /**************************************************************************/ /**************************************************************************/ @@ -144,7 +146,9 @@ NX_IPV6_DEFAULT_ROUTER_ENTRY *rt_entry; #ifndef NX_DISABLE_IPV4 #ifdef NX_ENABLE_IP_STATIC_ROUTING /* Remove router iterms associated with the interface that will be detached from route table. */ - for (i = 0; i < ip_ptr -> nx_ip_routing_table_entry_count; i++) + /* Stop at the last entry and recheck the slot after a removal, because + the next route has shifted into it. */ + for (i = 0; i < ip_ptr -> nx_ip_routing_table_entry_count; ) { /* Is this router iterm related to the interface to be detached. */ @@ -153,7 +157,7 @@ NX_IPV6_DEFAULT_ROUTER_ENTRY *rt_entry; /* Yes, we need to remove this iterm. */ /* If the entry is not the last one, we need to shift the table to fill the hole. */ - for (j = i; j < ip_ptr -> nx_ip_routing_table_entry_count; j++) + for (j = i; (j + 1) < ip_ptr -> nx_ip_routing_table_entry_count; j++) { ip_ptr -> nx_ip_routing_table[j].nx_ip_routing_dest_ip = ip_ptr -> nx_ip_routing_table[j + 1].nx_ip_routing_dest_ip; @@ -165,13 +169,17 @@ NX_IPV6_DEFAULT_ROUTER_ENTRY *rt_entry; ip_ptr -> nx_ip_routing_table[j + 1].nx_ip_routing_entry_ip_interface; } - ip_ptr -> nx_ip_routing_table[j - 1].nx_ip_routing_dest_ip = 0; - ip_ptr -> nx_ip_routing_table[j - 1].nx_ip_routing_net_mask = 0; - ip_ptr -> nx_ip_routing_table[j - 1].nx_ip_routing_next_hop_address = 0; - ip_ptr -> nx_ip_routing_table[j - 1].nx_ip_routing_entry_ip_interface = NX_NULL; + ip_ptr -> nx_ip_routing_table[j].nx_ip_routing_dest_ip = 0; + ip_ptr -> nx_ip_routing_table[j].nx_ip_routing_net_mask = 0; + ip_ptr -> nx_ip_routing_table[j].nx_ip_routing_next_hop_address = 0; + ip_ptr -> nx_ip_routing_table[j].nx_ip_routing_entry_ip_interface = NX_NULL; ip_ptr -> nx_ip_routing_table_entry_count--; } + else + { + i++; + } } #endif /* NX_ENABLE_IP_STATIC_ROUTING */ #endif /* !NX_DISABLE_IPV4 */ diff --git a/test/regression/netxduo_test/netx_ip_interface_detachment_test.c b/test/regression/netxduo_test/netx_ip_interface_detachment_test.c index 6f7b8d591..6afc57ce4 100644 --- a/test/regression/netxduo_test/netx_ip_interface_detachment_test.c +++ b/test/regression/netxduo_test/netx_ip_interface_detachment_test.c @@ -9,6 +9,8 @@ /* SPDX-License-Identifier: MIT */ /***************************************************************************/ +/* Portions of this file were generated with AI assistance. */ + #include "tx_api.h" @@ -294,14 +296,54 @@ static void ntest_1_entry(ULONG thread_input) { UINT status; +#ifdef NX_ENABLE_IP_STATIC_ROUTING +UINT route; +#endif tx_mutex_get(&mutex_0, TX_WAIT_FOREVER); +#ifdef NX_ENABLE_IP_STATIC_ROUTING + /* Fill the route table before detaching. Its original route uses the + second interface; keep one route through the primary interface, then + add adjacent second-interface routes. This exercises both the last + table entry and routes shifted into the slot being examined. */ + status = nx_ip_static_route_add(&ip_1, IP_ADDRESS(10, 1, 0, 0), + 0xFFFFFF00UL, IP_ADDRESS(1, 2, 3, 6)); + if (status != NX_SUCCESS) + { + error_counter++; + } + for (route = 2; route < NX_IP_ROUTING_TABLE_SIZE; route++) + { + status = nx_ip_static_route_add(&ip_1, IP_ADDRESS(10, route, 0, 0), + 0xFFFFFF00UL, IP_ADDRESS(4, 3, 2, 10)); + if (status != NX_SUCCESS) + { + error_counter++; + } + } + if (ip_1.nx_ip_routing_table_entry_count != NX_IP_ROUTING_TABLE_SIZE) + { + error_counter++; + } +#endif + /* Detach the 2nd interface(4.3.2.11) from IP instance1. */ status = nx_ip_interface_detach(&ip_1, 1); if(status) error_counter++; +#ifdef NX_ENABLE_IP_STATIC_ROUTING + /* Every route through the detached interface must be gone. The route + through the primary interface must survive in the compacted slot. */ + if ((ip_1.nx_ip_routing_table_entry_count != 1) || + (ip_1.nx_ip_routing_table[0].nx_ip_routing_dest_ip != IP_ADDRESS(10, 1, 0, 0)) || + (ip_1.nx_ip_routing_table[0].nx_ip_routing_entry_ip_interface != &ip_1.nx_ip_interface[0])) + { + error_counter++; + } +#endif + tx_mutex_put(&mutex_0); tx_thread_sleep(1); tx_mutex_get(&mutex_0, TX_WAIT_FOREVER); From 552a03e1bb0b8925adefb2173c228dc3eb1ad346 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Desbiens?= Date: Fri, 16 Oct 2026 17:28:01 -0400 Subject: [PATCH 2/2] Aligned AI disclosure markers in route detach files The two modified C files used block comments for their AI disclosure lines, which differed from the established single-line source header format. Placed the standard single-line marker directly below each license header. The routing logic and regression behavior are unchanged. The diff passed whitespace checks. No test suite was rerun for this comment-only change; the preceding PR head passed its full CI matrix. Assisted-by: Codex (GPT-6) --- common/src/nx_ip_interface_detach.c | 3 +-- .../netxduo_test/netx_ip_interface_detachment_test.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/common/src/nx_ip_interface_detach.c b/common/src/nx_ip_interface_detach.c index 3c9d412fa..c9ccbaedd 100644 --- a/common/src/nx_ip_interface_detach.c +++ b/common/src/nx_ip_interface_detach.c @@ -8,8 +8,7 @@ * * SPDX-License-Identifier: MIT **************************************************************************/ - -/* Portions of this file were generated with AI assistance. */ +// Portions of this file were generated with AI assistance. /**************************************************************************/ diff --git a/test/regression/netxduo_test/netx_ip_interface_detachment_test.c b/test/regression/netxduo_test/netx_ip_interface_detachment_test.c index 6afc57ce4..05ab1ceb2 100644 --- a/test/regression/netxduo_test/netx_ip_interface_detachment_test.c +++ b/test/regression/netxduo_test/netx_ip_interface_detachment_test.c @@ -8,8 +8,7 @@ /* */ /* SPDX-License-Identifier: MIT */ /***************************************************************************/ - -/* Portions of this file were generated with AI assistance. */ +// Portions of this file were generated with AI assistance.