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

feat(livenet): get live image size from TFTP servers #390

Merged
merged 2 commits into from
Jan 17, 2025

Conversation

aafeijoo-suse
Copy link
Collaborator

While the current code handles HTTP and FTP headers, parsing Content-Length, TFTP servers need a special handling. E.g.:

$ curl -sIL tftp://127.0.0.1/leap-15.3/Leap-15.3_appliance.x86_64-1.15.3.iso
$ echo $?
8

Being more verbose (-v), we can see:

$ curl -vsIL tftp://127.0.0.1/leap-15.3/Leap-15.3_appliance.x86_64-1.15.3.iso
*   Trying 127.0.0.1:69...
* Connected to 127.0.0.1 (127.0.0.1) port 69
* set timeouts for state 0; Total  300000, retry 6 maxtry 50
* got option=(tsize) value=(285802496)
* tsize parsed from OACK (285802496)
* got option=(timeout) value=(6)
* got option=(blksize) value=(512)
* blksize parsed from OACK (512) requested (512)
* Connected for receive
* set timeouts for state 1; Total  0, retry 72 maxtry 50
* Closing connection
$ echo $?
8

So, in this case, we can ignore the non-zero exit from curl and parse the tsize value received.

(cherry picked from commit dracut-ng/dracut-ng@93df9ad)

While the current code handles HTTP and FTP headers, parsing `Content-Length`,
TFTP servers need a special handling. E.g.:

```
$ curl -sIL tftp://127.0.0.1/leap-15.3/Leap-15.3_appliance.x86_64-1.15.3.iso
$ echo $?
8
```

Being more verbose (`-v`), we can see:

```
$ curl -vsIL tftp://127.0.0.1/leap-15.3/Leap-15.3_appliance.x86_64-1.15.3.iso
*   Trying 127.0.0.1:69...
* Connected to 127.0.0.1 (127.0.0.1) port 69
* set timeouts for state 0; Total  300000, retry 6 maxtry 50
* got option=(tsize) value=(285802496)
* tsize parsed from OACK (285802496)
* got option=(timeout) value=(6)
* got option=(blksize) value=(512)
* blksize parsed from OACK (512) requested (512)
* Connected for receive
* set timeouts for state 1; Total  0, retry 72 maxtry 50
* Closing connection
$ echo $?
8
```

So, in this case, we can ignore the non-zero exit from curl and parse the
`tsize` value received.

(cherry picked from commit dracut-ng/dracut-ng@93df9ad)
Copy link
Collaborator

@tblume tblume left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@aafeijoo-suse aafeijoo-suse merged commit 307c9d3 into openSUSE:SUSE/059 Jan 17, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants