Skip to content

Commit

Permalink
internal/pwru: replace unmaintained mitchellh/go-ps dependency
Browse files Browse the repository at this point in the history
Mitchell Hashimoto has announced [1] that he'll be archiving his Go
repositories in early 2024. This change updates the
github.com/mitchellh/go-ps dependency with github.com/tklauser/ps which
I've started a while ago as a replacement with additional features.

[1] https://gist.github.com/mitchellh/90029601268e59a29e64e55bab1c5bdc

Note that as a nice side effect this also changes the output to print
the full path to the executable, not just the executable name which
might be ambiguous.

Before this change:

    0xffff9137d7d2c6e0      4   [curl(239350)]             ip_local_out
    0xffff9137d7d2c6e0      4   [curl(239350)]           __ip_local_out
    0xffff9137d7d2c6e0      4   [curl(239350)]             nf_hook_slow
    0xffff9137d7d2c6e0      4   [curl(239350)]                ip_output
    0xffff9137d7d2c6e0      4   [curl(239350)]             nf_hook_slow
    0xffff9137d7d2c6e0      4   [curl(239350)]  apparmor_ipv4_postroute
    0xffff9137d7d2c6e0      4   [curl(239350)]         ip_finish_output
    0xffff9137d7d2c6e0      4   [curl(239350)] __cgroup_bpf_run_filter_skb
    0xffff9137d7d2c6e0      4   [curl(239350)]       __ip_finish_output
    0xffff9137d7d2c6e0      4   [curl(239350)]        ip_finish_output2
    0xffff9137d7d2c6e0      4   [curl(239350)]           dev_queue_xmit
    0xffff9137d7d2c6e0      4   [curl(239350)]         __dev_queue_xmit
    0xffff9137d7d2c6e0      4   [curl(239350)]       qdisc_pkt_len_init
    0xffff9137d7d2c6e0      4   [curl(239350)]      netdev_core_pick_tx
    0xffff9137d7d2c6e0      4   [curl(239350)]        validate_xmit_skb
    0xffff9137d7d2c6e0      4   [curl(239350)]       netif_skb_features
    0xffff9137d7d2c6e0      4   [curl(239350)]     skb_network_protocol
    0xffff9137d7d2c6e0      4   [curl(239350)]       validate_xmit_vlan
    0xffff9137d7d2c6e0      4   [curl(239350)]  skb_csum_hwoffload_help
    0xffff9137d7d2c6e0      4   [curl(239350)]       validate_xmit_xfrm
    0xffff9137d7d2c6e0      4   [curl(239350)]      dev_hard_start_xmit
    0xffff9137d7d2c6e0      4   [curl(239350)]                 skb_push

After this change:

    0xffff9137cb2ebae0      2 [/usr/bin/curl(250468)]             ip_local_out
    0xffff9137cb2ebae0      2 [/usr/bin/curl(250468)]           __ip_local_out
    0xffff9137cb2ebae0      2 [/usr/bin/curl(250468)]             nf_hook_slow
    0xffff9137cb2ebae0      2 [/usr/bin/curl(250468)]                ip_output
    0xffff9137cb2ebae0      2 [/usr/bin/curl(250468)]             nf_hook_slow
    0xffff9137cb2ebae0      2 [/usr/bin/curl(250468)]  apparmor_ipv4_postroute
    0xffff9137cb2ebae0      2 [/usr/bin/curl(250468)]         ip_finish_output
    0xffff9137cb2ebae0      2 [/usr/bin/curl(250468)] __cgroup_bpf_run_filter_skb
    0xffff9137cb2ebae0      2 [/usr/bin/curl(250468)]       __ip_finish_output
    0xffff9137cb2ebae0      2 [/usr/bin/curl(250468)]        ip_finish_output2
    0xffff9137cb2ebae0      2 [/usr/bin/curl(250468)]           dev_queue_xmit
    0xffff9137cb2ebae0      2 [/usr/bin/curl(250468)]         __dev_queue_xmit
    0xffff9137cb2ebae0      2 [/usr/bin/curl(250468)]       qdisc_pkt_len_init
    0xffff9137cb2ebae0      2 [/usr/bin/curl(250468)]      netdev_core_pick_tx
    0xffff9137cb2ebae0      2 [/usr/bin/curl(250468)]        validate_xmit_skb
    0xffff9137cb2ebae0      2 [/usr/bin/curl(250468)]       netif_skb_features
    0xffff9137cb2ebae0      2 [/usr/bin/curl(250468)]     skb_network_protocol
    0xffff9137cb2ebae0      2 [/usr/bin/curl(250468)]       validate_xmit_vlan
    0xffff9137cb2ebae0      2 [/usr/bin/curl(250468)]  skb_csum_hwoffload_help
    0xffff9137cb2ebae0      2 [/usr/bin/curl(250468)]       validate_xmit_xfrm
    0xffff9137cb2ebae0      2 [/usr/bin/curl(250468)]      dev_hard_start_xmit
    0xffff9137cb2ebae0      2 [/usr/bin/curl(250468)]                 skb_push

