Skip to content

Commit 0a4d149

Browse files
committed
Fix Traceflow with WireGuard enabled
WireGuard uses direct routing for same-subnet traffic similar to hybrid mode, but Traceflow was not checking for WireGuard mode when determining packet actions and forwarding behavior. This commit adds WireGuard mode checks in the Traceflow packet parsing and flow generation logic to correctly handle packets when WireGuard encryption is enabled. Signed-off-by: xliuxu <[email protected]>
1 parent 4fabbfb commit 0a4d149

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

pkg/agent/controller/traceflow/packetin.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,10 @@ func (c *Controller) parsePacketIn(pktIn *ofctrl.PacketIn) (*crdv1beta1.Traceflo
349349
}
350350

351351
ob.Action = crdv1beta1.ActionForwardedOutOfNetwork
352-
if c.networkConfig.TrafficEncapMode == config.TrafficEncapModeHybrid && c.podSubnetChecker != nil {
352+
// In hybrid mode or WireGuard mode, packets to Pod IPs in the same subnet are forwarded
353+
// directly without encapsulation. Check if the destination is a Pod IP to determine
354+
// the correct action (Forwarded vs ForwardedOutOfNetwork).
355+
if (c.networkConfig.TrafficEncapMode == config.TrafficEncapModeHybrid || c.networkConfig.TrafficEncryptionMode == config.TrafficEncryptionModeWireGuard) && c.podSubnetChecker != nil {
353356
netAddrDst, _ := netip.AddrFromSlice(netIPDst)
354357
isPodIP, _ := c.podSubnetChecker.LookupIPInPodSubnets(netAddrDst)
355358
if isPodIP {

pkg/agent/openflow/pipeline.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -974,8 +974,10 @@ func (f *featurePodConnectivity) flowsToTrace(dataplaneTag uint8,
974974
return fb
975975
}
976976
// Output the packets if traffic mode is noEncap or hybrid.
977+
// Also include WireGuard mode since it uses direct routing (no encapsulation) for same-subnet
978+
// traffic, similar to noEncap/hybrid modes.
977979
ifSupportsNoEncap := func(fb binding.FlowBuilder) binding.FlowBuilder {
978-
if f.networkConfig.TrafficEncapMode.SupportsNoEncap() {
980+
if f.networkConfig.TrafficEncapMode.SupportsNoEncap() || f.networkConfig.TrafficEncryptionMode == config.TrafficEncryptionModeWireGuard {
979981
fb = fb.Action().OutputToRegField(TargetOFPortField)
980982
}
981983
return fb

0 commit comments

Comments
 (0)