Skip to content

Commit

Permalink
fix svc pipeline
Browse files Browse the repository at this point in the history
Signed-off-by: Hang Yan <[email protected]>
  • Loading branch information
hangyan committed Sep 24, 2024
1 parent 223bd5c commit 0183504
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions pkg/agent/openflow/packetcapture.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,39 @@ func (f *featurePacketCapture) genFlows(dataplaneTag uint8,
flowBuilder = flowBuilder.MatchDstIP(packet.DestinationIP)
}
} else {
// handle pod -> svc case:
// generate flows to endpoints.
for _, epPacket := range endpointPackets {
tmpFlowBuilder := ConntrackStateTable.ofTable.BuildFlow(priorityHigh).
Cookie(cookieID).
MatchInPort(ofPort).
MatchCTStateTrk(true).
Action().LoadRegMark(RewriteMACRegMark).
Action().LoadToRegField(PacketCaptureMark, tag).
SetHardTimeout(timeout).
Action().GotoStage(stagePreRouting)
Action().GotoStage(stageEgressSecurity)
tmpFlowBuilder.MatchDstIP(epPacket.DestinationIP)
flow := matchTransportHeader(packet, tmpFlowBuilder, endpointPackets).Done()
flows = append(flows, flow)
}

// capture the first tracked packet for svc.
for _, ipProtocol := range f.ipProtocols {
tmpFlowBuilder := ConntrackStateTable.ofTable.BuildFlow(priorityHigh).
Cookie(cookieID).
MatchInPort(ofPort).
MatchProtocol(ipProtocol).
MatchCTStateNew(true).
MatchCTStateTrk(true).
Action().LoadRegMark(RewriteMACRegMark).
Action().LoadToRegField(PacketCaptureMark, tag).
SetHardTimeout(timeout).
Action().GotoStage(stagePreRouting)
tmpFlowBuilder.MatchDstIP(packet.DestinationIP)
tmpFlowBuilder = matchTransportHeader(packet, tmpFlowBuilder, nil)
flows = append(flows, tmpFlowBuilder.Done())
}

}
} else {
flowBuilder = L2ForwardingCalcTable.ofTable.BuildFlow(priorityHigh).
Expand All @@ -142,25 +162,6 @@ func (f *featurePacketCapture) genFlows(dataplaneTag uint8,
}
}

// for sender only case, capture the first tracked packet for svc.
if senderOnly {
for _, ipProtocol := range f.ipProtocols {
tmpFlowBuilder := ConntrackStateTable.ofTable.BuildFlow(priorityHigh).
Cookie(cookieID).
MatchInPort(ofPort).
MatchProtocol(ipProtocol).
MatchCTStateNew(true).
MatchCTStateTrk(true).
Action().LoadRegMark(RewriteMACRegMark).
Action().LoadToRegField(PacketCaptureMark, tag).
SetHardTimeout(timeout).
Action().GotoStage(stagePreRouting)
tmpFlowBuilder.MatchDstIP(packet.DestinationIP)
tmpFlowBuilder = matchTransportHeader(packet, tmpFlowBuilder, nil)
flows = append(flows, tmpFlowBuilder.Done())
}
}

if flowBuilder != nil {
flow := matchTransportHeader(packet, flowBuilder, nil).Done()
flows = append(flows, flow)
Expand Down

0 comments on commit 0183504

Please sign in to comment.