Skip to content

[pull] main from u-root:main #119

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

Open
wants to merge 46 commits into
base: main
Choose a base branch
from
Open

[pull] main from u-root:main #119

wants to merge 46 commits into from

Conversation

pull[bot]
Copy link

@pull pull bot commented Apr 13, 2025

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.1)

Can you help keep this open source service alive? 💖 Please sponsor : )

@pull pull bot added the ⤵️ pull label Apr 13, 2025
lersek and others added 24 commits April 15, 2025 16:35
cmd.connection() in "netcat.go" rejects SOCKET_TYPE_UNIX when
SSLConfig.Enabled or SSLConfig.VerifyTrust is set.

Therefore, checking for (SSLConfig.Enabled or SSLConfig.VerifyTrust) under
SOCKET_TYPE_UNIX in cmd.setupListener() in "listen.go" can only yield
false. Remove this dead check.

Best viewed with "git show -U5".

Signed-off-by: Laszlo Ersek <[email protected]>
…ource

In a subsequent patch, I'll rewrite SSLOptions.GenerateTLSConfiguration().
So that hunks of the old and the new function not be interleaved in that
patch, move the current code verbatim to a new source file, temporarily.

Best viewed with "git show --no-renames --color-moved=zebra".

Signed-off-by: Laszlo Ersek <[email protected]>
GenerateTLSConfiguration() currently works identically in client mode and
server mode. This is wrong for several reasons:

