@@ -161,8 +161,6 @@ struct
161161 );
162162 Lwt. return ()
163163
164- let max_vsock_header_length = 1024
165-
166164 let conn_read flow buf =
167165 Mux.Channel. read_into flow buf >> = function
168166 | Ok `Eof -> Lwt. fail End_of_file
@@ -179,12 +177,12 @@ struct
179177 let from_internet_buffer = Cstruct. create Constants. max_udp_length in
180178 (* We write to the internet using the from_vsock_buffer *)
181179 let from_vsock_buffer =
182- Cstruct. create (Constants. max_udp_length + max_vsock_header_length )
180+ Cstruct. create (Constants. max_udp_length + Forwarder.Frame.Udp. max_sizeof )
183181 in
184182 let handle fd =
185183 (* Construct the vsock header in a separate buffer but write the payload
186184 directly from the from_internet_buffer *)
187- let write_header_buffer = Cstruct. create max_vsock_header_length in
185+ let write_header_buffer = Cstruct. create Forwarder.Frame.Udp. max_sizeof in
188186 let write v buf (ip , port ) =
189187 let udp = Forwarder.Frame.Udp. ({
190188 ip; port;
@@ -309,6 +307,13 @@ struct
309307 Socket.Datagram.Udp. bind ~description (local_ip, local_port)
310308 >> = fun server ->
311309 t.server < - Some (`Udp server);
310+ (* Resolve the local port yet (the fds are already bound) *)
311+ t.local < - ( match t.local with
312+ | { Port. proto = `Udp ; port = 0 ; _ } ->
313+ let _, port = Socket.Datagram.Udp. getsockname server in
314+ { t.local with Port. port }
315+ | _ ->
316+ t.local );
312317 start_udp_proxy (to_string t) t.remote_port server
313318 > |= fun () ->
314319 Ok t
0 commit comments