Skip to content

Commit

Permalink
Fix tracing context assigned to packets
Browse files Browse the repository at this point in the history
  • Loading branch information
dhaavi committed Nov 30, 2020
1 parent 454a234 commit c37674d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions firewall/interception.go
Expand Up @@ -64,11 +64,13 @@ func handlePacket(ctx context.Context, pkt packet.Packet) {
return
}

// Add context tracer and set context on packet.
traceCtx, tracer := log.AddTracer(ctx)
if tracer != nil {
pkt.SetCtx(traceCtx)
defer tracer.Submit()
tracer.Tracef("filter: handling packet: %s", pkt)
}
pkt.SetCtx(traceCtx)

// associate packet to link and handle
conn, ok := network.GetConnection(pkt.GetConnectionID())
Expand Down Expand Up @@ -327,8 +329,8 @@ func packetHandler(ctx context.Context) error {
case <-ctx.Done():
return nil
case pkt := <-interception.Packets:
interceptionModule.StartWorker("initial packet handler", func(ctx context.Context) error {
handlePacket(ctx, pkt)
interceptionModule.StartWorker("initial packet handler", func(workerCtx context.Context) error {
handlePacket(workerCtx, pkt)
return nil
})
}
Expand Down

0 comments on commit c37674d

Please sign in to comment.