@@ -324,9 +324,15 @@ impl Server {
324324 self . listeners . write ( ) . unwrap ( ) . remove ( & addr)
325325 }
326326
327- // Preliminary work for PLAT-367
328- #[ allow( dead_code) ]
329- fn connection ( & self , enclave : VsockAddr , runner : VsockAddr ) -> Option < ConnectionInfo > {
327+ fn connection ( & self , enclave : VsockAddr , runner_port : u32 ) -> Option < ConnectionInfo > {
328+ // There's an interesting vsock bug. When a new connection is created to the enclave in
329+ // the `handle_request_accept` function (from `ConnectionKey::from_vsock_stream`), the
330+ // local cid is different from the cid received when inspecting `enclave: VsockStream`.
331+ // Locating the cid of the runner through the `get_local_cid` does give the same result.
332+ // When PLAT-288 lands, the cid may also here be retrieved through the open runner-enclave
333+ // connection
334+ let runner_cid = vsock:: get_local_cid ( ) . unwrap_or ( vsock:: VMADDR_CID_LOCAL ) ;
335+ let runner = VsockAddr :: new ( runner_cid, runner_port) ;
330336 let k = ConnectionKey :: from_addresses ( enclave, runner) ;
331337 self . connections
332338 . read ( )
@@ -451,9 +457,7 @@ impl Server {
451457 let enclave_addr = VsockAddr :: new ( enclave_cid, enclave_port) ;
452458 let response = if let Some ( runner_port) = runner_port {
453459 // We're looking for a Connection
454- let runner_cid: u32 = enclave. local ( ) . unwrap ( ) . parse ( ) . unwrap_or ( vsock:: VMADDR_CID_HYPERVISOR ) ;
455- let runner_addr = VsockAddr :: new ( runner_cid, runner_port) ;
456- if let Some ( connection) = self . connection ( enclave_addr, runner_addr) {
460+ if let Some ( connection) = self . connection ( enclave_addr, runner_port) {
457461 Response :: Info {
458462 local : connection. local . clone ( ) ,
459463 peer : Some ( connection. peer . clone ( ) ) ,
0 commit comments