-
Notifications
You must be signed in to change notification settings - Fork 909
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Netdev #3614
Netdev #3614
Conversation
I don't understand the build failures. I ran "make test" and "make test-tinygo" before submitting. (Frustrated!) |
@scottfeldman looks like now only Windows build is failing https://github.com/tinygo-org/tinygo/actions/runs/4546595651/jobs/8025444093?pr=3614#step:7:36 |
Also merge conflict in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking amazing all around. Good job on keeping this interface lean! Looks solid as could be.
I got a nit regarding the file descriptor type on netdever which could give us a tad bit of more type hinting which you can never really have too much.
@scottfeldman if you can rebase against the latest dev, I think you will see that actually the This should allow all of the tests to pass. |
@deadprogram Cool, I'll rebase but I need help on these instructions from here. The last step is where I've screwed up rebasing two times and end up having to create a new PR. What is "myfork" in the last line?
|
That last line would be:
Are you certain you have the latest dev branch? |
This PR adds a network device driver model called netdev. There will be a companion PR for TinyGo drivers to update the netdev drivers and network examples. This PR covers the core "net" package. An RFC for the work is here: #tinygo-org/drivers#487. Some things have changed from the RFC, but nothing major. The "net" package is a partial port of Go's "net" package, version 1.19.3. The src/net/README file has details on what is modified from Go's "net" package. Most "net" features are working as they would in normal Go. TCP/UDP/TLS protocol support is there. As well as HTTP client and server support. Standard Go network packages such as golang.org/x/net/websockets and Paho MQTT client work as-is. Other packages are likely to work as-is. Testing results are here (https://docs.google.com/spreadsheets/d/e/2PACX-1vT0cCjBvwXf9HJf6aJV2Sw198F2ief02gmbMV0sQocKT4y4RpfKv3dh6Jyew8lQW64FouZ8GwA2yjxI/pubhtml?gid=1013173032&single=true).
@deadprogram Still having trouble:
I first synced my fork in scottfeldman/tinygo to tinygo-org/tinygo:dev, then did the following:
|
Ok, I'm back on track with:
"net/mail" is the next failure. Removing it would get us thru, I believe. Feels like we're deferring a problem we'll have to fix eventually. |
Well, removing all the net package test paths from the Makefile didn't work. Somehow the reflect package forces a compile of the net package, and this is breaking the Windows build because the net package needs syscall.SOL_TCP, etc. I'll revert the last commit. I'm not sure what to do with Windows not finding syscall.SOL_TCP when it's clearly defined in src/syscall/net.go. Actually, looking at loader/goroot.go, I think adding "windows" tag to targets that need the syscall package merged. Let me try that. |
Year 2000 was the last time I did any development work on Windows. I don't want to break my 23-year streak of no Windows. |
Need to return the same error structure/content as regular Go for net.Conn Read/Write operations. Found/fixed when testing deadlines on Read/Write operations.
@@ -88,6 +88,11 @@ func ResolveTCPAddr(network, address string) (*TCPAddr, error) { | |||
return nil, fmt.Errorf("Network '%s' not supported", network) | |||
} | |||
|
|||
switch address { | |||
case ":http": | |||
address = ":80" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does native (upstream) Go default to port 80 too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, here's the doc for Addr in http.Server:
type Server struct {
// Addr optionally specifies the TCP address for the server to listen on,
// in the form "host:port". If empty, ":http" (port 80) is used.
// The service names are defined in RFC 6335 and assigned by IANA.
// See net.Dial for details of the address format.
Addr string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's try to keep net
compatible with native Go!
I have been thinking about how best to bring these changes into the code, because I really want the features that will be unlocked by the hard work put in by @scottfeldman Basically, what do we do with the following?
One idea I had was to perhaps put the Regarding how to update, perhaps some minimal automation could checkout the Go std lib The excellent work that @scottfeldman put into this PR with the list of specific files changed made me think that something like this could be possible for handling the inevitable upstream changes in the main Go standard libs. I really want to incorporate this incredible effort made by @scottfeldman and also want to keep things as maintainable as we can. Thoughts? |
One more thing, we will need to handle compatability with the upstream WASI changes being made by @achille-roussel @evanphx and friends such as https://cs.opensource.google/go/go/+/eb2bc919760d7a3e5ffd6022756cd7bda2f2dc63 |
I created https://github.com/tinygo-org/net so we can try this out. I'll get back to it later and let everything know what I find discover... |
Step 1 is complete: here is branch with the netdev commits included https://github.com/tinygo-org/net/tree/netdev3 |
#3704 passed CI so I squashed a couple commits to clean up. It is ready for testing and any further review, as required. |
My understanding on the subject of maintainability and security:
In doing so we accept we may exclude security patches and optimizations due to the implementation mismatch with upstream. I was fine with it since I did not see another agile way forward. @deadprogram Just to get me up to speed with the proposed changes-
Again, I ain't opposed- just want clarity on the reasons! |
(I'm closing the original PR #3452 and submitting this one as a replacement).
This PR adds a network device driver model called netdev. There is a companion PR for TinyGo drivers to update the netdev drivers and network examples. This PR covers the core "net" and "net/http" packages.
An RFC for the work is here: #tinygo-org/drivers#487. Some things have changed from the RFC, but nothing major.
The "net" package is a partial port of Go's "net" package, copied and modified from Go version 1.19.3. See src/net/README for details on what is modified from Go's "net" package.
Most "net" features are working as they would in normal Go. TCP/UDP/TLS protocol support is there. As well as HTTP client and server support. Standard Go network packages such as golang.org/x/net/websockets and Paho MQTT client work as-is. Other packages are likely to work as-is.
Testing results are here.