From b1836acb62d95e3aad19a84dad2e98f070103b27 Mon Sep 17 00:00:00 2001 From: Alfonso Acosta Date: Tue, 3 May 2016 15:10:27 +0000 Subject: [PATCH] Only add DNAT'ed addresses for short-lived connections --- probe/endpoint/nat_internal_test.go | 2 +- probe/endpoint/reporter.go | 13 +++---------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/probe/endpoint/nat_internal_test.go b/probe/endpoint/nat_internal_test.go index db4c0f578..29906d9a0 100644 --- a/probe/endpoint/nat_internal_test.go +++ b/probe/endpoint/nat_internal_test.go @@ -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 { diff --git a/probe/endpoint/reporter.go b/probe/endpoint/reporter.go index c1df1eedf..8f2fcf2c0 100644 --- a/probe/endpoint/reporter.go +++ b/probe/endpoint/reporter.go @@ -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) }) }