From 51e4fb77cf4e33f95a4d3ce7027eec59bc4cbebf Mon Sep 17 00:00:00 2001 From: Alexander Blagoev Date: Fri, 28 Apr 2017 19:34:08 +0300 Subject: [PATCH] Add socket state to TCP connection key --- net/net_linux.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/net_linux.go b/net/net_linux.go index 5e0fc21..9c936ac 100644 --- a/net/net_linux.go +++ b/net/net_linux.go @@ -368,9 +368,9 @@ func statsFromInodes(root string, pid int32, tmap []netConnectionKindType, inode } for _, c := range ls { // Build TCP key to id the connection uniquely - // socket type, src ip, src port, dst ip dst port should be enough + // socket type, src ip, src port, dst ip, dst port and state should be enough // to prevent duplications. - connKey = strconv.Itoa(int(c.sockType)) + "-" + c.laddr.IP + ":" + strconv.Itoa(int(c.laddr.Port)) + "-" + c.raddr.IP + ":" + strconv.Itoa(int(c.raddr.Port)) + connKey = strconv.Itoa(int(c.sockType)) + "-" + c.laddr.IP + ":" + strconv.Itoa(int(c.laddr.Port)) + "-" + c.raddr.IP + ":" + strconv.Itoa(int(c.raddr.Port)) + "-" + c.status if _, ok := dupCheckMap[connKey]; ok { continue }