Skip to content

Commit b200d87

Browse files
kumarvin123lakshk98
authored andcommitted
Removed usage of the hubble parser options
1 parent 8cab71d commit b200d87

4 files changed

Lines changed: 24 additions & 40 deletions

File tree

pkg/capture/file/timestamp.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,3 @@ func TimeToString(timestamp *metav1.Time) string {
3131
}
3232
return timestamp.UTC().Format(captureFileNameTimestampFormat)
3333
}
34-
35-
// TimeToString converts a Timestamp to a string in the capture file name format.
36-
func TimeToString(t Timestamp) string {
37-
return t.Time.UTC().Format(captureFileNameTimestampFormat)
38-
}

pkg/plugin/ebpfwindows/ebpf_windows.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,8 @@ func (p *Plugin) handleTraceEvent(data unsafe.Pointer, size uint32) error {
285285
if err != nil {
286286
return fmt.Errorf("could not convert dropnotify event to flow: %w", err)
287287
}
288-
meta := &utils.RetinaMetadata{}
289-
utils.AddPacketSize(meta, size-uint32(unsafe.Sizeof(DropNotify{})))
288+
ext := utils.NewExtensions()
289+
utils.AddPacketSize(ext, size-uint32(unsafe.Sizeof(DropNotify{})))
290290
fl := e.GetFlow()
291291
if fl == nil {
292292
return fmt.Errorf("%w", errNilDropNotifyFlow)
@@ -299,8 +299,8 @@ func (p *Plugin) handleTraceEvent(data unsafe.Pointer, size uint32) error {
299299
}
300300
// Set the drop reason.
301301
eventType := fl.GetEventType().GetSubType()
302-
meta.DropReason = utils.DropReason(eventType)
303-
utils.AddRetinaMetadata(fl, meta)
302+
utils.AddDropReason(fl, ext, uint16(eventType))
303+
utils.SetExtensions(fl, ext)
304304
p.enricher.Write(e)
305305
case monitorAPI.MessageTypeTrace:
306306
e := &v1.Event{}
@@ -315,16 +315,16 @@ func (p *Plugin) handleTraceEvent(data unsafe.Pointer, size uint32) error {
315315
if err != nil {
316316
return fmt.Errorf("could not convert tracenotify event to flow: %w", err)
317317
}
318-
meta := &utils.RetinaMetadata{}
319-
utils.AddPacketSize(meta, size-uint32(unsafe.Sizeof(TraceNotify{})))
318+
ext := utils.NewExtensions()
319+
utils.AddPacketSize(ext, size-uint32(unsafe.Sizeof(TraceNotify{})))
320320
fl := e.GetFlow()
321321
if fl == nil {
322322
return fmt.Errorf("%w", errNilTraceNotifyFlow)
323323
}
324324
if fl.GetIP() == nil {
325325
return fmt.Errorf("%w; perfdata: %v;", errNilDropNotifyEvent, perfData)
326326
}
327-
utils.AddRetinaMetadata(fl, meta)
327+
utils.SetExtensions(fl, ext)
328328
p.enricher.Write(e)
329329

330330
case MessageTypePktmonDrop:
@@ -340,8 +340,8 @@ func (p *Plugin) handleTraceEvent(data unsafe.Pointer, size uint32) error {
340340
if err != nil {
341341
return fmt.Errorf("could not convert pktmon dropnotify event to flow: %w", err)
342342
}
343-
meta := &utils.RetinaMetadata{}
344-
utils.AddPacketSize(meta, size-uint32(unsafe.Sizeof(DropNotify{})))
343+
ext := utils.NewExtensions()
344+
utils.AddPacketSize(ext, size-uint32(unsafe.Sizeof(DropNotify{})))
345345
fl := e.GetFlow()
346346
if fl == nil {
347347
return fmt.Errorf("%w", errNilDropNotifyFlow)
@@ -354,8 +354,8 @@ func (p *Plugin) handleTraceEvent(data unsafe.Pointer, size uint32) error {
354354
}
355355
// Set the drop reason.
356356
eventType := fl.GetEventType().GetSubType()
357-
meta.DropReason = utils.DropReason(eventType)
358-
utils.AddRetinaMetadata(fl, meta)
357+
utils.AddDropReason(fl, ext, uint16(eventType))
358+
utils.SetExtensions(fl, ext)
359359
p.enricher.Write(e)
360360
}
361361
return nil

pkg/plugin/ebpfwindows/ebpf_windows_test.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"encoding/binary"
1111
"errors"
1212
"fmt"
13+
"log/slog"
1314
"net"
1415
"testing"
1516
"time"
@@ -396,7 +397,7 @@ func TestHandleTraceEvent_InvalidSizeZero(t *testing.T) {
396397
// TestMetricsMapIterateCallback_DropEgress tests the behavior of the metricsMapIterateCallback function
397398
// when a drop event is received for egress traffic.
398399
func TestMetricsMapIterateCallback_DropEgress(t *testing.T) {
399-
metrics.InitializeMetrics()
400+
metrics.InitializeMetrics(slog.Default())
400401
p := &Plugin{
401402
cfg: &kcfg.Config{
402403
MetricsInterval: 100 * time.Second,
@@ -425,7 +426,7 @@ func TestMetricsMapIterateCallback_DropEgress(t *testing.T) {
425426
// TestMetricsMapIterateCallback_DropIngress tests the behavior of the metricsMapIterateCallback function
426427
// when a drop event is received for ingress traffic.
427428
func TestMetricsMapIterateCallback_DropIngress(t *testing.T) {
428-
metrics.InitializeMetrics()
429+
metrics.InitializeMetrics(slog.Default())
429430
p := &Plugin{
430431
cfg: &kcfg.Config{
431432
MetricsInterval: 100 * time.Second,
@@ -454,7 +455,7 @@ func TestMetricsMapIterateCallback_DropIngress(t *testing.T) {
454455
// TestMetricsMapIterateCallback_ForwardEgress tests the behavior of the metricsMapIterateCallback function
455456
// when a forward event is received for egress traffic.
456457
func TestMetricsMapIterateCallback_ForwardEgress(t *testing.T) {
457-
metrics.InitializeMetrics()
458+
metrics.InitializeMetrics(slog.Default())
458459
p := &Plugin{
459460
cfg: &kcfg.Config{
460461
MetricsInterval: 100 * time.Second,
@@ -483,7 +484,7 @@ func TestMetricsMapIterateCallback_ForwardEgress(t *testing.T) {
483484
// TestMetricsMapIterateCallback_ForwardIngress tests the behavior of the metricsMapIterateCallback function
484485
// when a forward event is received for ingress traffic.
485486
func TestMetricsMapIterateCallback_ForwardIngress(t *testing.T) {
486-
metrics.InitializeMetrics()
487+
metrics.InitializeMetrics(slog.Default())
487488
p := &Plugin{
488489
cfg: &kcfg.Config{
489490
MetricsInterval: 100 * time.Second,
@@ -519,7 +520,7 @@ func TestMetricsMapIterateCallback_NilKey(t *testing.T) {
519520
}
520521
}()
521522

522-
metrics.InitializeMetrics()
523+
metrics.InitializeMetrics(slog.Default())
523524
p := &Plugin{
524525
cfg: &kcfg.Config{
525526
MetricsInterval: 100 * time.Second,
@@ -541,7 +542,7 @@ func TestMetricsMapIterateCallback_NilValue(t *testing.T) {
541542
}
542543
}()
543544

544-
metrics.InitializeMetrics()
545+
metrics.InitializeMetrics(slog.Default())
545546
p := &Plugin{
546547
cfg: &kcfg.Config{
547548
MetricsInterval: 100 * time.Second,

pkg/plugin/ebpfwindows/parser_windows.go

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515
v1 "github.com/cilium/cilium/pkg/hubble/api/v1"
1616
observerTypes "github.com/cilium/cilium/pkg/hubble/observer/types"
1717
"github.com/cilium/cilium/pkg/hubble/parser/errors"
18-
"github.com/cilium/cilium/pkg/hubble/parser/options"
1918
"github.com/cilium/cilium/pkg/lock"
2019
monitorAPI "github.com/cilium/cilium/pkg/monitor/api"
2120
"github.com/gopacket/gopacket"
@@ -48,10 +47,9 @@ const (
4847

4948
// Parser is a parser for L3/L4 payloads
5049
type Parser struct {
51-
log *slog.Logger
52-
epResolver *EndpointResolver
53-
correlateL3L4Policy bool
54-
packet *packet
50+
log *slog.Logger
51+
epResolver *EndpointResolver
52+
packet *packet
5553
}
5654

5755
var (
@@ -83,7 +81,6 @@ type packet struct {
8381
// New returns a new L3/L4 parser
8482
func NewParser(
8583
log *slog.Logger,
86-
opts ...options.Option,
8784
) (*Parser, error) {
8885
packet := &packet{}
8986
decoders := []gopacket.DecodingLayer{
@@ -102,19 +99,10 @@ func NewParser(
10299
packet.decLayerL3Dev.IPv4.IgnoreUnsupported = true
103100
packet.decLayerL3Dev.IPv6.IgnoreUnsupported = true
104101

105-
args := &options.Options{
106-
EnableNetworkPolicyCorrelation: true,
107-
}
108-
109-
for _, opt := range opts {
110-
opt(args)
111-
}
112-
113102
return &Parser{
114-
log: log,
115-
epResolver: NewEndpointResolver(log),
116-
packet: packet,
117-
correlateL3L4Policy: args.EnableNetworkPolicyCorrelation,
103+
log: log,
104+
epResolver: NewEndpointResolver(log),
105+
packet: packet,
118106
}, nil
119107
}
120108

0 commit comments

Comments
 (0)