When restoring the previous DNS proxy port, we check if the port is
already in-use. However, if the port we retreived from GetProxyPort
was previously set via SetProxyPort, then we want to use it
unconditionally. We rely on isStatic for this, as as static ports
cannot change and the open port may be open with SO_REUSEPORT (which
proxy.OpenLocalPorts() does not check). Restored ports never have
isStatic set to true, so this does retain the "open ports" check if
the port was restored.
In addition, when restoring ports we want to make sure
that previous calls to SetProxyPort are also not overwritten, thus
this commit also only restores the port if it wasn't explicitly set.
This is the same behavior we had previously, which did not check the
returned port of d.l7Proxy.GetProxyPort against the list of open
ports.
Fixes: d11e4d261279 ("proxy: Reuse proxy ports from datapath on restart")
When restoring the previous DNS proxy port, we check if the port is already in-use. However, if the port we retreived from
GetProxyPort
was previously set viaSetProxyPort
, then we want to use it unconditionally. We rely onisStatic
for this, as as static ports cannot change and the open port may be open withSO_REUSEPORT
(whichproxy.OpenLocalPorts()
does not check). Restored ports never haveisStatic
set to true, so this does retain the "open ports" check if the port was restored.In addition, when restoring ports we want to make sure that previous calls to
SetProxyPort
are also not overwritten, thus this commit also only restores the port if it wasn't explicitly set.This is the same behavior we had previously, which did not check the returned port of
d.l7Proxy.GetProxyPort
against the list of open ports.Fixes: d11e4d261279 ("proxy: Reuse proxy ports from datapath on restart")