From 0f7052a427d228c6d2db0fbfc8053293d70f1190 Mon Sep 17 00:00:00 2001 From: Anton Petruhin Date: Fri, 31 May 2024 17:53:22 +0400 Subject: [PATCH] container: log TCP listen open/close events --- containers/container.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/containers/container.go b/containers/container.go index d95adfe..3c78d41 100644 --- a/containers/container.go +++ b/containers/container.go @@ -435,6 +435,7 @@ func (c *Container) onFileOpen(pid uint32, fd uint64) { } func (c *Container) onListenOpen(pid uint32, addr netaddr.IPPort, safe bool) { + klog.Infof("TCP listen open pid=%d id=%s addr=%s", pid, c.id, addr) if common.PortFilter.ShouldBeSkipped(addr.Port()) { return } @@ -463,6 +464,7 @@ func (c *Container) onListenOpen(pid uint32, addr netaddr.IPPort, safe bool) { if ips, err = proc.GetNsIps(ns); err != nil { klog.Warningln(err) } else { + klog.Infof("got IPs %s for %s", ips, nsId) c.ipsByNs[nsId] = ips } } @@ -471,6 +473,7 @@ func (c *Container) onListenOpen(pid uint32, addr netaddr.IPPort, safe bool) { } func (c *Container) onListenClose(pid uint32, addr netaddr.IPPort) { + klog.Infof("TCP listen close pid=%d id=%s addr=%s", pid, c.id, addr) c.lock.Lock() defer c.lock.Unlock() if _, byAddr := c.listens[addr]; byAddr {