Skip to content

Commit

Permalink
Merge pull request #58 from AkihiroSuda/dev
Browse files Browse the repository at this point in the history
Switch from go-pidfd to x/sys/unix
  • Loading branch information
AkihiroSuda authored Mar 4, 2024
2 parents 8c2f6f2 + 150b2fa commit c7daf1e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ go 1.19
require (
github.com/gorilla/mux v1.8.1
github.com/opencontainers/runtime-spec v1.2.0
github.com/oraoto/go-pidfd v0.1.2-0.20210402155345-46bf1ba22e22
github.com/seccomp/libseccomp-golang v0.10.0
github.com/sirupsen/logrus v1.9.3
github.com/spf13/pflag v1.0.5
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/opencontainers/runtime-spec v1.2.0 h1:z97+pHb3uELt/yiAWD691HNHQIF07bE7dzrbT927iTk=
github.com/opencontainers/runtime-spec v1.2.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
github.com/oraoto/go-pidfd v0.1.2-0.20210402155345-46bf1ba22e22 h1:TBw1Dwr/0eRvVIhdgQ+qGQuJ2STNL1+bjaI7nKLCoiQ=
github.com/oraoto/go-pidfd v0.1.2-0.20210402155345-46bf1ba22e22/go.mod h1:gPWelSU60MvzRX+ToMlKj9lZRkeqybg6qy8cy4+rZWE=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
Expand Down
9 changes: 4 additions & 5 deletions pkg/bypass4netns/bypass4netns.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"time"

"github.com/opencontainers/runtime-spec/specs-go"
"github.com/oraoto/go-pidfd"
"github.com/rootless-containers/bypass4netns/pkg/api/com"
"github.com/rootless-containers/bypass4netns/pkg/bypass4netns/iproute2"
"github.com/rootless-containers/bypass4netns/pkg/bypass4netns/nonbypassable"
Expand Down Expand Up @@ -285,7 +284,7 @@ func (h *notifHandler) getPidFdInfo(pid int) (*pidInfo, error) {
return &pidfd, nil
}

targetPidfd, err := pidfd.Open(int(pid), 0)
targetPidfd, err := unix.PidfdOpen(int(pid), 0)
if err == nil {
info := pidInfo{
pidType: PROCESS,
Expand Down Expand Up @@ -324,7 +323,7 @@ func (h *notifHandler) getPidFdInfo(pid int) (*pidInfo, error) {
if nextTgid < 0 {
logrus.Errorf("cannot get Tgid from /proc/%d/status status=%q", pid, string(st))
}
targetPidfd, err = pidfd.Open(nextTgid, 0)
targetPidfd, err = unix.PidfdOpen(nextTgid, 0)
if err != nil {
return nil, fmt.Errorf("pidfd Open failed with Tgid: pid=%d %s", nextTgid, err)
}
Expand All @@ -346,7 +345,7 @@ func (h *notifHandler) getFdInProcess(pid, targetFd int) (int, error) {
return 0, fmt.Errorf("pidfd Open failed: %s", err)
}

fd, err := targetPidfd.pidfd.GetFd(targetFd, 0)
fd, err := unix.PidfdGetfd(targetPidfd.pidfd, targetFd, 0)
if err != nil {
return 0, fmt.Errorf("pidfd GetFd failed: %s", err)
}
Expand Down Expand Up @@ -729,7 +728,7 @@ const (

type pidInfo struct {
pidType pidInfoPidType
pidfd pidfd.PidFd
pidfd int
tgid int
}

Expand Down

0 comments on commit c7daf1e

Please sign in to comment.