From 6f185cdfb5b33c0d8659cd268d32acccb9554ead Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Mon, 11 Mar 2024 13:31:38 +0100 Subject: [PATCH] confd: refactor gen-interfaces for hybrid bridge/iface setups Simplify interface generation by collapsing eth_ and ethlike_ifaces to a single list. Let gen_iface_json() determine interface type by querying each interface. This allows us to create bridge setups also for qemu use-cases. Signed-off-by: Joachim Wiberg --- src/confd/bin/gen-interfaces | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/confd/bin/gen-interfaces b/src/confd/bin/gen-interfaces index 45e3b961..984f47ed 100755 --- a/src/confd/bin/gen-interfaces +++ b/src/confd/bin/gen-interfaces @@ -56,17 +56,26 @@ EOF exit 0 } +iftype() +{ + iftype=$(ip -d -j link show "$1" |jq -r .[].parentbus) + if [ "$iftype" = "virtio" ]; then + echo "infix-if-type:etherlike" + else + echo "infix-if-type:ethernet" + fi +} + # shellcheck disable=SC3043 gen_iface_json() { - local iftype="$1" - local ifname="$2" - local br="$3" + local ifname="$1" + local br="$2" cat <