Skip to content

Commit c22a0e2

Browse files
committed
OCPBUGS-64771: Force Global IP forwarding for DPU host mode
Ensure DPU host nodes always use Global IP forwarding mode regardless of cluster-wide configuration. - Force ip_forwarding_mode="Global" for dpu-host mode - Add comprehensive test cases for IP forwarding behavior - Document DPU host IP forwarding requirements and rationale DPU hosts require IP forwarding enabled to allow traffic flow between management and data plane interfaces. This change ensures proper DPU operation even when cluster-wide IPForwarding is set to Restricted.
1 parent 05d6f46 commit c22a0e2

File tree

4 files changed

+109
-17
lines changed

4 files changed

+109
-17
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,9 @@ OVN-Kubernetes supports specialized hardware deployments such as DPU (Data Proce
167167
- Multi-network policies and admin network policies
168168
- Network segmentation features
169169

170-
This per-node feature enforcement is implemented through conditional logic in the startup scripts, allowing the same cluster configuration to work across heterogeneous node types. For detailed information about node modes and the technical implementation, see `docs/ovn_node_mode.md`.
170+
Additionally, **IP forwarding is always forced to Global mode** on DPU host nodes, regardless of the cluster-wide `IPForwarding` setting in `gatewayConfig`. This is required for DPU hosts to properly forward traffic across management and data plane interfaces.
171+
172+
This per-node feature enforcement is implemented through conditional logic in the startup scripts, allowing the same cluster configuration to work across heterogeneous node types. For detailed information about node modes, IP forwarding behavior, and the technical implementation, see `docs/ovn_node_mode.md`.
171173

172174
These configuration flags are only in the Operator configuration object.
173175

bindata/network/ovn-kubernetes/common/008-script-lib.yaml

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,9 @@ data:
548548
# enable multicast
549549
enable_multicast_flag="--enable-multicast"
550550

551+
# set ip_forwarding_mode to the value of IP_FORWARDING_MODE
552+
ip_forwarding_mode="{{.IP_FORWARDING_MODE}}"
553+
551554
# Use OVN_NODE_MODE environment variable, default to "full" if not set
552555
OVN_NODE_MODE=${OVN_NODE_MODE:-full}
553556
# We check only dpu-host mode and not smart-nic mode here as currently we do not support it yet
@@ -568,6 +571,28 @@ data:
568571

569572
# disable multi-external-gateway for dpu-host mode as it is not supported
570573
multi_external_gateway_enable_flag=""
574+
575+
# Force ip_forwarding_mode to Global for dpu-host mode.
576+
# DPU hosts require IP forwarding to be enabled at all times to allow proper
577+
# traffic flow between the host management interface and the DPU's data plane
578+
# interfaces. This overrides any cluster-wide IPForwarding configuration.
579+
# See docs/ovn_node_mode.md for more details.
580+
ip_forwarding_mode="Global"
581+
fi
582+
583+
# If IP Forwarding mode is global set it in the host here. IPv6 IP Forwarding shuld be
584+
# enabled for all interfaces at all times if cluster is configured as single stack IPv6
585+
# or dual stack. This will be taken care by ovn-kubernetes(ovn-org/ovn-kubernetes#4376).
586+
# Setting net.ipv6.conf.all.forwarding to '0' when ipForwarding is Restricted to make
587+
# sure IPv6 IP Forwarding is disabled when cluster is configured as single stack IPv4.
588+
ip_forwarding_flag=
589+
if [ ${ip_forwarding_mode} == "Global" ]; then
590+
sysctl -w net.ipv4.ip_forward=1
591+
sysctl -w net.ipv6.conf.all.forwarding=1
592+
else
593+
ip_forwarding_flag="--disable-forwarding"
594+
sysctl -w net.ipv4.ip_forward=0
595+
sysctl -w net.ipv6.conf.all.forwarding=0
571596
fi
572597

573598
if [ "{{.OVN_GATEWAY_MODE}}" == "shared" ]; then
@@ -653,21 +678,6 @@ data:
653678
dns_name_resolver_enabled_flag="--enable-dns-name-resolver"
654679
fi
655680

656-
# If IP Forwarding mode is global set it in the host here. IPv6 IP Forwarding shuld be
657-
# enabled for all interfaces at all times if cluster is configured as single stack IPv6
658-
# or dual stack. This will be taken care by ovn-kubernetes(ovn-org/ovn-kubernetes#4376).
659-
# Setting net.ipv6.conf.all.forwarding to '0' when ipForwarding is Restricted to make
660-
# sure IPv6 IP Forwarding is disabled when cluster is configured as single stack IPv4.
661-
ip_forwarding_flag=
662-
if [ "{{.IP_FORWARDING_MODE}}" == "Global" ]; then
663-
sysctl -w net.ipv4.ip_forward=1
664-
sysctl -w net.ipv6.conf.all.forwarding=1
665-
else
666-
ip_forwarding_flag="--disable-forwarding"
667-
sysctl -w net.ipv4.ip_forward=0
668-
sysctl -w net.ipv6.conf.all.forwarding=0
669-
fi
670-
671681
if [[ "{{.AdvertisedUDNIsolationMode}}" != "" ]]; then
672682
ovn_advertised_udn_isolation_mode_flag="--advertised-udn-isolation-mode={{.AdvertisedUDNIsolationMode}}"
673683
fi

docs/ovn_node_mode.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ This change introduces `OVN_NODE_MODE` as an environment variable injected into
2424
- `enable_multicast_flag=""` (disabled)
2525
- `egress_features_enable_flag=""` (egress IP and related features disabled)
2626
- `multi_external_gateway_enable_flag=""` (multi-external gateway disabled)
27+
- `ip_forwarding_mode="Global"` (forced to Global to allow traffic forwarding across interfaces)
2728
- Multi-network, network segmentation, and multi-network policy/admin network policy are gated and not enabled in this mode.
2829

2930
### Manifests
@@ -87,6 +88,24 @@ The following table shows how cluster-wide configuration translates to per-node
8788
- Correct multi-network enablement logic (OVN_MULTI_NETWORK_ENABLE or OVN_NETWORK_SEGMENTATION_ENABLE)
8889
- Tests verify both positive cases (features enabled in full mode) and negative cases (features disabled in DPU host mode).
8990

91+
### IP Forwarding Mode Behavior
92+
93+
IP forwarding configuration is handled differently based on the node mode:
94+
95+
#### Full Mode (default)
96+
- Respects the cluster-wide `IPForwarding` configuration from `gatewayConfig`
97+
- When set to `Global`: enables IP forwarding (`net.ipv4.ip_forward=1`, `net.ipv6.conf.all.forwarding=1`)
98+
- When set to `Restricted` or empty (default): disables IP forwarding and passes `--disable-forwarding` flag to ovnkube
99+
100+
#### DPU Host Mode
101+
- **Always forces IP forwarding to `Global` mode**, regardless of cluster-wide configuration
102+
- This is required for DPU hosts to properly forward traffic across management and data plane interfaces
103+
- The script automatically overrides `ip_forwarding_mode="Global"` when `OVN_NODE_MODE="dpu-host"`
104+
- System-level IP forwarding is enabled: `net.ipv4.ip_forward=1` and `net.ipv6.conf.all.forwarding=1`
105+
- The `--disable-forwarding` flag is never passed to ovnkube on DPU host nodes
106+
107+
**Rationale**: DPU hosts require IP forwarding to be enabled at all times to allow proper traffic flow between the host management interface and the DPU's data plane interfaces. Disabling IP forwarding on these nodes would break connectivity and prevent proper operation of the DPU hardware offload.
108+
90109
### Migration Notes
91110

92111
When upgrading clusters that previously relied on ConfigMap-based feature control:
@@ -95,6 +114,7 @@ When upgrading clusters that previously relied on ConfigMap-based feature contro
95114
2. The startup scripts (both node and control-plane) now contain the authoritative feature enablement logic
96115
3. Control-plane components automatically enable all features (always run in "full" mode)
97116
4. DPU host nodes will automatically have incompatible features disabled regardless of previous ConfigMap settings
98-
5. No manual intervention is required - the migration is handled automatically during the upgrade process
117+
5. DPU host nodes will have IP forwarding forced to Global mode regardless of the cluster-wide `IPForwarding` setting
118+
6. No manual intervention is required - the migration is handled automatically during the upgrade process
99119

100120

pkg/network/ovn_kubernetes_test.go

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4455,6 +4455,66 @@ func TestOVNKubernetesScriptLibCombined(t *testing.T) {
44554455
},
44564456
mustNotContain: []string{},
44574457
},
4458+
{
4459+
name: "dpu-host mode: IP forwarding forced to Global",
4460+
overrides: map[string]interface{}{
4461+
"OVN_NODE_MODE": "dpu-host",
4462+
"IP_FORWARDING_MODE": "", // Restricted/default
4463+
},
4464+
mustContain: []string{
4465+
"ip_forwarding_mode=\"Global\"",
4466+
"sysctl -w net.ipv4.ip_forward=1",
4467+
"sysctl -w net.ipv6.conf.all.forwarding=1",
4468+
},
4469+
mustNotContain: []string{
4470+
"ip_forwarding_flag=\"--disable-forwarding\"",
4471+
"sysctl -w net.ipv4.ip_forward=0",
4472+
"sysctl -w net.ipv6.conf.all.forwarding=0",
4473+
},
4474+
},
4475+
{
4476+
name: "dpu-host mode: IP forwarding Global even when template says Restricted",
4477+
overrides: map[string]interface{}{
4478+
"OVN_NODE_MODE": "dpu-host",
4479+
"IP_FORWARDING_MODE": "Restricted",
4480+
},
4481+
mustContain: []string{
4482+
"ip_forwarding_mode=\"Global\"",
4483+
"sysctl -w net.ipv4.ip_forward=1",
4484+
"sysctl -w net.ipv6.conf.all.forwarding=1",
4485+
},
4486+
mustNotContain: []string{
4487+
"ip_forwarding_flag=\"--disable-forwarding\"",
4488+
},
4489+
},
4490+
{
4491+
name: "full mode: IP forwarding Global when configured",
4492+
overrides: map[string]interface{}{
4493+
"OVN_NODE_MODE": "full",
4494+
"IP_FORWARDING_MODE": "Global",
4495+
},
4496+
mustContain: []string{
4497+
"ip_forwarding_mode=\"Global\"",
4498+
"sysctl -w net.ipv4.ip_forward=1",
4499+
"sysctl -w net.ipv6.conf.all.forwarding=1",
4500+
},
4501+
mustNotContain: []string{
4502+
"ip_forwarding_flag=\"--disable-forwarding\"",
4503+
},
4504+
},
4505+
{
4506+
name: "full mode: IP forwarding Restricted by default",
4507+
overrides: map[string]interface{}{
4508+
"OVN_NODE_MODE": "full",
4509+
"IP_FORWARDING_MODE": "",
4510+
},
4511+
mustContain: []string{
4512+
"ip_forwarding_flag=\"--disable-forwarding\"",
4513+
"sysctl -w net.ipv4.ip_forward=0",
4514+
"sysctl -w net.ipv6.conf.all.forwarding=0",
4515+
},
4516+
mustNotContain: []string{},
4517+
},
44584518
}
44594519

44604520
for _, tc := range testCases {

0 commit comments

Comments
 (0)