Skip to content

Commit

Permalink
Add TFTP blocksize flag: (#369)
Browse files Browse the repository at this point in the history
## Description


Allows customizing TFTP blocksize at runtime.

## Why is this needed



Fixes: #368 

## How Has This Been Tested?





## How are existing users impacted? What migration steps/scripts do we need?





## Checklist:

I have:

- [ ] updated the documentation and/or roadmap (if required)
- [ ] added unit or e2e tests
- [ ] provided instructions on how to upgrade
  • Loading branch information
mergify[bot] authored Nov 6, 2023
2 parents cd6a3ec + 8888658 commit bbd2b14
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ FLAGS
-syslog-enabled [syslog] enable Syslog server(receiver) (default "true")
-ipxe-script-patch [tftp/http] iPXE script fragment to patch into served iPXE binaries served via TFTP or HTTP
-tftp-addr [tftp] local IP:Port to listen on for iPXE TFTP binary requests (default "172.17.0.2:69")
-tftp-block-size [tftp] TFTP block size a value between 512 (the default block size for TFTP) and 65456 (the max size a UDP packet payload can be) (default "512")
-tftp-enabled [tftp] enable iPXE TFTP binary server) (default "true")
-tftp-timeout [tftp] iPXE TFTP binary server requests timeout (default "5s")
```
Expand Down
1 change: 1 addition & 0 deletions cmd/smee/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ func tftpFlags(c *config, fs *flag.FlagSet) {
fs.StringVar(&c.tftp.bindAddr, "tftp-addr", detectPublicIPv4(":69"), "[tftp] local IP:Port to listen on for iPXE TFTP binary requests")
fs.DurationVar(&c.tftp.timeout, "tftp-timeout", time.Second*5, "[tftp] iPXE TFTP binary server requests timeout")
fs.StringVar(&c.tftp.ipxeScriptPatch, "ipxe-script-patch", "", "[tftp/http] iPXE script fragment to patch into served iPXE binaries served via TFTP or HTTP")
fs.IntVar(&c.tftp.blockSize, "tftp-block-size", 512, "[tftp] TFTP block size a value between 512 (the default block size for TFTP) and 65456 (the max size a UDP packet payload can be)")
}

func ipxeHTTPBinaryFlags(c *config, fs *flag.FlagSet) {
Expand Down
8 changes: 5 additions & 3 deletions cmd/smee/flag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ func TestParser(t *testing.T) {
bindAddr: "192.168.2.4:514",
},
tftp: tftp{
enabled: true,
timeout: 5 * time.Second,
bindAddr: "192.168.2.4:69",
blockSize: 512,
enabled: true,
timeout: 5 * time.Second,
bindAddr: "192.168.2.4:69",
},
ipxeHTTPBinary: ipxeHTTPBinary{
enabled: true,
Expand Down Expand Up @@ -111,6 +112,7 @@ FLAGS
-syslog-enabled [syslog] enable Syslog server(receiver) (default "true")
-ipxe-script-patch [tftp/http] iPXE script fragment to patch into served iPXE binaries served via TFTP or HTTP
-tftp-addr [tftp] local IP:Port to listen on for iPXE TFTP binary requests (default "%[1]v:69")
-tftp-block-size [tftp] TFTP block size a value between 512 (the default block size for TFTP) and 65456 (the max size a UDP packet payload can be) (default "512")
-tftp-enabled [tftp] enable iPXE TFTP binary server) (default "true")
-tftp-timeout [tftp] iPXE TFTP binary server requests timeout (default "5s")
`, defaultIP)
Expand Down
14 changes: 8 additions & 6 deletions cmd/smee/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@ type syslogConfig struct {
}

type tftp struct {
enabled bool
bindAddr string
timeout time.Duration
blockSize int
enabled bool
ipxeScriptPatch string
timeout time.Duration
}

type ipxeHTTPBinary struct {
Expand Down Expand Up @@ -144,10 +145,11 @@ func main() {
tftpServer.EnableTFTPSinglePort = true
if ip, err := netip.ParseAddrPort(cfg.tftp.bindAddr); err == nil {
tftpServer.TFTP = ipxedust.ServerSpec{
Disabled: false,
Addr: ip,
Timeout: cfg.tftp.timeout,
Patch: []byte(cfg.tftp.ipxeScriptPatch),
Disabled: false,
Addr: ip,
Timeout: cfg.tftp.timeout,
Patch: []byte(cfg.tftp.ipxeScriptPatch),
BlockSize: cfg.tftp.blockSize,
}
// start the ipxe binary tftp server
log.Info("starting tftp server", "bind_addr", cfg.tftp.bindAddr)
Expand Down

0 comments on commit bbd2b14

Please sign in to comment.