Skip to content
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

Stub udp support #4005

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open

Stub udp support #4005

wants to merge 2 commits into from

Conversation

rminnich
Copy link

@rminnich rminnich commented Nov 24, 2023

UDPConn is needed to get u-root commands such as wget to build. We still need OpError.Timeout():

rminnich@pop-os:~/go/src/github.com/u-root/u-root/cmds/core/wget$ tinygo build -tags purego
# pack.ag/tftp
../../../vendor/pack.ag/tftp/server.go:113:49: err.Timeout undefined (type *net.OpError has no field or method Timeout)

I'd be much happier to just get rid of all tftp usage, but that is not easy, too many people still use it.

Rather than a new file, should this code just be in udpsock.go?

@rminnich
Copy link
Author

rminnich commented Nov 24, 2023

I'm not sure why it says I want to merge into release, I did this, following instructions:

 git checkout -b stub-udp-support origin/dev

Did I mess up somehow?

@deadprogram deadprogram changed the base branch from release to dev November 24, 2023 12:24
@deadprogram
Copy link
Member

@rminnich I think it just needed the correct base branch in github UI. Just changed it to dev.

@rminnich
Copy link
Author

This is a bit odd:

Caused by:
    0: failed to instantiate "C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\tinygo2017585412\\main"
    1: unknown import: `env::getpagesize` has not been defined
```

is this a flake or is there something I also missed? There's certainly nothing in this PR that should have caused that to be called.

The UDPConn struct is empty, and all operations
return ErrNotImplemented.

Once OpError.Timeout() is implemented, u-root wget and other
tools will build.

Signed-off-by: Ronald G Minnich <rminnich@gmail.com>
@rminnich
Copy link
Author

it was something I missed, 2:30 am commits are not my forte it seems

Always returns false, for now, until the infra
for real timeouts is ready.

Signed-off-by: Ronald G Minnich <rminnich@gmail.com>
@rminnich
Copy link
Author

data point:
tinygo build -target esp32c3 -tags purego
builds u-root wget.

This is a pretty big step forward.

@deadprogram
Copy link
Member

@rminnich have you ever taken a look at the https://github.com/tinygo-org/tinygo/tree/net-submodule-netdev3 branch by any chance? It might do what you need already? It is a part of #3704

@rminnich
Copy link
Author

well I'm prob doing something wrong but
git checkout net-submodule-netdev3
git submodule update
make

and in building wget I'm back to

rminnich@pop-os:~/go/src/github.com/u-root/u-root/cmds/core/wget$ tinygo build -target esp32c3 
# pack.ag/tftp
../../../vendor/pack.ag/tftp/conn.go:39:22: undefined: net.ListenUDP
../../../vendor/pack.ag/tftp/conn.go:754:21: c.netConn.WriteTo undefined (type *net.UDPConn has no field or method WriteTo)
../../../vendor/pack.ag/tftp/conn.go:832:28: c.netConn.ReadFrom undefined (type *net.UDPConn has no field or method ReadFrom)
../../../vendor/pack.ag/tftp/conn.go:842:22: c.netConn.WriteTo undefined (type *net.UDPConn has no field or method WriteTo)
../../../vendor/pack.ag/tftp/server.go:111:25: conn.ReadFromUDP undefined (type *net.UDPConn has no field or method ReadFromUDP)
../../../vendor/pack.ag/tftp/server.go:170:19: s.conn.WriteTo undefined (type *net.UDPConn has no field or method WriteTo)
../../../vendor/pack.ag/tftp/server.go:204:17: s.conn.WriteTo undefined (type *net.UDPConn has no field or method WriteTo)
../../../vendor/pack.ag/tftp/server.go:231:17: s.conn.WriteTo undefined (type *net.UDPConn has no field or method WriteTo)
../../../vendor/pack.ag/tftp/server.go:299:19: undefined: net.ListenUDP

I don't see any of these functions in that submodule. There is some UDP support but not this?

@rminnich
Copy link
Author

but if you do end up using the submodule, I suppose I can push a PR against that to get these 4 needed functions?

@deadprogram
Copy link
Member

cc @scottfeldman

@scottfeldman
Copy link
Contributor

Hi, I'm able to reproduce this issue. I'll work on porting the missing UDP parts to tinygo-net...

sfeldma@penguin:~/work/u-root$ ~/go/bin/tinygo build -tags purego ./cmds/core/wget/
go: downloading github.com/cenkalti/backoff/v4 v4.1.3
go: downloading pack.ag/tftp v1.0.1-0.20181129014014-07909dfbde3c
go: downloading github.com/pierrec/lz4/v4 v4.1.14
# pack.ag/tftp
../../go/pkg/mod/pack.ag/tftp@v1.0.1-0.20181129014014-07909dfbde3c/conn.go:39:22: ListenUDP not declared by package net
../../go/pkg/mod/pack.ag/tftp@v1.0.1-0.20181129014014-07909dfbde3c/conn.go:754:21: c.netConn.WriteTo undefined (type *net.UDPConn has no field or method WriteTo)
../../go/pkg/mod/pack.ag/tftp@v1.0.1-0.20181129014014-07909dfbde3c/conn.go:832:28: c.netConn.ReadFrom undefined (type *net.UDPConn has no field or method ReadFrom)
../../go/pkg/mod/pack.ag/tftp@v1.0.1-0.20181129014014-07909dfbde3c/conn.go:842:22: c.netConn.WriteTo undefined (type *net.UDPConn has no field or method WriteTo)
../../go/pkg/mod/pack.ag/tftp@v1.0.1-0.20181129014014-07909dfbde3c/server.go:111:25: conn.ReadFromUDP undefined (type *net.UDPConn has no field or method ReadFromUDP)
../../go/pkg/mod/pack.ag/tftp@v1.0.1-0.20181129014014-07909dfbde3c/server.go:170:19: s.conn.WriteTo undefined (type *net.UDPConn has no field or method WriteTo)
../../go/pkg/mod/pack.ag/tftp@v1.0.1-0.20181129014014-07909dfbde3c/server.go:204:17: s.conn.WriteTo undefined (type *net.UDPConn has no field or method WriteTo)
../../go/pkg/mod/pack.ag/tftp@v1.0.1-0.20181129014014-07909dfbde3c/server.go:231:17: s.conn.WriteTo undefined (type *net.UDPConn has no field or method WriteTo)
../../go/pkg/mod/pack.ag/tftp@v1.0.1-0.20181129014014-07909dfbde3c/server.go:299:19: ListenUDP not declared by package net

@scottfeldman
Copy link
Contributor

I opened an issue in tinygo-org/net to add UDP server support: tinygo-org/net#6

I'm trying to wrap my head around u-root. If we had UDP server working, would this mean you could flash a u-root image with wget to a tinygo target, and from there run wget on the network? I ask because it looks like this PR just stubs out the UDP server calls to get a compile. What does it mean for u-root to have full networking so netcat, wget, ping, dhclient work?

@leongross
Copy link

I'm interested in picking this issue up again. Could we re-run the CI to check the current state of this PR? @rminnich @scottfeldman @deadprogram

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants