[Utils] Add NetworkAddress abstraction for IPv6-safe address handling#20306
Merged
[Utils] Add NetworkAddress abstraction for IPv6-safe address handling#20306
NetworkAddress abstraction for IPv6-safe address handling#20306Conversation
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
NetworkAddress\ abstraction for IPv6-safe address handling
NetworkAddress\ abstraction for IPv6-safe address handlingNetworkAddress abstraction for IPv6-safe address handling
psaab
added a commit
to psaab/sglang
that referenced
this pull request
Mar 11, 2026
From PR sgl-project#20306 by hnyls2002. Introduces a frozen NetworkAddress dataclass in srt/utils/network.py to centralize all host:port operations (to_url, to_tcp, to_host_port_str, to_bind_tuple, parse, from_parts). Migrates server_args, data_parallel_controller, disaggregation connectors, shm_broadcast, mooncake_transfer_engine, and utils.py. Removes redundant configure_ipv6, maybe_wrap_ipv6_address, and format_tcp_address helpers. Adds comprehensive tests in test_network_address.py.
psaab
added a commit
to psaab/sglang
that referenced
this pull request
Mar 11, 2026
From PR sgl-project#20306 by hnyls2002. Introduces a frozen NetworkAddress dataclass in srt/utils/network.py to centralize all host:port operations (to_url, to_tcp, to_host_port_str, to_bind_tuple, parse, from_parts). Migrates server_args, data_parallel_controller, disaggregation connectors, shm_broadcast, mooncake_transfer_engine, and utils.py. Removes redundant configure_ipv6, maybe_wrap_ipv6_address, and format_tcp_address helpers. Adds comprehensive tests in test_network_address.py.
psaab
added a commit
to psaab/sglang
that referenced
this pull request
Mar 13, 2026
From PR sgl-project#20306 by hnyls2002. Introduces a frozen NetworkAddress dataclass in srt/utils/network.py to centralize all host:port operations (to_url, to_tcp, to_host_port_str, to_bind_tuple, parse, from_parts). Migrates server_args, data_parallel_controller, disaggregation connectors, shm_broadcast, mooncake_transfer_engine, and utils.py. Removes redundant configure_ipv6, maybe_wrap_ipv6_address, and format_tcp_address helpers. Adds comprehensive tests in test_network_address.py.
liubiyongge
pushed a commit
to liubiyongge/sglang
that referenced
this pull request
Mar 13, 2026
Wangzheee
pushed a commit
to Wangzheee/sglang
that referenced
this pull request
Mar 21, 2026
JustinTong0323
pushed a commit
to JustinTong0323/sglang
that referenced
this pull request
Apr 7, 2026
yhyang201
pushed a commit
to yhyang201/sglang
that referenced
this pull request
Apr 22, 2026
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.
Motivation
Preparing for IPv6 support (#19981). The codebase has scattered IPv6 handling —
configure_ipv6(),maybe_wrap_ipv6_address(),format_tcp_address(), manual.split(":")parsing, andis_valid_ipv6_address()checks at every call site. This PR introduces a singleNetworkAddressdataclass to centralize all host:port operations, then migrates existing callers as a first step.Modifications
New
srt/utils/network.pyNetworkAddress(host, port)frozen dataclass with.to_url(),.to_tcp(),.to_host_port_str(),.to_bind_tuple(),.parse(),.from_parts().is_ipv6/.familyproperties for automatic address family detectionwrap_ipv6()helper (internal use byget_zmq_socket_on_host)Migrate existing callers
server_args.py:url()usesNetworkAddress.to_url();PortArgs.init_new()replacesconfigure_ipv6()/.split(":")withNetworkAddress.parse()+.to_tcp()data_parallel_controller.py: 3-branch endpoint construction →NetworkAddress.parse()+ port offsetdisaggregation/{common,mooncake,mori}/conn.py: replaceis_valid_ipv6_address()+format_tcp_address()combos withNetworkAddressshm_broadcast.py: same pattern —NetworkAddressfor family detection +.to_tcp()mooncake_transfer_engine.py:maybe_wrap_ipv6_address()→NetworkAddress.to_host_port_str()utils.py:_prebind_listening_socketusesNetworkAddress.family/.to_bind_tuple()get_zmq_socket_on_host(): auto-wraps IPv6 + setszmq.IPV6flag internallyCleanup
configure_ipv6(),maybe_wrap_ipv6_address(),format_tcp_address()(zero remaining callers)is_valid_ipv6_addressimports from all migrated filesTests
test/registered/utils/test_network_address.pywith full coverage: IPv4, IPv6, hostname, parse/roundtrip, error cases,from_parts, immutabilitytest_server_args.py→test_network_address.py, update error message assertionsChecklist
NetworkAddress(registeredstage-a-cpu-only)PortArgs.init_new()andServerArgs.url()updated and passing