Compare commits

..
333 Commits
Author SHA1 Message Date
Joachim Wiberg a672074cef buildroot: fix libyang license hash, updated copyright year
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-28 15:25:11 +02:00
Joachim Wiberg 8f8766c340 package/python-libyang: allow building also for target
No need to lock it down solely for host build-time use.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-28 15:24:28 +02:00
Joachim Wiberg 46598a875d package/python-yangdoc: fix misspelled DEPENDENCIES variable
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-28 15:23:27 +02:00
Joachim Wiberg d523e588d6 packakge: spellcheck license file references
Minor spelling error and mistakes, hashes actually OK.

 - LICENCE -> LICENSE
 - LICENCE -> COPYING

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-28 15:21:48 +02:00
Joachim Wiberg 269c0f2b00 .github: generate checksum files also for latest build
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-28 14:49:25 +02:00
Joachim Wiberg 53c079e1b2 doc: update ChangeLog, final update for v24.06.0-rc1
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-28 12:54:27 +02:00
Joachim Wiberg 10744c5116 board/common: extract YANG documentation for all builds
This change builds on top of the earlier work to bootstrap Infix YANG
modules at build time.  Adding a step at the end of post-build.sh to
call the yangdoc tool.  The resulting yangdoc.html is a stand-alone HTML
file of (almost) all YANG nodes.  Almost because some top-level nodes
are unused by Infix atm. and have been filtered out for readability.

Fixes #432

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-28 12:54:27 +02:00
Joachim Wiberg edaaa33ddc package/python-yangdoc: new package
To be used with automatic generation of YANG documentation extracted
from sysrepo at build time.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-28 12:54:27 +02:00
Joachim Wiberg 31a30c736a package/python-libyang: new package
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-28 12:54:27 +02:00
Joachim Wiberg 5a3897b1aa package/confd: drop empty help text
This silences an annoying warning at defconfig/oldconfig about MD5CRYPT.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-28 12:54:27 +02:00
Joachim Wiberg 1fac47a728 doc: split CLI tutorial into multile files
Fixes #455

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-28 12:54:27 +02:00
Joachim Wiberg f1585476da confd: fix ietf-tcp-common version
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-28 12:54:27 +02:00
Mattias Walström d27153ea95 Refactor randomization of transport protocol
Simplify the logic and add a parameter to the command line parser
instead of environment variable.
2024-06-27 15:43:06 +02:00
Mattias Walström e3cd981830 restconf: Add workaround for bug in request 2.32.x 2024-06-27 15:43:06 +02:00
Mattias Walström 3b8505f8c4 sysrepo-cpp: Add timeout to getData 2024-06-27 15:43:06 +02:00
Mattias Walström 3feea4d9e2 rousette: Add timeout option 2024-06-27 15:43:06 +02:00
Mattias Walström 91c55ddeb8 backport fix for extending timeouts in initctl 2024-06-27 15:43:06 +02:00
Mattias Walström 4a3559d88f infamy: Remove duplicate function
Get management ip was implemented in two functions, removing one.
2024-06-27 15:43:06 +02:00
Mattias Walström d340ba7407 infamy: Wait for NETCONF and RESTCONF
Also remove some code duplication.
2024-06-27 15:43:06 +02:00
Mattias Walström b790c46dc4 restconf: Bugfix download yang modules
Actually check if the model is already downloaded,
before download.
2024-06-27 15:43:06 +02:00
Mattias Walström b57353294f test: usb: Make possible to run on physical devices
Virtual devices always have two USB ports, but physical, may have more
or less.
2024-06-27 15:43:06 +02:00
Mattias Walström c05ed73ff5 Document randomisation of restconf/netconf 2024-06-27 15:43:06 +02:00
Mattias Walström 4cc23092b2 restconf: Implement actions
And refactor how it was implemented in netconf
2024-06-27 15:43:06 +02:00
Mattias Walström 2919c23fde tests: containers: Adapt tests to work with restconf
Move the web port used in containers from 80 -> 91
this to not collide with nginx which is required
for restconf.
2024-06-27 15:43:06 +02:00
Mattias Walström df7dab5951 infamy: Randomize tests for restconf/netconf 2024-06-27 15:43:06 +02:00
Mattias Walström dd0f1610ab Add get_current_time_with_offset to netconf/restconf
This allows the timezone tests to run on restconf as well
2024-06-27 15:43:06 +02:00
Mattias Walström 29f56eb384 Restconf, netconf: Implement full feature compatibility
Abstract functions and common functions are located in transport.py
Some quirks has been required due to how rousette works,
these functions has been added to the abstract class

Can be removed when rousette behaves as expected.
2024-06-27 15:43:06 +02:00
Mattias Walström ba4d4caeb3 infamy: netconf: Implement deletion by xpath
This is the only way to delete with restconf so it it must also be
implemented in netconf. This replace the put_diff_dict function.

Also: how the xpath looks is different in restconf/netconf therefore
each protocl has a get_xpath() function as well.
2024-06-27 15:43:06 +02:00
Mattias Walström 0595628e97 infamy: Adapt for operational changes between netconf and restconf 2024-06-27 15:43:06 +02:00
Mattias Walström 095b256971 Adapt tests to be able to run them with NETCONF and RESTCONF 2024-06-27 15:43:06 +02:00
Mattias Walström ef09c65f40 restconf: Add support to download YANG-modules 2024-06-27 15:43:06 +02:00
Joachim Wiberg 2ecb6922a0 doc: update changelog for upcoming release
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-25 19:08:22 +02:00
Joachim Wiberg 4c3a46b288 package/klish: bump for improved error message on missing command
Replaces:

    Error: Illegal command

with:

    Error: Command not found, or incomplete.  Try ? for help or Tab for completion.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-25 19:08:22 +02:00
Joachim Wiberg 95a5f153df statd: increase port column width for 'show bridge mdb'
Fixes #462

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-25 19:08:22 +02:00
Joachim Wiberg afbe5ca20b confd: when disabling containers, delete in background
Instead of potentially blocking sysrepo, which has a 5 second timeout,
we move 'container delete' jobs to be run by the execd queue.

Fixes #479

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-25 19:08:22 +02:00
Joachim Wiberg 0edc2d5b70 execd: add support for SNN and KNN queue scripts
This change makes sure execd calls KNN style scripts before SNN,
allowing confd to post teardown jobs that are guaranteed to run
before any jobs to create new resources run.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-25 19:08:22 +02:00
Joachim Wiberg 56a5388242 confd: fix warning in call to initctl
ietf-system.c: In function ‘change_hostname’:
ietf-system.c:1722:9: warning: ignoring return value of ‘system’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
 1722 |         system("initctl -nbq touch netbrowse");
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-25 19:08:22 +02:00
Joachim Wiberg 4202c07926 package/curios-httpd: bump to v24.05.0
- Fixes to missing BusyBox tools (cat)
 - Bump Buildroot to this year's LTS (2024.02)

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-25 19:08:22 +02:00
Joachim Wiberg 3e045e62b1 confd: adjust libxcrypt dependency slightly
Ubuntu 22.04 (ubuntu-latest runner on GitHub) has a slightly earlier
version of libxcrypt.  The only hard requirement we have is yescrypt
support, so we can relax the configure check slightly to be able to
run coverity scan.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-25 17:22:36 +02:00
Joachim Wiberg 773b229749 .github: update coverity job to include libxrypt, drop augeas
We recently dropped Augas from confd and this branch adds support for
$0$cleartext passwords, which require libxcrypt.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-25 17:22:36 +02:00
Joachim Wiberg dcdc2ba24d confd: follow-up to 7d9257f
First, actually remove setup.sh.  No reason to have the old version
lingering in the repo confusing devs.  Also simplify script heading
dropping previous netopeer2 text and distilling the comment before
sourcing the .inc file.

Silence the install/update, dropping -v -- no need to be overly verbose
now that we now the new yang loader works at build time.

Crucially -- fix a bug in UPDATE_MODULE(), missing closing '

Simplify naming and location of .inc files.  No need for the long
filenames, or the new directory, the directory name gives plenty of
context.

Add reminder of duplicate infix-interfaces.yang in .inc files -- this
duplication is unfortunate and we should try to fix this better.  We
will forget to update one or the other any day ...

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-25 17:22:36 +02:00
Joachim Wiberg 3e7340cb52 confd: add support for $0$cleartext password
Finalize support for IETF System YANG incl. all IANA crypt-hash types.

This patch builds on the earlier work adding yescrypt and $factory$ key
word.  The YANG description for the crypt-hash type override has been
significantly udpated to discourage use of $0$cleartext passwords.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-25 17:22:36 +02:00
Joachim Wiberg ed88a92fac confd: add support for vendor/product specific factory-config
With the recent changes to confd to support: hostname format specifiers,
$factory$ default keyword for password, and on-the-fly generation of the
NETCONF SSH host keys, the system no longer depend on the very intricate
confd gen-* scripts to create factory-config and failure-config.

This patch set adds support for detecting and installing product/vendor
specific static factory-config and failure-config files.  See the confd
README for details.

To facilitate generation, e.g., of the NETCONF SSH host keys, the confd
daemon must be running when bootstrapping the first startup-config from
eithe generated or static factory-config.  This is why the bootstrap and
load helper scripts have been changed.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-25 17:22:36 +02:00
Joachim Wiberg 3aead122ee package/finit: backport batch mode for runparts
Drop annoying escape characters from ixinit when logging to syslog.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-25 17:22:36 +02:00
Joachim Wiberg 067c911640 confd: refactor netconf hostkey generation
This patch adds support for an empty "genkey" pair in the keystore for
the NETCONF hostkeys.  Primarily intended for static factory-config.

When a configuration is loaded and confd detects a missing public or
private key in the "genkey" asymmetric key, it loads generated keys
from disk and store in the running datastore.

Fixes #435

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-25 17:22:36 +02:00
Joachim Wiberg 935bb0d808 confd: minor, fix linter warning (value unused)
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-25 17:22:36 +02:00
Joachim Wiberg 170392cdb1 libsrx: new helper function srx_isset()
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-25 17:22:36 +02:00
Joachim Wiberg 2c81c7cdb6 doc: update ChangeLog for upcoming v24.06 release
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-25 17:22:36 +02:00
Joachim Wiberg 0d0d97ad3f test: verify hostname format %h-%m in running and operational
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-25 17:22:36 +02:00
Joachim Wiberg 32ef120928 test: verify admin user default password in running and operational
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-25 17:22:36 +02:00
Joachim Wiberg e5820e1e55 test: new method get_password() in Env
Allow tests to fetch expected factory default password of devices.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-25 17:22:36 +02:00
Joachim Wiberg fb424709d7 test: minor, fix pep-8 warnings from pylint
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-25 17:22:36 +02:00
Joachim Wiberg 99117fc90f conf: add support for handling breaking model changes
Add metadata 'version' field to ietf-system to be able to detect .cfg
file version.  Fixes #308

Add early boot script to automatically migrate configuration files of
older version to new syntax.  Fixes #178

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-25 17:22:36 +02:00
Joachim Wiberg 8851b279f5 confd: merge infix-shell-types.yang with infix-system.yang
All typedefs and identities should be declared in the module that uses
them unless other modules need them.  This change also makes it easier
to work with tools like yanglint and pyang.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-25 17:22:36 +02:00
Joachim Wiberg 86a962795a confd: operational support for ietf-system hostname and passwords
Fixes #478

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-25 17:22:36 +02:00
Joachim Wiberg 3a40bbca39 confd: silence setup.sh and fix update bug
This patch silences the previously very verbose setup.sh script, and
crucially also fixes a bug in UPDATE_MODULE().  Missing closing '

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-25 17:22:36 +02:00
Joachim Wiberg 4deeacd0ad confd: change failure mode hostname to capitals
For consistency with UNKNOWN base mac address, and making it easier for
the user to actually notice the fault condition.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-25 17:22:36 +02:00
Joachim Wiberg 1361d02e59 confd: add support for hostname format specifiers
The following specifiers are currently supported:

 - %h default hostname from /etc/os-release
 - %i value of ID from /etc/os-release
 - %m last three octets of base MAC, e.g., c0-ff-ee

Fixes #435

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-25 17:22:36 +02:00
Joachim Wiberg 173e6040fe confd: allow non-admin users to use the CLI, NACM rules apply
With this patch, users not in the NACM admin group and a login shell set
to clish can now log in to the CLI.  Prior to this change only members
of the UNIX group 'wheel' could open the klishd socket.

The patch adds another group, 'sys-cli', which acts as a capability for
users.  An admin user (member of the admin group) will now be member of
both the UNIX 'wheel' and 'sys-cli' groups.  A non-admin user that has
shell set to 'clish' will only be member of the 'sys-cli' group.  Other
users will not be mapped to any UNIX group and have only permissions set
in NACM.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-25 17:22:36 +02:00
Joachim Wiberg 3cbafd8ef4 confd: add supoprt for yescrypt
Fixes #447

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-25 17:22:36 +02:00
Joachim Wiberg 75d560440e confd: allow web services in failure mode
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-25 17:22:36 +02:00
Joachim Wiberg 174bf7dc6f confd: add support for $factory$ password hash
This patch simplifies the handling of factory default password for the
admin user by overloading the ietf-system password type.  The new type,
$factory$, acts a system hint to use any device specific (or built-in
software/device-tree) default password hash.

Fixes #435

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-25 17:22:36 +02:00
Joachim Wiberg 83d2e1b0ae container: clean up after unpacking oci archive
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-25 17:22:36 +02:00
Joachim Wiberg b251cb56f0 container: enable logging of output from start/stop action
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-25 17:22:36 +02:00
Joachim Wiberg fec19e1808 container: fix timeout handling in restart
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-25 17:22:36 +02:00
Joachim Wiberg aa529242c7 klish-plugin-infix: ensure filesystem is synced after 'copy' command
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-25 17:22:36 +02:00
Joachim Wiberg 03a8ea9500 package/klish-plugin-sysrepo: fix 'show leaf-node' in configure
This patch bumps klish-plugins-sysrepo to fix the annoying issue with
the CLI not supporting, e.g. "show hostname" in system config context.

Details: https://github.com/kernelkit/klish-plugin-sysrepo/issues/3

The problem was two-fold, first we used the wrong ptype for 'show'
(and 'diff') commands, so srp_show() was not even called.  Then the
klish-plugin-sysrepo code did not account for show being called for
leaf nodes.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-25 17:22:36 +02:00
Ahmed KaricandMattias Walström 2b1543ba11 confd: Minor Update on YANG Modules Setup Refactor
- Fix indentations:
    - Corrected indentations in confd.mk to adhere to Buildroot coding
     standards

  - Relocate YANG Modules List Files:
    - Moved the YANG modules list files (.inc) from package/confd to
     src/confd

  - Add Missing YANG Module:
    - Included infix-interfaces@2024-01-15.yang in
      yang_modules_confd.inc
    - This module was missing in the non-containerized build and is now
      correctly added
2024-06-19 15:41:33 +02:00
Mattias Walström b92276bfac docker: Upgrade requests to silence dependabot
Unintended leak of Proxy-Authorization header in requests #1
Requests `Session` object does not verify requests after making first request with verify=False #2
2024-06-19 15:35:51 +02:00
Mattias Walström ee0b035e4b doc: Update Changelog 2024-06-19 15:35:51 +02:00
Mattias Walström ac70c6bffc kernel: Upgrade kernel to 6.6.34 2024-06-19 15:35:51 +02:00
Mattias Walström 61b9e6307c buildroot: Update buildroot to 2024.02.3 2024-06-19 15:35:51 +02:00
Mattias Walström f0f8b7e06a containers: Remove empty entrypoint
This made it impossible to use the "command" in container
configuration.

This fix issue #476
2024-06-19 15:35:51 +02:00
Mattias Walström dadf81baf7 rousette: Import upstream patch to remove systemd dependancy 2024-06-19 15:35:51 +02:00
Mattias Walström f819279aea qemu: Make the size of /var configurable 2024-06-19 15:35:51 +02:00
Mattias Walström 6ce0fe7607 confd: Stop bfdd if ospf is removed
This was not handled in the previous design.
2024-06-19 15:35:51 +02:00
Ahmed KaricandMattias Walström 7d9257f5f6 confd: refactor yang modules setup script for better modularity and maintainability
- Moved setup.sh and yang_modules files from infix/src/confd/scripts/ to infix/utils/ to streamline the repository structure
- Updated confd.mk to correctly reference the new location of the setup script
- Introduced yang_modules_<type>.inc file to list all YANG modules for improved clarity and maintainability
- Modified the new setup script to dynamically source module lists from yang_modules_<type>.inc
2024-06-18 18:54:18 +02:00
Tobias Waldekranz 8baca7df03 test: unit: defconfig: Skip root login checks for all boot configs
Also, hoist the whitelist check up one level, so that we can report
which configs we are exempting, and which ones we are actually
checking.
2024-06-17 14:59:27 +02:00
Tobias Waldekranz 34a6a0ecc4 uboot: Allow untrusted images to boot in developer mode
Since a user has access to the shell in developer mode, we might as
well allow booting through the standard boot scripts as well. This
means that a product with a bootloader only accepting images signed by
Company A can now be configured to netboot a regular developer image
without any special user interaction.
2024-06-17 14:59:27 +02:00
Tobias Waldekranz 97c38ee024 cn9130-crb: Update U-Boot glue after bootmenu additions
We no longer need to set bootdelay on development platforms. You can
now always get to the bootmenu with a Ctrl-C, from there you can get
to the shell if developer mode is enabled. Therefore, override the
default dev-mode detection to statically enable it on the CRB.
2024-06-17 14:59:27 +02:00
Tobias Waldekranz ba73f3e832 uboot: HTTP netboot support
If we receive an option 67 (bootfile) matching http://IP/rootfs.itb,
use U-Boot's wget implementation to download the file. The web server
must listen on port 80. tftp:// is also supported.

Without a protocol prefix, assume that the bootfile should be fetched
using TFTP from ${serverip}.
2024-06-17 14:59:27 +02:00
Tobias Waldekranz ccb17b1c91 uboot: Remove dead code 2024-06-17 14:59:27 +02:00
Tobias Waldekranz 0b643f1a78 uboot: Add boot menu
Generate a boot menu, accessible with C-c during a short window, where
a user can interactively select a custom boot source and/or trigger a
factory reset of the device.

With this in place, we should always be able to unbrick a device, as
the image can be fed over the network, and local data can be ignored
by opting in to a factory reset.
2024-06-17 14:59:27 +02:00
Tobias Waldekranz 6eb8a41103 uboot: Import hush fixes from kkit/u-boot-2023.07.y 2024-06-17 14:59:27 +02:00
Tobias Waldekranz 60118fad0d uboot: Remove old unused patches
Patches are now versioned in the expected patches/uboot directory
instead.
2024-06-17 14:59:27 +02:00
Tobias Waldekranz 3b77db13c5 aarch64: Add defconfig to build U-Boot for QEMU 2024-06-17 14:59:27 +02:00
Tobias Waldekranz 81f05d1539 build: Allow relative relative output paths
Before this change, this invocation...

    make O=x-x64 x86_64_defconfig

...would use the output directory...

    /path/to/infix/buildroot/x-x64

...which is not the expected behavior. This would happen because
Buildroot will, naturally, expand relative paths based on _its_ top
directory.

Therefore, translate any relative paths to absolute ones based on
_Infix's_ top directory, before handing control over to Buildroot,
such that the expected...

    /path/to/infix/x-x64

...output directory is used.
2024-06-17 14:59:27 +02:00
Tobias Waldekranz ec5af122f6 qemu: Create UNIX socket for connecting to QEMU's GDB stub
This let's you debug the running operating system kernel, or the
bootloader.
2024-06-17 14:59:27 +02:00
Tobias Waldekranz b536f0c874 doc: Update ChangeLog with QoS improvements 2024-06-07 10:10:38 +02:00
Tobias Waldekranz 640ccea288 test: case: vlan_qos: Add
Verify that we can map VLAN PCP to skb->priority on ingress, and back
to PCP on egress.
2024-06-07 10:10:38 +02:00
Tobias Waldekranz 68b1632f19 test: netns: Add packet capture helper
This tries to improve on the existing sniffer in a couple of ways:

- In addition to being usable as a context manager, also allow
  explicitly starting and stopping the capture.

- Try to synchronize the start of the capture by snooping stderr and
  wait for tcpdump to start up. This should eliminate the need for
  sleeps before starting to send packets.

- By default, execute a safety sleep when terminating the capture to
  ensure that any straggling packets have had time to arrive at their
  destination.
2024-06-07 10:10:38 +02:00
Tobias Waldekranz c39f122014 test: netns: ping: Support specifying an ID
By default, ping(1) will use a random ID in the ICMP packet. Allow
setting it to a fixed value instead.

This makes it easy to identify that particular packet in a packet
capture later on.
2024-06-07 10:10:38 +02:00
Tobias Waldekranz ab8cb7a3ac confd: interfaces: VLAN QoS mappings
Let the ring-bearer^Wuser decide the policy around how VLAN PCP is
mapped to skb->priority on ingress, and back to PCP again on egress.

Either a fixed value is used for all packets, or a 1:1 mapping is done
between the two domains. By default, we follow Linux's defaults of a
fixed 0 value on both ingress and egress.
2024-06-07 10:10:38 +02:00
Tobias Waldekranz 20d7f901a2 confd: interfaces: Translate internal errors to sysrepo domain
Sysrepo expects callbacks to return `sr_error_t`'s, not POSIX errnos.
2024-06-07 10:10:38 +02:00
Tobias Waldekranz f0098059a7 confd: interfaces: Flush addresses when exiting current generation
The interface in question might not exist at init:49 if some other
change requires it to be recreated from scratch, in which case it will
be removed in exit:50. Therefore, run the flush at exit:49, where it
should always still exist.
2024-06-07 10:10:38 +02:00
Tobias Waldekranz de6c624b95 confd: dagger: Add debug statements to trace dagger commands 2024-06-07 10:10:38 +02:00
Tobias Waldekranz d9b14c457a confd: dagger: Detect failing scripts
When timestamping of scripts was added, we unfortunately started to
record the exitstatus of `ts(1)`, rather than the script itself.

Refactor the metadata collection to use `time(1)` instead, which will
propagate the inferior's exitcode. This will also allow us to collect
other parameters in the future.
2024-06-07 10:10:38 +02:00
Tobias Waldekranz 366cc4c8e7 board/common: Disable priority reclassification when forwarding IPv4
By default, Linux will map an IP packet's TOS field into skb->priority
when acting as a router. Unfortunately this is only globally
configurable (per network namespace), which leaves us with the
following dilemma:

If we keep reclassification enabled, then a setup like this...

vlan1 vlan2
   \   /
    br0
    / \
  e1   e2

...would likely not work as expected because any priority information
from hardware, that might be mapped to skb->priority via vlan1's
ingress-qos-map, would then be replaced by the standard TOS-mapping on
the routing boundary.

On the other hand, if we disable reclassification, then we won't be
able to source priority information from the TOS field when no other
source is available, as is the case when the source interface is a
regular NIC.

Given that the primary use-case is to run on switchdev ports, we will
most likely always have priority information available from hardware,
which is why we opt to disable the reclassification.

If this ever becomes configurable per interface, then we could open up
the configuration to let users define the policy of which layer's
priority should take precedence.
2024-06-07 10:10:38 +02:00
Tobias Waldekranz e358e6bc1f board/common: Use mqprio on supported interfaces
Opportunistically look for interfaces with multiple transmit queues
and hardware support for the mqprio queuing discipline. For every
matching interface, set up mappings from kernel-internal packet
priorities, via traffic classes, to transmit queues such that as many
high priorities as possible are scheduled on separate queues.
2024-06-07 10:10:38 +02:00
Tobias Waldekranz a5d98e9351 board/common: Collect all system init in a dedicated runparts dir
This makes it easier to add more scripts without having to update the
finit config file, and it clarifies which of the scripts in
/libexec/infix only execute at boot.
2024-06-07 10:10:38 +02:00
Tobias Waldekranz dfdd3b1090 package/sysrepo: Import upstream datastore corruption fix
See sysrepo/sysrepo#3268
2024-06-07 10:10:38 +02:00
Tobias Waldekranz b4e3c955d8 kernel: Import mqprio support for mv88e6xxx from kkit-linux-6.6.y
...and enable mqprio support in the kernel config.
2024-06-07 10:10:38 +02:00
Joachim WibergandTobias Waldekranz 91148de095 confd: allow ipv6 address with global prefix in factory bridges
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-05 15:08:06 +02:00
Joachim WibergandTobias Waldekranz fe036049b8 Fix #473: bridges never get IPv6 autoconf enabled
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-05 15:08:06 +02:00
Mattias Walström d2d1562c8c sysrepo-cpp: Change to kernelkit-url 2024-06-04 13:38:03 +02:00
Joachim WibergandMattias Walström eebba3b3cb doc: initial RESTCONF scripting examples
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-04 13:38:03 +02:00
Joachim WibergandMattias Walström 310563abda confd: background factory reset to allow time to respond to RPC
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-04 13:38:03 +02:00
Joachim WibergandMattias Walström 37506bcdd9 configs: enable rousette for RESTCONF support
Sync after `make update-defconfig`:

 - avahi selected by mdns-alias package (all)
 - iptables and ca-certs selected by other packages (r2s)

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-04 13:38:03 +02:00
Mattias Walström 23585486de test: Add backend to run tests with restconf
Very simple tests work (hostname.py), more complex
tests (static_routing.py) failes due to the lack of
model prefix, for example. infix-ip:ipv4 instead of just
ipv4.

We need to fix this before you send your configuration, run
it through libyang for example and get the full model-name.
2024-06-04 13:38:03 +02:00
Joachim WibergandMattias Walström 78153e62cf nginx: forward /yang and /.well-known as well to restconf agent
We skip /telemetry/optics for now since we don't support any telementry atm.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-04 13:38:03 +02:00
Joachim WibergandMattias Walström a37dd412e1 netbrowse: add /netbrowse route and RESTCONF mDNS xlate
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-04 13:38:03 +02:00
Joachim WibergandMattias Walström f9bbb86d49 confd: configurable support for RESTCONF using infix-services
This enables access to /restconf on port 443 over HTTP/1.1 and HTTP/2
via rousette when enabled.

Also, slight refactor to allow including /restconf and /netbrowse as
optional locations in the main servier directive.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-04 13:38:03 +02:00
Joachim WibergandMattias Walström 59eb73bf24 confd: minor, whitespace fixes
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-04 13:38:03 +02:00
Mattias Walström 44465b679f Add C.UTF-8 locale
Required by rousette
2024-06-04 13:38:03 +02:00
Mattias Walström 4f3ae3b9a4 Add new package: Rousette - a RESTConf server 2024-06-04 13:38:03 +02:00
Joachim WibergandTobias Waldekranz 3339fc5738 doc: update ChangeLog for upcoming v24.06 release
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-03 23:05:04 +02:00
Joachim WibergandTobias Waldekranz 90b35affe2 Drop augeas from system completely
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-03 23:05:04 +02:00
Joachim WibergandTobias Waldekranz ff10f4ee2f confd: drop augeas from build requirements and clean up
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-03 23:05:04 +02:00
Joachim WibergandTobias Waldekranz 96cdc7c628 confd: simplify, drop augeas for direct hostname update
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-03 23:05:04 +02:00
Joachim WibergandTobias Waldekranz 189ecd8fb0 confd: clean up internal user mgmg functions from augeas
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-03 23:05:04 +02:00
Joachim WibergandTobias Waldekranz 23dd84a690 confd: simplify, drop augeas also for add/del user to/from wheel
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-03 23:05:04 +02:00
Joachim WibergandTobias Waldekranz b5eb566c35 confd: replace malfunctioning augeas for setting password and shell
With increased use of augeas to manage users, groups, and permissions,
we seem to have reached peak complexity.  Because when re-running the
same test[1] over and over, somtimes the aug_save() function fails to
actually save the changes to /etc/shadow to disk!

We have already experienced weird behavior with augeas, see comment in
deleted code, and these latest problems became the last straw.  We have
decided to replace it with standard C APIs.

As a spin-off, thanks to the requried refactoring, the check_shell()
function, used by the change_nacm() callback, could be replaced with a
call to set_shell() for both "is-admin" and "non-admin" cases.  This
means we now also restore Bash privileges (and not just take them away)
when modifying nacm group memberships.

Fixes #468

[1]: test/case/ietf_system/user_admin.py

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-03 23:05:04 +02:00
Joachim WibergandTobias Waldekranz 21ef50ebfb test: new test, verify handling of non-admin users
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-03 23:05:04 +02:00
Joachim WibergandTobias Waldekranz 47ee01be96 test: minor, whitespace cleanup
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-03 23:05:04 +02:00
Joachim WibergandTobias Waldekranz eea5f77be9 confd: refactor nacm user shell check
reuse shells array from sys_find_usable_shell(), used elsewhere.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-03 23:05:04 +02:00
Joachim WibergandTobias Waldekranz 5f07fc9d9f confd: check if user has administrator rights for shell selection
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-03 23:05:04 +02:00
Joachim WibergandTobias Waldekranz 43d68289b9 confd: refactor, break out user-in-group check to separate function
No logical changes made.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-03 23:05:04 +02:00
Joachim WibergandTobias Waldekranz 50e068ef10 confd: fix check for group membership
Checking if a user is an administratr we cannot rely solely on the
return value of sr_get_items() but also ensure at least one group
matches the search criteria.

Fixes #469

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-03 23:05:04 +02:00
Joachim WibergandTobias Waldekranz 2218901dc7 confd: fix invalid module prefix to legacy motd setting
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-06-03 23:05:04 +02:00
Tobias WaldekranzandJoachim Wiberg 8eb67c1d13 test: Fixup permissions of generated files when using docker
Since containers managed by docker runs as root, files created in bind
mounted volumes will be owned by root:root. This is a problem for
files generated during test execution, as the calling user does not
have permission to remove them.

Therefore, add a wrapper entrypoint that hooks up an exit handler that
will fixup the permissions before exiting the container.
2024-05-24 19:10:10 +02:00
Joachim Wiberg 8fdd147d1e .github: ignore any existing output/ directory
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-24 17:40:36 +02:00
Joachim Wiberg f29ad88b16 .github: set up build env. for 'make test'
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-24 17:00:15 +02:00
Joachim Wiberg 3f36c4541d .github: drop make from configure step and fix test
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-24 15:41:05 +02:00
Joachim Wiberg 9f8b27ae4a .github: split build and test in separate jobs
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-24 14:43:05 +02:00
Joachim Wiberg b5af266953 .github: simplify build and regression testing
Now that Reggie builds all supported archs there is no point in keeping
two separate (and now very similar) workflows.  So we've decided to lay
off Reggie and let Bob, who has seniority, take over Reggie's tasks.

This simplification also means that jobs will no longer be started on
push to branches, only pull requests.  For half-baked branches a draft
pull request can be used to auto-start builds, if needed.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-24 13:23:16 +02:00
Mattias WalströmandTobias Waldekranz 0b3816473d setup.sh: Document the origin of this script. 2024-05-24 11:58:47 +02:00
Mattias WalströmandTobias Waldekranz b9a8d65e61 libsrx: Remove srx_require_module API
Not needed anymore since all YANG modules should be loaded at
build.
2024-05-24 11:58:47 +02:00
Mattias WalströmandTobias Waldekranz b1a6606728 confd: Add sysrepo and netopeer as a dependency.
And remove not needed environment variable
2024-05-24 11:58:47 +02:00
Joachim WibergandTobias Waldekranz 453afeb2d7 confd: simplify sysrepo datastore makedev permissions 2024-05-24 11:58:47 +02:00
Mattias WalströmandTobias Waldekranz c3128c4080 Update Changelog regarding updated YANG models 2024-05-24 11:58:47 +02:00
Mattias WalströmandTobias Waldekranz 6e07f5b6f8 test: ipv4_autoconf: Increace possible delay when waiting for link local
No reason to be that narrow (10s) change to 30s
2024-05-24 11:58:47 +02:00
Mattias WalströmandTobias Waldekranz d47cc76ab5 libyang: Add upstream segfault patch 2024-05-24 11:58:47 +02:00
Mattias WalströmandTobias Waldekranz a4b1d37763 confd: Update SHM path
Do not use netopeer-created shm-path
2024-05-24 11:58:47 +02:00
Mattias WalströmandTobias Waldekranz c4d567f994 infamy: route: ospf: Adopt to changes done in 2c88e1bdf5
Now there is no guarantee that the control-plane-protocol array
exist in operational.
2024-05-24 11:58:47 +02:00
Mattias WalströmandTobias Waldekranz 05a46475ed yanger: Change behavior to always genereate a valid YANG
Before we generated an invalid YANG model but it was
still accepted by libyang, but now, since the upgrade
it is not.
2024-05-24 11:58:47 +02:00
Mattias WalströmandTobias Waldekranz 2096d93282 ospf-status: Return {} if no status can be retreived (ospfd is disabled)
This helps yanger to generate a valid configuration.
2024-05-24 11:58:47 +02:00
Mattias WalströmandTobias Waldekranz dfe0a507fc confd: Always use model prefix for intentityrefs
This is a hardened requirement i latest libyang(/sysrepo)
2024-05-24 11:58:47 +02:00
Mattias WalströmandTobias Waldekranz 05f063d81b test: Refactor ipv4 address
More robust and less code duplication
2024-05-24 11:58:47 +02:00
Mattias WalströmandTobias Waldekranz fe06bea056 netopeer2: Add a custom PAM configuration file
The one installed with netopeer2 includes files that exist on ubuntu
but not in buildroot.
2024-05-24 11:58:47 +02:00
Mattias WalströmandTobias Waldekranz 4975a16446 FRR: Fix compatibility with newer libyang
only minor.
2024-05-24 11:58:47 +02:00
Mattias WalströmandTobias Waldekranz 8022bd31dc Refactor gen-key to generate SSH accepted keys. 2024-05-24 11:58:47 +02:00
Mattias WalströmandTobias Waldekranz 58541177aa libnetconf: Add support for passwd accounts
This was removed when the new version of ietf-netconf-server was
introduced with the new version of libnetconf.
2024-05-24 11:58:47 +02:00
Mattias WalströmandTobias Waldekranz d3b102d46e Bump sysrepo, netopeer2, libyang and libnetconf
This also adds support in sysrepot to install factory config on boot,
default is only to allow it when installing the module, we can not do
that anymore, since the modules is installed during build and the factory
config (or failure) can only be determed when booted.
2024-05-24 11:58:47 +02:00
Mattias WalströmandTobias Waldekranz 3354effc53 Build in required modules on buildtime
This to hopefully speed up boot, do as little as possible
during boot.