Signed-off-by: Tobias Klauser <tobias@cilium.io>
  • Loading branch information
tklauser committed Jan 2, 2024
1 parent d86733b commit fd88377
Show file tree
Hide file tree
Showing 33 changed files with 1,188 additions and 894 deletions.
2 changes: 1 addition & 1 deletion go.mod
Expand Up @@ -7,8 +7,8 @@ require (
github.com/cilium/ebpf v0.12.3
github.com/cloudflare/cbpfc v0.0.0-20221017140110-11acb56438a2
github.com/jsimonetti/rtnetlink v1.4.0
github.com/mitchellh/go-ps v1.0.0
github.com/spf13/pflag v1.0.5
github.com/tklauser/ps v0.0.2
github.com/vishvananda/netns v0.0.4
golang.org/x/net v0.19.0
golang.org/x/sys v0.15.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Expand Up @@ -37,8 +37,6 @@ github.com/mdlayher/netlink v1.7.2 h1:/UtM3ofJap7Vl4QWCPDGXY8d3GIY2UGSDbK+QWmY8/
github.com/mdlayher/netlink v1.7.2/go.mod h1:xraEF7uJbxLhc5fpHL4cPe221LI2bdttWlU+ZGLfQSw=
github.com/mdlayher/socket v0.4.1 h1:eM9y2/jlbs1M615oshPQOHZzj6R6wMT7bX5NPiQvn2U=
github.com/mdlayher/socket v0.4.1/go.mod h1:cAqeGjoufqdxWkD7DkpyS+wcefOtmu5OQ8KuoJGIReA=
github.com/mitchellh/go-ps v1.0.0 h1:i6ampVEEF4wQFF+bkYfwYgY+F/uYJDktmvLPf7qIgjc=
github.com/mitchellh/go-ps v1.0.0/go.mod h1:J4lOc8z8yJs6vUwklHw2XEIiT4z4C40KtWVN3nvg8Pg=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
Expand All @@ -47,6 +45,8 @@ github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTE
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/tklauser/ps v0.0.2 h1:Y+9ZQkxeqRGGzaMgW1hca3/aiwpSHfIDArsU468HSbo=
github.com/tklauser/ps v0.0.2/go.mod h1:F5GRwSO+0665vbwHx7j/bPdxFuJEoTXghQYCWKRHZls=
github.com/vishvananda/netns v0.0.4 h1:Oeaw1EM2JMxD51g9uhtC0D7erkIjgmj8+JZc26m1YX8=
github.com/vishvananda/netns v0.0.4/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM=
golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI=
Expand Down
4 changes: 2 additions & 2 deletions internal/pwru/output.go
Expand Up @@ -21,7 +21,7 @@ import (
"github.com/cilium/ebpf"
"github.com/cilium/ebpf/btf"
"github.com/jsimonetti/rtnetlink"
ps "github.com/mitchellh/go-ps"
"github.com/tklauser/ps"
"github.com/vishvananda/netns"
"golang.org/x/sys/unix"

Expand Down Expand Up @@ -99,7 +99,7 @@ func (o *output) Print(event *Event) {
p, err := ps.FindProcess(int(event.PID))
execName := fmt.Sprintf("<empty>(%d)", event.PID)
if err == nil && p != nil {
execName = fmt.Sprintf("%s(%d)", p.Executable(), event.PID)
execName = fmt.Sprintf("%s(%d)", p.ExecutablePath(), event.PID)
}
ts := event.Timestamp
if o.flags.OutputTS == "relative" {
Expand Down
1 change: 0 additions & 1 deletion vendor/github.com/mitchellh/go-ps/.gitignore

This file was deleted.

4 changes: 0 additions & 4 deletions vendor/github.com/mitchellh/go-ps/.travis.yml

This file was deleted.

21 changes: 0 additions & 21 deletions vendor/github.com/mitchellh/go-ps/LICENSE.md

This file was deleted.

34 changes: 0 additions & 34 deletions vendor/github.com/mitchellh/go-ps/README.md

This file was deleted.

43 changes: 0 additions & 43 deletions vendor/github.com/mitchellh/go-ps/Vagrantfile

This file was deleted.

40 changes: 0 additions & 40 deletions vendor/github.com/mitchellh/go-ps/process.go

This file was deleted.

138 changes: 0 additions & 138 deletions vendor/github.com/mitchellh/go-ps/process_darwin.go

This file was deleted.

0 comments on commit fd88377

Please sign in to comment.