summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2022-07-05 10:39:32 +0200
committerChristian Poessinger <christian@poessinger.com>2022-07-05 12:21:45 +0200
commitda961052291515f2e31bb4eca4d9091fad8c4d3c (patch)
tree3f6968bdbf434e3d02d001cee9ef15d731475fcf
parent4d405cc696b777c3ed96f2d22c7c82ca40c39a88 (diff)
downloadvyos-1x-da961052291515f2e31bb4eca4d9091fad8c4d3c.tar.gz
vyos-1x-da961052291515f2e31bb4eca4d9091fad8c4d3c.zip
op-mode: bgp: T4494: add "reset bgp" op-mode tree
-rw-r--r--op-mode-definitions/include/bgp/reset-bgp-afi-common.xml.i20
-rw-r--r--op-mode-definitions/include/bgp/reset-bgp-neighbor-options.xml.i48
-rw-r--r--op-mode-definitions/include/bgp/reset-bgp-peer-group-vrf.xml.i14
-rw-r--r--op-mode-definitions/include/bgp/reset-bgp-peer-group.xml.i14
-rw-r--r--op-mode-definitions/reset-bgp.xml.in258
-rwxr-xr-xsrc/completion/list_bgp_neighbors.sh13
-rwxr-xr-xsrc/op_mode/vtysh_wrapper.sh5
7 files changed, 365 insertions, 7 deletions
diff --git a/op-mode-definitions/include/bgp/reset-bgp-afi-common.xml.i b/op-mode-definitions/include/bgp/reset-bgp-afi-common.xml.i
new file mode 100644
index 000000000..2f88daad3
--- /dev/null
+++ b/op-mode-definitions/include/bgp/reset-bgp-afi-common.xml.i
@@ -0,0 +1,20 @@
+<!-- included start from bgp/reset-bgp-afi-common.xml.i -->
+<node name="external">
+ <properties>
+ <help>Reset all external peers</help>
+ </properties>
+ <command>${vyos_op_scripts_dir}/vtysh_wrapper.sh $@</command>
+ <children>
+ #include <include/bgp/reset-bgp-neighbor-options.xml.i>
+ </children>
+</node>
+<tagNode name="1-4294967295">
+ <properties>
+ <help>Reset peers with the AS number</help>
+ </properties>
+ <command>${vyos_op_scripts_dir}/vtysh_wrapper.sh $@</command>
+ <children>
+ #include <include/bgp/reset-bgp-neighbor-options.xml.i>
+ </children>
+</tagNode>
+<!-- included end -->
diff --git a/op-mode-definitions/include/bgp/reset-bgp-neighbor-options.xml.i b/op-mode-definitions/include/bgp/reset-bgp-neighbor-options.xml.i
new file mode 100644
index 000000000..d9feee18a
--- /dev/null
+++ b/op-mode-definitions/include/bgp/reset-bgp-neighbor-options.xml.i
@@ -0,0 +1,48 @@
+<!-- included start from bgp/reset-bgp-neighbor-options.xml.i -->
+<node name="in">
+ <properties>
+ <help>Send route-refresh unless using 'soft-reconfiguration inbound'</help>
+ </properties>
+ <command>${vyos_op_scripts_dir}/vtysh_wrapper.sh $@</command>
+ <children>
+ <leafNode name="prefix-filter">
+ <properties>
+ <help>Push out prefix-list ORF and do inbound soft reconfig</help>
+ </properties>
+ <command>${vyos_op_scripts_dir}/vtysh_wrapper.sh $@</command>
+ </leafNode>
+ </children>
+</node>
+<leafNode name="message-stats">
+ <properties>
+ <help>Reset message statistics</help>
+ </properties>
+ <command>${vyos_op_scripts_dir}/vtysh_wrapper.sh $@</command>
+</leafNode>
+<leafNode name="out">
+ <properties>
+ <help>Resend all outbound updates</help>
+ </properties>
+ <command>${vyos_op_scripts_dir}/vtysh_wrapper.sh $@</command>
+</leafNode>
+<node name="soft">
+ <properties>
+ <help>Soft reconfig inbound and outbound updates</help>
+ </properties>
+ <command>${vyos_op_scripts_dir}/vtysh_wrapper.sh $@</command>
+ <children>
+ <node name="in">
+ <properties>
+ <help>Send route-refresh unless using 'soft-reconfiguration inbound'</help>
+ </properties>
+ <command>${vyos_op_scripts_dir}/vtysh_wrapper.sh $@</command>
+ </node>
+ <node name="out">
+ <properties>
+ <help>Resend all outbound updates</help>
+ </properties>
+ <command>${vyos_op_scripts_dir}/vtysh_wrapper.sh $@</command>
+ </node>
+ </children>
+</node>
+<!-- included end -->
diff --git a/op-mode-definitions/include/bgp/reset-bgp-peer-group-vrf.xml.i b/op-mode-definitions/include/bgp/reset-bgp-peer-group-vrf.xml.i
new file mode 100644
index 000000000..c1a24bae2
--- /dev/null
+++ b/op-mode-definitions/include/bgp/reset-bgp-peer-group-vrf.xml.i
@@ -0,0 +1,14 @@
+<!-- included start from bgp/reset-bgp-peer-group-vrf.xml.i -->
+<tagNode name="peer-group">
+ <properties>
+ <help>Reset all members of peer-group</help>
+ <completionHelp>
+ <path>vrf name ${COMP_WORDS[4]} protocols bgp peer-group</path>
+ </completionHelp>
+ </properties>
+ <command>${vyos_op_scripts_dir}/vtysh_wrapper.sh $@</command>
+ <children>
+ #include <include/bgp/reset-bgp-neighbor-options.xml.i>
+ </children>
+</tagNode>
+<!-- included end -->
diff --git a/op-mode-definitions/include/bgp/reset-bgp-peer-group.xml.i b/op-mode-definitions/include/bgp/reset-bgp-peer-group.xml.i
new file mode 100644
index 000000000..c26e47b47
--- /dev/null
+++ b/op-mode-definitions/include/bgp/reset-bgp-peer-group.xml.i
@@ -0,0 +1,14 @@
+<!-- included start from bgp/reset-bgp-peer-group.xml.i -->
+<tagNode name="peer-group">
+ <properties>
+ <help>Reset all members of peer-group</help>
+ <completionHelp>
+ <path>protocols bgp peer-group</path>
+ </completionHelp>
+ </properties>
+ <command>${vyos_op_scripts_dir}/vtysh_wrapper.sh $@</command>
+ <children>
+ #include <include/bgp/reset-bgp-neighbor-options.xml.i>
+ </children>
+</tagNode>
+<!-- included end -->
diff --git a/op-mode-definitions/reset-bgp.xml.in b/op-mode-definitions/reset-bgp.xml.in
new file mode 100644
index 000000000..a1d42d4a3
--- /dev/null
+++ b/op-mode-definitions/reset-bgp.xml.in
@@ -0,0 +1,258 @@
+<?xml version="1.0"?>
+<interfaceDefinition>
+ <node name="reset">
+ <children>
+ <node name="bgp">
+ <properties>
+ <help>Border Gateway Protocol (BGP) information</help>
+ </properties>
+ <children>
+ <leafNode name="all">
+ <properties>
+ <help>Clear all peers</help>
+ </properties>
+ <command>vtysh -c "clear bgp *"</command>
+ </leafNode>
+ #include <include/bgp/reset-bgp-afi-common.xml.i>
+ #include <include/bgp/reset-bgp-peer-group.xml.i>
+ <tagNode name="prefix">
+ <properties>
+ <help>Clear bestpath and re-advertise</help>
+ <completionHelp>
+ <list>&lt;x.x.x.x/x&gt;</list>
+ </completionHelp>
+ </properties>
+ <command>${vyos_op_scripts_dir}/vtysh_wrapper.sh $@</command>
+ </tagNode>
+ <node name="ipv4">
+ <properties>
+ <help>IPv4 Address Family</help>
+ </properties>
+ <children>
+ <leafNode name="all">
+ <properties>
+ <help>Clear all peers</help>
+ </properties>
+ <command>vtysh -c "clear bgp ipv4 *"</command>
+ </leafNode>
+ #include <include/bgp/reset-bgp-afi-common.xml.i>
+ #include <include/bgp/reset-bgp-peer-group.xml.i>
+ </children>
+ </node>
+ <tagNode name="ipv4">
+ <properties>
+ <help>IPv4 neighbor to clear</help>
+ <completionHelp>
+ <script>${vyos_completion_dir}/list_bgp_neighbors.sh --ipv4</script>
+ </completionHelp>
+ </properties>
+ <command>${vyos_op_scripts_dir}/vtysh_wrapper.sh $@</command>
+ <children>
+ #include <include/bgp/reset-bgp-neighbor-options.xml.i>
+ </children>
+ </tagNode>
+ <node name="ipv6">
+ <properties>
+ <help>IPv6 Address Family</help>
+ </properties>
+ <children>
+ <leafNode name="all">
+ <properties>
+ <help>Clear all peers</help>
+ </properties>
+ <command>vtysh -c "clear bgp ipv6 *"</command>
+ </leafNode>
+ #include <include/bgp/reset-bgp-afi-common.xml.i>
+ #include <include/bgp/reset-bgp-peer-group.xml.i>
+ </children>
+ </node>
+ <tagNode name="ipv6">
+ <properties>
+ <help>IPv6 neighbor to clear</help>
+ <completionHelp>
+ <script>${vyos_completion_dir}/list_bgp_neighbors.sh --ipv6</script>
+ </completionHelp>
+ </properties>
+ <command>${vyos_op_scripts_dir}/vtysh_wrapper.sh $@</command>
+ <children>
+ #include <include/bgp/reset-bgp-neighbor-options.xml.i>
+ </children>
+ </tagNode>
+ <node name="l2vpn">
+ <properties>
+ <help>Layer 2 Virtual Private Network Address Family</help>
+ </properties>
+ <children>
+ <node name="evpn">
+ <properties>
+ <help>Ethernet Virtual Private Network</help>
+ </properties>
+ <children>
+ <leafNode name="all">
+ <properties>
+ <help>Clear all peers</help>
+ </properties>
+ <command>vtysh -c "clear bgp l2vpn evpn *"</command>
+ </leafNode>
+ #include <include/bgp/reset-bgp-afi-common.xml.i>
+ #include <include/bgp/reset-bgp-peer-group.xml.i>
+ </children>
+ </node>
+ <tagNode name="evpn">
+ <properties>
+ <help>BGP IPv4/IPv6 neighbor to clear</help>
+ <completionHelp>
+ <script>${vyos_completion_dir}/list_bgp_neighbors.sh --both</script>
+ </completionHelp>
+ </properties>
+ <command>${vyos_op_scripts_dir}/vtysh_wrapper.sh $@</command>
+ <children>
+ #include <include/bgp/reset-bgp-neighbor-options.xml.i>
+ </children>
+ </tagNode>
+ </children>
+ </node>
+ <tagNode name="vrf">
+ <properties>
+ <help>Virtual Routing and Forwarding (VRF)</help>
+ <completionHelp>
+ <path>vrf name</path>
+ </completionHelp>
+ </properties>
+ <children>
+ <node name="node.tag">
+ <properties>
+ <help>IPv4/IPv6 neighbor to clear</help>
+ <completionHelp>
+ <script>${vyos_completion_dir}/list_bgp_neighbors.sh --both --vrf ${COMP_WORDS[3]}</script>
+ </completionHelp>
+ </properties>
+ <command>${vyos_op_scripts_dir}/vtysh_wrapper.sh $@</command>
+ <children>
+ #include <include/bgp/reset-bgp-neighbor-options.xml.i>
+ </children>
+ </node>
+ <leafNode name="all">
+ <properties>
+ <help>Clear all peers</help>
+ </properties>
+ <command>vtysh -c "clear bgp vrf $4 *"</command>
+ </leafNode>
+ #include <include/bgp/reset-bgp-afi-common.xml.i>
+ #include <include/bgp/reset-bgp-peer-group-vrf.xml.i>
+ <tagNode name="prefix">
+ <properties>
+ <help>Clear bestpath and re-advertise</help>
+ <completionHelp>
+ <list>&lt;x.x.x.x/x&gt;</list>
+ </completionHelp>
+ </properties>
+ <command>${vyos_op_scripts_dir}/vtysh_wrapper.sh $@</command>
+ </tagNode>
+ <node name="ipv4">
+ <properties>
+ <help>IPv4 Address Family</help>
+ </properties>
+ <children>
+ <leafNode name="all">
+ <properties>
+ <help>Clear all peers</help>
+ </properties>
+ <command>vtysh -c "clear bgp vrf $4 ipv4 *"</command>
+ </leafNode>
+ #include <include/bgp/reset-bgp-afi-common.xml.i>
+ #include <include/bgp/reset-bgp-peer-group-vrf.xml.i>
+ </children>
+ </node>
+ <tagNode name="ipv4">
+ <properties>
+ <help>IPv4 neighbor to clear</help>
+ <completionHelp>
+ <script>${vyos_completion_dir}/list_bgp_neighbors.sh --ipv4 --vrf ${COMP_WORDS[3]}</script>
+ </completionHelp>
+ </properties>
+ <command>${vyos_op_scripts_dir}/vtysh_wrapper.sh $@</command>
+ <children>
+ #include <include/bgp/reset-bgp-neighbor-options.xml.i>
+ </children>
+ </tagNode>
+ <node name="ipv6">
+ <properties>
+ <help>IPv6 Address Family</help>
+ </properties>
+ <children>
+ <leafNode name="all">
+ <properties>
+ <help>Clear all peers</help>
+ </properties>
+ <command>vtysh -c "clear bgp vrf $4 ipv6 *"</command>
+ </leafNode>
+ #include <include/bgp/reset-bgp-afi-common.xml.i>
+ #include <include/bgp/reset-bgp-peer-group-vrf.xml.i>
+ </children>
+ </node>
+ <tagNode name="ipv6">
+ <properties>
+ <help>IPv6 neighbor to clear</help>
+ <completionHelp>
+ <script>${vyos_completion_dir}/list_bgp_neighbors.sh --ipv6 --vrf ${COMP_WORDS[3]}</script>
+ </completionHelp>
+ </properties>
+ <command>${vyos_op_scripts_dir}/vtysh_wrapper.sh $@</command>
+ <children>
+ #include <include/bgp/reset-bgp-neighbor-options.xml.i>
+ </children>
+ </tagNode>
+ <node name="l2vpn">
+ <properties>
+ <help>Layer 2 Virtual Private Network Address Family</help>
+ </properties>
+ <children>
+ <node name="evpn">
+ <properties>
+ <help>Ethernet Virtual Private Network</help>
+ </properties>
+ <children>
+ <leafNode name="all">
+ <properties>
+ <help>Clear all peers</help>
+ </properties>
+ <command>vtysh -c "clear bgp vrf $4 l2vpn evpn *"</command>
+ </leafNode>
+ #include <include/bgp/reset-bgp-afi-common.xml.i>
+ #include <include/bgp/reset-bgp-peer-group-vrf.xml.i>
+ </children>
+ </node>
+ <tagNode name="evpn">
+ <properties>
+ <help>BGP IPv4/IPv6 neighbor to clear</help>
+ <completionHelp>
+ <script>${vyos_completion_dir}/list_bgp_neighbors.sh --both --vrf ${COMP_WORDS[3]}</script>
+ </completionHelp>
+ </properties>
+ <command>${vyos_op_scripts_dir}/vtysh_wrapper.sh $@</command>
+ <children>
+ #include <include/bgp/reset-bgp-neighbor-options.xml.i>
+ </children>
+ </tagNode>
+ </children>
+ </node>
+ </children>
+ </tagNode>
+ </children>
+ </node>
+ <tagNode name="bgp">
+ <properties>
+ <help>BGP IPv4/IPv6 neighbor to clear</help>
+ <completionHelp>
+ <script>${vyos_completion_dir}/list_bgp_neighbors.sh --both</script>
+ </completionHelp>
+ </properties>
+ <command>${vyos_op_scripts_dir}/vtysh_wrapper.sh $@</command>
+ <children>
+ #include <include/bgp/reset-bgp-neighbor-options.xml.i>
+ </children>
+ </tagNode>
+ </children>
+ </node>
+</interfaceDefinition>
diff --git a/src/completion/list_bgp_neighbors.sh b/src/completion/list_bgp_neighbors.sh
index f74f102ef..869a7ab0a 100755
--- a/src/completion/list_bgp_neighbors.sh
+++ b/src/completion/list_bgp_neighbors.sh
@@ -1,5 +1,5 @@
#!/bin/sh
-# Copyright (C) 2021 VyOS maintainers and contributors
+# Copyright (C) 2021-2022 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
@@ -18,19 +18,21 @@
ipv4=0
ipv6=0
+vrf=""
while [[ "$#" -gt 0 ]]; do
case $1 in
-4|--ipv4) ipv4=1 ;;
-6|--ipv6) ipv6=1 ;;
-b|--both) ipv4=1; ipv6=1 ;;
+ --vrf) vrf="vrf name $2"; shift ;;
*) echo "Unknown parameter passed: $1" ;;
esac
shift
done
declare -a vals
-eval "vals=($(cli-shell-api listActiveNodes protocols bgp neighbor))"
+eval "vals=($(cli-shell-api listActiveNodes $vrf protocols bgp neighbor))"
if [ $ipv4 -eq 1 ] && [ $ipv6 -eq 1 ]; then
echo -n '<x.x.x.x>' '<h:h:h:h:h:h:h:h>' ${vals[@]}
@@ -54,9 +56,10 @@ elif [ $ipv6 -eq 1 ] ; then
done
else
echo "Usage:"
- echo "-4|--ipv4 list only IPv4 peers"
- echo "-6|--ipv6 list only IPv6 peers"
- echo "--both list both IP4 and IPv6 peers"
+ echo "-4|--ipv4 list only IPv4 peers"
+ echo "-6|--ipv6 list only IPv6 peers"
+ echo "--both list both IP4 and IPv6 peers"
+ echo "--vrf <name> apply command to given VRF (optional)"
echo ""
exit 1
fi
diff --git a/src/op_mode/vtysh_wrapper.sh b/src/op_mode/vtysh_wrapper.sh
index 09980e14f..bc7814a7c 100755
--- a/src/op_mode/vtysh_wrapper.sh
+++ b/src/op_mode/vtysh_wrapper.sh
@@ -1,5 +1,6 @@
#!/bin/sh
declare -a tmp
-# FRR uses ospf6 where we use ospfv3, thus alter the command
-tmp=$(echo $@ | sed -e "s/ospfv3/ospf6/")
+# FRR uses ospf6 where we use ospfv3, and we use reset over clear for BGP,
+# thus alter the commands
+tmp=$(echo $@ | sed -e "s/ospfv3/ospf6/" | sed -e "s/^reset bgp/clear bgp/")
vtysh -c "$tmp"