* New modules needs to be added to src/confd/scripts/setup.sh
* Permission needs to be changed post-build for YANG files,
  see CONFD_PERMISSIONS in confd.mk
2024-05-24 11:58:47 +02:00
Mattias WalströmandTobias Waldekranz bef44b725e Remove ietf-netconf-acm@2018-02-14.yang
Provided by libnetconf
2024-05-24 11:58:47 +02:00
Mattias Walström 115f5c8f52 infamy: igmp_vlan: Refactor
Simplify test, and speed it up when do positive testing.
2024-05-23 08:45:05 +02:00
Mattias Walström 6df2c90d85 test: Refactor routing tests
Make more in parallel and restructure code
2024-05-23 08:45:05 +02:00
Mattias WalströmandJoachim Wiberg 06742cf825 kernel: Upgrade to 6.6.31 2024-05-22 12:01:30 +02:00
Joachim Wiberg c7c1b5b12d .github: build aarch64 target as well in regression workflow
- Add aarch64 to build matrix on Reggie
 - Rename platform -> target in all workflows

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-21 10:10:16 +02:00
Joachim Wiberg 2f4cdd0d9c Fix 'ip addr show proto NAME'
- Add support for proto by name in ip addr show
 - Add missing static protos, needed for show

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-21 09:00:10 +02:00
Joachim Wiberg f1e7fda956 doc: revise developer's guide a bit wrt. packge overrides
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-21 09:00:10 +02:00
Tobias Waldekranz 7bb48ece49 test: Reinstate podman as default runner
Partial revert of 23469bbe3b. When running tests in a GitHub action,
we do not want to run as host root user. Therefore, restore podman as
the default runner, but make sure to prefer docker when attaching to
the host network namespace.
2024-05-20 16:21:06 +02:00
Tobias Waldekranz 508e2287b8 doc: testing: Sync documentation with latest changes
Update docs to match the recent developments in the test system.

Spin off the architecture description to its own document, and focus
testing.md on the day-to-day usage.
2024-05-20 16:21:06 +02:00
Tobias Waldekranz 03d48e9aab test: Unify the different test modes to a smaller number of targets
Now that tests in the host's network namespce can be run inside the
container, simplify test.mk for increased reusability.
2024-05-20 16:21:06 +02:00
Tobias Waldekranz d7c41489e0 test: Always run tests inside container
When we want to test a `make run` instance, or a physical topology,
start the docker in the host's network namespace instead.
2024-05-20 16:21:06 +02:00
Tobias Waldekranz 897faf08d9 qemu: Fix off-by-one in topology generation
When interface naming switched to use 1-based indices instead of
0-based, the topology generation was overlooked thus breaking tests
against a `make run` instance.

Bring everything back in sync.
2024-05-20 16:21:06 +02:00
Tobias Waldekranz 3ad20dfd5b test: Drop support for running tests with podman
When testing in the host's namespace, only docker seems to offer the
required capabilities (due to its daemon/client architecture).

Qeneth tests can still be run in podman. Users will have to install
the docker wrappers for podman to make use of this.
2024-05-20 16:21:06 +02:00
Tobias Waldekranz 3f2ae3f3fc test: case: igmp_basic: Speed up positive reception tests
Use must{,_not}_receive instead of the general sniffer, so that we can
continue the test as soon as we see the transmission at the receiver,
rather than always waiting the full 5s.

While we're here:
- Show the port mappings in the top block-comment
- Define a few more steps to show the user what is going on
2024-05-20 16:21:06 +02:00
Tobias Waldekranz f94815cf46 test: case: static_multicast_filters: Speed up positive reception tests
Use must{,_not}_receive instead of the general sniffer, so that we can
continue the test as soon as we see the transmission at the receiver,
rather than always waiting the full 5s.

While we're here:
- Show the port mappings in the top block-comment
- Define a few more steps to show the user what is going on
- Avoid global variable references in set_static_multicast_filter()
2024-05-20 16:21:06 +02:00
Tobias Waldekranz 2190c3bc52 test: netns: Add must{,_not}_receive
In test cases, it is common that we want to verify that a certain type
of traffic reaches a namespace. This has, up to this point, been
solved by the generic sniffer.Sniffer.

Try to improve the two most common use-cases...
1. Test if a flow reaches a namespace
2. Ensure that a flow does not reach a namespace
...by always exiting as soon as the first packet is received.

This saves time on positive tests, and the synchronous API allows it
to compose well with infamy.parallel().
2024-05-20 16:21:06 +02:00
Tobias Waldekranz e65625e32f test: Add support for attaching to devices via SSH
Support the familiar subprocess.run API, and runsh from netns.py.

This should only be used for debugging, or in the rare instances when
we want to test functionality that is not available via NETCONF.
2024-05-20 16:21:06 +02:00
Tobias Waldekranz af65bbe7f9 test: furl: Cap time spent waiting for HTTP requests
Without an explicit timeout, urllib will wait indefinitely for a
connection to be made.
2024-05-20 16:21:06 +02:00
Tobias Waldekranz 1dbe09b428 test: Spellchecking 2024-05-20 16:21:06 +02:00
Tobias Waldekranz 232c2329af test: netns: Let the default ping timeout be tuned in the topology
QEMU systems seem work fine with the 5s timeout, whereas some physical
devices can't quite keep up with that.

Let the slower systems indicate that they need a bit more time without
punishing faster ones with a longer default.
2024-05-20 16:21:06 +02:00
Tobias Waldekranz 772019db22 test: env: Add support for querying global attributes
This will let other Infamy submodules tune their behavior based on the
particular test system they are running on.

Attributes are defined by creating graph-global attributes with an
"ix_" prefix.
2024-05-20 16:21:06 +02:00
Tobias Waldekranz 52c6c2274e test: topology: Add helper to retrieve graph-global attributes
This will allow us to define attributes that are specific to a
particular test system.
2024-05-20 16:21:06 +02:00
Tobias Waldekranz e53f3362be test: case: routing_basic: Restructure to reuse existing namespace
Rather than setting up and tearing down two identical namespaces,
create it once and use it for the duration of the test.
2024-05-20 16:21:06 +02:00
Tobias Waldekranz c3945a996c test: case: static_routing: Restructure to reuse existing namespace
Rather than setting up and tearing down two identical namespaces,
create it once and use it for the duration of the test. (This is
probably a documentation issue with Infamy: there is no requirement
that test.steps are direct descendants of the test, but until this
point there was no example of this in the source base)

In the process of this, it was also discovered that no positive ping
test was done over v6, so that has been added.
2024-05-20 16:21:06 +02:00
Tobias Waldekranz c2d357a185 test: Use stable MAC addresses when creating MACVLANs
To work around the issue detailed in the method's doc comment.
2024-05-20 16:21:06 +02:00
Tobias Waldekranz 74b0679cf0 test: case: container_*: Use standard ping tests 2024-05-20 16:21:06 +02:00
Tobias Waldekranz dc6dffbff9 test: case: bridge_*: Use standard ping tests 2024-05-20 16:21:06 +02:00
Tobias Waldekranz 4c6dfdf600 test: Run negative ping tests in parallel
Rather than having to wait for each timeout sequentially, run each
test in parallel.
2024-05-20 16:21:06 +02:00
Tobias Waldekranz b62fd627f0 test: Never buffer output
Avoid having log messages stuck in a pipe when stdout is not a tty,
e.g. when running a suite of tests using 9pm.

Two benefits:
- Nicer experience when interactively running a suite
- Timestamps inserted by 9pm are more useful
2024-05-20 16:21:06 +02:00
Tobias Waldekranz 177b65587b test: case: routing_basic: Remove bridge from figure
This a routed setup, no bridge is used.
2024-05-20 16:21:06 +02:00
Tobias Waldekranz b5679aa603 test: Improve robustness of pinging from within namespaces
It turns out that the semantics of ping's -c option does not match our
expectations. The manual says:

> Stop after sending count ECHO_REQUEST packets. With deadline option,
> ping waits for count ECHO_REPLY packets, until the timeout expires.

But in fact, something like an ICMP_DEST_UNREACH will also count as a
response, meaning that the process will terminate with non-zero
exitcode even though the deadline has not yet been crossed, rather
than keep waiting for an ECHO_REPLY.

To add some extra flavor: this is only the case for iputils' ping,
Busybox's implementation will hold out for a response until the
deadline expires.

Therefore, wrap the ping in an ugly retry loop.

Also, return the full available context from must{,_not}_reach on
failures, instead of just the output. This allows us to show the exit
code in the top-level exception handler.
2024-05-20 16:21:06 +02:00
Tobias Waldekranz fb2bd2c2b7 test: Whitespace cleanup 2024-05-20 16:21:06 +02:00
Tobias Waldekranz b9907fa7ae test: Add nsenter helper script to enter Infamy namespaces
When a test starts an isolated MACVLAN namespace, it is often useful
to interactively join that namespace to investigate issues. To do
this, we need to find the "sleeper" process backing the namespace, and
`nsenter` into that process's network namespace.

Add a script that automates this process.

To start a shell in the netns of the MACVLAN stacked on top of d1b,
start a shell in the test environment:

    infix/test $ ./shell
    13:37:00 infamy0:test # ./nsenter d1b
    13:37:01 infamy0(netns:d1b):test #
2024-05-20 16:21:06 +02:00
Tobias Waldekranz 7d6792a638 test: Always log logical-to-physical mappings
For tests using a logical topology, log the resulting mapping to the
physical one. This way, we always have a record of the entire
environment.
2024-05-20 16:21:06 +02:00
Tobias Waldekranz b6cf866f52 test: Log the output of failing subprocesses
It is not uncommon for subprocesses to fail when developing new tests,
but the default representation of CalledProcessError does not print
the stdout of the program, only that it failed.

Catch this common case when a test is about to fail, and make sure to
log any output it produced.
2024-05-20 16:21:06 +02:00
Tobias Waldekranz 2c72aaf6e1 test: Move all test related targets from board/x86_64 to test/
The list of binaries needed inside the test environment is the only
architecture specific bit, so refactor that out to a separate
variable.
2024-05-20 16:21:06 +02:00
Tobias WaldekranzandJoachim Wiberg b5f2252650 kernel: Latest fixes
- Add missing locking around standard counter groups
- Fix reference counting issue with IGMPv3/MLDv2 reports

Found as part of debugging the regression test suite on hardware.
2024-05-20 16:15:23 +02:00
Joachim Wiberg ca026a37fc Add link to Latest Build
[skip ci]

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-18 12:11:37 +02:00
Joachim WibergandTobias Waldekranz abd8621e92 doc: split container host interface, add w/ phys-address example
The container host interface text was a bit hard to understand.  This
patch splits it up in two parts, basic routed setup and an advanced
with two interfaces.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-18 09:58:19 +02:00
Joachim WibergandTobias Waldekranz 0df778a5f6 confd: fix custom mac support for veth interfaces
This patch adds support for setting the mac address already when
creating veth interfaces.  Necessary to cooperate with containers.

Fixes #453

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-18 09:58:19 +02:00
Joachim WibergandTobias Waldekranz 0a7f8ce216 confd: always create factory bridges with multicast snooping enabled
The confd `gen-interfaces` script is called for some customers with a
default to create a bridge with all, or a subset of all, ports.  The
safe default, which incidentally coincides with the same customer's
requirements, is to have IGMP/MLD snooping enabled by default.

Fixes #454

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-18 09:58:19 +02:00
Joachim WibergandTobias Waldekranz 7e2d433857 Prepare ChangeLog for next release
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-18 09:58:19 +02:00
Joachim Wiberg 413470569e doc: clarify with before and after
[skip ci]

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-17 16:54:09 +02:00
Joachim Wiberg b2adf639ff doc: initial section on developing new features for confd
[skip ci]

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-17 16:42:06 +02:00
Joachim Wiberg 3ac1dfbf4c .github: ensure clean and recursive submodules
Minor change, mostly for consistency across repos.

[skip ci]

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-17 14:38:57 +02:00
Joachim Wiberg 975a7b466c .github: introduce issue templates
We already have a pull request template.  This is a propsal to add issue
templates as well.  These yml templates change the behavior of reporting
issues to more a of a pre-formatted form with guard rails.

It is still possible to report blank issues the old way.

[skip ci]

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-16 13:32:35 +02:00
Joachim Wiberg bdefe9452c .github: revise and update contributing guidelines
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-16 13:32:35 +02:00
Joachim Wiberg 9211fba6d5 .github: simplify pull-request template slightly
Referencing/Linking to issues is now supported in the GitHub GUI.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-16 13:32:35 +02:00
Joachim Wiberg 1d58d2058d package/gencert: declare dependency on pkg-config and libopenssl
Plain openssl is a meta-package, gencert requires libopenssl v3.x and
later, and use pkg-config to detect its presence.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-16 13:32:35 +02:00
Joachim WibergandMattias Walström 23dc237403 Switch to PAM for system authentication
- Add sshd 'UsePAM yes'
 - Buildroot automatically adds and enables:
   - /etc/pam.d/ with authentication for login, sshd, and sudo
   - PAM support in BusyBox login

Also, prepare for adding RADIUS authentication support to ietf-system
the only tricky part is testing against a RADIUS server.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-15 16:06:08 +02:00
Joachim Wiberg 406dbfdff4 Update release date for v24.04.2
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-13 15:50:12 +02:00
Joachim WibergandTobias Waldekranz 9d7817356f statd: support for enabling DEBUG() logs with env, like confd
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-13 11:42:27 +02:00
Joachim WibergandTobias Waldekranz 16c21f0da8 doc: update ChangeLog for v24.04.2 patch release
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-13 11:42:27 +02:00
Joachim WibergandTobias Waldekranz aa20f29b36 confd: fix missing /etc/resolv.conf after 'no system'
When a CLI user performs the following command, the DNS resolver was
left in an undefined state.

    admin@infix-00-00-00:/config/> no system
    admin@infix-00-00-00:/config/> leave
    admin@infix:/>

The avahi-daemon reported the missing /etc/resolv.conf and the fix is to
ensure `resolvconf -u` runs on every major change ot ietf-system, even
if there is no new resolv.conf to roll in.  At bootstrap this has been
handled by another mechanism so has not been seen by most users.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-13 11:42:27 +02:00
Joachim WibergandTobias Waldekranz c6b818d0bc confd: fix error handling for sr_get_data()
The sr_get_data() API may return SR_ERR_OK and still set the cfg pointer
to NULL!  This happens when, e.g., executing 'no system' from the CLI.

This patch adds a check for this in all occurrences of sr_get_data().

Also, in ietf-routing.c there was *no* error handling for this API, this
required some restructuring to ensure a FILE *fp was closed properly in
all cases.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-13 11:42:27 +02:00
Joachim WibergandTobias Waldekranz 89c9a12db2 confd: on failure to load startup-config, reset and regroup
With the sysrepo patch from the previous commit, we can now properly
detect if a callback failed to apply its changes in SR_EV_DONE.  When
this occurs the system may be in an undefined state, so we must try
to recover it before loading failure-config.

This patch tries to perform a factory-default RPC, which is an Infix
specifc RPC that does "copy factory-config running-config".  We give
sysrepocfg some time to clean up any stale SHM connections before we
do a hard scratch of the db state and restart sysrepo-plugind.

Fixes #429

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-13 11:42:27 +02:00
Joachim WibergandTobias Waldekranz 9df97d9a1b patches/sysrepo: add support for non-zero exit code from syrepocfg
This local patch of sysrepo adds support for detecting non-zero return
code from sysrepo callbacks during SR_EV_DONE, which upstream sysrepo
currently, as of v2.2.105, discards.

With this change failure to load startup-config results in the system
detecting the failure applying failure-config instead.

Fixes #429

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-13 11:42:27 +02:00
Joachim WibergandTobias Waldekranz d0cfe429c4 confd: fix regression, loss of admin account after upgrade to v24.04
Fix regression introduced in 3f87945, which tries to map a user to an
existing home directory.  The root cause for the problem is basically an
invalid check of the /home/admin UID being in use by any system account
or not.  This patch uses the same check used by the BusyBox adduser
command.

In addition to the uid-already-in-use fix, several other checks have
been added to ensure we do not end up with an invalid system state:

 - If reusing an existing /home/admin fails in the 'adduser admin'
   command, wipe out /home/admin and retry adding the user cleanly
 - Always delete any group with the same name before trying to add
   the user, regardless if /home/$user exists or not, this prevents
   issues with stale group records if we end up failing to load the
   startup-config and need to load failure-config
 - For the same reason (failure-config), make sure to always clean
   up any stale user in the retry step.  The same step is used when
   there is a uid:gid mismapping (the original bug)

Fixes #428

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-13 11:42:27 +02:00
Joachim WibergandTobias Waldekranz adf37394f4 confd: follow-up to 2412fff3, simplify chown of startup-config
Instead of having a chown process started by Finit in runlevel S, we can
just chown in the confd load script instead.

Issue #415

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-13 11:42:27 +02:00
Joachim WibergandTobias Waldekranz bc020436e7 confd: increased severity for log messages caught on stdout/stderr
Error messages from system() calls, like adduser, should be logged with
severity LOG_ERR to not arrive out of sequence with ERROR() messages.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-13 11:42:27 +02:00
Joachim WibergandTobias Waldekranz ad8a74fa7b confd: minor, fix variable shadowing
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-13 11:42:27 +02:00
Joachim WibergandTobias Waldekranz 3315a46423 confd: minor, skip shell update when deleting user
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-13 11:42:27 +02:00
Joachim WibergandTobias Waldekranz 334d222f7c confd: minor, logging cleanup
- Drop unnecessary \n
 - Drop needless ERROR() message triggered when deleting users

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-13 11:42:27 +02:00
Joachim WibergandTobias Waldekranz d624203815 confd: minor, match syslog tag with other log messages
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-13 11:42:27 +02:00
Joachim WibergandTobias Waldekranz ab21eff6c8 confd: minor, use initial hostname from /etc/os-release as fallback
Instead of hard-coding the fallback hostname we can now use the one
generated to /etc/os-release (for netbrowse).

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-13 11:42:27 +02:00
Jon-Olov Vatnandjovatn a05e28d349 Updating text after feedback.
I found similar error in other parts of the doc, as well
as some typos, and fixed them there too.

[skip ci]
2024-05-13 07:50:34 +02:00
Jon-Olov Vatnandjovatn 81c8f1c944 Fixing more typos.
[skip ci]
2024-05-13 07:50:34 +02:00
Jon-Olov Vatnandjovatn d039d9fc2b Fix typo.
[skip ci]
2024-05-13 07:50:34 +02:00
Jon-Olov Vatnandjovatn e1dd636ed0 Update link list and fixing typo.
[skip ci]
2024-05-13 07:50:34 +02:00
Jon-Olov Vatnandjovatn c4236eaa80 Yet another try for anchors for cross-references 2024-05-13 07:50:34 +02:00
Jon-Olov Vatnandjovatn a8c47779a2 New try for explicit anchors for cross-references
[skip ci]
2024-05-13 07:50:34 +02:00
Jon-Olov Vatnandjovatn 3178d5aae4 Adding script examples for production tests
- reading out eeprom/vpd data
- led testing
- power supply testing
- ethernet port test (example for looping ports)

[skip ci]
2024-05-13 07:50:34 +02:00
Tobias Waldekranz e63256edbb cn9130-crb: Document bootstrapping procedure 2024-05-07 15:34:47 +02:00
Tobias Waldekranz 68a0b289d2 board/aarch64: Separate board specific documentation
This should make it easier to find what you're after as the number of
supported boards increase.
2024-05-07 15:34:47 +02:00
Tobias Waldekranz 8a7eb80878 cn9130-crb: Set Infix default password
Since we don't have any VPD defined on this board, supply a default
password hash via the device tree instead.

Also, specify the path to external USB port, so that Infix will pick
it up in ietf-hardware.
2024-05-07 15:34:47 +02:00
Tobias Waldekranz 473d48097c cn9130-crb: Enable eth2, avoid polling of SFP io lines
Provide a patched device tree that:

- Uses the correct phy-mode for eth2, allowing it to be probed
  properly

- Wires up the interrupt signal to the GPIO expander, so that the SFP
  cage's I/O lines can be configured as interrupts, rather than having
  to poll them
2024-05-07 15:34:47 +02:00
Tobias Waldekranz 50a9bba1c7 board/common: fdisk: Allow reformatting of disks
Assume that the caller always want to create a new partition table,
even in scenarios where one already exists. This allows devices to be
reprovisioned with a newer image, for example.

Fixes #394
2024-05-07 15:34:47 +02:00
Tobias Waldekranz 21ab842357 board/common: Fix incorrect path to /etc/partition-uuid
While we're here, fix some whitespace nits.
2024-05-07 15:34:47 +02:00
Tobias Waldekranz b5abcc8af9 cn9130-crb: Add a small bootdelay in U-Boot
This is not a production target, so we choose the more developer
friendly option of allowing the boot process to be interrupted.

Also, remove the old update cruft and rely on Marvell's `bubt`
instead.
2024-05-07 15:34:47 +02:00
Tobias Waldekranz ca968c7d87 cn9130-crb: Switch to using SPI FLASH for bootloader storage
The BootROM wants the bootloader to be located on LBA1, which is not
ideal when using a GPT to describe the partition table.

Make sure the `bubt` command targets SPI by default.
2024-05-07 15:34:47 +02:00
Tobias Waldekranz d96f3ae2e9 defconfig: cn9130_crb_boot: Pin ATF version after Buildroot update
Buildroot's default ATF version changed from 2.9 to 2.10 when we
upgraded to 24.02.x. This meant that our patches were not applied,
which broke the build.

Take a conservative approach for now, and just pin the ATF version to
the known-good 2.9 series.
2024-05-07 15:34:47 +02:00
Tobias Waldekranz f45e1d57a0 defconfig: cn9130_crb_boot: Restore image signing functionality
During the addition of multi-key support to RAUC and U-Boot, the
bootloader defconfig for CN9130 CRB was overlooked, which meant that
the Infix specific U-Boot hooks never ran, thereby ultimately breaking
the build.

Restore the required options to build in the dev-key by default.
2024-05-07 15:34:47 +02:00
Joachim Wiberg f5b0f37386 confd: rename 10-infix-system.json -> 10-infix-services.json
Mislabled from the start, the file holds default services.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-05 18:20:03 +02:00
Joachim Wiberg f0205b0a35 board/common: document reserved syslog facilities
[skip ci]

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-05 18:15:03 +02:00
Joachim Wiberg 80659ef299 Final ChangeLog update for v24.04.1
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-03 17:06:15 +02:00
Joachim Wiberg 59b3e583f1 doc: update build deps, bison needed new uboot-tools
The Buildroot 2024.02.x-kkit branch recently had uboot-tools upgraded
and the patches needed require bison to rebuild.

The recommendation is to also install flex, they always go together.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-03 17:03:03 +02:00
Joachim WibergandMattias Walström 6a8eaacc6e Replace python + rust based gencert2 with C based gencert3
Also, sync r2s_defconfig with latest major changes.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-03 15:33:00 +02:00
Joachim WibergandMattias Walström 6b8bd4caf3 package/gencert: new package
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-03 15:33:00 +02:00
Joachim WibergandMattias Walström 39f868fc61 gencert: C replacement for python+rust gencert
Smaller, fewer dependencies, and quicker to cross-compile.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-03 15:33:00 +02:00
Joachim WibergandMattias Walström be1c00f469 package/factory: add checksum for LICENSE
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-03 15:33:00 +02:00
Joachim WibergandMattias Walström 71e63de0c1 execd: minor, drop dummy line from configure summary
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-03 15:33:00 +02:00
Tobias WaldekranzandJoachim Wiberg 6c1c31e5c0 doc: testing: Document how to use deterministic topology mappings 2024-05-03 14:44:54 +02:00
Tobias WaldekranzandJoachim Wiberg a2906acdf7 test: Optionally use deterministic topology mappings
Due to the salting being applied to Python's `hash()` (see [1]), the
hash of an object is not stable across different Python processes. As
a result, neither are the topology mappings generated by networkx.

The upside of this is randomness that we get better test coverage over
time, especially on physical devices where the underlying hardware
could differ between ports, for example.

On the other hand, it can be very frustrating to track down a bug when
locial nodes are suffled around between phyical nodes on each
invocation of a test case.

Therefore, use a random seed by default, but allow the user to specify
a fixed value if they so choose. We then add a meta test that logs the
seed being used for the current suite - which means we can simply
copy&paste that value to rerun the suite (or single test) with the
same topology mappings.

[1]: https://docs.python.org/3/reference/datamodel.html#object.__hash__
2024-05-03 14:44:54 +02:00
Tobias WaldekranzandJoachim Wiberg 753f3806a1 test: Improve efficiency of logical to physical topology matching
- Present the topologies to networkx as multigraphs, rather than
  expaning each port of the record shape as a separate node.

- Create a topology mapping by locating a subgraph monomorphism of the
  logical topology in the physical ditto.

This cuts down the time of finding a mapping by several orders of
magnitude. Example:

Before:

time python3 test/infamy/topology.py \
     	     test/virt/quad/topology.dot.in \
	     test/infamy/topologies/ring-4-duts.dot >/dev/null

real    13m1,213s
user    13m0,112s
sys     0m0,732s

After:

time python3 test/infamy/topology.py \
     	     test/virt/quad/topology.dot.in \
	     test/infamy/topologies/ring-4-duts.dot >/dev/null

real    0m0,153s
user    0m0,128s
sys     0m0,024s
2024-05-03 14:44:54 +02:00
Joachim WibergandTobias Waldekranz 2a218ce6e9 doc: update ChangeLog for v24.04.1
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-03 07:54:48 +02:00
Joachim WibergandTobias Waldekranz 474820c44b Fix #424: regression, root user can log in without password
This fixes a serious security regression introduced late in the v24.04
release cycle.  The root cause is the placement of the shadow file in
the rootfs overlay, which causes any changes made by the Buildroot
setting BR2_TARGET_ENABLE_ROOT_LOGIN to be discarded/overwritten just
before creating the squashfs image.

The fix in this commit relocates all files from b4eb450 to the skeleton
in Infix, package/skeleton-init-finit/skeleton/etc, which is one of the
first packages to be installed when starting a build.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-03 07:54:48 +02:00
Joachim WibergandTobias Waldekranz 9609fc144d confd: add timestamps to dagger .log files
Sample output:

    root@infix-00-00-00:~# cat /run/net/0/action/init/lo/45-init.sysctl.log
    May 02 13:45:58 net.ipv6.conf.lo.autoconf = 1
    May 02 13:45:58 net.ipv6.conf.lo.dad_transmits = 1
    May 02 13:45:58 net.ipv6.conf.lo.temp_prefered_lft = 86400
    May 02 13:45:58 net.ipv6.conf.lo.temp_valid_lft = 604800
    May 02 13:45:58 [exit:0]

Fixes #374

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-03 07:54:48 +02:00
Joachim WibergandTobias Waldekranz a0df130852 board/common: relocate dagger script to confd tree
The dagger tool is a helper for scripts generated by confd and should
therefore be installed by confd instead of the rootfs overlay.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-03 07:54:48 +02:00
Joachim WibergandTobias Waldekranz 22c911f85e package/landing: new package
Relocate the default landing page from the rootfs overlay to a package
so that customer repos can override it.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-03 07:54:48 +02:00
Tobias WaldekranzandJoachim Wiberg 3d8b64f939 aarch64: kernel: Enable DCB
In order to make use of the DCB support in mv88e6xxx we also enable it
in the kernel config.

Fixes: 3a73ce3cfb ("kernel: Import EtherType based priority override support")
2024-05-02 15:30:02 +02:00
Joachim Wiberg 1176560bb2 package/python-statd: update LICENSE hash
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-01 17:44:26 +02:00
Joachim Wiberg ec4a311f47 package/statd: update LICENSE hash
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-01 17:42:38 +02:00
Joachim Wiberg 7fd746e56f doc: add markdown link to v24.04.0 diff
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-01 15:17:50 +02:00
Joachim Wiberg 258368d814 .github: drop build in /mnt workaround for release build
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-01 15:16:11 +02:00
Joachim Wiberg 9dfb0ea1f1 doc: update ChangeLog for v24.04
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-01 12:35:13 +02:00
Joachim Wiberg 3408f02709 doc: follow-up to aaaad535, ACLs for guest and operator dropped
As mentioned previously, the NACM default ACLs in `factory-config` were
removed as part of the work on the nacm-basic branch.

Adjust text to not mention any pre-configured user levels, for now.  A
future update may change the defaults when we've found resonable levels.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-01 11:09:01 +02:00
Joachim Wiberg b557d69b8a package/confd: follow-up to 2412fff, chown only in runlevel S
Run chown only at bootstrap, after confd has started and we've loaded
startup-config.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-01 11:08:50 +02:00
Joachim Wiberg 3a2579ec9e board/common: follow-up to bb18afa, adjust qemu.sh interface names
This adjusts the name of the first interface in all network modes, not
just tap, for consistency.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-01 11:08:36 +02:00
Joachim Wiberg ab3a09b260 board/x86_64: follow-up to c637ab4, allow console also on ttyS0
Fixes #419

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-05-01 10:45:17 +02:00
Tobias Waldekranz f1d21a4bae uboot: Install all trusted keys into U-Boot's control DT
Now that RAUC can have multiple keys in its keyring, we should include
the same set of keys in the bootloader.
2024-04-30 16:03:09 +02:00
Tobias Waldekranz 6e4aa0d7be buildroot: Bump to latest 2024.02.x-kkit for new uboot-tools 2024-04-30 16:03:09 +02:00
Joachim WibergandTobias Waldekranz 0629022b1f confd: minor, adjust log levels and drop duplicate log messages
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-04-30 15:51:17 +02:00
Joachim WibergandTobias Waldekranz cffaf71d6e board/common: generate a small aux partition for 'make run'
This patch helps silence kernel errors to console at boot.  To fully
silence errors, enable emulated /var in your Qemu runs as well.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-04-30 15:51:17 +02:00
Joachim WibergandTobias Waldekranz d1b0f69e18 board/common: minor, whitespace
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-04-30 15:51:17 +02:00
Joachim WibergandTobias Waldekranz fe33d0d733 patches/linux: adjust log level for unauthorized usb devices
The fact that a USB device currently is not authorized is not an error.
This patch adjusts the log level to slip below 'quiet' to prevent logs
to console at boot.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-04-30 15:51:17 +02:00
Joachim WibergandTobias Waldekranz aaaad53549 doc: new section, multiple users, and multiple admins
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-04-30 15:51:17 +02:00
Joachim WibergandTobias Waldekranz 053d9c2131 test: reenable infix-services test with a link toggle
Since we do not yet have lldpTxFast, or similar, to enable on LLDP, we
tickle both services to resend their HELLO frames on link down/up event
instead.

 + Reduces turnaround times drastically
 + Restore regression test for mDNS, which we lost recently

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-04-30 15:51:17 +02:00
Joachim WibergandTobias Waldekranz db628ee3f3 test: revert back to tcpdump output format when reading pcap
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-04-30 15:51:17 +02:00
Joachim WibergandTobias Waldekranz dee36ce801 confd: fix mDNS service type generation
In the 34fa6a3 refactor we lost announcement of mDNS completely:

 - The type of all services was set to 'all', instead of, e.g., _ssh._tcp
 - The web console service was not added properly
 - Web services for plain HTTP/HTTPS were not created at all

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-04-30 15:51:17 +02:00
Joachim WibergandTobias Waldekranz 3f87945f75 confd: map new users to existing home directories
UNIX home directories are persistent across reboots, but user accounts
are not.  If multiple users exist in startup-config and one or more are
removed, we must use the UID of their $HOME on the next reboot to ensure
they do not lose their files.

If a home directory exists and its UID is already in /etc/passwd we have
triggered an unsupported use-case and must remove the home directory on
disk before recreating it empty.  This should not happen, but may occur
on upgrades from a time before UIDs started at 1000 and instead shared
the UID range with reserved system accounts.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-04-30 15:51:17 +02:00
Joachim WibergandTobias Waldekranz fbeeed7a2c confd: refactor add/remove user from UNIX sysadmin group (wheel)
In review discussions we've decided to go for Augeas to modify the file
/etc/group instead of relying on the BusyBox tools adduser and delgroup,
which check for the existence of the user in /etc/passwd -- which we, at
the point in time the NACM callback runs, cannot guarantee.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-04-30 15:51:17 +02:00
Joachim WibergandTobias Waldekranz b03db7f994 confd: disable shell for non-admin users
A user that is not part of the 'admin' group may only have /bin/false or
/bin/clish as login shells for ssh/console.  Any POSIX shell is reserved
for administrators.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-04-30 15:51:17 +02:00
Joachim WibergandTobias Waldekranz 26820111f7 confd: add basic support for nacm
This patch adds basic NACM support to detect users assigned to a group
granting full access privileges.  Full privileges require membership of
at least one group listed in an ACL rule with:

   module-name=*
   access-operations=*
   action=permit

This matches the `admin-acl` rule in factory-config, which the 'admin'
group is part of, and in turn the 'admin' *user* is a member of.

Also, drop unused guest and limited ACLs from factory-config.  Added
from the RFC as an example, but is likely more confusing than helpful.

Note: this does not add all NACM groups to the system, it maps users
      with administrator privileges to the UNIX 'wheel' group, which
      grants access to all IPC sockets (klish, finit, mctl), and sudo
      access to all other parts of the system.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-04-30 15:51:17 +02:00
Joachim WibergandTobias Waldekranz e395c90958 confd: create admin user without -S flag to adduser
After the upgrade to Buildroot 2024.02 a new system user was added to
/etc/passwd, sshd.  Used for drop-privs sshd.  This caused files that
were previously owned by the 'admin' user to now be owned by 'sshd'.

