Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Use of this source code is governed by the license
# that can be found in the LICENSE file.

NET ?= 0
NET ?= none
DEBUG ?= 0
TAMAGO ?= $(shell go tool -n github.com/usbarmory/tamago/cmd/tamago)
BUILD_TAGS = linkcpuinit,linkramsize,linkramstart,linkprintk
Expand All @@ -13,8 +13,8 @@ CONSOLE ?= text
DEFAULT_EFI_ENTRY = \efi\boot\bootx64.efi
DEFAULT_LINUX_ENTRY = \loader\entries\arch.conf

ifeq ($(NET),1)
BUILD_TAGS := $(BUILD_TAGS),net
ifeq ($(NET),gvisor)
BUILD_TAGS := $(BUILD_TAGS),net,gvisor
endif

ifeq ($(DEBUG),1)
Expand Down Expand Up @@ -58,7 +58,7 @@ ifneq ($(OVMFVARS),)
QEMU_SNP := $(QEMU_SNP) -drive if=pflash,format=raw,file=$(OVMFVARS)
endif

ifeq ($(NET),1)
ifneq ($(NET),none)
QEMU := $(QEMU) -device virtio-net-pci,netdev=net0 -netdev tap,id=net0,ifname=tap0,script=no,downscript=no
QEMU_SNP := $(QEMU_SNP) -device virtio-net-pci,netdev=net0 -netdev tap,id=net0,ifname=tap0,script=no,downscript=no
endif
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ build:
* `CONSOLE`: set to either `com1` or `text` (default) controls the output
console to either serial port or UEFI console.

* `NET`: set to either `0` (default) or `1` controls enabling of UEFI
networking support (see _UEFI networking_).
* `NET`: set to `none` (default) or `gvisor` to control enabling of UEFI
networking support with a choice of network stack (see _UEFI networking_).

Build the `go-boot.efi` executable:

Expand Down
25 changes: 18 additions & 7 deletions cmd/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ func netCmd(_ *shell.Interface, arg []string) (res string, err error) {
return "", fmt.Errorf("could not set receive filters, %v", err)
}

iface := gnet.Interface{}
iface := gnet.Interface{
Stack: newStack(),
}

if arg[1] == ":" {
arg[1] = ""
Expand All @@ -88,15 +90,24 @@ func netCmd(_ *shell.Interface, arg []string) (res string, err error) {
return "", fmt.Errorf("could not initialize networking, %v", err)
}

if err = nic.StationAddress(false, iface.NIC.MAC); err != nil {
fmt.Errorf("could not set permanent station address, %v\n", err)
mac, err := iface.Stack.HardwareAddress()

if err != nil {
return "", fmt.Errorf("could not get stack hw address: %v", err)
}

if err = nic.StationAddress(false, mac); err != nil {
return "", fmt.Errorf("could not set permanent station address, %v", err)
}

if err = iface.Stack.EnableICMP(); err != nil {
return "", fmt.Errorf("could not enable ICMP, %v", err)
}

iface.EnableICMP()
go iface.NIC.Start()
go iface.Start()

// hook interface into Go runtime
net.SocketFunc = iface.Socket
net.SocketFunc = iface.Stack.Socket

if len(arg[3]) > 0 {
ip, _, _ := strings.Cut(arg[0], `/`)
Expand All @@ -121,7 +132,7 @@ func netCmd(_ *shell.Interface, arg []string) (res string, err error) {
go http.ListenAndServe(":80", nil)
}

return fmt.Sprintf("network initialized (%s %s)\n", arg[0], iface.NIC.MAC), nil
return fmt.Sprintf("network initialized (%s %s)\n", arg[0], mac), nil
}

func dnsCmd(_ *shell.Interface, arg []string) (res string, err error) {
Expand Down
16 changes: 16 additions & 0 deletions cmd/net_gvisor.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (c) The go-boot authors. All Rights Reserved.
//
// Use of this source code is governed by the license
// that can be found in the LICENSE file.

//go:build net && gvisor

package cmd

import (
"github.com/usbarmory/go-net"
)

func newStack() gnet.Stack {
return gnet.NewGVisorStack(1)
}
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ github.com/usbarmory/armory-boot v0.0.0-20260202115234-edf170b30f66 h1:EKfiE4TIq
github.com/usbarmory/armory-boot v0.0.0-20260202115234-edf170b30f66/go.mod h1:2cCdG4eUnVtrKyfbCc2A+0SHJl62Cgf4jEXTw/OvlW4=
github.com/usbarmory/go-net v0.0.0-20251003201608-93d9ffe808de h1:5O20CXXbFwjrqyDFtCyFUlxiRLCdc+ksT8MUihbjIDg=
github.com/usbarmory/go-net v0.0.0-20251003201608-93d9ffe808de/go.mod h1:+6WiKCFJtJQZdNM2VpwQsYGo/aBJ39pN7nWx6Td3Z8s=
github.com/usbarmory/tamago v1.26.1 h1:ZJkxM/+qNZTO631bJz5x/flhYb/ww1ura4H2BrZbX5I=
github.com/usbarmory/tamago v1.26.1/go.mod h1:7x0kUe5eE9S1z7Pi/C9RjF8E4JHWzqnE4cKzGl0hyug=
github.com/usbarmory/tamago v1.26.2 h1:lSB+tnxVAUFczwBu3oVkoAwJriFrxtQ7x/8Tu6lRQUc=
github.com/usbarmory/tamago v1.26.2/go.mod h1:+p26O/6sbXO3PWWC22bFEuK4qDBmNzW4EgtXfE+kgyQ=
golang.org/x/crypto v0.42.0 h1:chiH31gIWm57EkTXpwnqf8qeuMUi0yekh6mT2AvFlqI=
Expand Down