Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
f318a68
Unify transport handshakes on current upstream master
Spicy-cream Oct 9, 2026
d9fc07d
Merge current upstream master and preserve IPC V2 handshake compatibi…
Spicy-cream Oct 16, 2026
2e51361
Fix certificate name extraction with const OpenSSL accessors
Spicy-cream Oct 16, 2026
7ebd2f2
Merge pull request #75 from Spicy-cream/review/pr3535-sync-master-oct15
zchuango Oct 16, 2026
3da2dde
Merge current master and retain shared memory name validation
Spicy-cream Oct 19, 2026
d819d93
Merge pull request #79 from Spicy-cream/review/pr3535-shm-conflict-oct18
zchuango Oct 19, 2026
ebcb46d
Merge modular CMake master and preserve handshake proto generation
Spicy-cream Oct 20, 2026
29f3185
Merge pull request #82 from Spicy-cream/review/pr3535-cmake-conflict-…
zchuango Oct 20, 2026
03e1fba
Integrate URMA with the common transport handshake
Spicy-cream Oct 22, 2026
74facf5
Run Linux CI for transport handshake pull requests
Spicy-cream Oct 22, 2026
dc983e8
Fix URMA handshake fallback compatibility
Spicy-cream Oct 22, 2026
571fb20
Use nullptr and refresh URMA handshake factory tests
Spicy-cream Oct 22, 2026
9f4efc6
Test legacy URMA interoperability and final ACK handoff
Spicy-cream Oct 22, 2026
5323b4f
Fix URMA CQ callback lifetime during teardown
Spicy-cream Oct 22, 2026
91bf2d1
Simplify URMA documentation
Spicy-cream Oct 22, 2026
e894f75
Restore upstream CI and URMA documentation
Spicy-cream Oct 22, 2026
48640dc
Clarify URMA handshake comments and align local style
Spicy-cream Oct 23, 2026
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
2 changes: 1 addition & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,6 @@ filegroup(
srcs = glob([
"src/brpc/*.proto",
"src/brpc/policy/*.proto",
"src/brpc/rdma/*.proto",
"src/brpc/urma/*.proto",
]),
visibility = ["//visibility:public"],
Expand All @@ -543,6 +542,7 @@ brpc_proto_library(
)

URMA_SRC_PATTERNS = [
"src/brpc/handshake/urma_handshake.cpp",
"src/brpc/urma/*.cpp",
"src/brpc/urma/**/*.cpp",
]
Expand Down
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ JSON2PB_DIRS = src/json2pb
JSON2PB_SOURCES = $(foreach d,$(JSON2PB_DIRS),$(wildcard $(addprefix $(d)/*,$(SRCEXTS))))
JSON2PB_OBJS = $(addsuffix .o, $(basename $(JSON2PB_SOURCES)))

BRPC_DIRS = src/brpc src/brpc/details src/brpc/builtin src/brpc/policy src/brpc/policy/mysql src/brpc/rdma
BRPC_DIRS = src/brpc src/brpc/details src/brpc/builtin src/brpc/handshake src/brpc/policy src/brpc/policy/mysql src/brpc/rdma
ifeq ($(WITH_URMA),1)
BRPC_DIRS += src/brpc/urma
endif
Expand All @@ -214,7 +214,8 @@ ifeq ($(URMA_USE_MOCK),0)
BRPC_SOURCES_ALL := $(filter-out src/brpc/urma/mock_urma.cpp,$(BRPC_SOURCES_ALL))
endif
BRPC_SOURCES = $(filter-out $(THRIFT_SOURCES) $(EXCLUDE_SOURCES), $(BRPC_SOURCES_ALL))
BRPC_PROTOS = $(filter %.proto,$(BRPC_SOURCES))
# TCP-only servers also encode the disabled URMA Hello.
BRPC_PROTOS = $(sort $(filter %.proto,$(BRPC_SOURCES)) src/brpc/urma/urma_handshake.proto)
BRPC_CFAMILIES = $(filter-out %.proto %.pb.cc,$(BRPC_SOURCES))
BRPC_OBJS = $(BRPC_PROTOS:.proto=.pb.o) $(addsuffix .o, $(basename $(BRPC_CFAMILIES)))

Expand Down Expand Up @@ -312,6 +313,8 @@ output/bin:protoc-gen-mcpack
src/mcpack2pb/generator.o:src/mcpack2pb/generator.cpp src/idl_options.pb.h
$(CXX) -c $(HDRPATHS) $(CXXFLAGS) $< -o $@

src/brpc/handshake/urma_fallback_handshake.o src/brpc/handshake/urma_fallback_handshake.dbg.o: src/brpc/urma/urma_handshake.pb.h

%.o:%.cpp
@echo "> Compiling $@"
$(CXX) -c $(HDRPATHS) $(CXXFLAGS) $< -o $@
Expand Down
38 changes: 38 additions & 0 deletions docs/cn/handshake_common_design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# 公共传输握手

`AdapterTransport` 统一 RDMA、UBSHM 和 URMA 的握手入口。TCP 承担控制面,
升级成功后使用高速数据面,协商不可用时继续使用 TCP。

## 组件分工

| 组件 | 职责 |
| --- | --- |
| `AdapterTransport` | 持有 TCP 与候选 Transport,选择协议及数据面 |
| `HandshakeSession` | 编排客户端、服务端状态机和增量帧解析 |
| `HandshakeProtocol` | 编解码 hello、ACK 和扩展帧,处理版本兼容 |
| `HandshakeTransport` | 准备资源,执行升级、回退和失败清理 |
| 各传输的 Endpoint | 管理资源及数据收发 |

客户端在 TCP 建连后启动握手 bthread;服务端通过 `InputMessenger` 增量解析
hello、扩展字段和 ACK。ACK 不带 magic,服务端使用已选协议继续解析。

## 状态与回退

- `ESTABLISHED`:使用高速数据面,TCP 保留为控制连接;额外 TCP 业务数据按协议错误处理。
- `FALLBACK_TCP`:资源不可用或协商拒绝时释放升级资源,继续解析已缓存及后续 TCP 数据。
- `FAILED`:握手帧畸形或处理失败,清理资源并关闭连接。

终态以 release/acquire 顺序发布和读取。未收齐的帧返回 `NOT_ENOUGH_DATA`,
不消费输入;非握手 magic 返回 `TRY_OTHERS`。帧边界处理支持 TCP 分片和粘连。

## 协议与数据面衔接

- RDMA 保持既有 v2/v3 wire format、协议 ID 和注册名称。
- UBSHM 使用 v3 hello:64 字节 hello 后交换 4 字节网络序格式扩展,IPC 选择
`IPC_V2`,UBS 选择 `LEGACY_64`;格式一致后升级,ACK 为 4 字节。
- URMA 保持 v2 二进制和 v3 protobuf 格式;资源导入和收发信用由
`UrmaEndpoint` 管理,详见 [UrmaTransport](urma.md)。
- 激活数据面后,等待 TCP 握手解析退出再注册 URMA CQ 回调,避免两条输入路径并行解析。

测试覆盖分片与粘连、magic 分流、版本协商、终态发布、TCP 回退、
资源清理及各传输的数据面回归。
2 changes: 1 addition & 1 deletion src/brpc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ set(PROTO_FILES brpc/builtin_service.proto
brpc/policy/public_pbrpc_meta.proto
brpc/policy/sofa_pbrpc_meta.proto
brpc/proto_base.proto
brpc/rdma/rdma_handshake.proto
brpc/rdma_handshake.proto
brpc/rpc_dump.proto
brpc/rtmp.proto
brpc/span.proto
Expand Down
Loading
Loading