Skip to content

Commit

Permalink
hubble: fix traffic direction and reply on encrypted trace notifications
Browse files Browse the repository at this point in the history
[ upstream commit 9939fa2 ]
[ backporter notes: No SRV6 support on v1.13, I removed those test cases ]

Before this patch, Hubble would wrongly report known traffic direction
and reply status when IPSec was enabled.

Signed-off-by: Alexandre Perrin <alex@isovalent.com>
Signed-off-by: Sebastian Wicki <sebastian@isovalent.com>
  • Loading branch information
kaworu authored and gandro committed Mar 19, 2024
1 parent 771f2c9 commit 515d1dc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions pkg/hubble/parser/threefour/parser_test.go
Expand Up @@ -619,6 +619,17 @@ func TestDecodeTrafficDirection(t *testing.T) {
assert.Equal(t, flowpb.TrafficDirection_TRAFFIC_DIRECTION_UNKNOWN, f.GetTrafficDirection())
assert.Equal(t, uint32(localEP), f.GetSource().GetID())

// TRACE_FROM_LXC unknown (encrypted)
tn = monitor.TraceNotifyV0{
Type: byte(monitorAPI.MessageTypeTrace),
Source: localEP,
ObsPoint: monitorAPI.TraceFromLxc,
Reason: monitor.TraceReasonUnknown | monitor.TraceReasonEncryptMask,
}
f = parseFlow(tn, localIP, remoteIP)
assert.Equal(t, flowpb.TrafficDirection_TRAFFIC_DIRECTION_UNKNOWN, f.GetTrafficDirection())
assert.Equal(t, uint32(localEP), f.GetSource().GetID())

// PolicyVerdictNotify Egress
pvn := monitor.PolicyVerdictNotify{
Type: byte(monitorAPI.MessageTypePolicyVerdict),
Expand Down Expand Up @@ -693,6 +704,16 @@ func TestDecodeIsReply(t *testing.T) {
assert.Nil(t, f.GetIsReply())
assert.Equal(t, false, f.GetReply())

// TRACE_FROM_LXC encrypted
tn = monitor.TraceNotifyV0{
Type: byte(monitorAPI.MessageTypeTrace),
ObsPoint: monitorAPI.TraceFromLxc,
Reason: monitor.TraceReasonUnknown | monitor.TraceReasonEncryptMask,
}
f = parseFlow(tn, localIP, remoteIP)
assert.Nil(t, f.GetIsReply())
assert.Equal(t, false, f.GetReply())

// PolicyVerdictNotify forward statically assumes is_reply=false
pvn := monitor.PolicyVerdictNotify{
Type: byte(monitorAPI.MessageTypePolicyVerdict),
Expand Down
2 changes: 1 addition & 1 deletion pkg/monitor/datapath_trace.go
Expand Up @@ -105,7 +105,7 @@ func connState(reason uint8) string {
}

func TraceReasonIsKnown(reason uint8) bool {
switch reason {
switch reason & ^TraceReasonEncryptMask {
case TraceReasonUnknown:
return false
default:
Expand Down

0 comments on commit 515d1dc

Please sign in to comment.