Commit Graph
260 Commits
Author SHA1 Message Date
Joachim WibergandTobias Waldekranz f40e747fbd statd: drop extra \n, not needed
The idea is to 1) map debug/error macros to syslog(), which does not
need \n, and 2) when stdout logging is used, let the macro add a \n.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-08-07 00:28:04 +02:00
Joachim WibergandTobias Waldekranz db813bd623 klinfix: add CLI support for set datetime 2023-07-03T16:06:34+02:00
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-08-06 23:58:59 +02:00
Joachim WibergandTobias Waldekranz 6dafda072a klinfix: add klix_rpc() for poweroff and reboot CLI commands
This change allows us to verify common RPC commands from within the
CLI, starting with the poweroff and reboot commands.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-08-06 23:58:59 +02:00
Richard AlpeandJoachim Wiberg a9317901c3 statd: add support for additional operstates
Add support for yang link state "lower-layer-down" and "not-present".

Signed-off-by: Richard Alpe <richard@bit42.se>
2023-08-02 11:11:19 +02:00
Jon-Olov VatnandJoachim Wiberg 76c09ba3bd Timezone names as enumerated strings defined by IANA
Use timezone names defined in iana-timezones.yang, replacing
the type 'string' in standard ietf-system.yang

This enables CLI (tab complete) and NETCONF clients (dropdown)
to view available timezone strings, and the yang engine to
validate the input.
2023-07-12 08:51:27 +02:00
Jon-Olov VatnandJoachim Wiberg a43bdd94ab Limit username length and pattern in system yang model
Deviation in ietf-system.yang
'replace' username type from general string to a string
with length and pattern restrictions inline with the
BusyBox 'adduser' tool.

Note, chk_sr_user_update is more restrictive, which should
be handled.
2023-07-12 08:51:27 +02:00
Jon-Olov VatnandJoachim Wiberg 5c4982e388 Specify deviations for optional features (ietf-systems.yang)
Declaring deviations for optional features for clarity regaring
extent of support.

New revision and file of infix-systems created, as earlier version
was included in infix-2023.06 release.
Please see infix-systems@2023-04-11 for history.

Support and deviations has not been checked for the included
'sub-yang-module' infix-systems-software, thus there may be
more updates to come.
2023-07-12 08:51:27 +02:00
Richard AlpeandJoachim Wiberg b3213c6228 statd: break out operational status into new daemon
This patch does two main things:
1) Breaks "statd" free from "confd".
2) Introduces netlink monitoring of interfaces for sysrepo data.

Prior to this patch, sysrepo operation status was handled by code
named "statd" inside "confd". (Where confd is a sysrepo-plugin and
not a real daemon, which its name implies)

In this patch, we break out the interface part of the operational
sysrepo status, previously "statd", into a new daemon, also called
"statd".

The main reason for doing this is to avoid sysrepo threading, which
allows the new "statd" to have control over sysrepo events in the
same event pool as netlink events from the kernel. This in turn allows
statd to subscribe and unsubscribe dynamically to interfaces that
comes and goes during runtime (such as vlans).

It also makes sense that "statd" is in fact a finit daemon.

Signed-off-by: Richard Alpe <richard@bit42.se>
2023-07-04 17:43:16 +02:00
Joachim WibergandRichard Alpe de24d0389a package: relocate PROFINET packages to customer repo.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-07-03 13:51:30 +02:00
Tobias WaldekranzandJoachim Wiberg 4fb09267cf confd: Add a sysrepo interface to install RAUC bundles 2023-06-30 15:33:10 +02:00
Tobias WaldekranzandJoachim Wiberg 6ca6a4e2f8 confd: Restructure list of source files
We were now at the point where it was completely impossible to see
which files are actually built.

Bring back some order, making future diffs easier to understand.
2023-06-30 15:33:10 +02:00
Joachim WibergandTobias Waldekranz b88348145c confd: fix regression in enabling ipv4 zeroconf address
To reproduce regression, before fix, in CLI from factory-default:

  > configure
  > set interfaces interface e0 ipv4 autoconf enable true
  > leave
  > shell
  $ ps; ip -br a