(1) "--ssl-verify" only makes sense in client mode (neither nmap's ncat,
    nor u-root's netcat, support client authentication in server mode).
    Ignore "-ssl-verify" in server mode. (This is also what nmap's ncat
    does.)

(2) "--ssl-trustfile" only makes sense if "--ssl-verify" is in effect;
    ignore "--ssl-trustfile" otherwise.

(3) "--ssl-cert" and "--ssl-key" are indeed required in server mode, but
    they should be possible to omit in client mode; make them optional in
    client mode.

    Note that, if these options are set in client mode, an interfacing
    *netcat* server still does not authenticate the client; however, a
    *different* SSL server could try to authenticate the client.

(4) "--ssl-servername" only makes sense in client mode; ignore it in
    server mode.

Add 39 unit tests for covering every *path* (not just every branch) in
GenerateTLSConfiguration().

Signed-off-by: Laszlo Ersek <[email protected]>
Enable the netcatVM() helper function to take any number of trailing
"uimage.Modifier" arguments. This is a pure refactoring; no observable
change.

Best viewed with "git show -b -W".

Signed-off-by: Laszlo Ersek <[email protected]>
Demonstrate certificate validation and data transfer.

Signed-off-by: Laszlo Ersek <[email protected]>
Remove unimplemented features.

Signed-off-by: Jens Drenhaus <[email protected]>
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.37.0 to 0.38.0.
- [Commits](golang/net@v0.37.0...v0.38.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-version: 0.38.0
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
when context will be cancelled cleanup will be executed in a loop, this
probably never happens because context is context.Background(), but I
think its better to exit function anyway.

Signed-off-by: Siarhiej Siemianczuk <[email protected]>
Signed-off-by: Siarhiej Siemianczuk <[email protected]>
Signed-off-by: Siarhiej Siemianczuk <[email protected]>
SMBIOSBase returns base address and size of header. Since SMBIOSBase
might return either base address SMBIOS2 or SMBIO3, we need a way
to distinguish the actual version of SMBIOS.

Introudce a new method to get SMBIO3 header size. This method allows
caller to compare the size of header to figure out the SMBIOS version.

Signed-off-by: Ajan Zhong <[email protected]>
According to EDK2 UPL implementation, SMBIOS3 info can be provided
by device tree info only. Add SMBIOS3 child node in reserved memory
node to provide SMBIOS3 info.

Signed-off-by: Ajan Zhong <[email protected]>
In previous implementation of universalpayload.Load() method, execution
will be handed over to Universal Payload directly. In this case, warning
messages need to be printed inside universalpayload package in case we
succeed to load and boot Universal Payload.

In order to keep universalpayload package without any warning printed,
separate universalpayload.Load() method to Load() and Exec(), then any
warning messages can be retrieved from return value of Load() method,
and print warning messages out of universalpayload package before caller
invokes Exec() method.

Signed-off-by: Ajan Zhong <[email protected]>
Returns any warning message produced during universalpayload package
loading Universal Paylaod binary to kexec, then kexec prints warning
messages.

This logic ensures universalpayload package never prints message when
it succees to load Universal Payload binary.

Signed-off-by: Ajan Zhong <[email protected]>
Add test case to cover constructing SMBIOS3 node in Device Tree.

Signed-off-by: Ajan Zhong <[email protected]>
Signed-off-by: Siarhiej Siemianczuk <[email protected]>
CONFIG_NET_CLS_U32=y is necessary for the upcoming "tc" integration test.

Signed-off-by: Laszlo Ersek <[email protected]>
Start using the kernels with CONFIG_NET_CLS_U32=y, from commit
f0e05c3 (".circleci/images: enable the tc-u32 filter type in kernel
configs", 2025-04-25).

(I visited

  https://ghcr.io/u-root/u-root/test-kernel-amd64
  https://ghcr.io/u-root/u-root/test-kernel-arm
  https://ghcr.io/u-root/u-root/test-kernel-arm64

with my browser, and grabbed the digests of the most recently built images
that were tagged as "main".)

Signed-off-by: Laszlo Ersek <[email protected]>
Non-root qdiscs have classes for parents, which are identified by class
IDs, not by flat integers. Fix the qdisc args parser.

Signed-off-by: Laszlo Ersek <[email protected]>
Deduplicate the fmt.Fprintf call.

Signed-off-by: Laszlo Ersek <[email protected]>
The output changes, for example, from

            TestDev2   htb
            TestDev2   sfq
            TestDev2   sfq
            TestDev2   sfq

to

            TestDev2   qdisc htb 1: root
            TestDev2   qdisc sfq 30: parent 1:30
            TestDev2   qdisc sfq 10: parent 1:10
            TestDev2   qdisc sfq 20: parent 1:20

Signed-off-by: Laszlo Ersek <[email protected]>
The output changes, for example, from

            TestDev2   qdisc htb 1: root

to

            TestDev2   qdisc htb 1: root r2q 10 default 0x30 direct_qlen 1000

Signed-off-by: Laszlo Ersek <[email protected]>
lersek and others added 17 commits April 25, 2025 15:47
getTickInUsec and CalcXMitTime were incorrectly ported from iproute2's
"tc" utility to u-root.

getTickInUsec is supposed to return a "double" (aka "float64") value, not
an integer; the value is in fact fractional on my system: 15.625. (Refer
to the "tick_in_usec" assignment in tc_core_init() in
"iproute2/tc/tc_core.c".)

Accordingly, CalcXMitTime is supposed to perform the last multiplication
in "float64", and return the ceiling only thereof as an integer. (Refer to
tc_calc_xmittime() and tc_core_time2tick() in "iproute2/tc/tc_core.c".)

This bug leads to an inexact "burst" calculation in ParseHTBClassArgs; fix
it.

Signed-off-by: Laszlo Ersek <[email protected]>
The debug output is not useful, it just messes up the standard output.

Signed-off-by: Laszlo Ersek <[email protected]>
The output changes, for example, from

            TestDev2   htb
            TestDev2   htb
            TestDev2   htb
            TestDev2   htb

to

            TestDev2   class htb 1:1 root
            TestDev2   class htb 1:10 parent 1:1
            TestDev2   class htb 1:20 parent 1:1
            TestDev2   class htb 1:30 parent 1:1

Signed-off-by: Laszlo Ersek <[email protected]>
The output changes, for example, from

            TestDev2   class htb 1:1 root
            TestDev2   class htb 1:10 parent 1:1
            TestDev2   class htb 1:20 parent 1:1
            TestDev2   class htb 1:30 parent 1:1

to

            TestDev2   class htb 1:1 root prio 0 rate 750000b ceil 750000b burst 15360b cburst 1600b
            TestDev2   class htb 1:10 parent 1:1 prio 0 rate 625000b ceil 625000b burst 15360b cburst 1600b
            TestDev2   class htb 1:20 parent 1:1 prio 0 rate 375000b ceil 750000b burst 15360b cburst 1600b
            TestDev2   class htb 1:30 parent 1:1 prio 0 rate 125b ceil 750000b burst 15360b cburst 1600b

Signed-off-by: Laszlo Ersek <[email protected]>
"tc filter" from the original iproute2 package accepts any nonempty prefix
of the words "priority" and "preference", for setting a filter priority.
The most commonly used prefixes, in practice, are "prio" and "pref"; add
"prio" to the list of words that u-root's tc recognizes.

Signed-off-by: Laszlo Ersek <[email protected]>
The management of filter prios and EtherType protos suffers from the
following list of problems:

1. In the "FArgs" structure, both the EtherType protocol field and the
   priority field of the filter ("protocol" and "pref") are needlessly
   represented as uint32 values. Make each a uint16 instead.

2. "FArgs.protocol" stands for the EtherType field of the Ethernet frame,
   and therefore it should be expressed in network byte order (i.e., big
   endian byte order); that's how the underlying TC machinery expects it.
   pkg/tc currently handles this field in native (host) byte order; fix
   it.

3. ParseProto and GetProtoFromInfo are supposedly *duals*; however, they
   operate at mismatched semantic levels:

   - ParseProto translates an EtherType name to a numeric EtherType
     identifier, but does not ensure proper (= big endian) byte order in
     the return value. Add the missing byte order conversion.

   - GetProtoFromInfo translates a numeric EtherType identifier to an
     EtherType name, but it insists on extracting the numeric EtherType
     identifier from the 32-bit Info field of a go-tc Object. Said field
     extraction is a separate responsibility, though. Therefore, keep only
     the field extraction in GetProtoFromInfo -- according to its name --,
     and separate ParseProto's *inverse operation* out to a new function
     called RenderProto.

4. The "htons for beggars" in the pre-patch GetProtoFromInfo is justified,
   but it is implemented incorrectly. The pre-patch code implements an
   unconditional byte-swap, which is wrong if the host byte order is big
   endian (that is, when the native byte order matches the network byte
   order). Instead, implement both HToNS and NToHS properly, in separate
   functions.

5. In order to add a new TC filter, the priority, and the numeric
   EtherType identifier (in network byte order) of the filter need to be
   combined into the 32-bit tc.Object.Msg.Info field. The logic that
   currently attempts to do this in AddFilter is mistaken:

   - the core.BuildHandle function (from tc-go) builds TC *handles*, not
     prio/proto combinations, and is totally unrelated;

   - even though the *internals* of core.BuildHandle resemble what we need
     to do for combining prio and proto into Info, AddFilter nonetheless
     calls core.BuildHandle with wrong arguments.

   Introduce the GetInfoFromPrefAndProto function, as the inverse
   operation of both GetProtoFromInfo and GetPrefFromInfo
   (simultaneously). While at it, simplify GetPrefFromInfo.

6. Clean up the TestParseProto and TestRenderProto unit tests, so that
   they *all* provide the numeric EtherType identifiers in network byte
   order, *and* that they do so explicitly.

This patch is too large, of course, but I couldn't find a way to fix all
the problems in small, incremental steps.

Signed-off-by: Laszlo Ersek <[email protected]>
The debug output is not useful, it just messes up the standard output.

Signed-off-by: Laszlo Ersek <[email protected]>
- Eliminate the colon (:) from the "protocol:" output, in order to bring
  u-root's output closer to that of iproute2's tc.

- Rearrange newlines, so that optional characteristics can be printed more
  easily later.

Signed-off-by: Laszlo Ersek <[email protected]>
Add a minimal sub-language of what is recognized by iproute2's tc-u32(8)
filter/classifier. Internally, each tc-u32 selector ("match" stanza) is
represented as a (u32 value, u32 mask, offset) triplet
<https://linux-tc-notes.sourceforge.net/tc/doc/cls_u32.txt>, so exposing
only the sub-language of tc-u32(8) that directly maps to this internal
representation suffices (albeit not very convenient) for classifying
packets.

Signed-off-by: Laszlo Ersek <[email protected]>
Adding the alternative string values:
-ascii AND netascii for ModeNETASCII
-binary AND octet for ModeOctet

Signed-off-by: Jens Drenhaus <[email protected]>
Indeces for low and high bound selects a half-open range which
includes the first element, but excludes the last one.

Fix that for local files slice in executePut().

Signed-off-by: Jens Drenhaus <[email protected]>
The flags/commands "verbose", "trace", "literal" are either not
supported by the uses go package or not implemented.

Remove them from the help text and remove the related code.

Signed-off-by: Jens Drenhaus <[email protected]>
This tftp server implementation is mainly for testing purposes.
It serves files of a given directory.

Signed-off-by: Jens Drenhaus <[email protected]>
The usage and other documentation has been moved to the package
doc comment in recent commits. The removed doc was used during
development.

Signed-off-by: Jens Drenhaus <[email protected]>
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.

5 participants