mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-28 01:31:17 +00:00
Only add DNAT'ed addresses for short-lived connections
This commit is contained in:
@@ -30,7 +30,7 @@ func TestNat(t *testing.T) {
|
||||
// the setup is this:
|
||||
//
|
||||
// container2 (10.0.47.2:222222), host2 (2.3.4.5:22223) ->
|
||||
// host1 (1.2.3.4:80), container1 (10.0.47.2:80)
|
||||
// host1 (1.2.3.4:80), container1 (10.0.47.1:80)
|
||||
|
||||
// from the PoV of host1
|
||||
{
|
||||
|
||||
@@ -118,27 +118,20 @@ func (r *Reporter) Report() (report.Report, error) {
|
||||
uint16(f.Original.Layer4.SrcPort),
|
||||
uint16(f.Original.Layer4.DstPort),
|
||||
}
|
||||
seenTuples[tuple.key()] = tuple
|
||||
r.addConnection(&rpt, tuple, extraNodeInfo, extraNodeInfo)
|
||||
|
||||
// Handle DNAT-ed short-lived connections.
|
||||
// The NAT mapper won't help since it only runs periodically,
|
||||
// missing the short-lived connections.
|
||||
if f.Original.Layer3.DstIP != f.Reply.Layer3.SrcIP {
|
||||
reply_tuple := fourTuple{
|
||||
tuple = fourTuple{
|
||||
f.Reply.Layer3.DstIP,
|
||||
f.Reply.Layer3.SrcIP,
|
||||
uint16(f.Reply.Layer4.DstPort),
|
||||
uint16(f.Reply.Layer4.SrcPort),
|
||||
}
|
||||
// FIXME: For DNAT-ed connections the
|
||||
// f.Original.Layer3.SrcIP -> f.Original.Layer3.DstIP connection above
|
||||
// results in a unattributed dangling-edge to the Internet node.
|
||||
// It could be enough to simply not add that connection, but
|
||||
// it may not be correct in general.
|
||||
r.addConnection(&rpt, reply_tuple, extraNodeInfo, extraNodeInfo)
|
||||
}
|
||||
|
||||
seenTuples[tuple.key()] = tuple
|
||||
r.addConnection(&rpt, tuple, extraNodeInfo, extraNodeInfo)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user