Skip to content

Commit 4adcda0

Browse files
committed
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>
1 parent ced57b0 commit 4adcda0

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
)
@@ -88,6 +90,14 @@ func (ctrl *KernelParamDefaultsController) getKernelParams() []*kernel.Param {
8890
},
8991
}
9092

93+
// block apid and trustd from the ephemeral port range
94+
res = append(res, []*kernel.Param{
95+
{
96+
Key: "proc.sys.net.ipv4.ip_local_reserved_ports",
97+
Value: fmt.Sprintf("%d,%d", constants.ApidPort, constants.TrustdPort),
98+
},
99+
}...)
100+
91101
if ctrl.V1Alpha1Mode != v1alpha1runtime.ModeContainer {
92102
res = append(res, []*kernel.Param{
93103
{

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)