summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-08-16 12:37:50 +0200
committerChristian Poessinger <christian@poessinger.com>2020-08-16 12:45:58 +0200
commit3104c0ea8284ac5039e1dbab4a3ccd193e748ede (patch)
tree587db85d894076c93534f57a31acfa73723ea167
parentfd830743cda009e13e3fb7a31f4ba895f5084f1b (diff)
downloadvyos-1x-3104c0ea8284ac5039e1dbab4a3ccd193e748ede.tar.gz
vyos-1x-3104c0ea8284ac5039e1dbab4a3ccd193e748ede.zip
ping: op-mode: T2762: always run in default VRF unless defined otherwise
When connected to VyOS by SSH through any VRF, every command is executed in the VRF context thus e.g. ping will run in VRF context but no VRF was defined on the CLI. ping should always run in the default VRF no matter where it is executed, unless a VRF instance is explicitly defined by CLI.
-rwxr-xr-xsrc/op_mode/ping.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/op_mode/ping.py b/src/op_mode/ping.py
index e56952c38..29b430d53 100755
--- a/src/op_mode/ping.py
+++ b/src/op_mode/ping.py
@@ -118,7 +118,8 @@ options = {
'vrf': {
'ping': 'sudo ip vrf exec {value} {command}',
'type': '<vrf>',
- 'help': 'Use specified VRF table'
+ 'help': 'Use specified VRF table',
+ 'dflt': 'default',
},
'verbose': {
'ping': '{command} -v',
@@ -207,6 +208,11 @@ if __name__ == '__main__':
sys.stdout.write(options[matched[0]]['type'])
sys.exit(0)
+ for name,option in options.items():
+ if 'dflt' in option and name not in args:
+ args.append(name)
+ args.append(option['dflt'])
+
try:
ip = socket.gethostbyname(host)
except socket.gaierror: