diff options
| author | Christian Breunig <christian@breunig.cc> | 2025-10-18 13:14:54 +0200 |
|---|---|---|
| committer | Christian Breunig <christian@breunig.cc> | 2025-10-18 13:19:10 +0200 |
| commit | 6a5cd3b87b2dee397ddb4a72dffd25e4e24122f1 (patch) | |
| tree | a11137ca35472179b1ee7a535fef958723211820 /src | |
| parent | 69a9b93f71c818bf134ea06ad73d86a513628f06 (diff) | |
| download | vyos-1x-6a5cd3b87b2dee397ddb4a72dffd25e4e24122f1.tar.gz vyos-1x-6a5cd3b87b2dee397ddb4a72dffd25e4e24122f1.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/etc/dhcp/dhclient-enter-hooks.d/03-vyos-ipwrapper | 2 |
1 files changed, 1 insertions, 1 deletions
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 () { |