This patch drops the `-S` flag from adduser for the adin user, ensuring
no future clashes with system system users and instead mapping the uid
to a range starting from uid 1000 (default for BusyBox adduser).

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-04-30 15:51:17 +02:00
Joachim WibergandTobias Waldekranz 969ec1dd11 board/common: drop operator and staff, add backup user and group
- Free up 'operator' and 'staff' groups for NETCONF use
 - Reserve 'backup' user and group for future auto-backup (Debian)

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-04-30 15:51:17 +02:00
Joachim WibergandTobias Waldekranz a972966a02 board/common: override default Buildroot passwd and group files
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-04-30 15:51:17 +02:00
Joachim WibergandTobias Waldekranz 1d7eeb5c53 doc: minor, follow-up to scripting.md
Drop sysrepocfg commands from first section.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-04-30 15:51:17 +02:00
Tobias Waldekranz 5e2475c742 confd: Avoid needless Ethernet flow-control reconfigurations
Unless some configuration has changed that affects flow-control (only
auto-neg for now, until we allow actual configuration of flow-control
itself), do not issue any commands that might trigger a link down/up
cycle.

Additionally, make sure that we always configure it on boot, as the
driver defaults might not necessarily line up with our defaults.
2024-04-29 14:31:40 +02:00
Tobias Waldekranz 824b911f49 confd: Unify determination of Ethernet auto-negotiation config
As detailed in the block comment in iface_uses_autoneg(), we make some
special considerations around this, so make sure we always reach the
same conclusion.
2024-04-29 14:31:40 +02:00
Joachim WibergandTobias Waldekranz 66ae2eb2e8 Update src/confd/src/ietf-interfaces.c
Co-authored-by: Tobias Waldekranz <tobias@waldekranz.com>
2024-04-29 14:31:40 +02:00
Joachim WibergandTobias Waldekranz f5408d9fbc doc: update ChangeLog with latest fixes
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-04-29 14:31:40 +02:00
Joachim WibergandTobias Waldekranz 0f7983008e confd: allow admin user to send factory reset rpc using sysrepocfg
Fixes #416

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-04-29 14:31:40 +02:00
Joachim WibergandTobias Waldekranz 2412fff39c confd: ensure correct ownership of startup-config after factory reset
Fixes #415

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-04-29 14:31:40 +02:00
Joachim WibergandTobias Waldekranz 809e6b44be confd: spellcheck infix-hardware.yang
Fixes #414

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-04-29 14:31:40 +02:00
Joachim WibergandTobias Waldekranz 7c7b9ee1f6 confd: fix missing support for globally disable dhcp client
Fixes #412

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-04-29 14:31:40 +02:00
Joachim WibergandTobias Waldekranz 132dca844a board/common: disable lldpd on dsa0 interface
Fixes #404

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-04-29 14:31:40 +02:00
Joachim WibergandTobias Waldekranz 8a007d61d0 Disable Ethernet flow-control completely by default
We have previously stated configuration and status flow-control as not
supported, see infix-ethernet-interface.yang.  This is also the default
for flow-control in the ieee-ethernet-interface.yang model.

This patch change the actual value to disabled, so that devices properly
advertise flow-control as disabled/not-supported in auto-negotiation.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-04-29 14:31:40 +02:00
Jon-Olov VatnandJoachim Wiberg c58a624a51 Updating scripting file with sysrepo examples
[skip ci]
2024-04-29 11:09:01 +02:00
Jon-Olov VatnandJoachim Wiberg 9326812430 Updating sysrepocfg scripting examples
[skip ci]
2024-04-29 11:09:01 +02:00
Jon-Olov VatnandJoachim Wiberg 9bf4f1d982 Adding sysrepocfg examples
Initial examples added.
More can be done to show how config files are transferred to infix.

[skip ci]
2024-04-29 11:09:01 +02:00
Joachim Wiberg d722b108dc .github: let Coverity Scan run on GitHub infra
Our local runners do not allow sudo, e.g., when installing libyang and
the other dependencies.

[skip ci]

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-04-29 11:08:27 +02:00
Joachim WibergandTobias Waldekranz d1a7e1d744 .github: revert massive-parallel builds and select new runners
The massive-parallel build change added recently is a bit shaky still,
so while we stabilze that, we revert it and also take the oppportunity
to tag the new build server.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-04-29 08:44:44 +02:00
Joachim WibergandTobias Waldekranz 286d5e9c0d .github: cleanup and minor changes for consistency.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-04-29 08:44:44 +02:00
Joachim WibergandTobias Waldekranz 7dc0542d01 test/virt: override default Qeneth OUI
Over the lifetime of Infix, so far, we've run into at least one customer
issue where we had qualms about our use of the local bit causing issues
with 3rd party software.  In the end that was not the root cause of our
problems, but we spent way too much time worrying about it.  Hence this
patch, which brings our virtual environments another step closer to the
real hardware that Infix runs on.

The OUI used is one of the "private" ones, taken completly at random.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-04-29 08:44:44 +02:00
Joachim WibergandTobias Waldekranz 0480d0f16b test/virt: rename according to new interface naming standard
Ethernet ports start with 'e'
Port numbers start with '1'

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-04-29 08:44:44 +02:00
Joachim WibergandTobias Waldekranz 59f81e9391 test/qeneth: bump for new mac ranges and mactab support
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-04-29 08:44:44 +02:00
Joachim WibergandTobias Waldekranz 3f2ead2528 doc: update list of required packages
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-04-29 08:44:44 +02:00
Joachim WibergandTobias Waldekranz 3f1c360287 doc: add section on multicast filtering and snooping
Final work item for the Infix bridge MDB support epic.

Fixes #334

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-04-29 08:44:44 +02:00
Joachim WibergandTobias Waldekranz c3a227289d confd: allow setting factory hostname from qemu_fw_cfg
This patch adds support for overriding the default hostname generation
on Qemu systems with the /sys/firmware/qemu_fw_cfg/by_name/opt/hostname
file.  E.g., virtual Infamy test systems using Qeneth.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-04-29 08:44:44 +02:00
Joachim WibergandTobias Waldekranz bb18afa883 board/common: probe system base mac also on qemu systems
The base mac address is used by bridges in Infix.  This patch adds
support for extracting a base mac from the first interface "- 1",
e.g., if the mac address of e1 is 08:00:20:00:00:01, the base mac
will be 08:00:20:00:00:00.

This works with the Infamy test framework (Qeneth) and also with
the qemu script, included in this patch.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-04-29 08:44:44 +02:00
Joachim WibergandTobias Waldekranz adab286bf9 board/common: ensure /run/system.json is readable only wheel group
Writable by root, readble only by wheel members, e.g. admin.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-04-29 08:44:44 +02:00
Joachim WibergandTobias Waldekranz b993c8daa7 board/common: minor, fix a few pylint warnings
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-04-29 08:44:44 +02:00
Joachim WibergandTobias Waldekranz e59bab16c0 confd: set mcast_vlan_snooping and correct IGMP/MLD versions
As described in issue #396, multicast filtering on VLAN filtering
bridges did not work at all.  This because bridge_mcast_settings()
exited when no global multicast settings were found -- a change to
the YANG model made previously triggered this fauled behavior.

Also, the initial IGMP/MLD versions were set to 2/1 (kernel default)
instead of 3/2 (Infix default).

Fixes #396

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-04-29 08:44:44 +02:00
Joachim WibergandTobias Waldekranz 4ce1be6f0a package/mcd: bump from v2.1 to v2.3
For a full ChangeLog, see:

  - https://github.com/kernelkit/mcd/releases/tag/v2.2
  - https://github.com/kernelkit/mcd/releases/tag/v2.3

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-04-29 08:44:44 +02:00
Mattias Walström a0804b15fe Add possibility to have multiple trusted certificates
Today, only one certificate is shipped with infix, it is
selectable in menuconfig. It is also possible to add extra
certificates, useful when using infix as a submodule.
2024-04-25 13:29:24 +02:00
Tobias Waldekranz 886132600a kernel: Import 6393X fixes
- Isolation of ports in standalone mode was broken in multi-chip trees
- Let the CPU send FORWARDs to IEEE reserved L2 groups
2024-04-25 11:24:19 +02:00
Joachim Wiberg b5c0bfea62 .github: relocate all builds to self-hosted runners
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-04-25 09:20:32 +02:00
Joachim Wiberg c3900ec710 confd: allow VLAN interfaces as bridge ports
Fixes #406

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-04-25 09:20:32 +02:00
Joachim Wiberg 4fb7969de8 execd: install into /lib/tmpfiles.d
The CNI directories must be created before the podman tmpfiles
are called, so move our tmpfiles to /lib/tmpfiles.d

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-04-25 09:20:32 +02:00
Joachim Wiberg dcd7cb1a77 package/sysklogd: backport fix for kernel logs to console
- Backport fix to allow raw kernel logs to console
 - Save 10 rotated (and gzipped) backups of all logs

The latter change was discussed a few weeks ago.  We determined it was a
safe number since all active products have eMMC with *lots* of storage.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-04-25 09:20:32 +02:00
Joachim Wiberg 8f8805a1ee package/finit: backport support for allowing kernel logs to console
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-04-25 09:20:32 +02:00
Joachim Wiberg c21c94f851 package/finit: backport fix for tty @console
Only the first listed console in /sys/class/tty/console/active starts
properly, the remaining one(s) were registered using the wrong :ID and
no arguments to getty.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-04-25 09:20:32 +02:00
Mattias Walström 45cc13ccfe statd: Add libyang as dependancy 2024-04-24 21:10:05 +02:00
Mattias Walström 096b7edee2 confd: add libglib2 as a dependency 2024-04-24 21:10:05 +02:00
Mattias Walström 6f962fcadf libsrx: add libite dependancy 2024-04-24 21:10:05 +02:00
Mattias Walström fef8dd5072 Enable parallell build of packages
Build all packages in parallell to cut building time.
2024-04-24 21:10:05 +02:00
Mattias Walström 9cd7737d7e Change to self-hosted runner 2024-04-24 21:10:05 +02:00
Mattias WalströmandJoachim Wiberg 2f61aaaaf8 Revert "Change to self-hosted runner"
This reverts commit b2fef1585f.
2024-04-23 21:05:35 +02:00
Mattias WalströmandJoachim Wiberg dcc80d0d8a Allow to run testsystem using disk image
This will run the testsystem with a disk
image containing grub bootloader.
2024-04-23 16:24:18 +02:00
Mattias WalströmandJoachim Wiberg c637ab4edb grub: Use same console for qeneth and make run
Console is now located on hvc0
2024-04-23 16:24:18 +02:00
Mattias WalströmandJoachim Wiberg 4add90e601 qemu: Synchronize with qeneth setting for console
Change default console to hvc0 (same as qeneth)
This is the only working console for now.
2024-04-23 16:24:18 +02:00
Mattias WalströmandJoachim Wiberg 72fe0ac963 Bump qeneth to add new infix templates
Adds infix-kernel-x86_64
and infix-bios-x86_64
2024-04-23 16:24:18 +02:00
Tobias WaldekranzandJoachim Wiberg c9a30d20cb board/aarch64: alder: Use in-band-status on USXGMII links
This avoids the issue with unidirectional links described in the
parent commit.
2024-04-23 07:57:32 +02:00
Tobias WaldekranzandJoachim Wiberg d36899b49e kernel: Import mv88e6xxx in-band-status fix
Even when `managed = "in-band-status";` was specified on a port,
mv88e6xxx would insist on forcing the values that were supposed to be
automatically picked up by the MAC via in-band signaling.

In the case of USXGMII links on 6393X, forcing the link bit would
sometimes, for reasons that are not understood, cause the SERDES to
reset its USXGMII link partner base page (register 4.0xf0a2) to 0,
which it would then interpret as 10M/half-duplex. As a result, the
SERDES would erroneously perform rate-matching to 10M on egress
towards the PHY (which is configured for 10G/full-duplex), leading to
nothing but dropped packets and much sadness.

This can most easily be reproduced by the following setup:

.------------.
|        .-----.   .-------.
|        | p9  +---+ 3310P +--.
| 6393X  :-----:   :-------:  | T- or X-Units looped via external cable
|        | p10 +---+ 3310P +--'
|        '-----'   '-------'
'------------'

Make sure that neither p9 nor p10 are managed using in-band-status.

1. ip link set dev p9 up; ip link set dev p10 up
2. ip link set dev p9 down
3. ip link set dev p9 up

