Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: containers/gvisor-tap-vsock
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.8.2
Choose a base ref
...
head repository: containers/gvisor-tap-vsock
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.8.3
Choose a head ref
  • 15 commits
  • 62 files changed
  • 6 contributors

Commits on Jan 21, 2025

  1. Add --services flag to start API without using --listen flag

    In the current implementation when gvproxy is started with the --listen option, it exposes a HTTP API with several endpoints like /connect, /stats, /services ...
    The /connect endpoint, however, is only used when the gvforwarder tool is running on the guest, and, when using different connectivities like --listen-vfkit or --listen-qemu, it is not really necessary.
    
    This commit adds a new flag --services that allows to start the HTTP API without the /connect endpoint. It could be used when using different network connectivity and still wanting a lighter HTTP API. It accepts the endpoint where it will be reachable E.g. gvproxy --listen-vfkit .... --services unix:///tmp/svc_gvproxy.sock
    
    Signed-off-by: Luca Stocchi <lstocchi@redhat.com>
    lstocchi committed Jan 21, 2025
    Copy the full SHA
    d1a7ed9 View commit details
  2. doc: update doc with new services option

    Signed-off-by: Luca Stocchi <lstocchi@redhat.com>
    lstocchi committed Jan 21, 2025
    Copy the full SHA
    ab9bbf4 View commit details

Commits on Jan 22, 2025

  1. Use poll based file watcher

    fsnotify/fsnotify can't watch a folder that contains a symlink into
    a socket or named pipe.
    
    Use poll-based mechanism to watch the file for the time being until
    we find a better way or fix the issue in the upstream.
    
    Signed-off-by: Fata Nugraha <fatanugraha@outlook.com>
    fatanugraha committed Jan 22, 2025
    Copy the full SHA
    c56ed7a View commit details

Commits on Jan 23, 2025

  1. test: upload and download tests against vfkit

    This commit adds two tests:
    
    1. Upload files to the VM This test uploads three files of different sizes (10M, 100M, 1G) to the running VM and verifies the sha256sum of the uploaded files.
    
    2. Download the above files from the VM This test downloads the three files uploaded in the previous test and verifies their sha256sum values.
    
    Signed-off-by: Gunjan Vyas <vyasgun20@gmail.com>
    vyasgun committed Jan 23, 2025
    Copy the full SHA
    0b09d74 View commit details

