@@ -73,16 +73,16 @@ func init() {
73
73
Command = & cobra.Command {
74
74
Use : "packetcapture" ,
75
75
Short : "Start capture packets" ,
76
- Long : "Start capture packets on the target flow. " ,
76
+ Long : "Start capturing packets on the target flow" ,
77
77
Aliases : []string {"pc" , "packetcaptures" },
78
78
Example : packetCaptureExample ,
79
79
RunE : packetCaptureRunE ,
80
80
}
81
81
82
82
Command .Flags ().StringVarP (& option .source , "source" , "S" , "" , "source of the the PacketCapture: Namespace/Pod, Pod, or IP" )
83
83
Command .Flags ().StringVarP (& option .dest , "destination" , "D" , "" , "destination of the PacketCapture: Namespace/Pod, Pod, or IP" )
84
- Command .Flags ().Int32VarP (& option .number , "number" , "n" , 0 , "target packets number " )
85
- Command .Flags ().StringVarP (& option .flow , "flow" , "f" , "" , "specify the flow (packet headers) of the PacketCapture , including tcp_src, tcp_dst, udp_src, udp_dst" )
84
+ Command .Flags ().Int32VarP (& option .number , "number" , "n" , 0 , "target number of packets to capture, the capture will stop when it is reached " )
85
+ Command .Flags ().StringVarP (& option .flow , "flow" , "f" , "" , "specify the flow (packet headers) of the PacketCapture, including tcp_src, tcp_dst, udp_src, udp_dst" )
86
86
Command .Flags ().BoolVarP (& option .nowait , "nowait" , "" , false , "if set, command returns without retrieving results" )
87
87
Command .Flags ().StringVarP (& option .outputDir , "output-dir" , "o" , "." , "save the packets file to the target directory" )
88
88
}
@@ -155,7 +155,7 @@ func packetCaptureRunE(cmd *cobra.Command, args []string) error {
155
155
}
156
156
pc , err := newPacketCapture ()
157
157
if err != nil {
158
- return fmt .Errorf ("error when filling up PacketCapture config : %w" , err )
158
+ return fmt .Errorf ("error when constructing a PacketCapture CR : %w" , err )
159
159
}
160
160
createCtx , cancel := context .WithTimeout (context .Background (), 5 * time .Second )
161
161
defer cancel ()
@@ -172,7 +172,7 @@ func packetCaptureRunE(cmd *cobra.Command, args []string) error {
172
172
}()
173
173
174
174
if option .nowait {
175
- fmt .Fprintf (cmd .OutOrStdout (), "PacketCapture Name: %s\n " , pc .Name )
175
+ fmt .Fprintf (cmd .OutOrStdout (), "PacketCapture Name: %s\n " , pc .Name )
176
176
return nil
177
177
}
178
178
@@ -193,7 +193,7 @@ func packetCaptureRunE(cmd *cobra.Command, args []string) error {
193
193
})
194
194
195
195
if wait .Interrupted (err ) {
196
- err = errors .New ("timeout waiting for PacketCapture done " )
196
+ err = errors .New ("timeout while waiting for PacketCapture to complete " )
197
197
if latestPC == nil {
198
198
return err
199
199
}
@@ -206,7 +206,7 @@ func packetCaptureRunE(cmd *cobra.Command, args []string) error {
206
206
copier , _ := getCopier (cmd )
207
207
err = copier .CopyFromPod (context .TODO (), env .GetAntreaNamespace (), splits [0 ], "antrea-agent" , splits [1 ], option .outputDir )
208
208
if err == nil {
209
- fmt .Fprintf (cmd .OutOrStdout (), "Packet File : %s\n " , filepath .Join (option .outputDir , fileName ))
209
+ fmt .Fprintf (cmd .OutOrStdout (), "Captured packets file : %s\n " , filepath .Join (option .outputDir , fileName ))
210
210
}
211
211
return err
212
212
}
@@ -244,7 +244,7 @@ func getPCName(src, dest string) string {
244
244
}
245
245
246
246
func parseFlow () (* v1alpha1.Packet , error ) {
247
- cleanFlow := strings .ReplaceAll (option .flow , " " , "" )
247
+ trimFlow := strings .ReplaceAll (option .flow , " " , "" )
248
248
fields , err := getFlowFields (cleanFlow )
249
249
if err != nil {
250
250
return nil , fmt .Errorf ("error when parsing the flow: %w" , err )
@@ -272,7 +272,7 @@ func parseFlow() (*v1alpha1.Packet, error) {
272
272
pkt .TransportHeader .UDP .SrcPort = ptr .To (int32 (r ))
273
273
}
274
274
if r , ok := fields ["udp_dst" ]; ok {
275
- if pkt .TransportHeader .UDP ! = nil {
275
+ if pkt .TransportHeader .UDP = = nil {
276
276
pkt .TransportHeader .UDP = new (v1alpha1.UDPHeader )
277
277
}
278
278
pkt .TransportHeader .UDP .DstPort = ptr .To (int32 (r ))
0 commit comments