Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable IPv4/IPv6 forwarding on demand automatically #5833

Merged
merged 1 commit into from
Jan 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions pkg/agent/route/route_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,17 @@ func (c *Client) Initialize(nodeConfig *config.NodeConfig, done func()) error {
return fmt.Errorf("failed to initialize ip routes: %v", err)
}

// Ensure IPv4 forwarding is enabled if it is a dual-stack or IPv4-only cluster.
if c.nodeConfig.NodeIPv4Addr != nil {
if err := sysctl.EnsureSysctlNetValue("ipv4/ip_forward", 1); err != nil {
return fmt.Errorf("failed to enable IPv4 forwarding: %w", err)
}
}

// Ensure IPv6 forwarding is enabled if it is a dual-stack or IPv6-only cluster.
if c.nodeConfig.NodeIPv6Addr != nil {
sysctlFilename := "ipv6/conf/all/forwarding"
v, err := sysctl.GetSysctlNet(sysctlFilename)
if err != nil {
return fmt.Errorf("failed to read value of sysctl file: %s", sysctlFilename)
}
if v != 1 {
return fmt.Errorf("IPv6 forwarding is not enabled")
if err := sysctl.EnsureSysctlNetValue("ipv6/conf/all/forwarding", 1); err != nil {
return fmt.Errorf("failed to enable IPv6 forwarding: %w", err)
}
}

Expand Down
Loading