chenBright opened a new pull request, #3350:
URL: https://github.com/apache/brpc/pull/3350

   ### What problem does this PR solve?
   
   Issue Number: resolve 
   
   Problem Summary:
   
   When an RDMA-enabled client connects to a server that supports TCP only,
   the client sends its handshake hello ("RDMA"/"RDM3" magic + body) and
   then blocks waiting for the server hello. The server does not recognize 
those 
   leading bytes as any known protocol and simply closes the connection, so the 
   client only sees EOF on the socket and has no signal to downgrade to TCP. 
   
   ### What is changed and the side effects?
   
   Changed:
   
   A new server-side-only pseudo-protocol `PROTOCOL_RDMA_HANDSHAKE` 
   (registered ahead of `PROTOCOL_HTTP` so the protocol selector tries it 
first) 
   implements a tiny handshake state machine:
   
   1. **Detect**: If the first 4 bytes are "RDMA" or "RDM3", enter the fallback 
path; 
       otherwise return `TRY_OTHERS` and let normal protocol parsing continue.
   
   2. **Drain client hello**: Read and drain the full v2 or v3 hello.
   
   3. **Reply an un-negotiable hello:** 
     - v2: well-formed framing (correct magic + msg_len) but `hello_ver = 
0xFFFF`, 
        which makes the client's `ValidHelloMessage()` fail.
     - v3: a RdmaHello protobuf that parses cleanly (all required fields set) 
but fails 
        `ValidRdmaHello()` because `block_size = 0 < MIN_BLOCK_SIZE` and 
`qp_num = 0`. 
     - In both cases the client sets `negotiated = false` and downgrades to TCP 
on the 
        same connection rather than erroring at the IO layer.
   
   4. **Drain the client ACK**: A per-socket parsing context records that we 
are now 
       expecting the 4B handshake ACK; the next call drops those bytes, clears 
the context, 
       and returns `TRY_OTHERS` so the subsequent real RPC payload goes through 
normal parsing.
   
   Side effects:
   - Performance effects:
   
   - Breaking backward compatibility: 
   
   ---
   ### Check List:
   - Please make sure your changes are compilable.
   - When providing us with a new feature, it is best to add related tests.
   - Please follow [Contributor Covenant Code of 
Conduct](https://github.com/apache/brpc/blob/master/CODE_OF_CONDUCT.md).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to