public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Gabriel Goller <g.goller@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH proxmox-ve-rs 2/9] frr: add proxmox-frr-templates package that contains templates
Date: Tue,  3 Feb 2026 17:01:09 +0100	[thread overview]
Message-ID: <20260203160246.353351-3-g.goller@proxmox.com> (raw)
In-Reply-To: <20260203160246.353351-1-g.goller@proxmox.com>

This debian package contains the jinja template files used to generate
the frr config. Currently only the fabrics template files are here, the
rest will be added in later commits. When installing this package the
templates will be installed to `/usr/share/proxmox-frr/templates/`.
`proxmox-frr` will then use `include_str!` to embed the templates into
the binary.

This package will only be published to the `devel` channel.

We will be able to retrieve the templates using the `pvesdn` cli, which
will make a call to perl-rs.

Co-authored-by: Stefan Hanreich <s.hanreich@proxmox.com>
Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
 Makefile                                      |  8 +++
 proxmox-frr-templates/.gitignore              |  1 +
 proxmox-frr-templates/Makefile                | 50 +++++++++++++++++++
 proxmox-frr-templates/debian/changelog        |  5 ++
 proxmox-frr-templates/debian/control          | 17 +++++++
 proxmox-frr-templates/debian/copyright        | 18 +++++++
 .../debian/proxmox-frr-templates.install      |  1 +
 proxmox-frr-templates/debian/rules            |  5 ++
 .../templates/access_list.jinja               |  6 +++
 .../templates/access_lists.jinja              |  6 +++
 proxmox-frr-templates/templates/fabricd.jinja | 29 +++++++++++
 .../templates/frr.conf.jinja                  |  5 ++
 .../templates/interface.jinja                 |  9 ++++
 proxmox-frr-templates/templates/ospfd.jinja   | 18 +++++++
 .../templates/protocol_routemaps.jinja        | 10 ++++
 .../templates/route_maps.jinja                | 20 ++++++++
 16 files changed, 208 insertions(+)
 create mode 100644 proxmox-frr-templates/.gitignore
 create mode 100644 proxmox-frr-templates/Makefile
 create mode 100644 proxmox-frr-templates/debian/changelog
 create mode 100644 proxmox-frr-templates/debian/control
 create mode 100644 proxmox-frr-templates/debian/copyright
 create mode 100644 proxmox-frr-templates/debian/proxmox-frr-templates.install
 create mode 100755 proxmox-frr-templates/debian/rules
 create mode 100644 proxmox-frr-templates/templates/access_list.jinja
 create mode 100644 proxmox-frr-templates/templates/access_lists.jinja
 create mode 100644 proxmox-frr-templates/templates/fabricd.jinja
 create mode 100644 proxmox-frr-templates/templates/frr.conf.jinja
 create mode 100644 proxmox-frr-templates/templates/interface.jinja
 create mode 100644 proxmox-frr-templates/templates/ospfd.jinja
 create mode 100644 proxmox-frr-templates/templates/protocol_routemaps.jinja
 create mode 100644 proxmox-frr-templates/templates/route_maps.jinja

diff --git a/Makefile b/Makefile
index 812bc8e691bf..58e4475161a1 100644
--- a/Makefile
+++ b/Makefile
@@ -2,6 +2,8 @@
 
 CRATES != echo proxmox-*/Cargo.toml | sed -e 's|/Cargo.toml||g'
 
+BUILDDIR = build
+
 # By default we just run checks:
 .PHONY: all
 all: check
@@ -25,6 +27,12 @@ dinstall:
 	$(MAKE) deb
 	sudo -k dpkg -i build/librust-*.deb
 
