summaryrefslogtreecommitdiff
path: root/src/etc/dhcp/dhclient-enter-hooks.d
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-08-15 22:54:23 +0200
committerChristian Poessinger <christian@poessinger.com>2020-08-15 22:54:23 +0200
commit910fc06cfd4160705f12d890ca6a6b8436326a67 (patch)
treed097792cd79a0dbf8533a211fd06bd17315ea838 /src/etc/dhcp/dhclient-enter-hooks.d
parenta8f5cc26273e561bb4d4df088f13e7b6023dad5e (diff)
downloadvyos-1x-910fc06cfd4160705f12d890ca6a6b8436326a67.tar.gz
vyos-1x-910fc06cfd4160705f12d890ca6a6b8436326a67.zip
dhclient: T2277: retrieve VRF inform from sysfs rather then iproute2
Diffstat (limited to 'src/etc/dhcp/dhclient-enter-hooks.d')
-rw-r--r--src/etc/dhcp/dhclient-enter-hooks.d/03-vyos-ipwrapper11
1 files changed, 5 insertions, 6 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 60e001af7..1e102c2d7 100644
--- a/src/etc/dhcp/dhclient-enter-hooks.d/03-vyos-ipwrapper
+++ b/src/etc/dhcp/dhclient-enter-hooks.d/03-vyos-ipwrapper
@@ -20,7 +20,7 @@ function iptovtysh () {
local VTYSH_NETADDR=""
local VTYSH_GATEWAY=""
local VTYSH_DEV=""
- local VTYSH_VRF_NAME=$(ip -d link show dev $interface | grep $interface | awk '{print $9}')
+ local VTYSH_VRF_NAME=$(basename /sys/class/net/eth1/upper_* | sed -e 's/upper_//')
# convert default route to 0.0.0.0/0
if [ "$4" == "default" ] ; then
VTYSH_NETADDR="0.0.0.0/0"
@@ -42,12 +42,11 @@ function iptovtysh () {
VTYSH_DEV=$8
fi
- # check if vrf is present
- if [ $(ip -d link show dev $interface | grep vrf | wc -l) -eq 0 ]; then
- VTYSH_CMD="ip route $VTYSH_NETADDR $VTYSH_GATEWAY $VTYSH_DEV tag $VTYSH_TAG $VTYSH_DISTANCE"
- elif [ $(ip -d link show dev $interface | grep vrf | wc -l) -eq 1 ]; then
- VTYSH_CMD="ip route $VTYSH_NETADDR $VTYSH_GATEWAY $VTYSH_DEV tag $VTYSH_TAG $VTYSH_DISTANCE vrf $VTYSH_VRF_NAME"
+ # Add route to VRF routing table
+ if [ -n $VTYSH_VRF_NAME ]; then
+ VTYSH_VRF="vrf $VTYSH_VRF_NAME"
fi
+ VTYSH_CMD="ip route $VTYSH_NETADDR $VTYSH_GATEWAY $VTYSH_DEV tag $VTYSH_TAG $VTYSH_DISTANCE $VTYSH_VRF"
# delete route if the command is "del"
if [ "$3" == "del" ] ; then