Skip to content

Commit

Permalink
[traceflow] Use random port when UDP source port is 0 (#4963)
Browse files Browse the repository at this point in the history
Signed-off-by: gran <gran@vmware.com>
  • Loading branch information
gran-vmv committed May 11, 2023
1 parent ddc8850 commit ca80de3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/agent/openflow/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -1096,8 +1096,13 @@ func (c *client) SendTraceflowPacket(dataplaneTag uint8, packet *binding.Packet,
} else {
packetOutBuilder = packetOutBuilder.SetIPProtocol(binding.ProtocolUDP)
}
udpSrcPort := packet.SourcePort
if udpSrcPort == 0 {
// #nosec G404: random number generator not used for security purposes.
udpSrcPort = uint16(rand.Uint32())
}
packetOutBuilder = packetOutBuilder.SetUDPDstPort(packet.DestinationPort).
SetUDPSrcPort(packet.SourcePort)
SetUDPSrcPort(udpSrcPort)
default:
packetOutBuilder = packetOutBuilder.SetIPProtocolValue(packet.IsIPv6, packet.IPProto)
}
Expand Down

0 comments on commit ca80de3

Please sign in to comment.