Skip to content

Commit 8edddaf

Browse files
smirashanduur
authored andcommitted
fix: reserve the apid and trustd ports from the ephemeral port range
The problem is that ports 50000 and 50001 are part of the ephemeral port range, so they might be occupied by outgoing connections before `apid`/`trustd` has a chance to bind to it. So ensure these two ports are always excluded from the ephemeral port range. Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com> (cherry picked from commit 4adcda0)
1 parent a0243ef commit 8edddaf

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

internal/app/machined/pkg/controllers/runtime/kernel_param_defaults.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package runtime
77
import (
88
"context"
99
"errors"
10+
"fmt"
1011
"os"
1112

1213
"github.com/cosi-project/runtime/pkg/controller"
@@ -15,6 +16,7 @@ import (
1516

1617
v1alpha1runtime "github.com/siderolabs/talos/internal/app/machined/pkg/runtime"
1718
"github.com/siderolabs/talos/pkg/kernel/kspp"
19+
"github.com/siderolabs/talos/pkg/machinery/constants"
1820
"github.com/siderolabs/talos/pkg/machinery/kernel"
1921
"github.com/siderolabs/talos/pkg/machinery/resources/runtime"
2022
)
@@ -80,6 +82,14 @@ func (ctrl *KernelParamDefaultsController) getKernelParams() []*kernel.Param {
8082
},
8183
}
8284

85+
// block apid and trustd from the ephemeral port range
86+
res = append(res, []*kernel.Param{
87+
{
88+
Key: "proc.sys.net.ipv4.ip_local_reserved_ports",
89+
Value: fmt.Sprintf("%d,%d", constants.ApidPort, constants.TrustdPort),
90+
},
91+
}...)
92+
8393
if ctrl.V1Alpha1Mode != v1alpha1runtime.ModeContainer {
8494
res = append(res, []*kernel.Param{
8595
{

internal/app/machined/pkg/controllers/runtime/kernel_param_defaults_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ func getParams(mode runtime.Mode) []*kernel.Param {
4848
Key: "proc.sys.vm.overcommit_memory",
4949
Value: "1",
5050
},
51+
{
52+
Key: "proc.sys.net.ipv4.ip_local_reserved_ports",
53+
Value: "50000,50001",
54+
},
5155
}
5256

5357
if mode != runtime.ModeContainer {

0 commit comments

Comments
 (0)