Accept response from netlink just if inode is valid

Sometimes we get wrong values for Uid field, so just check if the inode
field is valid to accept the response from netlink.
This commit is contained in:
Gustavo Iñiguez Goia 2020-02-15 00:22:37 +01:00
parent 9207465d58
commit 6646ee469a

View file

@ -81,7 +81,7 @@ func newConnectionImpl(nfp *netfilter.Packet, c *Connection) (cr *Connection, er
// 2. lookup pid by inode
// 3. if this is coming from us, just accept
// 4. lookup process info by pid
if _uid, _inode := netlink.GetSocketInfo(c.Protocol, c.SrcIP, c.SrcPort, c.DstIP, c.DstPort); _uid != -1 && _inode != -1 {
if _uid, _inode := netlink.GetSocketInfo(c.Protocol, c.SrcIP, c.SrcPort, c.DstIP, c.DstPort); _inode > 0 {
c.Entry = &netstat.Entry {
Proto: c.Protocol,
SrcIP: c.SrcIP,