After step (3), p10 will experience the failure described above in
about 3/4 of the cases. In the cases where the issue does not arise,
simply repeat steps (2) and (3).
2024-04-23 07:57:32 +02:00
Mattias WalströmandTobias Waldekranz 9b02782f57 Build: Fix recursive dependency in statd and python-statd 2024-04-22 14:22:50 +02:00
Mattias WalströmandTobias Waldekranz ced93c89c7 grub: Select root partion from UUID 2024-04-22 14:22:50 +02:00
Mattias WalströmandTobias Waldekranz e6def82be1 grub2: Add patch to add search by partition uuid 2024-04-22 14:22:50 +02:00
Mattias WalströmandTobias Waldekranz f36f805a77 grub2: Require to run autogen.sh before configure 2024-04-22 14:22:50 +02:00
Tobias WaldekranzandJoachim Wiberg 36716dab42 utils: ixll: Add link-local wrappers for ping/ssh/scp 2024-04-19 15:25:02 +02:00
385 changed files with 11765 additions and 5292 deletions
+36 -20
View File
@@ -11,7 +11,7 @@ Talking about code and problems first is often the best way to get started
before submitting a pull request.
When submitting a bug report, patch, or pull request, please start by
stating the version the change is made against, what it does, and why.
stating the version the change is made against, what it does, *and why*.
Please take care to ensure you follow the project coding style and the
commit message format. If you follow these recommendations you help
@@ -21,13 +21,28 @@ the maintainer(s) and make it easier for them to include your code.
Coding Style
------------
> **Tip:** Always submit code that follows the style of surrounding code!
Before jumping into code, remember to **document new features** and bug
fixes. Both the manual and ChangeLog are in the `doc/` sub-directory
and it is expected that you provide a human-readable summary for the
release notes (ChangeLog) and at least a configuration example in the
manual for new features.
First of all, lines are allowed to be longer than 72 characters these
days. In fact, there exist no enforced maximum, but keeping it around
100 chars is OK.
> **Tip:** consider ["Readme driven development"][RDD] for new features.
> It is amazing how many flaws in your own bright ideas come to bare
> when you suddenly have to explain them to someone else!
The coding style itself is otherwise strictly Linux [KNF][].
We expect code contributions for:
- C code in [Linux Coding Style][Linux]
- Python code should follow [PEP-8][]
> **However,** always submit code that follows the style of surrounding
> code! Legacy takes precedence, and remember, we read code a lot more
> than write it, so legibility is important.
As a final note, lines are allowed to be longer than 72 characters these
days. There is no enforced maximum, but the team usually keep it around
100 characters for both C and Python.
Commit Messages
@@ -37,22 +52,21 @@ Commit messages exist to track *why* a change was made. Try to be as
clear and concise as possible in your commit messages, and always, be
proud of your work and set up a proper GIT identity for your commits:
git config --global user.name "Jane Doe"
git config --global user.email jane.doe@example.com
$ git config --global user.name "Jacky Linker"
$ git config --global user.email jacky.linker@example.com
Example commit message from the [Pro Git][gitbook] online book, notice
how `git commit -s` is used to automatically add a `Signed-off-by`:
Brief, but clear and concise summary of changes
subsystem: brief, but clear and concise summary of changes
More detailed explanatory text, if necessary. Wrap it to about 72
characters or so. In some contexts, the first line is treated as
the subject of an email and the rest of the text as the body. The
blank line separating the ummary from the body is critical (unless
you omit the body entirely); tools like rebase can get confused if
you run the two together.
empty line separating summary from body is critical. Tools like
rebase can get confused if the empty line is missing.
Further paragraphs come after blank lines.
Further paragraphs should be separated with empty lines.
- Bullet points are okay, too
@@ -60,17 +74,19 @@ how `git commit -s` is used to automatically add a `Signed-off-by`:
by a single space, with blank lines in between, but conventions
vary here
Signed-off-by: Jane Doe <jane.doe@example.com>
Signed-off-by: Jacky Linker <jacky.linker@example.com>
Code of Conduct
---------------
It is expected of everyone to respect the [Code of Conduct][conduct].
The *"maintainers have the right and responsibility to remove, edit,
or reject comments, commits, code, wiki edits, issues, and other
contributions that are not aligned to this Code of Conduct."*
The *"maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, discussion forum threads, issues, and
other contributions that are not aligned to this Code of Conduct."*
[KNF]: https://en.wikipedia.org/wiki/Kernel_Normal_Form
[gitbook]: https://git-scm.com/book/ch5-2.html
[conduct]: CODE-OF-CONDUCT.md
[Linux]: https://www.kernel.org/doc/html/v6.9/process/coding-style.html
[PEP-8]: https://peps.python.org/pep-0008/
[RDD]: https://tom.preston-werner.com/2010/08/23/readme-driven-development
[gitbook]: https://git-scm.com/book/ch5-2.html
[conduct]: CODE-OF-CONDUCT.md
+69
View File
@@ -0,0 +1,69 @@
# https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/syntax-for-githubs-form-schema
name: "\U0001F41E Bug report"
description: Create a bug report
labels:
- "bug"
- "triage"
body:
- type: markdown
attributes:
value: |
**Thank :heart: you for taking the time to fill out this bug report!**
We kindly ask that you search to see if an issue [already exists](https://github.com/kernelkit/infix/issues?q=is%3Aissue+sort%3Acreated-desc+) for the bug you encountered.
- type: textarea
attributes:
label: Current Behavior
description: |
A clear and concise description of the issue you're experiencing.
value: |
For code snippets, logs, commands, etc., please use triple backticks:
```
admin@infix-c0-ff-ee:/> show log
May 15 07:21:02 infix-00-00-00 container[3192]: Failed creating container test from curios-httpd-v24.03.0
- (press h for help or q to quit)
```
validations:
required: true
- type: textarea
attributes:
label: Expected Behavior
description: |
A clear and concise description of what you expected to happen.
value: |
```
admin@infix-c0-ff-ee:/> show log
May 15 07:21:02 infix-c0-ff-ee container[3192]: Successfully created container test from curios-httpd-v24.03.0
- (press h for help or q to quit)
```
validations:
required: true
- type: textarea
attributes:
label: Steps To Reproduce
description: |
Steps to reproduce the issue. For example:
1. Built from source
2. Upgrade to latest release, vYY.MM.P
3. Factory reset
4. Enable feature
5. Check the logs/show command/operational status
validations:
required: false
- type: textarea
attributes:
label: Additional information
description: |
- Relevant parts of `startup-config`
- Output from `show interfaces`, if applicable
- Other observations, screenshots, log files ...
**Tip:** You can attach images or log files by clicking this area to highlight it and then dragging files in.
validations:
required: false
+7
View File
@@ -0,0 +1,7 @@
contact_links:
- name: "🔍 Look for my Issue"
url: https://github.com/kernelkit/infix/issues?q=is%3Aissue+sort%3Acreated-desc+
about: Thank ❤️ you for your time! We kindly ask that you first check if an issue already exists.
- name: "💬 Discussions and Q&A"
url: https://github.com/kernelkit/infix/discussions
about: Discussions are perfect for quick questions, bouncing ideas, and things that may be a bug.
@@ -0,0 +1,45 @@
# https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/syntax-for-githubs-form-schema
name: "\U0001F6E0 Feature request"
description: Suggest a new feature, idea or improvement of the OS
labels:
- "feature"
- "triage"
body:
- type: markdown
attributes:
value: |
**Thank :heart: you for taking the time to fill out this feature request!**
We kindly ask that you search to see if an issue [already exists](https://github.com/kernelkit/infix/issues?q=is%3Aissue+sort%3Acreated-desc+) for your feature. We are also happy to accept contributions from our users. For details see [CONTRIBUTING](https://github.com/kernelkit/infix/blob/master/.github/CONTRIBUTING.md).
- type: textarea
attributes:
label: Description
description: |
A clear and concise description of the problem or missing feature.
**Example:** *I'm always frustrated when [...]*, or *I'd like to see support for [...]*
validations:
required: true
- type: textarea
attributes:
label: Additional Information
description: |
Any other related information, e.g. existing YANG model(s), or possibly screenshots about the feature request here.
validations:
required: false
- type: textarea
attributes:
label: General Information
description: |
Appended to all feature requests for future readers.
value: |
Anyone can help out by [sponsoring][1] development of new features or [contributing][2] pull requests.
Please use this issue for discussions related to the feature.
[1]: https://github.com/kernelkit/infix/blob/main/.github/SUPPORT.md
[2]: https://github.com/kernelkit/infix/blob/main/.github/CONTRIBUTING.md
validations:
required: true
+1 -7
View File
@@ -1,5 +1,3 @@
<!--- **Summarize** your changes in the title above -->
## Description
<!--
@@ -15,7 +13,7 @@
## Checklist
Tick relevant boxes, this PR is-a or has-a:
Tick *relevant* boxes, this PR is-a or has-a:
- [ ] Bugfix
- [ ] Regression tests
@@ -31,7 +29,3 @@ Tick relevant boxes, this PR is-a or has-a:
- [ ] Documentation content changes
- [ ] Other (please describe):
## References
<!-- Please list references to related issue(s) -->
+78 -34
View File
@@ -1,6 +1,7 @@
name: Bob the Builder
on:
pull_request:
push:
branches:
- main
@@ -8,30 +9,25 @@ on:
jobs:
build:
name: Build Infix ${{ matrix.platform }}
runs-on: ubuntu-latest
name: Build Infix ${{ matrix.target }}
runs-on: [ self-hosted, latest ]
strategy:
matrix:
platform: [aarch64, x86_64]
target: [aarch64, x86_64]
fail-fast: false
steps:
- name: Maintenance
run: |
docker image prune -af
docker volume prune -f
docker container prune -f
- uses: actions/checkout@v4
with:
clean: true
submodules: recursive
- name: Set Build Variables
id: vars
run: |
target=${{ matrix.platform }}
target=${{ matrix.target }}
echo "dir=infix-$target" >> $GITHUB_OUTPUT
echo "tgz=infix-$target.tar.gz" >> $GITHUB_OUTPUT
if [ "$target" = x86_64 ]; then
echo "out=$PWD/output" >> $GITHUB_OUTPUT
else
echo "out=/mnt/x-$target" >> $GITHUB_OUTPUT
fi
- name: Restore Cache of dl/
uses: actions/cache@v4
with:
@@ -39,42 +35,82 @@ jobs:
key: dl-${{ hashFiles('.git/modules/buildroot/HEAD', 'configs/*', 'package/*/*.hash') }}
restore-keys: |
dl-
- name: Restore Cache of .ccache/
uses: actions/cache@v4
with:
path: .ccache/
key: ccache-${{ matrix.platform }}-${{ hashFiles('.git/modules/buildroot/HEAD', 'package/*/*.hash') }}
key: ccache-${{ matrix.target }}-${{ hashFiles('.git/modules/buildroot/HEAD', 'package/*/*.hash') }}
restore-keys: |
ccache-${{ matrix.platform }}-
ccache-${{ matrix.target }}-
ccache-
- name: Configure & Build
- name: Configure ${{ matrix.target }}
run: |
target=${{ matrix.platform }}_defconfig
echo "Building $target ..."
sudo mkdir ${{ steps.vars.outputs.out }}
sudo chown $(id -un):$(id -gn) ${{ steps.vars.outputs.out }}
export O=${{ steps.vars.outputs.out }}
make $target
make ${{ matrix.target }}_defconfig
- name: Unit Test ${{ matrix.target }}
run: |
make test-unit
- name: Build ${{ matrix.target }}
run: |
echo "Building ${{ matrix.target }}_defconfig ..."
make
- name: Prepare Artifact
- name: Prepare ${{ matrix.target }} Artifact
run: |
cd ${{ steps.vars.outputs.out }}
cd output/
mv images ${{ steps.vars.outputs.dir }}
ln -s ${{ steps.vars.outputs.dir }} images
tar chfz ${{ steps.vars.outputs.tgz }} ${{ steps.vars.outputs.dir }}
- name: Test
if: matrix.platform == 'x86_64'
run: |
export O=${{ steps.vars.outputs.out }}
make test-qeneth
- uses: actions/upload-artifact@v4
with:
path: ${{ steps.vars.outputs.out }}/${{ steps.vars.outputs.tgz }}
name: artifact-${{ matrix.platform }}
path: output/${{ steps.vars.outputs.tgz }}
name: artifact-${{ matrix.target }}
test:
name: Regression Test of Infix x86_64
needs: build
runs-on: [ self-hosted, regression ]
steps:
- uses: actions/checkout@v4
with:
clean: true
submodules: recursive
- name: Configure x86_64
run: |
make x86_64_defconfig
- uses: actions/download-artifact@v4
with:
pattern: "artifact-*"
merge-multiple: true
- name: Restore x86-64 output/
run: |
ls -l
mkdir -p output
mv infix-x86_64.tar.gz output/
cd output/
tar xf infix-x86_64.tar.gz
ln -s infix-x86_64 images
- name: Regression Test
run: |
make test
- name: Publish Test Result
# Ensure this runs even if Regression Test fails
if: always()
run: cat test/.log/last/result-gh.md >> $GITHUB_STEP_SUMMARY
release:
if: ${{github.repository_owner == 'kernelkit' && github.ref_name == 'main'}}
name: Upload Latest Build
needs: build
needs: test
runs-on: ubuntu-latest
permissions:
contents: write
@@ -83,6 +119,13 @@ jobs:
with:
pattern: "artifact-*"
merge-multiple: true
- name: Create checksums ...
run: |
for file in *.tar.gz; do
sha256sum $file > $file.sha256
done
- uses: ncipollo/release-action@v1
with:
allowUpdates: true
@@ -92,7 +135,8 @@ jobs:
prerelease: true
tag: "latest"
token: ${{ secrets.GITHUB_TOKEN }}
artifacts: "*.tar.gz"
artifacts: "*.tar.gz*"
- name: Summary
run: |
cat <<EOF >> $GITHUB_STEP_SUMMARY
+8 -1
View File
@@ -24,6 +24,7 @@ jobs:
--post-data "token=$TOKEN&project=${PROJECT_NAME}&md5=1" \
-O coverity-latest.tar.gz.md5
echo "md5=$(cat coverity-latest.tar.gz.md5)" | tee -a $GITHUB_OUTPUT
- uses: actions/cache@v4
id: cache
with:
@@ -33,6 +34,7 @@ jobs:
${{ runner.os }}-coverity-${{ steps.var.outputs.md5 }}
${{ runner.os }}-coverity-
${{ runner.os }}-coverity
- name: Download Coverity Scan
env:
TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}
@@ -47,12 +49,14 @@ jobs:
fi
mkdir coverity
tar xzf coverity-latest.tar.gz --strip 1 -C coverity
- name: Install dependencies
run: |
sudo apt-get -y update
sudo apt-get -y install pkg-config libjansson-dev libev-dev \
libaugeas-dev libglib2.0-dev libpcre2-dev \
libcrypt-dev libglib2.0-dev libpcre2-dev \
libuev-dev libite-dev
- name: Build dependencies
run: |
git clone https://github.com/CESNET/libyang.git
@@ -62,10 +66,12 @@ jobs:
mkdir sysrepo/build
(cd sysrepo/build && cmake .. && make all && sudo make install)
make dep
- name: Check applications
run: |
export PATH=`pwd`/coverity/bin:$PATH
cov-build --dir cov-int make check
- name: Submit results to Coverity Scan
env:
TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}
@@ -78,6 +84,7 @@ jobs:
--form version=$(git rev-parse HEAD) \
--form description="${PROJECT_NAME} $(git rev-parse HEAD)" \
https://scan.coverity.com/builds?project=${PROJECT_NAME}
- name: Upload build.log
uses: actions/upload-artifact@v4
with:
-77
View File
@@ -1,77 +0,0 @@
name: Reggie Regression
on:
push:
branches:
- '*'
pull_request:
branches:
- '*'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
build:
name: Regression Testing
runs-on: self-hosted
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
steps:
- uses: actions/checkout@v4
with:
submodules: 'true'
- name: Clean up cruft ...
run: |
./test/env -c
- name: Set Build Variables
id: vars
run: |
target=x86_64
echo "dir=infix-$target" >> $GITHUB_OUTPUT
echo "tgz=infix-$target.tar.gz" >> $GITHUB_OUTPUT
- name: Restore Cache of dl/
uses: actions/cache@v4
with:
path: dl/
key: dl-netconf-${{ hashFiles('.git/modules/buildroot/refs/heads/master', 'package/*/*.hash') }}
restore-keys: |
dl-netconf-
dl-
- name: Restore Cache of .ccache/
uses: actions/cache@v4
with:
path: .ccache/
key: ccache-x86_64-${{ hashFiles('.git/modules/buildroot/refs/head/master', 'package/*/*.hash') }}
restore-keys: |
ccache-x86_64-
ccache-
- name: Configure NETCONF
run: |
make x86_64_defconfig
- name: Unit Test
run: make test-unit
- name: Build
run: |
make
- name: Prepare Artifact
run: |
cd output
mv images ${{ steps.vars.outputs.dir }}
ln -s ${{ steps.vars.outputs.dir }} images
tar cfz ${{ steps.vars.outputs.tgz }} ${{ steps.vars.outputs.dir }}
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
path: output/${{ steps.vars.outputs.tgz }}
- name: Regression Test
run: make test-qeneth
- name: Publish Test Result
# Ensure this runs even if Regression Test fails
if: always()
run: cat test/.log/last/result-gh.md >> $GITHUB_STEP_SUMMARY
+30 -20
View File
@@ -20,19 +20,18 @@ on:
jobs:
build:
if: github.repository == 'kernelkit/infix' && startsWith(github.ref, 'refs/tags/')
name: Build Infix ${{ github.ref_name }} [${{ matrix.platform }}]
runs-on: ubuntu-latest
name: Build Infix ${{ github.ref_name }} [${{ matrix.target }}]
runs-on: [ self-hosted, release ]
strategy:
matrix:
platform: [aarch64, x86_64]
target: [aarch64, x86_64]
fail-fast: false
steps:
- name: Maintenance
run: |
docker image prune -af
docker volume prune -f
docker container prune -f
- uses: actions/checkout@v4
with:
clean: true
submodules: recursive
- name: Set Release Variables
id: vars
run: |
@@ -43,10 +42,10 @@ jobs:
fi
echo "ver=${ver}" >> $GITHUB_OUTPUT
fver=${ver#v}
target=${{ matrix.platform }}-${fver}
target=${{ matrix.target }}-${fver}
echo "dir=infix-$target" >> $GITHUB_OUTPUT
echo "tgz=infix-$target.tar.gz" >> $GITHUB_OUTPUT
echo "out=/mnt/x-$target" >> $GITHUB_OUTPUT
- name: Restore Cache of dl/
uses: actions/cache@v4
with:
@@ -54,49 +53,55 @@ jobs:
key: dl-${{ hashFiles('.git/modules/buildroot/HEAD', 'configs/*', 'package/*/*.hash') }}
restore-keys: |
dl-
- name: Restore Cache of .ccache/
uses: actions/cache@v4
with:
path: .ccache/
key: ccache-${{ matrix.platform }}-${{ hashFiles('.git/modules/buildroot/HEAD', 'package/*/*.hash') }}
key: ccache-${{ matrix.target }}-${{ hashFiles('.git/modules/buildroot/HEAD', 'package/*/*.hash') }}
restore-keys: |
ccache-${{ matrix.platform }}-
ccache-${{ matrix.target }}-
ccache-
- name: Configure & Build
env:
INFIX_RELEASE: ${{ steps.vars.outputs.ver }}
run: |
target=${{ matrix.platform }}_defconfig
target=${{ matrix.target }}_defconfig
echo "Building $target ..."
sudo mkdir ${{ steps.vars.outputs.out }}
sudo chown $(id -un):$(id -gn) ${{ steps.vars.outputs.out }}
export O=${{ steps.vars.outputs.out }}
make $target
make
- name: Generate SBOM from Build
run: |
make legal-info
- name: Prepare Artifacts
run: |
cd ${{ steps.vars.outputs.out }}
cd output/
mv images ${{ steps.vars.outputs.dir }}
ln -s ${{ steps.vars.outputs.dir }} images
tar chfz ${{ steps.vars.outputs.tgz }} ${{ steps.vars.outputs.dir }}
mv legal-info legal-info-$target
tar chfz legal-info-$target.tar.gz legal-info-$target
- uses: actions/upload-artifact@v4
with:
name: artifact-${{ matrix.platform }}
path: ${{ steps.vars.outputs.out }}/*.tar.gz
name: artifact-${{ matrix.target }}
path: output/*.tar.gz
release:
name: Release Infix ${{ github.ref_name }}
needs: build
runs-on: ubuntu-latest
runs-on: [ self-hosted, release ]
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
submodules: 'true'
- name: Set Release Variables
id: rel
run: |
@@ -118,20 +123,24 @@ jobs:
fi
echo "pre=${{ steps.rel.outputs.pre }}"
echo "latest=${{ steps.rel.outputs.latest }}"
- uses: actions/download-artifact@v4
with:
pattern: "artifact-*"
merge-multiple: true
- name: Create checksums ...
run: |
for file in *.tar.gz; do
sha256sum $file > $file.sha256
done
- name: Extract ChangeLog entry ...
run: |
awk '/^-----*$/{if (x == 1) exit; x=1;next}x' doc/ChangeLog.md \
|head -n -1 > release.md
cat release.md
- uses: ncipollo/release-action@v1
with:
name: Infix ${{ github.ref_name }}
@@ -139,6 +148,7 @@ jobs:
makeLatest: ${{ steps.rel.outputs.latest }}
bodyFile: release.md
artifacts: "*.tar.gz*"
- name: Summary
run: |
cat <<EOF >> $GITHUB_STEP_SUMMARY
+1 -5
View File
@@ -112,10 +112,6 @@ config INFIX_ARCH
default "riscv64" if BR2_riscv
default "x86_64" if BR2_x86_64
menu "Packages"
source "$BR2_EXTERNAL_INFIX_PATH/package/Config.in"
endmenu
source "$BR2_EXTERNAL_INFIX_PATH/package/Config.in.host"
source "$BR2_EXTERNAL_INFIX_PATH/board/common/Config.in"
+6 -1
View File
@@ -2,7 +2,12 @@ export BR2_EXTERNAL := $(CURDIR)
export PATH := $(CURDIR)/bin:$(PATH)
ARCH ?= $(shell uname -m)
O ?= $(CURDIR)/output
O ?= output
# If a relative output path is specified, we have to translate it to
# an absolute one before handing over control to Buildroot, which will
# otherwise treat it as relative to ./buildroot.
override O := $(if $(filter /%,$O),$O,$(CURDIR)/$O)
config := $(O)/.config
bmake = $(MAKE) -C buildroot O=$(O) $1
+2 -1
View File
@@ -100,7 +100,7 @@ and testing, but can also be used for evaluation and demo purposes. For
more information, see: [Infix in Virtual Environments](doc/virtual.md).
> See the [GitHub Releases](https://github.com/kernelkit/infix/releases)
> page for our pre-built images. The *Latest Build* has the bleeding
> page for our pre-built images. The *[Latest Build][]* has bleeding
> edge images, if possible we recommend using a versioned release.
>
> For *customer specific builds* of Infix, see your product repository.
@@ -116,6 +116,7 @@ more information, see: [Infix in Virtual Environments](doc/virtual.md).
[1]: https://buildroot.org/
[2]: https://www.sysrepo.org/
[3]: doc/cli/introduction.md
[Latest Build]: https://github.com/kernelkit/infix/releases/tag/latest
[License]: https://en.wikipedia.org/wiki/GPL_license
[License Badge]: https://img.shields.io/badge/License-GPL%20v2-blue.svg
[GitHub]: https://github.com/kernelkit/infix/actions/workflows/build.yml/
+4 -64
View File
@@ -1,67 +1,7 @@
aarch64
=======
Microchip SparX-5i PCB135 (eMMC)
--------------------------------
At present, only FIT images are supported via the SparX-5i eval
board's U-Boot, which must contain a valid load address. If you are
using this board, after selecting your base configuration, run the
following command to supplement the existing config with the required
FIT options:
make board-enable-sparx-fit
### Unbricking
1. Don't load a corrupt bootloader to begin with
2. Done
If, for some reason, you didn't manage to follow step 1, you can use
the `FLASH_PROG`(`J4`) connector on the board to access the SPI flash
directly.
Using a [Bus Blaster][BB3] in combination with [dangerspi][dangerspi],
you can load a new bootloader. The schematic below details how to
connect the Bus Blaster to the board, but the concept should be
portable to any debugger/device based around an FTDI2232 chip.
```
Bus Blaster: FLASH_PROG (J4):
.---. .---.
VTG >o o| VTG SCK >o o| GND
TRST |o o| GND MISO |o o| #RESET_FLASH
TDI |o o| GND o o| 3V3
TMS |o o| GND #CS |o o| #SYSRESET
TCK o o| GND MOSI |o o| GND
RTCK o o| GND '---'
TDO |o o| GND
TSRST |o o| GND
DBGRQ |o o| GND
DBGACK |o o| GND
'---'
```
| Bus Blaster | FLASH_PROG |
|-------------|----------------|
| `VTG` | `3V3` |
| `GND` | `GND` |
| | |
| `VTG` | `#RESET_FLASH` |
| `GND` | `#SYSRESET` |
| | |
| `TDI` | `MOSI` |
| `TMS` | `#CS` |
| `TCK` | `SCK` |
| `TDO` | `MISO` |
With the cable in place, build U-Boot with the correct configuration:
make fireant_boot_defconfig && make
To flash it to the board, connect the cable to `J4` and run:
make board-sparx-flash-uboot
[BB3]: http://dangerousprototypes.com/docs/Bus_Blaster#Bus_Blaster_v3
[dangerspi]: https://github.com/wkz/dangerspi
Board Specific Documentation
----------------------------
- [Marvell CN9130-CRB](cn9130-crb/)
- [Microchip SparX-5i PCB135 (eMMC)](sparx5-pcb135/)
+132
View File
@@ -0,0 +1,132 @@
Marvell CN9130-CRB
==================
## Build instructions
### Bootloader
Build the bootloader from the supplied `defconfig`. It might be useful
to build in a separate output directory if you want to build Infix
from the same working tree later:
make O=$(pwd)/x-cn9130-boot cn9130_crb_boot_defconfig
cd x-cn9130-boot
make
The artifact of interest is called `flash-image.bin`, which will be
located in the `images/` directory once the build completes.
### Infix
> If you do not want to build Infix from source, feel free to use a pre-built [release]
The standard `aarch64_defconfig` is compatible with this board:
make O=$(pwd)/x-aarch64 aarch64_defconfig
cd x-aarch64
make
Two artifacts from the `images/` directory of this build are required
to provision a new board:
- `rootfs.itb`: Netbootable image
- `infix-aarch64.pkg`: Standard upgrade bundle
## Provisioning
The overall provisioning flow, in which each step in described in
details in the following sections, is as follows:
- Strap board to boot from SPI FLASH
- Load `flash-image.bin` over UART
- Burn `flash-image.bin` to SPI FLASH
- Netboot `rootfs.itb`
- Run Infix's built-in provisioning script
- Reboot, now booting from the primary partition of the SD-card
#### Strap Board to Boot from SPI FLASH
By default, the board is strapped to boot from eMMC. However, Infix
assumes that the board will boot from SPI FLASH. Therefore we have to
ensure that the DIP switches of `SW2` on the board selects a
`BOOT_MODE` of `0x32`, meaning that the switches on positions 4, 3,
and 1 should be enabled (i.e. these need to be tied to ground):
```
.-----. .-----. .-----.
| | | | | PWR |
| SIM | | uSD | | |
| | | | '-----'
'-----' '-----'
|
v
.-----. .-----.
| SW1 | | SW2 |
'-----' '-----'
.--------------------------.
| |
| |
| CN9130 |
```
#### UART Boot U-Boot
Make sure that:
- [mvebu64boot] is installed and available in your shell's `$PATH`
- No other program is attached to `ttyUSB0`
- No power is applied to the board
1. Start `mvebu64boot`:
mvebu64boot -b /path/to/flash-image.bin /dev/ttyUSB0
2. Apply power
As soon as `mvebu64boot` completes, attach to the serial port,
e.g. using `screen(1)`, or `console(1)` and stop the normal boot
process by hitting any key.
#### Burn U-Boot to SPI FLASH
Make sure that:
- `eth1` is connected to a machine which serves `flash-image.bin` over
TFTP
- U-Boot can reach the TFTP server. If the neighboring machine is also
set up as a DHCP server, simply run the command `dhcp -`
To burn the bootloader to SPI FLASH, run the `bubt` command:
bubt flash-image.bin
Once the command completes, reset the board to verify that it can now
boot unassisted:
reset
#### Boot up `rootfs.itb`
U-Boot will automatically fallback to netboot since the SD-card is
still blank. Make sure that the PC provides the path to `rootfs.itb`
in DHCP option 67 ("bootfile").
#### Install Firmware
Login as `admin`/`admin`, setup networking to the PC, ensure that the date on
the device is reasonably correct, and run the provisioning script:
admin@infix:~$ sudo -i
root@infix:~$ udhcpc -i e28
root@infix:~$ date -us YYYY-MM-DD
root@infix:~$ /libexec/infix/prod/provision tftp://<PC-IP>/infix-aarch64.pkg /dev/mmcblk0
After successful completion, the device is fully provisioned. On the
next boot, the device will boot of its own accord from the primary
SD-card partition.
> If possible, serve `infix-aarch64.pkg` over HTTP instead, as
> libcurl's TFTP implementation is quite slow.
[release]: https://github.com/kernelkit/infix/releases
[mvebu64boot]: https://github.com/addiva-elektronik/mvebu64boot
@@ -17,35 +17,11 @@ run ixboot
boot_targets = "mmc1";
ethprime = "eth1";
/* Uncomment this if you're debugging U-Boot
*
* This will allow you to break out of the
* normal boot flow and into the interactive
* console.
*
* To upgrade U-Boot itself, simply set the
* `bootfile` variable to the path of
* `flash-image.bin` on your TFTP server, then
* issue `run ixupgradeboot`.
/* This is a development platform, keep
* developer mode statically enabled.
*/
/* bootdelay = "2"; */
/* ixupgradeboot = " */
/* dhcp */
/* setexpr fileblks ${filesize} + 0x1ff */
/* setexpr fileblks ${fileblks} / 0x200 */
/* mmc dev 1 */
/* part start mmc 1 boot bootstart */
/* part size mmc 1 boot bootsize */
/* mmc erase ${bootstart} ${bootsize} */
/* mmc write ${fileaddr} ${bootstart} ${fileblks} */
/* "; */
ixbtn-devmode = "setenv dev_mode yes; echo Enabled";
ixbtn-factory = "echo \"No button available, use bootmenu\"";
};
};
};
/* &cp0_eth0 { */
/* phy-mode = "10gbase-r"; */
/* }; */
@@ -1,4 +1,6 @@
CONFIG_DEVICE_TREE_INCLUDES="infix-env.dtsi infix-key.dtsi cn9130-crb-env.dtsi"
CONFIG_SYS_PROMPT="(cn9130-crb) "
CONFIG_ENV_IS_NOWHERE=y
# CONFIG_ENV_IS_IN_MMC is not set
CONFIG_MVEBU_SPI_BOOT=y
+1 -4
View File
@@ -14,10 +14,6 @@
#include "alder-mpp.h"
&ap_crit {
temperature = <115000>;
};
/ {
model = "Alder";
compatible = "alder,alder",
@@ -358,6 +354,7 @@
#define XSWP(_n, _label, _mac_offs, _phy) \
port@_n { \
SWP_COMMON(_n, _label, _mac_offs, "usxgmii", _phy); \
managed = "in-band-status"; \
}
#define GSWP(_n, _label, _mac_offs, _phy) \
@@ -0,0 +1,69 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright (C) 2020 Marvell International Ltd.
*/
#include "cn9130-crb.dtsi"
/ {
model = "Marvell Armada CN9130-CRB-A";
chosen {
infix {
/* "admin" */
factory-password-hash = "$5$mI/zpOAqZYKLC2WU$i7iPzZiIjOjrBF3NyftS9CCq8dfYwHwrmUK097Jca9A";
usb-ports = <&cp0_usb3_1>;
usb-port-names = "USB";
};
};
};
&cp0_pcie0 {
status = "okay";
num-lanes = <4>;
num-viewport = <8>;
/* Generic PHY, providing serdes lanes */
phys = <&cp0_comphy0 0
&cp0_comphy1 0
&cp0_comphy2 0
&cp0_comphy3 0>;
iommu-map =
<0x0 &smmu 0x480 0x20>,
<0x100 &smmu 0x4a0 0x20>,
<0x200 &smmu 0x4c0 0x20>;
iommu-map-mask = <0x031f>;
};
&cp0_usb3_0 {
status = "okay";
usb-phy = <&cp0_usb3_0_phy0>;
phy-names = "usb";
};
&cp0_usb3_1 {
status = "okay";
usb-phy = <&cp0_usb3_0_phy1>;
phy-names = "usb";
};
&cp0_eth2 {
status = "okay";
phy-mode = "2500base-x";
};
&cp0_pinctrl {
cp0_expander0_pins: cp0-expander-pins-0 {
marvell,pins = "mpp39";
marvell,function = "gpio";
};
};
&expander0 {
pinctrl-names = "default";
pinctrl-0 = <&cp0_expander0_pins>;
interrupt-parent = <&cp0_gpio2>;
interrupts = <7 IRQ_TYPE_LEVEL_LOW>;
interrupt-controller;
#interrupt-cells=<2>;
microchip,irq-mirror;
};
+6
View File
@@ -175,9 +175,15 @@ CONFIG_VLAN_8021Q=y
CONFIG_VLAN_8021Q_GVRP=y
CONFIG_VLAN_8021Q_MVRP=y
CONFIG_NET_SCHED=y
CONFIG_NET_SCH_MQPRIO=y
CONFIG_NET_CLS_BASIC=y
CONFIG_NET_CLS_BPF=y
CONFIG_NET_CLS_FLOWER=y
CONFIG_NET_CLS_ACT=y
CONFIG_NET_ACT_GACT=y
CONFIG_NET_ACT_MIRRED=y
CONFIG_NET_ACT_SKBEDIT=y
CONFIG_DCB=y
CONFIG_NETLINK_DIAG=y
CONFIG_MPLS=y
CONFIG_NET_MPLS_GSO=y
+64
View File
@@ -0,0 +1,64 @@
Microchip SparX-5i PCB135 (eMMC)
================================
At present, only FIT images are supported via the SparX-5i eval
board's U-Boot, which must contain a valid load address. If you are
using this board, after selecting your base configuration, run the
following command to supplement the existing config with the required
FIT options:
make board-enable-sparx-fit
## Unbricking
1. Don't load a corrupt bootloader to begin with
2. Done
If, for some reason, you didn't manage to follow step 1, you can use
the `FLASH_PROG`(`J4`) connector on the board to access the SPI flash
directly.
Using a [Bus Blaster][BB3] in combination with [dangerspi][dangerspi],
you can load a new bootloader. The schematic below details how to
connect the Bus Blaster to the board, but the concept should be
portable to any debugger/device based around an FTDI2232 chip.
```
Bus Blaster: FLASH_PROG (J4):
.---. .---.
VTG >o o| VTG SCK >o o| GND
TRST |o o| GND MISO |o o| #RESET_FLASH
TDI |o o| GND o o| 3V3
TMS |o o| GND #CS |o o| #SYSRESET
TCK o o| GND MOSI |o o| GND
RTCK o o| GND '---'
TDO |o o| GND
TSRST |o o| GND
DBGRQ |o o| GND
DBGACK |o o| GND
'---'
```
| Bus Blaster | FLASH_PROG |
|-------------|----------------|
| `VTG` | `3V3` |
| `GND` | `GND` |
| | |
| `VTG` | `#RESET_FLASH` |
| `GND` | `#SYSRESET` |
| | |
| `TDI` | `MOSI` |
| `TMS` | `#CS` |
| `TCK` | `SCK` |
| `TDO` | `MISO` |
With the cable in place, build U-Boot with the correct configuration:
make fireant_boot_defconfig && make
To flash it to the board, connect the cable to `J4` and run:
make board-sparx-flash-uboot
[BB3]: http://dangerousprototypes.com/docs/Bus_Blaster#Bus_Blaster_v3
[dangerspi]: https://github.com/wkz/dangerspi
+21 -2
View File
@@ -18,7 +18,27 @@ endchoice
config SIGN_KEY
string "Signing key"
depends on SIGN_ENABLED
default "${BR2_EXTERNAL_INFIX_PATH}/board/common/dev-key" if SIGN_SRC_DIR
default "${BR2_EXTERNAL_INFIX_PATH}/board/common/signing-keys/development" if SIGN_SRC_DIR
menuconfig TRUSTED_KEYS
bool "Trusted keys for image"
depends on SIGN_ENABLED
help
Keys that will be accepted for this image
config TRUSTED_KEYS_DEVELOPMENT
bool "Development key"
depends on TRUSTED_KEYS
config TRUSTED_KEYS_DEVELOPMENT_PATH
string
depends on TRUSTED_KEYS_DEVELOPMENT
default "${BR2_EXTERNAL_INFIX_PATH}/board/common/signing-keys/development/infix.crt"
config TRUSTED_KEYS_EXTRA_PATH
string "Path to extra keys to include in image"
depends on TRUSTED_KEYS
menuconfig DISK_IMAGE
bool "Disk image"
@@ -140,4 +160,3 @@ config FIT_ARCH
config FIT_KERNEL_LOAD_ADDR
string "Kernel load address"
depends on FIT_IMAGE
+3 -1
View File
@@ -1,11 +1,13 @@
ifeq ($(SIGN_ENABLED),y)
include $(BR2_EXTERNAL_INFIX_PATH)/board/common/uboot/uboot.mk
TRUSTED_KEYS=$(TRUSTED_KEYS_DEVELOPMENT_PATH) $(TRUSTED_KEYS_EXTRA_PATH)
define RAUC_POST_BUILD_INSTALL_CERT
@$(call IXMSG,"Installing signing cert for RAUC")
mkdir -p $(TARGET_DIR)/etc/rauc/keys
$(foreach crt,$(shell ls $(SIGN_KEY)/*.crt), \
$(foreach crt,$(shell ls $(TRUSTED_KEYS)), \
cp $(crt) $(TARGET_DIR)/etc/rauc/keys/$(shell openssl x509 -hash -noout <$(crt)).0;)
endef
RAUC_POST_BUILD_HOOKS += RAUC_POST_BUILD_INSTALL_CERT
endif
+3
View File
@@ -44,16 +44,19 @@ image @DISKIMG@ {
partition aux {
offset = @AUXOFFS@
image = "aux.ext4"
partition-uuid = @AUXUUID@
}
partition primary {
image = "rootfs.squashfs"
size = @IMGSIZE@
partition-uuid = @PRIMARYUUID@
}
partition secondary {
image = "rootfs.squashfs"
size = @IMGSIZE@
partition-uuid = @SECONDARYUUID@
}
partition cfg {
+9 -1
View File
@@ -1,7 +1,8 @@
#!/bin/sh
set -e
. $BR2_EXTERNAL_INFIX_PATH/board/common/rootfs/etc/partition-uuid
K=10
M=20
G=30
@@ -157,6 +158,9 @@ genboot
# Use awk over sed because replacement text may contain newlines,
# which sed does not approve of.
awk \
-vauxuuid=$AUX_UUID \
-vprimaryuuid=$PRIMARY_UUID \
-vsecondaryuuid=$SECONDARY_UUID \
-vtotal=$total \
-vauxsize=$auxsize -vauxoffs=$auxoffs \
-vimgsize=$imgsize \
@@ -174,6 +178,10 @@ awk \
sub(/@DISKIMG@/, diskimg);
sub(/@BOOTIMG@/, bootimg);
sub(/@BOOTPART@/, bootpart);
sub(/@AUXUUID@/, auxuuid);
sub(/@PRIMARYUUID@/, primaryuuid);
sub(/@SECONDARYUUID@/, secondaryuuid);
}1' \
< $common/genimage.cfg.in >$root/genimage.cfg
+36
View File
@@ -4,6 +4,37 @@ common=$(dirname "$(readlink -f "$0")")
. "$BR2_CONFIG" 2>/dev/null
. "$TARGET_DIR/usr/lib/os-release"
# Extract list of loaded YANG modules and their features for yangdoc.html
mkyangdoc()
{
cmd="yangdoc -o $1 -p $TARGET_DIR/usr/share/yang"
# shellcheck disable=SC2155
export SYSREPO_SHM_PREFIX="yangdoc"
while IFS= read -r line; do
if echo "$line" | grep -q '^[a-z]'; then
module=$(echo "$line" | awk '{print $1}')
cmd="$cmd -m $module"
feature=$(echo "$line" | awk -F'|' '{print $8}' | sed 's/^ *//;s/ *$//')
if [ -n "$feature" ]; then
feature_list=$(echo "$feature" | tr ' ' '\n')
for feat in $feature_list; do
cmd="$cmd -e $feat"
done
fi
fi
done <<EOF
$(sysrepoctl -l; rm -f /dev/shm/${SYSREPO_SHM_PREFIX}*)
EOF
# Ignore a few top-level oddballs not used by core Infix
cmd="$cmd -x supported-algorithms"
# Execute the command
echo "Calling: $cmd"
$cmd
}
if [ -n "${ID_LIKE}" ]; then
ID="${ID} ${ID_LIKE}"
fi
@@ -85,3 +116,8 @@ grep -qsE '^/bin/false$$' "$TARGET_DIR/etc/shells" \
# Allow clish (symlink to /usr/bin/klish) to be a login shell
grep -qsE '^/bin/clish$$' "$TARGET_DIR/etc/shells" \
|| echo "/bin/clish" >> "$TARGET_DIR/etc/shells"
# Create YANG documentation
if [ "$BR2_PACKAGE_HOST_PYTHON_YANGDOC" = "y" ]; then
mkyangdoc "$BINARIES_DIR/yangdoc.html"
fi
+5 -4
View File
@@ -54,11 +54,10 @@ choice
config QEMU_CONSOLE_VIRTIO
bool "Virtio (hvc0)"
depends on QEMU_LOADER_KERNEL
config QEMU_CONSOLE_SERIAL
bool "Serial (ttyS0/ttyAMA0)"
depends on !QEMU_LOADER_OVMF
endchoice
config QEMU_MACHINE
@@ -109,10 +108,12 @@ config QEMU_RW
default "cfg.ext4"
config QEMU_RW_VAR_OPT
bool "Separate writable /var (256MB)"
bool "Separate writable /var"
if QEMU_RW_VAR_OPT
config QEMU_RW_VAR_SIZE
string "Size of /var"
default "256M"
config QEMU_RW_VAR
string "Writable /var layer"
default "var.ext4"
+29 -13
View File
@@ -117,7 +117,7 @@ rootfs_args()
echo -n "-device sd-card,drive=mmc "
echo -n "-drive id=mmc,file=$CONFIG_QEMU_ROOTFS,if=none,format=raw "
elif [ "$CONFIG_QEMU_ROOTFS_VSCSI" = "y" ]; then
echo -n "-drive file=$CONFIG_QEMU_ROOTFS,if=virtio,format=raw,bus=0,unit=0 "
echo -n "-drive file=$CONFIG_QEMU_ROOTFS.qcow2,if=virtio,format=qcow2,bus=0,unit=0 "
fi
}
@@ -148,14 +148,20 @@ usb_args()
dd if=/dev/zero of=${USBSTICK} bs=8M count=1 >/dev/null 2>&1
mkfs.vfat $USBSTICK >/dev/null 2>&1
fi
echo -n "-drive if=none,id=usbstick,format=raw,file=${USBSTICK} "
echo -n "-drive if=none,id=usbstick,format=raw,file=$USBSTICK "
echo -n "-usb "
echo -n "-device usb-ehci,id=ehci "
echo -n "-device usb-storage,bus=ehci.0,drive=usbstick "
}
rw_args()
{
[ "$CONFIG_QEMU_RW" ] || return
[ "$CONFIG_QEMU_RW" ] || return
if ! [ -f "aux.ext4" ]; then
dd if=/dev/zero of="aux.ext4" bs=1M count=1 >/dev/null 2>&1
mkfs.ext4 -L aux "aux.ext4" >/dev/null 2>&1
fi
echo -n "-drive file=aux.ext4,if=virtio,format=raw,bus=0,unit=3 "
if ! [ -f "$CONFIG_QEMU_RW" ]; then
dd if=/dev/zero of="$CONFIG_QEMU_RW" bs=16M count=1 >/dev/null 2>&1
@@ -166,7 +172,7 @@ rw_args()
if [ "$CONFIG_QEMU_RW_VAR_OPT" ]; then
if ! [ -f "$CONFIG_QEMU_RW_VAR" ]; then
dd if=/dev/zero of="$CONFIG_QEMU_RW_VAR" bs=256M count=1 >/dev/null 2>&1
dd if=/dev/zero of="$CONFIG_QEMU_RW_VAR" bs=$CONFIG_QEMU_RW_VAR_SIZE count=1 >/dev/null 2>&1
mkfs.ext4 -L var "$CONFIG_QEMU_RW_VAR" >/dev/null 2>&1
fi
@@ -198,10 +204,10 @@ net_args()
echo -n "-fw_cfg name=opt/mactab,file=$mactab "
if [ "$CONFIG_QEMU_NET_BRIDGE" = "y" ]; then
echo -n "-netdev bridge,id=e0,br=$CONFIG_QEMU_NET_BRIDGE_DEV "
net_dev_args 0
echo -n "-netdev bridge,id=e1,br=$CONFIG_QEMU_NET_BRIDGE_DEV "
net_dev_args 1
elif [ "$CONFIG_QEMU_NET_TAP" = "y" ]; then
for i in $(seq 0 $(($CONFIG_QEMU_NET_TAP_N - 1))); do
for i in $(seq 1 $(($CONFIG_QEMU_NET_TAP_N))); do
echo -n "-netdev tap,id=e$i,ifname=qtap$i "
net_dev_args $i
done
@@ -209,8 +215,8 @@ net_args()
local useropts=
[ "$CONFIG_QEMU_NET_USER_OPTS" ] && useropts=",$CONFIG_QEMU_NET_USER_OPTS"
echo -n "-netdev user,id=e0${useropts} "
net_dev_args 0
echo -n "-netdev user,id=e1${useropts} "
net_dev_args 1
else
echo -n "-nic none"
fi
@@ -249,8 +255,17 @@ wdt_args()
echo -n "-device i6300esb -rtc clock=host"
}
gdb_args()
{
echo -n "-chardev socket,id=gdbqemu,path=gdbqemu.sock,server=on,wait=off "
echo -n "-gdb chardev:gdbqemu"
}
run_qemu()
{
if [ "$CONFIG_QEMU_ROOTFS_VSCSI" = "y" ]; then
qemu-img create -f qcow2 -o backing_file=$CONFIG_QEMU_ROOTFS -F raw $CONFIG_QEMU_ROOTFS.qcow2 > /dev/null
fi
local qemu
read qemu <<EOF
$CONFIG_QEMU_MACHINE -m $CONFIG_QEMU_MACHINE_RAM \
@@ -263,6 +278,7 @@ run_qemu()
$(net_args) \
$(wdt_args) \
$(vpd_args) \
$(gdb_args) \
$CONFIG_QEMU_EXTRA
EOF
@@ -303,10 +319,10 @@ generate_dot()
{
[ "$CONFIG_QEMU_NET_TAP" = "y" ] || return
hostports="<qtap0> qtap0"
targetports="<e0> e0"
edges="host:qtap0 -- target:e0 [kind=mgmt];"
for tap in $(seq 1 $(($CONFIG_QEMU_NET_TAP_N - 1))); do
hostports="<qtap1> qtap1"
targetports="<e1> e1"
edges="host:qtap1 -- target:e1 [kind=mgmt];"
for tap in $(seq 2 $(($CONFIG_QEMU_NET_TAP_N - 1))); do
hostports="$hostports | <qtap$tap> qtap$tap "
targetports="$targetports | <e$tap> e$tap "
edges="$edges host:qtap$tap -- target:e$tap;"
-67
View File
@@ -1,67 +0,0 @@
#!/usr/bin/env python3
# Generate a self signed certificate with unlimited expire time
import argparse
from cryptography import x509
from cryptography.x509.oid import NameOID
from cryptography.hazmat.primitives import hashes, serialization
from cryptography.hazmat.primitives.asymmetric import rsa
from cryptography.hazmat.backends import default_backend
from datetime import datetime, timedelta
# Generate private key
private_key = rsa.generate_private_key(
public_exponent=65537,
key_size=2048,
backend=default_backend()
)
parser = argparse.ArgumentParser(description="Generate a self signed certificate")
parser.add_argument('--country', required=True, help="Set country")
parser.add_argument('--state', required=True, help="Set state or province name")
parser.add_argument('--city', required=True, help="Set city name")
parser.add_argument('--organisation', required=True, help="Set organisation name")
parser.add_argument('--organisation-unit', required=True, help="Set organisation unit name")
parser.add_argument('--common-name', required=True, help="Set common name")
parser.add_argument('--out-certificate', required=True, help="Output certificate")
parser.add_argument('--out-key', required=True, help="Output key")
args = parser.parse_args()
# Builder for certificate
subject = issuer = x509.Name([
x509.NameAttribute(NameOID.COUNTRY_NAME, args.country),
x509.NameAttribute(NameOID.STATE_OR_PROVINCE_NAME, args.state),
x509.NameAttribute(NameOID.LOCALITY_NAME, args.city),
x509.NameAttribute(NameOID.ORGANIZATION_NAME, args.organisation),
x509.NameAttribute(NameOID.ORGANIZATIONAL_UNIT_NAME, args.organisation_unit),
x509.NameAttribute(NameOID.COMMON_NAME, args.common_name),
])
certificate = x509.CertificateBuilder().subject_name(
subject
).issuer_name(
issuer
).public_key(
private_key.public_key()
).serial_number(
x509.random_serial_number()
).not_valid_before(
datetime(2000, 1, 1)
).not_valid_after(
datetime(9999, 1, 1)
).add_extension(
x509.SubjectAlternativeName([x509.DNSName(args.common_name)]),
critical=False,
).sign(private_key, hashes.SHA256(), default_backend())
# Serialize certificate and private key
with open(args.out_certificate, "wb") as f:
f.write(certificate.public_bytes(serialization.Encoding.PEM))
with open(args.out_key, "wb") as f:
f.write(private_key.private_bytes(
encoding=serialization.Encoding.PEM,
format=serialization.PrivateFormat.PKCS8,
encryption_algorithm=serialization.NoEncryption()
))
-5
View File
@@ -1,5 +0,0 @@
#!/bin/sh
sleep 30
stress-ng --cpu 8 --io 4 --vm 2 --vm-bytes 128M --fork 4 -t 0
-76
View File
@@ -1,76 +0,0 @@
#!/bin/sh
tstamp()
{
if [ "$1" = "head" ]; then
printf '%9s' time
else
printf '%9s' $(date +%T)
fi
}
thermal()
{
for th in /sys/class/thermal/thermal_zone*; do
if [ "$1" = "head" ]; then
printf '%5s' $(cat $th/type | \
sed -e 's/-thermal//' -e 's/ap-cpu/cpu/' -e 's/-ic//')
else
printf '%5d' \
$((($(cat $th/temp) + 500) / 1000))
fi
done
}
hwmon()
{
for hw in /sys/class/hwmon/*; do
[ -f $hw/temp1_input ] || continue
if [ "$1" = "head" ]; then
printf '%5s' \
$(cat $hw/name | sed -e 's/cp0configspacef2000000mdio12a200switch0mdio0/p/' -e 's/f212a600mdiomii0/xp/')
else
printf '%5d' \
$((($(cat $hw/temp1_input) + 500) / 1000))
fi
done
}
xphys()
{
for xphy in 4 5; do
mdio f212a6* $xphy:31 0xf08a 0x4d00
if [ "$1" = "head" ]; then
printf '%5s' \
p$((xphy + 5))
else
printf '%5d' \
$(($(mdio f212a6* $xphy:31 0xf08a) & 0xff - 75))
fi
done
}
if [ "$1" != "-H" ]; then
# tstamp head
thermal head
hwmon head
# xphys head
echo
fi
while :; do
# tstamp
thermal
hwmon
# xphys
echo
if [ "$1" == "-n" ]; then
sleep ${2:-10}
else
break
fi
done
@@ -1,3 +1 @@
run [S] log:console /libexec/infix/probe -- Probing system information
run [S] <pid/syslogd> /libexec/infix/sysctl-sync-ip-conf --
run [S] <pid/syslogd> /libexec/infix/nameif -- Probing network interfaces
task name:ixinit log:tag:ixinit [S] <pid/syslogd> /libexec/finit/runparts -bp /libexec/infix/init.d -- Probing system
@@ -1,4 +1,4 @@
service :%i pid:!/run/k8s-logger-%i.pid <usr/container:%i> \
[2345] k8s-logger -cni %i -f local1 /run/containers/%i.fifo -- Logger for container %i
sysv :%i pid:!/run/container:%i.pid <pid/k8s-logger:%i> kill:10 \
sysv :%i pid:!/run/container:%i.pid <pid/k8s-logger:%i> log kill:10 \
[2345] container -n %i -- container %i
@@ -0,0 +1,3 @@
service name:rousette notify:none log <pid/confd> \
[12345] rousette --syslog -t 60 \
-- RESTCONF server
@@ -1,3 +0,0 @@
service [2345789] log:/var/log/temp.log /bin/temp.sh -n 10 -- Temperature monitor
service [2345789] log:/var/log/load.log /bin/load.sh -- CPU load generator
service [2345789] log:/var/log/memtester.log /usr/bin/memtester 1G -- Memory load generator
@@ -1 +0,0 @@
../available/temp.conf
+1 -1
View File
@@ -19,4 +19,4 @@ LABEL=aux /mnt/aux auto noatime,nodiratime,noauto 0 0
LABEL=var /mnt/var auto noatime,nodiratime,noauto 0 0
LABEL=cfg /mnt/cfg auto noatime,nodiratime,noauto 0 0
hostfs /mnt/host 9p cache=none,msize=16384,noauto 0 0
/libexec/infix/mnt# /cfg helper none 0 0
/libexec/infix/mnt# /cfg helper none 0 0
@@ -1,3 +1,7 @@
0 unspec
1 kernel_lo
2 kernel_ra
3 kernel_ll
4 static
5 dhcp
6 random
@@ -0,0 +1 @@
configure ports dsa0 lldp status disabled
@@ -24,4 +24,6 @@ server {
root html;
index index.html index.htm;
}
include /etc/nginx/app/*.conf;
}
@@ -5,14 +5,6 @@ server {
include ssl.conf;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect off;
include /etc/nginx/netbrowse.conf;
}
}
@@ -0,0 +1,6 @@
location /netbrowse/ {
return 301 /netbrowse;
}
location /netbrowse {
include /etc/nginx/netbrowse.conf;
}
@@ -0,0 +1,9 @@
proxy_pass http://127.0.0.1:8000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect off;
@@ -0,0 +1,8 @@
# /telemetry/optics is for streaming (not used atm)
location ~ ^/(restconf|yang|.well-known)/ {
grpc_pass grpc://[::1]:10080;
grpc_set_header Host $host;
grpc_set_header X-Real-IP $remote_addr;
grpc_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
grpc_set_header X-Forwarded-Proto $scheme;
}
@@ -0,0 +1,20 @@
#%PAM-1.0
auth requisite pam_nologin.so
auth [success=1 default=ignore] pam_unix.so nullok
auth requisite pam_deny.so
auth required pam_permit.so
account requisite pam_nologin.so
account [success=1 default=ignore] pam_unix.so
account requisite pam_deny.so
account required pam_permit.so
password [success=1 default=ignore] pam_unix.so
password requisite pam_deny.so
password required pam_permit.so
session required pam_loginuid.so
session include common-session
session optional pam_keyinit.so force revoke
session optional pam_lastlog.so showfailed
session optional pam_motd.so
+20
View File
@@ -0,0 +1,20 @@
#%PAM-1.0
auth requisite pam_nologin.so
auth [success=1 default=ignore] pam_unix.so nullok
auth requisite pam_deny.so
auth required pam_permit.so
account requisite pam_nologin.so
account [success=1 default=ignore] pam_unix.so
account requisite pam_deny.so
account required pam_permit.so
password [success=1 default=ignore] pam_unix.so
password requisite pam_deny.so
password required pam_permit.so
session required pam_loginuid.so
session include common-session
session optional pam_keyinit.so force revoke
session optional pam_lastlog.so showfailed
session optional pam_motd.so
+3
View File
@@ -0,0 +1,3 @@
AUX_UUID="78460f84-de84-4fe7-89bd-4c1f433b2230"
PRIMARY_UUID="107ae911-a97b-4380-975c-7ce1a2dde1e0"
SECONDARY_UUID="352bd9b2-2ca9-44e2-bdc7-edbc87ba1e02"
@@ -0,0 +1 @@
UsePAM yes
@@ -1,2 +1,3 @@
net.ipv4.ip_forward=1
net.ipv4.ip_forward_update_priority=0
net.ipv6.conf.all.forwarding=1
@@ -0,0 +1,10 @@
Reserved facilities for logging in various subsystems:
- local0: rauc
- local1: containers
- local2:
- local3:
- local5:
- local6: reserved
- local7: nginx
@@ -3,12 +3,13 @@
import importlib.machinery
import json
import os
import shutil
import struct
import subprocess
import sys
onieprom = importlib.machinery.SourceFileLoader("onieprom","/bin/onieprom").load_module()
SYSTEM_JSON = "/run/system.json"
KKIT_IANA_PEM = 61046
class DTSystem:
@@ -233,8 +234,36 @@ def vpd_inject(out, vpds):
out["factory-password-hash"] = pwhash
break
def qemu_base_mac():
"""Find MAC address of first non-loopback interface, subtract with 1"""
base_path = '/sys/class/net'
interfaces = []
for iface in os.listdir(base_path):
if iface == 'lo':
continue
try:
# pylint: disable=invalid-name
with open(os.path.join(base_path, iface, 'address'), 'r', encoding='ascii') as f:
mac = f.read().strip()
interfaces.append((mac, iface))
except FileNotFoundError:
continue
if interfaces:
interfaces.sort()
mac = interfaces[0][0]
mac = int(mac.replace(':', ''), 16)
mac -= 1
mac %= 1 << 48
mac = ':'.join(f"{(mac >> 8 * i) & 0xff:02x}" for i in range(5, -1, -1))
return mac
return None
def probe_qemusystem(out):
ADMINHASH = "$5$mI/zpOAqZYKLC2WU$i7iPzZiIjOjrBF3NyftS9CCq8dfYwHwrmUK097Jca9A"
"""Probe Qemu based test systems and 'make run'"""
admin_hash = "$5$mI/zpOAqZYKLC2WU$i7iPzZiIjOjrBF3NyftS9CCq8dfYwHwrmUK097Jca9A"
qsys = QEMUSystem()
vpds = qsys.vpds()
@@ -244,6 +273,7 @@ def probe_qemusystem(out):
for (attr, default) in (
("vendor", "QEMU"),
("product-name", "VM"),
("mac-address", qemu_base_mac()),
):
if not out[attr]:
out[attr] = default
@@ -252,13 +282,14 @@ def probe_qemusystem(out):
not out["vpd"]["product"]["available"]:
# Virtual instance without VPD emulation, fallback to
# admin/admin
out["factory-password-hash"] = ADMINHASH
out["factory-password-hash"] = admin_hash
# Let others react to the fact that we are running in QEMU
subprocess.run("initctl -nbq cond set qemu".split())
subprocess.run("initctl -nbq cond set qemu".split(), check=False)
return 0
def probe_dtsystem(out):
"""Probe DTS based system, expects a VPD in ONIE PROM format."""
dtsys = DTSystem()
vpds = dtsys.infix_vpds()
dtsys.infix_usb_devices(out)
@@ -296,11 +327,15 @@ def main():
return err
if not out["factory-password-hash"]:
sys.stdout.write("\n\n\033[31mCRITICAL BOOTSTRAP ERROR\nNO FACTORY PASSWORD FOUND\033[0m\n\n")
sys.stdout.write("\n\n\033[31mCRITICAL BOOTSTRAP ERROR\n" +
"NO FACTORY PASSWORD FOUND\033[0m\n\n")
err = 1
json.dump(out, open("/run/system.json", "w"))
os.chmod("/run/system.json", 0o444)
os.umask(0o337)
# pylint: disable=invalid-name
with open(SYSTEM_JSON, "w", encoding="ascii") as f:
json.dump(out, f)
shutil.chown(SYSTEM_JSON, user="root", group="wheel")
return err
if __name__ == "__main__":
+22
View File
@@ -0,0 +1,22 @@
#!/bin/sh
# Find and install any product specific files in /etc before bootstrap
ident=$(basename "$0")
PREFIXD=/usr/share/product
PRODUCT=$(jq -r '."product-name" | ascii_downcase' /run/system.json)
note()
{
logger -k -p user.notice -t "$ident" "$1"
}
DIR="$PREFIXD/$PRODUCT"
if [ -z "$PRODUCT" ] || [ ! -d "$DIR" ]; then
note "No vendor/product specific directory found, using built-in defaults."
exit 0
fi
note "Using vendor/product specific defaults."
for dir in "$DIR"/*; do
[ -d "$dir" ] && cp -a "$dir" /
done
@@ -10,8 +10,7 @@ sysctl net.ipv4.conf.default >$tmp
sysctl net.ipv6.conf.default >>$tmp
for iface in $(ip -j link show | jq -r .[].ifname); do
sed -e "s/.default./.${iface}./g" $tmp | sysctl -p -
sed -e "s/.default./.${iface}./g" $tmp | sysctl -q -p -
done
rm $tmp
+52
View File
@@ -0,0 +1,52 @@
#!/bin/sh
# Opportunistically look for interfaces with multiple transmit queues
# and hardware support for the mqprio queuing discipline. For every
# matching interface, set up mappings from kernel-internal packet
# priorities, via traffic classes, to transmit queues such that as
# many high priorities as possible are scheduled on separate queues.
set -e
map()
{
case "$1" in
2)
echo "map 0 0 0 0 0 0 1 1";;
3)
echo "map 0 0 0 0 1 1 2 2";;
4)
echo "map 0 0 1 1 2 2 3 3";;
5)
echo "map 0 0 1 1 2 2 3 4";;
6)
echo "map 0 0 1 1 2 3 4 5";;
7)
echo "map 0 0 1 2 3 4 5 6";;
8)
echo "map 0 1 2 3 4 5 6 7";;
esac
}
queues()
{
out="queues "
for tc in $(seq 0 $(($1 - 1))); do
out="$out 1@$tc"
done
echo "$out"
}
set $(ip -j -d link show | jq -r '.[] | .ifname, .num_tx_queues')
while [ "$1" ]; do
iface="$1"
txqs="$2"
shift 2
[ $txqs -lt 2 ] && continue
[ $txqs -gt 8 ] && txqs=8
tc qdisc add dev $iface root mqprio hw 1 \
num_tc $txqs $(map $txqs) $(queues $txqs) || true
done
+102
View File
@@ -0,0 +1,102 @@
#!/bin/sh
# Run .cfg migration jq scripts to backup and transform older .cfg files
ident=$(basename "$0")
MIGRATIONS_DIR="/usr/share/confd/migrate"
CONFIG_FILE="/cfg/startup-config.cfg"
BACKUP_DIR="/cfg/backup"
note()
{
logger -k -p user.notice -t "$ident" "$1"
}
err()
{
logger -k -p user.err -t "$ident" "$1"
}
file_version()
{
jq -r '
if .["infix-meta:meta"] | has("version") then
.["infix-meta:meta"]["version"]
else
"0.0"
end
' "$1"
}
atoi()
{
echo "$1" | awk -F. '{print $1 * 1000 + $2}'
}
if [ ! -f "$CONFIG_FILE" ]; then
# Nothing to migrate
note "No $(basename "$CONFIG_FILE" .cfg) yet, likely factory reset."
exit 0
fi
cfg_version=$(file_version "$CONFIG_FILE")
current_version=$(atoi "$cfg_version")
# Find the latest version by examining the highest numbered directory
sys_version=$(find "$MIGRATIONS_DIR" -mindepth 1 -maxdepth 1 -type d | sort -V | tail -n1 | xargs -n1 basename)
latest_version=$(atoi "$sys_version")
# Check for downgrade
if [ "$current_version" -gt "$latest_version" ]; then
err "Configuration file $CONFIG_FILE version ($cfg_version) is newer than the latest supported version ($sys_version). Exiting."
exit 1
fi
# If the current version is already the latest, exit the script
if [ "$current_version" -eq "$latest_version" ]; then
note "Configuration is already at the latest version ($sys_version). No migration needed."
exit 0
fi
note "Configuration file $CONFIG_FILE is of version $cfg_version, migrating ..."
# Create the backup directory if it doesn't exist
mkdir -p "$BACKUP_DIR"
# Create a backup of the current configuration file
nm=$(basename "$CONFIG_FILE" .cfg)
BACKUP_FILE="$BACKUP_DIR/${nm}-${cfg_version}.cfg"
if cp "$CONFIG_FILE" "$BACKUP_FILE"; then
note "Backup created: $BACKUP_FILE"
else
err "Failed creating backup: $BACKUP_FILE"
exit 1
fi
# Apply the scripts for each version directory in sequence
for version_dir in $(find "$MIGRATIONS_DIR" -mindepth 1 -maxdepth 1 -type d | sort -V); do
dir=$(basename "$version_dir")
version=$(atoi "$dir")
# Step by step upgrade file to latest version
if [ "$current_version" -lt "$version" ]; then
note "Applying migrations for version $dir ..."
# Apply all scripts in the version directory in order
for script in $(find "$version_dir" -type f -name '*.sh' | sort -V); do
note "Calling $script for $CONFIG_FILE ..."
sh "$script" "$CONFIG_FILE"
done
# File now at $version ...
current_version="$version"
fi
done
# Update the JSON file to the latest version
if jq --arg version "$sys_version" '.["infix-meta:meta"]["infix-meta:version"] = $version' "$CONFIG_FILE" \
> "${CONFIG_FILE}.tmp" && mv "${CONFIG_FILE}.tmp" "$CONFIG_FILE"; then
note "Configuration updated to version $sys_version."
else
err "Failed updating configuration to version $sys_version!"
exit 1
fi
+2
View File
@@ -0,0 +1,2 @@
#!/bin/sh
exec initctl -bq cond set ixinit-done
+14
View File
@@ -0,0 +1,14 @@
#!/bin/sh
# Generate NETCONF SSH host key pair
set -e
BIT=2048
KEY=$1
PUB=$2
mkdir -p "$(dirname "$KEY")" "$(dirname "$PUB")"
openssl genpkey -quiet -algorithm RSA -pkeyopt rsa_keygen_bits:$BIT -outform PEM > "$KEY"
openssl rsa -RSAPublicKey_out < "$KEY" > "$PUB"
exit 0
+6 -5
View File
@@ -1,7 +1,8 @@
#!/bin/sh
set -e
. /etc/partition-uuid
disk=$1
bootoffs=$2
@@ -27,11 +28,11 @@ else
fi
sgdisk \
-o \
-Z \
-n1:${bootoffs}:+${bootsize} -t1:8301 -c1:boot \
-n2::+${auxsize} -t2:8301 -c2:aux \
-n3::+${imgsize} -t3:8300 -c3:primary \
-n4::+${imgsize} -t4:8300 -c4:secondary \
-n2::+${auxsize} -t2:8301 -c2:aux -u2:${AUX_UUID} \
-n3::+${imgsize} -t3:8300 -c3:primary -u3:${PRIMARY_UUID} \
-n4::+${imgsize} -t4:8300 -c4:secondary -u4:${SECONDARY_UUID} \
-n5::+${cfgsize} -t5:8302 -c5:cfg \
-n6:: -t6:8310 -c6:var \
-p \
+6 -1
View File
@@ -58,6 +58,7 @@ unpack_archive()
[ -n "$quiet" ] || log "Extracting OCI archive $file ..."
tar xf "$file" || (log "Error: failed unpacking $file in $(pwd)"; exit 1)
remove=true
fi
dir=$(dirname "$index")
@@ -72,6 +73,10 @@ unpack_archive()
name=$dir
fi
if [ "$remove" = "true" ]; then
rm -rf "$file"
fi
echo "$name"
}
@@ -575,7 +580,7 @@ case $cmd in
stop "$name"
timeout=20
while running "$name"; do
_=$((timeoute -= 1))
_=$((timeout -= 1))
if [ $timeout -le 0 ]; then
log "Timeout waiting for container $1 to stop before restarting it."
exit 1
@@ -119,7 +119,7 @@ case "$ACTION" in
if [ -n "$hostname" ]; then
log "setting new hostname: $hostname"
hostname "$hostname"
augtool -s "set /files/etc/hosts/*[ipaddr='127.0.1.1']/canonical $hostname"
sed -i -E "s/^(127\.0\.1\.1\s+).*/\1$hostname/" /etc/hosts
fi
# drop info from this interface
+9 -6
View File
@@ -7,16 +7,19 @@
&env {
vendor = "infix";
preboot = "run ixpreboot";
ixbootdelay = "0.5";
bootdelay = "-2";
bootcmd = "run ixbtn";
bootmenu_delay = "10";
boot_targets = "virtio mmc";
bootcmd = "run ixboot";
ixpreboot = /incbin/("scripts/ixpreboot.sh");
ixbtn-devmode = /incbin/("scripts/ixbtn-devmode.sh");
ixbtn-factory = /incbin/("scripts/ixbtn-factory.sh");
ixfactory = /incbin/("scripts/ixfactory.sh");
ixbtn = /incbin/("scripts/ixbtn.sh");
ixdevmode = /incbin/("scripts/ixdevmode.sh");
ixfactory = /incbin/("scripts/ixfactory.sh");
ixbtn = /incbin/("scripts/ixbtn.sh");
ixboot = /incbin/("scripts/ixboot.sh");
ixbootmedia = /incbin/("scripts/ixbootmedia.sh");
ixbootslot = /incbin/("scripts/ixbootslot.sh");
ixprepblk = /incbin/("scripts/ixprepblk.sh");
ixprepdhcp = /incbin/("scripts/ixprepdhcp.sh");
+10
View File
@@ -1,5 +1,6 @@
# CONFIG_OF_OMIT_DTB is not set
CONFIG_DEVICE_TREE_INCLUDES="infix-env.dtsi infix-key.dtsi"
CONFIG_SYS_PROMPT="(ixboot) "
CONFIG_ENV_IMPORT_FDT=y
@@ -16,6 +17,7 @@ CONFIG_DISTRO_DEFAULTS=y
CONFIG_CMD_SETEXPR=y
CONFIG_CMD_SETEXPR_FMT=y
CONFIG_MMC=y
CONFIG_MMC_SDHCI=y
CONFIG_MMC_PCI=y
@@ -24,3 +26,11 @@ CONFIG_CMD_MMC=y
CONFIG_FS_SQUASHFS=y
CONFIG_CMD_SQUASHFS=y
CONFIG_PROT_TCP=y
CONFIG_PROT_TCP_SACK=y
CONFIG_CMD_WGET=y
CONFIG_USE_PREBOOT=y
CONFIG_CMD_BOOTMENU=y
CONFIG_CMD_PAUSE=y
# CONFIG_CMD_BOOTEFI_BOOTMGR is not set
@@ -1,32 +0,0 @@
From 4aef55d1b8cc24187f12f83a2f4d9bfc41ba12ee Mon Sep 17 00:00:00 2001
From: Tobias Waldekranz <tobias@waldekranz.com>
Date: Mon, 30 Jan 2023 15:54:56 +0100
Subject: [PATCH v2 1/9] image: Fix script execution from FIT images with
external data
Update the script loading code to recognize when script data is stored
externally from the FIT metadata (i.e., built with `mkimage -E`).
Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
boot/image-board.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/boot/image-board.c b/boot/image-board.c
index 25b60ec30b..af693c9c08 100644
--- a/boot/image-board.c
+++ b/boot/image-board.c
@@ -1111,7 +1111,8 @@ fallback:
}
/* get script subimage data address and length */
- if (fit_image_get_data(fit_hdr, noffset, &fit_data, &fit_len)) {
+ if (fit_image_get_data_and_size(fit_hdr, noffset,
+ &fit_data, &fit_len)) {
puts("Could not find script subimage data\n");
return 1;
}
--
2.34.1
@@ -1,73 +0,0 @@
From 74f121de98a1614a4068960445b8355cb3e5fa04 Mon Sep 17 00:00:00 2001
From: Tobias Waldekranz <tobias@waldekranz.com>
Date: Tue, 24 Jan 2023 14:00:04 +0100
Subject: [PATCH v2 2/9] cmd: blk: Allow generic read/write operations to work
in sandbox
Ensure that the memory destination/source addresses of block
read/write operations are mapped in before access. Currently, this is
only needed on sandbox builds.
Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
cmd/blk_common.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/cmd/blk_common.c b/cmd/blk_common.c
index 75a072caf5..9f9d4327a9 100644
--- a/cmd/blk_common.c
+++ b/cmd/blk_common.c
@@ -11,6 +11,7 @@
#include <common.h>
#include <blk.h>
#include <command.h>
+#include <mapmem.h>
int blk_common_cmd(int argc, char *const argv[], enum uclass_id uclass_id,
int *cur_devnump)
@@ -63,31 +64,37 @@ int blk_common_cmd(int argc, char *const argv[], enum uclass_id uclass_id,
default: /* at least 4 args */
if (strcmp(argv[1], "read") == 0) {
- ulong addr = hextoul(argv[2], NULL);
+ phys_addr_t paddr = hextoul(argv[2], NULL);
lbaint_t blk = hextoul(argv[3], NULL);
ulong cnt = hextoul(argv[4], NULL);
+ void *vaddr;
ulong n;
printf("\n%s read: device %d block # "LBAFU", count %lu ... ",
if_name, *cur_devnump, blk, cnt);
+ vaddr = map_sysmem(paddr, 512 * cnt);
n = blk_read_devnum(uclass_id, *cur_devnump, blk, cnt,
- (ulong *)addr);
+ vaddr);
+ unmap_sysmem(vaddr);
printf("%ld blocks read: %s\n", n,
n == cnt ? "OK" : "ERROR");
return n == cnt ? 0 : 1;
} else if (strcmp(argv[1], "write") == 0) {
- ulong addr = hextoul(argv[2], NULL);
+ phys_addr_t paddr = hextoul(argv[2], NULL);
lbaint_t blk = hextoul(argv[3], NULL);
ulong cnt = hextoul(argv[4], NULL);
+ void *vaddr;
ulong n;
printf("\n%s write: device %d block # "LBAFU", count %lu ... ",
if_name, *cur_devnump, blk, cnt);
+ vaddr = map_sysmem(paddr, 512 * cnt);
n = blk_write_devnum(uclass_id, *cur_devnump, blk, cnt,
- (ulong *)addr);
+ vaddr);
+ unmap_sysmem(vaddr);
printf("%ld blocks written: %s\n", n,
n == cnt ? "OK" : "ERROR");
--
2.34.1
@@ -1,501 +0,0 @@
From 104a2ab39ac72c402d7463bec05aae4a6d09cfbf Mon Sep 17 00:00:00 2001
From: Tobias Waldekranz <tobias@waldekranz.com>
Date: Thu, 16 Feb 2023 15:06:12 +0100
Subject: [PATCH v2 3/9] blk: blkmap: Add basic infrastructure
blkmaps are loosely modeled on Linux's device mapper subsystem. The
basic idea is that you can create virtual block devices whose blocks
can be backed by a plethora of sources that are user configurable.
This change just adds the basic infrastructure for creating and
removing blkmap devices. Subsequent changes will extend this to add
support for actual mappings.
Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
---
MAINTAINERS | 6 +
drivers/block/Kconfig | 18 ++
drivers/block/Makefile | 1 +
drivers/block/blk-uclass.c | 1 +
drivers/block/blkmap.c | 343 +++++++++++++++++++++++++++++++++++++
include/blkmap.h | 35 ++++
include/dm/uclass-id.h | 1 +
7 files changed, 405 insertions(+)
create mode 100644 drivers/block/blkmap.c
create mode 100644 include/blkmap.h
diff --git a/MAINTAINERS b/MAINTAINERS
index 6f53f9c2f6..3e47c9b34c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -793,6 +793,12 @@ M: Alper Nebi Yasak <alpernebiyasak@gmail.com>
S: Maintained
F: tools/binman/
+BLKMAP
+M: Tobias Waldekranz <tobias@waldekranz.com>
+S: Maintained
+F: drivers/block/blkmap.c
+F: include/blkmap.h
+
BOOTDEVICE
M: Simon Glass <sjg@chromium.org>
S: Maintained
diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index e95da48bdc..5a1aeb3d2b 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -67,6 +67,24 @@ config BLOCK_CACHE
it will prevent repeated reads from directory structures and other
filesystem data structures.
+config BLKMAP
+ bool "Composable virtual block devices (blkmap)"
+ depends on BLK
+ help
+ Create virtual block devices that are backed by various sources,
+ e.g. RAM, or parts of an existing block device. Though much more
+ rudimentary, it borrows a lot of ideas from Linux's device mapper
+ subsystem.
+
+ Example use-cases:
+ - Treat a region of RAM as a block device, i.e. a RAM disk. This let's
+ you extract files from filesystem images stored in RAM (perhaps as a
+ result of a TFTP transfer).
+ - Create a virtual partition on an existing device. This let's you
+ access filesystems that aren't stored at an exact partition
+ boundary. A common example is a filesystem image embedded in an FIT
+ image.
+
config SPL_BLOCK_CACHE
bool "Use block device cache in SPL"
depends on SPL_BLK
diff --git a/drivers/block/Makefile b/drivers/block/Makefile
index f12447d78d..a161d145fd 100644
--- a/drivers/block/Makefile
+++ b/drivers/block/Makefile
@@ -14,6 +14,7 @@ obj-$(CONFIG_IDE) += ide.o
endif
obj-$(CONFIG_SANDBOX) += sandbox.o host-uclass.o host_dev.o
obj-$(CONFIG_$(SPL_TPL_)BLOCK_CACHE) += blkcache.o
+obj-$(CONFIG_BLKMAP) += blkmap.o
obj-$(CONFIG_EFI_MEDIA) += efi-media-uclass.o
obj-$(CONFIG_EFI_MEDIA_SANDBOX) += sb_efi_media.o
diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
index c69fc4d518..cb73faaeda 100644
--- a/drivers/block/blk-uclass.c
+++ b/drivers/block/blk-uclass.c
@@ -32,6 +32,7 @@ static struct {
{ UCLASS_EFI_LOADER, "efiloader" },
{ UCLASS_VIRTIO, "virtio" },
{ UCLASS_PVBLOCK, "pvblock" },
+ { UCLASS_BLKMAP, "blkmap" },
};
static enum uclass_id uclass_name_to_iftype(const char *uclass_idname)
diff --git a/drivers/block/blkmap.c b/drivers/block/blkmap.c
new file mode 100644
index 0000000000..acfc002ceb
--- /dev/null
+++ b/drivers/block/blkmap.c
@@ -0,0 +1,343 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2023 Addiva Elektronik
+ * Author: Tobias Waldekranz <tobias@waldekranz.com>
+ */
+
+#include <common.h>
+#include <blk.h>
+#include <blkmap.h>
+#include <dm.h>
+#include <malloc.h>
+#include <mapmem.h>
+#include <part.h>
+#include <dm/device-internal.h>
+#include <dm/lists.h>
+#include <dm/root.h>
+
+struct blkmap;
+
+/**
+ * struct blkmap_slice - Region mapped to a blkmap
+ *
+ * Common data for a region mapped to a blkmap, specialized by each
+ * map type.
+ *
+ * @node: List node used to associate this slice with a blkmap
+ * @blknr: Start block number of the mapping
+ * @blkcnt: Number of blocks covered by this mapping
+ */
+struct blkmap_slice {
+ struct list_head node;
+
+ lbaint_t blknr;
+ lbaint_t blkcnt;
+
+ /**
+ * @read: - Read from slice
+ *
+ * @read.bm: Blkmap to which this slice belongs
+ * @read.bms: This slice
+ * @read.blknr: Start block number to read from
+ * @read.blkcnt: Number of blocks to read
+ * @read.buffer: Buffer to store read data to
+ */
+ ulong (*read)(struct blkmap *bm, struct blkmap_slice *bms,
+ lbaint_t blknr, lbaint_t blkcnt, void *buffer);
+
+ /**
+ * @write: - Write to slice
+ *
+ * @write.bm: Blkmap to which this slice belongs
+ * @write.bms: This slice
+ * @write.blknr: Start block number to write to
+ * @write.blkcnt: Number of blocks to write
+ * @write.buffer: Data to be written
+ */
+ ulong (*write)(struct blkmap *bm, struct blkmap_slice *bms,
+ lbaint_t blknr, lbaint_t blkcnt, const void *buffer);
+
+ /**
+ * @destroy: - Tear down slice
+ *
+ * @read.bm: Blkmap to which this slice belongs
+ * @read.bms: This slice
+ */
+ void (*destroy)(struct blkmap *bm, struct blkmap_slice *bms);
+};
+
+/**
+ * struct blkmap - Block map
+ *
+ * Data associated with a blkmap.
+ *
+ * @label: Human readable name of this blkmap
+ * @blk: Underlying block device
+ * @slices: List of slices associated with this blkmap
+ */
+struct blkmap {
+ char *label;
+ struct udevice *blk;
+ struct list_head slices;
+};
+
+static bool blkmap_slice_contains(struct blkmap_slice *bms, lbaint_t blknr)
+{
+ return (blknr >= bms->blknr) && (blknr < (bms->blknr + bms->blkcnt));
+}
+
+static bool blkmap_slice_available(struct blkmap *bm, struct blkmap_slice *new)
+{
+ struct blkmap_slice *bms;
+ lbaint_t first, last;
+
+ first = new->blknr;
+ last = new->blknr + new->blkcnt - 1;
+
+ list_for_each_entry(bms, &bm->slices, node) {
+ if (blkmap_slice_contains(bms, first) ||
+ blkmap_slice_contains(bms, last) ||
+ blkmap_slice_contains(new, bms->blknr) ||
+ blkmap_slice_contains(new, bms->blknr + bms->blkcnt - 1))
+ return false;
+ }
+
+ return true;
+}
+
+static int blkmap_slice_add(struct blkmap *bm, struct blkmap_slice *new)
+{
+ struct blk_desc *bd = dev_get_uclass_plat(bm->blk);
+ struct list_head *insert = &bm->slices;
+ struct blkmap_slice *bms;
+
+ if (!blkmap_slice_available(bm, new))
+ return -EBUSY;
+
+ list_for_each_entry(bms, &bm->slices, node) {
+ if (bms->blknr < new->blknr)
+ continue;
+
+ insert = &bms->node;
+ break;
+ }
+
+ list_add_tail(&new->node, insert);
+
+ /* Disk might have grown, update the size */
+ bms = list_last_entry(&bm->slices, struct blkmap_slice, node);
+ bd->lba = bms->blknr + bms->blkcnt;
+ return 0;
+}
+
+static ulong blkmap_blk_read_slice(struct blkmap *bm, struct blkmap_slice *bms,
+ lbaint_t blknr, lbaint_t blkcnt,
+ void *buffer)
+{
+ lbaint_t nr, cnt;
+
+ nr = blknr - bms->blknr;
+ cnt = (blkcnt < bms->blkcnt) ? blkcnt : bms->blkcnt;
+ return bms->read(bm, bms, nr, cnt, buffer);
+}
+
+static ulong blkmap_blk_read(struct udevice *dev, lbaint_t blknr,
+ lbaint_t blkcnt, void *buffer)
+{
+ struct blk_desc *bd = dev_get_uclass_plat(dev);
+ struct blkmap *bm = dev_get_plat(dev->parent);
+ struct blkmap_slice *bms;
+ lbaint_t cnt, total = 0;
+
+ list_for_each_entry(bms, &bm->slices, node) {
+ if (!blkmap_slice_contains(bms, blknr))
+ continue;
+
+ cnt = blkmap_blk_read_slice(bm, bms, blknr, blkcnt, buffer);
+ blknr += cnt;
+ blkcnt -= cnt;
+ buffer += cnt << bd->log2blksz;
+ total += cnt;
+ }
+
+ return total;
+}
+
+static ulong blkmap_blk_write_slice(struct blkmap *bm, struct blkmap_slice *bms,
+ lbaint_t blknr, lbaint_t blkcnt,
+ const void *buffer)
+{
+ lbaint_t nr, cnt;
+
+ nr = blknr - bms->blknr;
+ cnt = (blkcnt < bms->blkcnt) ? blkcnt : bms->blkcnt;
+ return bms->write(bm, bms, nr, cnt, buffer);
+}
+
+static ulong blkmap_blk_write(struct udevice *dev, lbaint_t blknr,
+ lbaint_t blkcnt, const void *buffer)
+{
+ struct blk_desc *bd = dev_get_uclass_plat(dev);
+ struct blkmap *bm = dev_get_plat(dev->parent);
+ struct blkmap_slice *bms;
+ lbaint_t cnt, total = 0;
+
+ list_for_each_entry(bms, &bm->slices, node) {
+ if (!blkmap_slice_contains(bms, blknr))
+ continue;
+
+ cnt = blkmap_blk_write_slice(bm, bms, blknr, blkcnt, buffer);
+ blknr += cnt;
+ blkcnt -= cnt;
+ buffer += cnt << bd->log2blksz;
+ total += cnt;
+ }
+
+ return total;
+}
+
+static const struct blk_ops blkmap_blk_ops = {
+ .read = blkmap_blk_read,
+ .write = blkmap_blk_write,
+};
+
+U_BOOT_DRIVER(blkmap_blk) = {
+ .name = "blkmap_blk",
+ .id = UCLASS_BLK,
+ .ops = &blkmap_blk_ops,
+};
+
+int blkmap_dev_bind(struct udevice *dev)
+{
+ struct blkmap *bm = dev_get_plat(dev);
+ struct blk_desc *bd;
+ int err;
+
+ err = blk_create_devicef(dev, "blkmap_blk", "blk", UCLASS_BLKMAP,
+ dev_seq(dev), 512, 0, &bm->blk);
+ if (err)
+ return log_msg_ret("blk", err);
+
+ INIT_LIST_HEAD(&bm->slices);
+
+ bd = dev_get_uclass_plat(bm->blk);
+ snprintf(bd->vendor, BLK_VEN_SIZE, "U-Boot");
+ snprintf(bd->product, BLK_PRD_SIZE, "blkmap");
+ snprintf(bd->revision, BLK_REV_SIZE, "1.0");
+
+ /* EFI core isn't keen on zero-sized disks, so we lie. This is
+ * updated with the correct size once the user adds a
+ * mapping.
+ */
+ bd->lba = 1;
+
+ return 0;
+}
+
+int blkmap_dev_unbind(struct udevice *dev)
+{
+ struct blkmap *bm = dev_get_plat(dev);
+ struct blkmap_slice *bms, *tmp;
+ int err;
+
+ list_for_each_entry_safe(bms, tmp, &bm->slices, node) {
+ list_del(&bms->node);
+ free(bms);
+ }
+
+ err = device_remove(bm->blk, DM_REMOVE_NORMAL);
+ if (err)
+ return err;
+
+ return device_unbind(bm->blk);
+}
+
+U_BOOT_DRIVER(blkmap_root) = {
+ .name = "blkmap_dev",
+ .id = UCLASS_BLKMAP,
+ .bind = blkmap_dev_bind,
+ .unbind = blkmap_dev_unbind,
+ .plat_auto = sizeof(struct blkmap),
+};
+
+struct udevice *blkmap_from_label(const char *label)
+{
+ struct udevice *dev;
+ struct uclass *uc;
+ struct blkmap *bm;
+
+ uclass_id_foreach_dev(UCLASS_BLKMAP, dev, uc) {
+ bm = dev_get_plat(dev);
+ if (bm->label && !strcmp(label, bm->label))
+ return dev;
+ }
+
+ return NULL;
+}
+
+int blkmap_create(const char *label, struct udevice **devp)
+{
+ char *hname, *hlabel;
+ struct udevice *dev;
+ struct blkmap *bm;
+ size_t namelen;
+ int err;
+
+ dev = blkmap_from_label(label);
+ if (dev) {
+ err = -EBUSY;
+ goto err;
+ }
+
+ hlabel = strdup(label);
+ if (!hlabel) {
+ err = -ENOMEM;
+ goto err;
+ }
+
+ namelen = strlen("blkmap-") + strlen(label) + 1;
+ hname = malloc(namelen);
+ if (!hname) {
+ err = -ENOMEM;
+ goto err_free_hlabel;
+ }
+
+ strlcpy(hname, "blkmap-", namelen);
+ strlcat(hname, label, namelen);
+
+ err = device_bind_driver(dm_root(), "blkmap_dev", hname, &dev);
+ if (err)
+ goto err_free_hname;
+
+ device_set_name_alloced(dev);
+ bm = dev_get_plat(dev);
+ bm->label = hlabel;
+
+ if (devp)
+ *devp = dev;
+
+ return 0;
+
+err_free_hname:
+ free(hname);
+err_free_hlabel:
+ free(hlabel);
+err:
+ return err;
+}
+
+int blkmap_destroy(struct udevice *dev)
+{
+ int err;
+
+ err = device_remove(dev, DM_REMOVE_NORMAL);
+ if (err)
+ return err;
+
+ return device_unbind(dev);
+}
+
+UCLASS_DRIVER(blkmap) = {
+ .id = UCLASS_BLKMAP,
+ .name = "blkmap",
+};
diff --git a/include/blkmap.h b/include/blkmap.h
new file mode 100644
index 0000000000..3c7e36efab
--- /dev/null
+++ b/include/blkmap.h
@@ -0,0 +1,35 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2023 Addiva Elektronik
+ * Author: Tobias Waldekranz <tobias@waldekranz.com>
+ */
+
+#ifndef _BLKMAP_H
+#define _BLKMAP_H
+
+/**
+ * blkmap_from_label() - Find blkmap from label
+ *
+ * @label: Label of the requested blkmap
+ * Returns: A pointer to the blkmap on success, NULL on failure
+ */
+struct udevice *blkmap_from_label(const char *label);
+
+/**
+ * blkmap_create() - Create new blkmap
+ *
+ * @label: Label of the new blkmap
+ * @devp: If not NULL, updated with the address of the resulting device
+ * Returns: 0 on success, negative error code on failure
+ */
+int blkmap_create(const char *label, struct udevice **devp);
+
+/**
+ * blkmap_destroy() - Destroy blkmap
+ *
+ * @dev: The blkmap to be destroyed
+ * Returns: 0 on success, negative error code on failure
+ */
+int blkmap_destroy(struct udevice *dev);
+
+#endif /* _BLKMAP_H */
diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h
index 33e43c20db..576237b954 100644
--- a/include/dm/uclass-id.h
+++ b/include/dm/uclass-id.h
@@ -37,6 +37,7 @@ enum uclass_id {
UCLASS_AUDIO_CODEC, /* Audio codec with control and data path */
UCLASS_AXI, /* AXI bus */
UCLASS_BLK, /* Block device */
+ UCLASS_BLKMAP, /* Composable virtual block device */
UCLASS_BOOTCOUNT, /* Bootcount backing store */
UCLASS_BOOTDEV, /* Boot device for locating an OS to boot */
UCLASS_BOOTMETH, /* Bootmethod for booting an OS */
--
2.34.1
@@ -1,174 +0,0 @@
From 77fd2a74a5f7a14f42b5c7acd175a9c1519c4f16 Mon Sep 17 00:00:00 2001
From: Tobias Waldekranz <tobias@waldekranz.com>
Date: Thu, 16 Feb 2023 15:08:00 +0100
Subject: [PATCH v2 4/9] blk: blkmap: Add memory mapping support
Allow a slice of RAM to be mapped to a blkmap. This means that RAM can
now be accessed as if it was a block device, meaning that existing
filesystem drivers can now be used to access ramdisks.
Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
---
drivers/block/blkmap.c | 105 +++++++++++++++++++++++++++++++++++++++++
include/blkmap.h | 29 ++++++++++++
2 files changed, 134 insertions(+)
diff --git a/drivers/block/blkmap.c b/drivers/block/blkmap.c
index acfc002ceb..6d6eed889e 100644
--- a/drivers/block/blkmap.c
+++ b/drivers/block/blkmap.c
@@ -130,6 +130,111 @@ static int blkmap_slice_add(struct blkmap *bm, struct blkmap_slice *new)
return 0;
}
+/**
+ * struct blkmap_mem - Memory mapping
+ *
+ * @slice: Common map data
+ * @addr: Target memory region of this mapping
+ * @remapped: True if @addr is backed by a physical to virtual memory
+ * mapping that must be torn down at the end of this mapping's
+ * lifetime.
+ */
+struct blkmap_mem {
+ struct blkmap_slice slice;
+ void *addr;
+ bool remapped;
+};
+
+static ulong blkmap_mem_read(struct blkmap *bm, struct blkmap_slice *bms,
+ lbaint_t blknr, lbaint_t blkcnt, void *buffer)
+{
+ struct blkmap_mem *bmm = container_of(bms, struct blkmap_mem, slice);
+ struct blk_desc *bd = dev_get_uclass_plat(bm->blk);
+ char *src;
+
+ src = bmm->addr + (blknr << bd->log2blksz);
+ memcpy(buffer, src, blkcnt << bd->log2blksz);
+ return blkcnt;
+}
+
+static ulong blkmap_mem_write(struct blkmap *bm, struct blkmap_slice *bms,
+ lbaint_t blknr, lbaint_t blkcnt,
+ const void *buffer)
+{
+ struct blkmap_mem *bmm = container_of(bms, struct blkmap_mem, slice);
+ struct blk_desc *bd = dev_get_uclass_plat(bm->blk);
+ char *dst;
+
+ dst = bmm->addr + (blknr << bd->log2blksz);
+ memcpy(dst, buffer, blkcnt << bd->log2blksz);
+ return blkcnt;
+}
+
+static void blkmap_mem_destroy(struct blkmap *bm, struct blkmap_slice *bms)
+{
+ struct blkmap_mem *bmm = container_of(bms, struct blkmap_mem, slice);
+
+ if (bmm->remapped)
+ unmap_sysmem(bmm->addr);
+}
+
+int __blkmap_map_mem(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt,
+ void *addr, bool remapped)
+{
+ struct blkmap *bm = dev_get_plat(dev);
+ struct blkmap_mem *bmm;
+ int err;
+
+ bmm = malloc(sizeof(*bmm));
+ if (!bmm)
+ return -ENOMEM;
+
+ *bmm = (struct blkmap_mem) {
+ .slice = {
+ .blknr = blknr,
+ .blkcnt = blkcnt,
+
+ .read = blkmap_mem_read,
+ .write = blkmap_mem_write,
+ .destroy = blkmap_mem_destroy,
+ },
+
+ .addr = addr,
+ .remapped = remapped,
+ };
+
+ err = blkmap_slice_add(bm, &bmm->slice);
+ if (err)
+ free(bmm);
+
+ return err;
+}
+
+int blkmap_map_mem(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt,
+ void *addr)
+{
+ return __blkmap_map_mem(dev, blknr, blkcnt, addr, false);
+}
+
+int blkmap_map_pmem(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt,
+ phys_addr_t paddr)
+{
+ struct blkmap *bm = dev_get_plat(dev);
+ struct blk_desc *bd = dev_get_uclass_plat(bm->blk);
+ void *addr;
+ int err;
+
+ addr = map_sysmem(paddr, blkcnt << bd->log2blksz);
+ if (!addr)
+ return -ENOMEM;
+
+ err = __blkmap_map_mem(dev, blknr, blkcnt, addr, true);
+ if (err)
+ unmap_sysmem(addr);
+
+ return err;
+}
+
static ulong blkmap_blk_read_slice(struct blkmap *bm, struct blkmap_slice *bms,
lbaint_t blknr, lbaint_t blkcnt,
void *buffer)
diff --git a/include/blkmap.h b/include/blkmap.h
index 3c7e36efab..74baeb19f8 100644
--- a/include/blkmap.h
+++ b/include/blkmap.h
@@ -7,6 +7,35 @@
#ifndef _BLKMAP_H
#define _BLKMAP_H
+/**
+ * blkmap_map_mem() - Map region of memory
+ *
+ * @dev: Blkmap to create the mapping on
+ * @blknr: Start block number of the mapping
+ * @blkcnt: Number of blocks to map
+ * @addr: The target memory address of the mapping
+ * Returns: 0 on success, negative error code on failure
+ */
+int blkmap_map_mem(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt,
+ void *addr);
+
+/**
+ * blkmap_map_pmem() - Map region of physical memory
+ *
+ * Ensures that a valid physical to virtual memory mapping for the
+ * requested region is valid for the lifetime of the mapping, on
+ * architectures that require it (sandbox).
+ *
+ * @dev: Blkmap to create the mapping on
+ * @blknr: Start block number of the mapping
+ * @blkcnt: Number of blocks to map
+ * @paddr: The target physical memory address of the mapping
+ * Returns: 0 on success, negative error code on failure
+ */
+int blkmap_map_pmem(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt,
+ phys_addr_t paddr);
+
+
/**
* blkmap_from_label() - Find blkmap from label
*
--
2.34.1
@@ -1,125 +0,0 @@
From 29ed14e1a427c4e308413bccdc75084c1c1ec75a Mon Sep 17 00:00:00 2001
From: Tobias Waldekranz <tobias@waldekranz.com>
Date: Thu, 16 Feb 2023 15:09:21 +0100
Subject: [PATCH v2 5/9] blk: blkmap: Add linear device mapping support
Allow a slice of an existing block device to be mapped to a
blkmap. This means that filesystems that are not stored at exact
partition boundaries can be accessed by remapping a slice of the
existing device to a blkmap device.
Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
---
drivers/block/blkmap.c | 71 ++++++++++++++++++++++++++++++++++++++++++
include/blkmap.h | 13 ++++++++
2 files changed, 84 insertions(+)
diff --git a/drivers/block/blkmap.c b/drivers/block/blkmap.c
index 6d6eed889e..2bb0acc20f 100644
--- a/drivers/block/blkmap.c
+++ b/drivers/block/blkmap.c
@@ -130,6 +130,77 @@ static int blkmap_slice_add(struct blkmap *bm, struct blkmap_slice *new)
return 0;
}
+/**
+ * struct blkmap_linear - Linear mapping to other block device
+ *
+ * @slice: Common map data
+ * @blk: Target block device of this mapping
+ * @blknr: Start block number of the target device
+ */
+struct blkmap_linear {
+ struct blkmap_slice slice;
+
+ struct udevice *blk;
+ lbaint_t blknr;
+};
+
+static ulong blkmap_linear_read(struct blkmap *bm, struct blkmap_slice *bms,
+ lbaint_t blknr, lbaint_t blkcnt, void *buffer)
+{
+ struct blkmap_linear *bml = container_of(bms, struct blkmap_linear, slice);
+
+ return blk_read(bml->blk, bml->blknr + blknr, blkcnt, buffer);
+}
+
+static ulong blkmap_linear_write(struct blkmap *bm, struct blkmap_slice *bms,
+ lbaint_t blknr, lbaint_t blkcnt,
+ const void *buffer)
+{
+ struct blkmap_linear *bml = container_of(bms, struct blkmap_linear, slice);
+
+ return blk_write(bml->blk, bml->blknr + blknr, blkcnt, buffer);
+}
+
+int blkmap_map_linear(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt,
+ struct udevice *lblk, lbaint_t lblknr)
+{
+ struct blkmap *bm = dev_get_plat(dev);
+ struct blkmap_linear *linear;
+ struct blk_desc *bd, *lbd;
+ int err;
+
+ bd = dev_get_uclass_plat(bm->blk);
+ lbd = dev_get_uclass_plat(lblk);
+ if (lbd->blksz != bd->blksz)
+ /* We could support block size translation, but we
+ * don't yet.
+ */
+ return -EINVAL;
+
+ linear = malloc(sizeof(*linear));
+ if (!linear)
+ return -ENOMEM;
+
+ *linear = (struct blkmap_linear) {
+ .slice = {
+ .blknr = blknr,
+ .blkcnt = blkcnt,
+
+ .read = blkmap_linear_read,
+ .write = blkmap_linear_write,
+ },
+
+ .blk = lblk,
+ .blknr = lblknr,
+ };
+
+ err = blkmap_slice_add(bm, &linear->slice);
+ if (err)
+ free(linear);
+
+ return err;
+}
+
/**
* struct blkmap_mem - Memory mapping
*
diff --git a/include/blkmap.h b/include/blkmap.h
index 74baeb19f8..af54583c7d 100644
--- a/include/blkmap.h
+++ b/include/blkmap.h
@@ -7,6 +7,19 @@
#ifndef _BLKMAP_H
#define _BLKMAP_H
+/**
+ * blkmap_map_linear() - Map region of other block device
+ *
+ * @dev: Blkmap to create the mapping on
+ * @blknr: Start block number of the mapping
+ * @blkcnt: Number of blocks to map
+ * @lblk: The target block device of the mapping
+ * @lblknr: The start block number of the target device
+ * Returns: 0 on success, negative error code on failure
+ */
+int blkmap_map_linear(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt,
+ struct udevice *lblk, lbaint_t lblknr);
+
/**
* blkmap_map_mem() - Map region of memory
*
--
2.34.1
@@ -1,337 +0,0 @@
From c20dd0f17a128e65c1f376bf0e1cad9cec1d0336 Mon Sep 17 00:00:00 2001
From: Tobias Waldekranz <tobias@waldekranz.com>
Date: Thu, 16 Feb 2023 15:10:49 +0100
Subject: [PATCH v2 6/9] cmd: blkmap: Add blkmap command
Add a frontend for the blkmap subsystem. In addition to the common
block device operations, this allows users to create and destroy
devices, and map in memory and slices of other block devices.
With that we support two primary use-cases:
- Being able to "distro boot" from a RAM disk. I.e., from an image
where the kernel is stored in /boot of some filesystem supported
by U-Boot.
- Accessing filesystems not located on exact partition boundaries,
e.g. when a filesystem image is wrapped in an FIT image and stored
in a disk partition.
Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
---
MAINTAINERS | 1 +
cmd/Kconfig | 19 +++++
cmd/Makefile | 1 +
cmd/blkmap.c | 233 +++++++++++++++++++++++++++++++++++++++++++++++++++
disk/part.c | 1 +
5 files changed, 255 insertions(+)
create mode 100644 cmd/blkmap.c
diff --git a/MAINTAINERS b/MAINTAINERS
index 3e47c9b34c..316b85fed7 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -796,6 +796,7 @@ F: tools/binman/
BLKMAP
M: Tobias Waldekranz <tobias@waldekranz.com>
S: Maintained
+F: cmd/blkmap.c
F: drivers/block/blkmap.c
F: include/blkmap.h
diff --git a/cmd/Kconfig b/cmd/Kconfig
index 2caa4af71c..3dd3cdc656 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -1959,6 +1959,25 @@ config CMD_BLOCK_CACHE
during development, but also allows the cache to be disabled when
it might hurt performance (e.g. when using the ums command).
+config CMD_BLKMAP
+ bool "blkmap - Composable virtual block devices"
+ depends on BLKMAP
+ default y if BLKMAP
+ help
+ Create virtual block devices that are backed by various sources,
+ e.g. RAM, or parts of an existing block device. Though much more
+ rudimentary, it borrows a lot of ideas from Linux's device mapper
+ subsystem.
+
+ Example use-cases:
+ - Treat a region of RAM as a block device, i.e. a RAM disk. This let's
+ you extract files from filesystem images stored in RAM (perhaps as a
+ result of a TFTP transfer).
+ - Create a virtual partition on an existing device. This let's you
+ access filesystems that aren't stored at an exact partition
+ boundary. A common example is a filesystem image embedded in an FIT
+ image.
+
config CMD_BUTTON
bool "button"
depends on BUTTON
diff --git a/cmd/Makefile b/cmd/Makefile
index 36d2daf22a..837eee39b1 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -27,6 +27,7 @@ obj-$(CONFIG_CMD_BCB) += bcb.o
obj-$(CONFIG_CMD_BDI) += bdinfo.o
obj-$(CONFIG_CMD_BIND) += bind.o
obj-$(CONFIG_CMD_BINOP) += binop.o
+obj-$(CONFIG_CMD_BLKMAP) += blkmap.o
obj-$(CONFIG_CMD_BLOBLIST) += bloblist.o
obj-$(CONFIG_CMD_BLOCK_CACHE) += blkcache.o
obj-$(CONFIG_CMD_BMP) += bmp.o
diff --git a/cmd/blkmap.c b/cmd/blkmap.c
new file mode 100644
index 0000000000..b34c013072
--- /dev/null
+++ b/cmd/blkmap.c
@@ -0,0 +1,233 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2023 Addiva Elektronik
+ * Author: Tobias Waldekranz <tobias@waldekranz.com>
+ */
+
+#include <blk.h>
+#include <blkmap.h>
+#include <common.h>
+#include <command.h>
+#include <malloc.h>
+#include <dm/device.h>
+
+static int blkmap_curr_dev;
+
+struct map_ctx {
+ struct udevice *dev;
+ lbaint_t blknr, blkcnt;
+};
+
+typedef int (*map_parser_fn)(struct map_ctx *ctx, int argc, char *const argv[]);
+
+struct map_handler {
+ const char *name;
+ map_parser_fn fn;
+};
+
+int do_blkmap_map_linear(struct map_ctx *ctx, int argc, char *const argv[])
+{
+ struct blk_desc *lbd;
+ int err, ldevnum;
+ lbaint_t lblknr;
+
+ if (argc < 4)
+ return CMD_RET_USAGE;
+
+ ldevnum = dectoul(argv[2], NULL);
+ lblknr = dectoul(argv[3], NULL);
+
+ lbd = blk_get_devnum_by_uclass_idname(argv[1], ldevnum);
+ if (!lbd) {
+ printf("Found no device matching \"%s %d\"\n",
+ argv[1], ldevnum);
+ return CMD_RET_FAILURE;
+ }
+
+ err = blkmap_map_linear(ctx->dev, ctx->blknr, ctx->blkcnt,
+ lbd->bdev, lblknr);
+ if (err) {
+ printf("Unable to map \"%s %d\" at block 0x" LBAF ": %d\n",
+ argv[1], ldevnum, ctx->blknr, err);
+
+ return CMD_RET_FAILURE;
+ }
+
+ printf("Block 0x" LBAF "+0x" LBAF " mapped to block 0x" LBAF " of \"%s %d\"\n",
+ ctx->blknr, ctx->blkcnt, lblknr, argv[1], ldevnum);
+ return CMD_RET_SUCCESS;
+}
+
+int do_blkmap_map_mem(struct map_ctx *ctx, int argc, char *const argv[])
+{
+ phys_addr_t addr;
+ int err;
+
+ if (argc < 2)
+ return CMD_RET_USAGE;
+
+ addr = hextoul(argv[1], NULL);
+
+ err = blkmap_map_pmem(ctx->dev, ctx->blknr, ctx->blkcnt, addr);
+ if (err) {
+ printf("Unable to map %#llx at block 0x" LBAF ": %d\n",
+ (unsigned long long)addr, ctx->blknr, err);
+ return CMD_RET_FAILURE;
+ }
+
+ printf("Block 0x" LBAF "+0x" LBAF " mapped to %#llx\n",
+ ctx->blknr, ctx->blkcnt, (unsigned long long)addr);
+ return CMD_RET_SUCCESS;
+}
+
+struct map_handler map_handlers[] = {
+ { .name = "linear", .fn = do_blkmap_map_linear },
+ { .name = "mem", .fn = do_blkmap_map_mem },
+
+ { .name = NULL }
+};
+
+static int do_blkmap_map(struct cmd_tbl *cmdtp, int flag,
+ int argc, char *const argv[])
+{
+ struct map_handler *handler;
+ struct map_ctx ctx;
+
+ if (argc < 5)
+ return CMD_RET_USAGE;
+
+ ctx.dev = blkmap_from_label(argv[1]);
+ if (!ctx.dev) {
+ printf("\"%s\" is not the name of any known blkmap\n", argv[1]);
+ return CMD_RET_FAILURE;
+ }
+
+ ctx.blknr = hextoul(argv[2], NULL);
+ ctx.blkcnt = hextoul(argv[3], NULL);
+ argc -= 4;
+ argv += 4;
+
+ for (handler = map_handlers; handler->name; handler++) {
+ if (!strcmp(handler->name, argv[0]))
+ return handler->fn(&ctx, argc, argv);
+ }
+
+ printf("Unknown map type \"%s\"\n", argv[0]);
+ return CMD_RET_USAGE;
+}
+
+static int do_blkmap_create(struct cmd_tbl *cmdtp, int flag,
+ int argc, char *const argv[])
+{
+ const char *label;
+ int err;
+
+ if (argc != 2)
+ return CMD_RET_USAGE;
+
+ label = argv[1];
+
+ err = blkmap_create(label, NULL);
+ if (err) {
+ printf("Unable to create \"%s\": %d\n", label, err);
+ return CMD_RET_FAILURE;
+ }
+
+ printf("Created \"%s\"\n", label);
+ return CMD_RET_SUCCESS;
+}
+
+static int do_blkmap_destroy(struct cmd_tbl *cmdtp, int flag,
+ int argc, char *const argv[])
+{
+ struct udevice *dev;
+ const char *label;
+ int err;
+
+ if (argc != 2)
+ return CMD_RET_USAGE;
+
+ label = argv[1];
+
+ dev = blkmap_from_label(label);
+ if (!dev) {
+ printf("\"%s\" is not the name of any known blkmap\n", label);
+ return CMD_RET_FAILURE;
+ }
+
+ err = blkmap_destroy(dev);
+ if (err) {
+ printf("Unable to destroy \"%s\": %d\n", label, err);
+ return CMD_RET_FAILURE;
+ }
+
+ printf("Destroyed \"%s\"\n", label);
+ return CMD_RET_SUCCESS;
+}
+
+static int do_blkmap_get(struct cmd_tbl *cmdtp, int flag,
+ int argc, char *const argv[])
+{
+ struct udevice *dev;
+ const char *label;
+ int err;
+
+ if (argc < 3)
+ return CMD_RET_USAGE;
+
+ label = argv[1];
+
+ dev = blkmap_from_label(label);
+ if (!dev) {
+ printf("\"%s\" is not the name of any known blkmap\n", label);
+ return CMD_RET_FAILURE;
+ }
+
+ if (!strcmp(argv[2], "dev")) {
+ if (argc == 3) {
+ printf("%d\n", dev_seq(dev));
+ } else {
+ err = env_set_hex(argv[3], dev_seq(dev));
+ if (err)
+ return CMD_RET_FAILURE;
+ }
+ } else {
+ return CMD_RET_USAGE;
+ }
+
+ return CMD_RET_SUCCESS;
+}
+
+static int do_blkmap_common(struct cmd_tbl *cmdtp, int flag,
+ int argc, char *const argv[])
+{
+ /* The subcommand parsing pops the original argv[0] ("blkmap")
+ * which blk_common_cmd expects. Push it back again.
+ */
+ argc++;
+ argv--;
+
+ return blk_common_cmd(argc, argv, UCLASS_BLKMAP, &blkmap_curr_dev);
+}
+
+U_BOOT_CMD_WITH_SUBCMDS(
+ blkmap, "Composeable virtual block devices",
+ "info - list configured devices\n"
+ "blkmap part - list available partitions on current blkmap device\n"
+ "blkmap dev [<dev>] - show or set current blkmap device\n"
+ "blkmap read <addr> <blk#> <cnt>\n"
+ "blkmap write <addr> <blk#> <cnt>\n"
+ "blkmap get <label> dev [<var>] - store device number in variable\n"
+ "blkmap create <label> - create device\n"
+ "blkmap destroy <label> - destroy device\n"
+ "blkmap map <label> <blk#> <cnt> linear <interface> <dev> <blk#> - device mapping\n"
+ "blkmap map <label> <blk#> <cnt> mem <addr> - memory mapping\n",
+ U_BOOT_SUBCMD_MKENT(info, 2, 1, do_blkmap_common),
+ U_BOOT_SUBCMD_MKENT(part, 2, 1, do_blkmap_common),
+ U_BOOT_SUBCMD_MKENT(dev, 4, 1, do_blkmap_common),
+ U_BOOT_SUBCMD_MKENT(read, 5, 1, do_blkmap_common),
+ U_BOOT_SUBCMD_MKENT(write, 5, 1, do_blkmap_common),
+ U_BOOT_SUBCMD_MKENT(get, 5, 1, do_blkmap_get),
+ U_BOOT_SUBCMD_MKENT(create, 2, 1, do_blkmap_create),
+ U_BOOT_SUBCMD_MKENT(destroy, 2, 1, do_blkmap_destroy),
+ U_BOOT_SUBCMD_MKENT(map, 32, 1, do_blkmap_map));
diff --git a/disk/part.c b/disk/part.c
index d449635254..35300df590 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -140,6 +140,7 @@ void dev_print(struct blk_desc *dev_desc)
case UCLASS_NVME:
case UCLASS_PVBLOCK:
case UCLASS_HOST:
+ case UCLASS_BLKMAP:
printf ("Vendor: %s Rev: %s Prod: %s\n",
dev_desc->vendor,
dev_desc->revision,
--
2.34.1
@@ -1,266 +0,0 @@
From e9a394da1d75b2b3bea81e53ec2899d240a98861 Mon Sep 17 00:00:00 2001
From: Tobias Waldekranz <tobias@waldekranz.com>
Date: Thu, 16 Feb 2023 15:13:33 +0100
Subject: [PATCH v2 7/9] test: blkmap: Add test suite
Verify that:
- Block maps can be created and destroyed
- Mappings aren't allowed to overlap
- Multiple mappings can be attached and be read/written from/to
Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
---
MAINTAINERS | 1 +
configs/sandbox_defconfig | 1 +
test/dm/Makefile | 1 +
test/dm/blkmap.c | 201 ++++++++++++++++++++++++++++++++++++++
4 files changed, 204 insertions(+)
create mode 100644 test/dm/blkmap.c
diff --git a/MAINTAINERS b/MAINTAINERS
index 316b85fed7..bbcb5117fe 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -799,6 +799,7 @@ S: Maintained
F: cmd/blkmap.c
F: drivers/block/blkmap.c
F: include/blkmap.h
+F: test/dm/blkmap.c
BOOTDEVICE
M: Simon Glass <sjg@chromium.org>
diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index 34c342b6f5..06021e4902 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -145,6 +145,7 @@ CONFIG_ADC=y
CONFIG_ADC_SANDBOX=y
CONFIG_AXI=y
CONFIG_AXI_SANDBOX=y
+CONFIG_BLKMAP=y
CONFIG_SYS_IDE_MAXBUS=1
CONFIG_SYS_ATA_BASE_ADDR=0x100
CONFIG_SYS_ATA_STRIDE=4
diff --git a/test/dm/Makefile b/test/dm/Makefile
index 7a79b6e1a2..e15bdbf04b 100644
--- a/test/dm/Makefile
+++ b/test/dm/Makefile
@@ -29,6 +29,7 @@ obj-$(CONFIG_ADC) += adc.o
obj-$(CONFIG_SOUND) += audio.o
obj-$(CONFIG_AXI) += axi.o
obj-$(CONFIG_BLK) += blk.o
+obj-$(CONFIG_BLKMAP) += blkmap.o
obj-$(CONFIG_BUTTON) += button.o
obj-$(CONFIG_DM_BOOTCOUNT) += bootcount.o
obj-$(CONFIG_DM_REBOOT_MODE) += reboot-mode.o
diff --git a/test/dm/blkmap.c b/test/dm/blkmap.c
new file mode 100644
index 0000000000..7a163d6eae
--- /dev/null
+++ b/test/dm/blkmap.c
@@ -0,0 +1,201 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2023 Addiva Elektronik
+ * Author: Tobias Waldekranz <tobias@waldekranz.com>
+ */
+
+#include <common.h>
+#include <blk.h>
+#include <blkmap.h>
+#include <dm.h>
+#include <asm/test.h>
+#include <dm/test.h>
+#include <test/test.h>
+#include <test/ut.h>
+
+#define BLKSZ 0x200
+
+struct mapping {
+ int src;
+ int cnt;
+ int dst;
+};
+
+const struct mapping unordered_mapping[] = {
+ { 0, 1, 3 },
+ { 1, 3, 0 },
+ { 4, 2, 6 },
+ { 6, 2, 4 },
+
+ { 0, 0, 0 }
+};
+
+const struct mapping identity_mapping[] = {
+ { 0, 8, 0 },
+
+ { 0, 0, 0 }
+};
+
+static char identity[8 * BLKSZ];
+static char unordered[8 * BLKSZ];
+static char buffer[8 * BLKSZ];
+
+static void mkblob(void *base, const struct mapping *m)
+{
+ int nr;
+
+ for (; m->cnt; m++) {
+ for (nr = 0; nr < m->cnt; nr++) {
+ memset(base + (m->dst + nr) * BLKSZ,
+ m->src + nr, BLKSZ);
+ }
+ }
+}
+
+static int dm_test_blkmap_read(struct unit_test_state *uts)
+{
+ struct udevice *dev, *blk;
+ const struct mapping *m;
+
+ ut_assertok(blkmap_create("rdtest", &dev));
+ ut_assertok(blk_get_from_parent(dev, &blk));
+
+ /* Generate an ordered and an unordered pattern in memory */
+ mkblob(unordered, unordered_mapping);
+ mkblob(identity, identity_mapping);
+
+ /* Create a blkmap that cancels out the disorder */
+ for (m = unordered_mapping; m->cnt; m++) {
+ ut_assertok(blkmap_map_mem(dev, m->src, m->cnt,
+ unordered + m->dst * BLKSZ));
+ }
+
+ /* Read out the data via the blkmap device to another area,
+ * and verify that it matches the ordered pattern.
+ */
+ ut_asserteq(8, blk_read(blk, 0, 8, buffer));
+ ut_assertok(memcmp(buffer, identity, sizeof(buffer)));
+
+ ut_assertok(blkmap_destroy(dev));
+ return 0;
+}
+DM_TEST(dm_test_blkmap_read, 0);
+
+static int dm_test_blkmap_write(struct unit_test_state *uts)
+{
+ struct udevice *dev, *blk;
+ const struct mapping *m;
+
+ ut_assertok(blkmap_create("wrtest", &dev));
+ ut_assertok(blk_get_from_parent(dev, &blk));
+
+ /* Generate an ordered and an unordered pattern in memory */
+ mkblob(unordered, unordered_mapping);
+ mkblob(identity, identity_mapping);
+
+ /* Create a blkmap that mimics the disorder */
+ for (m = unordered_mapping; m->cnt; m++) {
+ ut_assertok(blkmap_map_mem(dev, m->src, m->cnt,
+ buffer + m->dst * BLKSZ));
+ }
+
+ /* Write the ordered data via the blkmap device to another
+ * area, and verify that the result matches the unordered
+ * pattern.
+ */
+ ut_asserteq(8, blk_write(blk, 0, 8, identity));
+ ut_assertok(memcmp(buffer, unordered, sizeof(buffer)));
+
+ ut_assertok(blkmap_destroy(dev));
+ return 0;
+}
+DM_TEST(dm_test_blkmap_write, 0);
+
+static int dm_test_blkmap_slicing(struct unit_test_state *uts)
+{
+ struct udevice *dev;
+
+ ut_assertok(blkmap_create("slicetest", &dev));
+
+ ut_assertok(blkmap_map_mem(dev, 8, 8, NULL));
+
+ /* Can't overlap on the low end */
+ ut_asserteq(-EBUSY, blkmap_map_mem(dev, 4, 5, NULL));
+ /* Can't be inside */
+ ut_asserteq(-EBUSY, blkmap_map_mem(dev, 10, 2, NULL));
+ /* Can't overlap on the high end */
+ ut_asserteq(-EBUSY, blkmap_map_mem(dev, 15, 4, NULL));
+
+ /* But we should be able to add slices right before and
+ * after
+ */
+ ut_assertok(blkmap_map_mem(dev, 4, 4, NULL));
+ ut_assertok(blkmap_map_mem(dev, 16, 4, NULL));
+
+ ut_assertok(blkmap_destroy(dev));
+ return 0;
+}
+DM_TEST(dm_test_blkmap_slicing, 0);
+
+static int dm_test_blkmap_creation(struct unit_test_state *uts)
+{
+ struct udevice *first, *second;
+
+ ut_assertok(blkmap_create("first", &first));
+
+ /* Can't have two "first"s */
+ ut_asserteq(-EBUSY, blkmap_create("first", &second));
+
+ /* But "second" should be fine */
+ ut_assertok(blkmap_create("second", &second));
+
+ /* Once "first" is destroyed, we should be able to create it
+ * again
+ */
+ ut_assertok(blkmap_destroy(first));
+ ut_assertok(blkmap_create("first", &first));
+
+ ut_assertok(blkmap_destroy(first));
+ ut_assertok(blkmap_destroy(second));
+ return 0;
+}
+DM_TEST(dm_test_blkmap_creation, 0);
+
+static int dm_test_cmd_blkmap(struct unit_test_state *uts)
+{
+ ulong loadaddr = env_get_hex("loadaddr", 0);
+ struct udevice *dev;
+
+ console_record_reset();
+
+ ut_assertok(run_command("blkmap info", 0));
+ ut_assert_console_end();
+
+ ut_assertok(run_command("blkmap create ramdisk", 0));
+ ut_assert_nextline("Created \"ramdisk\"");
+ ut_assert_console_end();
+
+ ut_assertnonnull((dev = blkmap_from_label("ramdisk")));
+
+ ut_assertok(run_commandf("blkmap map ramdisk 0 800 mem 0x%lx", loadaddr));
+ ut_assert_nextline("Block 0x0+0x800 mapped to 0x%lx", loadaddr);
+ ut_assert_console_end();
+
+ ut_assertok(run_command("blkmap info", 0));
+ ut_assert_nextline("Device 0: Vendor: U-Boot Rev: 1.0 Prod: blkmap");
+ ut_assert_nextline(" Type: Hard Disk");
+ ut_assert_nextline(" Capacity: 1.0 MB = 0.0 GB (2048 x 512)");
+ ut_assert_console_end();
+
+ ut_assertok(run_command("blkmap get ramdisk dev devnum", 0));
+ ut_asserteq(dev_seq(dev), env_get_hex("devnum", 0xdeadbeef));
+
+ ut_assertok(run_command("blkmap destroy ramdisk", 0));
+ ut_assert_nextline("Destroyed \"ramdisk\"");
+ ut_assert_console_end();
+
+ ut_assertok(run_command("blkmap info", 0));
+ ut_assert_console_end();
+ return 0;
+}
+DM_TEST(dm_test_cmd_blkmap, 0);
--
2.34.1
@@ -1,159 +0,0 @@
From 53e157184110e66144e805e733e5f0a7a4a031a8 Mon Sep 17 00:00:00 2001
From: Tobias Waldekranz <tobias@waldekranz.com>
Date: Thu, 16 Feb 2023 15:14:27 +0100
Subject: [PATCH v2 8/9] doc: blkmap: Add introduction and examples
Explain block maps by going through two common use-cases.
Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
---
MAINTAINERS | 1 +
doc/usage/blkmap.rst | 111 +++++++++++++++++++++++++++++++++++++++++++
doc/usage/index.rst | 1 +
3 files changed, 113 insertions(+)
create mode 100644 doc/usage/blkmap.rst
diff --git a/MAINTAINERS b/MAINTAINERS
index bbcb5117fe..e02dacc20a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -797,6 +797,7 @@ BLKMAP
M: Tobias Waldekranz <tobias@waldekranz.com>
S: Maintained
F: cmd/blkmap.c
+F: doc/usage/blkmap.rst
F: drivers/block/blkmap.c
F: include/blkmap.h
F: test/dm/blkmap.c
diff --git a/doc/usage/blkmap.rst b/doc/usage/blkmap.rst
new file mode 100644
index 0000000000..dbfa8e5aad
--- /dev/null
+++ b/doc/usage/blkmap.rst
@@ -0,0 +1,111 @@
+.. SPDX-License-Identifier: GPL-2.0+
+..
+.. Copyright (c) 2023 Addiva Elektronik
+.. Author: Tobias Waldekranz <tobias@waldekranz.com>
+
+Block Maps (blkmap)
+===================
+
+Block maps are a way of looking at various sources of data through the
+lens of a regular block device. It lets you treat devices that are not
+block devices, like RAM, as if they were. It also lets you export a
+slice of an existing block device, which does not have to correspond
+to a partition boundary, as a new block device.
+
+This is primarily useful because U-Boot's filesystem drivers only
+operate on block devices, so a block map lets you access filesystems
+wherever they might be located.
+
+The implementation is loosely modeled on Linux's "Device Mapper"
+subsystem, see `kernel documentation`_ for more information.
+
+.. _kernel documentation: https://docs.kernel.org/admin-guide/device-mapper/index.html
+
+
+Example: Netbooting an Ext4 Image
+---------------------------------
+
+Say that our system is using an Ext4 filesystem as its rootfs, where
+the kernel is stored in ``/boot``. This image is then typically stored
+in an eMMC partition. In this configuration, we can use something like
+``load mmc 0 ${kernel_addr_r} /boot/Image`` to load the kernel image
+into the expected location, and then boot the system. No problems.
+
+Now imagine that during development, or as a recovery mechanism, we
+want to boot the same type of image by downloading it over the
+network. Getting the image to the target is easy enough:
+
+::
+
+ dhcp ${ramdisk_addr_r} rootfs.ext4
+
+But now we are faced with a predicament: how to we extract the kernel
+image? Block maps to the rescue!
+
+We start by creating a new device:
+
+::
+
+ blkmap create netboot
+
+Before setting up the mapping, we figure out the size of the
+downloaded file, in blocks:
+
+::
+
+ setexpr fileblks ${filesize} + 0x1ff
+ setexpr fileblks ${filesize} / 0x200
+
+Then we can add a mapping to the start of our device, backed by the
+memory at `${loadaddr}`:
+
+::
+
+ blkmap map netboot 0 ${fileblks} mem ${fileaddr}
+
+Now we can access the filesystem via the virtual device:
+
+::
+
+ blkmap get netboot dev devnum
+ load blkmap ${devnum} ${kernel_addr_r} /boot/Image
+
+
+Example: Accessing a filesystem inside an FIT image
+---------------------------------------------------
+
+In this example, an FIT image is stored in an eMMC partition. We would
+like to read the file ``/etc/version``, stored inside a Squashfs image
+in the FIT. Since the Squashfs image is not stored on a partition
+boundary, there is no way of accessing it via ``load mmc ...``.
+
+What we can to instead is to first figure out the offset and size of
+the filesystem:
+
+::
+
+ mmc dev 0
+ mmc read ${loadaddr} 0 0x100
+
+ fdt addr ${loadaddr}
+ fdt get value squashaddr /images/ramdisk data-position
+ fdt get value squashsize /images/ramdisk data-size
+
+ setexpr squashblk ${squashaddr} / 0x200
+ setexpr squashsize ${squashsize} + 0x1ff
+ setexpr squashsize ${squashsize} / 0x200
+
+Then we can create a block map that maps to that slice of the full
+partition:
+
+::
+
+ blkmap create sq
+ blkmap map sq 0 ${squashsize} linear mmc 0 ${squashblk}
+
+Now we can access the filesystem:
+
+::
+
+ blkmap get sq dev devnum
+ load blkmap ${devnum} ${loadaddr} /etc/version
diff --git a/doc/usage/index.rst b/doc/usage/index.rst
index cde7dcb14a..2dfcd4b2b2 100644
--- a/doc/usage/index.rst
+++ b/doc/usage/index.rst
@@ -4,6 +4,7 @@ Use U-Boot
.. toctree::
:maxdepth: 1
+ blkmap
dfu
environment
fdt_overlays
--
2.34.1
@@ -1,86 +0,0 @@
From 0a0ceadab82a1e76d0d21b14b75510d3bd9228ff Mon Sep 17 00:00:00 2001
From: Tobias Waldekranz <tobias@waldekranz.com>
Date: Thu, 16 Feb 2023 15:15:59 +0100
Subject: [PATCH v2 9/9] efi_loader: device_path: support blkmap devices
Create a distinct EFI device path for each blkmap device.
Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
---
include/efi_loader.h | 4 ++++
lib/efi_loader/efi_device_path.c | 30 ++++++++++++++++++++++++++++++
2 files changed, 34 insertions(+)
diff --git a/include/efi_loader.h b/include/efi_loader.h
index c664d6cdf2..eb3818b457 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -134,6 +134,10 @@ static inline efi_status_t efi_launch_capsules(void)
#define U_BOOT_GUID \
EFI_GUID(0xe61d73b9, 0xa384, 0x4acc, \
0xae, 0xab, 0x82, 0xe8, 0x28, 0xf3, 0x62, 0x8b)
+/* GUID used as root for blkmap devices */
+#define U_BOOT_BLKMAP_DEV_GUID \
+ EFI_GUID(0x4cad859d, 0xd644, 0x42ff, \
+ 0x87, 0x0b, 0xc0, 0x2e, 0xac, 0x05, 0x58, 0x63)
/* GUID used as host device on sandbox */
#define U_BOOT_HOST_DEV_GUID \
EFI_GUID(0xbbe4e671, 0x5773, 0x4ea1, \
diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c
index 3b267b713e..4b4c96bc2e 100644
--- a/lib/efi_loader/efi_device_path.c
+++ b/lib/efi_loader/efi_device_path.c
@@ -21,6 +21,9 @@
#include <asm-generic/unaligned.h>
#include <linux/compat.h> /* U16_MAX */
+#ifdef CONFIG_BLKMAP
+const efi_guid_t efi_guid_blkmap_dev = U_BOOT_BLKMAP_DEV_GUID;
+#endif
#ifdef CONFIG_SANDBOX
const efi_guid_t efi_guid_host_dev = U_BOOT_HOST_DEV_GUID;
#endif
@@ -573,6 +576,16 @@ __maybe_unused static unsigned int dp_size(struct udevice *dev)
*/
return dp_size(dev->parent)
+ sizeof(struct efi_device_path_vendor) + 1;
+#endif
+#ifdef CONFIG_BLKMAP
+ case UCLASS_BLKMAP:
+ /*
+ * blkmap devices will be represented as a vendor
+ * device node with an extra byte for the device
+ * number.
+ */
+ return dp_size(dev->parent)
+ + sizeof(struct efi_device_path_vendor) + 1;
#endif
default:
return dp_size(dev->parent);
@@ -631,6 +644,23 @@ __maybe_unused static void *dp_fill(void *buf, struct udevice *dev)
#endif
case UCLASS_BLK:
switch (dev->parent->uclass->uc_drv->id) {
+#ifdef CONFIG_BLKMAP
+ case UCLASS_BLKMAP: {
+ struct efi_device_path_vendor *dp;
+ struct blk_desc *desc = dev_get_uclass_plat(dev);
+
+ dp_fill(buf, dev->parent);
+ dp = buf;
+ ++dp;
+ dp->dp.type = DEVICE_PATH_TYPE_HARDWARE_DEVICE;
+ dp->dp.sub_type = DEVICE_PATH_SUB_TYPE_VENDOR;
+ dp->dp.length = sizeof(*dp) + 1;
+ memcpy(&dp->guid, &efi_guid_blkmap_dev,
+ sizeof(efi_guid_t));
+ dp->vendor_data[0] = desc->devnum;
+ return &dp->vendor_data[1];
+ }
+#endif
#ifdef CONFIG_SANDBOX
case UCLASS_HOST: {
/* stop traversing parents at this point: */
--
2.34.1
+11 -39
View File
@@ -1,42 +1,14 @@
setenv valid_media no
echo "Press Ctrl-C NOW to enter boot menu"
if sleep "${ixbootdelay}"; then
run ixbootorder
for tgt in "${boot_targets}"; do
if test "${tgt}" = "mmc0"; then
setenv devtype "mmc"
setenv devnum 0
mmc dev 0
elif test "${tgt}" = "mmc1"; then
setenv devtype "mmc"
setenv devnum 1
mmc dev 1
else
setenv devtype "${tgt}"
setenv devnum 0
fi
if part number ${devtype} ${devnum} aux auxpart; then
if load ${devtype} ${devnum}:${auxpart} ${loadaddr} /uboot.env; then
env import -b ${loadaddr} ${filesize} BOOT_ORDER DEBUG
fi
test -n "${BOOT_ORDER}" || setenv BOOT_ORDER "primary secondary net"
if test -n "${DEBUG}"; then
setenv bootargs_log "debug"
else
setenv bootargs_log "loglevel=4"
fi
setenv valid_media yes
run ixbootmedia
fi
done
if test "${valid_media}" = "no"; then
echo "NO BOOTABLE MEDIA FOUND, falling back to netboot"
setenv BOOT_ORDER "net"
setenv bootargs_log "debug"
run ixbootmedia
echo "FATAL: Exhausted all available boot sources, rebooting"
sleep 1
reset
fi
reset
bootmenu
if test "${dev_mode}" != "yes"; then
pause "Console shell access PROHIBITED. Press any key to reset..."
reset
fi
@@ -1,6 +0,0 @@
echo "Booting from ${devtype}${devnum} (order: ${BOOT_ORDER})"
for s in "${BOOT_ORDER}"; do
setenv slot "${s}"
run ixbootslot
done
+34 -26
View File
@@ -10,34 +10,42 @@ elif test "${slot}" = "net"; then
fi
if test "${prepared}" = "ok"; then
echo "${slot}: Validating..."
if iminfo ${ramdisk_addr_r}; then
echo "${slot}: Booting..."
echo "${slot}: Validating..."
setenv bootargs_user "rauc.slot=${slot}"
if test "${factory_reset}" = "yes"; then
setenv bootargs_user "${bootargs_user} finit.cond=factory-reset"
fi
if test "${dev_mode}" = "yes"; then
setenv bootargs_user "${bootargs_user} finit.cond=dev-mode"
fi
iminfo ${ramdisk_addr_r}
imok=$?
blkmap create boot
blkmap get boot dev blkmapnum
blkmap map boot 0 ${sqblkcnt} mem ${sqaddr}
for conf in "${board}-syslinux.conf syslinux.conf"; do
if test -e blkmap ${blkmapnum} /boot/syslinux/${conf}; then
sysboot blkmap ${blkmapnum} any ${scriptaddr} /boot/syslinux/${conf}
fi
done
blkmap destroy boot
echo "${slot}: ERROR: Boot failed"
else
echo "${slot}: ERROR: Validation failed"
if test ${imok} -eq 0 || test "${dev_mode}" = "yes"; then
if test ${imok} -ne 0; then
echo "DEVELOPER MODE ACTIVE, BOOTING UNTRUSTED IMAGE"
fi
echo "${slot}: Booting..."
setenv bootargs_user "rauc.slot=${slot}"
if test "${factory_reset}" = "yes"; then
setenv bootargs_user "${bootargs_user} finit.cond=factory-reset"
fi
if test "${dev_mode}" = "yes"; then
setenv bootargs_user "${bootargs_user} finit.cond=dev-mode"
fi
blkmap create boot
blkmap get boot dev blkmapnum
blkmap map boot 0 ${sqblkcnt} mem ${sqaddr}
for conf in "${board}-syslinux.conf syslinux.conf"; do
if test -e blkmap ${blkmapnum} /boot/syslinux/${conf}; then
sysboot blkmap ${blkmapnum} any ${scriptaddr} /boot/syslinux/${conf}
fi
done
blkmap destroy boot
echo "${slot}: ERROR: Boot failed"
else
echo "${slot}: ERROR: Validation failed"
fi
else
echo "${slot}: ERROR: Unable to use slot"
echo "${slot}: ERROR: Unable to use slot"
fi
@@ -0,0 +1,6 @@
if button factory-reset; then
echo "Keep button pressed for 10 seconds to engage factory reset"
if sleep 10 && button factory-reset; then
run ixfactory
fi
fi
-13
View File
@@ -1,13 +0,0 @@
setenv dev_mode no
setenv factory_reset no
echo -n "dev-mode: "
run ixdevmode
echo -n "factory-reset: "
run ixfactory
if test "${dev_mode}" = "yes"; then
sleep 1 && run ixboot
else
run ixboot
fi
+4 -7
View File
@@ -1,7 +1,4 @@
if button factory-reset; then
echo "Keep button pressed for 10 seconds to engage reset"
if sleep 10 && button factory-reset; then
setenv factory_reset yes
echo "FACTORY RESET ENGAGED"
fi
fi
setenv factory_reset yes
echo "FACTORY RESET ENGAGED"
echo "ALL user data will be deleted on system boot."
echo "To ABORT, power off device NOW."
-14
View File
@@ -1,14 +0,0 @@
${devtype} dev ${devnum}
${devtype} read ${ramdisk_addr_r} ${devoffs} 0x10
fdt addr ${ramdisk_addr_r}
fdt get value squashaddr /images/ramdisk data-position
fdt get value squashsize /images/ramdisk data-size
setexpr blkcnt ${squashaddr} + ${squashsize}
setexpr blkcnt ${blkcnt} + 0x1ff
setexpr blkcnt ${blkcnt} / 0x200
${devtype} read ${ramdisk_addr_r} ${devoffs} ${blkcnt}
+73
View File
@@ -0,0 +1,73 @@
setenv dev_mode no
setenv factory_reset no
echo -n "dev-mode: "
run ixbtn-devmode
echo -n "factory-reset: "
run ixbtn-factory
setenv valid_media no
setenv ixmenu_n 0
for tgt in "${boot_targets}"; do
if test "${tgt}" = "mmc0"; then
setenv devtype "mmc"
setenv devnum 0
mmc dev 0
elif test "${tgt}" = "mmc1"; then
setenv devtype "mmc"
setenv devnum 1
mmc dev 1
else
setenv devtype "${tgt}"
setenv devnum 0
fi
if part number ${devtype} ${devnum} aux auxpart; then
setenv "boot_${tgt}_primary" "setenv devtype ${devtype}; setenv devnum ${devnum}; setenv slot primary; run ixbootslot"
setenv "bootmenu_${ixmenu_n}" "Boot primary ${tgt} partition=run boot_${tgt}_primary"
setexpr ixmenu_n ${ixmenu_n} + 1
setenv "boot_${tgt}_secondary" "setenv devtype ${devtype}; setenv devnum ${devnum}; setenv slot secondary; run ixbootslot"
setenv "bootmenu_${ixmenu_n}" "Boot secondary ${tgt} partition=run boot_${tgt}_secondary"
setexpr ixmenu_n ${ixmenu_n} + 1
if load ${devtype} ${devnum}:${auxpart} ${loadaddr} /uboot.env; then
env import -b ${loadaddr} ${filesize} BOOT_ORDER DEBUG
fi
if test -n "${DEBUG}"; then
setenv bootargs_log "debug"
else
setenv bootargs_log "loglevel=4"
fi
test -n "${BOOT_ORDER}" || setenv BOOT_ORDER "primary secondary net"
echo "Valid boot device found on ${tgt} (order: ${BOOT_ORDER})"
for slot in "${BOOT_ORDER}"; do
if test "${slot}" = "primary"; then
setenv ixbootorder "${ixbootorder}run boot_${tgt}_primary; "
elif test "${slot}" = "secondary"; then
setenv ixbootorder "${ixbootorder}run boot_${tgt}_secondary; "
elif test "${slot}" = "net"; then
setenv ixbootorder "${ixbootorder}run boot_net; "
fi
done
setenv valid_media yes
fi
done
setenv "boot_net" "setenv slot net; run ixbootslot"
setenv "bootmenu_${ixmenu_n}" "Boot over network=run boot_net"
setexpr ixmenu_n ${ixmenu_n} + 1
setenv "bootmenu_${ixmenu_n}" "Factory reset=run ixfactory; echo; pause; bootmenu"
setexpr ixmenu_n ${ixmenu_n} + 1
if test "${valid_media}" = "no"; then
echo "NO BOOTABLE MEDIA FOUND, falling back to netboot"
setenv bootargs_log "debug"
setenv ixbootorder "run boot_net"
fi
+23 -11
View File
@@ -1,16 +1,28 @@
if dhcp ${ramdisk_addr_r}; then
setenv autoload no
setenv old_fdt_addr ${fdt_addr}
if fdt addr ${ramdisk_addr_r}; then
fdt get value sqoffs /images/rootfs data-position
fdt get value sqsize /images/rootfs data-size
fdt addr ${old_fdt_addr}
if dhcp; then
setenv proto tftp
setenv dltool tftpboot
setexpr sqaddr ${ramdisk_addr_r} + ${sqoffs}
setexpr sqblkcnt ${sqsize} / 0x200
setexpr sqkbsize ${sqsize} / 0x400
if setexpr proto sub "^(http|tftp)://.*" "\\1" "${bootfile}" && setexpr bootfile sub "^(http|tftp)://([^/]+?)/(.*)" "\2:\3"; then
if test "${proto}" = "http"; then
setenv dltool wget
fi
fi
setenv bootargs_root "root=/dev/ram0 ramdisk_size=0x${sqkbsize} initrd=0x${sqaddr},${sqsize}"
setenv prepared ok
if ${dltool} ${ramdisk_addr_r} "${bootfile}"; then
setenv old_fdt_addr ${fdt_addr}
if fdt addr ${ramdisk_addr_r}; then
fdt get value sqoffs /images/rootfs data-position
fdt get value sqsize /images/rootfs data-size
fdt addr ${old_fdt_addr}
setexpr sqaddr ${ramdisk_addr_r} + ${sqoffs}
setexpr sqblkcnt ${sqsize} / 0x200
setexpr sqkbsize ${sqsize} / 0x400
setenv bootargs_root "root=/dev/ram0 ramdisk_size=0x${sqkbsize} initrd=0x${sqaddr},${sqsize}"
setenv prepared ok
fi
fi
fi
@@ -1,5 +0,0 @@
if part number mmc 0 aux auxpart; then
if load mmc 0:${auxpart} ${loadaddr} /uboot.env; then
env import -b ${loadaddr} ${filesize} BOOT_ORDER DEBUG
fi
fi
-28
View File
@@ -1,28 +0,0 @@
setenv devtype mmc
setenv devnum 0
part start ${devtype} ${devnum} ${slot} devoffs
${devtype} dev ${devnum}
${devtype} read ${ramdisk_addr_r} ${devoffs} 0x10
setenv bootargs_root "root=/dev/dm-0 dm-mod.create=\"rootfs,,0,ro,0"
setenv old_fdt_addr ${fdt_addr}
if fdt addr ${ramdisk_addr_r}; then
fdt get value sqoffs /images/rootfs data-position
fdt get value sqsize /images/rootfs data-size
fdt addr ${old_fdt_addr}
setexpr sqaddr ${ramdisk_addr_r} + ${sqoffs}
setexpr sqblknr ${sqoffs} / 0x200
setexpr sqblkcnt ${sqsize} / 0x200
setexpr fitblkcnt ${sqblknr} + ${sqblkcnt}
if ${devtype} read ${ramdisk_addr_r} ${devoffs} ${fitblkcnt}; then
setexpr decsqblkcnt fmt %u ${sqblkcnt}
setexpr decsqblknr fmt %u ${sqblknr}
setenv bootargs_root "${bootargs_root} ${decsqblkcnt} linear PARTLABEL=${slot} ${decsqblknr}\""
setenv ramdisk "-"
setenv prepared ok
fi
fi
+22 -21
View File
@@ -1,26 +1,27 @@
# This is a bit awkward. If you know about a more straight forward way
# of doing this, please simplify.
#
# U-Boot needs the public part of the signing key to be preprocessed
# and then inserted into its control DT. mkimage(1) can perform this
# conversion, but only as a side-effect of building/signing an FIT
# image. Since we might not always be doing that, e.g. when only
# building a hardware specific bootloader, we build a dummy FIT just
# to get the key information into a DTB, which we then convert back to
# a .dtsi and install in the U-Boot build tree. This will then be
# built in to the final U-Boot image's control DT via the
# CONFIG_DEVICE_TREE_INCLUDES option (see extras.config).
define uboot-add-pubkey
$(call IXMSG,"Installing trusted key $1")
$(HOST_DIR)/bin/fdt_add_pubkey \
-a sha256,rsa$(shell \
openssl x509 -text -noout -in $1 | \
grep 'Public-Key: ' | \
sed -e 's/.*(\(.*\) bit)/\1/') \
-k $(dir $1) \
-n $(notdir $(basename $1)) \
-r image \
$2
endef
# U-Boot has its own public key format which has to be stored in its
# control DT. So we collect all of the trusted keys, convert them to
# the required format, and write the result to infix-key.dtb in the
# U-Boot build tree. This will then be built in to the final U-Boot
# image's control DT via the CONFIG_DEVICE_TREE_INCLUDES option (see
# extras.config).
define UBOOT_PRE_BUILD_INSTALL_KEY
@$(call IXMSG,"Installing Infix signing key ($(SIGN_KEY))")
$(HOST_DIR)/bin/dtc <(echo '/dts-v1/; / { signature {}; };') >$(@D)/infix-key.dtb
$(HOST_DIR)/bin/mkimage \
-k $(SIGN_KEY) \
-f $(BR2_EXTERNAL_INFIX_PATH)/board/common/uboot/key-dummy.its \
-K $(@D)/infix-key.dtb \
$(if $(SIGN_SRC_PKCS11),-N pkcs11) \
-r \
$(@D)/key-dummy.itb
rm $(@D)/key-dummy.itb
$(foreach key, \
$(call qstrip,$(TRUSTED_KEYS_DEVELOPMENT_PATH)) $(call qstrip,$(TRUSTED_KEYS_EXTRA_PATH)),\
$(call uboot-add-pubkey,$(key),$(@D)/infix-key.dtb))
$(HOST_DIR)/bin/dtc -I dtb -O dts \
<$(@D)/infix-key.dtb \
| sed -e 's:/dts-v[0-9]\+/;::' >$(@D)/arch/$(UBOOT_ARCH)/dts/infix-key.dtsi
-32
View File
@@ -1,32 +0,0 @@
test-dir := $(BR2_EXTERNAL_INFIX_PATH)/test
INFIX_TESTS ?= $(test-dir)/case/all.yaml
test-env = $(test-dir)/env \
-f $(BINARIES_DIR)/infix-x86_64.img \
-p $(BINARIES_DIR)/infix-x86_64.pkg \
$(1) $(2)
test-env-qeneth = $(call test-env,-q $(test-dir)/virt/quad,$(1))
test-env-run = $(call test-env,-C -t $(BINARIES_DIR)/qemu.dot,$(1))
test test-qeneth:
$(call test-env-qeneth,\
$(BR2_EXTERNAL_INFIX_PATH)/test/9pm/9pm.py \
$(INFIX_TESTS))
test-sh test-qeneth-sh:
$(call test-env-qeneth,-i /bin/sh)
test-run: | ~/.infix-test-venv
$(call test-env-run,\
$(BR2_EXTERNAL_INFIX_PATH)/test/9pm/9pm.py \
$(INFIX_TESTS))
test-run-sh: | ~/.infix-test-venv
$(call test-env-run,/bin/sh)
test-run-play: | ~/.infix-test-venv
$(call test-env-run,$(test-dir)/case/meta/play.py)
~/.infix-test-venv:
$(test-dir)/docker/init-venv.sh $(test-dir)/docker/pip-requirements.txt
.PHONY: test test-sh test-qeneth test-qeneth-sh test-run test-run-sh test-run-play
+6 -1
View File
@@ -1 +1,6 @@
set prefix=(hd0,gpt2)/grub
search -l aux --set=aux
search -l primary --set=primary
search -l secondary --set=secondary
set prefix=($aux)/grub
configfile ($aux)/grub/grub.cfg
+12 -5
View File
@@ -33,17 +33,24 @@ else
set log="loglevel=4"
fi
# From board/common/rootfs/etc/partition-uuid
search -p 107ae911-a97b-4380-975c-7ce1a2dde1e0 --set primary
search -p 352bd9b2-2ca9-44e2-bdc7-edbc87ba1e02 --set secondary
export primary
export secondary
submenu "primary" "$log" {
set slot="$1"
set append="console=ttyS0 root=PARTLABEL=$slot $2"
set root=(hd0,gpt3)
set append="console=ttyS0 console=hvc0 root=PARTLABEL=$slot $2"
set root="($primary)"
source /boot/grub/grub.cfg
}
submenu "secondary" "$log" {
set slot="$1"
set append="console=ttyS0 root=PARTLABEL=$slot $2"
set root=(hd0,gpt4)
set append="console=ttyS0 console=hvc0 root=PARTLABEL=$slot $2"
set root="($secondary)"
source /boot/grub/grub.cfg
}
@@ -56,7 +63,7 @@ submenu "net" "$log" {
set root=(initrd)
set slot="$1"
set append="console=ttyS0 root=/dev/ram0 ramdisk_size=65536 $2"
set append="console=ttyS0 console=hvc0 qroot=/dev/ram0 ramdisk_size=65536 $2"
source /boot/grub/grub.cfg
else
if [ -z "$net_efinet0_dhcp_next_server" ]; then
+15 -6
View File
@@ -13,18 +13,20 @@ BR2_TARGET_GENERIC_ISSUE="Infix by KernelKit"
BR2_INIT_FINIT=y
BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_EUDEV=y
BR2_ROOTFS_DEVICE_TABLE="system/device_table.txt ${BR2_EXTERNAL_INFIX_PATH}/board/common/xattrs"
# BR2_TARGET_ENABLE_ROOT_LOGIN is not set
BR2_SYSTEM_BIN_SH_BASH=y
BR2_TARGET_GENERIC_GETTY_PORT="@console"
BR2_TARGET_GENERIC_GETTY_TERM="xterm"
BR2_SYSTEM_DHCP="eth0"
BR2_ENABLE_LOCALE_WHITELIST="C en_US en_CA"
BR2_GENERATE_LOCALE="en_US en_CA"
BR2_ENABLE_LOCALE_WHITELIST="C en_US en_CA C.UTF-8"
BR2_GENERATE_LOCALE="en_US en_CA C.UTF-8"
BR2_TARGET_TZ_INFO=y
BR2_ROOTFS_OVERLAY="${BR2_EXTERNAL_INFIX_PATH}/board/common/rootfs ${BR2_EXTERNAL_INFIX_PATH}/board/aarch64/rootfs"
BR2_ROOTFS_POST_BUILD_SCRIPT="${BR2_EXTERNAL_INFIX_PATH}/board/common/post-build.sh"
BR2_ROOTFS_POST_IMAGE_SCRIPT="${BR2_EXTERNAL_INFIX_PATH}/board/common/post-image.sh"
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_CUSTOM_VERSION=y
BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.6.22"
BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.6.34"
BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="${BR2_EXTERNAL_INFIX_PATH}/board/aarch64/linux_defconfig"
BR2_LINUX_KERNEL_DTS_SUPPORT=y
@@ -45,7 +47,6 @@ BR2_PACKAGE_EUDEV_RULES_GEN=y
BR2_PACKAGE_GPTFDISK=y
BR2_PACKAGE_GPTFDISK_SGDISK=y
BR2_PACKAGE_MDIO_TOOLS=y
BR2_PACKAGE_MEMTESTER=y
BR2_PACKAGE_RNG_TOOLS=y
BR2_PACKAGE_UBOOT_TOOLS=y
BR2_PACKAGE_UBOOT_TOOLS_FIT_SUPPORT=y
@@ -53,17 +54,18 @@ BR2_PACKAGE_UBOOT_TOOLS_FIT_SIGNATURE_SUPPORT=y
BR2_PACKAGE_UBOOT_TOOLS_FIT_CHECK_SIGN=y
BR2_PACKAGE_UBOOT_TOOLS_MKENVIMAGE=y
BR2_PACKAGE_PYTHON3=y
BR2_PACKAGE_PYTHON_CRYPTOGRAPHY=y
BR2_PACKAGE_PYTHON_GUNICORN=y
BR2_PACKAGE_LIBSSH_OPENSSL=y
BR2_PACKAGE_LIBSSH2=y
BR2_PACKAGE_LIBSSH2_OPENSSL=y
BR2_PACKAGE_LIBXCRYPT=y
BR2_PACKAGE_LIBOPENSSL_BIN=y
BR2_PACKAGE_LIBCURL_CURL=y
BR2_PACKAGE_NETOPEER2_CLI=y
BR2_PACKAGE_NSS_MDNS=y
BR2_PACKAGE_LINUX_PAM=y
BR2_PACKAGE_LIBPAM_RADIUS_AUTH=y
BR2_PACKAGE_ONIGURUMA=y
BR2_PACKAGE_AVAHI=y
BR2_PACKAGE_AVAHI_DAEMON=y
BR2_PACKAGE_AVAHI_DEFAULT_SERVICES=y
BR2_PACKAGE_CHRONY=y
@@ -94,6 +96,7 @@ BR2_PACKAGE_SOCAT=y
BR2_PACKAGE_TCPDUMP=y
BR2_PACKAGE_TRACEROUTE=y
BR2_PACKAGE_ULOGD=y
BR2_PACKAGE_WHOIS=y
BR2_PACKAGE_BASH_COMPLETION=y
BR2_PACKAGE_SUDO=y
BR2_PACKAGE_TTYD=y
@@ -129,6 +132,7 @@ INFIX_SUPPORT="mailto:kernelkit@googlegroups.com"
BR2_PACKAGE_CONFD=y
BR2_PACKAGE_CURIOS_HTTPD=y
BR2_PACKAGE_EXECD=y
BR2_PACKAGE_GENCERT=y
BR2_PACKAGE_STATD=y
BR2_PACKAGE_FACTORY=y
BR2_PACKAGE_FINIT_PLUGIN_HOTPLUG=y
@@ -141,6 +145,7 @@ BR2_PACKAGE_IITO=y
BR2_PACKAGE_K8S_LOGGER=y
BR2_PACKAGE_KEYACK=y
BR2_PACKAGE_KLISH_PLUGIN_INFIX=y
BR2_PACKAGE_LANDING=y
BR2_PACKAGE_LOWDOWN=y
BR2_PACKAGE_MCD=y
BR2_PACKAGE_MDNS_ALIAS=y
@@ -150,7 +155,11 @@ BR2_PACKAGE_PODMAN_DRIVER_BTRFS=y
BR2_PACKAGE_PODMAN_DRIVER_DEVICEMAPPER=y
BR2_PACKAGE_PODMAN_DRIVER_VFS=y
BR2_PACKAGE_TETRIS=y
BR2_PACKAGE_ROUSETTE=y
BR2_PACKAGE_LIBINPUT=y
BR2_PACKAGE_HOST_PYTHON_YANGDOC=y
DISK_IMAGE_BOOT_BIN=y
TRUSTED_KEYS=y
TRUSTED_KEYS_DEVELOPMENT=y
GNS3_APPLIANCE_RAM=512
GNS3_APPLIANCE_IFNUM=10
+34
View File
@@ -0,0 +1,34 @@
BR2_aarch64=y
BR2_cortex_a72=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
BR2_DL_DIR="$(BR2_EXTERNAL_INFIX_PATH)/dl"
BR2_CCACHE=y
BR2_CCACHE_DIR="$(BR2_EXTERNAL_INFIX_PATH)/.ccache"
BR2_ENABLE_DEBUG=y
BR2_PACKAGE_OVERRIDE_FILE="$(BR2_EXTERNAL_INFIX_PATH)/local.mk"
BR2_GLOBAL_PATCH_DIR="$(BR2_EXTERNAL_INFIX_PATH)/patches"
BR2_SSP_NONE=y
BR2_INIT_NONE=y
BR2_SYSTEM_BIN_SH_NONE=y
BR2_ROOTFS_POST_IMAGE_SCRIPT="${BR2_EXTERNAL_INFIX_PATH}/board/common/post-image.sh"
# BR2_PACKAGE_BUSYBOX is not set
# BR2_PACKAGE_IFUPDOWN_SCRIPTS is not set
# BR2_TARGET_ROOTFS_TAR is not set
BR2_TARGET_UBOOT=y
BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG=y
BR2_TARGET_UBOOT_CUSTOM_VERSION=y
BR2_TARGET_UBOOT_CUSTOM_VERSION_VALUE="2023.07.02"
BR2_TARGET_UBOOT_BOARD_DEFCONFIG="qemu_arm64"
BR2_TARGET_UBOOT_CONFIG_FRAGMENT_FILES="$(BR2_EXTERNAL_INFIX_PATH)/board/common/uboot/extras.config"
BR2_TARGET_UBOOT_FORMAT_DTB=y
BR2_PACKAGE_HOST_GENIMAGE=y
BR2_PACKAGE_HOST_RAUC=y
BR2_PACKAGE_HOST_UBOOT_TOOLS=y
BR2_PACKAGE_HOST_UBOOT_TOOLS_FIT_SUPPORT=y
BR2_PACKAGE_HOST_UBOOT_TOOLS_FIT_SIGNATURE_SUPPORT=y
TRUSTED_KEYS=y
TRUSTED_KEYS_DEVELOPMENT=y
DISK_IMAGE_BOOT_BIN=y
DISK_IMAGE_BOOT_DATA="${BINARIES_DIR}/flash-image.bin"
DISK_IMAGE_BOOT_OFFSET=0x00200000
+4 -2
View File
@@ -16,6 +16,8 @@ BR2_ROOTFS_POST_IMAGE_SCRIPT="${BR2_EXTERNAL_INFIX_PATH}/board/common/post-image
# BR2_PACKAGE_IFUPDOWN_SCRIPTS is not set
# BR2_TARGET_ROOTFS_TAR is not set
BR2_TARGET_ARM_TRUSTED_FIRMWARE=y
BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_VERSION=y
BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_VERSION_VALUE="v2.9"
BR2_TARGET_ARM_TRUSTED_FIRMWARE_PLATFORM="t9130"
BR2_TARGET_ARM_TRUSTED_FIRMWARE_FIP=y
BR2_TARGET_ARM_TRUSTED_FIRMWARE_UBOOT_AS_BL33=y
@@ -36,8 +38,8 @@ BR2_PACKAGE_HOST_RAUC=y
BR2_PACKAGE_HOST_UBOOT_TOOLS=y
BR2_PACKAGE_HOST_UBOOT_TOOLS_FIT_SUPPORT=y
BR2_PACKAGE_HOST_UBOOT_TOOLS_FIT_SIGNATURE_SUPPORT=y
# SIGN_ENABLED is not set
DISK_IMAGE=y
TRUSTED_KEYS=y
TRUSTED_KEYS_DEVELOPMENT=y
DISK_IMAGE_BOOT_BIN=y
DISK_IMAGE_BOOT_DATA="${BINARIES_DIR}/flash-image.bin"
DISK_IMAGE_BOOT_OFFSET=0x00200000
+14 -10
View File
@@ -13,22 +13,22 @@ BR2_TARGET_GENERIC_HOSTNAME="infix"
BR2_TARGET_GENERIC_ISSUE="Infix by KernelKit"
BR2_INIT_FINIT=y
BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_EUDEV=y
BR2_ROOTFS_DEVICE_TABLE="system/device_table.txt ${BR2_EXTERNAL_INFIX_PATH}/board/common/xattrs ${BR2_EXTERNAL_INFIX_PATH}/board/netconf/xattrs"
BR2_ROOTFS_DEVICE_TABLE="system/device_table.txt ${BR2_EXTERNAL_INFIX_PATH}/board/common/xattrs"
# BR2_TARGET_ENABLE_ROOT_LOGIN is not set
BR2_SYSTEM_BIN_SH_BASH=y
BR2_TARGET_GENERIC_GETTY_PORT="@console"
BR2_TARGET_GENERIC_GETTY_TERM="xterm"
BR2_SYSTEM_DHCP="eth0"
BR2_ENABLE_LOCALE_WHITELIST="C en_US en_CA"
BR2_GENERATE_LOCALE="en_US en_CA"
BR2_ENABLE_LOCALE_WHITELIST="C en_US en_CA C.UTF-8"
BR2_GENERATE_LOCALE="en_US en_CA C.UTF-8"
BR2_TARGET_TZ_INFO=y
BR2_ROOTFS_OVERLAY="${BR2_EXTERNAL_INFIX_PATH}/board/common/rootfs ${BR2_EXTERNAL_INFIX_PATH}/board/aarch64/rootfs ${BR2_EXTERNAL_INFIX_PATH}/board/netconf/rootfs"
BR2_ROOTFS_POST_BUILD_SCRIPT="$(BR2_EXTERNAL_INFIX_PATH)/board/aarch64/r2s/post-build.sh ${BR2_EXTERNAL_INFIX_PATH}/board/common/post-build.sh ${BR2_EXTERNAL_INFIX_PATH}/board/netconf/post-build.sh"
BR2_ROOTFS_OVERLAY="${BR2_EXTERNAL_INFIX_PATH}/board/common/rootfs ${BR2_EXTERNAL_INFIX_PATH}/board/aarch64/rootfs"
BR2_ROOTFS_POST_BUILD_SCRIPT="$(BR2_EXTERNAL_INFIX_PATH)/board/aarch64/r2s/post-build.sh ${BR2_EXTERNAL_INFIX_PATH}/board/common/post-build.sh"
BR2_ROOTFS_POST_IMAGE_SCRIPT="${BR2_EXTERNAL_INFIX_PATH}/board/common/post-image.sh support/scripts/genimage.sh"
BR2_ROOTFS_POST_SCRIPT_ARGS="-c $(BR2_EXTERNAL_INFIX_PATH)/board/aarch64/r2s/genimage.cfg"
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_CUSTOM_VERSION=y
BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.6.22"
BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.6.34"
BR2_LINUX_KERNEL_PATCH="$(BR2_EXTERNAL_INFIX_PATH)/board/aarch64/r2s/rk3328-nanopi-r2s-dts.patch"
BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="$(BR2_EXTERNAL_INFIX_PATH)/board/aarch64/r2s/linux_defconfig"
@@ -64,18 +64,18 @@ BR2_PACKAGE_UBOOT_TOOLS_FIT_SIGNATURE_SUPPORT=y
BR2_PACKAGE_UBOOT_TOOLS_FIT_CHECK_SIGN=y
BR2_PACKAGE_UBOOT_TOOLS_MKENVIMAGE=y
BR2_PACKAGE_PYTHON3=y
BR2_PACKAGE_PYTHON_CRYPTOGRAPHY=y
BR2_PACKAGE_PYTHON_GUNICORN=y
BR2_PACKAGE_CA_CERTIFICATES=y
BR2_PACKAGE_LIBSSH_OPENSSL=y
BR2_PACKAGE_LIBSSH2=y
BR2_PACKAGE_LIBSSH2_OPENSSL=y
BR2_PACKAGE_LIBXCRYPT=y
BR2_PACKAGE_LIBOPENSSL_BIN=y
BR2_PACKAGE_LIBCURL_CURL=y
BR2_PACKAGE_NETOPEER2_CLI=y
BR2_PACKAGE_NSS_MDNS=y
BR2_PACKAGE_LINUX_PAM=y
BR2_PACKAGE_LIBPAM_RADIUS_AUTH=y
BR2_PACKAGE_ONIGURUMA=y
BR2_PACKAGE_AVAHI=y
BR2_PACKAGE_AVAHI_DAEMON=y
BR2_PACKAGE_AVAHI_DEFAULT_SERVICES=y
BR2_PACKAGE_CHRONY=y
@@ -86,7 +86,6 @@ BR2_PACKAGE_FPING=y
BR2_PACKAGE_FRR=y
# BR2_PACKAGE_IFUPDOWN_SCRIPTS is not set
BR2_PACKAGE_IPROUTE2=y
BR2_PACKAGE_IPTABLES=y
BR2_PACKAGE_IPTABLES_NFTABLES=y
BR2_PACKAGE_IPUTILS=y
BR2_PACKAGE_LLDPD=y
@@ -107,6 +106,7 @@ BR2_PACKAGE_SOCAT=y
BR2_PACKAGE_TCPDUMP=y
BR2_PACKAGE_TRACEROUTE=y
BR2_PACKAGE_ULOGD=y
BR2_PACKAGE_WHOIS=y
BR2_PACKAGE_BASH_COMPLETION=y
BR2_PACKAGE_SUDO=y
BR2_PACKAGE_TTYD=y
@@ -159,6 +159,7 @@ INFIX_DOC="https://github.com/kernelkit/infix/tree/main/doc"
INFIX_SUPPORT="mailto:kernelkit@googlegroups.com"
BR2_PACKAGE_CONFD=y
BR2_PACKAGE_EXECD=y
BR2_PACKAGE_GENCERT=y
BR2_PACKAGE_STATD=y
BR2_PACKAGE_FACTORY=y
BR2_PACKAGE_FINIT_PLUGIN_HOTPLUG=y
@@ -171,6 +172,7 @@ BR2_PACKAGE_IITO=y
BR2_PACKAGE_K8S_LOGGER=y
BR2_PACKAGE_KEYACK=y
BR2_PACKAGE_KLISH_PLUGIN_INFIX=y
BR2_PACKAGE_LANDING=y
BR2_PACKAGE_LOWDOWN=y
BR2_PACKAGE_MCD=y
BR2_PACKAGE_MDNS_ALIAS=y
@@ -180,6 +182,8 @@ BR2_PACKAGE_PODMAN_DRIVER_BTRFS=y
BR2_PACKAGE_PODMAN_DRIVER_DEVICEMAPPER=y
BR2_PACKAGE_PODMAN_DRIVER_VFS=y
BR2_PACKAGE_TETRIS=y
BR2_PACKAGE_ROUSETTE=y
BR2_PACKAGE_LIBINPUT=y
BR2_PACKAGE_HOST_PYTHON_YANGDOC=y
# SIGN_ENABLED is not set
# GNS3_APPLIANCE is not set
+14 -6
View File
@@ -17,15 +17,15 @@ BR2_SYSTEM_BIN_SH_BASH=y
BR2_TARGET_GENERIC_GETTY_PORT="@console"
BR2_TARGET_GENERIC_GETTY_TERM="xterm"
BR2_SYSTEM_DHCP="eth0"
BR2_ENABLE_LOCALE_WHITELIST="C en_US en_CA"
BR2_GENERATE_LOCALE="en_US en_CA"
BR2_ENABLE_LOCALE_WHITELIST="C en_US en_CA C.UTF-8"
BR2_GENERATE_LOCALE="en_US en_CA C.UTF-8"
BR2_TARGET_TZ_INFO=y
BR2_ROOTFS_OVERLAY="${BR2_EXTERNAL_INFIX_PATH}/board/common/rootfs ${BR2_EXTERNAL_INFIX_PATH}/board/x86_64/rootfs"
BR2_ROOTFS_POST_BUILD_SCRIPT="board/qemu/x86_64/post-build.sh ${BR2_EXTERNAL_INFIX_PATH}/board/common/post-build.sh"
BR2_ROOTFS_POST_IMAGE_SCRIPT="${BR2_EXTERNAL_INFIX_PATH}/board/common/post-image.sh"
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_CUSTOM_VERSION=y
BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.6.22"
BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.6.34"
BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="${BR2_EXTERNAL_INFIX_PATH}/board/x86_64/linux_defconfig"
BR2_LINUX_KERNEL_INSTALL_TARGET=y
@@ -49,17 +49,18 @@ BR2_PACKAGE_UBOOT_TOOLS_FIT_SIGNATURE_SUPPORT=y
BR2_PACKAGE_UBOOT_TOOLS_FIT_CHECK_SIGN=y
BR2_PACKAGE_UBOOT_TOOLS_MKENVIMAGE=y
BR2_PACKAGE_PYTHON3=y
BR2_PACKAGE_PYTHON_CRYPTOGRAPHY=y
BR2_PACKAGE_PYTHON_GUNICORN=y
BR2_PACKAGE_LIBSSH_OPENSSL=y
BR2_PACKAGE_LIBSSH2=y
BR2_PACKAGE_LIBSSH2_OPENSSL=y
BR2_PACKAGE_LIBXCRYPT=y
BR2_PACKAGE_LIBOPENSSL_BIN=y
BR2_PACKAGE_LIBCURL_CURL=y
BR2_PACKAGE_NETOPEER2_CLI=y
BR2_PACKAGE_NSS_MDNS=y
BR2_PACKAGE_LINUX_PAM=y
BR2_PACKAGE_LIBPAM_RADIUS_AUTH=y
BR2_PACKAGE_ONIGURUMA=y
BR2_PACKAGE_AVAHI=y
BR2_PACKAGE_AVAHI_DAEMON=y
BR2_PACKAGE_AVAHI_DEFAULT_SERVICES=y
BR2_PACKAGE_CHRONY=y
@@ -90,6 +91,7 @@ BR2_PACKAGE_SOCAT=y
BR2_PACKAGE_TCPDUMP=y
BR2_PACKAGE_TRACEROUTE=y
BR2_PACKAGE_ULOGD=y
BR2_PACKAGE_WHOIS=y
BR2_PACKAGE_BASH_COMPLETION=y
BR2_PACKAGE_SUDO=y
BR2_PACKAGE_TTYD=y
@@ -112,7 +114,7 @@ BR2_TARGET_ROOTFS_SQUASHFS=y
BR2_TARGET_EDK2=y
BR2_TARGET_GRUB2=y
BR2_TARGET_GRUB2_X86_64_EFI=y
BR2_TARGET_GRUB2_BUILTIN_MODULES_EFI="boot linux ext2 squash4 part_gpt normal efi_gop configfile loadenv test echo reboot net efinet tftp loopback"
BR2_TARGET_GRUB2_BUILTIN_MODULES_EFI="boot linux ext2 squash4 part_gpt normal efi_gop configfile loadenv test echo reboot net efinet tftp loopback cat search"
BR2_TARGET_GRUB2_BUILTIN_CONFIG_EFI="${BR2_EXTERNAL_INFIX_PATH}/board/x86_64/grub-embed.cfg"
BR2_TARGET_GRUB2_INSTALL_TOOLS=y
BR2_PACKAGE_HOST_DOSFSTOOLS=y
@@ -133,6 +135,7 @@ INFIX_SUPPORT="mailto:kernelkit@googlegroups.com"
BR2_PACKAGE_CONFD=y
BR2_PACKAGE_CURIOS_HTTPD=y
BR2_PACKAGE_EXECD=y
BR2_PACKAGE_GENCERT=y
BR2_PACKAGE_STATD=y
BR2_PACKAGE_FACTORY=y
BR2_PACKAGE_FINIT_PLUGIN_HOTPLUG=y
@@ -145,6 +148,7 @@ BR2_PACKAGE_IITO=y
BR2_PACKAGE_K8S_LOGGER=y
BR2_PACKAGE_KEYACK=y
BR2_PACKAGE_KLISH_PLUGIN_INFIX=y
BR2_PACKAGE_LANDING=y
BR2_PACKAGE_LOWDOWN=y
BR2_PACKAGE_MCD=y
BR2_PACKAGE_MDNS_ALIAS=y
@@ -154,5 +158,9 @@ BR2_PACKAGE_PODMAN_DRIVER_BTRFS=y
BR2_PACKAGE_PODMAN_DRIVER_DEVICEMAPPER=y
BR2_PACKAGE_PODMAN_DRIVER_VFS=y
BR2_PACKAGE_TETRIS=y
BR2_PACKAGE_ROUSETTE=y
BR2_PACKAGE_HOST_PYTHON_YANGDOC=y
TRUSTED_KEYS=y
TRUSTED_KEYS_DEVELOPMENT=y
GNS3_APPLIANCE_RAM=512
GNS3_APPLIANCE_IFNUM=10
+238 -23
View File
@@ -4,23 +4,176 @@ Change Log
All notable changes to the project are documented in this file.
[v24.03.0][UNRELEASED]
[v24.06.0][] - 2024-06-28
-------------------------
Please note, as of this release the Infix Classic variant has been
dropped. This was the legacy, pre-NETCONF, Infix with manual config of
the system using a persistent `/etc`. It may be resurrected later as a
separate project. Going forward Infix' focus is entirely on NETCONF.
> Development in progress, for daily updates see the team board:
> <https://github.com/orgs/kernelkit/projects/3/views/2>
> **Note:** this release contains **breaking changes** in YANG models
> that are incompatible with existing configuration files. So, after
> upgrade, but before reboot, a factory reset is required!
### Changes
- Bump the base Linux kernel version to 6.6
- Upgrade Buildroot to 2024.02.3 (LTS)
- Upgrade Linux kernel to 6.6.34 (LTS)
- Upgrade bundled curiOS httpd container to v24.05.0
- Default web landing page refactored into a Buildroot package to make
it possible to overload from customer repos.
- Enable DCB support in aarch64 kernel (for EtherType prio override)
- Topology mapper improvements, including option for deterministic
reproduction of logical to physical mappings
- New version of `gencert` tool, for self signed HTTPS certificates.
This allows dropping dependency on building a host rust toolchain
- Issue #374: add timestamps to dagger .log files
- Add small delay in U-Boot to allow stopping boot on reference boards
- Document how to provision the bootloader and Infix on a blank board
- Use initial hostname from `/etc/os-release` as configuration fallback
- Update documentation for use of VETH pairs in containers
- Issue #454: create bridges in `factory-config` with IGMP/MLD snooping
enabled by default
- The following YANG models have been updated to newer draft versions:
`ietf-crypto-types`, `ietf-keystore`, `ietf-netconf-server`, `ietf-ssh-common`,
`ietf-ssh-server`, `ietf-tcp-client`, `ietf-tcp-common`, `ietf-tcp-server`,
`ietf-tcp-server`, `ietf-tcp-server`, `ietf-tcp-server`.
In these there are a lot of breaking changes, most likely
you will need to redo your configuration from `factory-config`.
- The Augeas package has been dropped, so `augtool` is no longer available
- VLAN interfaces can now map the incoming PCP value to the
kernel-internal priority on ingress, and perform the reverse mapping
on egress.
- `mv88e6xxx` ports can now use Linux's priority information to select
the appropriate egress queue, via the `mqprio` queuing discipline.
- Add logging of output from container start/stop action
- Clean up stale directories after OCI container archive import
- Add support for `show leaf-node` in CLI configure context
- Allow non-admin users to use the CLI. NACM rules still apply
- Ensure filesystem is sync'ed properly after a CLI `copy` command
- Issue #178: add early boot script to migrate configuration files of
older version to new syntax. Initial, rudimentary support, for the
change in shell types
- Issue #308: add `version` field to configuration file using a new
model, infix-meta.yang. Used to trigger migration from older formats
to newer on future breaking changes
- Issue #432: extract YANG documentation at build time. Part of the
release tarballs is now `yangdoc.html` for the complete tree of all
YANG configuration, operational data, RPCs, and notification nodes
- Issue #435: add support for `$factory$` password hash. This allows
backing up configuration files with device specific passwords. Upon
restore to another device this ensures the replacement's password is
used instead of the originals'
- Issue #435: add support for hostname format specifiers. The default
hostname configuration is now `%h-%m` to encode, `infix-c0-ff-ee`
- Issue #435: support for "empty" NETCONF host keys. Primarily used in
static factory-config setups. When a configuration is detected with
this, the automatically generated, device specific 2048 bit RSA host
key pair is used. With this, vendor/product specific factory-config
is now fully supported. See `src/confd/README.md`
- Issue #447: add support for [yescrypt][], `$y$` hashes. This also
adds support for `$0$cleartext` password according to ietf-system.yang
- Issue #455: split CLI tutorial into multiple files for easy access
from the CLI admin-exec context using the `help` command
- Issue #478: add operational support for ietf-system.yang, reading
actual hostname and passwords after issue #435
- Merge infix-shell-types.yang with infix-system.yang
- cli: improved error/warning message on missing or incomplete command
[yescrypt]: https://en.wikipedia.org/wiki/Yescrypt)
### Fixes
- Fix #424: regression, root user can log in without password
- Fix build regressions in `cn9130_crb_boot_defconfig` caused by upgrade
to Buildroot v2024.02 and recent multi-key support in RAUC and U-Boot
- Fix provisioning script after changes to make GRUB loading more robust
- Fix missing `/etc/resolv.conf`, as noticed by `avahi-daemon`, when a
user calls `no system` from the CLI
- Fix #428: loss of admin account after upgrade to v24.04
- Fix #429: failing to load `startup-config` does not trigger the fail
secure mode, causing the system to end up in an undefined state
- Fix #453: fix inconsistent behavior of custom MAC address (interface
`phys-address` for VETH pairs. Allows fixed MAC in containers
- Fix #462: increase port column width for CLI `show bridge mdb`
- Fix #468: non-admin users can get a POSIX shell as login shell, root
cause was buggy Augeas library, replaced with plain C API.
- Fix #469: non-admin users added to *any* group get administrator
privileges (added to UNIX `wheel` group)
- Fix #473: bridge interface with IPv6 SLAAC never get global prefix
- Fix #476: Custom command for containers not working
- Fix #479: timeout from underlying datastore when disabling containers
in configuration. Only disabling (stopping) container now done in the
configuration change, removal of container done in the background
- Fix locking issue with standard counter groups on `mv88e6xxx`
- Add missing LICENSE hash for factory reset tool
- Fix timeout handling in container restart command
- Fix MDB/ATU synchronization issue from IGMPv3/MLDv2 reports on
`mv88e6xxx` systems
[v24.04.2][] - 2024-05-15
-------------------------
### Changes
- Add small delay in U-Boot to allow stopping boot on reference boards
- Document how to provision the bootloader and Infix on a blank board
- Use initial hostname from `/etc/os-release` as configuration fallback
### Fixes
- Fix build regressions in `cn9130_crb_boot_defconfig` caused by upgrade
to Buildroot v2024.02 and recent multi-key support in RAUC and U-Boot
- Fix provisioning script after changes to make GRUB loading more robust
- Fix missing `/etc/resolv.conf`, as noticed by `avahi-daemon`, when a
user calls `no system` from the CLI
- Fix #428: loss of admin account after upgrade to v24.04
- Fix #429: failing to load `startup-config` does not trigger the fail
secure mode, causing the system to end up in an undefined state
[v24.04.1][] - 2024-05-03
-------------------------
### Changes
- Default web landing page refactored into a Buildroot package to make
it possible to overload from customer repos.
- Enable DCB support in aarch64 kernel (for EtherType prio override)
- Topology mapper improvements, including option for deterministic
reproduction of logical to physical mappings
- New version of `gencert` tool, for self signed HTTPS certificates.
This allows dropping dependency on building a host rust toolchain
- Issue #374: add timestamps to dagger .log files
### Fixes
- Add missing LICENSE hash for factory reset tool
- Fix #424: regression, root user can log in without password
[v24.04.0][] - 2024-04-30
-------------------------
**News:** this release marks the first major upgrade of the underlying
Buildroot to the latest LTS release, v2024.02. This caused a few small
regressions in the release cycle, all known issues have been addressed.
Also worth highlighting, as of this release the Infix Classic variant
has been dropped. It was the legacy Infix with manual configuration of
the system using a persistent `/etc`. May be resurrected later as a
separate project. Going forward Infix' focus is entirely on NETCONF.
Finally, the YANG Status section has been dropped for this release, the
idea is to generate supported features from the models and include in
future releases.
### Changes
- Bump the base Buildroot version to v2024.02 LTS
- Bump the base Linux kernel version to 6.6 LTS
- Drop Classic variant to reduce overhead, simplify build & release
processes, and focus on NETCONF for Arm64 and Amd64 platforms
- Add hostname restrictions to ietf-system, and infix-dhcp-client
models. Max 64 characters on Linux systems
- Add mDNS CNAME (alias) advertisement, e.g., infix.local in addition to
the default infix-c0-ff-ee.local. Note: this is build-specific and
does not change if system hostname is changed
- Add mDNS browser web application, https://network.local that shows all
mDNS devices on the LAN. The network.local mDNS name is also a CNAME,
so with multiple Infix devices, only one will act as the mDNS browser
- Add temporary landing page to web server for https://infix.local
- Add web console using ttyd, https://infix.local:7681
- Add support for disabling web services using CLI
- The bridge model now has built-in validation of port memberships,
i.e., a port must be a bridge member to be used in VLAN filtering
- The bridge model only permits the bridge itself to be a tagged
@@ -28,8 +181,49 @@ separate project. Going forward Infix' focus is entirely on NETCONF.
such bridges is to use a VLAN interface on top
- A VLAN filtering bridge now validates that no IP address has been
set. Use a VLAN interface on top for that (see above)
- Container documentation: CLI prompts have been updated to match the
examples used in other parts of the User Guide
- Restructure documentation, let first page in doc/ be table of contents
- Scripting Infix, new document on how to script Infix from remote,
e.g., for production or from a container
- Introduction, update documentation now that the `admin` user's default
login shell is `/bin/bash`
- System documentation, first outline of how to change hostname, add
users, add system administrator users, changing login banner, change
the system default editor, and more
- Network documentation, add section on VETH pairs
- Container documentation:
- CLI prompts have been updated to match the examples used in other
parts of the User Guide
- Default route example for static container interfaces
- How to upgrade a container image
- As a follow-up to port speed/duplex/autoneg support added in v24.02,
this release ensures flow-control is always disabled on all Ethernet
ports, as described in the IEEE Ethernet interfaces YANG model
- Add support for core dumps, saving them in `/var/crash`, max one dump
per process, for use with future support tarballs
- Add support for multicast snooping, both IPv4 (IGMP) and IPv6 (MLD) in
bridge setups, including offloading to switchdev
- Add support for acting as passive (proxy) or active IGMP querier
- Add support for static multicast filters, MAC, IPv4 and IPv6 groups
are supported -- multicast snooping must be enabled
- Include Buildroot `legal-info` in releases, i.e., licenses, sources
with patches, as well as csv files for packages and toolchain
- Drop `shell` command from CLI to allow confining users
- The CLI `copy` command now allows absolute paths
- Local resolver, `dnsmasq`, had port 53 visible from external `nmap`
scans, even though it dropped non-local requests, it now only binds to
the loopback interface reduce number of externally visible ports
- Kernel log messages, of severity error or higher, now log directly to
the console. This may cause some annoyance but has been enabled to
ease debugging, in particular issues where the system crashes before
the syslog daemon has flushed logs to disk. (Logs are still saved to
log files as well.)
- Issue #325: Add support for multiple administrator users by opening
up basic NETCONF ACM support. See documentation for details
- Any user can be added to the `admin` NACM group
- Any user *not* in the `admin` group is not allowed to have a login
shell other than the CLI (or disabled). POSIX shell, e.g., Bash is
reserved for system administrators
- Issue #327: Remove IPv6LL from bridge port interfaces
- Issue #358: translate YANG model's LOWER-LAYER-DOWN -> LINK-DOWN in
CLI `show interfaces` command
- Issue #360: document factory-config, startup-config, and the various
@@ -41,20 +235,12 @@ separate project. Going forward Infix' focus is entirely on NETCONF.
users to avoid enabling privileged mode
- Issue #367: setting date/time over NETCONF now saves system time also
to the RTC, which otherwise is only saved on reboot or power-down
- Add support for static multicast filters, MAC, IPv4 and IPv6 groups
are supported.
- Include Buildroot `legal-info` in releases, i.e., licenses, sources
with patches, as well as csv files for packages and toolchain
- Issue #369: Remove limitation that the routing instance must be
named 'default'
### Fixes
- Issue #391 Creating VLAN interface in the CLI with "edit interface vlanN"
does not set VLAN id to N.
- confd: Fix memory leak when operating on candidate configuration.
- CLI: fix VLAN inference for interfaces named `eth0.1`, i.e., VID 1 on
lower-layer-if `eth0`. Only affects automatic inference in the CLI,
entering the values manually (CLI/NETCONF) not affected by this bug
- confd: Fix memory leak when operating on candidate configuration
- probe: Fix crash on systems without USB
- Reduced syslog errors for accesses no non-existing xpaths
- Fix bogus warning about not properly updating `/etc/motd` in new
`motd-banner` setting, introduced in v24.02.0
@@ -63,8 +249,16 @@ separate project. Going forward Infix' focus is entirely on NETCONF.
- Fix #328: when setting up a VLAN filtering bridge, the PVID for bridge
ports defaulted to 1, making it impossible to set up "tagged-only"
ports which drop ingressing untagged traffic
- Fix #329: VLAN inference for interfaces named `eth0.1`, i.e., VID 1 on
lower-layer-if `eth0`. Only affects automatic inference in the CLI,
entering the values manually (CLI/NETCONF) not affected by this bug
- Fix #331: inconsistent naming of 'enabled' in infix-routing.yang
- Fix #349: minor changes to `bridge-port` settings, like setting `pvid`
when you forget it, did not take without a reboot
- Fix #353: impossible to remove bridge port with `no bridge-port`
- Fix #358: MAC address no longer shown for bridge interfaces in CLI
`show interfaces` command
- Fix #365: not possible to run `ping` from container
- Fix #366: static routes from container host interfaces do not work.
Documentation updated with an example
- Fix #368: upgrading `oci-archive:/` images fail because system thinks
@@ -74,8 +268,25 @@ separate project. Going forward Infix' focus is entirely on NETCONF.
declare `network` settings, Infix v23.02 had a late regression that
reverted back to the podman default: network behind a CNI bridge
(firewalled and NAT:ed, hidden from the rest of the network)
- Fix #385: segfault in helper function when disabling the DHCP client
- Fix #375: k8s-logger, used for containers, does not exit properly and
causes 100% CPU load when container stop or are restarted. Also in
this issue: handle ip/route additions to container networks at runtime
- Fix #384: segfault in helper function when disabling the DHCP client
using `no dhcp-client` from the CLI
- Fix #391 Creating VLAN interface in the CLI with "edit interface vlanN"
does not set VLAN id to N.
- Fix #404: `lldpd` should be disabled on internal interface `dsa0`
- Fix #406: an overly restrictive `when` expression in the bridge YANG
model prevented users from adding VLAN interfaces as bridge ports.
E.g., creating interface `eth0.10` and adding that to `br0`
- Fix #412: after starting up with DHCP client enabled on any interface
`set dhcp-client enabled false` does not bite at runtime
- Fix #414: spelling error in `infix-hardware.yang`, leaf node `coutry`
- Fix #415: `startup-config` owned by `root` user and group instead of
`admin`. The file ownership is now adjusted on every boot
- Fix #416: `admin` user cannot perform a factory reset with RPC using
`sysrepocfg` tool over SSH
- Fix bogus syslog warning about not updating `/etc/motd` properly
[v24.02.0][] - 2024-03-01
@@ -770,7 +981,11 @@ Supported YANG models in addition to those used by sysrepo and netopeer:
- N/A
[buildroot]: https://buildroot.org/
[UNRELEASED]: https://github.com/kernelkit/infix/compare/v24.02.0...HEAD
[UNRELEASED]: https://github.com/kernelkit/infix/compare/v24.04.0...HEAD
[v24.06.0]: https://github.com/kernelkit/infix/compare/v24.04.0...v24.06.0
[v24.04.2]: https://github.com/kernelkit/infix/compare/v24.04.1...v24.04.2
[v24.04.1]: https://github.com/kernelkit/infix/compare/v24.04.0...v24.04.1
[v24.04.0]: https://github.com/kernelkit/infix/compare/v24.02.0...v24.04.0
[v24.02.0]: https://github.com/kernelkit/infix/compare/v23.11.0...v24.02.0
[v23.11.0]: https://github.com/kernelkit/infix/compare/v23.10.0...v23.11.0
[v23.10.0]: https://github.com/kernelkit/infix/compare/v23.09.0...v23.10.0
+2 -1
View File
@@ -11,8 +11,9 @@ the `help` command.
- **CLI Topics**
- [Introduction to the CLI](cli/introduction.md)
- [CLI User's Guide](cli/tutorial.md)
- [Configuring using the CLI](cli/configure.md)
- [Quick Overview](cli/quick.md)
- [Upgrading the Software](cli/upgrade.md)
- **Infix User Guide**
- [Introduction](introduction.md)
- [System Configuration](system.md)
@@ -1,109 +1,3 @@
User Guide
==========
The command line interface (CLI, see-ell-aye) implements a CISCO-like,
or Juniper Networks JunOS-like, CLI for UNIX systems.
New users always get the CLI as the default "shell" when logging in, but
the default `admin` user logs in to `bash`. To access the CLI, type:
cli
Key commands available in any context are:
help
show
For each command it also possible to press the `?` key and `TAB` to get
more help and suggestions for completion.
> **Note:** for the sake of brevity, the hostname in the following examples
> has been shortened to `host`. The default name is composed from a product
> specific string followed by the last three octets of the system base MAC
> address, e.g., `switch-12-34-56`. An example of how to change the hostname
> is included below.
Admin Exec
----------
The top-level context after logging in and starting the CLI is the
admin-exec or "main" context. It is used for querying system status,
managing configuration files/profiles and doing advanced debugging.
Available commands can be seen by pressing `?` at the prompt:
```
admin@host:/>
configure Create new candidate-config based on running-config
copy Copy configuration, e.g., copy running-config startup-config
exit Exit from CLI (log out)
factory-reset Restore the system to factory default state
follow Monitor a log file, use Ctrl-C to abort
help Help system (also try '?' key)
logout Alias to exit
netcalc IP subnet calculator
password Password tools
ping Ping a network host or multicast group
poweroff Poweroff system (system policy may yield reboot)
reboot Reboot system
set Set operations, e.g., current date/time
shell Enter system shell
show Show system status and configuration files
tcpdump Capture network traffic
upgrade Install a software update bundle
```
To get more help for a given command, type the command, a space, and
then tap `?` again. You can also tap the `Tab` key to see available
argument completions.
### Upgrading the Software
The admin-exec command `upgrade` can be used to install software images, or
bundles. A bundle is a signed and self-contained package that carries all the
information necessary to determine if it holds a bootloader, a Linux image, or
even both.
To install a new software image to the currently *inactive* partition[^1], we
use the `upgrade` command and a URI to a ftp/tftp/sftp or http/https server
that hosts the file:
```
admin@host:/> upgrade tftp://192.168.122.1/firmware-x86_64-v23.11.pkg
installing
0% Installing
0% Determining slot states
20% Determining slot states done.
20% Checking bundle
20% Verifying signature
40% Verifying signature done.
40% Checking bundle done.
40% Checking manifest contents
60% Checking manifest contents done.
60% Determining target install group
80% Determining target install group done.
80% Updating slots
80% Checking slot rootfs.1
90% Checking slot rootfs.1 done.
90% Copying image to rootfs.1
99% Copying image to rootfs.1 done.
99% Updating slots done.
100% Installing done.
Installing `tftp://192.168.122.1/firmware-x86_64-v23.11.pkg` succeeded
admin@host:/>
```
The secondary partition (`rootfs.1`) has now been upgraded and will be used as
the *active* partition on the next boot. Leaving the primary partition, with
the version we are currently running, intact in case of trouble.
[^1]: It is not possible to upgrade the partition we booted from. Thankfully
the underlying "rauc" subsystem keeps track of this. Hence, to upgrade
both partitions you must reboot to the new version (to verify it works)
and then repeat the same command.
Configure Context
-----------------
@@ -382,7 +276,3 @@ is filtered, except LLDP frames as shown above.
> **Note:** the bridge can be named anything, provided the interface
> name is not already taken. However, for any name outside the pattern
> `br[0-9]+`, you have to set the interface type manually to `bridge`.
[1]: https://src.libcode.org/pkun/klish

Some files were not shown because too many files have changed in this diff Show More