mirror of
https://github.com/mirage/qubes-mirage-firewall.git
synced 2024-10-01 01:05:39 -04:00
My_nat.free_udp_port: avoid looping forever, use last_resort_port earlier
This commit is contained in:
parent
d094b20950
commit
e8e03fe6a6
@ -44,7 +44,10 @@ let pick_free_port t proto =
|
|||||||
go 10
|
go 10
|
||||||
|
|
||||||
let free_udp_port t ~src ~dst ~dst_port =
|
let free_udp_port t ~src ~dst ~dst_port =
|
||||||
let rec go () =
|
let rec go retries =
|
||||||
|
if retries = 0 then
|
||||||
|
t.last_resort_port, Fun.id
|
||||||
|
else
|
||||||
let src_port =
|
let src_port =
|
||||||
Option.value ~default:t.last_resort_port (pick_free_port t `Udp)
|
Option.value ~default:t.last_resort_port (pick_free_port t `Udp)
|
||||||
in
|
in
|
||||||
@ -57,9 +60,9 @@ let free_udp_port t ~src ~dst ~dst_port =
|
|||||||
in
|
in
|
||||||
src_port, remove
|
src_port, remove
|
||||||
end else
|
end else
|
||||||
go ()
|
go (retries - 1)
|
||||||
in
|
in
|
||||||
go ()
|
go 10
|
||||||
|
|
||||||
let dns_port t port = S.mem port t.udp_dns || port = t.last_resort_port
|
let dns_port t port = S.mem port t.udp_dns || port = t.last_resort_port
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user