Only add DNAT'ed addresses for short-lived connections

This commit is contained in:
Alfonso Acosta
2016-05-03 15:10:27 +00:00
parent 1f825c52ff
commit b1836acb62
2 changed files with 4 additions and 11 deletions

View File

@@ -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
{

View File

@@ -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)
})
}