+proxmox-frr-templates-deb:
+	mkdir -p "${BUILDDIR}/proxmox-frr-templates"
+	cp -r proxmox-frr-templates/* "${BUILDDIR}/proxmox-frr-templates"
+	cd "${BUILDDIR}/proxmox-frr-templates"; dpkg-buildpackage -b -uc -us
+	touch $@
+
 %-deb:
 	./build.sh $*
 	touch $@
diff --git a/proxmox-frr-templates/.gitignore b/proxmox-frr-templates/.gitignore
new file mode 100644
index 000000000000..796b96d1c402
--- /dev/null
+++ b/proxmox-frr-templates/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/proxmox-frr-templates/Makefile b/proxmox-frr-templates/Makefile
new file mode 100644
index 000000000000..0b010ed71e7a
--- /dev/null
+++ b/proxmox-frr-templates/Makefile
@@ -0,0 +1,50 @@
+include /usr/share/dpkg/default.mk
+
+PACKAGE=proxmox-frr-templates
+
+GITVERSION:=$(shell git rev-parse HEAD)
+
+BUILDDIR ?= build/$(PACKAGE)-$(DEB_VERSION)
+DSC=$(PACKAGE)_$(DEB_VERSION).dsc
+
+PVE_DEB=$(PACKAGE)_$(DEB_VERSION_UPSTREAM_REVISION)_all.deb
+
+DEBS=$(PVE_DEB)
+
+all: deb
+deb: $(DEBS)
+
+$(BUILDDIR):
+	rm -rf $(BUILDDIR)
+	mkdir -p $(BUILDDIR)
+	cp -a debian $(BUILDDIR)/
+	cp -a templates $(BUILDDIR)/ || true
+	echo "git clone git://git.proxmox.com/git/proxmox-ve-rs.git\\ngit checkout $(GITVERSION)" > $(BUILDDIR)/debian/SOURCE
+
+$(PVE_DEB): $(BUILDDIR)
+	cd $(BUILDDIR); dpkg-buildpackage -b -uc -us
+	lintian build/$(DEBS)
+
+dsc: $(DSC)
+	$(MAKE) clean
+	$(MAKE) $(DSC)
+	lintian build/$(DSC)
+
+$(DSC): $(BUILDDIR)
+	cd $(BUILDDIR); dpkg-buildpackage -S -uc -us
+
+sbuild: $(DSC)
+	sbuild build/$(DSC)
+
+.PHONY: upload
+upload: UPLOAD_DIST ?= $(DEB_DISTRIBUTION)
+upload: $(DEBS)
+	tar cf - build/$(DEBS)|ssh repoman@repo.proxmox.com -- upload --product devel --dist $(UPLOAD_DIST)
+
+.PHONY: distclean
+distclean: clean
+
+.PHONY: clean
+clean:
+	rm -rf build
+
diff --git a/proxmox-frr-templates/debian/changelog b/proxmox-frr-templates/debian/changelog
new file mode 100644
index 000000000000..e70d0e12dfa8
--- /dev/null
+++ b/proxmox-frr-templates/debian/changelog
@@ -0,0 +1,5 @@
+proxmox-frr-templates (0.1.0-1) trixie; urgency=medium
+
+  * Initial release.
+
+ -- Proxmox Support Team <support@proxmox.com>  Wed, 21 Jan 2026 15:53:51 +0100
diff --git a/proxmox-frr-templates/debian/control b/proxmox-frr-templates/debian/control
new file mode 100644
index 000000000000..d144d3f5f6b0
--- /dev/null
+++ b/proxmox-frr-templates/debian/control
@@ -0,0 +1,17 @@
+Source: proxmox-frr-templates
+Section: admin
+Priority: important
+Maintainer: Proxmox Support Team <support@proxmox.com>
+Standards-Version: 4.7.2
+Rules-Requires-Root: no
+Build-Depends: debhelper-compat (= 13)
+Vcs-Git: git://git.proxmox.com/git/proxmox-ve-rs.git
+Vcs-Browser: https://git.proxmox.com/?p=proxmox-ve-rs.git
+Homepage: https://proxmox.com
+
+Package: proxmox-frr-templates
+Architecture: all
+Depends: ${misc:Depends}
+Description: Provides template files which are used by the Proxmox VE SDN stack
+ to generate FRR config files.
+
diff --git a/proxmox-frr-templates/debian/copyright b/proxmox-frr-templates/debian/copyright
new file mode 100644
index 000000000000..1ea8a56b4f58
--- /dev/null
+++ b/proxmox-frr-templates/debian/copyright
@@ -0,0 +1,18 @@
+Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
+
+Files:
+ *
+Copyright: 2019 - 2025 Proxmox Server Solutions GmbH <support@proxmox.com>
+License: AGPL-3.0-or-later
+ This program is free software: you can redistribute it and/or modify it under
+ the terms of the GNU Affero General Public License as published by the Free
+ Software Foundation, either version 3 of the License, or (at your option) any
+ later version.
+ .
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
+ details.
+ .
+ You should have received a copy of the GNU Affero General Public License along
+ with this program. If not, see <https://www.gnu.org/licenses/>.
diff --git a/proxmox-frr-templates/debian/proxmox-frr-templates.install b/proxmox-frr-templates/debian/proxmox-frr-templates.install
new file mode 100644
index 000000000000..a8e3df9d7260
--- /dev/null
+++ b/proxmox-frr-templates/debian/proxmox-frr-templates.install
@@ -0,0 +1 @@
+templates/* /usr/share/proxmox-frr/templates
diff --git a/proxmox-frr-templates/debian/rules b/proxmox-frr-templates/debian/rules
new file mode 100755
index 000000000000..abde6ef2247c
--- /dev/null
+++ b/proxmox-frr-templates/debian/rules
@@ -0,0 +1,5 @@
+#!/usr/bin/make -f
+
+%:
+	dh $@
+
diff --git a/proxmox-frr-templates/templates/access_list.jinja b/proxmox-frr-templates/templates/access_list.jinja
new file mode 100644
index 000000000000..5572fb9b0304
--- /dev/null
+++ b/proxmox-frr-templates/templates/access_list.jinja
@@ -0,0 +1,6 @@
+{% for access_list in access_lists %}
+!
+{%  for rule in access_list.rules %}
+{{ "ipv6 " if rule.is_ipv6 }}access-list {{ access_list.name }} {{ ("seq " ~ rule.seq ~ " ") if rule.seq }}{{ rule.action }} {{ rule.network }}
+{%  endfor%}
+{% endfor %}
diff --git a/proxmox-frr-templates/templates/access_lists.jinja b/proxmox-frr-templates/templates/access_lists.jinja
new file mode 100644
index 000000000000..25f27a293529
--- /dev/null
+++ b/proxmox-frr-templates/templates/access_lists.jinja
@@ -0,0 +1,6 @@
+{% for access_list_name, access_list in access_lists | items %}
+!
+{%  for rule in access_list %}
+{{ "ipv6 " if rule.is_ipv6 }}access-list {{ access_list_name }} {{ ("seq " ~ rule.seq ~ " ") if rule.seq }}{{ rule.action }} {{ rule.network }}
+{%  endfor%}
+{% endfor %}
diff --git a/proxmox-frr-templates/templates/fabricd.jinja b/proxmox-frr-templates/templates/fabricd.jinja
new file mode 100644
index 000000000000..4857a24ebab4
--- /dev/null
+++ b/proxmox-frr-templates/templates/fabricd.jinja
@@ -0,0 +1,29 @@
+{% from "interface.jinja" import interface %}
+{% for router_name, router_config in openfabric.router|items %}
+!
+router openfabric {{ router_name }}
+ net {{ router_config.net }}
+exit
+{% endfor %}
+{% for interface_name, interface_config in openfabric.interfaces|items %}
+{% call interface(interface_name, interface_config.addresses) %}
+{% if interface_config.fabric_id and interface_config.is_ipv4 %}
+ ip router openfabric {{ interface_config.fabric_id }}
+{% endif %}
+{% if interface_config.fabric_id and interface_config.is_ipv6 %}
+ ipv6 router openfabric {{ interface_config.fabric_id }}
+{% endif %}
+{% if interface_config.passive %}
+ openfabric passive
+{% endif %}
+{% if interface_config.hello_interval %}
+ openfabric hello-interval {{ interface_config.hello_interval}}
+{% endif %}
+{% if interface_config.hello_multiplier %}
+ openfabric hello-multiplier {{ interface_config.hello_multiplier}}
+{% endif %}
+{% if interface_config.csnp_interval %}
+ openfabric csnp-interval {{ interface_config.csnp_interval}}
+{% endif %}
+{%- endcall %}
+{%- endfor %}
diff --git a/proxmox-frr-templates/templates/frr.conf.jinja b/proxmox-frr-templates/templates/frr.conf.jinja
new file mode 100644
index 000000000000..8458c6a61112
--- /dev/null
+++ b/proxmox-frr-templates/templates/frr.conf.jinja
@@ -0,0 +1,5 @@
+{% include "fabricd.jinja" %}
+{% include "ospfd.jinja" %}
+{% include "access_lists.jinja" %}
+{% include "route_maps.jinja" %}
+{% include "protocol_routemaps.jinja" %}
diff --git a/proxmox-frr-templates/templates/interface.jinja b/proxmox-frr-templates/templates/interface.jinja
new file mode 100644
index 000000000000..c3c3b6c3526f
--- /dev/null
+++ b/proxmox-frr-templates/templates/interface.jinja
@@ -0,0 +1,9 @@
+{% macro interface(name, addresses) %}
+!
+interface {{ name }}
+{% for address in addresses %}
+ ip address {{address}}
+{% endfor %}
+{{ caller() -}}
+exit
+{% endmacro %}
diff --git a/proxmox-frr-templates/templates/ospfd.jinja b/proxmox-frr-templates/templates/ospfd.jinja
new file mode 100644
index 000000000000..8f9e76390f75
--- /dev/null
+++ b/proxmox-frr-templates/templates/ospfd.jinja
@@ -0,0 +1,18 @@
+{% from "interface.jinja" import interface %}
+{% if ospf.router %}
+!
+router ospf
+ ospf router-id {{ ospf.router.router_id }}
+exit
+{% endif %}
+{% for interface_name, interface_config in ospf.interfaces|items %}
+{% call interface(interface_name, interface_config.addresses) %}
+ ip ospf area {{ interface_config.area }}
+{% if interface_config.passive %}
+ ip ospf passive
+{% endif %}
+{% if interface_config.network_type %}
+ ip ospf network {{ interface_config.network_type }}
+{% endif %}
+{% endcall %}
+{% endfor %}
diff --git a/proxmox-frr-templates/templates/protocol_routemaps.jinja b/proxmox-frr-templates/templates/protocol_routemaps.jinja
new file mode 100644
index 000000000000..38c00b6407ee
--- /dev/null
+++ b/proxmox-frr-templates/templates/protocol_routemaps.jinja
@@ -0,0 +1,10 @@
+{% for protocol_name, protocol_routemap in protocol_routemaps | items %}
+!
+{% if protocol_routemap.v4 %}
+ip protocol {{ protocol_name }} route-map {{ protocol_routemap.v4 }}
+{% endif %}
+{% if protocol_routemap.v6 %}
+!
+ipv6 protocol {{ protocol_name }} route-map {{ protocol_routemap.v6 }}
+{% endif %}
+{% endfor %}
diff --git a/proxmox-frr-templates/templates/route_maps.jinja b/proxmox-frr-templates/templates/route_maps.jinja
new file mode 100644
index 000000000000..61fbf3256a19
--- /dev/null
+++ b/proxmox-frr-templates/templates/route_maps.jinja
@@ -0,0 +1,20 @@
+{% for name, routemap_list in routemaps | items %}
+{% for routemap in routemap_list %}
+!
+route-map {{ name }} {{ routemap.action }} {{ routemap.seq }}
+{%  for match in routemap.matches %}
+{%   if match.value.list_type == "prefixlist" %}
+ match {{ match.protocol_type }} {{ match.match_type }} prefix-list {{ match.value.list_name }}
+{%   elif match.value.list_type == "accesslist" %}
+ match {{ match.protocol_type }} {{ match.match_type }} {{ match.value.list_name }}
+{%   endif %}
+{%  endfor %}
+{%  for set in routemap.sets %}
+ set {{ set.set_type }} {{ set.value }}
+{%  endfor %}
+{% for line in routemap.custom_frr_config %}
+{{ line }}
+{% endfor %}
+exit
+{% endfor %}
+{% endfor %}
-- 
2.47.3





  parent reply	other threads:[~2026-02-03 16:04 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-03 16:01 [PATCH docs/manager/network/proxmox{-ve-rs,-perl-rs} 00/23] Generate frr config using jinja templates and rust types Gabriel Goller
2026-02-03 16:01 ` [PATCH proxmox-ve-rs 1/9] ve-config: firewall: cargo fmt Gabriel Goller
2026-02-03 16:01 ` Gabriel Goller [this message]
2026-02-03 16:01 ` [PATCH proxmox-ve-rs 3/9] ve-config: remove FrrConfigBuilder struct Gabriel Goller
2026-02-03 16:01 ` [PATCH proxmox-ve-rs 4/9] sdn-types: support variable-length NET identifier Gabriel Goller
2026-02-03 16:01 ` [PATCH proxmox-ve-rs 5/9] frr: add template serializer and serialize fabrics using templates Gabriel Goller
2026-02-03 16:01 ` [PATCH proxmox-ve-rs 6/9] frr: add isis configuration and templates Gabriel Goller
2026-02-03 16:01 ` [PATCH proxmox-ve-rs 7/9] frr: support custom frr configuration lines Gabriel Goller
2026-02-03 16:01 ` [PATCH proxmox-ve-rs 8/9] frr: add bgp support with templates and serialization Gabriel Goller
2026-02-03 16:01 ` [PATCH proxmox-ve-rs 9/9] frr: store frr template content as a const map Gabriel Goller
2026-02-03 16:01 ` [PATCH proxmox-perl-rs 1/2] sdn: add function to generate the frr config for all daemons Gabriel Goller
2026-02-03 16:01 ` [PATCH proxmox-perl-rs 2/2] sdn: add method to get a frr template Gabriel Goller
2026-02-03 16:01 ` [PATCH pve-network 01/10] sdn: remove duplicate comment line '!' in frr config Gabriel Goller
2026-02-03 16:01 ` [PATCH pve-network 02/10] sdn: tests: add missing comment " Gabriel Goller
2026-02-03 16:01 ` [PATCH pve-network 03/10] tests: use Test::Differences to make test assertions Gabriel Goller
2026-02-03 16:01 ` [PATCH pve-network 04/10] sdn: write structured frr config that can be rendered using templates Gabriel Goller
2026-02-03 16:01 ` [PATCH pve-network 05/10] tests: rearrange some statements in the frr config Gabriel Goller
2026-02-03 16:01 ` [PATCH pve-network 06/10] sdn: adjust frr.conf.local merging to rust template types Gabriel Goller
2026-02-03 16:01 ` [PATCH pve-network 07/10] cli: add pvesdn cli tool for managing frr template overrides Gabriel Goller
2026-02-03 16:01 ` [PATCH pve-network 08/10] debian: handle user modifications to FRR templates via ucf Gabriel Goller
2026-02-03 16:01 ` [PATCH pve-network 09/10] api: add dry-run endpoint for sdn apply to preview changes Gabriel Goller
2026-02-03 16:01 ` [PATCH pve-network 10/10] test: add test for frr.conf.local merging Gabriel Goller
2026-02-03 16:01 ` [PATCH pve-manager 1/1] sdn: add dry-run view for sdn apply Gabriel Goller
2026-02-03 16:01 ` [PATCH pve-docs 1/1] docs: add man page for the `pvesdn` cli Gabriel Goller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260203160246.353351-3-g.goller@proxmox.com \
    --to=g.goller@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal