From: Remi Gacogne Date: Fri, 23 Aug 2024 13:17:33 +0000 (+0200) Subject: dnsdist: Add an optional YAML configuration switch X-Git-Tag: dnsdist-2.0.0-alpha1~160^2~32 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b5fe615630d358985f1c4d9aef2b596a5e7d81a6;p=thirdparty%2Fpdns.git dnsdist: Add an optional YAML configuration switch --- diff --git a/.github/workflows/build-and-test-all.yml b/.github/workflows/build-and-test-all.yml index 79af546f7c..f7ce113e02 100644 --- a/.github/workflows/build-and-test-all.yml +++ b/.github/workflows/build-and-test-all.yml @@ -252,6 +252,8 @@ jobs: path: ~/.ccache key: dnsdist-${{ matrix.features }}-${{ matrix.sanitizers }}-ccache-${{ steps.get-stamp.outputs.stamp }} restore-keys: dnsdist-${{ matrix.features }}-${{ matrix.sanitizers }}-ccache- + - run: inv install-lld-linker-if-needed + working-directory: ./pdns/dnsdistdist/ - run: inv ci-install-rust ${{ env.REPO_HOME }} working-directory: ./pdns/dnsdistdist/ - run: inv ci-build-and-install-quiche ${{ env.REPO_HOME }} diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index d7cdcc81c9..82d29cb0f7 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -150,6 +150,10 @@ jobs: if: matrix.product == 'dnsdist' run: | inv install-dnsdist-build-deps --skipXDP + # installing the python3-package does not work because of actions/setup-python which installs a different version in /opt/hostedtoolcache/Python + - name: Install python yaml + run: | + pip install pyyaml - name: Autoreconf dnsdist if: matrix.product == 'dnsdist' working-directory: ./pdns/dnsdistdist/ diff --git a/pdns/dnsdistdist/Makefile.am b/pdns/dnsdistdist/Makefile.am index a704f6a2aa..cefe0b021d 100644 --- a/pdns/dnsdistdist/Makefile.am +++ b/pdns/dnsdistdist/Makefile.am @@ -8,12 +8,19 @@ AM_CPPFLAGS += $(SYSTEMD_CFLAGS) \ $(NGHTTP2_CFLAGS) \ $(LIBCAP_CFLAGS) \ -I$(top_srcdir)/ext/protozero/include \ + -I$(top_srcdir)/dnsdist-rust-lib \ + -I$(top_builddir)/dnsdist-rust-lib \ + -I$(top_srcdir)/dnsdist-rust-lib/rust/src \ -DSYSCONFDIR=\"${sysconfdir}\" \ -DBOOST_CONTAINER_USE_STD_EXCEPTIONS +DNSDIST_RUST_LIBS = $(top_builddir)/dnsdist-rust-lib/rust/libdnsdist_rust.a $(LIBDL) + ACLOCAL_AMFLAGS = -I m4 -SUBDIRS=ext/arc4random \ +SUBDIRS=dnsdist-rust-lib \ + dnsdist-rust-lib/rust \ + ext/arc4random \ ext/ipcrypt \ ext/yahttp @@ -494,6 +501,10 @@ testrunner_SOURCES += doq-common.cc testrunner_LDADD += $(QUICHE_LDFLAGS) $(QUICHE_LIBS) endif +if HAVE_YAML_CONFIGURATION +dnsdist_LDADD += $(DNSDIST_RUST_LIBS) +endif + if !HAVE_LUA_HPP BUILT_SOURCES += lua.hpp nodist_dnsdist_SOURCES = lua.hpp diff --git a/pdns/dnsdistdist/configure.ac b/pdns/dnsdistdist/configure.ac index aa1892f4c1..f50b90e6e0 100644 --- a/pdns/dnsdistdist/configure.ac +++ b/pdns/dnsdistdist/configure.ac @@ -13,6 +13,9 @@ AC_DEFINE([DNSDIST], [1], [This is dnsdist] ) +# Warn when pkg.m4 is missing +m4_pattern_forbid([^_?PKG_[A-Z_]+$], [*** pkg.m4 missing, please install pkg-config]) + LT_PREREQ([2.2.2]) LT_INIT([disable-static]) @@ -132,6 +135,12 @@ AS_IF([test "x$enable_dns_over_http3" != "xno"], [ ]) ]) +DNSDIST_ENABLE_YAML + +AS_IF([test "x$enable_yaml" != "xno"], [ + PDNS_CHECK_CARGO([1.64]) +]) + DNSDIST_WITH_CDB PDNS_CHECK_LMDB PDNS_ENABLE_IPCIPHER @@ -190,6 +199,8 @@ AS_IF([test "x$PACKAGEVERSION" != "x"], ) AC_CONFIG_FILES([Makefile + dnsdist-rust-lib/Makefile + dnsdist-rust-lib/rust/Makefile ext/arc4random/Makefile ext/yahttp/Makefile ext/yahttp/yahttp/Makefile @@ -305,5 +316,9 @@ AS_IF([test "x$LMDB_LIBS" != "x"], [AC_MSG_NOTICE([lmdb: yes])], [AC_MSG_NOTICE([lmdb: no])] ) +AS_IF([test "x$enable_yaml" != "xno"], + [AC_MSG_NOTICE([YAML configuration: yes])], + [AC_MSG_NOTICE([YAML configuration: no])] +) AC_MSG_NOTICE([]) diff --git a/pdns/dnsdistdist/dnsdist-rust-lib/.gitignore b/pdns/dnsdistdist/dnsdist-rust-lib/.gitignore new file mode 100644 index 0000000000..b336cc7cec --- /dev/null +++ b/pdns/dnsdistdist/dnsdist-rust-lib/.gitignore @@ -0,0 +1,2 @@ +/Makefile +/Makefile.in diff --git a/pdns/dnsdistdist/dnsdist-rust-lib/Makefile.am b/pdns/dnsdistdist/dnsdist-rust-lib/Makefile.am new file mode 100644 index 0000000000..65595f3547 --- /dev/null +++ b/pdns/dnsdistdist/dnsdist-rust-lib/Makefile.am @@ -0,0 +1,4 @@ +EXTRA_DIST = \ + rust/src/lib.rs + +all: diff --git a/pdns/dnsdistdist/dnsdist-rust-lib/rust/.gitignore b/pdns/dnsdistdist/dnsdist-rust-lib/rust/.gitignore new file mode 100644 index 0000000000..e9a64ebe1d --- /dev/null +++ b/pdns/dnsdistdist/dnsdist-rust-lib/rust/.gitignore @@ -0,0 +1,5 @@ +/target +/Makefile +/Makefile.in +/cxx.h +/lib.rs.h diff --git a/pdns/dnsdistdist/dnsdist-rust-lib/rust/Cargo.lock b/pdns/dnsdistdist/dnsdist-rust-lib/rust/Cargo.lock new file mode 100644 index 0000000000..58b8d6f03a --- /dev/null +++ b/pdns/dnsdistdist/dnsdist-rust-lib/rust/Cargo.lock @@ -0,0 +1,332 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "anyhow" +version = "1.0.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" + +[[package]] +name = "cc" +version = "1.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50d2eb3cd3d1bf4529e31c215ee6f93ec5a3d536d9f578f93d9d33ee19562932" +dependencies = [ + "shlex", +] + +[[package]] +name = "codespan-reporting" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" +dependencies = [ + "termcolor", + "unicode-width", +] + +[[package]] +name = "cxx" +version = "1.0.126" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c4eae4b7fc8dcb0032eb3b1beee46b38d371cdeaf2d0c64b9944f6f69ad7755" +dependencies = [ + "cc", + "cxxbridge-flags", + "cxxbridge-macro", + "link-cplusplus", +] + +[[package]] +name = "cxx-build" +version = "1.0.126" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c822bf7fb755d97328d6c337120b6f843678178751cba33c9da25cf522272e0" +dependencies = [ + "cc", + "codespan-reporting", + "once_cell", + "proc-macro2", + "quote", + "scratch", + "syn", +] + +[[package]] +name = "cxxbridge-flags" +version = "1.0.126" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "719d6197dc016c88744aff3c0d0340a01ecce12e8939fc282e7c8f583ee64bc6" + +[[package]] +name = "cxxbridge-macro" +version = "1.0.126" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35de3b547387863c8f82013c4f79f1c2162edee956383e4089e1d04c18c4f16c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "dnsdist-rust" +version = "2.0.0" +dependencies = [ + "cxx", + "cxx-build", + "serde", + "serde_yml", +] + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" + +[[package]] +name = "indexmap" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93ead53efc7ea8ed3cfb0c79fc8023fbb782a5432b52830b6518941cebe6505c" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] +name = "libyml" +version = "0.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3302702afa434ffa30847a83305f0a69d6abd74293b6554c18ec85c7ef30c980" +dependencies = [ + "anyhow", + "version_check", +] + +[[package]] +name = "link-cplusplus" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d240c6f7e1ba3a28b0249f774e6a9dd0175054b52dfbb61b16eb8505c3785c9" +dependencies = [ + "cc", +] + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "proc-macro2" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] +name = "scratch" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3cf7c11c38cb994f3d40e8a8cde3bbd1f72a435e4c49e85d6553d8312306152" + +[[package]] +name = "serde" +version = "1.0.208" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cff085d2cb684faa248efb494c39b68e522822ac0de72ccf08109abde717cfb2" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.208" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24008e81ff7613ed8e5ba0cfaf24e2c2f1e5b8a0495711e44fcd4882fca62bcf" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_yml" +version = "0.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59e2dd588bf1597a252c3b920e0143eb99b0f76e4e082f4c92ce34fbc9e71ddd" +dependencies = [ + "indexmap", + "itoa", + "libyml", + "memchr", + "ryu", + "serde", + "version_check", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "syn" +version = "2.0.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6af063034fc1935ede7be0122941bafa9bacb949334d090b77ca98b5817c7d9" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "termcolor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "unicode-width" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "winapi-util" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" diff --git a/pdns/dnsdistdist/dnsdist-rust-lib/rust/Cargo.toml b/pdns/dnsdistdist/dnsdist-rust-lib/rust/Cargo.toml new file mode 100644 index 0000000000..d3537feb5c --- /dev/null +++ b/pdns/dnsdistdist/dnsdist-rust-lib/rust/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "dnsdist-rust" +# Convention: major/minor is equal to DNSdist's major/minor +version = "2.0.0" +edition = "2021" + +[lib] +name = "dnsdist_rust" +crate-type = ["staticlib"] + +[dependencies] +cxx = "1.0" +serde = { version = "1.0", features = ["derive"] } +serde_yaml = { package = "serde_yml", version = "0.0.12" } + +[build-dependencies] +cxx-build = "1.0" diff --git a/pdns/dnsdistdist/dnsdist-rust-lib/rust/Makefile.am b/pdns/dnsdistdist/dnsdist-rust-lib/rust/Makefile.am new file mode 100644 index 0000000000..c30191a2c5 --- /dev/null +++ b/pdns/dnsdistdist/dnsdist-rust-lib/rust/Makefile.am @@ -0,0 +1,21 @@ +CARGO ?= cargo + +EXTRA_DIST = \ + Cargo.toml \ + Cargo.lock \ + build.rs \ + src/helpers.rs + +if HAVE_YAML_CONFIGURATION +all install: libdnsdist_rust.a + +libdnsdist_rust.a: src/lib.rs src/helpers.rs Cargo.toml Cargo.lock + SYSCONFDIR=$(sysconfdir) $(CARGO) build --release $(RUST_TARGET) --target-dir=$(builddir)/target --manifest-path ${srcdir}/Cargo.toml + cp target/release/libdnsdist_rust.a libdnsdist_rust.a + cp target/cxxbridge/dnsdist-rust/src/lib.rs.h lib.rs.h + cp target/cxxbridge/rust/cxx.h cxx.h + +clean-local: + rm -rf libdnsdist_rust.a lib.rs.h cxx.h target + +endif diff --git a/pdns/dnsdistdist/dnsdist-rust-lib/rust/build.rs b/pdns/dnsdistdist/dnsdist-rust-lib/rust/build.rs new file mode 100644 index 0000000000..18d00f906a --- /dev/null +++ b/pdns/dnsdistdist/dnsdist-rust-lib/rust/build.rs @@ -0,0 +1,12 @@ +fn main() { + cxx_build::bridge("src/lib.rs") + .flag_if_supported("-std=c++17") + .flag("-Isrc") + .flag("-I.") + .flag("-I..") + .flag("-I../..") + .compile("dnsdist_rust"); + + println!("cargo:rerun-if-changed=src/lib.rs"); + println!("cargo:rerun-if-changed=src/helpers.rs"); +} \ No newline at end of file diff --git a/pdns/dnsdistdist/dnsdist-rust-lib/rust/src/helpers.rs b/pdns/dnsdistdist/dnsdist-rust-lib/rust/src/helpers.rs new file mode 100644 index 0000000000..289dfe6407 --- /dev/null +++ b/pdns/dnsdistdist/dnsdist-rust-lib/rust/src/helpers.rs @@ -0,0 +1,93 @@ +/* + * This file is part of PowerDNS or dnsdist. + * Copyright -- PowerDNS.COM B.V. and its contributors + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * In addition, for the avoidance of any doubt, permission is granted to + * link this program with OpenSSL and to (re)distribute the binaries + * produced as the result of such linking. + * + * 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +use crate::ValidationError; +use std::{error::Error, fmt}; + +/* Helper code for validation */ +impl Error for ValidationError {} +impl fmt::Display for ValidationError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", self.msg) + } +} + +// Generic helpers + +// A helper to define a function returning a constant value and an equal function as a Rust path */ +pub struct U64; +impl U64 { + pub const fn value() -> u64 { + U + } + pub fn is_equal(v: &u64) -> bool { + v == &U + } +} + +pub struct U32; +impl U32 { + pub const fn value() -> u32 { + U + } + pub fn is_equal(v: &u32) -> bool { + v == &U + } +} + +pub struct U16; +impl U16 { + pub const fn value() -> u16 { + U + } + pub fn is_equal(v: &u16) -> bool { + v == &U + } +} + +pub struct U8; +impl U8 { + pub const fn value() -> u8 { + U + } + pub fn is_equal(v: &u8) -> bool { + v == &U + } +} + +// A helper to define constant value as a Rust path */ +pub struct Bool; +impl Bool { + pub const fn value() -> bool { + U + } +} + +// A helper used to decide if a bool value should be skipped +pub fn if_true(v: &bool) -> bool { + *v +} + +/* Helper to decide if a value has a default value, as defined by Default trait */ +pub fn is_default(t: &T) -> bool { + t == &T::default() +} diff --git a/pdns/dnsdistdist/dnsdist-rust-lib/rust/src/lib.rs b/pdns/dnsdistdist/dnsdist-rust-lib/rust/src/lib.rs new file mode 100644 index 0000000000..5d614f0c44 --- /dev/null +++ b/pdns/dnsdistdist/dnsdist-rust-lib/rust/src/lib.rs @@ -0,0 +1,28 @@ +use serde::{Deserialize, Serialize}; + +mod helpers; +use helpers::*; + +// Suppresses "Deserialize unused" warning +#[derive(Deserialize, Serialize)] +struct UnusedStruct {} + +#[derive(Debug)] +pub struct ValidationError { + msg: String, +} + +#[cxx::bridge(namespace = dnsdist::rust::settings)] +mod dnsdistsetttings { + + #[derive(Deserialize, Serialize, Debug, PartialEq)] + #[serde(deny_unknown_fields)] + struct CarbonConfiguration { + #[serde(default, skip_serializing_if = "crate::is_default")] + address: String, + #[serde(default, skip_serializing_if = "crate::is_default")] + name: String, + #[serde(default, skip_serializing_if = "crate::is_default")] + interval: u16 + } +} diff --git a/pdns/dnsdistdist/m4/ax_compare_version.m4 b/pdns/dnsdistdist/m4/ax_compare_version.m4 new file mode 120000 index 0000000000..e9020c183c --- /dev/null +++ b/pdns/dnsdistdist/m4/ax_compare_version.m4 @@ -0,0 +1 @@ +../../../m4/ax_compare_version.m4 \ No newline at end of file diff --git a/pdns/dnsdistdist/m4/dnsdist_enable_yaml.m4 b/pdns/dnsdistdist/m4/dnsdist_enable_yaml.m4 new file mode 100644 index 0000000000..7705d857ac --- /dev/null +++ b/pdns/dnsdistdist/m4/dnsdist_enable_yaml.m4 @@ -0,0 +1,14 @@ +AC_DEFUN([DNSDIST_ENABLE_YAML], [ + AC_MSG_CHECKING([whether to enable YAML configuration]) + AC_ARG_ENABLE([yaml], + AS_HELP_STRING([--enable-yaml], [enable YAML configuration (requires Rust and Cargo) @<:@default=no@:>@]), + [enable_yaml=$enableval], + [enable_yaml=no] + ) + AC_MSG_RESULT([$enable_yaml]) + AM_CONDITIONAL([HAVE_YAML_CONFIGURATION], [test "x$enable_yaml" != "xno"]) + + AM_COND_IF([HAVE_YAML_CONFIGURATION], [ + AC_DEFINE([HAVE_YAML_CONFIGURATION], [1], [Define to 1 if you enable YAML configuration support]) + ]) +]) diff --git a/pdns/dnsdistdist/m4/pdns_check_cargo.m4 b/pdns/dnsdistdist/m4/pdns_check_cargo.m4 new file mode 120000 index 0000000000..114702d2bf --- /dev/null +++ b/pdns/dnsdistdist/m4/pdns_check_cargo.m4 @@ -0,0 +1 @@ +../../recursordist/m4/pdns_check_cargo.m4 \ No newline at end of file diff --git a/tasks.py b/tasks.py index b8e8f9535c..f40080069c 100644 --- a/tasks.py +++ b/tasks.py @@ -171,6 +171,11 @@ def apt_fresh(c): c.sudo('apt-get update') c.sudo('apt-get -y --allow-downgrades dist-upgrade') +@task +def install_lld_linker_if_needed(c): + if is_compiler_clang(): + c.sudo(f'apt-get -y --no-install-recommends install lld-{clang_version}') + @task def install_clang(c): """ @@ -453,12 +458,14 @@ def get_cxxflags(): ]) -def get_base_configure_cmd(additional_c_flags='', additional_cxx_flags='', enable_systemd=True, enable_sodium=True): +def get_base_configure_cmd(additional_c_flags='', additional_cxx_flags='', additional_ld_flags='', enable_systemd=True, enable_sodium=True): cflags = " ".join([get_cflags(), additional_c_flags]) cxxflags = " ".join([get_cxxflags(), additional_cxx_flags]) + ldflags = additional_ld_flags return " ".join([ f'CFLAGS="{cflags}"', f'CXXFLAGS="{cxxflags}"', + f'LDFLAGS="{ldflags}"', './configure', f"CC='{get_c_compiler()}'", f"CXX='{get_cxx_compiler()}'", @@ -657,6 +664,9 @@ def ci_rec_configure(c, features, build_dir=None, meson=False): @task def ci_dnsdist_configure(c, features): additional_flags = '' + additional_ld_flags = '' + if is_compiler_clang(): + additional_ld_flags += '-fuse-ld=lld ' if features == 'full': features_set = '--enable-dnstap \ --enable-dnscrypt \ @@ -665,6 +675,7 @@ def ci_dnsdist_configure(c, features): --enable-dns-over-quic \ --enable-dns-over-http3 \ --enable-systemd \ + --enable-yaml \ --prefix=/opt/dnsdist \ --with-gnutls \ --with-h2o \ @@ -725,7 +736,7 @@ def ci_dnsdist_configure(c, features): tools = f'''AR=llvm-ar-{clang_version} RANLIB=llvm-ranlib-{clang_version}''' if is_compiler_clang() else '' configure_cmd = " ".join([ tools, - get_base_configure_cmd(additional_c_flags='', additional_cxx_flags=additional_flags, enable_systemd=False, enable_sodium=False), + get_base_configure_cmd(additional_c_flags='', additional_cxx_flags=additional_flags, additional_ld_flags=additional_ld_flags, enable_systemd=False, enable_sodium=False), features_set, unittests, fuzztargets,