fix(endpoint_manager): scope client_endpoints_ by service to prevent socket sharing (#899)#1026
Open
aki1770-del wants to merge 1 commit intoCOVESA:masterfrom
Open
Conversation
…socket sharing When two SOME/IP services are offered on the same remote address:port, find_remote_client() returns the existing endpoint created for the first service and registers it under the second service. The second service's configured local port is never opened; both SubscribeEventgroup messages are sent from the first service's socket. Root cause: client_endpoints_ is keyed by [addr][port][reliable][partition]. This key has no service dimension, so any two services sharing the same remote addr:port:partition triple collide in find_remote_client(), causing create_remote_client() to be skipped for the second service. Fix: add service_t as the outermost key of client_endpoints_t and update all six usage sites (find_remote_client, create_remote_client, clear_client_endpoints, print_status, log_client_states, resume). Each service now has an independent client endpoint even when the remote address:port matches, preserving existing partition-sharing behaviour for multiple instances of the same service. Fixes COVESA#899
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When two SOME/IP services are offered on the same remote address:port, a client subscribing to both services incorrectly shares a single UDP socket between them.
Root cause —
client_endpoints_inendpoint_manager_implis keyed by[remote_address][remote_port][reliable][partition_id]. Whenfind_remote_client()is called for a second service whose server endpoint shares address and port with the first, it finds the existing endpoint object and registers it under the second service.create_remote_client()is never called for the second service, so:SubscribeEventgroupmessages are sent from the first service's socket.Reported against v3.4.10 on Embedded Linux with two services (
0x9002,0x9003) both offered on UDP port35699— closes #899. Related to #380.Fix
Add
service_tas the outermost key ofclient_endpoints_t:Six usage sites updated:
find_remote_client,create_remote_client,clear_client_endpoints,print_status,log_client_states,resume.Partition-sharing behaviour preserved: existing logic that lets multiple instances of the same service share a client endpoint (via the partition key) is unaffected — the new outermost key is identical for same-service lookups.
Verification
After the fix,
client_endpoints_[0x9002][addr][35699][false][P0]andclient_endpoints_[0x9003][addr][35699][false][P0]are independent map entries. The second service falls through tocreate_remote_client()and obtains its own socket bound to its configured local port. Both subscription messages are sent from the correct per-service source ports.