From 9dc4487b24dd6da329ee9013cfa9eaef7c826d2b Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Thu, 27 Jun 2024 07:54:58 +0200 Subject: [PATCH 1/7] confd: fix ietf-tcp-common version Signed-off-by: Joachim Wiberg --- src/confd/yang/confd.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/confd/yang/confd.inc b/src/confd/yang/confd.inc index b4e19a5805..6d2fccecd6 100644 --- a/src/confd/yang/confd.inc +++ b/src/confd/yang/confd.inc @@ -4,7 +4,7 @@ MODULES=( "ietf-system@2014-08-06.yang -e authentication -e local-users -e ntp -e ntp-udp-port -e timezone-name" "iana-timezones@2013-11-19.yang" "notifications@2008-07-14.yang" - "ietf-tcp-common@2019-07-02.yang -e keepalives-supported" + "ietf-tcp-common@2023-12-28.yang -e keepalives-supported" "ietf-interfaces@2018-02-20.yang -e if-mib" "ietf-ip@2018-02-22.yang -e ipv6-privacy-autoconf" "ietf-network-instance@2019-01-21.yang" From 867d279f5301f95ed3c2affeb095841a131c14cd Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Wed, 26 Jun 2024 10:08:08 +0200 Subject: [PATCH 2/7] doc: split CLI tutorial into multile files Fixes #455 Signed-off-by: Joachim Wiberg --- doc/README.md | 3 +- doc/cli/{tutorial.md => configure.md} | 110 ------------------------ doc/cli/introduction.md | 116 +++++++++++++++++++++----- doc/cli/netcalc.md | 62 ++++++++++++++ doc/cli/quick.md | 4 +- doc/cli/tcpdump.md | 91 ++++++++++++++++++++ doc/cli/upgrade.md | 45 ++++++++++ src/klish-plugin-infix/xml/infix.xml | 24 +++++- 8 files changed, 317 insertions(+), 138 deletions(-) rename doc/cli/{tutorial.md => configure.md} (70%) create mode 100644 doc/cli/netcalc.md create mode 100644 doc/cli/tcpdump.md create mode 100644 doc/cli/upgrade.md diff --git a/doc/README.md b/doc/README.md index 2d88f69b96..8888f3cf69 100644 --- a/doc/README.md +++ b/doc/README.md @@ -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) diff --git a/doc/cli/tutorial.md b/doc/cli/configure.md similarity index 70% rename from doc/cli/tutorial.md rename to doc/cli/configure.md index bb43b77223..23cad3bb6a 100644 --- a/doc/cli/tutorial.md +++ b/doc/cli/configure.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 diff --git a/doc/cli/introduction.md b/doc/cli/introduction.md index ef7be3a56d..09165c7151 100644 --- a/doc/cli/introduction.md +++ b/doc/cli/introduction.md @@ -1,6 +1,7 @@ # Introduction -The command line interface (CLI, see-ell-i) is the traditional way of +The command line interface (CLI, see-ell-aye) implements a CISCO-like, +or Juniper Networks JunOS-like, CLI. It is the traditional way of interacting with single network equipment like switches and routers. Today more advanced graphical NETCONF-based tools are available that allows for managing entire fleets of installed equipment. @@ -9,34 +10,107 @@ Nevertheless, when it comes to initial deployment and debugging, it is very useful to know how to navigate and use the CLI. This very short guide intends to help you with that. + +## About + +New users usually get the CLI as the default "shell" when logging in, +but the default `admin` user logs in to `bash`. To access the CLI, +type: + +``` +admin@host-12-34-56:~$ cli + +See the 'help' command for an introduction to the system + +admin@host-12-34-56:/> +``` + +The prompt (beginning of the line) changes slightly. Key commands +available in any context are: + +``` +admin@host-12-34-56:/> help # Try: Tab or ? +... +admin@host-12-34-56:/> show # Try: Tab or ? +admin@host-12-34-56:/> # Try: Tab or ? +``` + +> **Tip:** Even on an empty command line you can tap the Tab or ? keys. +> See `help keybindings` for more tips! + + ## Key Concepts The two modes in the CLI are the admin-exec and the configure context. -When logging in to the system, be it from console or SSH, you first have -a stopover in a UNIX shell, usually Bash. Type `cli` to enter the CLI -and finally land in admin-exec. Here you can inspect system status and -do operations to debug networking issues, e.g. ping. You can also enter -configure context by typing: `configure` - -The system has several datastores (or files): - - - `factory-config` consists of a set of default configurations, some - static and others generated per-device, e.g., a unique hostname and - number of ports/interfaces. This file is generated at boot. - - `startup-config` is created from `factory-config` at boot if it does - not exist. It is loaded as the system configuration on each boot. - - `running-config` is what is actively running on the system. If no - changes have been made since the system booted, it is the same as - `startup-config`. +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 file or configuration, e.g., copy running-config startup-config + dir List available configuration files + 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 (try also the '?' key) + logout Alias to exit + netcalc IP subnet calculator, with subnetting + password Password tools + ping Ping a network host or multicast group + poweroff Poweroff system (system policy may yield reboot) + reboot Reboot system + remove Remove a configuration file + set Set operations, e.g., current date/time + show Show system status and configuration files + tcpdump Capture network traffic + upgrade Install a software update bundle from remote or local file +``` + +The system has three *main datastores* (or files): *factory*, *startup*, +and *running* that can be managed and inspected using the `copy`, +`show`, and `configure` commands. The traditional names used in the CLI +for these are listed below: + + - `factory-config` the default configuration from factory for the + device, i.e., what the system returns to after a `factory-reset` + - `startup-config` created from `factory-config` at first boot after + factory reset. Loaded as the system configuration on each boot + - `running-config` what is actively running on the system. If no + changes have been made since boot, it is the same as `startup-config` - `candidate-config` is created from `running-config` when entering the configure context. Any changes made here can be discarded (`abort`, - `rollback`) or committed (`commit`, `leave`) to `running-config`. + `rollback`) or committed (`commit`, `leave`) to `running-config` + +Edit the *running* configuration using the `configure` command. This +copies *running* to *candidate*, a temporary datastore, where changes +are made: + +``` +admin@host-12-34-56:/> configure +admin@host-12-34-56:/config/> ... # Try: Tab or ? +admin@host-12-34-56:/config/> leave +``` + +The `leave` command activates the changes by issuing a transaction to, +essentially, copy the *candidate* back to *running*. Depending on the +changes made, this can take a few seconds. If the changes are invalid, +i.e., not correct according to the underlying YANG models, a warning is +shown and the session remains in configure context. Use the `abort` +command to cancel your changes, or investigate further with the `diff` +command (see more below). -To save configuration changes made to the `running-config` so the system -will use them consecutive reboots, use the `copy` command: +To save configuration changes made to the `running-config` to persistent +store, so the system will use them for consecutive reboots, use the +`copy` command: - admin@host-12-34-56:/> copy running-config startup-config +``` +admin@host-12-34-56:/> copy running-config startup-config +``` In *configure context* the following commands are available: diff --git a/doc/cli/netcalc.md b/doc/cli/netcalc.md new file mode 100644 index 0000000000..ec6e65d432 --- /dev/null +++ b/doc/cli/netcalc.md @@ -0,0 +1,62 @@ +## Usage + +``` +netcalc
[split <1-32 | 64-128>] +``` + +## Description + +`netcalc` is a network calculator that takes an IP address and a subnet +mask, or an IP address and prefix mask in CIDR notation, and then returns +information about the subnet. Both IPv4 and IPv6 is supported. + +A subnet can be entered in two ways: + + - `192.168.2.0 255.255.255.0`: traditional IPv4 'address netmask' style + - `192.168.2.0/24`: modern prefix length, same also for IPv6 + +An optional `split LEN` can be given as argument, the new length value +must be bigger than the current prefix length. See example below. + + +## Examples + +Its most commonly used features are to understand how many addresses an +IP subnet has, what the broadcast address is, first and last *usable* +address. + +``` +admin@example:/> netcalc 192.168.2.0/24 +Address : 192.168.2.0 11000000.10101000.00000010. 00000000 +Netmask : 255.255.255.0 = 24 11111111.11111111.11111111. 00000000 +Wildcard : 0.0.0.255 00000000.00000000.00000000. 11111111 +=> +Network : 192.168.2.0/24 11000000.10101000.00000010. 00000000 +HostMin : 192.168.2.1 11000000.10101000.00000010. 00000001 +HostMax : 192.168.2.254 11000000.10101000.00000010. 11111110 +Broadcast: 192.168.2.255 11000000.10101000.00000010. 11111111 +Hosts/Net: 254 Class C, Private network (RFC1918) +``` + +Another common use-case is for IP subnetting, i.e., using only as many +addresses for an IP subnet as needed. Example, to split the above /24 +in four: + +``` +admin@example:/> netcalc 192.168.2.0/24 split 26 +Address : 192.168.2.0 11000000.10101000.00000010. 00000000 +Netmask : 255.255.255.0 = 24 11111111.11111111.11111111. 00000000 +Wildcard : 0.0.0.255 00000000.00000000.00000000. 11111111 +=> +Network : 192.168.2.0/24 11000000.10101000.00000010. 00000000 +HostMin : 192.168.2.1 11000000.10101000.00000010. 00000001 +HostMax : 192.168.2.254 11000000.10101000.00000010. 11111110 +Broadcast: 192.168.2.255 11000000.10101000.00000010. 11111111 +Hosts/Net: 254 Class C, Private network (RFC1918) + +[Split network/26] +Network : 192.168.2.0 - 192.168.2.63 Netmask : 255.255.255.192 +Network : 192.168.2.64 - 192.168.2.127 Netmask : 255.255.255.192 +Network : 192.168.2.128 - 192.168.2.191 Netmask : 255.255.255.192 +Network : 192.168.2.192 - 192.168.2.255 Netmask : 255.255.255.192 +``` diff --git a/doc/cli/quick.md b/doc/cli/quick.md index 8f5838ba18..c1bdaad8ed 100644 --- a/doc/cli/quick.md +++ b/doc/cli/quick.md @@ -19,9 +19,9 @@ keybindings are really useful to learn! | **Command** | **Description** | |---------------------|--------------------------------------------| | `help introduction` | An introduction to the CLI | -| `help keybindings` | Lists keybindings and other helpful tricks | -| `help tutorial` | The CLI User Guide | +| `help configure` | How to use configure context | | `help text-editor` | Help with the built-in text-editor command | +| `help keybindings` | Lists keybindings and other helpful tricks | > In `configure` context the `help setting` command shows the YANG > description text for each node and container. To reach the admin diff --git a/doc/cli/tcpdump.md b/doc/cli/tcpdump.md new file mode 100644 index 0000000000..c668c5ff7c --- /dev/null +++ b/doc/cli/tcpdump.md @@ -0,0 +1,91 @@ +## Network Traffic Inspection + +`tcpdump` is useful tool for analyzing and diagnosing network problems. +This document presents the limited feature set that exposed is in the +CLI. Administrator level users with shell access can use the full +feature set, and is not described here. + +The following section is useful for understanding how to use the tool. +A section called [Examples](#examples) follows that, which may be what +you want to scroll down to. + + +### Hardware Overview + +Using `tcpdump` effectively requires an understanding of how the +underlying hardware works. For a standard PC, or common single-board +computers (SBC), the network cards (NICs) are usually connected directly +to the CPU. + + .---------. + | +-- eth0 + | CPU | + | +-- eth1 + '---------' + +In this setup it is evident that traffic coming in on either eth0 or +eth1 reach the CPU, i.e., running `tcpdump eth0` captures all traffic. + +However, on other types of networking hardware, e.g., dedicated switch +core setups depicted below, the flow of network traffic will likely +*not* pass through the CPU. This depends of course on how the switch is +set up, for instance if routing between all ports is enabled, each flow +will reach the CPU, but in a plain switching setup it will not. + + .---------. + | | + | CPU | + | | + '----+----' + | + | + .----------+---------. + | | + ---+ +--- + E1 | SC | E3 + ---+ +--- + E2 | | E4 + '--+--+--+--+--+--+--' + | | | | | | + E5 E6 E7 E8 E9 E10 + +So, running `tcpdump e1` in a switching setup, inside the CPU, the only +traffic that will be captured is traffic ingressing port E1 destined for +the CPU itself. To analyze traffic going through the switch, you need +something called *port mirroring*, or *port monitoring*, i.e., setting +up the switch core to mirror traffic ingressing and/or egressing a set +of ports to another port. On this *monitor port* you can then run your +tcpdump, which means you need an external device (laptop). + +> A planned feature is to support mirroring traffic to the CPU port, +> which would be an effective way to log and monitor traffic over a +> longer period of time. Highly effective for diagnosing intermittent +> and other rare network issues. + +If only "proof of life" is required, then sometimes port counters, also +called *RMON counters*, can be very useful too. Seeing counters of a +particular type increment means traffic is ingressing or egressing. + + +### Examples + +Listen to all traffic on an interface: + + admin@example:/> tcpdump e1 + +Listen to only ping traffic: + + admin@example:/> tcpdump e1 expression icmp + +Listen to traffic on a given port: + + admin@example:/> tcpdump e1 expression "port 80" + +Wait for one ping only: + + admin@example:/> tcpdump e1 count 1 expression icmp + +Very verbose output: + + admin@example:/> tcpdump e1 verbose + diff --git a/doc/cli/upgrade.md b/doc/cli/upgrade.md new file mode 100644 index 0000000000..9586da85f5 --- /dev/null +++ b/doc/cli/upgrade.md @@ -0,0 +1,45 @@ +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. diff --git a/src/klish-plugin-infix/xml/infix.xml b/src/klish-plugin-infix/xml/infix.xml index 3c1b605824..3cf3409f78 100644 --- a/src/klish-plugin-infix/xml/infix.xml +++ b/src/klish-plugin-infix/xml/infix.xml @@ -123,10 +123,14 @@ + configure introduction keybindings + netcalc + quick + tcpdump text-editor - tutorial + upgrade @@ -135,7 +139,7 @@ if [ -f "$fn" ]; then lowdown -t term --term-vmargin=1 "$fn" else - echo "Topic not available." + echo "Help topic not available, try help without an argument, or tap '?' for a list." fi @@ -431,10 +435,22 @@ - + - netcalc $KLISH_PARAM_addrlen $KLISH_PARAM_netmask + + + if [ -n "$KLISH_PARAM_split" ]; then + if echo $KLISH_PARAM_addrlen |grep -q ':'; then + split="-S $KLISH_PARAM_split" + else + split="-s $KLISH_PARAM_split" + fi + else + split="" + fi + netcalc $split $KLISH_PARAM_addrlen $KLISH_PARAM_netmask + From 3307aac5d98e9405b3e2f7ad6d9f95b266207682 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Fri, 28 Jun 2024 07:59:34 +0200 Subject: [PATCH 3/7] package/confd: drop empty help text This silences an annoying warning at defconfig/oldconfig about MD5CRYPT. Signed-off-by: Joachim Wiberg --- package/confd/Config.in | 1 - 1 file changed, 1 deletion(-) diff --git a/package/confd/Config.in b/package/confd/Config.in index 1b469ce850..984d7cdaba 100644 --- a/package/confd/Config.in +++ b/package/confd/Config.in @@ -26,7 +26,6 @@ choice config BR2_PACKAGE_CONFD_MD5CRYPT bool "md5crypt" - help config BR2_PACKAGE_CONFD_SHA256CRYPT bool "sha256crypt" From 81be278ae24f0a591fecc5bc9df5672829503a3e Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Fri, 28 Jun 2024 07:50:20 +0200 Subject: [PATCH 4/7] package/python-libyang: new package Signed-off-by: Joachim Wiberg --- Config.in | 6 +----- package/Config.in | 4 +++- package/Config.in.host | 3 +++ package/python-libyang/Config.in | 8 ++++++++ package/python-libyang/Config.in.host | 7 +++++++ package/python-libyang/python-libyang.hash | 5 +++++ package/python-libyang/python-libyang.mk | 15 +++++++++++++++ 7 files changed, 42 insertions(+), 6 deletions(-) create mode 100644 package/Config.in.host create mode 100644 package/python-libyang/Config.in create mode 100644 package/python-libyang/Config.in.host create mode 100644 package/python-libyang/python-libyang.hash create mode 100644 package/python-libyang/python-libyang.mk diff --git a/Config.in b/Config.in index 5511be7c29..62def07376 100644 --- a/Config.in +++ b/Config.in @@ -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" diff --git a/package/Config.in b/package/Config.in index 9b5dbd55d4..500f2ef883 100644 --- a/package/Config.in +++ b/package/Config.in @@ -1,3 +1,4 @@ +menu "Packages" source "$BR2_EXTERNAL_INFIX_PATH/package/confd/Config.in" source "$BR2_EXTERNAL_INFIX_PATH/package/curios-httpd/Config.in" source "$BR2_EXTERNAL_INFIX_PATH/package/execd/Config.in" @@ -21,6 +22,7 @@ source "$BR2_EXTERNAL_INFIX_PATH/package/mcd/Config.in" source "$BR2_EXTERNAL_INFIX_PATH/package/mdns-alias/Config.in" source "$BR2_EXTERNAL_INFIX_PATH/package/netbrowse/Config.in" source "$BR2_EXTERNAL_INFIX_PATH/package/podman/Config.in" +source "$BR2_EXTERNAL_INFIX_PATH/package/python-libyang/Config.in" source "$BR2_EXTERNAL_INFIX_PATH/package/python-statd/Config.in" source "$BR2_EXTERNAL_INFIX_PATH/package/skeleton-init-finit/Config.in" source "$BR2_EXTERNAL_INFIX_PATH/package/tetris/Config.in" @@ -28,4 +30,4 @@ source "$BR2_EXTERNAL_INFIX_PATH/package/libyang-cpp/Config.in" source "$BR2_EXTERNAL_INFIX_PATH/package/sysrepo-cpp/Config.in" source "$BR2_EXTERNAL_INFIX_PATH/package/rousette/Config.in" source "$BR2_EXTERNAL_INFIX_PATH/package/nghttp2-asio/Config.in" - +endmenu diff --git a/package/Config.in.host b/package/Config.in.host new file mode 100644 index 0000000000..ba2ea03d2d --- /dev/null +++ b/package/Config.in.host @@ -0,0 +1,3 @@ +menu "Host utilities" +source "$BR2_EXTERNAL_INFIX_PATH/package/python-libyang/Config.in.host" +endmenu diff --git a/package/python-libyang/Config.in b/package/python-libyang/Config.in new file mode 100644 index 0000000000..8cf43d7d54 --- /dev/null +++ b/package/python-libyang/Config.in @@ -0,0 +1,8 @@ +config BR2_PACKAGE_PYTHON_LIBYANG + bool "python-libyang" + select BR2_PACKAGE_PYTHON_PIP # buildtime + select BR2_PACKAGE_PYTHON_CFFI # runtime + help + CFFI bindings to libyang. + + https://github.com/CESNET/libyang-python diff --git a/package/python-libyang/Config.in.host b/package/python-libyang/Config.in.host new file mode 100644 index 0000000000..6538ca49da --- /dev/null +++ b/package/python-libyang/Config.in.host @@ -0,0 +1,7 @@ +config BR2_PACKAGE_HOST_PYTHON_LIBYANG + bool "host python-libyang" + select BR2_PACKAGE_HOST_PYTHON_CFFI # runtime + help + CFFI bindings to libyang. + + https://github.com/CESNET/libyang-python diff --git a/package/python-libyang/python-libyang.hash b/package/python-libyang/python-libyang.hash new file mode 100644 index 0000000000..9c9897ed70 --- /dev/null +++ b/package/python-libyang/python-libyang.hash @@ -0,0 +1,5 @@ +# md5, sha256 from https://pypi.org/pypi/libyang/json +md5 46332891cac852441b523f7e71a507f7 libyang-3.0.1.tar.gz +sha256 57f8b234131fb073518313351288194e535d74cc8fdff7f0ff7e31c0ab33e663 libyang-3.0.1.tar.gz +# Locally computed sha256 checksums +sha256 c8d554f918d32b1467f35829e1cfb753764dd683c6edcecc877a4d7e9f05b2a7 LICENSE diff --git a/package/python-libyang/python-libyang.mk b/package/python-libyang/python-libyang.mk new file mode 100644 index 0000000000..3e50c8c278 --- /dev/null +++ b/package/python-libyang/python-libyang.mk @@ -0,0 +1,15 @@ +################################################################################ +# +# python-libyang +# +################################################################################ + +PYTHON_LIBYANG_VERSION = 3.0.1 +PYTHON_LIBYANG_SOURCE = libyang-$(PYTHON_LIBYANG_VERSION).tar.gz +PYTHON_LIBYANG_SITE = https://files.pythonhosted.org/packages/91/2e/ff13ee16c874d232d5d3fdff83f629cbc9ac47f9aaf2b59256b6a1bdbc16 +PYTHON_LIBYANG_SETUP_TYPE = setuptools +PYTHON_LIBYANG_LICENSE = MIT +PYTHON_LIBYANG_LICENSE_FILES = LICENSE +HOST_PYTHON_LIBYANG_DEPENDENCIES = host-python-cython host-python-cffi + +$(eval $(host-python-package)) From 6936a0e7b593660ba5ca18c5bafeb36a613a6e83 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Thu, 27 Jun 2024 14:23:26 +0200 Subject: [PATCH 5/7] 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 --- package/Config.in | 1 + package/Config.in.host | 1 + package/python-yangdoc/Config.in | 9 +++++++++ package/python-yangdoc/Config.in.host | 9 +++++++++ package/python-yangdoc/python-yangdoc.hash | 5 +++++ package/python-yangdoc/python-yangdoc.mk | 15 +++++++++++++++ 6 files changed, 40 insertions(+) create mode 100644 package/python-yangdoc/Config.in create mode 100644 package/python-yangdoc/Config.in.host create mode 100644 package/python-yangdoc/python-yangdoc.hash create mode 100644 package/python-yangdoc/python-yangdoc.mk diff --git a/package/Config.in b/package/Config.in index 500f2ef883..5b03bf6e50 100644 --- a/package/Config.in +++ b/package/Config.in @@ -24,6 +24,7 @@ source "$BR2_EXTERNAL_INFIX_PATH/package/netbrowse/Config.in" source "$BR2_EXTERNAL_INFIX_PATH/package/podman/Config.in" source "$BR2_EXTERNAL_INFIX_PATH/package/python-libyang/Config.in" source "$BR2_EXTERNAL_INFIX_PATH/package/python-statd/Config.in" +source "$BR2_EXTERNAL_INFIX_PATH/package/python-yangdoc/Config.in" source "$BR2_EXTERNAL_INFIX_PATH/package/skeleton-init-finit/Config.in" source "$BR2_EXTERNAL_INFIX_PATH/package/tetris/Config.in" source "$BR2_EXTERNAL_INFIX_PATH/package/libyang-cpp/Config.in" diff --git a/package/Config.in.host b/package/Config.in.host index ba2ea03d2d..aa28d8a0d5 100644 --- a/package/Config.in.host +++ b/package/Config.in.host @@ -1,3 +1,4 @@ menu "Host utilities" source "$BR2_EXTERNAL_INFIX_PATH/package/python-libyang/Config.in.host" +source "$BR2_EXTERNAL_INFIX_PATH/package/python-yangdoc/Config.in.host" endmenu diff --git a/package/python-yangdoc/Config.in b/package/python-yangdoc/Config.in new file mode 100644 index 0000000000..ff13e821a6 --- /dev/null +++ b/package/python-yangdoc/Config.in @@ -0,0 +1,9 @@ +config BR2_PACKAGE_PYTHON_YANGDOC + bool "python-yangdoc" + select BR2_PACKAGE_PYTHON_LIBYANG #runtime + help + YANG documentation viewer based on libyang, similar output to + that of pyang -f jstree. The default output is a standalone + HTML file, called yangtree.html + + https://pypi.org/project/yangdoc/ diff --git a/package/python-yangdoc/Config.in.host b/package/python-yangdoc/Config.in.host new file mode 100644 index 0000000000..4c353bd815 --- /dev/null +++ b/package/python-yangdoc/Config.in.host @@ -0,0 +1,9 @@ +config BR2_PACKAGE_HOST_PYTHON_YANGDOC + bool "host python-yangdoc" + select BR2_PACKAGE_HOST_PYTHON_LIBYANG #runtime + help + YANG documentation viewer based on libyang, similar output to + that of pyang -f jstree. The default output is a standalone + HTML file, called yangtree.html + + https://pypi.org/project/yangdoc/ diff --git a/package/python-yangdoc/python-yangdoc.hash b/package/python-yangdoc/python-yangdoc.hash new file mode 100644 index 0000000000..6506962ed0 --- /dev/null +++ b/package/python-yangdoc/python-yangdoc.hash @@ -0,0 +1,5 @@ +# md5, sha256 from https://pypi.org/pypi/yangdoc/json +md5 9fe18b73870676c7f7f6a9311b531f97 yangdoc-0.4.0.tar.gz +sha256 f7a311c3c58859f33c85342b92947124bf4696015db0816f4324cf1663ebc007 yangdoc-0.4.0.tar.gz +# Locally computed sha256 checksums +sha256 0d642b9805375b12da79c64386bbae4221c7759c2c580ada01d5458ed9c8e37c LICENSE diff --git a/package/python-yangdoc/python-yangdoc.mk b/package/python-yangdoc/python-yangdoc.mk new file mode 100644 index 0000000000..cb365938d8 --- /dev/null +++ b/package/python-yangdoc/python-yangdoc.mk @@ -0,0 +1,15 @@ +################################################################################ +# +# python-yangdoc +# +################################################################################ + +PYTHON_YANGDOC_VERSION = 0.4.0 +PYTHON_YANGDOC_SOURCE = yangdoc-$(PYTHON_YANGDOC_VERSION).tar.gz +PYTHON_YANGDOC_SITE = https://files.pythonhosted.org/packages/75/83/a426dcb6f9c56b3cfc70c49040a7ea76c6e9be8ed86026eb6b5942dcb03a +PYTHON_YANGDOC_SETUP_TYPE = setuptools +PYTHON_YANGDOC_LICENSE = MIT +PYTHON_YANGDOC_LICENSE_FILES = LICENSE +HOST_PYTHON_LIBYANG_DEPENDENCIES = host-python-cython host-python-cffi host-python-libyang + +$(eval $(host-python-package)) From b4b96589c1dd683567c9ef2a5bf40fb2936d29d2 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Fri, 28 Jun 2024 07:50:39 +0200 Subject: [PATCH 6/7] 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 --- board/common/post-build.sh | 36 ++++++++++++++++++++++++++++++++++++ configs/aarch64_defconfig | 1 + configs/r2s_defconfig | 1 + configs/x86_64_defconfig | 1 + 4 files changed, 39 insertions(+) diff --git a/board/common/post-build.sh b/board/common/post-build.sh index 21e938635d..807990a85c 100755 --- a/board/common/post-build.sh +++ b/board/common/post-build.sh @@ -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 <> "$TARGET_DIR/etc/shells" + +# Create YANG documentation +if [ "$BR2_PACKAGE_HOST_PYTHON_YANGDOC" = "y" ]; then + mkyangdoc "$BINARIES_DIR/yangdoc.html" +fi diff --git a/configs/aarch64_defconfig b/configs/aarch64_defconfig index 5d5351d3ee..d26e23bd02 100644 --- a/configs/aarch64_defconfig +++ b/configs/aarch64_defconfig @@ -157,6 +157,7 @@ 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 diff --git a/configs/r2s_defconfig b/configs/r2s_defconfig index c827362493..3b5d585536 100644 --- a/configs/r2s_defconfig +++ b/configs/r2s_defconfig @@ -184,5 +184,6 @@ 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 diff --git a/configs/x86_64_defconfig b/configs/x86_64_defconfig index e37dcaebdd..600deceae3 100644 --- a/configs/x86_64_defconfig +++ b/configs/x86_64_defconfig @@ -159,6 +159,7 @@ 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 From e5709c84f1920605eb1895cc886862fc4fec1b97 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Fri, 28 Jun 2024 08:15:29 +0200 Subject: [PATCH 7/7] doc: update ChangeLog, final update for v24.06.0-rc1 Signed-off-by: Joachim Wiberg --- doc/ChangeLog.md | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/doc/ChangeLog.md b/doc/ChangeLog.md index 4ae1fe5f92..6e0b37b634 100644 --- a/doc/ChangeLog.md +++ b/doc/ChangeLog.md @@ -4,8 +4,8 @@ Change Log All notable changes to the project are documented in this file. -[v24.06.0][UNRELEASED] ----------------------- +[v24.06.0][] - 2024-06-28 +------------------------- > **Note:** this release contains **breaking changes** in YANG models > that are incompatible with existing configuration files. So, after @@ -49,15 +49,27 @@ All notable changes to the project are documented in this file. - 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 ietf-system.yang to be able to - detect the configuration file version. +- 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 #447: add support for [yescrypt][], `$y$` hashes +- 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