Skip to content

common: harden IntrusiveList and migrate some extensions to it - #48997

Open
wbpcode wants to merge 1 commit into
envoyproxy:mainfrom
wbpcode:dev-intrusive-list-node-noncopyable
Open

wbpcode wants to merge 1 commit into
envoyproxy:mainfrom
wbpcode:dev-intrusive-list-node-noncopyable

Conversation

@wbpcode

@wbpcode wbpcode commented Nov 4, 2026

Copy link
Copy Markdown
Member

Commit Message: common: harden IntrusiveList and migrate some extensions to it
Additional Description:

This hardens the IntrusiveList added in #43967 and moves a first batch of non-core extensions to it. Core users (router, connection pools, codecs, HCM) stay on LinkedObject/std::list for now and will be migrated in follow-ups once this has been exercised.

IntrusiveList hardening:

  • IntrusiveListNode is now non-copyable and non-movable. Nodes are owned through unique_ptr and linked by address, so a copy or assignment of an inserted element previously aliased the list links and corrupted the owning list.
  • The node destructor asserts the node is no longer in a list.
  • push()/pushBack() ignore a null unique_ptr.
  • removeFromList() on a node that is not in a list is now an ENVOY_BUG that returns nullptr, instead of a debug-only assert followed by a null dereference in release builds.
  • Documented that next() must be saved before removing while iterating.

Migrated to IntrusiveList:

  • generic_proxy: ActiveStream list. Also drops the unused LinkedObject base from the generic_proxy router's UpstreamRequest, which is never placed in a list.
  • dubbo_proxy: ActiveMessage list.
  • rocketmq_proxy (contrib): ActiveMessage list.
  • sip_proxy (contrib): the TRA client's request and stream callback lists.

The filter chains in these extensions keep std::list iterators to resume iteration and are left unchanged.

Risk Level: Low
Testing: Unit tests added for the new IntrusiveList behavior; existing tests of the migrated extensions pass.
Docs Changes: N/A
Release Notes: N/A

Signed-off-by: wbpcode <wbphub@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain to block approval.

No open issues 🎉

What changed in this PR

Hardens the IntrusiveList introduced in #43967 and migrates selected non-core extensions to reduce per-item allocations. Core users and filter chains remain unchanged.

Changes:

  • Prevents node copying and moving, asserts safe destruction, handles null insertion and invalid removal, and documents removal during iteration.
  • Migrates generic proxy, Dubbo, RocketMQ, and SIP TRA lists; removes unused list inheritance from generic proxy upstream requests.
  • Adds hardening tests and adapts existing tests to the intrusive-list API.
File Description
test/​extensions/​filters/​network/​generic_proxy/​proxy_test.cc Updates active-stream access to use front().
test/​common/​common/​linked_object_test.cc Tests node ownership constraints and defensive behavior.
test/​common/​common/​BUILD Adds support for Envoy bug assertions in tests.
source/​extensions/​filters/​network/​generic_proxy/​router/​router.h Removes unused LinkedObject inheritance and include.
source/​extensions/​filters/​network/​generic_proxy/​router/​BUILD Removes the unused linked-object dependency.
source/​extensions/​filters/​network/​generic_proxy/​proxy.h Converts active streams to intrusive nodes and storage.
source/​extensions/​filters/​network/​generic_proxy/​proxy.cc Adapts stream insertion, removal, and access.
source/​extensions/​filters/​network/​dubbo_proxy/​conn_manager.h Converts active-message storage and its test accessor.
source/​extensions/​filters/​network/​dubbo_proxy/​conn_manager.cc Adapts message insertion and deferred removal.
source/​extensions/​filters/​network/​dubbo_proxy/​active_message.h Makes active messages intrusive-list nodes.
source/​common/​common/​linked_object.h Hardens node lifecycle, insertion, and removal.
contrib/​sip_proxy/​filters/​network/​source/​tra/​tra_impl.h Converts callback nodes, storage, and cleanup.
contrib/​sip_proxy/​filters/​network/​source/​tra/​tra_impl.cc Uses intrusive insertion for TRA callbacks.
contrib/​rocketmq_proxy/​filters/​network/​test/​router_test.cc Adapts message setup and access to the new API.
contrib/​rocketmq_proxy/​filters/​network/​source/​conn_manager.h Converts active-message storage and accessor.
contrib/​rocketmq_proxy/​filters/​network/​source/​conn_manager.cc Adapts message insertion, access, and removal.
contrib/​rocketmq_proxy/​filters/​network/​source/​active_message.h Makes active messages intrusive-list nodes.

Review effort: Balanced

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants