Skip to content

Commit cc4c324

Browse files
committed
Call firewall-port in IPv6 when management is in IPv6
Signed-off-by: Benjamin Reis <[email protected]>
1 parent fd5faa0 commit cc4c324

File tree

5 files changed

+52
-10
lines changed

5 files changed

+52
-10
lines changed

ocaml/xapi/dbsync_slave.ml

+8-1
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,15 @@ let refresh_localhost_info ~__context info =
126126
) else
127127
Db.Host.remove_from_other_config ~__context ~self:host
128128
~key:Xapi_globs.host_no_local_storage ;
129+
let options =
130+
match Helpers.get_management_iface_primary_address_type with
131+
| `IPv4 ->
132+
["check"; "80"]
133+
| `IPv6 ->
134+
["-6"; "check"; "80"]
135+
in
129136
let script_output =
130-
Helpers.call_script !Xapi_globs.firewall_port_config_script ["check"; "80"]
137+
Helpers.call_script !Xapi_globs.firewall_port_config_script options
131138
in
132139
try
133140
let network_state = Scanf.sscanf script_output "Port 80 open: %B" Fun.id in

ocaml/xapi/helpers.ml

+4
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,10 @@ let get_localhost ~__context =
165165
| true ->
166166
get_localhost_uncached ~__context
167167

168+
let get_management_iface_primary_address_type =
169+
Record_util.primary_address_type_of_string
170+
(Xapi_inventory.lookup Xapi_inventory._management_address_type)
171+
168172
(* Determine the gateway and DNS PIFs:
169173
* If one of the PIFs with IP has other_config:defaultroute=true, then
170174
* pick this one as gateway PIF. If there are multiple, pick a random one of these.

ocaml/xapi/nm.ml

+16-2
Original file line numberDiff line numberDiff line change
@@ -796,10 +796,17 @@ let bring_pif_up ~__context ?(management_interface = false) (pif : API.ref_PIF)
796796
| `vxlan ->
797797
debug
798798
"Opening VxLAN UDP port for tunnel with protocol 'vxlan'" ;
799+
let options =
800+
match Helpers.get_management_iface_primary_address_type with
801+
| `IPv4 ->
802+
["open"; "4789"; "udp"]
803+
| `IPv6 ->
804+
["-6"; "open"; "4789"; "udp"]
805+
in
799806
ignore
800807
@@ Helpers.call_script
801808
!Xapi_globs.firewall_port_config_script
802-
["open"; "4789"; "udp"]
809+
options
803810
| `gre ->
804811
()
805812
)
@@ -857,10 +864,17 @@ let bring_pif_down ~__context ?(force = false) (pif : API.ref_PIF) =
857864
in
858865
if no_more_vxlan then (
859866
debug "Last VxLAN tunnel was closed, closing VxLAN UDP port" ;
867+
let options =
868+
match Helpers.get_management_iface_primary_address_type with
869+
| `IPv4 ->
870+
["close"; "4789"; "udp"]
871+
| `IPv6 ->
872+
["-6"; "close"; "4789"; "udp"]
873+
in
860874
ignore
861875
@@ Helpers.call_script
862876
!Xapi_globs.firewall_port_config_script
863-
["close"; "4789"; "udp"]
877+
options
864878
)
865879
| `gre ->
866880
()

ocaml/xapi/xapi_clustering.ml

+16-4
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,16 @@ module Daemon = struct
274274
raise Api_errors.(Server_error (not_implemented, ["Cluster.create"]))
275275
) ;
276276
( try
277+
let options =
278+
match Helpers.get_management_iface_primary_address_type with
279+
| `IPv4 ->
280+
["open"; port]
281+
| `IPv6 ->
282+
["-6"; "open"; port]
283+
in
277284
maybe_call_script ~__context
278285
!Xapi_globs.firewall_port_config_script
279-
["open"; port] ;
286+
options ;
280287
maybe_call_script ~__context !Xapi_globs.systemctl ["enable"; service] ;
281288
maybe_call_script ~__context !Xapi_globs.systemctl ["start"; service]
282289
with _ ->
@@ -295,9 +302,14 @@ module Daemon = struct
295302
Atomic.set enabled false ;
296303
maybe_call_script ~__context !Xapi_globs.systemctl ["disable"; service] ;
297304
maybe_call_script ~__context !Xapi_globs.systemctl ["stop"; service] ;
298-
maybe_call_script ~__context
299-
!Xapi_globs.firewall_port_config_script
300-
["close"; port] ;
305+
let options =
306+
match Helpers.get_management_iface_primary_address_type with
307+
| `IPv4 ->
308+
["close"; port]
309+
| `IPv6 ->
310+
["-6"; "close"; port]
311+
in
312+
maybe_call_script ~__context !Xapi_globs.firewall_port_config_script options ;
301313
debug "Cluster daemon: disabled & stopped"
302314

303315
let restart ~__context =

ocaml/xapi/xapi_host.ml

+8-3
Original file line numberDiff line numberDiff line change
@@ -3045,10 +3045,15 @@ let set_https_only ~__context ~self ~value =
30453045
let state = match value with true -> "close" | false -> "open" in
30463046
match cc_prep () with
30473047
| false ->
3048+
let options =
3049+
match Helpers.get_management_iface_primary_address_type with
3050+
| `IPv4 ->
3051+
[state; "80"]
3052+
| `IPv6 ->
3053+
["-6"; state; "80"]
3054+
in
30483055
ignore
3049-
@@ Helpers.call_script
3050-
!Xapi_globs.firewall_port_config_script
3051-
[state; "80"] ;
3056+
@@ Helpers.call_script !Xapi_globs.firewall_port_config_script options ;
30523057
Db.Host.set_https_only ~__context ~self ~value
30533058
| true when value = Db.Host.get_https_only ~__context ~self ->
30543059
(* the new value is the same as the old value *)

0 commit comments

Comments
 (0)