From 3354effc53a0fad0d6e0305617c43998e2ba13de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Walstr=C3=B6m?= Date: Mon, 6 May 2024 19:38:16 +0200 Subject: [PATCH] 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 --- package/confd/confd.mk | 360 +++++++++++++++++- src/confd/bin/bootstrap | 109 +----- src/confd/bin/gen-hostkeys | 5 +- src/confd/scripts/setup.sh | 183 +++++++++ .../share/factory.d/10-netconf-server.json | 42 +- src/confd/src/ietf-interfaces.c | 5 - src/confd/src/infix-containers.c | 9 - src/confd/src/infix-factory.c | 10 - src/klish-plugin-infix/src/infix.c | 2 +- 9 files changed, 575 insertions(+), 150 deletions(-) create mode 100755 src/confd/scripts/setup.sh diff --git a/package/confd/confd.mk b/package/confd/confd.mk index 7a9ed058..56e1afc6 100644 --- a/package/confd/confd.mk +++ b/package/confd/confd.mk @@ -11,8 +11,12 @@ CONFD_SITE = $(BR2_EXTERNAL_INFIX_PATH)/src/confd CONFD_LICENSE = BSD-3-Clause CONFD_LICENSE_FILES = LICENSE CONFD_REDISTRIBUTE = NO -CONFD_DEPENDENCIES = augeas jansson libite sysrepo libsrx libglib2 +CONFD_DEPENDENCIES = host-sysrepo netopeer2 augeas jansson libite sysrepo libsrx libglib2 CONFD_AUTORECONF = YES + +CONFD_SYSREPO_SHM_PREFIX = sr_buildroot$(subst /,_,$(CONFIG_DIR))_netopeer2 + +echo "prefix: $(CONFD_SYSREPO_SHM_PREFIX)" define CONFD_CONF_ENV CFLAGS="$(INFIX_CFLAGS)" endef @@ -23,6 +27,11 @@ else CONFD_CONF_OPTS += --disable-containers endif + +CONFD_MAKE_ENV = \ + SYSREPOCTL_EXECUTABLE=$(HOST_DIR)/bin/sysrepoctl \ + SYSREPO_SHM_PREFIX=$(CONFD_SYSREPO_SHM_PREFIX) + define CONFD_INSTALL_EXTRA cp $(CONFD_PKGDIR)/confd.conf $(FINIT_D)/available/ ln -sf ../available/confd.conf $(FINIT_D)/enabled/confd.conf @@ -30,6 +39,353 @@ define CONFD_INSTALL_EXTRA mkdir -p $(TARGET_DIR)/etc/avahi/services cp $(CONFD_PKGDIR)/avahi.service $(TARGET_DIR)/etc/avahi/services/netconf.service endef -CONFD_POST_INSTALL_TARGET_HOOKS += CONFD_INSTALL_EXTRA +define CONFD_INSTALL_YANG_MODULES + USE_CONTAINERS=$(BR2_PACKAGE_PODMAN) SYSREPO_SHM_PREFIX=$(CONFD_SYSREPO_SHM_PREFIX) SYSREPOCTL_EXECUTABLE="$(HOST_DIR)/bin/sysrepoctl" SYSREPOCFG_EXECUTABLE="$(HOST_DIR)/bin/sysrepocfg" SEARCH_PATH="$(TARGET_DIR)/usr/share/yang/modules/confd/" $(@D)/scripts/setup.sh +endef +define CONFD_PERMISSIONS +# generated using chatGPT +/etc/sysrepo/data/iana-ssh-mac-algs.startup f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-netconf-nmda.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-netconf-with-defaults.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-netconf-acm.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/libnetconf2-netconf-server.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-netconf-acm.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/infix-factory-default.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/sysrepo-factory-default.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/iana-tls-cipher-suite-algs.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-tcp-client.startup f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-keystore.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ieee802-dot1q-types.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/infix-ethernet-interface.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-netconf-monitoring.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-tls-common.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-tls-server.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/infix-system.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-netconf-nmda.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-tcp-server.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/infix-system.startup f 660 root wheel - - - - - +/etc/sysrepo/data/infix-factory-default.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/iana-ssh-key-exchange-algs.startup f 660 root wheel - - - - - +/etc/sysrepo/data/libnetconf2-netconf-server.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-netconf-server.startup f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-routing.startup f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-datastores.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/infix-interfaces.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-network-instance.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-tcp-server.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-tcp-client.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-routing.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/infix-routing.startup f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-yang-schema-mount.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-crypto-types.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-ip.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-crypto-types.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/infix-services.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ieee802-dot1ab-lldp.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/infix-lldp.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-yang-schema-mount.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/infix-factory-default.startup f 660 root wheel - - - - - +/etc/sysrepo/data/notifications.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/infix-ip.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/sysrepo-plugind.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/iana-hardware.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-subscribed-notifications.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-key-chain.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-ipv6-unicast-routing.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-keystore.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/sysrepo-monitoring.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/infix-lldp.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/infix-interfaces.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-system.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-yang-schema-mount.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ieee802-dot1q-types.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/infix-if-type.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/ieee802-ethernet-interface.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-yang-library.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-netconf-with-defaults.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/iana-ssh-encryption-algs.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/infix-interfaces.startup f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-routing.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-netconf.startup f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-truststore.startup f 660 root wheel - - - - - +/etc/sysrepo/data/iana-hardware.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/iana-crypt-hash.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ieee802-dot1q-types.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/infix-hardware.startup f 660 root wheel - - - - - +/etc/sysrepo/data/sysrepo-plugind.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-ssh-common.startup f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-subscribed-notifications.startup f 660 root wheel - - - - - +/etc/sysrepo/data/iana-if-type.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/iana-if-type.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-ipv4-unicast-routing.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/sysrepo.startup f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-netconf-with-defaults.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ieee802-dot1q-types.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-yang-library.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-tcp-common.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-subscribed-notifications.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-interfaces.startup f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-ipv4-unicast-routing.startup f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-netconf-monitoring.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/iana-ssh-public-key-algs.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/sysrepo-plugind.startup f 660 root wheel - - - - - +/etc/sysrepo/data/infix-containers.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-hardware.startup f 660 root wheel - - - - - +/etc/sysrepo/data/iana-ssh-key-exchange-algs.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ieee802-dot1ab-lldp.startup f 660 root wheel - - - - - +/etc/sysrepo/data/infix-ethernet-interface.startup f 660 root wheel - - - - - +/etc/sysrepo/data/notifications.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/infix-routing.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ieee802-ethernet-interface.startup f 660 root wheel - - - - - +/etc/sysrepo/data/iana-timezones.startup f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-datastores.startup f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-x509-cert-to-name.startup f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-factory-default.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/ieee802-dot1ab-lldp.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-netconf-acm.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/sysrepo-factory-default.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/infix-containers.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/iana-tls-cipher-suite-algs.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-netconf.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-yang-push.startup f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-tcp-common.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/infix-factory-default.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/infix-if-type.startup f 660 root wheel - - - - - +/etc/sysrepo/data/nc-notifications.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-tls-server.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/yang.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-ip.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-hardware.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-yang-push.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/notifications.startup f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-netconf-notifications.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/iana-ssh-public-key-algs.startup f 660 root wheel - - - - - +/etc/sysrepo/data/nc-notifications.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/infix-interfaces.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/sysrepo-factory-default.startup f 660 root wheel - - - - - +/etc/sysrepo/data/iana-tls-cipher-suite-algs.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/infix-hardware.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/iana-ssh-encryption-algs.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/iana-crypt-hash.startup f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-network-instance.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-crypto-types.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-datastores.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/infix-hardware.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-netconf-monitoring.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-datastores.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/infix-hardware.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/infix-ethernet-interface.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/yang.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-netconf-notifications.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-ssh-common.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-tls-common.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/infix-ethernet-interface.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/iana-ssh-mac-algs.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-netconf-server.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/infix-services.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-x509-cert-to-name.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/iana-timezones.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-datastores.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/libnetconf2-netconf-server.startup f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-tls-common.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-yang-library.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-netconf-notifications.startup f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-tcp-server.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/iana-ssh-mac-algs.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/sysrepo-monitoring.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-netconf-server.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-crypto-types.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/iana-ssh-public-key-algs.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/infix-shell-type.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/infix-routing.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-netconf-nmda.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-netconf-monitoring.startup f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-truststore.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/infix-shell-type.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ieee802-ethernet-interface.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/iana-tls-cipher-suite-algs.startup f 660 root wheel - - - - - +/etc/sysrepo/data/infix-interfaces.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-tls-server.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-ipv6-unicast-routing.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/infix-lldp.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-network-instance.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/infix-ip.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/nc-notifications.startup f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-tcp-client.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-routing.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-ssh-common.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-keystore.startup f 660 root wheel - - - - - +/etc/sysrepo/data/ieee802-dot1ab-lldp.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-netconf-notifications.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-tcp-client.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-origin.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-system.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-yang-library.startup f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-factory-default.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/iana-timezones.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-subscribed-notifications.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-key-chain.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-ipv4-unicast-routing.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/iana-crypt-hash.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/iana-ssh-encryption-algs.startup f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-netconf-notifications.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/iana-hardware.startup f 660 root wheel - - - - - +/etc/sysrepo/data/iana-ssh-encryption-algs.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-ospf.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/iana-ssh-key-exchange-algs.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-netconf-nmda.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/iana-timezones.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-ip.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/infix-containers.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ieee802-ethernet-interface.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-interfaces.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-origin.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/libnetconf2-netconf-server.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-yang-push.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-netconf-nmda.startup f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-netconf.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-ssh-common.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/sysrepo-monitoring.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-ip.startup f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-netconf-acm.startup f 660 root wheel - - - - - +/etc/sysrepo/data/infix-if-type.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-tls-common.startup f 660 root wheel - - - - - +/etc/sysrepo/data/infix-dhcp-client.startup f 660 root wheel - - - - - +/etc/sysrepo/data/infix-hardware.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/infix-system.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-ssh-common.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-netconf-monitoring.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-tls-server.startup f 660 root wheel - - - - - +/etc/sysrepo/data/infix-ip.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-netconf-with-defaults.startup f 660 root wheel - - - - - +/etc/sysrepo/data/infix-system.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-ssh-server.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-ipv4-unicast-routing.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/infix-ethernet-interface.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/yang.startup f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-hardware.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-x509-cert-to-name.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-tcp-common.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/iana-if-type.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-netconf-server.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-origin.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-key-chain.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-tcp-common.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/infix-system.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-x509-cert-to-name.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/nc-notifications.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-keystore.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/iana-hardware.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-tcp-common.startup f 660 root wheel - - - - - +/etc/sysrepo/data/infix-containers.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-tcp-server.startup f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-interfaces.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-ssh-server.startup f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-key-chain.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-truststore.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-factory-default.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/iana-if-type.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-tls-server.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-keystore.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/infix-routing.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-ssh-server.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/sysrepo-plugind.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-tcp-client.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/infix-shell-type.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/infix-lldp.startup f 660 root wheel - - - - - +/etc/sysrepo/data/iana-ssh-mac-algs.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-interfaces.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/infix-services.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-subscribed-notifications.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/iana-if-type.startup f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-factory-default.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/iana-ssh-public-key-algs.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/infix-if-type.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/iana-ssh-mac-algs.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-factory-default.startup f 660 root wheel - - - - - +/etc/sysrepo/data/sysrepo-monitoring.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-tls-common.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-netconf.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/iana-hardware.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/infix-dhcp-client.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-system.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/infix-if-type.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-truststore.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-yang-schema-mount.startup f 660 root wheel - - - - - +/etc/sysrepo/data/infix-dhcp-client.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-network-instance.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-tcp-server.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-ospf.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-truststore.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/iana-crypt-hash.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/infix-routing.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-ipv6-unicast-routing.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/yang.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-routing.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/notifications.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/infix-ip.startup f 660 root wheel - - - - - +/etc/sysrepo/data/libnetconf2-netconf-server.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-yang-schema-mount.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/sysrepo-factory-default.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/yang.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ieee802-dot1ab-lldp.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/sysrepo-monitoring.startup f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-key-chain.startup f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-hardware.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-ip.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/infix-dhcp-client.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-ipv6-unicast-routing.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/iana-timezones.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-system.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-network-instance.startup f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-hardware.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/infix-ip.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-ipv6-unicast-routing.startup f 660 root wheel - - - - - +/etc/sysrepo/data/infix-services.startup f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-origin.startup f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-yang-library.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-ospf.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-netconf-acm.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-yang-push.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/infix-containers.startup f 660 root wheel - - - - - +/etc/sysrepo/data/iana-ssh-encryption-algs.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-ssh-server.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ieee802-ethernet-interface.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/infix-services.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-netconf.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ieee802-dot1q-types.startup f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-origin.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/iana-ssh-public-key-algs.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-ospf.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/infix-shell-type.startup f 660 root wheel - - - - - +/etc/sysrepo/data/iana-crypt-hash.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-interfaces.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-yang-push.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/notifications.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/nc-notifications.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-netconf-server.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-ospf.startup f 660 root wheel - - - - - +/etc/sysrepo/data/infix-lldp.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-x509-cert-to-name.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/infix-factory-default.factory-default f 660 root wheel - - - - - +/etc/sysrepo/data/infix-shell-type.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/iana-ssh-key-exchange-algs.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/iana-tls-cipher-suite-algs.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-system.startup f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-netconf-with-defaults.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/iana-ssh-key-exchange-algs.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/sysrepo-factory-default.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/infix-dhcp-client.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-ipv4-unicast-routing.running.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-ssh-server.operational.perm f 660 root wheel - - - - - +/etc/sysrepo/data/sysrepo-plugind.candidate.perm f 660 root wheel - - - - - +/etc/sysrepo/data/ietf-crypto-types.startup f 660 root wheel - - - - - +endef +define CONFD_CLEANUP + rm -f /dev/shm/$(NETOPEER2_SYSREPO_SHM_PREFIX)* +endef +CONFD_POST_INSTALL_TARGET_HOOKS += CONFD_INSTALL_EXTRA +CONFD_POST_INSTALL_TARGET_HOOKS += CONFD_INSTALL_YANG_MODULES +CONFD_POST_INSTALL_TARGET_HOOKS += CONFD_CLEANUP $(eval $(autotools-package)) diff --git a/src/confd/bin/bootstrap b/src/confd/bin/bootstrap index 3aa453b5..aa710349 100755 --- a/src/confd/bin/bootstrap +++ b/src/confd/bin/bootstrap @@ -148,111 +148,23 @@ if [ -n "$TESTING" ]; then exit 0 fi -# Drop all pre-initialized data from netopeer2 install, then re-create -# with required netopeer2 models, sysrepo implicitly installs its own, -# and then we initialize it all with our factory defaults. -rm -rf /etc/sysrepo/* /dev/shm/sr_* mkdir -p /etc/sysrepo/ if [ -f "$FACTORY_CFG" ]; then cp "$FACTORY_CFG" "$INIT_DATA" else cp "$FAILURE_CFG" "$INIT_DATA" fi - -sysrepoctl -s $SEARCH \ - -i ietf-system@2014-08-06.yang -g wheel -p 0660 \ - -e authentication \ - -e local-users \ - -e ntp \ - -e ntp-udp-port \ - -e timezone-name \ - -i iana-timezones@2013-11-19.yang -g wheel -p 0660 \ - -i nc-notifications@2008-07-14.yang -g wheel -p 0660 \ - -i notifications@2008-07-14.yang -g wheel -p 0660 \ - -i ietf-keystore@2019-07-02.yang -g wheel -p 0660 \ - -e keystore-supported \ - -e local-definitions-supported \ - -e key-generation \ - -i ietf-truststore@2019-07-02.yang -g wheel -p 0660 \ - -e truststore-supported \ - -e x509-certificates \ - -i ietf-tcp-common@2019-07-02.yang -g wheel -p 0660 \ - -e keepalives-supported \ - -i ietf-ssh-server@2019-07-02.yang -g wheel -p 0660 \ - -e local-client-auth-supported \ - -i ietf-tls-server@2019-07-02.yang -g wheel -p 0660 \ - -e local-client-auth-supported \ - -i ietf-netconf-server@2019-07-02.yang -g wheel -p 0660 \ - -e ssh-listen \ - -e tls-listen \ - -e ssh-call-home \ - -e tls-call-home \ - -i ietf-interfaces@2018-02-20.yang -g wheel -p 0660 \ - -e if-mib \ - -i ietf-ip@2018-02-22.yang -g wheel -p 0660 \ - -e ipv6-privacy-autoconf \ - -i ietf-network-instance@2019-01-21.yang -g wheel -p 0660 \ - -i ietf-netconf-monitoring@2010-10-04.yang -g wheel -p 0660 \ - -i ietf-netconf-nmda@2019-01-07.yang -g wheel -p 0660 \ - -e origin \ - -e with-defaults \ - -i ietf-subscribed-notifications@2019-09-09.yang \ - -g wheel -p 0660 \ - -e encode-xml \ - -e replay \ - -e subtree \ - -e xpath \ - -i ietf-yang-push@2019-09-09.yang -g wheel -p 0660 \ - -e on-change \ - -i ietf-routing@2018-03-13.yang -g wheel -p 0660 \ - -i ietf-ipv6-unicast-routing@2018-03-13.yang -g wheel -p 0660 \ - -i ietf-ipv4-unicast-routing@2018-03-13.yang -g wheel -p 0660 \ - -i ietf-ospf@2022-10-19.yang -g wheel -p 0660 \ - -e bfd \ - -e explicit-router-id \ - -i iana-if-type@2023-01-26.yang -g wheel -p 0660 \ - -i iana-hardware@2018-03-13.yang -g wheel -p 0660 \ - -i ietf-hardware@2018-03-13.yang -g wheel -p 0660 \ - -e hardware-state \ - -i infix-hardware@2024-04-25.yang -g wheel -p 0660 \ - -i ieee802-dot1q-types@2022-10-29.yang -g wheel -p 0660 \ - -i infix-ip@2023-09-14.yang -g wheel -p 0660 \ - -i infix-if-type@2024-01-29.yang -g wheel -p 0660 \ - -i infix-routing@2024-03-06.yang -g wheel -p 0660 \ - -i infix-interfaces@2024-01-15.yang -g wheel -p 0660 \ - -e vlan-filtering \ - -i ieee802-dot1ab-lldp@2022-03-15.yang -g wheel -p 0660 \ - -i infix-lldp@2023-08-23.yang -g wheel -p 0660 \ - -i infix-dhcp-client@2024-04-12.yang -g wheel -p 0660 \ - -i infix-shell-type@2023-08-21.yang -g wheel -p 0660 \ - -i infix-system@2024-04-12.yang -g wheel -p 0660 \ - -i infix-services@2024-04-08.yang -g wheel -p 0660 \ - -i ieee802-ethernet-interface@2019-06-21.yang -g wheel -p 0660 \ - -i infix-ethernet-interface@2024-02-27.yang -g wheel -p 0660 \ - -I "${INIT_DATA}" rc=$? -# Unlike `sysrepoctl -i` the `-c` command requires separate invocations. -# NOTE: we ignore any errors from these at bootstrap since sysrepo may -# already enable some of these feature, resulting in error here. -# Enable features required by netopeer2 -sysrepoctl -c ietf-netconf -g wheel -p 0660 \ - -e writable-running \ - -e candidate \ - -e rollback-on-error \ - -e validate \ - -e startup \ - -e url \ - -e xpath \ - -e confirmed-commit -# Allow wheel group users (admin) to modify NACM and do factory reset -sysrepoctl -c ietf-netconf-acm -g wheel -p 0660 -sysrepoctl -c ietf-factory-default -g wheel -p 0660 -sysrepoctl -c sysrepo-plugind -g wheel -p 0660 +sysrepoctl -z $INIT_DATA +rc=$? +sudo -u root -g wheel sysrepocfg -f json -I"$INIT_DATA" -d running +rc=$? -# On first boot, install factory-config as startup-config. Due to a -# limitation in sysrepo we cannot initialize ietf-netconf-acm, so we -# cheat, see sysrepo#3079 + +#rm $INIT_DATA + +# On first boot, install factory-config as startup-config. chgrp wheel /cfg chmod g+w /cfg if [ ! -f "$STARTUP_CFG" ]; then @@ -260,7 +172,8 @@ if [ ! -f "$STARTUP_CFG" ]; then fi # Clear running-config so we can load startup in the next step -echo "{}" > "$INIT_DATA" -sysrepocfg -f json -I"$INIT_DATA" -d running +temp=$(mktemp) +echo "{}" > $temp +sysrepocfg -f json -I$temp -d running exit $rc diff --git a/src/confd/bin/gen-hostkeys b/src/confd/bin/gen-hostkeys index d7639adf..76037057 100755 --- a/src/confd/bin/gen-hostkeys +++ b/src/confd/bin/gen-hostkeys @@ -18,9 +18,10 @@ cat <conn, "infix-interfaces", "containers"); -#endif - REGISTER_CHANGE(confd->session, "ietf-interfaces", "/ietf-interfaces:interfaces//.", 0, ifchange, confd, &confd->sub); REGISTER_CHANGE(confd->cand, "ietf-interfaces", "/ietf-interfaces:interfaces//.", diff --git a/src/confd/src/infix-containers.c b/src/confd/src/infix-containers.c index 8cb22b4a..9b99d580 100644 --- a/src/confd/src/infix-containers.c +++ b/src/confd/src/infix-containers.c @@ -22,11 +22,6 @@ #define ACTIVE_QUEUE "/var/lib/containers/active" #define LOGGER "logger -t container -p local1.notice" -static const struct srx_module_requirement reqs[] = { - { .dir = YANG_PATH_, .name = MODULE, .rev = "2024-03-27" }, - { NULL } -}; - static int add(const char *name, struct lyd_node *cif) { const char *image = lydx_get_cattr(cif, "image"); @@ -438,10 +433,6 @@ int infix_containers_init(struct confd *confd) { int rc; - rc = srx_require_modules(confd->conn, reqs); - if (rc) - goto fail; - REGISTER_CHANGE(confd->session, MODULE, CFG_XPATH, 0, change, confd, &confd->sub); REGISTER_RPC(confd->session, CFG_XPATH "/container/start", action, NULL, &confd->sub); REGISTER_RPC(confd->session, CFG_XPATH "/container/stop", action, NULL, &confd->sub); diff --git a/src/confd/src/infix-factory.c b/src/confd/src/infix-factory.c index be239602..8cecfe6b 100644 --- a/src/confd/src/infix-factory.c +++ b/src/confd/src/infix-factory.c @@ -15,11 +15,6 @@ #include "core.h" -static const struct srx_module_requirement reqs[] = { - { .dir = YANG_PATH_, .name = "infix-factory-default", .rev = "2023-06-28" }, - { NULL } -}; - static int rpc(sr_session_ctx_t *session, uint32_t sub_id, const char *xpath, const sr_val_t *input, const size_t input_cnt, sr_event_t event, unsigned request_id, sr_val_t **output, size_t *output_cnt, void *priv) @@ -42,11 +37,6 @@ static int rpc(sr_session_ctx_t *session, uint32_t sub_id, const char *xpath, int infix_factory_init(struct confd *confd) { int rc; - - rc = srx_require_modules(confd->conn, reqs); - if (rc) - goto fail; - REGISTER_RPC(confd->session, "/infix-factory-default:factory-default", rpc, NULL, &confd->fsub); return SR_ERR_OK; fail: diff --git a/src/klish-plugin-infix/src/infix.c b/src/klish-plugin-infix/src/infix.c index 1c523bcf..f2d9265f 100644 --- a/src/klish-plugin-infix/src/infix.c +++ b/src/klish-plugin-infix/src/infix.c @@ -43,7 +43,7 @@ struct infix_ds infix_config[] = { { "running-config", "running", SR_DS_RUNNING, 1, NULL }, { "candidate-config", "candidate", SR_DS_CANDIDATE, 1, NULL }, { "operational-config", "operational", SR_DS_OPERATIONAL, 1, NULL }, - { "factory-config", NULL, SR_DS_FACTORY_DEFAULT, 0, "/etc/factory-config.cfg" }, + { "factory-config", "factory-default", SR_DS_FACTORY_DEFAULT, 0, NULL } }; static void cd_home(kcontext_t *ctx)