Skip to content

Commit

Permalink
Merge pull request #93 from coroot/log_listen_events
Browse files Browse the repository at this point in the history
container: log TCP listen open/close events
  • Loading branch information
apetruhin authored May 31, 2024
2 parents 990c7e9 + 0f7052a commit cd29567
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions containers/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
}
Expand All @@ -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 {
Expand Down

0 comments on commit cd29567

Please sign in to comment.