Skip to content

Commit 058bc4e

Browse files
authored
NETOBSERV-1275: Introduce new "INNER" direction for inner-node traffic (#483)
* Introduce new "INNER" direction for inner-node traffic The flows (and duplicates) generated for inner-node traffic differs compared to node-to-node traffic, and reinterpret direction isn't able to decide between ingress or egress. This is causing discrepancies with the dedup mechanism that filters out flows where Duplicate=true and also favors ingress over egress. To fix that, the proposed solution is to create this new INNER direction specifically for this kind of traffic. Deduping this INNER traffic can then rely solely on the Duplicate flag, since that flag was set from a single Agent (single node) there will always be only one Duplicate=false. * update doc * Enable reinterpret on conversations
1 parent e958fe7 commit 058bc4e

File tree

5 files changed

+22
-6
lines changed

5 files changed

+22
-6
lines changed

docs/api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ Following is the supported API format for network transformations:
158158
add_location: add output location fields from input
159159
add_service: add output network service field from input port and parameters protocol field
160160
add_kubernetes: add output kubernetes fields from input
161-
reinterpret_direction: reinterpret flow direction at a higher level than the interface
161+
reinterpret_direction: reinterpret flow direction at the node level (instead of net interface), to ease the deduplication process
162162
add_ip_category: categorize IPs based on known subnets configuration
163163
parameters: parameters specific to type
164164
assignee: value needs to assign to output field

pkg/api/transform_network.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ type TransformNetworkOperationEnum struct {
5252
AddLocation string `yaml:"add_location" json:"add_location" doc:"add output location fields from input"`
5353
AddService string `yaml:"add_service" json:"add_service" doc:"add output network service field from input port and parameters protocol field"`
5454
AddKubernetes string `yaml:"add_kubernetes" json:"add_kubernetes" doc:"add output kubernetes fields from input"`
55-
ReinterpretDirection string `yaml:"reinterpret_direction" json:"reinterpret_direction" doc:"reinterpret flow direction at a higher level than the interface"`
55+
ReinterpretDirection string `yaml:"reinterpret_direction" json:"reinterpret_direction" doc:"reinterpret flow direction at the node level (instead of net interface), to ease the deduplication process"`
5656
AddIPCategory string `yaml:"add_ip_category" json:"add_ip_category" doc:"categorize IPs based on known subnets configuration"`
5757
}
5858

pkg/pipeline/transform/transform_network.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,7 @@ func (n *Network) Transform(inputEntry config.GenericMap) (config.GenericMap, bo
124124
}
125125
}
126126
case api.OpReinterpretDirection:
127-
// only reinterpret direction on flowlogs
128-
if rt, ok := outputEntry["_RecordType"]; !ok || rt == "flowLog" {
129-
reinterpretDirection(outputEntry, &n.DirectionInfo)
130-
}
127+
reinterpretDirection(outputEntry, &n.DirectionInfo)
131128
case api.OpAddIPCategory:
132129
if strIP, ok := outputEntry[rule.Input].(string); ok {
133130
cat, ok := n.ipCatCache.GetCacheEntry(strIP)

pkg/pipeline/transform/transform_network_direction.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
const (
1111
ingress = 0
1212
egress = 1
13+
inner = 2
1314
)
1415

1516
func validateReinterpretDirectionConfig(info *api.NetworkTransformDirectionInfo) error {
@@ -57,5 +58,7 @@ func reinterpretDirection(output config.GenericMap, info *api.NetworkTransformDi
5758
} else if dstNode == reporter {
5859
output[info.FlowDirectionField] = ingress
5960
}
61+
} else if srcNode != "" {
62+
output[info.FlowDirectionField] = inner
6063
}
6164
}

pkg/pipeline/transform/transform_network_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,22 @@ func Test_ReinterpretDirection(t *testing.T) {
370370
"FlowDirection": 0,
371371
}, output)
372372

373+
output, ok = tr.Transform(config.GenericMap{
374+
"ReporterIP": "10.1.2.3",
375+
"SrcHostIP": "10.1.2.3",
376+
"DstHostIP": "10.1.2.3",
377+
"FlowDirection": "whatever",
378+
})
379+
require.True(t, ok)
380+
// Inner node => inner (2)
381+
require.Equal(t, config.GenericMap{
382+
"ReporterIP": "10.1.2.3",
383+
"SrcHostIP": "10.1.2.3",
384+
"DstHostIP": "10.1.2.3",
385+
"IfDirection": "whatever",
386+
"FlowDirection": 2,
387+
}, output)
388+
373389
output, ok = tr.Transform(config.GenericMap{
374390
"ReporterIP": "10.1.2.100",
375391
"SrcHostIP": "10.1.2.3",

0 commit comments

Comments
 (0)