diff --git a/Makefile b/Makefile index abe4524d1..2adf385f9 100644 --- a/Makefile +++ b/Makefile @@ -1,129 +1,120 @@ TMPL_DIR := templates-cfg OP_TMPL_DIR := templates-op BUILD_DIR := build DATA_DIR := data SHIM_DIR := src/shim XDP_DIR := src/xdp CC := gcc LIBS := -lzmq CFLAGS := config_xml_src = $(wildcard interface-definitions/*.xml.in) config_xml_obj = $(config_xml_src:.xml.in=.xml) op_xml_src = $(wildcard op-mode-definitions/*.xml.in) op_xml_obj = $(op_xml_src:.xml.in=.xml) %.xml: %.xml.in @echo Generating $(BUILD_DIR)/$@ from $< # -ansi This turns off certain features of GCC that are incompatible # with ISO C90. Without this regexes containing '/' as in an URL # won't work # -x c By default GCC guesses the input language from its file extension, # thus XML is unknown. Force it to C language # -E Stop after the preprocessing stage # -undef Do not predefine any system-specific or GCC-specific macros. # -nostdinc Do not search the standard system directories for header files # -P Inhibit generation of linemarkers in the output from the # preprocessor mkdir -p $(BUILD_DIR)/$(dir $@) @$(CC) -x c-header -E -undef -nostdinc -P -I$(CURDIR)/$(dir $<) -o $(BUILD_DIR)/$@ -c $< .PHONY: interface_definitions .ONESHELL: interface_definitions: $(config_xml_obj) mkdir -p $(TMPL_DIR) $(CURDIR)/scripts/override-default $(BUILD_DIR)/interface-definitions find $(BUILD_DIR)/interface-definitions -type f -name "*.xml" | xargs -I {} $(CURDIR)/scripts/build-command-templates {} $(CURDIR)/schema/interface_definition.rng $(TMPL_DIR) || exit 1 # XXX: delete top level node.def's that now live in other packages rm -f $(TMPL_DIR)/firewall/node.def rm -f $(TMPL_DIR)/interfaces/node.def rm -f $(TMPL_DIR)/policy/node.def rm -f $(TMPL_DIR)/system/node.def rm -f $(TMPL_DIR)/vpn/node.def rm -f $(TMPL_DIR)/vpn/ipsec/node.def rm -rf $(TMPL_DIR)/vpn/nipsec - # XXX: required until OSPF and RIP is migrated from vyatta-cfg-quagga to vyos-1x - mkdir $(TMPL_DIR)/interfaces/loopback/node.tag/ipv6 - mkdir $(TMPL_DIR)/interfaces/dummy/node.tag/ipv6 - mkdir -p $(TMPL_DIR)/interfaces/vti/node.tag/ipv6 - cp $(TMPL_DIR)/interfaces/ethernet/node.tag/ipv6/node.def $(TMPL_DIR)/interfaces/loopback/node.tag/ipv6 - cp $(TMPL_DIR)/interfaces/ethernet/node.tag/ipv6/node.def $(TMPL_DIR)/interfaces/dummy/node.tag/ipv6 - - cp $(TMPL_DIR)/interfaces/ethernet/node.tag/ipv6/node.def $(TMPL_DIR)/interfaces/vti/node.tag/ipv6 - .PHONY: op_mode_definitions .ONESHELL: op_mode_definitions: $(op_xml_obj) mkdir -p $(OP_TMPL_DIR) find $(BUILD_DIR)/op-mode-definitions/ -type f -name "*.xml" | xargs -I {} $(CURDIR)/scripts/build-command-op-templates {} $(CURDIR)/schema/op-mode-definition.rng $(OP_TMPL_DIR) || exit 1 # XXX: delete top level op mode node.def's that now live in other packages rm -f $(OP_TMPL_DIR)/add/node.def rm -f $(OP_TMPL_DIR)/clear/interfaces/node.def rm -f $(OP_TMPL_DIR)/clear/node.def rm -f $(OP_TMPL_DIR)/delete/node.def rm -f $(OP_TMPL_DIR)/generate/node.def rm -f $(OP_TMPL_DIR)/monitor/node.def rm -f $(OP_TMPL_DIR)/reset/vpn/node.def rm -f $(OP_TMPL_DIR)/set/node.def rm -f $(OP_TMPL_DIR)/show/interfaces/node.def rm -f $(OP_TMPL_DIR)/show/node.def rm -f $(OP_TMPL_DIR)/show/system/node.def rm -f $(OP_TMPL_DIR)/show/vpn/node.def # XXX: ping must be able to recursivly call itself as the # options are provided from the script itself ln -s ../node.tag $(OP_TMPL_DIR)/ping/node.tag/node.tag/ .PHONY: component_versions .ONESHELL: component_versions: interface_definitions $(CURDIR)/scripts/build-component-versions $(BUILD_DIR)/interface-definitions $(DATA_DIR) .PHONY: vyshim vyshim: $(MAKE) -C $(SHIM_DIR) .PHONY: vyxdp vyxdp: $(MAKE) -C $(XDP_DIR) .PHONY: all all: clean interface_definitions op_mode_definitions component_versions vyshim .PHONY: clean clean: rm -rf $(BUILD_DIR) rm -rf $(TMPL_DIR) rm -rf $(OP_TMPL_DIR) $(MAKE) -C $(SHIM_DIR) clean $(MAKE) -C $(XDP_DIR) clean .PHONY: test test: set -e; python3 -m compileall -q . PYTHONPATH=python/ python3 -m "nose" --with-xunit src --with-coverage --cover-erase --cover-xml --cover-package src/conf_mode,src/op_mode,src/completion,src/helpers,src/validators,src/tests --verbose .PHONY: sonar sonar: sonar-scanner -X -Dsonar.login=${SONAR_TOKEN} .PHONY: docs .ONESHELL: docs: sphinx-apidoc -o sphinx/source/ python/ cd sphinx/ PYTHONPATH=../python make html deb: dpkg-buildpackage -uc -us -tc -b .PHONY: schema schema: trang -I rnc -O rng schema/interface_definition.rnc schema/interface_definition.rng trang -I rnc -O rng schema/op-mode-definition.rnc schema/op-mode-definition.rng diff --git a/interface-definitions/include/ospf-interface-common.xml.i b/interface-definitions/include/ospf-interface-common.xml.i new file mode 100644 index 000000000..c3493faa3 --- /dev/null +++ b/interface-definitions/include/ospf-interface-common.xml.i @@ -0,0 +1,39 @@ +<!-- included start from ospf-interface-common.xml.i --> +<leafNode name="bfd"> + <properties> + <help>Enable Bidirectional Forwarding Detection (BFD) support</help> + <valueless/> + </properties> +</leafNode> +<leafNode name="cost"> + <properties> + <help>Interface cost</help> + <valueHelp> + <format>u32:1-65535</format> + <description>OSPF interface cost</description> + </valueHelp> + <constraint> + <validator name="numeric" argument="--range 1-65535"/> + </constraint> + </properties> +</leafNode> +<leafNode name="mtu-ignore"> + <properties> + <help>Disable Maximum Transmission Unit (MTU) mismatch detection</help> + <valueless/> + </properties> +</leafNode> +<leafNode name="priority"> + <properties> + <help>Router priority (default: 1)</help> + <valueHelp> + <format>u32:0-255</format> + <description>OSPF router priority cost</description> + </valueHelp> + <constraint> + <validator name="numeric" argument="--range 0-255"/> + </constraint> + </properties> + <defaultValue>1</defaultValue> +</leafNode> +<!-- included end --> diff --git a/interface-definitions/protocols-ospf.xml.in b/interface-definitions/protocols-ospf.xml.in index a616c0e60..d0cfa14b1 100644 --- a/interface-definitions/protocols-ospf.xml.in +++ b/interface-definitions/protocols-ospf.xml.in @@ -1,849 +1,813 @@ <?xml version="1.0" encoding="utf-8"?> <!-- Protocol OSPF configuration --> <interfaceDefinition> <node name="protocols"> <children> <node name="ospf" owner="${vyos_conf_scripts_dir}/protocols_ospf.py"> <properties> <help>Open Shortest Path First (OSPF)</help> <priority>620</priority> </properties> <children> <tagNode name="access-list"> <properties> <help>Access list to filter networks in routing updates</help> <completionHelp> <path>policy access-list</path> </completionHelp> <valueHelp> <format>u32</format> <description>Access-list number</description> </valueHelp> <constraint> <validator name="numeric" argument="--range 0-4294967295"/> </constraint> </properties> <children> <leafNode name="export"> <properties> <help>Filter for outgoing routing update [REQUIRED]</help> <completionHelp> <list>bgp connected kernel rip static</list> </completionHelp> <valueHelp> <format>bgp</format> <description>Filter BGP routes</description> </valueHelp> <valueHelp> <format>connected</format> <description>Filter connected routes</description> </valueHelp> <valueHelp> <format>kernel</format> <description>Filter Kernel routes</description> </valueHelp> <valueHelp> <format>rip</format> <description>Filter RIP routes</description> </valueHelp> <valueHelp> <format>static</format> <description>Filter static routes</description> </valueHelp> <constraint> <regex>^(bgp|connected|kernel|rip|static)$</regex> </constraint> <constraintErrorMessage>Must be bgp, connected, kernel, rip, or static</constraintErrorMessage> <multi/> </properties> </leafNode> </children> </tagNode> <tagNode name="area"> <properties> <help>OSPF Area</help> <valueHelp> <format>u32</format> <description>OSPF area in decimal notation</description> </valueHelp> <valueHelp> <format>ipv4</format> <description>OSPF area in dotted decimal notation</description> </valueHelp> <constraint> <validator name="numeric" argument="--range 0-4294967295"/> <validator name="ip-address"/> </constraint> </properties> <children> <node name="area-type"> <properties> <help>Area type</help> </properties> <children> <leafNode name="normal"> <properties> <help>Normal OSPF area</help> <valueless/> </properties> </leafNode> <node name="nssa"> <properties> <help>Nssa OSPF area</help> </properties> <children> <leafNode name="default-cost"> <properties> <help>Summary-default cost of nssa area</help> <valueHelp> <format>u32:0-16777215</format> <description>Summary default cost</description> </valueHelp> <constraint> <validator name="numeric" argument="--range 0-16777215"/> </constraint> </properties> </leafNode> <leafNode name="no-summary"> <properties> <help>Do not inject inter-area routes into stub</help> <valueless/> </properties> </leafNode> <leafNode name="translate"> <properties> <help>Configure NSSA-ABR (default: candidate)</help> <completionHelp> <list>always candidate never</list> </completionHelp> <valueHelp> <format>always</format> <description>NSSA-ABR to always translate</description> </valueHelp> <valueHelp> <format>candidate</format> <description>NSSA-ABR for translate election (default)</description> </valueHelp> <valueHelp> <format>never</format> <description>NSSA-ABR to never translate</description> </valueHelp> <constraint> <regex>^(always|candidate|never)$</regex> </constraint> </properties> <defaultValue>candidate</defaultValue> </leafNode> </children> </node> <node name="stub"> <properties> <help>Stub OSPF area</help> </properties> <children> <leafNode name="default-cost"> <properties> <help>Summary-default cost of nssa area</help> <valueHelp> <format>u32:0-16777215</format> <description>Summary default cost</description> </valueHelp> <constraint> <validator name="numeric" argument="--range 0-16777215"/> </constraint> </properties> </leafNode> <leafNode name="no-summary"> <properties> <help>Do not inject inter-area routes into stub</help> <valueless/> </properties> </leafNode> </children> </node> </children> </node> <leafNode name="authentication"> <properties> <help>OSPF area authentication type</help> <completionHelp> <list>plaintext-password md5</list> </completionHelp> <valueHelp> <format>plaintext-password</format> <description>Use plain-text authentication</description> </valueHelp> <valueHelp> <format>md5</format> <description>Use md5 authentication</description> </valueHelp> <constraint> <regex>^(plaintext-password|md5)$</regex> </constraint> </properties> </leafNode> <leafNode name="network"> <properties> <help>OSPF network [REQUIRED]</help> <valueHelp> <format>ipv4net</format> <description>OSPF network [REQUIRED]</description> </valueHelp> <constraint> <validator name="ipv4-prefix"/> </constraint> <multi/> </properties> </leafNode> <tagNode name="range"> <properties> <help>Summarize routes matching prefix (border routers only)</help> <valueHelp> <format>ipv4net</format> <description>Area range prefix</description> </valueHelp> <constraint> <validator name="ipv4-prefix"/> </constraint> </properties> <children> <leafNode name="cost"> <properties> <help>Metric for this range</help> <valueHelp> <format>u32:0-16777215</format> <description>Metric for this range</description> </valueHelp> <constraint> <validator name="numeric" argument="--range 0-16777215"/> </constraint> </properties> </leafNode> <leafNode name="not-advertise"> <properties> <help>Do not advertise this range</help> <valueless/> </properties> </leafNode> <leafNode name="substitute"> <properties> <help>Announce area range as another prefix</help> <valueHelp> <format>ipv4net</format> <description>Announce area range as another prefix</description> </valueHelp> <constraint> <validator name="ipv4-prefix"/> </constraint> </properties> </leafNode> </children> </tagNode> <leafNode name="shortcut"> <properties> <help>Area shortcut mode</help> <completionHelp> <list>default disable enable</list> </completionHelp> <valueHelp> <format>default</format> <description>Set default</description> </valueHelp> <valueHelp> <format>disable</format> <description>Disable shortcutting mode</description> </valueHelp> <valueHelp> <format>enable</format> <description>Enable shortcutting mode</description> </valueHelp> <constraint> <regex>^(default|disable|enable)$</regex> </constraint> </properties> </leafNode> <tagNode name="virtual-link"> <properties> <help>Virtual link</help> <valueHelp> <format>ipv4</format> <description>OSPF area in dotted decimal notation</description> </valueHelp> <constraint> <validator name="numeric" argument="--range 0-4294967295"/> <validator name="ip-address"/> </constraint> </properties> <children> #include <include/ospf-authentication.xml.i> #include <include/ospf-intervals.xml.i> </children> </tagNode> </children> </tagNode> <node name="auto-cost"> <properties> <help>Calculate OSPF interface cost according to bandwidth (default: 100)</help> </properties> <children> <leafNode name="reference-bandwidth"> <properties> <help>Reference bandwidth method to assign OSPF cost</help> <valueHelp> <format>u32:1-4294967</format> <description>Reference bandwidth cost in Mbits/sec</description> </valueHelp> <constraint> <validator name="numeric" argument="--range 1-4294967"/> </constraint> </properties> <defaultValue>100</defaultValue> </leafNode> </children> </node> <node name="default-information"> <properties> <help>Control distribution of default information</help> </properties> <children> <node name="originate"> <properties> <help>Distribute a default route</help> </properties> <children> <leafNode name="always"> <properties> <help>Always advertise default route</help> <valueless/> </properties> </leafNode> #include <include/ospf-metric.xml.i> #include <include/ospf-metric-type.xml.i> #include <include/ospf-route-map.xml.i> </children> </node> </children> </node> <leafNode name="default-metric"> <properties> <help>Metric of redistributed routes</help> <valueHelp> <format>u32:0-16777214</format> <description>Metric of redistributed routes</description> </valueHelp> <constraint> <validator name="numeric" argument="--range 0-16777214"/> </constraint> </properties> </leafNode> <node name="distance"> <properties> <help>Administrative distance</help> </properties> <children> <leafNode name="global"> <properties> <help>OSPF administrative distance</help> <valueHelp> <format>u32:1-255</format> <description>Administrative distance</description> </valueHelp> <constraint> <validator name="numeric" argument="--range 1-255"/> </constraint> </properties> </leafNode> <node name="ospf"> <properties> <help>OSPF administrative distance</help> </properties> <children> <leafNode name="external"> <properties> <help>Distance for external routes</help> <valueHelp> <format>u32:1-255</format> <description>Distance for external routes</description> </valueHelp> <constraint> <validator name="numeric" argument="--range 1-255"/> </constraint> </properties> </leafNode> <leafNode name="inter-area"> <properties> <help>Distance for inter-area routes</help> <valueHelp> <format>u32:1-255</format> <description>Distance for inter-area routes</description> </valueHelp> <constraint> <validator name="numeric" argument="--range 1-255"/> </constraint> </properties> </leafNode> <leafNode name="intra-area"> <properties> <help>Distance for intra-area routes</help> <valueHelp> <format>u32:1-255</format> <description>Distance for intra-area routes</description> </valueHelp> <constraint> <validator name="numeric" argument="--range 1-255"/> </constraint> </properties> </leafNode> </children> </node> </children> </node> <tagNode name="interface"> <properties> <help>Interface related configuration</help> <completionHelp> <script>${vyos_completion_dir}/list_interfaces.py</script> </completionHelp> <valueHelp> <format>txt</format> <description>Interface name</description> </valueHelp> <constraint> <validator name="interface-name"/> </constraint> </properties> <children> #include <include/ospf-authentication.xml.i> #include <include/ospf-intervals.xml.i> + #include <include/ospf-interface-common.xml.i> <leafNode name="bandwidth"> <properties> <help>Bandwidth of interface (Megabit/sec)</help> <valueHelp> <format>u32:1-100000</format> <description>Bandwidth in Megabit/sec (for calculating OSPF cost)</description> </valueHelp> <constraint> <validator name="numeric" argument="--range 1-100000"/> </constraint> </properties> </leafNode> - <leafNode name="bfd"> - <properties> - <help>Enable Bidirectional Forwarding Detection (BFD) support</help> - <valueless/> - </properties> - </leafNode> - <leafNode name="cost"> - <properties> - <help>Interface cost</help> - <valueHelp> - <format>u32:1-65535</format> - <description>OSPF interface cost</description> - </valueHelp> - <constraint> - <validator name="numeric" argument="--range 1-65535"/> - </constraint> - </properties> - </leafNode> <leafNode name="hello-multiplier"> <properties> <help>Hello multiplier factor</help> <valueHelp> <format>u32:1-10</format> <description>Number of Hellos to send each second</description> </valueHelp> <constraint> <validator name="numeric" argument="--range 1-10"/> </constraint> </properties> </leafNode> - <leafNode name="mtu-ignore"> - <properties> - <help>Disable Maximum Transmission Unit (MTU) mismatch detection</help> - <valueless/> - </properties> - </leafNode> <leafNode name="network"> <properties> <help>Network type</help> <completionHelp> <list>broadcast non-broadcast point-to-multipoint point-to-point</list> </completionHelp> <valueHelp> <format>broadcast</format> <description>Broadcast network type</description> </valueHelp> <valueHelp> <format>non-broadcast</format> <description>Non-broadcast network type</description> </valueHelp> <valueHelp> <format>point-to-multipoint</format> <description>Point-to-multipoint network type</description> </valueHelp> <valueHelp> <format>point-to-point</format> <description>Point-to-point network type</description> </valueHelp> <constraint> <regex>^(broadcast|non-broadcast|point-to-multipoint|point-to-point)$</regex> </constraint> <constraintErrorMessage>Must be broadcast, non-broadcast, point-to-multipoint or point-to-point</constraintErrorMessage> </properties> </leafNode> - <leafNode name="priority"> - <properties> - <help>Router priority (default: 1)</help> - <valueHelp> - <format>u32:0-255</format> - <description>OSPF router priority cost</description> - </valueHelp> - <constraint> - <validator name="numeric" argument="--range 0-255"/> - </constraint> - </properties> - <defaultValue>1</defaultValue> - </leafNode> </children> </tagNode> <node name="log-adjacency-changes"> <properties> <help>Log changes in adjacency state</help> </properties> <children> <leafNode name="detail"> <properties> <help>Log all state changes</help> <valueless/> </properties> </leafNode> </children> </node> <node name="max-metric"> <properties> <help>OSPF maximum and infinite-distance metric</help> </properties> <children> <node name="router-lsa"> <properties> <help>Advertise own Router-LSA with infinite distance (stub router)</help> </properties> <children> <leafNode name="administrative"> <properties> <help>Administratively apply, for an indefinite period</help> <valueless/> </properties> </leafNode> <leafNode name="on-shutdown"> <properties> <help>Advertise stub-router prior to full shutdown of OSPF</help> <valueHelp> <format>u32:5-100</format> <description>Time (seconds) to advertise self as stub-router</description> </valueHelp> <constraint> <validator name="numeric" argument="--range 5-100"/> </constraint> </properties> </leafNode> <leafNode name="on-startup"> <properties> <help>Automatically advertise stub Router-LSA on startup of OSPF</help> <valueHelp> <format>u32:5-86400</format> <description>Time (seconds) to advertise self as stub-router</description> </valueHelp> <constraint> <validator name="numeric" argument="--range 5-86400"/> </constraint> </properties> </leafNode> </children> </node> </children> </node> <node name="mpls-te"> <properties> <help>MultiProtocol Label Switching-Traffic Engineering (MPLS-TE) parameters</help> </properties> <children> <leafNode name="enable"> <properties> <help>Enable MPLS-TE functionality</help> <valueless/> </properties> </leafNode> <leafNode name="router-address"> <properties> <help>Stable IP address of the advertising router</help> <valueHelp> <format>ipv4</format> <description>Stable IP address of the advertising router</description> </valueHelp> <constraint> <validator name="ipv4-address"/> </constraint> </properties> <defaultValue>0.0.0.0</defaultValue> </leafNode> </children> </node> <tagNode name="neighbor"> <properties> <help>Specify neighbor router</help> <valueHelp> <format>ipv4</format> <description>Neighbor IP address</description> </valueHelp> <constraint> <validator name="ipv4-address"/> </constraint> </properties> <children> <leafNode name="poll-interval"> <properties> <help>Dead neighbor polling interval (default: 60)</help> <valueHelp> <format>u32:1-65535</format> <description>Seconds between dead neighbor polling interval</description> </valueHelp> <constraint> <validator name="numeric" argument="--range 1-65535"/> </constraint> </properties> <defaultValue>60</defaultValue> </leafNode> <leafNode name="priority"> <properties> <help>Neighbor priority in seconds (default: 0)</help> <valueHelp> <format>u32:0-255</format> <description>Neighbor priority</description> </valueHelp> <constraint> <validator name="numeric" argument="--range 0-255"/> </constraint> </properties> <defaultValue>0</defaultValue> </leafNode> </children> </tagNode> <node name="parameters"> <properties> <help>OSPF specific parameters</help> </properties> <children> <leafNode name="abr-type"> <properties> <help>OSPF ABR type (default: cisco)</help> <completionHelp> <list>cisco ibm shortcut standard</list> </completionHelp> <valueHelp> <format>cisco</format> <description>Cisco ABR type (default)</description> </valueHelp> <valueHelp> <format>ibm</format> <description>Ibm ABR type</description> </valueHelp> <valueHelp> <format>shortcut</format> <description>Shortcut ABR type</description> </valueHelp> <valueHelp> <format>standard</format> <description>Standard ABR type</description> </valueHelp> <constraint> <regex>^(cisco|ibm|shortcut|standard)$</regex> </constraint> </properties> <defaultValue>cisco</defaultValue> </leafNode> <leafNode name="opaque-lsa"> <properties> <help>Enable the Opaque-LSA capability (rfc2370)</help> <valueless/> </properties> </leafNode> <leafNode name="rfc1583-compatibility"> <properties> <help>Enable rfc1583 criteria for handling AS external routes</help> <valueless/> </properties> </leafNode> <leafNode name="router-id"> <properties> <help>Override the default router identifier</help> <valueHelp> <format>ipv4</format> <description>Override the default router identifier</description> </valueHelp> <constraint> <validator name="ipv4-address"/> </constraint> </properties> </leafNode> </children> </node> #include <include/routing-passive-interface-xml.i> <leafNode name="passive-interface-exclude"> <properties> <help>Interface to exclude when using 'passive-interface default'</help> <completionHelp> <script>${vyos_completion_dir}/list_interfaces.py</script> </completionHelp> <valueHelp> <format>txt</format> <description>Interface to be passive (i.e. suppress routing updates)</description> </valueHelp> <constraint> <validator name="interface-name"/> </constraint> <multi/> </properties> </leafNode> <node name="redistribute"> <properties> <help>Redistribute information from another routing protocol</help> </properties> <children> <node name="bgp"> <properties> <help>Redistribute BGP routes</help> </properties> <children> #include <include/ospf-metric.xml.i> #include <include/ospf-metric-type.xml.i> #include <include/ospf-route-map.xml.i> </children> </node> <node name="connected"> <properties> <help>Redistribute connected routes</help> </properties> <children> #include <include/ospf-metric.xml.i> #include <include/ospf-metric-type.xml.i> #include <include/ospf-route-map.xml.i> </children> </node> <node name="kernel"> <properties> <help>Redistribute kernel routes</help> </properties> <children> #include <include/ospf-metric.xml.i> #include <include/ospf-metric-type.xml.i> #include <include/ospf-route-map.xml.i> </children> </node> <node name="rip"> <properties> <help>Redistribute rip routes</help> </properties> <children> #include <include/ospf-metric.xml.i> #include <include/ospf-metric-type.xml.i> #include <include/ospf-route-map.xml.i> </children> </node> <node name="static"> <properties> <help>Redistribute static routes</help> </properties> <children> #include <include/ospf-metric.xml.i> #include <include/ospf-metric-type.xml.i> #include <include/ospf-route-map.xml.i> </children> </node> </children> </node> <node name="refresh"> <properties> <help>Adjust refresh parameters</help> </properties> <children> <leafNode name="timers"> <properties> <help>Refresh timer</help> <valueHelp> <format>u32:10-1800</format> <description>Timer value in seconds</description> </valueHelp> <constraint> <validator name="numeric" argument="--range 10-1800"/> </constraint> </properties> </leafNode> </children> </node> #include <include/ospf-route-map.xml.i> <node name="timers"> <properties> <help>Adjust routing timers</help> </properties> <children> <node name="throttle"> <properties> <help>Throttling adaptive timers</help> </properties> <children> <node name="spf"> <properties> <help>OSPF SPF timers</help> </properties> <children> <leafNode name="delay"> <properties> <help>Delay from first change received till SPF calculation (default: 200)</help> <valueHelp> <format>u32:0-600000</format> <description>Delay in milliseconds</description> </valueHelp> <constraint> <validator name="numeric" argument="--range 0-600000"/> </constraint> </properties> <defaultValue>200</defaultValue> </leafNode> <leafNode name="initial-holdtime"> <properties> <help>Initial hold time between consecutive SPF calculations (default: 1000)</help> <valueHelp> <format>u32:0-600000</format> <description>Initial hold time in milliseconds</description> </valueHelp> <constraint> <validator name="numeric" argument="--range 0-600000"/> </constraint> </properties> <defaultValue>1000</defaultValue> </leafNode> <leafNode name="max-holdtime"> <properties> <help>Maximum hold time (default: 10000)</help> <valueHelp> <format>u32:0-600000</format> <description>Max hold time in milliseconds</description> </valueHelp> <constraint> <validator name="numeric" argument="--range 0-600000"/> </constraint> </properties> <defaultValue>10000</defaultValue> </leafNode> </children> </node> </children> </node> </children> </node> </children> </node> </children> </node> </interfaceDefinition> diff --git a/interface-definitions/protocols-ospfv3.xml.in b/interface-definitions/protocols-ospfv3.xml.in index bd6a55b45..e28faa3cf 100644 --- a/interface-definitions/protocols-ospfv3.xml.in +++ b/interface-definitions/protocols-ospfv3.xml.in @@ -1,221 +1,275 @@ <?xml version="1.0" encoding="utf-8"?> <interfaceDefinition> <node name="protocols"> <children> <node name="ospfv3" owner="${vyos_conf_scripts_dir}/protocols_ospfv3.py"> <properties> <help>Open Shortest Path First (OSPF) for IPv6</help> <priority>620</priority> </properties> <children> <tagNode name="area"> <properties> <help>OSPFv3 Area</help> <valueHelp> <format>u32</format> <description>Area ID as a decimal value</description> </valueHelp> <valueHelp> <format>ipv4</format> <description>Area ID in IP address forma</description> </valueHelp> <constraint> <validator name="numeric" argument="--range 0-4294967295"/> <validator name="ip-address"/> </constraint> </properties> <children> <leafNode name="export-list"> <properties> <help>Name of export-list</help> <completionHelp> <path>policy access-list6</path> </completionHelp> </properties> </leafNode> <leafNode name="import-list"> <properties> <help>Name of import-list</help> <completionHelp> <path>policy access-list6</path> </completionHelp> </properties> </leafNode> - <leafNode name="interface"> + <tagNode name="interface"> <properties> <help>Enable routing on an IPv6 interface</help> <completionHelp> <script>${vyos_completion_dir}/list_interfaces.py</script> </completionHelp> <valueHelp> <format>txt</format> <description>Interface used for routing information exchange</description> </valueHelp> <constraint> <validator name="interface-name"/> </constraint> - <multi/> </properties> - </leafNode> + <children> + #include <include/ospf-intervals.xml.i> + #include <include/ospf-interface-common.xml.i> + <leafNode name="ifmtu"> + <properties> + <help>Interface MTU</help> + <valueHelp> + <format>u32:1-65535</format> + <description>Interface MTU</description> + </valueHelp> + <constraint> + <validator name="numeric" argument="--range 1-65535"/> + </constraint> + </properties> + </leafNode> + <leafNode name="instance-id"> + <properties> + <help>Instance Id (default: 0)</help> + <valueHelp> + <format>u32:0-255</format> + <description>Instance Id</description> + </valueHelp> + <constraint> + <validator name="numeric" argument="--range 0-255"/> + </constraint> + </properties> + <defaultValue>0</defaultValue> + </leafNode> + <leafNode name="network"> + <properties> + <help>Network type</help> + <completionHelp> + <list>broadcast point-to-point</list> + </completionHelp> + <valueHelp> + <format>broadcast</format> + <description>Broadcast network type</description> + </valueHelp> + <valueHelp> + <format>point-to-point</format> + <description>Point-to-point network type</description> + </valueHelp> + <constraint> + <regex>^(broadcast|point-to-point)$</regex> + </constraint> + <constraintErrorMessage>Must be broadcast or point-to-point</constraintErrorMessage> + </properties> + </leafNode> + <leafNode name="passive"> + <properties> + <help>Disable forming of adjacency</help> + <valueless/> + </properties> + </leafNode> + </children> + </tagNode> <tagNode name="range"> <properties> <help>Specify IPv6 prefix (border routers only)</help> <valueHelp> <format>ipv6net</format> <description>Specify IPv6 prefix (border routers only)</description> </valueHelp> <constraint> <validator name="ipv6-prefix"/> </constraint> </properties> <children> <leafNode name="advertise"> <properties> <help>Advertise this range</help> <valueless/> </properties> </leafNode> <leafNode name="not-advertise"> <properties> <help>Do not advertise this range</help> <valueless/> </properties> </leafNode> </children> </tagNode> </children> </tagNode> <node name="distance"> <properties> <help>Administrative distance</help> </properties> <children> <leafNode name="global"> <properties> <help>OSPFv3 administrative distance</help> <valueHelp> <format>u32:1-255</format> <description>Administrative distance</description> </valueHelp> <constraint> <validator name="numeric" argument="--range 1-255"/> </constraint> </properties> </leafNode> <node name="ospfv3"> <properties> <help>OSPFv3 administrative distance</help> </properties> <children> <leafNode name="external"> <properties> <help>Distance for external routes</help> <valueHelp> <format>u32:1-255</format> <description>Distance for external routes</description> </valueHelp> <constraint> <validator name="numeric" argument="--range 1-255"/> </constraint> </properties> </leafNode> <leafNode name="inter-area"> <properties> <help>Distance for inter-area routes</help> <valueHelp> <format>u32:1-255</format> <description>Distance for inter-area routes</description> </valueHelp> <constraint> <validator name="numeric" argument="--range 1-255"/> </constraint> </properties> </leafNode> <leafNode name="intra-area"> <properties> <help>Distance for intra-area routes</help> <valueHelp> <format>u32:1-255</format> <description>Distance for intra-area routes</description> </valueHelp> <constraint> <validator name="numeric" argument="--range 1-255"/> </constraint> </properties> </leafNode> </children> </node> </children> </node> <node name="parameters"> <properties> <help>OSPFv3 specific parameters</help> </properties> <children> <leafNode name="router-id"> <properties> <help>Override the default router identifier</help> <valueHelp> <format>ipv4</format> <description>Override the default router identifier</description> </valueHelp> <constraint> <validator name="ipv4-address"/> </constraint> </properties> </leafNode> </children> </node> <node name="redistribute"> <properties> <help>Redistribute information from another routing protocol</help> </properties> <children> <node name="bgp"> <properties> <help>Redistribute BGP routes</help> </properties> <children> #include <include/ospf-route-map.xml.i> </children> </node> <node name="connected"> <properties> <help>Redistribute connected routes</help> </properties> <children> #include <include/ospf-route-map.xml.i> </children> </node> <node name="kernel"> <properties> <help>Redistribute kernel routes</help> </properties> <children> #include <include/ospf-route-map.xml.i> </children> </node> <node name="ripng"> <properties> <help>Redistribute RIPNG routes</help> </properties> <children> #include <include/ospf-route-map.xml.i> </children> </node> <node name="static"> <properties> <help>Redistribute static routes</help> </properties> <children> #include <include/ospf-route-map.xml.i> </children> </node> </children> </node> #include <include/ospf-route-map.xml.i> </children> </node> </children> </node> </interfaceDefinition> diff --git a/smoketest/configs/ospf-small b/smoketest/configs/ospf-small index fe313e4b0..d95ba4ea4 100644 --- a/smoketest/configs/ospf-small +++ b/smoketest/configs/ospf-small @@ -1,120 +1,142 @@ interfaces { dummy dum0 { address 172.18.254.201/32 } ethernet eth0 { duplex auto smp-affinity auto speed auto vif 201 { address 172.18.201.10/24 ip { ospf { authentication { md5 { key-id 10 { md5-key OSPFVyOSNET } } } dead-interval 40 hello-interval 10 priority 1 retransmit-interval 5 transmit-delay 1 } } + ipv6 { + ospfv3 { + bfd + cost 40 + } + } } } ethernet eth1 { duplex auto smp-affinity auto speed auto + ipv6 { + ospfv3 { + bfd + cost 60 + mtu-ignore + network broadcast + priority 20 + } + } } } protocols { ospf { area 0 { network 172.18.201.0/24 network 172.18.254.201/32 } log-adjacency-changes { } parameters { abr-type cisco router-id 172.18.254.201 } passive-interface default passive-interface-exclude eth0.201 } + ospfv3 { + area 0.0.0.0 { + interface eth0 + interface eth1 + interface eth2 + } + } static { route 0.0.0.0/0 { next-hop 172.18.201.254 { distance 10 } } } } service { lldp { interface all { } } snmp { community public { authorization ro network 172.16.100.0/24 } contact "VyOS maintainers and contributors <maintainers@vyos.io>" location "Jenkins" } ssh { disable-host-validation port 22 } } system { config-management { commit-revisions 200 } console { device ttyS0 { speed 115200 } } domain-name vyos.net host-name vyos login { user vyos { authentication { encrypted-password $6$2Ta6TWHd/U$NmrX0x9kexCimeOcYK1MfhMpITF9ELxHcaBU/znBq.X2ukQOj61fVI2UYP/xBzP4QtiTcdkgs7WOQMHWsRymO/ plaintext-password "" } level admin } } name-server 172.16.254.30 ntp { server 0.pool.ntp.org { } server 1.pool.ntp.org { } server 2.pool.ntp.org { } } syslog { global { facility all { level info } facility protocols { level debug } } } time-zone Europe/Berlin } /* Warning: Do not remove the following line. */ /* === vyatta-config-version: "broadcast-relay@1:cluster@1:config-management@1:conntrack-sync@1:conntrack@1:dhcp-relay@2:dhcp-server@5:dns-forwarding@1:firewall@5:ipsec@5:l2tp@1:mdns@1:nat@4:ntp@1:pptp@1:qos@1:quagga@6:snmp@1:ssh@1:system@9:vrrp@2:wanloadbalance@3:webgui@1:webproxy@1:webproxy@2:zone-policy@1" === */ /* Release version: 1.2.6 */ diff --git a/src/migration-scripts/interfaces/18-to-19 b/src/migration-scripts/interfaces/18-to-19 index 460032602..06e07572f 100755 --- a/src/migration-scripts/interfaces/18-to-19 +++ b/src/migration-scripts/interfaces/18-to-19 @@ -1,127 +1,145 @@ #!/usr/bin/env python3 # # Copyright (C) 2021 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/>. from sys import argv from sys import exit from vyos.configtree import ConfigTree def migrate_ospf(config, path, interface): path = path + ['ospf'] if config.exists(path): new_base = ['protocols', 'ospf', 'interface'] config.set(new_base) config.set_tag(new_base) config.copy(path, new_base + [interface]) config.delete(path) # if "ip ospf" was the only setting, we can clean out the empty # ip node afterwards if len(config.list_nodes(path[:-1])) == 0: config.delete(path[:-1]) +def migrate_ospfv3(config, path, interface): + path = path + ['ospfv3'] + if config.exists(path): + new_base = ['protocols', 'ospfv3', 'interface'] + config.set(new_base) + config.set_tag(new_base) + config.copy(path, new_base + [interface]) + config.delete(path) + + # if "ipv6 ospfv3" was the only setting, we can clean out the empty + # ip node afterwards + if len(config.list_nodes(path[:-1])) == 0: + config.delete(path[:-1]) + def migrate_rip(config, path, interface): path = path + ['rip'] if config.exists(path): new_base = ['protocols', 'rip', 'interface'] config.set(new_base) config.set_tag(new_base) config.copy(path, new_base + [interface]) config.delete(path) # if "ip rip" was the only setting, we can clean out the empty # ip node afterwards if len(config.list_nodes(path[:-1])) == 0: config.delete(path[:-1]) def migrate_ripng(config, path, interface): path = path + ['ripng'] if config.exists(path): new_base = ['protocols', 'ripng', 'interface'] config.set(new_base) config.set_tag(new_base) config.copy(path, new_base + [interface]) config.delete(path) # if "ipv6 ripng" was the only setting, we can clean out the empty # ip node afterwards if len(config.list_nodes(path[:-1])) == 0: config.delete(path[:-1]) 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) # # Migrate "interface ethernet eth0 ip ospf" to "protocols ospf interface eth0" # for type in config.list_nodes(['interfaces']): for interface in config.list_nodes(['interfaces', type]): ip_base = ['interfaces', type, interface, 'ip'] ipv6_base = ['interfaces', type, interface, 'ipv6'] migrate_rip(config, ip_base, interface) migrate_ripng(config, ipv6_base, interface) migrate_ospf(config, ip_base, interface) + migrate_ospfv3(config, ipv6_base, interface) vif_path = ['interfaces', type, interface, 'vif'] if config.exists(vif_path): for vif in config.list_nodes(vif_path): vif_ip_base = vif_path + [vif, 'ip'] vif_ipv6_base = vif_path + [vif, 'ipv6'] ifname = f'{interface}.{vif}' migrate_rip(config, vif_ip_base, ifname) migrate_ripng(config, vif_ipv6_base, ifname) migrate_ospf(config, vif_ip_base, ifname) + migrate_ospfv3(config, vif_ipv6_base, ifname) vif_s_path = ['interfaces', type, interface, 'vif-s'] if config.exists(vif_s_path): for vif_s in config.list_nodes(vif_s_path): vif_s_ip_base = vif_s_path + [vif_s, 'ip'] vif_s_ipv6_base = vif_s_path + [vif_s, 'ipv6'] # vif-c interfaces MUST be migrated before their parent vif-s # interface as the migrate_*() functions delete the path! vif_c_path = ['interfaces', type, interface, 'vif-s', vif_s, 'vif-c'] if config.exists(vif_c_path): for vif_c in config.list_nodes(vif_c_path): vif_c_ip_base = vif_c_path + [vif_c, 'ip'] vif_c_ipv6_base = vif_c_path + [vif_c, 'ipv6'] ifname = f'{interface}.{vif_s}.{vif_c}' migrate_rip(config, vif_c_ip_base, ifname) migrate_ripng(config, vif_c_ipv6_base, ifname) migrate_ospf(config, vif_c_ip_base, ifname) + migrate_ospfv3(config, vif_c_ipv6_base, ifname) ifname = f'{interface}.{vif_s}' migrate_rip(config, vif_s_ip_base, ifname) migrate_ripng(config, vif_s_ipv6_base, ifname) migrate_ospf(config, vif_s_ip_base, ifname) + migrate_ospfv3(config, vif_s_ipv6_base, ifname) 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)