Skip to content

Commit

Permalink
Iptables wait option (#289)
Browse files Browse the repository at this point in the history
  • Loading branch information
hsubramanianaks authored Jul 7, 2023
1 parent f55a535 commit f90eb41
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/common/IP/IPManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,9 @@ private void AddRoutingRules(IEnumerable<EndpointInfo> endpoints, CancellationTo
{
foreach (var portPair in endpoint.Ports)
{
rules.Add($"--table nat --append PREROUTING -p tcp --dst {endpoint.LocalIP} --dport {portPair.RemotePort} --jump DNAT --to-destination {endpoint.LocalIP}:{portPair.LocalPort}");
rules.Add($"--table nat --append OUTPUT -p tcp --dst {endpoint.LocalIP} --dport {portPair.RemotePort} --jump DNAT --to-destination {endpoint.LocalIP}:{portPair.LocalPort}");
// --wait -w [seconds] maximum wait to acquire xtables lock before give up
rules.Add($"--table nat --append PREROUTING -p tcp --dst {endpoint.LocalIP} --dport {portPair.RemotePort} --jump DNAT --to-destination {endpoint.LocalIP}:{portPair.LocalPort} --wait 30");
rules.Add($"--table nat --append OUTPUT -p tcp --dst {endpoint.LocalIP} --dport {portPair.RemotePort} --jump DNAT --to-destination {endpoint.LocalIP}:{portPair.LocalPort} --wait 30");
}
}

Expand Down Expand Up @@ -297,7 +298,7 @@ private void RemoveRoutingRules(CancellationToken cancellationToken, IPAddress[]
command: args,
logCallback: (line) => _log.Info(line),
envVariables: null,
timeout: TimeSpan.FromSeconds(10),
timeout: TimeSpan.FromSeconds(60), // increasing the timeout to match with iptables --wait time.
cancellationToken: cancellationToken,
out string output);

Expand Down

0 comments on commit f90eb41

Please sign in to comment.