File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -276,6 +276,22 @@ type ops = {
276276 domain_restore : Unix .file_descr -> int -> int -> int -> int -> int -> bool -> bool -> string ;
277277}
278278
279+ let tcp_keepcnt = 5
280+ let tcp_keepidle = 30
281+ let tcp_keepintvl = 2
282+
283+ (* CA-94829: Set the TCP keepalive options if it's a socket *)
284+ let fix_fd fd =
285+ let stats = Unix. fstat fd in
286+ if stats.Unix. st_kind = Unix. S_SOCK then begin
287+ Unix. setsockopt fd Unix. SO_KEEPALIVE true ;
288+ Unixext. set_sock_keepalives fd tcp_keepcnt tcp_keepidle tcp_keepintvl;
289+ debug " Set socket TCP keepalive values to TCP_KEEPCNT=%d TCP_KEEPIDLE=%d TCP_KEEPINTVL=%d" tcp_keepcnt tcp_keepidle tcp_keepintvl
290+ end else begin
291+ debug " Skipping TCP keepalive setting as fd is not a socket"
292+ end
293+
294+
279295(* main *)
280296let _ =
281297 (* Union of all the options required by all modes: *)
@@ -373,7 +389,7 @@ let _ =
373389 and domid = int_of_string (get_param " domid" )
374390 and flags = List. concat [ if has_param " live" then [ Xenguest. Live ] else [];
375391 if has_param " debug" then [ Xenguest. Debug ] else [] ] in
376-
392+ fix_fd fd;
377393 with_logging (fun () -> ops.domain_save fd domid 0 0 flags hvm)
378394 | Some " hvm_restore"
379395 | Some "restore" ->
@@ -387,7 +403,7 @@ let _ =
387403 and console_port = int_of_string (get_param " console_port" )
388404 and console_domid = int_of_string (get_param " console_domid" )
389405 and no_incr_generationid = bool_of_string (get_param " no_incr_generationid" ) in
390-
406+ fix_fd fd;
391407 with_logging (fun () -> ops.domain_restore fd domid store_port store_domid console_port console_domid hvm no_incr_generationid)
392408 | Some "linux_build" ->
393409 debug " linux_build mode selected" ;
You can’t perform that action at this time.
0 commit comments