Skip to content

Commit 50d245c

Browse files
committed
Do not apply IPv6 config if IPv6 is disabled
Any exceptions from this were ignored anyway, but this again avoids scary messages in the logs. Signed-off-by: Rob Hoes <[email protected]>
1 parent c1bf225 commit 50d245c

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

lib/network_utils.ml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,13 @@ module Proc = struct
901901
let get_bond_links_up name =
902902
let statusses = get_bond_slave_info name "MII Status" in
903903
List.fold_left (fun x (_, y) -> x + (if y = "up" then 1 else 0)) 0 statusses
904+
905+
let get_ipv6_disabled () =
906+
try
907+
Unixext.string_of_file "/proc/sys/net/ipv6/conf/all/disable_ipv6"
908+
|> String.trim
909+
|> (=) "1"
910+
with _ -> false
904911
end
905912

906913
module Ovs = struct

networkd/network_server.ml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,9 @@ module Interface = struct
323323

324324
let set_ipv6_conf _ dbg ~name ~conf =
325325
Debug.with_thread_associated dbg (fun () ->
326+
if Proc.get_ipv6_disabled () then
327+
warn "Not configuring IPv6 address for %s (IPv6 is disabled)" name
328+
else begin
326329
debug "Configuring IPv6 address for %s: %s" name (conf |> Rpcmarshal.marshal typ_of_ipv6 |> Jsonrpc.to_string);
327330
update_config name {(get_config name) with ipv6_conf = conf};
328331
match conf with
@@ -371,6 +374,7 @@ module Interface = struct
371374
let add_addrs = Xapi_stdext_std.Listext.List.set_difference addrs cur_addrs in
372375
List.iter (Ip.del_ip_addr name) rm_addrs;
373376
List.iter (Ip.set_ip_addr name) add_addrs
377+
end
374378
) ()
375379

376380
let get_ipv6_gateway _ dbg ~name =
@@ -385,13 +389,17 @@ module Interface = struct
385389

386390
let set_ipv6_gateway _ dbg ~name ~address =
387391
Debug.with_thread_associated dbg (fun () ->
392+
if Proc.get_ipv6_disabled () then
393+
warn "Not configuring IPv6 gateway for %s (IPv6 is disabled)" name
394+
else begin
388395
debug "Configuring IPv6 gateway for %s: %s" name (Unix.string_of_inet_addr address);
389396
update_config name {(get_config name) with ipv6_gateway = Some address};
390397
if !config.gateway_interface = None || !config.gateway_interface = Some name then begin
391398
debug "%s is the default gateway interface" name;
392399
Ip.set_gateway name address
393400
end else
394401
debug "%s is NOT the default gateway interface" name
402+
end
395403
) ()
396404

397405
let set_ipv4_routes _ dbg ~name ~routes =

0 commit comments

Comments
 (0)