Turns out, for some reason I cannot figure out, that we cannot use the
same pattern as for ipv6 with lydx_get_descendant().  Manually fetching
the node works though.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-06-30 14:13:09 +02:00
Joachim WibergandTobias Waldekranz d6eca354b3 klish: add reboot and poweroff commands, for usability
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-06-30 14:13:09 +02:00
Joachim WibergandTobias Waldekranz ecc24d13cb confd: call avahi-set-host-name on hostname changes
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-06-30 14:13:09 +02:00
Joachim WibergandTobias Waldekranz e4a1261ad8 Fix #57: unneccesary lldpd restarts on configuration change
Instead of restarting lldpd we can call lldpcli to inform lldpd of the change.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-06-30 14:13:09 +02:00
Joachim WibergandTobias Waldekranz 123317ce35 confd: add support for factory-default rpc
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-06-30 13:37:12 +02:00
Joachim WibergandTobias Waldekranz 8302ad9735 confd: fix missing RPC OK from system-restart et al
Use new APIs runbg() and run_status() to call 'reboot' or 'poweroff' in
the background.  This allows sysrepo + netopeer to reply to remote RPCs
before networking goes down.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-06-30 13:37:12 +02:00
Richard AlpeandJoachim Wiberg 9d63aeed61 confd: fix memory leak in lydx_new_path()
Prior to this patch, every new call to lydx_new_path() where "first"
was set to 1 resulted in a memory leak of 72 bytes. Typically at least
once for each sysrepo query.

The memory was allocated deep down in the lyd library, but as the
parent node wasn't set (NULL) it wasn't found by sysrepo when
cleaning up.

In this patch we mitigate this by simply removing the "first" concept,
as it doesn't appear to be needed.

Signed-off-by: Richard Alpe <richard@bit42.se>
2023-06-29 14:47:36 +02:00
Joachim WibergandTobias Waldekranz a295086a35 confd: add support for bridge VLAN proto and pvid
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-06-22 13:55:16 +02:00
Joachim WibergandTobias Waldekranz c8a3e94501 confd: initial support for bridge native vlan filtering
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-06-22 13:55:16 +02:00
Joachim WibergandTobias Waldekranz da1bc57b92 confd: prevent sprious errors of symlinks already existing
When/If dagger generations are abandoned we should not bail out if a
recovery generation finds an existing 'order' in the previous gen.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-06-22 00:12:43 +02:00
Joachim WibergandTobias Waldekranz 76b7dce7fc confd: ignore other end of veth pairs also when deleting interfaces
Same as with creating veth pairs, we must not try to delete both ends
since the kernel does that for us.  Ensure we check skip in the current
generation and not in the next.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-06-22 00:12:43 +02:00
Joachim WibergandTobias Waldekranz 5e5cc8070f confd: skip shebang in dagger action if action already exists
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-06-22 00:12:43 +02:00
Joachim WibergandTobias Waldekranz 9ca26a6ef7 confd: clean up error messages and drop developer debug messages
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-06-22 00:12:43 +02:00
Joachim WibergandTobias Waldekranz 2994b68e89 confd: follow-up to bridge support, support removing bridge ports
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-06-22 00:12:43 +02:00
Joachim WibergandTobias Waldekranz 791a153ebf confd: minor refactor
Relocate and reorder code a bit, preparing for VLAN support.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-06-22 00:12:43 +02:00
Joachim WibergandTobias Waldekranz e8c3eff52b confd: add support for setting bridge group_fwd_mask
This one was a little bit tricky with the special yang union.  To figure
out the integer value of enums one has to check the schema and deref the
correct subvalue within.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-06-20 11:11:52 +02:00
Joachim WibergandTobias Waldekranz 7555e18996 confd: allow wheel group (admin) to access datastore locally
The admin account is the superuser in Infix.  The root account will soon
only be for running system daemons.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-06-20 11:11:52 +02:00
Joachim WibergandTobias Waldekranz c00ff6daf5 confd: bootstrap sysrepo+netopeer yang models with factory defaults
To set up proper factory defaults in Infix we need to drop the default
/etc/sysrepo datastores, initialized at compile-time by Buildroot when
installing netopeer2.  The pre-initialized datastores cannot be set up
with new {factory} data in any other way.