Commits on Jan 27, 2025

  1. build(deps): bump github.com/miekg/dns from 1.1.62 to 1.1.63

    Bumps [github.com/miekg/dns](https://github.com/miekg/dns) from 1.1.62 to 1.1.63.
    - [Changelog](https://github.com/miekg/dns/blob/master/Makefile.release)
    - [Commits](miekg/dns@v1.1.62...v1.1.63)
    
    ---
    updated-dependencies:
    - dependency-name: github.com/miekg/dns
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored Jan 27, 2025
    Copy the full SHA
    aeffde3 View commit details
  2. Add make target to enable debugger during test run

    Signed-off-by: Yevhen Vydolob <yvydolob@redhat.com>
    evidolob committed Jan 27, 2025
    Copy the full SHA
    9b92119 View commit details

Commits on Jan 28, 2025

  1. OWNERS: Add Yevhen and Luca as approvers

    openshift-merge-bot[bot] authored and cfergeau committed Jan 28, 2025
    Copy the full SHA
    374c44e View commit details
  2. Merge pull request #446 from evidolob/add-debugger

    Enable debugger for tests on macOS
    openshift-merge-bot[bot] authored Jan 28, 2025
    Copy the full SHA
    e635d66 View commit details
  3. Merge pull request #463 from fatanugraha/main

    Use poll-based approach to subscribe to file changes
    openshift-merge-bot[bot] authored Jan 28, 2025
    Copy the full SHA
    c9dd0cb View commit details

Commits on Jan 29, 2025

  1. Revert "Replace multiple "resolver.*" fn cals with single "dns.Exchan…

    …ge()" fn."
    
    This reverts commit 58eb054
    
    Due to numerous issues related to getting DNS configuration we're returning back usage of system dns resolver
    
    Signed-off-by: Yevhen Vydolob <yvydolob@redhat.com>
    evidolob committed Jan 29, 2025
    Copy the full SHA
    3b1806e View commit details
  2. Delete unused files and dependencies.

    Due to reverting PR #339 thous files is not used
    
    Signed-off-by: Yevhen Vydolob <yvydolob@redhat.com>
    evidolob committed Jan 29, 2025
    Copy the full SHA
    88ffff3 View commit details
  3. Merge pull request #467 from evidolob/revert-dns

    Revert PR #339
    openshift-merge-bot[bot] authored Jan 29, 2025
    Copy the full SHA
    6436c51 View commit details

Commits on Jan 30, 2025

  1. Merge pull request #453 from vyasgun/pr/upload-download-tests

    Upload and Download tests against vfkit
    openshift-merge-bot[bot] authored Jan 30, 2025
    Copy the full SHA
    c30fc5c View commit details
  2. Merge pull request #429 from lstocchi/i425

    Add --services flag to start API without using --listen flag
    openshift-merge-bot[bot] authored Jan 30, 2025
    Copy the full SHA
    45ea6bb View commit details
  3. Merge pull request #465 from containers/dependabot/go_modules/github.…

    …com/miekg/dns-1.1.63
    
    build(deps): bump github.com/miekg/dns from 1.1.62 to 1.1.63
    openshift-merge-bot[bot] authored Jan 30, 2025
    Copy the full SHA
    f0f1802 View commit details
Showing with 608 additions and 4,852 deletions.
  1. +86 −0 DEVELOPMENT.md
  2. +5 −0 Makefile
  3. +3 −0 OWNERS
  4. +7 −2 README.md
  5. +29 −18 cmd/gvproxy/main.go
  6. +3 −5 go.mod
  7. +2 −2 go.sum
  8. +123 −78 pkg/services/dns/dns.go
  9. +0 −24 pkg/services/dns/dns_config.go
  10. +0 −67 pkg/services/dns/dns_config_unix.go
  11. +0 −34 pkg/services/dns/dns_config_windows.go
  12. +3 −6 pkg/services/dns/dns_test.go
  13. +0 −79 pkg/services/dns/hosts_file.go
  14. +0 −41 pkg/services/dns/hosts_file_test.go
  15. +29 −50 pkg/utils/filewatcher.go
  16. +81 −47 pkg/utils/filewatcher_test.go
  17. +26 −21 pkg/virtualnetwork/mux.go
  18. +76 −0 test-vfkit/basic_test.go
  19. +36 −4 test-vfkit/vfkit_suite_test.go
  20. +0 −5 vendor/github.com/areYouLazy/libhosty/.gitignore
  21. +0 −201 vendor/github.com/areYouLazy/libhosty/LICENSE
  22. +0 −167 vendor/github.com/areYouLazy/libhosty/README.md
  23. +0 −4 vendor/github.com/areYouLazy/libhosty/TODO.md
  24. BIN vendor/github.com/areYouLazy/libhosty/coverage_badge.png
  25. +0 −38 vendor/github.com/areYouLazy/libhosty/errors.go
  26. +0 −33 vendor/github.com/areYouLazy/libhosty/formatter.go
  27. +0 −25 vendor/github.com/areYouLazy/libhosty/helper.go
  28. +0 −846 vendor/github.com/areYouLazy/libhosty/libhosty.go
  29. +0 −112 vendor/github.com/areYouLazy/libhosty/parser.go
  30. +0 −52 vendor/github.com/areYouLazy/libhosty/templates.go
  31. +1 −0 vendor/github.com/miekg/dns/README.md
  32. +29 −13 vendor/github.com/miekg/dns/dnssec.go
  33. +16 −20 vendor/github.com/miekg/dns/edns.go
  34. +18 −4 vendor/github.com/miekg/dns/{listen_no_reuseport.go → listen_no_socket_options.go}
  35. +31 −0 vendor/github.com/miekg/dns/{listen_reuseport.go → listen_socket_options.go}
  36. +1 −0 vendor/github.com/miekg/dns/server.go
  37. +1 −2 vendor/github.com/miekg/dns/sig0.go
  38. +1 −1 vendor/github.com/miekg/dns/version.go
  39. +0 −21 vendor/github.com/qdm12/dns/v2/LICENSE
  40. +0 −51 vendor/github.com/qdm12/dns/v2/pkg/nameserver/getlocal_unix.go
  41. +0 −275 vendor/github.com/qdm12/dns/v2/pkg/nameserver/getlocal_windows.go
  42. +0 −47 vendor/github.com/qdm12/dns/v2/pkg/nameserver/internal.go
  43. +0 −108 vendor/github.com/qdm12/dns/v2/pkg/nameserver/system.go
  44. +0 −7 vendor/github.com/qdm12/gosettings/.dockerignore
  45. +0 −92 vendor/github.com/qdm12/gosettings/.golangci.yml
  46. +0 −42 vendor/github.com/qdm12/gosettings/Dockerfile
  47. +0 −21 vendor/github.com/qdm12/gosettings/LICENSE
  48. +0 −142 vendor/github.com/qdm12/gosettings/README.md
  49. +0 −22 vendor/github.com/qdm12/gosettings/copy.go
  50. +0 −55 vendor/github.com/qdm12/gosettings/defaults.go
  51. +0 −9 vendor/github.com/qdm12/gosettings/interfaces.go
  52. +0 −78 vendor/github.com/qdm12/gosettings/messages.go
  53. +0 −56 vendor/github.com/qdm12/gosettings/override.go
  54. +0 −27 vendor/golang.org/x/exp/LICENSE
  55. +0 −22 vendor/golang.org/x/exp/PATENTS
  56. +0 −50 vendor/golang.org/x/exp/constraints/constraints.go
  57. +0 −44 vendor/golang.org/x/exp/slices/cmp.go
  58. +0 −515 vendor/golang.org/x/exp/slices/slices.go
  59. +0 −197 vendor/golang.org/x/exp/slices/sort.go
  60. +0 −479 vendor/golang.org/x/exp/slices/zsortanyfunc.go
  61. +0 −481 vendor/golang.org/x/exp/slices/zsortordered.go
  62. +1 −10 vendor/modules.txt
86 changes: 86 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
### Debugging test

#### MacOS

You could debug tests with [Delve](https://github.com/go-delve/delve) debugger.
Run:
```shell
make test-mac-debug
```
This command will run build `gvisor` binary with debugger enabled.

>Note: By default it would use `--continue` `dlv` option to not pause `gvisor` execution on start, if debugger is not connected.
> To pause `gvisor` execution until debugger is connected just remove `"--continue"` parameter from this [line](./test-vfkit/vfkit_suite_test.go#L93)
And debug server with `2345` port, you could use any `delve` client to interact with debugger

##### GoLand Example
Create new `Go Remote` debug configuration:
1. Click Edit | Run Configurations. Alternatively, click the list of run/debug configurations on the toolbar and select Edit Configurations.
2. In the Run/Debug Configurations dialog, click the Add button (the Add button) and select Go Remote.
3. Set meaningful name
4. In the Host field, keep `localhost`
5. In the Port field, keep `2345` port number
6. Click **OK** button

Run `gvisor` tests with debug with:
```shell
make test-mac-debug
```
wait until `Listening for remote connections (connections are not authenticated nor encrypted)` message it appears.
Click on debug button on Golang, ensure that your `Go Remote` profile is selected.

Have fun with debugging.

##### VSCode
Create/edit `launch.json` by adding this configuration:
```json
{
"name": "Connect to Gvisor",
"type": "go",
"request": "attach",
"mode": "remote",
"remotePath": "${workspaceFolder}",
"port": 2345,
"host": "localhost"
}
```
Run `gvisor` tests with debug with:
```shell
make test-mac-debug
```
wait until `Listening for remote connections (connections are not authenticated nor encrypted)` message it appears.
Execute the launch attach request(`Connect to Gvisor`).

Have fun with debugging.

##### CLI Example

Connect to debugger server with:
```shell
dlv connect :2345
```
Example of usage:
```shell
Type 'help' for list of commands.
(dlv) break main.main
Breakpoint 1 set at 0xe735776 for main.main() ./work/redhat/gvisor-tap-vsock/cmd/gvproxy/main.go:59
(dlv) continue
> [Breakpoint 1] main.main() ./work/redhat/gvisor-tap-vsock/cmd/gvproxy/main.go:59 (hits goroutine(1):1 total:1) (PC: 0xe735776)
54: hostIP = "192.168.127.254"
55: host = "host"
56: gateway = "gateway"
57: )
58:
=> 59: func main() {
60: version := types.NewVersion("gvproxy")
61: version.AddFlag()
62: flag.Var(&endpoints, "listen", "control endpoint")
63: flag.BoolVar(&debug, "debug", false, "Print debug info")
64: flag.IntVar(&mtu, "mtu", 1500, "Set the MTU")
```
More info about CLI client [here](https://github.com/go-delve/delve/blob/master/Documentation/cli/README.md)
#### Editor integration
For available editor integration look [there](https://github.com/go-delve/delve/blob/master/Documentation/EditorIntegration.md)
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -78,3 +78,8 @@ test-qemu: gvproxy test-companion
.PHONY: test-mac
test-mac: gvproxy
go test -timeout 20m -v ./test-vfkit

.PHONY: test-mac-debug
test-mac-debug:
go test -timeout 20m -v ./test-vfkit --debug
rm -f ./test-vfkit/__debug_bin*
3 changes: 3 additions & 0 deletions OWNERS
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
approvers:
- baude
- cfergeau
- evidolob
- lstocchi

reviewers:
- baude
- cfergeau
- jakecorrenti
- praveenkumar
- evidolob
- lstocchi
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -112,7 +112,7 @@ With the executable:

### API

When `gvproxy` is started with the `--listen` option, it exposes a HTTP API on the host.
When `gvproxy` is started with the `--listen` or `--services` option, it exposes a HTTP API on the host.
This API can be used with curl.

```
@@ -127,6 +127,8 @@ $ curl --unix-socket /tmp/network.sock http:/unix/stats
...
```

N.B: The `--services` option exposes the same HTTP API as the `--listen` option, but without the `/connect` endpoint. This is useful for scenarios where the `gvforwarder`/`vm` tool is not run on the guest but you still want to expose services and stats endpoints.

### Gateway

The executable running on the host runs a virtual gateway that can be used by the VM.
@@ -144,7 +146,7 @@ nameserver 192.168.127.1
### Port forwarding

Dynamic port forwarding is supported over the host HTTP API when `gvproxy` was
started with `--listen`, but also in the VM over http://192.168.127.1:80.
started with `--listen` or `--services`, but also in the VM over http://192.168.127.1:80.

Expose a port:
```
@@ -207,3 +209,6 @@ This is the same behaviour as [slirp](https://wiki.qemu.org/index.php/Documentat
2. Each time, a client sends a http request, the process creates and sends the appropriate Ethernet packets to the VM.
3. The tap device receives the packets and injects them in the kernel.
4. The http server receives the request and send back the response.

### Development
Developers who want to work on gvisor-tap-vsock should visit the [Development](./DEVELOPMENT.md) document.
47 changes: 29 additions & 18 deletions cmd/gvproxy/main.go
Original file line number Diff line number Diff line change
@@ -30,22 +30,23 @@ import (
)

var (
debug bool
mtu int
endpoints arrayFlags
vpnkitSocket string
qemuSocket string
bessSocket string
stdioSocket string
vfkitSocket string
forwardSocket arrayFlags
forwardDest arrayFlags
forwardUser arrayFlags
forwardIdentify arrayFlags
sshPort int
pidFile string
exitCode int
logFile string
debug bool
mtu int
endpoints arrayFlags
vpnkitSocket string
qemuSocket string
bessSocket string
stdioSocket string
vfkitSocket string
forwardSocket arrayFlags
forwardDest arrayFlags
forwardUser arrayFlags
forwardIdentify arrayFlags
sshPort int
pidFile string
exitCode int
logFile string
servicesEndpoint string
)

const (
@@ -74,6 +75,7 @@ func main() {
flag.Var(&forwardIdentify, "forward-identity", "Path to SSH identity key for forwarding")
flag.StringVar(&pidFile, "pid-file", "", "Generate a file with the PID in it")
flag.StringVar(&logFile, "log-file", "", "Output log messages (logrus) to a given file path")
flag.StringVar(&servicesEndpoint, "services", "", "Exposes the same HTTP API as the --listen flag, without the /connect endpoint")
flag.Parse()

if version.ShowVersion() {
@@ -262,7 +264,7 @@ func main() {
}

groupErrs.Go(func() error {
return run(ctx, groupErrs, &config, endpoints)
return run(ctx, groupErrs, &config, endpoints, servicesEndpoint)
})

// Wait for something to happen
@@ -310,7 +312,7 @@ func captureFile() string {
return "capture.pcap"
}

func run(ctx context.Context, g *errgroup.Group, configuration *types.Configuration, endpoints []string) error {
func run(ctx context.Context, g *errgroup.Group, configuration *types.Configuration, endpoints []string, servicesEndpoint string) error {
vn, err := virtualnetwork.New(configuration)
if err != nil {
return err
@@ -326,6 +328,15 @@ func run(ctx context.Context, g *errgroup.Group, configuration *types.Configurat
httpServe(ctx, g, ln, withProfiler(vn))
}

if servicesEndpoint != "" {
log.Infof("enabling services API. Listening %s", servicesEndpoint)
ln, err := transport.Listen(servicesEndpoint)
if err != nil {
return errors.Wrap(err, "cannot listen")
}
httpServe(ctx, g, ln, vn.ServicesMux())
}

ln, err := vn.Listen("tcp", fmt.Sprintf("%s:80", gatewayIP))
if err != nil {
return err
8 changes: 3 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
@@ -5,34 +5,33 @@ go 1.22.0
require (
github.com/Microsoft/go-winio v0.6.2
github.com/apparentlymart/go-cidr v1.1.0
github.com/areYouLazy/libhosty v1.1.0
github.com/containers/winquit v1.1.0
github.com/coreos/stream-metadata-go v0.4.5
github.com/dustin/go-humanize v1.0.1
github.com/fsnotify/fsnotify v1.8.0
github.com/google/gopacket v1.1.19
github.com/insomniacslk/dhcp v0.0.0-20240710054256-ddd8a41251c9
github.com/linuxkit/virtsock v0.0.0-20220523201153-1a23e78aa7a2
github.com/mdlayher/vsock v1.2.1
github.com/miekg/dns v1.1.62
github.com/miekg/dns v1.1.63
github.com/onsi/ginkgo v1.16.5
github.com/onsi/gomega v1.36.2
github.com/opencontainers/go-digest v1.0.0
github.com/pkg/errors v0.9.1
github.com/qdm12/dns/v2 v2.0.0-rc6
github.com/sirupsen/logrus v1.9.3
github.com/songgao/packets v0.0.0-20160404182456-549a10cd4091
github.com/songgao/water v0.0.0-20200317203138-2b4b6d7c09d8
github.com/stretchr/testify v1.10.0
github.com/vishvananda/netlink v1.3.0
golang.org/x/crypto v0.32.0
golang.org/x/mod v0.22.0
golang.org/x/sync v0.10.0
golang.org/x/sys v0.29.0
gvisor.dev/gvisor v0.0.0-20240916094835-a174eb65023f
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fsnotify/fsnotify v1.8.0 // indirect
github.com/google/btree v1.1.2 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/mdlayher/socket v0.4.1 // indirect
@@ -43,7 +42,6 @@ require (
github.com/u-root/uio v0.0.0-20240224005618-d2acac8f3701 // indirect
github.com/vishvananda/netns v0.0.4 // indirect
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
golang.org/x/mod v0.22.0 // indirect
golang.org/x/net v0.33.0 // indirect
golang.org/x/text v0.21.0 // indirect
golang.org/x/time v0.5.0 // indirect
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -54,8 +54,8 @@ github.com/mdlayher/socket v0.4.1 h1:eM9y2/jlbs1M615oshPQOHZzj6R6wMT7bX5NPiQvn2U
github.com/mdlayher/socket v0.4.1/go.mod h1:cAqeGjoufqdxWkD7DkpyS+wcefOtmu5OQ8KuoJGIReA=
github.com/mdlayher/vsock v1.2.1 h1:pC1mTJTvjo1r9n9fbm7S1j04rCgCzhCOS5DY0zqHlnQ=
github.com/mdlayher/vsock v1.2.1/go.mod h1:NRfCibel++DgeMD8z/hP+PPTjlNJsdPOmxcnENvE+SE=
github.com/miekg/dns v1.1.62 h1:cN8OuEF1/x5Rq6Np+h1epln8OiyPWV+lROx9LxcGgIQ=
github.com/miekg/dns v1.1.62/go.mod h1:mvDlcItzm+br7MToIKqkglaGhlFMHJ9DTNNWONWXbNQ=
github.com/miekg/dns v1.1.63 h1:8M5aAw6OMZfFXTT7K5V0Eu5YiiL8l7nUAkyN6C9YwaY=
github.com/miekg/dns v1.1.63/go.mod h1:6NGHfjhpmr5lt3XPLuyfDJi5AXbNIPM9PY6H6sF1Nfs=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
Loading