diff options
30 files changed, 1199 insertions, 152 deletions
@@ -91,8 +91,6 @@ op_mode_definitions: rm -f $(OP_TMPL_DIR)/set/node.def rm -f $(OP_TMPL_DIR)/show/node.def rm -f $(OP_TMPL_DIR)/show/interfaces/node.def - rm -f $(OP_TMPL_DIR)/show/ip/node.def - rm -f $(OP_TMPL_DIR)/show/ip/route/node.def rm -f $(OP_TMPL_DIR)/show/ipv6/node.def rm -f $(OP_TMPL_DIR)/show/ipv6/route/node.def rm -f $(OP_TMPL_DIR)/restart/node.def diff --git a/data/templates/dhcp-client/ipv6.tmpl b/data/templates/dhcp-client/ipv6.tmpl index 6cfe24d3e..490f14726 100644 --- a/data/templates/dhcp-client/ipv6.tmpl +++ b/data/templates/dhcp-client/ipv6.tmpl @@ -10,7 +10,7 @@ interface {{ ifname }} { {% if not dhcpv6_temporary %} send ia-na 1; # non-temporary address {% endif %} -{% if dhcpv6_pd %} +{% if dhcpv6_pd_interfaces %} send ia-pd 2; # prefix delegation {% endif %} }; @@ -21,9 +21,12 @@ id-assoc na 1 { }; {% endif %} -{% if dhcpv6_pd %} +{% if dhcpv6_pd_interfaces %} id-assoc pd 2 { -{% for intf in dhcpv6_pd %} +{% if dhcpv6_pd_length %} + prefix ::/{{ dhcpv6_pd_length }} infinity; +{% endif %} +{% for intf in dhcpv6_pd_interfaces %} prefix-interface {{ intf.ifname }} { {% if intf.sla_id %} sla-id {{ intf.sla_id }}; diff --git a/data/templates/pppoe/ip-down.script.tmpl b/data/templates/pppoe/ip-down.script.tmpl index fe8fd7584..9e6bd2a8e 100644 --- a/data/templates/pppoe/ip-down.script.tmpl +++ b/data/templates/pppoe/ip-down.script.tmpl @@ -25,9 +25,12 @@ fi # Always delete default route when interface goes down vtysh -c "conf t" ${VRF_NAME} -c "no ip route 0.0.0.0/0 {{ intf }} ${VRF_NAME}" +{% if ipv6_enable %} +vtysh -c "conf t" ${VRF_NAME} -c "no ipv6 route ::/0 {{ intf }} ${VRF_NAME}" +{% endif %} {% endif %} -{% if dhcpv6_pd %} +{% if dhcpv6_pd_interfaces %} # Start wide dhcpv6 client systemctl stop dhcp6c@{{ intf }}.service {% endif %} diff --git a/data/templates/pppoe/ip-pre-up.script.tmpl b/data/templates/pppoe/ip-pre-up.script.tmpl index 9a7ba7d57..6a2d2af94 100644 --- a/data/templates/pppoe/ip-pre-up.script.tmpl +++ b/data/templates/pppoe/ip-pre-up.script.tmpl @@ -2,7 +2,6 @@ # As PPPoE is an "on demand" interface we need to re-configure it when it # becomes up - if [ "$6" != "{{ intf }}" ]; then exit fi diff --git a/data/templates/pppoe/ip-up.script.tmpl b/data/templates/pppoe/ip-up.script.tmpl index 697ebcc20..a274296b6 100644 --- a/data/templates/pppoe/ip-up.script.tmpl +++ b/data/templates/pppoe/ip-up.script.tmpl @@ -7,13 +7,14 @@ if [ "$6" != "{{ intf }}" ]; then fi {% if not on_demand %} -# See https://phabricator.vyos.net/T2248 & T2220. Determine if we are enslaved -# to a VRF, this is needed to properly insert the default route. - # add some info to syslog DIALER_PID=$(cat /var/run/{{ intf }}.pid) logger -t pppd[$DIALER_PID] "executing $0" +{% if default_route != 'none' -%} +# See https://phabricator.vyos.net/T2248 & T2220. Determine if we are enslaved +# to a VRF, this is needed to properly insert the default route. + SED_OPT="^ip route" VRF_NAME="" if [ -d /sys/class/net/{{ intf }}/upper_* ]; then @@ -27,21 +28,22 @@ if [ -d /sys/class/net/{{ intf }}/upper_* ]; then VRF_NAME="vrf ${VRF}" fi -{% if 'auto' in default_route -%} +{% if default_route == 'auto' -%} # Only insert a new default route if there is no default route configured routes=$(vtysh -c "show running-config" | sed -n "/${SED_OPT}/,/!/p" | grep 0.0.0.0/0 | wc -l) if [ "$routes" -ne 0 ]; then exit 1 fi -{% elif 'force' in default_route -%} +{% elif default_route == 'force' -%} # Retrieve current static default routes and remove it from the routing table vtysh -c "show running-config" | sed -n "/${SED_OPT}/,/!/p" | grep 0.0.0.0/0 | while read route ; do vtysh -c "conf t" ${VTY_OPT} -c "no ${route} ${VRF_NAME}" done -{% endif %} +{% endif %} # Add default route to default or VRF routing table vtysh -c "conf t" ${VTY_OPT} -c "ip route 0.0.0.0/0 {{ intf }} ${VRF_NAME}" logger -t pppd[$DIALER_PID] "added default route via {{ intf }} ${VRF_NAME}" +{% endif %} {% endif %} diff --git a/data/templates/pppoe/ipv6-up.script.tmpl b/data/templates/pppoe/ipv6-up.script.tmpl index 90873229a..097f1d4c3 100644 --- a/data/templates/pppoe/ipv6-up.script.tmpl +++ b/data/templates/pppoe/ipv6-up.script.tmpl @@ -7,6 +7,8 @@ if [ "$6" != "{{ intf }}" ]; then exit fi +set -x + {% if ipv6_autoconf -%} # add some info to syslog DIALER_PID=$(cat /var/run/{{ intf }}.pid) @@ -37,10 +39,49 @@ echo 1 > /proc/sys/net/ipv6/conf/{{ intf }}/forwarding echo 2 > /proc/sys/net/ipv6/conf/{{ intf }}/accept_ra # Autoconfigure addresses using Prefix Information in Router Advertisements. -echo 1 > /proc/sys/net/ipv6/conf/{{ intf }}/autoconfigure +echo 1 > /proc/sys/net/ipv6/conf/{{ intf }}/autoconf {% endif %} -{% if dhcpv6_pd %} +{% if dhcpv6_pd_interfaces %} # Start wide dhcpv6 client systemctl start dhcp6c@{{ intf }}.service {% endif %} + + +{% if default_route != 'none' -%} +# See https://phabricator.vyos.net/T2248 & T2220. Determine if we are enslaved +# to a VRF, this is needed to properly insert the default route. + +SED_OPT="^ipv6 route" +VRF_NAME="" +if [ -d /sys/class/net/{{ intf }}/upper_* ]; then + # Determine upper (VRF) interface + VRF=$(basename $(ls -d /sys/class/net/{{ intf }}/upper_*)) + # Remove upper_ prefix from result string + VRF=${VRF#"upper_"} + # generate new SED command + SED_OPT="vrf ${VRF}" + # generate vtysh option + VRF_NAME="vrf ${VRF}" +fi + +{% if default_route == 'auto' -%} +# Only insert a new default route if there is no default route configured +routes=$(vtysh -c "show running-config" | sed -n "/${SED_OPT}/,/!/p" | grep ::/0 | wc -l) +if [ "$routes" -ne 0 ]; then + exit 1 +fi + +{% elif default_route == 'force' -%} +# Retrieve current static default routes and remove it from the routing table +vtysh -c "show running-config" | sed -n "/${SED_OPT}/,/!/p" | grep ::/0 | while read route ; do + vtysh -c "conf t" ${VTY_OPT} -c "no ${route} ${VRF_NAME}" +done +{% endif %} + +# Add default route to default or VRF routing table +vtysh -c "conf t" ${VTY_OPT} -c "ipv6 route ::/0 {{ intf }} ${VRF_NAME}" +logger -t pppd[$DIALER_PID] "added default route via {{ intf }} ${VRF_NAME}" +{% endif %} + + diff --git a/interface-definitions/include/dhcpv6-options.xml.i b/interface-definitions/include/dhcpv6-options.xml.i index 2c5058d2c..98a87dba2 100644 --- a/interface-definitions/include/dhcpv6-options.xml.i +++ b/interface-definitions/include/dhcpv6-options.xml.i @@ -3,52 +3,71 @@ <help>DHCPv6 options</help> </properties> <children> - <tagNode name="delegate"> + <node name="prefix-delegation"> <properties> - <help>Delegate IPv6 prefix from provider to this interface</help> - <completionHelp> - <script>${vyos_completion_dir}/list_interfaces.py --broadcast</script> - </completionHelp> + <help>DHCPv6 Prefix Delegation Options</help> </properties> <children> - <leafNode name="interface-id"> + <leafNode name="length"> <properties> - <help>Interface address identifier</help> + <help>Request IPv6 prefix length from peer</help> <valueHelp> - <format>0-</format> - <description>Used to form IPv6 interface address (default: EUI-64)</description> - </valueHelp> - <constraint> - <validator name="numeric" argument="--non-negative"/> - </constraint> - </properties> - </leafNode> - <leafNode name="sla-id"> - <properties> - <help>Interface site-Level aggregator (SLA)</help> - <valueHelp> - <format>0-128</format> - <description>Decimal integer which fits in the length of SLA IDs</description> + <format>32-64</format> + <description>Length of delegated prefix</description> </valueHelp> <constraint> - <validator name="numeric" argument="--range 0-128"/> + <validator name="numeric" argument="--range 32-64"/> </constraint> </properties> </leafNode> - <leafNode name="sla-len"> + <tagNode name="interface"> <properties> - <help>Site-Level aggregator (SLA) length</help> - <valueHelp> - <format>0-128</format> - <description>Length of delegated prefix</description> - </valueHelp> - <constraint> - <validator name="numeric" argument="--range 0-128"/> - </constraint> + <help>Delegate IPv6 prefix from provider to this interface</help> + <completionHelp> + <script>${vyos_completion_dir}/list_interfaces.py --broadcast</script> + </completionHelp> </properties> - </leafNode> + <children> + <leafNode name="address"> + <properties> + <help>Local interface address assigned to interface</help> + <valueHelp> + <format>>0</format> + <description>Used to form IPv6 interface address (default: EUI-64)</description> + </valueHelp> + <constraint> + <validator name="numeric" argument="--non-negative"/> + </constraint> + </properties> + </leafNode> + <leafNode name="sla-id"> + <properties> + <help>Interface site-Level aggregator (SLA)</help> + <valueHelp> + <format>0-128</format> + <description>Decimal integer which fits in the length of SLA IDs</description> + </valueHelp> + <constraint> + <validator name="numeric" argument="--range 0-128"/> + </constraint> + </properties> + </leafNode> + <leafNode name="sla-len"> + <properties> + <help>Site-Level aggregator (SLA) length</help> + <valueHelp> + <format>0-128</format> + <description>Length of delegated prefix</description> + </valueHelp> + <constraint> + <validator name="numeric" argument="--range 0-128"/> + </constraint> + </properties> + </leafNode> + </children> + </tagNode> </children> - </tagNode> + </node> <leafNode name="parameters-only"> <properties> <help>Acquire only config parameters, no address</help> diff --git a/interface-definitions/protocols-bgp.xml.in b/interface-definitions/protocols-bgp.xml.in index 2932d890e..8cab34141 100644 --- a/interface-definitions/protocols-bgp.xml.in +++ b/interface-definitions/protocols-bgp.xml.in @@ -375,7 +375,7 @@ </leafNode> <leafNode name="disable-connected-check"> <properties> - <help>Disable check to see if EBGP peer's address is a connected route</help> + <help>Disable check to see if eBGP peer address is a connected route</help> <valueless/> </properties> </leafNode> @@ -528,7 +528,7 @@ </leafNode> <leafNode name="port"> <properties> - <help>Neighbor's BGP port</help> + <help>Neighbor BGP port</help> <valueHelp> <format><1-65535></format> <description>Neighbor BGP port number</description> @@ -605,7 +605,7 @@ </valueHelp> <valueHelp> <format>0</format> - <description>Don't hold timer</description> + <description>Hold timer disabled</description> </valueHelp> <constraint> <validator name="numeric" argument="--range 0-65535"/> @@ -662,7 +662,7 @@ <regex>(en|eth|br|bond|gnv|vxlan|wg|tun)[0-9]+</regex> </constraint> </properties> - </leafNode> + </leafNode> </children> </tagNode> <node name="parameters"> @@ -940,7 +940,7 @@ </node> <leafNode name="enforce-first-as"> <properties> - <help>Require first AS in the path to match peer's AS</help> + <help>Require first AS in the path to match peer AS number</help> <valueless/> </properties> </leafNode> @@ -951,7 +951,7 @@ <children> <leafNode name="stalepath-time"> <properties> - <help>Maximum time to hold onto restarting peer's stale paths</help> + <help>Maximum time to hold onto restarting neighbors stale paths</help> <valueHelp> <format><1-3600></format> <description>Hold time in seconds</description> @@ -983,7 +983,7 @@ </leafNode> <leafNode name="no-fast-external-failover"> <properties> - <help>Disable immediate session reset if peer's connected link goes down</help> + <help>Disable immediate session reset on peer link down event</help> <valueless/> </properties> </leafNode> @@ -1054,7 +1054,7 @@ </leafNode> <leafNode name="disable-connected-check"> <properties> - <help>Disable check to see if EBGP peer's address is a connected route</help> + <help>Disable check to see if eBGP peer address is a connected route</help> <valueless/> </properties> </leafNode> @@ -1199,7 +1199,7 @@ </valueHelp> <valueHelp> <format>0</format> - <description>Don't hold routes</description> + <description>Do not hold routes</description> </valueHelp> <constraint> <validator name="numeric" argument="--range 0-65535"/> diff --git a/op-mode-definitions/connect-disconnect.xml b/op-mode-definitions/connect-disconnect.xml index cbce2d9ef..f0fcef5da 100644 --- a/op-mode-definitions/connect-disconnect.xml +++ b/op-mode-definitions/connect-disconnect.xml @@ -10,6 +10,7 @@ <help>Bring up a connection-oriented network interface</help> <completionHelp> <path>interfaces pppoe</path> + <path>interfaces wirelessmodem</path> </completionHelp> </properties> <command>sudo ${vyos_op_scripts_dir}/connect_disconnect.py --connect "$3"</command> @@ -26,6 +27,7 @@ <help>Take down a connection-oriented network interface</help> <completionHelp> <path>interfaces pppoe</path> + <path>interfaces wirelessmodem</path> </completionHelp> </properties> <command>sudo ${vyos_op_scripts_dir}/connect_disconnect.py --disconnect "$3"</command> diff --git a/op-mode-definitions/dhcp.xml b/op-mode-definitions/dhcp.xml index 2013d0014..1302151e9 100644 --- a/op-mode-definitions/dhcp.xml +++ b/op-mode-definitions/dhcp.xml @@ -161,4 +161,40 @@ </node> </children> </node> + <node name="renew"> + <children> + <node name="dhcp"> + <properties> + <help>Renew DHCP client lease</help> + </properties> + <children> + <tagNode name="interface"> + <properties> + <help>Renew DHCP client lease for specified interface</help> + <completionHelp> + <script>${vyos_completion_dir}/list_interfaces.py</script> + </completionHelp> + </properties> + <command>sudo systemctl restart "dhclient@$4.service"</command> + </tagNode> + </children> + </node> + <node name="dhcpv6"> + <properties> + <help>Renew DHCPv6 client lease</help> + </properties> + <children> + <tagNode name="interface"> + <properties> + <help>Renew DHCPv6 client lease for specified interface</help> + <completionHelp> + <script>${vyos_completion_dir}/list_interfaces.py</script> + </completionHelp> + </properties> + <command>sudo systemctl restart "dhcp6c@$4.service"</command> + </tagNode> + </children> + </node> + </children> + </node> </interfaceDefinition> diff --git a/op-mode-definitions/ipv4-route.xml b/op-mode-definitions/ipv4-route.xml index d2846a6f2..1bda3ac11 100644 --- a/op-mode-definitions/ipv4-route.xml +++ b/op-mode-definitions/ipv4-route.xml @@ -16,44 +16,6 @@ </properties> <command>netstat -gn4</command> </leafNode> - - <node name="route"> - <properties> - <help>Show IP routes</help> - </properties> - <children> - <node name="cache"> - <properties> - <help>Show kernel route cache</help> - </properties> - <command>ip -s route list cache</command> - </node> - <tagNode name="cache"> - <properties> - <help>Show kernel route cache for a given route</help> - <completionHelp> - <list><x.x.x.x> <x.x.x.x/x></list> - </completionHelp> - </properties> - <command>ip -s route list cache $5</command> - </tagNode> - <node name="forward"> - <properties> - <help>Show kernel route table</help> - </properties> - <command>ip route list</command> - </node> - <tagNode name="forward"> - <properties> - <help>Show kernel route table for a given route</help> - <completionHelp> - <list><x.x.x.x> <x.x.x.x/x></list> - </completionHelp> - </properties> - <command>ip -s route list $5</command> - </tagNode> - </children> - </node> </children> </node> </children> diff --git a/op-mode-definitions/show-interfaces-wirelessmodem.xml b/op-mode-definitions/show-interfaces-wirelessmodem.xml index d9690f521..b21bb520c 100644 --- a/op-mode-definitions/show-interfaces-wirelessmodem.xml +++ b/op-mode-definitions/show-interfaces-wirelessmodem.xml @@ -8,7 +8,7 @@ <properties> <help>Show Wireless Modem (WWAN) interface information</help> <completionHelp> - <script>${vyos_completion_dir}/list_wlm_peers.sh</script> + <path>interfaces wirelessmodem</path> </completionHelp> </properties> <command>${vyos_op_scripts_dir}/show_interfaces.py --intf="$4"</command> @@ -17,7 +17,7 @@ <properties> <help>Show specified wirelessmodem interface statistics</help> <completionHelp> - <script>${vyos_completion_dir}/list_wlm_peers.sh</script> + <path>interfaces wirelessmodem</path> </completionHelp> </properties> <command>/usr/sbin/pppstats $4</command> diff --git a/op-mode-definitions/show-ip-access-paths-prefix-community-lists.xml b/op-mode-definitions/show-ip-access-paths-prefix-community-lists.xml new file mode 100644 index 000000000..a5ec65c94 --- /dev/null +++ b/op-mode-definitions/show-ip-access-paths-prefix-community-lists.xml @@ -0,0 +1,116 @@ +<?xml version="1.0"?> +<interfaceDefinition> + <node name="show"> + <children> + <node name="ip"> + <properties> + <help>Show IPv4 routing information</help> + </properties> + <children> + <leafNode name="access-list"> + <properties> + <help>Show all IP access-lists</help> + </properties> + <command>/usr/bin/vtysh -c "show ip access-list"</command> + </leafNode> + <tagNode name="access-list"> + <properties> + <help>Show all IP access-lists</help> + <completionHelp> + <path>policy access-list</path> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip access-list $4"</command> + </tagNode> + <leafNode name="as-path-access-list"> + <properties> + <help>Show all as-path-access-lists</help> + </properties> + <command>/usr/bin/vtysh -c "show ip as-path-access-list"</command> + </leafNode> + <tagNode name="as-path-access-list"> + <properties> + <help>Show all as-path-access-lists</help> + <completionHelp> + <path>policy as-path-list</path> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip as-path-access-list $4"</command> + </tagNode> + <leafNode name="community-list"> + <properties> + <help>Show IP community-lists</help> + </properties> + <command>/usr/bin/vtysh -c "show bgp community-list"</command> + </leafNode> + <tagNode name="community-list"> + <properties> + <help>Show IP community-lists</help> + <completionHelp> + <path>policy community-list</path> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show bgp community-list $4 detail"</command> + </tagNode> + <leafNode name="extcommunity-list"> + <properties> + <help>Show extended IP community-lists</help> + </properties> + <command>/usr/bin/vtysh -c "show bgp extcommunity-list"</command> + </leafNode> + <tagNode name="extcommunity-list"> + <properties> + <help>Show extended IP community-lists</help> + <completionHelp> + <path>policy extcommunity-list</path> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show bgp extcommunity-list $4 detail"</command> + </tagNode> + <leafNode name="forwarding"> + <properties> + <help>Show IP forwarding status</help> + </properties> + <command>/usr/bin/vtysh -c "show ip forwarding"</command> + </leafNode> + <leafNode name="large-community-list"> + <properties> + <help>Show IP large-community-lists</help> + </properties> + <command>/usr/bin/vtysh -c "show bgp large-community-list"</command> + </leafNode> + <tagNode name="large-community-list"> + <properties> + <help>Show IP large-community-lists</help> + <completionHelp> + <path>policy large-community-list</path> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show bgp large-community-list $4 detail"</command> + </tagNode> + <leafNode name="prefix-list"> + <properties> + <help>Show all IP prefix-lists</help> + </properties> + <command>/usr/bin/vtysh -c "show ip prefix-list"</command> + </leafNode> + <tagNode name="prefix-list"> + <properties> + <help>Show all IP prefix-lists</help> + <completionHelp> + <path>policy prefix-list</path> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip prefix-list $4"</command> + </tagNode> + <leafNode name="protocol"> + <properties> + <help>Show IP route-maps per protocol</help> + </properties> + <command>/usr/bin/vtysh -c "show ip protocol"</command> + </leafNode> + </children> + </node> + </children> + </node> +</interfaceDefinition> diff --git a/op-mode-definitions/show-ip-ospf.xml b/op-mode-definitions/show-ip-ospf.xml new file mode 100644 index 000000000..99441d185 --- /dev/null +++ b/op-mode-definitions/show-ip-ospf.xml @@ -0,0 +1,579 @@ +<?xml version="1.0"?> +<interfaceDefinition> + <node name="show"> + <children> + <node name="ip"> + <properties> + <help>Show IPv4 routing information</help> + </properties> + <children> + <node name="ospf"> + <properties> + <help>Show IPv4 Open Shortest Path First (OSPF) routing information</help> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf"</command> + <children> + <leafNode name="border-routers"> + <properties> + <help>Show IPv4 OSPF border-routers information</help> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf border-routers"</command> + </leafNode> + <node name="database"> + <properties> + <help>Show IPv4 OSPF database information</help> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database"</command> + <children> + <node name="asbr-summary"> + <properties> + <help>Show IPv4 OSPF ASBR summary database</help> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database asbr-summary"</command> + <children> + <tagNode name="adv-router"> + <properties> + <help>Show IPv4 OSPF ASBR summary database for given address of advertised router</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database asbr-summary adv-router $7"</command> + </tagNode> + <node name="adv-router"> + <properties> + <help>Show IPv4 OSPF ASBR summary database for given address of advertised router</help> + </properties> + </node> + </children> + </node> + <tagNode name="asbr-summary"> + <properties> + <help>Show IPv4 OSPF ASBR summary database information of given address</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database asbr-summary"</command> + <children> + <node name="adv-router"> + <properties> + <help>Show advertising router link states</help> + </properties> + </node> + <tagNode name="adv-router"> + <properties> + <help>Show IPv4 OSPF ASBR summary database of given address for given advertised router</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database asbr-summary $6 adv-router $8"</command> + </tagNode> + <leafNode name="self-originate"> + <properties> + <help>Show summary of self-originate IPv4 OSPF ASBR database</help> + </properties> + <command>show ip ospf database asbr-summary $6 self-originate</command> + </leafNode> + </children> + </tagNode> + <node name="external"> + <properties> + <help>Show IPv4 OSPF external database</help> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database external"</command> + <children> + <tagNode name="adv-router"> + <properties> + <help>Show IPv4 OSPF external database for specified IP address of advertised router</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database external adv-router $7"</command> + </tagNode> + <node name="adv-router"> + <properties> + <help>Show IPv4 OSPF external database for specified IP address of advertised router</help> + </properties> + </node> + </children> + </node> + <tagNode name="external"> + <properties> + <help>Show IPv4 OSPF external database information of specified IP address</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database external"</command> + <children> + <node name="adv-router"> + <properties> + <help>Show advertising router link states</help> + </properties> + </node> + <tagNode name="adv-router"> + <properties> + <help>Show IPv4 OSPF external database of specified IP address for specified advertised router</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database external $6 adv-router $8"</command> + </tagNode> + <leafNode name="self-originate"> + <properties> + <help>Show self-originate IPv4 OSPF external database</help> + </properties> + <command>show ip ospf database external $6 self-originate</command> + </leafNode> + </children> + </tagNode> + <leafNode name="max-age"> + <properties> + <help>Show IPv4 OSPF max-age database</help> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database max-age"</command> + </leafNode> + <node name="network"> + <properties> + <help>Show IPv4 OSPF network database</help> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database network"</command> + <children> + <tagNode name="adv-router"> + <properties> + <help>Show IPv4 OSPF network database for specified IP address of advertised router</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database network adv-router $7"</command> + </tagNode> + <node name="adv-router"> + <properties> + <help>Show IPv4 OSPF network database for given address of advertised router</help> + </properties> + </node> + </children> + </node> + <tagNode name="network"> + <properties> + <help>Show IPv4 OSPF network database information of specified IP address</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database network"</command> + <children> + <node name="adv-router"> + <properties> + <help>Show advertising router link states</help> + </properties> + </node> + <tagNode name="adv-router"> + <properties> + <help>Show IPv4 OSPF network database of specified IP address for specified advertised router</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database network $6 adv-router $8"</command> + </tagNode> + <leafNode name="self-originate"> + <properties> + <help>Show self-originate IPv4 OSPF network database</help> + </properties> + <command>show ip ospf database network $6 self-originate</command> + </leafNode> + </children> + </tagNode> + <node name="nssa-external"> + <properties> + <help>Show IPv4 OSPF NSSA external database</help> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database nssa-external"</command> + <children> + <tagNode name="adv-router"> + <properties> + <help>Show IPv4 OSPF NSSA external database for specified IP address of advertised router</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database nssa-external adv-router $7"</command> + </tagNode> + <node name="adv-router"> + <properties> + <help>Show IPv4 OSPF NSSA external database for specified IP address of advertised router</help> + </properties> + </node> + </children> + </node> + <tagNode name="nssa-external"> + <properties> + <help>Show IPv4 OSPF NSSA external database information of specified IP address</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database nssa-external"</command> + <children> + <node name="adv-router"> + <properties> + <help>Show advertising router link states</help> + </properties> + </node> + <tagNode name="adv-router"> + <properties> + <help>Show IPv4 OSPF NSSA external database of specified IP address for specified advertised router</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database nssa-external $6 adv-router $8"</command> + </tagNode> + <leafNode name="self-originate"> + <properties> + <help>Show self-originate IPv4 OSPF NSSA external database</help> + </properties> + <command>show ip ospf database nssa-external $6 self-originate</command> + </leafNode> + </children> + </tagNode> + <node name="opaque-area"> + <properties> + <help>Show IPv4 OSPF opaque-area database</help> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database opaque-area"</command> + <children> + <tagNode name="adv-router"> + <properties> + <help>Show IPv4 OSPF opaque-area database for specified IP address of advertised router</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database opaque-area adv-router $7"</command> + </tagNode> + <node name="adv-router"> + <properties> + <help>Show IPv4 OSPF opaque-area database for specified IP address of advertised router</help> + </properties> + </node> + </children> + </node> + <tagNode name="opaque-area"> + <properties> + <help>Show IPv4 OSPF opaque-area database information of specified IP address</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database opaque-area"</command> + <children> + <node name="adv-router"> + <properties> + <help>Show advertising router link states</help> + </properties> + </node> + <tagNode name="adv-router"> + <properties> + <help>Show IPv4 OSPF opaque-area database of specified IP address for specified advertised router</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database opaque-area $6 adv-router $8"</command> + </tagNode> + <leafNode name="self-originate"> + <properties> + <help>Show self-originate IPv4 OSPF opaque-area database</help> + </properties> + <command>show ip ospf database opaque-area $6 self-originate</command> + </leafNode> + </children> + </tagNode> + <node name="opaque-as"> + <properties> + <help>Show IPv4 OSPF opaque-as database</help> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database opaque-as"</command> + <children> + <tagNode name="adv-router"> + <properties> + <help>Show IPv4 OSPF opaque-as database for specified IP address of advertised router</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database opaque-as adv-router $7"</command> + </tagNode> + <node name="adv-router"> + <properties> + <help>Show IPv4 OSPF opaque-as database for specified IP address of advertised router</help> + </properties> + </node> + </children> + </node> + <tagNode name="opaque-as"> + <properties> + <help>Show IPv4 OSPF opaque-as database information of specified IP address</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database opaque-as"</command> + <children> + <node name="adv-router"> + <properties> + <help>Show advertising router link states</help> + </properties> + </node> + <tagNode name="adv-router"> + <properties> + <help>Show IPv4 OSPF opaque-as database of specified IP address for specified advertised router</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database opaque-as $6 adv-router $8"</command> + </tagNode> + <leafNode name="self-originate"> + <properties> + <help>Show self-originate IPv4 OSPF opaque-as database</help> + </properties> + <command>show ip ospf database opaque-as $6 self-originate</command> + </leafNode> + </children> + </tagNode> + <node name="opaque-link"> + <properties> + <help>Show IPv4 OSPF opaque-link database</help> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database opaque-link"</command> + <children> + <tagNode name="adv-router"> + <properties> + <help>Show IPv4 OSPF opaque-link database for specified IP address of advertised router</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database opaque-link adv-router $7"</command> + </tagNode> + <node name="adv-router"> + <properties> + <help>Show IPv4 OSPF opaque-link database for specified IP address of advertised router</help> + </properties> + </node> + </children> + </node> + <tagNode name="opaque-link"> + <properties> + <help>Show IPv4 OSPF opaque-link database information of specified IP address</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database opaque-link"</command> + <children> + <node name="adv-router"> + <properties> + <help>Show advertising router link states</help> + </properties> + </node> + <tagNode name="adv-router"> + <properties> + <help>Show IPv4 OSPF opaque-link database of specified IP address for specified advertised router</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database opaque-link $6 adv-router $8"</command> + </tagNode> + <leafNode name="self-originate"> + <properties> + <help>Show self-originate IPv4 OSPF opaque-link database</help> + </properties> + <command>show ip ospf database opaque-link $6 self-originate</command> + </leafNode> + </children> + </tagNode> + <node name="router"> + <properties> + <help>Show IPv4 OSPF router database</help> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database router"</command> + <children> + <tagNode name="adv-router"> + <properties> + <help>Show IPv4 OSPF router database for specified IP address of advertised router</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database router adv-router $7"</command> + </tagNode> + <node name="adv-router"> + <properties> + <help>Show IPv4 OSPF router database for specified IP address of advertised router</help> + </properties> + </node> + </children> + </node> + <tagNode name="router"> + <properties> + <help>Show IPv4 OSPF router database information of specified IP address</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database router"</command> + <children> + <node name="adv-router"> + <properties> + <help>Show advertising router link states</help> + </properties> + </node> + <tagNode name="adv-router"> + <properties> + <help>Show IPv4 OSPF router database of specified IP address for specified advertised router</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database router $6 adv-router $8"</command> + </tagNode> + <leafNode name="self-originate"> + <properties> + <help>Show self-originate IPv4 OSPF router database</help> + </properties> + <command>show ip ospf database router $6 self-originate</command> + </leafNode> + </children> + </tagNode> + <leafNode name="self-originate"> + <properties> + <help>Show IPv4 OSPF self-originate database</help> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database self-originate"</command> + </leafNode> + <node name="summary"> + <properties> + <help>Show summary of IPv4 OSPF database</help> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database summary"</command> + <children> + <tagNode name="adv-router"> + <properties> + <help>Show IPv4 OSPF summary database for specified IP address of advertised router</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database summary adv-router $7"</command> + </tagNode> + <node name="adv-router"> + <properties> + <help>Show IPv4 OSPF summary database for specified IP address of advertised router</help> + </properties> + </node> + </children> + </node> + <tagNode name="summary"> + <properties> + <help>Show IPv4 OSPF summary database information of specified IP address</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database summary"</command> + <children> + <node name="adv-router"> + <properties> + <help>Show advertising router link states</help> + </properties> + </node> + <tagNode name="adv-router"> + <properties> + <help>Show IPv4 OSPF summary database of specified IP address for specified advertised router</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf database summary $6 adv-router $8"</command> + </tagNode> + <leafNode name="self-originate"> + <properties> + <help>Show self-originate IPv4 OSPF summary database</help> + </properties> + <command>show ip ospf database summary $6 self-originate</command> + </leafNode> + </children> + </tagNode> + </children> + </node> + <node name="interface"> + <properties> + <help>Show IPv4 OSPF interface information</help> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf interface"</command> + </node> + <tagNode name="interface"> + <properties> + <help>Show IPv4 OSPF information for specified interface</help> + <completionHelp> + <script>${vyos_completion_dir}/list_interfaces.py</script> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf interface $5"</command> + </tagNode> + <node name="neighbor"> + <properties> + <help>Show IPv4 OSPF neighbor information</help> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf neighbor"</command> + <children> + <tagNode name="address"> + <properties> + <help>Show IPv4 OSPF neighbor information for specified IP address</help> + <completionHelp> + <list><x.x.x.x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf neighbor $6"</command> + </tagNode> + <node name="detail"> + <properties> + <help>Show detailed IPv4 OSPF neighbor information</help> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf neighbor detail"</command> + </node> + </children> + </node> + <tagNode name="neighbor"> + <properties> + <help>Show IPv4 OSPF neighbor information for specified IP address or interface</help> + <completionHelp> + <list><x.x.x.x></list> + <script>${vyos_completion_dir}/list_interfaces.py</script> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf neighbor $5"</command> + </tagNode> + <leafNode name="route"> + <properties> + <help>Show IPv4 OSPF route information</help> + </properties> + <command>/usr/bin/vtysh -c "show ip ospf route"</command> + </leafNode> + </children> + </node> + </children> + </node> + </children> + </node> +</interfaceDefinition> diff --git a/op-mode-definitions/show-ip-rip.xml b/op-mode-definitions/show-ip-rip.xml new file mode 100644 index 000000000..b61ab10a7 --- /dev/null +++ b/op-mode-definitions/show-ip-rip.xml @@ -0,0 +1,28 @@ +<?xml version="1.0"?> +<interfaceDefinition> + <node name="show"> + <children> + <node name="ip"> + <properties> + <help>Show IPv4 routing information</help> + </properties> + <children> + <node name="rip"> + <properties> + <help>Show Routing Information Protocol (RIP) information</help> + </properties> + <command>/usr/bin/vtysh -c "show ip rip"</command> + <children> + <leafNode name="status"> + <properties> + <help>Show RIP protocol status</help> + </properties> + <command>/usr/bin/vtysh -c "show ip rip status"</command> + </leafNode> + </children> + </node> + </children> + </node> + </children> + </node> +</interfaceDefinition> diff --git a/op-mode-definitions/show-ip-route.xml b/op-mode-definitions/show-ip-route.xml new file mode 100644 index 000000000..d12d132c0 --- /dev/null +++ b/op-mode-definitions/show-ip-route.xml @@ -0,0 +1,160 @@ +<?xml version="1.0"?> +<interfaceDefinition> + <node name="show"> + <children> + <node name="ip"> + <properties> + <help>Show IPv4 routing information</help> + </properties> + <children> + <node name="route"> + <properties> + <help>Show IP routes</help> + </properties> + <command>/usr/bin/vtysh -c "show ip route"</command> + <children> + <leafNode name="bgp"> + <properties> + <help>Show IP BGP routes</help> + </properties> + <command>/usr/bin/vtysh -c "show ip route bgp"</command> + </leafNode> + <node name="cache"> + <properties> + <help>Show kernel route cache</help> + </properties> + <command>ip -s route list cache</command> + </node> + <tagNode name="cache"> + <properties> + <help>Show kernel route cache for a given route</help> + <completionHelp> + <list><x.x.x.x> <x.x.x.x/x></list> + </completionHelp> + </properties> + <command>ip -s route list cache $5</command> + </tagNode> + <leafNode name="connected"> + <properties> + <help>Show IP connected routes</help> + </properties> + <command>/usr/bin/vtysh -c "show ip route connected"</command> + </leafNode> + <node name="forward"> + <properties> + <help>Show kernel route table</help> + </properties> + <command>ip route list</command> + </node> + <tagNode name="forward"> + <properties> + <help>Show kernel route table for a given route</help> + <completionHelp> + <list><x.x.x.x> <x.x.x.x/x></list> + </completionHelp> + </properties> + <command>ip -s route list $5</command> + </tagNode> + <leafNode name="kernel"> + <properties> + <help>Show IP kernel routes</help> + </properties> + <command>/usr/bin/vtysh -c "show ip route kernel"</command> + </leafNode> + <leafNode name="ospf"> + <properties> + <help>Show IP OSPF routes</help> + </properties> + <command>/usr/bin/vtysh -c "show ip route ospf"</command> + </leafNode> + <leafNode name="rip"> + <properties> + <help>Show IP RIP routes</help> + </properties> + <command>/usr/bin/vtysh -c "show ip route rip"</command> + </leafNode> + <leafNode name="static"> + <properties> + <help>Show IP static routes</help> + </properties> + <command>/usr/bin/vtysh -c "show ip route static"</command> + </leafNode> + <leafNode name="summary"> + <properties> + <help>Show IP routes summary</help> + </properties> + <command>/usr/bin/vtysh -c "show ip route summary"</command> + </leafNode> + <leafNode name="supernets-only"> + <properties> + <help>Show IP supernet routes</help> + </properties> + <command>/usr/bin/vtysh -c "show ip route supernets-only"</command> + </leafNode> + <node name="table"> + <properties> + <help>Show IP routes in policy table</help> + </properties> + </node> + <tagNode name="table"> + <properties> + <help>Show IP routes in policy table</help> + <completionHelp> + <list><1-200></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip route table $5"</command> + </tagNode> + <node name="tag"> + <properties> + <help>Show only routes with tag</help> + </properties> + </node> + <tagNode name="tag"> + <properties> + <help>Tag value</help> + <completionHelp> + <list><1-4294967295></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip route tag $5"</command> + </tagNode> + <node name="vrf"> + <properties> + <help>Show IP routes in VRF</help> + </properties> + </node> + <tagNode name="vrf"> + <properties> + <help>Show IP routes in VRF</help> + <completionHelp> + <list><vrf></list> + <path>vrf name</path> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip route vrf $5"</command> + </tagNode> + </children> + </node> + <tagNode name="route"> + <properties> + <help>Show IP routes of specified IP address or prefix</help> + <completionHelp> + <list><x.x.x.x> <x.x.x.x/x></list> + </completionHelp> + </properties> + <command>/usr/bin/vtysh -c "show ip route $4"</command> + <children> + <leafNode name="longer-prefixes"> + <properties> + <help>Show longer prefixes of routes for specified IP address or prefix</help> + </properties> + <command>/usr/bin/vtysh -c "show ip route $4"</command> + </leafNode> + </children> + </tagNode> + </children> + </node> + </children> + </node> +</interfaceDefinition> diff --git a/python/vyos/configdict.py b/python/vyos/configdict.py index eec64e964..ead7e8637 100644 --- a/python/vyos/configdict.py +++ b/python/vyos/configdict.py @@ -103,16 +103,21 @@ def get_ethertype(ethertype_val): else: raise ConfigError('invalid ethertype "{}"'.format(ethertype_val)) +dhcpv6_pd_default_data = { + 'dhcpv6_prm_only': False, + 'dhcpv6_temporary': False, + 'dhcpv6_pd_length': '', + 'dhcpv6_pd_interfaces': [] +} + interface_default_data = { + **dhcpv6_pd_default_data, 'address': [], 'address_remove': [], 'description': '', 'dhcp_client_id': '', 'dhcp_hostname': '', 'dhcp_vendor_class_id': '', - 'dhcpv6_prm_only': False, - 'dhcpv6_temporary': False, - 'dhcpv6_pd': [], 'disable': False, 'disable_link_detect': 1, 'ip_disable_arp_filter': 1, @@ -229,9 +234,9 @@ def intf_to_dict(conf, default): # DHCPv6 prefix delegation (RFC3633) current_level = conf.get_level() - if conf.exists(['dhcpv6-options', 'delegate']): - for interface in conf.list_nodes(['dhcpv6-options', 'delegate']): - conf.set_level(current_level + ['dhcpv6-options', 'delegate', interface]) + if conf.exists(['dhcpv6-options', 'prefix-delegation']): + for interface in conf.list_nodes(['dhcpv6-options', 'prefix-delegation', 'interface']): + conf.set_level(current_level + ['dhcpv6-options', 'prefix-delegation', 'interface', interface]) pd = { 'ifname': interface, 'sla_id': '', @@ -245,10 +250,10 @@ def intf_to_dict(conf, default): if conf.exists(['sla-len']): pd['sla_len'] = conf.return_value(['sla-len']) - if conf.exists(['interface-id']): - pd['if_id'] = conf.return_value(['interface-id']) + if conf.exists(['address']): + pd['if_id'] = conf.return_value(['address']) - intf['dhcpv6_pd'].append(pd) + intf['dhcpv6_pd_interfaces'].append(pd) # re-set config level conf.set_level(current_level) diff --git a/python/vyos/ifconfig/dhcp.py b/python/vyos/ifconfig/dhcp.py index f8fdeb6a9..a8b9a2a87 100644 --- a/python/vyos/ifconfig/dhcp.py +++ b/python/vyos/ifconfig/dhcp.py @@ -86,7 +86,8 @@ class _DHCPv6 (Control): 'ifname': ifname, 'dhcpv6_prm_only': False, 'dhcpv6_temporary': False, - 'dhcpv6_pd': [], + 'dhcpv6_pd_interfaces': [], + 'dhcpv6_pd_length': '' }) self._conf_file = f'/run/dhcp6c/dhcp6c.{ifname}.conf' diff --git a/python/vyos/ifconfig/interface.py b/python/vyos/ifconfig/interface.py index 07efc6d97..2c2396440 100644 --- a/python/vyos/ifconfig/interface.py +++ b/python/vyos/ifconfig/interface.py @@ -644,7 +644,7 @@ class Interface(Control): IPv4: add IPv4 address to interface IPv6: add IPv6 address to interface dhcp: start dhclient (IPv4) on interface - dhcpv6: start dhclient (IPv6) on interface + dhcpv6: start WIDE DHCPv6 (IPv6) on interface Returns False if address is already assigned and wasn't re-added. Example: diff --git a/python/vyos/ifconfig_vlan.py b/python/vyos/ifconfig_vlan.py index a53136ebf..53a77c651 100644 --- a/python/vyos/ifconfig_vlan.py +++ b/python/vyos/ifconfig_vlan.py @@ -87,8 +87,11 @@ def apply_vlan_config(vlan, config): if config['dhcpv6_temporary']: vlan.dhcp.v6.options['dhcpv6_temporary'] = True - if config['dhcpv6_pd']: - vlan.dhcp.v6.options['dhcpv6_pd'] = config['dhcpv6_pd'] + if config['dhcpv6_pd_length']: + vlan.dhcp.v6.options['dhcpv6_pd_length'] = config['dhcpv6_pd_length'] + + if config['dhcpv6_pd_interfaces']: + vlan.dhcp.v6.options['dhcpv6_pd_interfaces'] = config['dhcpv6_pd_interfaces'] # update interface description used e.g. within SNMP vlan.set_alias(config['description']) diff --git a/src/completion/list_wlm_peers.sh b/src/completion/list_wlm_peers.sh deleted file mode 100755 index 12dd00650..000000000 --- a/src/completion/list_wlm_peers.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -if [ -d /etc/ppp/peers ]; then - cd /etc/ppp/peers - ls wlm* -fi diff --git a/src/conf_mode/interfaces-bonding.py b/src/conf_mode/interfaces-bonding.py index d87e0cd0e..c2081b8c3 100755 --- a/src/conf_mode/interfaces-bonding.py +++ b/src/conf_mode/interfaces-bonding.py @@ -302,8 +302,11 @@ def apply(bond): if bond['dhcpv6_temporary']: b.dhcp.v6.options['dhcpv6_temporary'] = True - if bond['dhcpv6_pd']: - b.dhcp.v6.options['dhcpv6_pd'] = bond['dhcpv6_pd'] + if bond['dhcpv6_pd_length']: + b.dhcp.v6.options['dhcpv6_pd_length'] = bond['dhcpv6_pd_length'] + + if bond['dhcpv6_pd_interfaces']: + b.dhcp.v6.options['dhcpv6_pd_interfaces'] = bond['dhcpv6_pd_interfaces'] # ignore link state changes b.set_link_detect(bond['disable_link_detect']) diff --git a/src/conf_mode/interfaces-bridge.py b/src/conf_mode/interfaces-bridge.py index af5372e21..1e4fa5816 100755 --- a/src/conf_mode/interfaces-bridge.py +++ b/src/conf_mode/interfaces-bridge.py @@ -324,8 +324,11 @@ def apply(bridge): if bridge['dhcpv6_temporary']: br.dhcp.v6.options['dhcpv6_temporary'] = True - if bridge['dhcpv6_pd']: - br.dhcp.v6.options['dhcpv6_pd'] = br['dhcpv6_pd'] + if bridge['dhcpv6_pd_length']: + br.dhcp.v6.options['dhcpv6_pd_length'] = br['dhcpv6_pd_length'] + + if bridge['dhcpv6_pd_interfaces']: + br.dhcp.v6.options['dhcpv6_pd_interfaces'] = br['dhcpv6_pd_interfaces'] # assign/remove VRF br.set_vrf(bridge['vrf']) diff --git a/src/conf_mode/interfaces-ethernet.py b/src/conf_mode/interfaces-ethernet.py index ef958e9f8..8d657acba 100755 --- a/src/conf_mode/interfaces-ethernet.py +++ b/src/conf_mode/interfaces-ethernet.py @@ -173,6 +173,10 @@ def verify(eth): f'Interface "{eth["intf"]}" cannot be member of VRF "{eth["vrf"]}" ' f'and "{memberof}" at the same time!')) + if eth['mac'] and eth['is_bond_member']: + print('WARNING: "mac {0}" command will be ignored because {1} is a part of {2}'\ + .format(eth['mac'], eth['intf'], eth['is_bond_member'])) + # use common function to verify VLAN configuration verify_vlan_config(eth) return None @@ -204,8 +208,11 @@ def apply(eth): if eth['dhcpv6_temporary']: e.dhcp.v6.options['dhcpv6_temporary'] = True - if eth['dhcpv6_pd']: - e.dhcp.v6.options['dhcpv6_pd'] = e['dhcpv6_pd'] + if eth['dhcpv6_pd_length']: + e.dhcp.v6.options['dhcpv6_pd_length'] = eth['dhcpv6_pd_length'] + + if eth['dhcpv6_pd_interfaces']: + e.dhcp.v6.options['dhcpv6_pd_interfaces'] = eth['dhcpv6_pd_interfaces'] # ignore link state changes e.set_link_detect(eth['disable_link_detect']) @@ -239,11 +246,12 @@ def apply(eth): e.del_ipv6_eui64_address(addr) # Change interface MAC address - re-set to real hardware address (hw-id) - # if custom mac is removed - if eth['mac']: - e.set_mac(eth['mac']) - elif eth['hw_id']: - e.set_mac(eth['hw_id']) + # if custom mac is removed. Skip if bond member. + if not eth['is_bond_member']: + if eth['mac']: + e.set_mac(eth['mac']) + elif eth['hw_id']: + e.set_mac(eth['hw_id']) # Add IPv6 EUI-based addresses for addr in eth['ipv6_eui64_prefix']: diff --git a/src/conf_mode/interfaces-pppoe.py b/src/conf_mode/interfaces-pppoe.py index ac0022dc1..231672490 100755 --- a/src/conf_mode/interfaces-pppoe.py +++ b/src/conf_mode/interfaces-pppoe.py @@ -21,15 +21,17 @@ from copy import deepcopy from netifaces import interfaces from vyos.config import Config +from vyos.configdict import dhcpv6_pd_default_data from vyos.ifconfig import Interface +from vyos.template import render from vyos.util import chown, chmod_755, call from vyos import ConfigError -from vyos.template import render from vyos import airbag airbag.enable() default_config_data = { + **dhcpv6_pd_default_data, 'access_concentrator': '', 'auth_username': '', 'auth_password': '', @@ -38,7 +40,6 @@ default_config_data = { 'deleted': False, 'description': '\0', 'disable': False, - 'dhcpv6_pd': [], 'intf': '', 'idle_timeout': '', 'ipv6_autoconf': False, @@ -139,15 +140,24 @@ def get_config(): if conf.exists('vrf'): pppoe['vrf'] = conf.return_value(['vrf']) - if conf.exists(['dhcpv6-options', 'delegate']): - for interface in conf.list_nodes(['dhcpv6-options', 'delegate']): + if conf.exists(['dhcpv6-options', 'prefix-delegation']): + dhcpv6_pd_path = base_path + [pppoe['intf'], + 'dhcpv6-options', 'prefix-delegation'] + conf.set_level(dhcpv6_pd_path) + + # retriebe DHCPv6-PD prefix helper length as some ISPs only hand out a + # /64 by default (https://phabricator.vyos.net/T2506) + if conf.exists(['length']): + pppoe['dhcpv6_pd_length'] = conf.return_value(['length']) + + for interface in conf.list_nodes(['interface']): + conf.set_level(dhcpv6_pd_path + ['interface', interface]) pd = { 'ifname': interface, 'sla_id': '', 'sla_len': '', 'if_id': '' } - conf.set_level(base_path + [pppoe['intf'], 'dhcpv6-options', 'delegate', interface]) if conf.exists(['sla-id']): pd['sla_id'] = conf.return_value(['sla-id']) @@ -155,10 +165,10 @@ def get_config(): if conf.exists(['sla-len']): pd['sla_len'] = conf.return_value(['sla-len']) - if conf.exists(['interface-id']): - pd['if_id'] = conf.return_value(['interface-id']) + if conf.exists(['address']): + pd['if_id'] = conf.return_value(['address']) - pppoe['dhcpv6_pd'].append(pd) + pppoe['dhcpv6_pd_interfaces'].append(pd) return pppoe @@ -225,7 +235,7 @@ def generate(pppoe): render(script_pppoe_ipv6_up, 'pppoe/ipv6-up.script.tmpl', pppoe, trim_blocks=True, permission=0o755) - if len(pppoe['dhcpv6_pd']) > 0: + if len(pppoe['dhcpv6_pd_interfaces']) > 0: # ipv6.tmpl relies on ifname - this should be made consitent in the # future better then double key-ing the same value pppoe['ifname'] = intf diff --git a/src/conf_mode/interfaces-pseudo-ethernet.py b/src/conf_mode/interfaces-pseudo-ethernet.py index 96ec5602d..b142688f6 100755 --- a/src/conf_mode/interfaces-pseudo-ethernet.py +++ b/src/conf_mode/interfaces-pseudo-ethernet.py @@ -174,8 +174,11 @@ def apply(peth): if peth['dhcpv6_temporary']: p.dhcp.v6.options['dhcpv6_temporary'] = True - if peth['dhcpv6_pd']: - p.dhcp.v6.options['dhcpv6_pd'] = peth['dhcpv6_pd'] + if peth['dhcpv6_pd_length']: + p.dhcp.v6.options['dhcpv6_pd_length'] = peth['dhcpv6_pd_length'] + + if peth['dhcpv6_pd_interfaces']: + p.dhcp.v6.options['dhcpv6_pd_interfaces'] = peth['dhcpv6_pd_interfaces'] # ignore link state changes p.set_link_detect(peth['disable_link_detect']) diff --git a/src/conf_mode/interfaces-wireless.py b/src/conf_mode/interfaces-wireless.py index 328632036..0162b642c 100755 --- a/src/conf_mode/interfaces-wireless.py +++ b/src/conf_mode/interfaces-wireless.py @@ -594,8 +594,11 @@ def apply(wifi): if wifi['dhcpv6_temporary']: w.dhcp.v6.options['dhcpv6_temporary'] = True - if wifi['dhcpv6_pd']: - w.dhcp.v6.options['dhcpv6_pd'] = wifi['dhcpv6_pd'] + if wifi['dhcpv6_pd_length']: + w.dhcp.v6.options['dhcpv6_pd_length'] = wifi['dhcpv6_pd_length'] + + if wifi['dhcpv6_pd_interfaces']: + w.dhcp.v6.options['dhcpv6_pd_interfaces'] = wifi['dhcpv6_pd_interfaces'] # ignore link state changes w.set_link_detect(wifi['disable_link_detect']) diff --git a/src/migration-scripts/interfaces/9-to-10 b/src/migration-scripts/interfaces/9-to-10 new file mode 100755 index 000000000..4aa2c42b5 --- /dev/null +++ b/src/migration-scripts/interfaces/9-to-10 @@ -0,0 +1,64 @@ +#!/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/>. + +# - rename CLI node 'dhcpv6-options delgate' to 'dhcpv6-options prefix-delegation +# interface' +# - rename CLI node 'interface-id' for prefix-delegation to 'address' as it +# represents the local interface IPv6 address assigned by DHCPv6-PD + +from sys import exit, argv +from vyos.configtree import ConfigTree + +if __name__ == '__main__': + if (len(argv) < 1): + print("Must specify file name!") + exit(1) + + file_name = argv[1] + with open(file_name, 'r') as f: + config_file = f.read() + + config = ConfigTree(config_file) + + for intf_type in config.list_nodes(['interfaces']): + for intf in config.list_nodes(['interfaces', intf_type]): + # cache current config tree + base_path = ['interfaces', intf_type, intf, 'dhcpv6-options', + 'delegate'] + + if config.exists(base_path): + # cache new config tree + new_path = ['interfaces', intf_type, intf, 'dhcpv6-options', + 'prefix-delegation'] + if not config.exists(new_path): + config.set(new_path) + + # copy to new node + config.copy(base_path, new_path + ['interface']) + + # rename interface-id to address + for interface in config.list_nodes(new_path + ['interface']): + config.rename(new_path + ['interface', interface, 'interface-id'], 'address') + + # delete old noe + config.delete(base_path) + + try: + with open(file_name, 'w') as f: + f.write(config.to_string()) + except OSError as e: + print("Failed to save the modified config: {}".format(e)) + exit(1) diff --git a/src/services/vyos-hostsd b/src/services/vyos-hostsd index 6017cea82..bf5d67cfa 100755 --- a/src/services/vyos-hostsd +++ b/src/services/vyos-hostsd @@ -28,6 +28,7 @@ import zmq import collections import jinja2 +from vyos.util import popen, process_named_running debug = True @@ -212,13 +213,17 @@ def handle_message(msg_json): op = get_option(msg, 'op') _type = get_option(msg, 'type') + changes = 0 + if op == 'delete': tag = get_option(msg, 'tag') if _type == 'name_servers': delete_name_servers(STATE, tag) + changes += 1 elif _type == 'hosts': delete_hosts(STATE, tag) + changes += 1 else: raise ValueError("Unknown message type {0}".format(_type)) elif op == 'add': @@ -226,8 +231,10 @@ def handle_message(msg_json): entries = get_option(msg, 'data') if _type == 'name_servers': add_name_servers(STATE, entries, tag) + changes += 1 elif _type == 'hosts': add_hosts(STATE, entries, tag) + changes += 1 else: raise ValueError("Unknown message type {0}".format(_type)) elif op == 'set': @@ -236,6 +243,7 @@ def handle_message(msg_json): data = get_option(msg, 'data') if _type == 'host_name': set_host_name(STATE, data) + changes += 1 else: raise ValueError("Unknown message type {0}".format(_type)) elif op == 'get': @@ -255,6 +263,12 @@ def handle_message(msg_json): with open(STATE_FILE, 'w') as f: json.dump(STATE, f) + if changes > 0: + if process_named_running("pdns_recursor"): + (ret,return_code) = popen("sudo rec_control --socket-dir=/run/powerdns reload-zones") + if return_code > 0: + logger.exception("PowerDNS rec_control failed to reload") + def exit_handler(sig, frame): """ Clean up the state when shutdown correctly """ logger.info("Cleaning up state") diff --git a/src/system/on-dhcp-event.sh b/src/system/on-dhcp-event.sh index 385ae460f..57f492401 100755 --- a/src/system/on-dhcp-event.sh +++ b/src/system/on-dhcp-event.sh @@ -20,7 +20,6 @@ client_ip=$3 client_mac=$4 domain=$5 file=/etc/hosts -changes=0 if [ -z "$client_name" ]; then logger -s -t on-dhcp-event "Client name was empty, using MAC \"$client_mac\" instead" @@ -44,13 +43,11 @@ case "$action" in fi # add host /usr/bin/vyos-hostsd-client --add-hosts --tag "DHCP-$client_ip" --host "$client_fqdn_name,$client_ip" - ((changes++)) ;; release) # delete mapping for released address # delete host /usr/bin/vyos-hostsd-client --delete-hosts --tag "DHCP-$client_ip" - ((changes++)) ;; *) @@ -59,15 +56,6 @@ case "$action" in ;; esac -if [ $changes -gt 0 ]; then - echo Success - pid=`pgrep pdns_recursor` - if [ -n "$pid" ]; then - sudo rec_control --socket-dir=/run/powerdns reload-zones - fi -else - echo No changes made -fi exit 0 |