The system factory-config is constructed from two parts: static data and
generated data.  The latter is:

 - hostname (product name + the three last octets of the base MAC)
 - interface defaults (depends on number of ports on the device) that
   enable IPv6 link-local on all interfaces, and
 - per-device unique SSH hostkey for remote NETCONF access, requires
   openssl binary on target.  Can maybe use openssh for this (TODO).
   The hostkeys are saved in /cfg/factory.d/ to prevent them from being
   regenerated on every boot.

The script gen-hostkeys and the update of 10-netconf-server.json are
inspired by the netopeer2 scripts merge_hostkey.sh and merge_config.sh,
which do just about the same thing for regular systems.

We bootstrap sysrepo early with all the required models, netopeer2 as
well as our own, by calling sysrepoctl with initial data for {factory}
and {startup} datastores.  A local patch to sysrepo is used to allow it
to look for an /etc/factory-default.json instead of compile-time default
data, the patch allows us to have variable amount of objects in the init
data, e.g. number of interface objects.

A system startup-config is generated, if one is mising, from {running}.

We then drop the initial {running} datastore before starting the daemons
sysrepo-plugind and netopeer2-server so that they, and our plugins, are
ready when we load the system startup-config.

Some sanity checks and debug possibilities:

 - Ensure /etc/sysrepo exists before copying factory-config
 - Keep factory-default.json for debug

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-06-20 11:11:52 +02:00
Joachim WibergandTobias Waldekranz 003eedeab8 confd: IP addresses must not be set, or be deleted, when not enabled
The ietf-ip yang model has a global IPv4 and IPv6 'enabled' setting that
must be honored.  E.g., when setting eth0 as a bridge port and disabling
IPv4 address on eth0, we must flush all addresses, including autoconf.
When detaching interface from the bridge and toggling the 'enabled' node
back on, we only get a "replaced" flag for that node, so we must restore
all addresses from the configure data.  The same goes for 'autoconf'.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-06-20 11:11:52 +02:00
Joachim WibergandTobias Waldekranz d71a3b3db6 confd: add support for "replace" operation
When toggling settings like 'interfaces/interface/ipv6/enabled', which
guards both link-local and all static addresses, the operation is not
"create" or "delete", but "replace".  Callback must take any "replace"
on an 'enabled' node into account since none of the other nodes will
be available in the diff.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-06-20 11:11:52 +02:00
Joachim WibergandTobias Waldekranz 5be4a629f3 confd: add errno codes for out-of-range prio and missing current gen
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-06-20 11:11:52 +02:00
Joachim WibergandTobias Waldekranz 352a1f1f64 confd: refactor, make lydx_is_enabled() available to all modules
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-06-20 11:11:52 +02:00
Joachim WibergandTobias Waldekranz 86304e2656 confd: rudimentary support for Linux bridges
Very limited, only TPMR-style bridge, no VLAN filtering support yet.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-06-20 11:11:52 +02:00
Joachim WibergandTobias Waldekranz 1b7d72a07c confd: add support for veth pairs, incl. new native YANG models
This change adds support for Linux veth pairs and is also a bit of a
cleanup of our native yang models, more on that below.  The interesting
things are the use of submodule(s) for veth, and the addition of the
deviation for the deprecated /if:interfaces-state.

Unfortunately the `fprintf(ip, "link add dev %s down", ifname);` had to
be delagated from netdag_gen_afspec_add() because of this change.  This
because we only know very late that the peer-end of the pair should be
skipped.  Having a lingering `ip link add dev foo down` causes iproute2
to fail hard.

A note about Yang models.  According to RFC they must follow the naming
standard; 'org-name' and use prefixes 'org-shortname'.  So we've decided
to standardize on 'infix-modulename' and 'infix-mn', where 'modulename'
is the standard model we extend, and 'mn' is the prefix used by that
standard model.  For example

 - infix-interfaces extend ietf-interfaces and use infix-if
 - infix-if-veth is a submodule extending infix with veth pairs

Upcoming bridge and lag models follow the same pattern.  The use of
submodules require a patch to sysrepo, included earlier, and allows
us to have the same 'infix-if:', or 'infix-interfaecs:' prefix to
all ietf-interfaces extensions.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-06-20 11:11:52 +02:00
Joachim WibergandTobias Waldekranz 7c17793e5a confd: add support for bookkeeping "skip" interfaces
When setting up veth pairs we only need to set up one end of the pair,
so the confd callback code need a way to remember to skip setting up
the peer interface.

