summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/conf_mode/protocols_ospf.py14
-rwxr-xr-xsrc/conf_mode/protocols_ospfv3.py1
-rwxr-xr-xsrc/conf_mode/protocols_rpki.py1
-rwxr-xr-xsrc/op_mode/powerctrl.py2
-rwxr-xr-xsrc/op_mode/show_nat_translations.py2
-rwxr-xr-xsrc/op_mode/show_neigh.py96
6 files changed, 112 insertions, 4 deletions
diff --git a/src/conf_mode/protocols_ospf.py b/src/conf_mode/protocols_ospf.py
index 866b2db62..3310fac5a 100755
--- a/src/conf_mode/protocols_ospf.py
+++ b/src/conf_mode/protocols_ospf.py
@@ -97,8 +97,15 @@ def get_config(config=None):
default_values, ospf['area'][area]['virtual_link'][virtual_link])
if 'interface' in ospf:
- default_values = defaults(base + ['interface'])
for interface in ospf['interface']:
+ # We need to reload the defaults on every pass b/c of
+ # hello-multiplier dependency on dead-interval
+ default_values = defaults(base + ['interface'])
+ # If hello-multiplier is set, we need to remove the default from
+ # dead-interval.
+ if 'hello_multiplier' in ospf['interface'][interface]:
+ del default_values['dead_interval']
+
ospf['interface'][interface] = dict_merge(default_values,
ospf['interface'][interface])
@@ -120,6 +127,11 @@ def verify(ospf):
if 'interface' in ospf:
for interface in ospf['interface']:
verify_interface_exists(interface)
+ # One can not use dead-interval and hello-multiplier at the same
+ # time. FRR will only activate the last option set via CLI.
+ if {'hello_multiplier', 'dead_interval'} <= set(ospf['interface'][interface]):
+ raise ConfigError(f'Can not use hello-multiplier and dead-interval ' \
+ f'concurrently for "{interface}"!')
return None
diff --git a/src/conf_mode/protocols_ospfv3.py b/src/conf_mode/protocols_ospfv3.py
index 2fb600056..e008a350b 100755
--- a/src/conf_mode/protocols_ospfv3.py
+++ b/src/conf_mode/protocols_ospfv3.py
@@ -24,7 +24,6 @@ from vyos.configverify import verify_route_maps
from vyos.template import render
from vyos.template import render_to_string
from vyos.util import call
-from vyos.util import dict_search
from vyos.xml import defaults
from vyos import ConfigError
from vyos import frr
diff --git a/src/conf_mode/protocols_rpki.py b/src/conf_mode/protocols_rpki.py
index aa6f974ab..0b9525caf 100755
--- a/src/conf_mode/protocols_rpki.py
+++ b/src/conf_mode/protocols_rpki.py
@@ -20,7 +20,6 @@ from sys import exit
from vyos.config import Config
from vyos.configdict import dict_merge
-from vyos.configverify import verify_route_maps
from vyos.template import render
from vyos.template import render_to_string
from vyos.util import call
diff --git a/src/op_mode/powerctrl.py b/src/op_mode/powerctrl.py
index c000d7d06..f8b5a3dda 100755
--- a/src/op_mode/powerctrl.py
+++ b/src/op_mode/powerctrl.py
@@ -177,7 +177,7 @@ def main():
action="store_true")
action.add_argument("--check",
- help="Check pending chutdown",
+ help="Check pending shutdown",
action="store_true")
args = parser.parse_args()
diff --git a/src/op_mode/show_nat_translations.py b/src/op_mode/show_nat_translations.py
index 04c20e584..25091e9fc 100755
--- a/src/op_mode/show_nat_translations.py
+++ b/src/op_mode/show_nat_translations.py
@@ -51,6 +51,8 @@ def command(srcdest, proto, ipaddr):
command += f' --orig-src {ipaddr}'
if srcdest == 'destination':
command += ' -g'
+ if ipaddr:
+ command += f' --orig-dst {ipaddr}'
return command
diff --git a/src/op_mode/show_neigh.py b/src/op_mode/show_neigh.py
new file mode 100755
index 000000000..94e745493
--- /dev/null
+++ b/src/op_mode/show_neigh.py
@@ -0,0 +1,96 @@
+#!/usr/bin/env python3
+#
+# Copyright (C) 2020 VyOS maintainers and contributors
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 or later as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#ip -j -f inet neigh list | jq
+#[
+ #{
+ #"dst": "192.168.101.8",
+ #"dev": "enp0s25",
+ #"lladdr": "78:d2:94:72:77:7e",
+ #"state": [
+ #"STALE"
+ #]
+ #},
+ #{
+ #"dst": "192.168.101.185",
+ #"dev": "enp0s25",
+ #"lladdr": "34:46:ec:76:f8:9b",
+ #"state": [
+ #"STALE"
+ #]
+ #},
+ #{
+ #"dst": "192.168.101.225",
+ #"dev": "enp0s25",
+ #"lladdr": "c2:cb:fa:bf:a0:35",
+ #"state": [
+ #"STALE"
+ #]
+ #},
+ #{
+ #"dst": "192.168.101.1",
+ #"dev": "enp0s25",
+ #"lladdr": "00:98:2b:f8:3f:11",
+ #"state": [
+ #"REACHABLE"
+ #]
+ #},
+ #{
+ #"dst": "192.168.101.181",
+ #"dev": "enp0s25",
+ #"lladdr": "d8:9b:3b:d5:88:22",
+ #"state": [
+ #"STALE"
+ #]
+ #}
+#]
+
+import sys
+import argparse
+import json
+from vyos.util import cmd
+
+def main():
+ #parese args
+ parser = argparse.ArgumentParser()
+ parser.add_argument('--family', help='Protocol family', required=True)
+ args = parser.parse_args()
+
+ neigh_raw_json = cmd(f'ip -j -f {args.family} neigh list')
+ neigh_raw_json = neigh_raw_json.lower()
+ neigh_json = json.loads(neigh_raw_json)
+
+ format_neigh = '%-50s %-10s %-20s %s'
+ print(format_neigh % ("IP Address", "Device", "State", "LLADDR"))
+ print(format_neigh % ("----------", "------", "-----", "------"))
+
+ if neigh_json is not None:
+ for neigh_item in neigh_json:
+ dev = neigh_item['dev']
+ dst = neigh_item['dst']
+ lladdr = neigh_item['lladdr'] if 'lladdr' in neigh_item else ''
+ state = neigh_item['state']
+
+ i = 0
+ for state_item in state:
+ if i == 0:
+ print(format_neigh % (dst, dev, state_item, lladdr))
+ else:
+ print(format_neigh % ('', '', state_item, ''))
+ i+=1
+
+if __name__ == '__main__':
+ main()