From 6a5cd3b87b2dee397ddb4a72dffd25e4e24122f1 Mon Sep 17 00:00:00 2001 From: Christian Breunig Date: Sat, 18 Oct 2025 13:14:54 +0200 Subject: T7941: fix DHCP client running in VRF with non-word characters The previous implementation used awk with a regex to extract the VRF name from JSON data, relying on "(\w+)" to match the value. This broke for valid VRF names containing hyphens or other non-word characters. This update replaces the regex-based extraction with a jq query that reliably parses the JSON structure, ensuring correct behavior regardless of VRF name format. This also reduces parsing fragility by using a tool purpose-built for JSON processing. --- src/etc/dhcp/dhclient-enter-hooks.d/03-vyos-ipwrapper | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/etc/dhcp/dhclient-enter-hooks.d/03-vyos-ipwrapper b/src/etc/dhcp/dhclient-enter-hooks.d/03-vyos-ipwrapper index 2a1c5a7b2..1f27ee14c 100644 --- a/src/etc/dhcp/dhclient-enter-hooks.d/03-vyos-ipwrapper +++ b/src/etc/dhcp/dhclient-enter-hooks.d/03-vyos-ipwrapper @@ -4,7 +4,7 @@ IF_METRIC=${IF_METRIC:-210} # Check if interface is inside a VRF -VRF_OPTION=$(/usr/sbin/ip -j -d link show ${interface} | awk '{if(match($0, /.*"master":"(\w+)".*"info_slave_kind":"vrf"/, IFACE_DETAILS)) printf("vrf %s", IFACE_DETAILS[1])}') +VRF_OPTION=$(/usr/sbin/ip --json --detail link show ${interface} | jq -r '.[0] | select(.linkinfo.info_slave_kind == "vrf") | "vrf \(.master)"') # get status of FRR function frr_alive () { -- cgit v1.2.3