The code added here is generic enough to handle other such transactions.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-06-20 11:11:52 +02:00
Joachim WibergandTobias Waldekranz 491239f99c confd: backport fexistf() from latest libite master
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-06-20 11:11:52 +02:00
Joachim WibergandTobias Waldekranz 50a02e1690 confd: add support for changes in more deeply nested nodes
With the coming support for veth pairs, bridge, and link aggregates, we
need to infer peer interfaces (veth), and similar more deeply nested
data nodes to aid the user.  Thereforce we can no longer rely on the
xpath in the callbacks to always be "interfaces/interface[name='ifnm']".

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-06-20 11:11:52 +02:00
Joachim WibergandTobias Waldekranz f6e64a52ac confd: minor fixes
- initialize stack variables to prevent undefined behavior
 - memory leak

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-06-20 11:11:52 +02:00
Joachim WibergandTobias Waldekranz 28d07c6255 confd: new function, srx_set_str(), complements srx_set_item()
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-06-20 11:11:52 +02:00
Joachim WibergandTobias Waldekranz 6f27e51700 confd: refactor srx_require_module(), patched upstream now works
This changeset includes a patch to the upstream sysrepo that is a slight
refactor of the internal function sr_install_modules_prepare_mod() that
is used by sr_install_module2().  Meaning, the srx_require_module() can
now be simplified greatly and we now also support the include statement
with submodules in yang models.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-06-20 11:11:52 +02:00
Joachim WibergandTobias Waldekranz 8462fe4ab6 confd: refactor ietf-system augments and deviations
Initial yang model cleanup:

 - Use infix-foo@rev.yang for augments and deviations of each std-foo model
 - Drop kernelkit-infix-deviations, moved to infix-system model

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-06-20 11:11:52 +02:00
Richard AlpeandJoachim Wiberg 723c325b0d statd: add limited operational data for all ifaces
Add oper-status and if-index data to sysrepo for every existing
interface. The origin of the data is the "standard" ip tool with
JSON output.

Current implementation is limited to interfaces existing at startup.

Signed-off-by: Richard Alpe <richard@bit42.se>
2023-06-13 16:39:53 +02:00
Richard AlpeandJoachim Wiberg 75155b72b3 confd: move helper.c to lib
Signed-off-by: Richard Alpe <richard@bit42.se>
2023-06-13 16:39:53 +02:00
Richard AlpeandJoachim Wiberg 382f428edf confd: add new statd skeleton for operational status
Add a new "statd" module to sysrepo. This module is intended to handle
operational status, i.e. R/O attributes.

In this state, the statd module only retrieves and answers to the
"oper-state" of "eth0". This will be replaced by proper interface
handling and json data processing in upcoming patches. The indent here
is to get the base logistics in place as soon as possible to make life
easier for developers.

Signed-off-by: Richard Alpe <richard@bit42.se>
2023-06-07 13:24:23 +02:00
Richard AlpeandJoachim Wiberg 26391d5381 confd: move srx_module to src/lib
Signed-off-by: Richard Alpe <richard@bit42.se>
2023-06-07 13:24:23 +02:00
Richard AlpeandJoachim Wiberg 84822390ff confd: move lyx source to new src lib directory
Preparation for statd.

Signed-off-by: Richard Alpe <richard@bit42.se>
2023-06-07 13:24:23 +02:00
Richard AlpeandTobias Waldekranz 4fa89651a7 confd: move src into confd subdirectory
This patch is a preparation for the upcoming "statd" addition.

Signed-off-by: Richard Alpe <richard@bit42.se>
2023-06-05 13:21:01 +02:00
Joachim WibergandTobias Waldekranz c81bc445ca confd: simplify, yang model ensures iftype (+ ifname) is always set
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-06-01 15:16:39 +02:00
Tobias Waldekranz d82e586687 confd: Infer VLAN parameters for the common <BASE>.<VID> pattern
When adding a new interface to the candidate, if the name matches
<BASE>.<VID>, infer that:

- The parent-interface is <BASE>
- The tag-type is c-vlan
- The vlan-id is <VID>

With this in place, from klish, the following sequence:

configure
set interfaces interface e0.10
leave

Will create a stacked VLAN interface, using VID 10, on top of e0.
2023-06-01 15:16:39 +02:00