From da961052291515f2e31bb4eca4d9091fad8c4d3c Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Tue, 5 Jul 2022 10:39:32 +0200 Subject: op-mode: bgp: T4494: add "reset bgp" op-mode tree --- .../include/bgp/reset-bgp-afi-common.xml.i | 20 ++ .../include/bgp/reset-bgp-neighbor-options.xml.i | 48 ++++ .../include/bgp/reset-bgp-peer-group-vrf.xml.i | 14 ++ .../include/bgp/reset-bgp-peer-group.xml.i | 14 ++ op-mode-definitions/reset-bgp.xml.in | 258 +++++++++++++++++++++ src/completion/list_bgp_neighbors.sh | 13 +- src/op_mode/vtysh_wrapper.sh | 5 +- 7 files changed, 365 insertions(+), 7 deletions(-) create mode 100644 op-mode-definitions/include/bgp/reset-bgp-afi-common.xml.i create mode 100644 op-mode-definitions/include/bgp/reset-bgp-neighbor-options.xml.i create mode 100644 op-mode-definitions/include/bgp/reset-bgp-peer-group-vrf.xml.i create mode 100644 op-mode-definitions/include/bgp/reset-bgp-peer-group.xml.i create mode 100644 op-mode-definitions/reset-bgp.xml.in 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 @@ + + + + Reset all external peers + + ${vyos_op_scripts_dir}/vtysh_wrapper.sh $@ + + #include + + + + + Reset peers with the AS number + + ${vyos_op_scripts_dir}/vtysh_wrapper.sh $@ + + #include + + + 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 @@ + + + + Send route-refresh unless using 'soft-reconfiguration inbound' + + ${vyos_op_scripts_dir}/vtysh_wrapper.sh $@ + + + + Push out prefix-list ORF and do inbound soft reconfig + + ${vyos_op_scripts_dir}/vtysh_wrapper.sh $@ + + + + + + Reset message statistics + + ${vyos_op_scripts_dir}/vtysh_wrapper.sh $@ + + + + Resend all outbound updates + + ${vyos_op_scripts_dir}/vtysh_wrapper.sh $@ + + + + Soft reconfig inbound and outbound updates + + ${vyos_op_scripts_dir}/vtysh_wrapper.sh $@ + + + + Send route-refresh unless using 'soft-reconfiguration inbound' + + ${vyos_op_scripts_dir}/vtysh_wrapper.sh $@ + + + + Resend all outbound updates + + ${vyos_op_scripts_dir}/vtysh_wrapper.sh $@ + + + + 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 @@ + + + + Reset all members of peer-group + + vrf name ${COMP_WORDS[4]} protocols bgp peer-group + + + ${vyos_op_scripts_dir}/vtysh_wrapper.sh $@ + + #include + + + 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 @@ + + + + Reset all members of peer-group + + protocols bgp peer-group + + + ${vyos_op_scripts_dir}/vtysh_wrapper.sh $@ + + #include + + + 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 @@ + + + + + + + Border Gateway Protocol (BGP) information + + + + + Clear all peers + + vtysh -c "clear bgp *" + + #include + #include + + + Clear bestpath and re-advertise + + <x.x.x.x/x> + + + ${vyos_op_scripts_dir}/vtysh_wrapper.sh $@ + + + + IPv4 Address Family + + + + + Clear all peers + + vtysh -c "clear bgp ipv4 *" + + #include + #include + + + + + IPv4 neighbor to clear + + + + + ${vyos_op_scripts_dir}/vtysh_wrapper.sh $@ + + #include + + + + + IPv6 Address Family + + + + + Clear all peers + + vtysh -c "clear bgp ipv6 *" + + #include + #include + + + + + IPv6 neighbor to clear + + + + + ${vyos_op_scripts_dir}/vtysh_wrapper.sh $@ + + #include + + + + + Layer 2 Virtual Private Network Address Family + + + + + Ethernet Virtual Private Network + + + + + Clear all peers + + vtysh -c "clear bgp l2vpn evpn *" + + #include + #include + + + + + BGP IPv4/IPv6 neighbor to clear + + + + + ${vyos_op_scripts_dir}/vtysh_wrapper.sh $@ + + #include + + + + + + + Virtual Routing and Forwarding (VRF) + + vrf name + + + + + + IPv4/IPv6 neighbor to clear + + + + + ${vyos_op_scripts_dir}/vtysh_wrapper.sh $@ + + #include + + + + + Clear all peers + + vtysh -c "clear bgp vrf $4 *" + + #include + #include + + + Clear bestpath and re-advertise + + <x.x.x.x/x> + + + ${vyos_op_scripts_dir}/vtysh_wrapper.sh $@ + + + + IPv4 Address Family + + + + + Clear all peers + + vtysh -c "clear bgp vrf $4 ipv4 *" + + #include + #include + + + + + IPv4 neighbor to clear + + + + + ${vyos_op_scripts_dir}/vtysh_wrapper.sh $@ + + #include + + + + + IPv6 Address Family + + + + + Clear all peers + + vtysh -c "clear bgp vrf $4 ipv6 *" + + #include + #include + + + + + IPv6 neighbor to clear + + + + + ${vyos_op_scripts_dir}/vtysh_wrapper.sh $@ + + #include + + + + + Layer 2 Virtual Private Network Address Family + + + + + Ethernet Virtual Private Network + + + + + Clear all peers + + vtysh -c "clear bgp vrf $4 l2vpn evpn *" + + #include + #include + + + + + BGP IPv4/IPv6 neighbor to clear + + + + + ${vyos_op_scripts_dir}/vtysh_wrapper.sh $@ + + #include + + + + + + + + + + + BGP IPv4/IPv6 neighbor to clear + + + + + ${vyos_op_scripts_dir}/vtysh_wrapper.sh $@ + + #include + + + + + 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 '' '' ${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 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" -- cgit v1.2.3