firestack icon indicating copy to clipboard operation
firestack copied to clipboard

tunnel/tunnel.go: add SetPcapFd()

Open Lanius-collaris opened this issue 1 year ago • 1 comments

celzero/rethink-app#1309

PoC: Lanius-collaris/playground1

func GoHello(fd int32) int64{
	out:=os.NewFile(uintptr(fd), "")
	defer out.Close()
	str:=fmt.Sprintf("hello from golang, pid: %d\n", os.Getpid())
	len,_:=out.Write([]byte(str))
	return int64(len)
}

Lanius-collaris avatar Mar 28 '24 22:03 Lanius-collaris

Passing a SAF fd to tunnel.SetPcapFd works?

ignoramous avatar Mar 31 '24 09:03 ignoramous

Did this ever work? If so, we'd prefer passing FD instead. In our tests, it never did (not this particular code but the one we wrote when we first impl this feature).

ignoramous avatar Jul 18 '24 12:07 ignoramous

I have not tested on real rethink-app, but the PoC works whether I pass mode w or mode wa to openFileDescriptor(). Could you tell me the commit id of your test? Maybe I can find why it doesn't work.

Lanius-collaris avatar Jul 20 '24 22:07 Lanius-collaris

That code isn't public, I'm afraid. The current code (passing filepath instead of fd) works, so we will leave it as-is, as there are other complications with passing the fd around (such as double-close & use-after-close, since both Kotlinland & Goland may think they own the fd).

ignoramous avatar Jul 21 '24 04:07 ignoramous