diff --git a/tstest/tailmac/Swift/Common/TailMacConfigHelper.swift b/tstest/tailmac/Swift/Common/TailMacConfigHelper.swift index 796adf1cb..6c1db77fc 100644 --- a/tstest/tailmac/Swift/Common/TailMacConfigHelper.swift +++ b/tstest/tailmac/Swift/Common/TailMacConfigHelper.swift @@ -125,42 +125,11 @@ struct TailMacConfigHelper { print("Virtual if mac address is \(config.mac)") print("Client bound to \(clientSocket)") print("Connected to server at \(serverSocket)") + print("Socket fd is \(socket)") - // Use a socketpair between VZ and the relay. VZ reads/writes one end; - // background threads relay between the other end and the vnet dgram socket. - // This is more reliable than giving VZ the dgram socket directly. - var spFds: [Int32] = [0, 0] - guard socketpair(AF_UNIX, SOCK_DGRAM, 0, &spFds) == 0 else { - print("socketpair failed: \(String(cString: strerror(errno)))") - return networkDevice - } - let vzFd = spFds[0] - let relayFd = spFds[1] - - let vzHandle = FileHandle(fileDescriptor: vzFd) - let device = VZFileHandleNetworkDeviceAttachment(fileHandle: vzHandle) + let handle = FileHandle(fileDescriptor: socket) + let device = VZFileHandleNetworkDeviceAttachment(fileHandle: handle) networkDevice.attachment = device - - // Relay: guest→network (read from relayFd, write to dgram socket) - DispatchQueue.global().async { - var buf = [UInt8](repeating: 0, count: 65536) - while true { - let n = Darwin.read(relayFd, &buf, buf.count) - if n <= 0 { break } - Darwin.write(socket, buf, n) - } - } - - // Relay: network→guest (read from dgram socket, write to relayFd) - DispatchQueue.global().async { - var buf = [UInt8](repeating: 0, count: 65536) - while true { - let n = Darwin.read(socket, &buf, buf.count) - if n <= 0 { break } - Darwin.write(relayFd, buf, n) - } - } - return networkDevice }