summaryrefslogtreecommitdiff
path: root/src/etc/dhcp/dhclient-exit-hooks.d
diff options
context:
space:
mode:
authorRoss Dougherty <ross@dougherty.id.au>2021-10-20 23:50:51 +1100
committerChristian Poessinger <christian@poessinger.com>2021-10-21 20:07:14 +0200
commit927ff3abba7610f7e70a4672bfd28156ace2915d (patch)
tree3e4a458d1f1d13379d2fba751ee9c598e144d11a /src/etc/dhcp/dhclient-exit-hooks.d
parent77fddf724490e9dda77b92d651f6d508b949f3b0 (diff)
downloadvyos-1x-927ff3abba7610f7e70a4672bfd28156ace2915d.tar.gz
vyos-1x-927ff3abba7610f7e70a4672bfd28156ace2915d.zip
dhclient hooks: T3920: avoid 'too many args' error when no vrf
(cherry picked from commit 67b3dd6b4715fef266eb47e68623944f8be617e0)
Diffstat (limited to 'src/etc/dhcp/dhclient-exit-hooks.d')
-rw-r--r--src/etc/dhcp/dhclient-exit-hooks.d/01-vyos-cleanup12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/etc/dhcp/dhclient-exit-hooks.d/01-vyos-cleanup b/src/etc/dhcp/dhclient-exit-hooks.d/01-vyos-cleanup
index 694d53b6b..fec792b64 100644
--- a/src/etc/dhcp/dhclient-exit-hooks.d/01-vyos-cleanup
+++ b/src/etc/dhcp/dhclient-exit-hooks.d/01-vyos-cleanup
@@ -15,10 +15,16 @@ if [[ $reason =~ (EXPIRE|FAIL|RELEASE|STOP) ]]; then
if_metric="$IF_METRIC"
- # try to delete default ip route
+ # try to delete default ip route
for router in $old_routers; do
- logmsg info "Deleting default route: via $router dev ${interface} ${if_metric:+metric $if_metric}"
- ip -4 route del default via $router dev ${interface} ${if_metric:+metric $if_metric}
+ # check if we are bound to a VRF
+ local vrf_name=$(basename /sys/class/net/${interface}/upper_* | sed -e 's/upper_//')
+ if [ "$vrf_name" != "*" ]; then
+ vrf="vrf $vrf_name"
+ fi
+
+ logmsg info "Deleting default route: via $router dev ${interface} ${if_metric:+metric $if_metric} ${vrf}"
+ ip -4 route del default via $router dev ${interface} ${if_metric:+metric $if_metric} ${vrf}
if_metric=$((if_metric+1))
done