@@ -204,6 +204,126 @@ func TestAccumulate(t *testing.T) {
204
204
PktDrops : ebpf.BpfPktDropsT {Packets : 5 , Bytes : 1000 , LatestFlags : 1 },
205
205
},
206
206
},
207
+ }, {
208
+ name : "IPsec: missing + success" ,
209
+ inputFlow : ebpf.BpfFlowMetrics {Packets : 0x7 , Bytes : 0x22d , StartMonoTimeTs : 0x176a790b240b , EndMonoTimeTs : 0x176a792a755b , Flags : 1 },
210
+ inputAdditional : []ebpf.BpfAdditionalMetrics {
211
+ {
212
+ FlowEncrypted : false ,
213
+ FlowEncryptedRet : 0 ,
214
+ },
215
+ {
216
+ FlowEncrypted : true ,
217
+ FlowEncryptedRet : 0 ,
218
+ },
219
+ },
220
+ expected : BpfFlowContent {
221
+ BpfFlowMetrics : & ebpf.BpfFlowMetrics {Packets : 0x7 , Bytes : 0x22d , StartMonoTimeTs : 0x176a790b240b , EndMonoTimeTs : 0x176a792a755b , Flags : 1 },
222
+ AdditionalMetrics : & ebpf.BpfAdditionalMetrics {
223
+ FlowEncrypted : true ,
224
+ FlowEncryptedRet : 0 ,
225
+ },
226
+ },
227
+ }, {
228
+ name : "IPsec: success + missing" ,
229
+ inputFlow : ebpf.BpfFlowMetrics {Packets : 0x7 , Bytes : 0x22d , StartMonoTimeTs : 0x176a790b240b , EndMonoTimeTs : 0x176a792a755b , Flags : 1 },
230
+ inputAdditional : []ebpf.BpfAdditionalMetrics {
231
+ {
232
+ FlowEncrypted : true ,
233
+ FlowEncryptedRet : 0 ,
234
+ },
235
+ {
236
+ FlowEncrypted : false ,
237
+ FlowEncryptedRet : 0 ,
238
+ },
239
+ },
240
+ expected : BpfFlowContent {
241
+ BpfFlowMetrics : & ebpf.BpfFlowMetrics {Packets : 0x7 , Bytes : 0x22d , StartMonoTimeTs : 0x176a790b240b , EndMonoTimeTs : 0x176a792a755b , Flags : 1 },
242
+ AdditionalMetrics : & ebpf.BpfAdditionalMetrics {
243
+ FlowEncrypted : true ,
244
+ FlowEncryptedRet : 0 ,
245
+ },
246
+ },
247
+ }, {
248
+ name : "IPsec: missing + error" ,
249
+ inputFlow : ebpf.BpfFlowMetrics {Packets : 0x7 , Bytes : 0x22d , StartMonoTimeTs : 0x176a790b240b , EndMonoTimeTs : 0x176a792a755b , Flags : 1 },
250
+ inputAdditional : []ebpf.BpfAdditionalMetrics {
251
+ {
252
+ FlowEncrypted : false ,
253
+ FlowEncryptedRet : 0 ,
254
+ },
255
+ {
256
+ FlowEncrypted : false ,
257
+ FlowEncryptedRet : 2 ,
258
+ },
259
+ },
260
+ expected : BpfFlowContent {
261
+ BpfFlowMetrics : & ebpf.BpfFlowMetrics {Packets : 0x7 , Bytes : 0x22d , StartMonoTimeTs : 0x176a790b240b , EndMonoTimeTs : 0x176a792a755b , Flags : 1 },
262
+ AdditionalMetrics : & ebpf.BpfAdditionalMetrics {
263
+ FlowEncrypted : false ,
264
+ FlowEncryptedRet : 2 ,
265
+ },
266
+ },
267
+ }, {
268
+ name : "IPsec: error + missing" ,
269
+ inputFlow : ebpf.BpfFlowMetrics {Packets : 0x7 , Bytes : 0x22d , StartMonoTimeTs : 0x176a790b240b , EndMonoTimeTs : 0x176a792a755b , Flags : 1 },
270
+ inputAdditional : []ebpf.BpfAdditionalMetrics {
271
+ {
272
+ FlowEncrypted : false ,
273
+ FlowEncryptedRet : 2 ,
274
+ },
275
+ {
276
+ FlowEncrypted : false ,
277
+ FlowEncryptedRet : 0 ,
278
+ },
279
+ },
280
+ expected : BpfFlowContent {
281
+ BpfFlowMetrics : & ebpf.BpfFlowMetrics {Packets : 0x7 , Bytes : 0x22d , StartMonoTimeTs : 0x176a790b240b , EndMonoTimeTs : 0x176a792a755b , Flags : 1 },
282
+ AdditionalMetrics : & ebpf.BpfAdditionalMetrics {
283
+ FlowEncrypted : false ,
284
+ FlowEncryptedRet : 2 ,
285
+ },
286
+ },
287
+ }, {
288
+ name : "IPsec: success + error" ,
289
+ inputFlow : ebpf.BpfFlowMetrics {Packets : 0x7 , Bytes : 0x22d , StartMonoTimeTs : 0x176a790b240b , EndMonoTimeTs : 0x176a792a755b , Flags : 1 },
290
+ inputAdditional : []ebpf.BpfAdditionalMetrics {
291
+ {
292
+ FlowEncrypted : true ,
293
+ FlowEncryptedRet : 0 ,
294
+ },
295
+ {
296
+ FlowEncrypted : false ,
297
+ FlowEncryptedRet : 2 ,
298
+ },
299
+ },
300
+ expected : BpfFlowContent {
301
+ BpfFlowMetrics : & ebpf.BpfFlowMetrics {Packets : 0x7 , Bytes : 0x22d , StartMonoTimeTs : 0x176a790b240b , EndMonoTimeTs : 0x176a792a755b , Flags : 1 },
302
+ AdditionalMetrics : & ebpf.BpfAdditionalMetrics {
303
+ FlowEncrypted : false ,
304
+ FlowEncryptedRet : 2 ,
305
+ },
306
+ },
307
+ }, {
308
+ name : "IPsec: error + success" ,
309
+ inputFlow : ebpf.BpfFlowMetrics {Packets : 0x7 , Bytes : 0x22d , StartMonoTimeTs : 0x176a790b240b , EndMonoTimeTs : 0x176a792a755b , Flags : 1 },
310
+ inputAdditional : []ebpf.BpfAdditionalMetrics {
311
+ {
312
+ FlowEncrypted : false ,
313
+ FlowEncryptedRet : 2 ,
314
+ },
315
+ {
316
+ FlowEncrypted : true ,
317
+ FlowEncryptedRet : 0 ,
318
+ },
319
+ },
320
+ expected : BpfFlowContent {
321
+ BpfFlowMetrics : & ebpf.BpfFlowMetrics {Packets : 0x7 , Bytes : 0x22d , StartMonoTimeTs : 0x176a790b240b , EndMonoTimeTs : 0x176a792a755b , Flags : 1 },
322
+ AdditionalMetrics : & ebpf.BpfAdditionalMetrics {
323
+ FlowEncrypted : false ,
324
+ FlowEncryptedRet : 2 ,
325
+ },
326
+ },
207
327
}}
208
328
for i , tc := range tcs {
209
329
t .Run (fmt .Sprint (i ), func (t * testing.T ) {
0 commit comments