From bfd53d28e51c1e543faa003e929cce5ed1daf1b2 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Sat, 24 Jun 2017 18:24:40 +0100 Subject: [PATCH 1/4] ensure connections from /proc/net/tcp{,6} get the right pid ProcNet.Next does not allocate Connection structs, for efficiency. Instead it always returns a *Connection pointing to the same instance. As a result, any mutations by the caller to struct elements that aren't actually set by ProcNet.Next, in particular Connection.Proc, are carried across to subsequent calls. This had hilarious consequences: connections referencing an inode which we hadn't come across during proc walking would be associated with the process corresponding to the last successfully looked up inode. The fix is to clear out the garbage left over from previous calls. Fixes #2638. --- probe/endpoint/procspy/spy_linux.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/probe/endpoint/procspy/spy_linux.go b/probe/endpoint/procspy/spy_linux.go index 08d4258c5..d3b222323 100644 --- a/probe/endpoint/procspy/spy_linux.go +++ b/probe/endpoint/procspy/spy_linux.go @@ -28,6 +28,11 @@ func (c *pnConnIter) Next() *Connection { } if proc, ok := c.procs[n.Inode]; ok { n.Proc = *proc + } else { + // ProcNet.Next() always returns a pointer to the same + // struct. We therefore must clear any garbage left over from + // the previous call. + n.Proc = Proc{} } return n } From 3d96174788ad071ce57a0cf3dcb2a979af1ce5c0 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Sun, 25 Jun 2017 11:08:24 +0100 Subject: [PATCH 2/4] correct polarity of initial connections Fixes #2644 --- probe/endpoint/ebpf.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/probe/endpoint/ebpf.go b/probe/endpoint/ebpf.go index 1cce0c564..76ff85eb4 100644 --- a/probe/endpoint/ebpf.go +++ b/probe/endpoint/ebpf.go @@ -276,9 +276,9 @@ func (t *EbpfTracker) feedInitialConnections(conns procspy.ConnIter, seenTuples // We assume that tuple.fromPort < tuple.toPort is a connect event (outgoing) canonical, ok := seenTuples[tuple.key()] if (ok && canonical != tuple) || (!ok && tuple.fromPort < tuple.toPort) { - t.handleConnection(tracer.EventConnect, tuple, int(conn.Proc.PID), namespaceID) - } else { t.handleConnection(tracer.EventAccept, tuple, int(conn.Proc.PID), namespaceID) + } else { + t.handleConnection(tracer.EventConnect, tuple, int(conn.Proc.PID), namespaceID) } } for _, p := range processesWaitingInAccept { From d38854fbda95b562a3761aaac347c25e444e7ffb Mon Sep 17 00:00:00 2001 From: Alfonso Acosta Date: Wed, 5 Jul 2017 18:14:06 +0000 Subject: [PATCH 3/4] Release 1.5.1 --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 19f0efb6a..16db60c4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +## Release 1.5.1 + +Bugfix patch release + +Bug fixes: +- initial connections have wrong polarity + [#2644](https://github.com/weaveworks/scope/issues/2644) +- connection to dead process associated with different process + [#2638](https://github.com/weaveworks/scope/pull/2638) + ## Release 1.5.0 Highlights: From af3b8cfabf82d39854e05a6a3aefc616a68929ad Mon Sep 17 00:00:00 2001 From: Alfonso Acosta Date: Wed, 5 Jul 2017 20:43:15 +0000 Subject: [PATCH 4/4] Update doc versions --- site/installing.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/site/installing.md b/site/installing.md index 7331381fa..876a1dfea 100644 --- a/site/installing.md +++ b/site/installing.md @@ -125,7 +125,7 @@ After it’s been launched, open your browser to `http://localhost:4040`. **Docker Compose Format Version 1:** scope: - image: weaveworks/scope:1.5.0 + image: weaveworks/scope:1.5.1 net: "host" pid: "host" privileged: true @@ -141,7 +141,7 @@ After it’s been launched, open your browser to `http://localhost:4040`. version: '2' services: scope: - image: weaveworks/scope:1.5.0 + image: weaveworks/scope:1.5.1 network_mode: "host" pid: "host" privileged: true @@ -165,7 +165,7 @@ Version 2 of this YAML file supports networks and volumes as defined by any plug **Docker Compose Format Version 1:** probe: - image: weaveworks/scope:1.5.0 + image: weaveworks/scope:1.5.1 net: "host" pid: "host" privileged: true @@ -182,7 +182,7 @@ Version 2 of this YAML file supports networks and volumes as defined by any plug version: '2' services: probe: - image: weaveworks/scope:1.5.0 + image: weaveworks/scope:1.5.1 network_mode: "host" pid: "host" privileged: true