Skip to content

Commit 6ba0653

Browse files
authored
CA-417020: DNS not cleared after reconfiguring to static IP without DNS (#6707)
2 parents 2b735a2 + 3cf2088 commit 6ba0653

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

ocaml/networkd/bin/network_server.ml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -737,11 +737,21 @@ module Interface = struct
737737
) ) ->
738738
update_config name c ;
739739
exec (fun () ->
740-
(* Old configs used empty dns lists to mean none, keep that
741-
behaviour instead of writing an empty resolv.conf *)
742740
match dns with
743-
| None | Some ([], []) ->
741+
| None ->
744742
()
743+
| Some ([], []) -> (
744+
match (ipv4_conf, ipv6_conf) with
745+
| Static4 _, _ | _, Static6 _ | _, Autoconf6 ->
746+
(* clear DNS for Static mode *)
747+
set_dns () dbg ~name ~nameservers:[] ~domains:[]
748+
| _ ->
749+
(* networkd.db in v25.28.0 and before stores empty
750+
dns lists for DHCP mode, this case is to keep
751+
resolv.conf intact when Toolstack update from
752+
version earlier than v25.28.0 *)
753+
()
754+
)
745755
| Some (nameservers, domains) ->
746756
set_dns () dbg ~name ~nameservers ~domains
747757
) ;

ocaml/xapi/nm.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,8 +638,10 @@ let bring_pif_up ~__context ?(management_interface = false) (pif : API.ref_PIF)
638638
in
639639
let dns =
640640
match (static, rc.API.pIF_DNS) with
641-
| false, _ | true, "" ->
641+
| false, _ ->
642642
None
643+
| true, "" ->
644+
Some ([], [])
643645
| true, pif_dns ->
644646
let nameservers =
645647
List.map Unix.inet_addr_of_string

0 commit comments

Comments
 (0)