From 6f87d8c910964fd0ebe9724183baa12861caa419 Mon Sep 17 00:00:00 2001
From: Christian Poessinger <christian@poessinger.com>
Date: Sun, 15 Aug 2021 12:53:03 +0200
Subject: ospf: T3757: support to configure area at an interface level

FRR supports configuring either network prefixes per area, or assign an
interface to an area to participate in the routing process. This is already well
known from other venders and supported by FRR.

A valid VyOS OSPF configuration would then look like:

vyos@vyos# show protocols
 ospf {
     interface dum0 {
         area 0
     }
     interface eth0.201 {
         area 0
         authentication {
             md5 {
                 key-id 10 {
                     md5-key vyos
                 }
             }
         }
         dead-interval 40
         hello-interval 10
         priority 1
         retransmit-interval 5
         transmit-delay 1
     }
     log-adjacency-changes {
         detail
     }
     parameters {
         abr-type cisco
         router-id 172.18.254.201
     }
     passive-interface default
     passive-interface-exclude eth0.201
 }
---
 .../include/ospf/protocol-common-config.xml.i           | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

(limited to 'interface-definitions/include/ospf')

diff --git a/interface-definitions/include/ospf/protocol-common-config.xml.i b/interface-definitions/include/ospf/protocol-common-config.xml.i
index db39b1a86..c4ca613a4 100644
--- a/interface-definitions/include/ospf/protocol-common-config.xml.i
+++ b/interface-definitions/include/ospf/protocol-common-config.xml.i
@@ -361,6 +361,23 @@
     </constraint>
   </properties>
   <children>
+    <leafNode name="area">
+      <properties>
+        <help>Enable OSPF on this interface</help>
+        <valueHelp>
+          <format>u32</format>
+          <description>OSPF area ID as decimal notation</description>
+        </valueHelp>
+        <valueHelp>
+          <format>ipv4</format>
+          <description>OSPF area ID in IP address notation</description>
+        </valueHelp>
+        <constraint>
+          <validator name="numeric" argument="--range 0-4294967295"/>
+          <validator name="ip-address"/>
+        </constraint>
+      </properties>
+    </leafNode>
     #include <include/ospf/authentication.xml.i>
     #include <include/ospf/intervals.xml.i>
     #include <include/ospf/interface-common.xml.i>
-- 
cgit v1.2.3


From 33ccbfdd0b367a2416c3a8b41a73d7477123d276 Mon Sep 17 00:00:00 2001
From: Christian Poessinger <christian@poessinger.com>
Date: Sun, 29 Aug 2021 12:07:53 +0200
Subject: ospf: xml: T3236: update help strings

---
 interface-definitions/include/ospf/protocol-common-config.xml.i | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'interface-definitions/include/ospf')

diff --git a/interface-definitions/include/ospf/protocol-common-config.xml.i b/interface-definitions/include/ospf/protocol-common-config.xml.i
index c4ca613a4..546516a80 100644
--- a/interface-definitions/include/ospf/protocol-common-config.xml.i
+++ b/interface-definitions/include/ospf/protocol-common-config.xml.i
@@ -665,7 +665,7 @@
     </node>
     <node name="kernel">
       <properties>
-        <help>Redistribute kernel routes</help>
+        <help>Redistribute Kernel routes</help>
       </properties>
       <children>
         #include <include/ospf/metric.xml.i>
@@ -685,7 +685,7 @@
     </node>
     <node name="static">
       <properties>
-        <help>Redistribute static routes</help>
+        <help>Redistribute statically configured routes</help>
       </properties>
       <children>
         #include <include/ospf/metric.xml.i>
-- 
cgit v1.2.3


From 40bfaed4d1d427c33157136026944df80e02a5b6 Mon Sep 17 00:00:00 2001
From: Christian Poessinger <christian@poessinger.com>
Date: Sun, 29 Aug 2021 12:08:22 +0200
Subject: ospf: T3236: add possibility to redistribute "table"

Add new CLI command:
* "set protocols ospf redistribute table <n>"
---
 data/templates/frr/ospfd.frr.tmpl                       | 10 ++++++++--
 interface-definitions/include/ospf/metric-type.xml.i    |  2 +-
 .../include/ospf/protocol-common-config.xml.i           | 17 +++++++++++++++++
 src/conf_mode/protocols_ospf.py                         | 14 +++++++++++++-
 4 files changed, 39 insertions(+), 4 deletions(-)

(limited to 'interface-definitions/include/ospf')

diff --git a/data/templates/frr/ospfd.frr.tmpl b/data/templates/frr/ospfd.frr.tmpl
index be39519c3..90a6bbd56 100644
--- a/data/templates/frr/ospfd.frr.tmpl
+++ b/data/templates/frr/ospfd.frr.tmpl
@@ -172,8 +172,14 @@ router ospf {{ 'vrf ' + vrf if vrf is defined and vrf is not none }}
 {%   endfor %}
 {% endif %}
 {% if redistribute is defined and redistribute is not none %}
-{%   for protocol, options in redistribute.items() %}
- redistribute {{ protocol }} {{ 'metric ' + options.metric if options.metric is defined }} {{ 'metric-type ' + options.metric_type if options.metric_type is defined }} {{ 'route-map ' + options.route_map if options.route_map is defined }}
+{%   for protocol, protocols_options in redistribute.items() %}
+{%     if protocol == 'table' %}
+{%       for table, table_options in protocols_options.items() %}
+ redistribute {{ protocol }} {{ table }} {{ 'metric ' + table_options.metric if table_options.metric is defined }} {{ 'metric-type ' + table_options.metric_type if table_options.metric_type is defined }} {{ 'route-map ' + table_options.route_map if table_options.route_map is defined }}
+{%       endfor %}
+{%     else %}
+ redistribute {{ protocol }} {{ 'metric ' + protocols_options.metric if protocols_options.metric is defined }} {{ 'metric-type ' + protocols_options.metric_type if protocols_options.metric_type is defined }} {{ 'route-map ' + protocols_options.route_map if protocols_options.route_map is defined }}
+{%     endif %}
 {%   endfor %}
 {% endif %}
 {% if refresh is defined and refresh.timers is defined and refresh.timers is not none %}
diff --git a/interface-definitions/include/ospf/metric-type.xml.i b/interface-definitions/include/ospf/metric-type.xml.i
index 83dc24909..ef9fd8ac0 100644
--- a/interface-definitions/include/ospf/metric-type.xml.i
+++ b/interface-definitions/include/ospf/metric-type.xml.i
@@ -4,7 +4,7 @@
     <help>OSPF metric type for default routes (default: 2)</help>
     <valueHelp>
       <format>u32:1-2</format>
-      <description>Metric type for default routes</description>
+      <description>Set OSPF External Type 1/2 metrics</description>
     </valueHelp>
     <constraint>
       <validator name="numeric" argument="--range 1-2"/>
diff --git a/interface-definitions/include/ospf/protocol-common-config.xml.i b/interface-definitions/include/ospf/protocol-common-config.xml.i
index 546516a80..d8556ebf5 100644
--- a/interface-definitions/include/ospf/protocol-common-config.xml.i
+++ b/interface-definitions/include/ospf/protocol-common-config.xml.i
@@ -693,6 +693,23 @@
         #include <include/route-map.xml.i>
       </children>
     </node>
+    <tagNode name="table">
+      <properties>
+        <help>Redistribute non-main Kernel Routing Table</help>
+        <completionHelp>
+          <path>protocols static table</path>
+        </completionHelp>
+        <valueHelp>
+          <format>u32:1-200</format>
+          <description>Policy route table number</description>
+        </valueHelp>
+      </properties>
+      <children>
+        #include <include/ospf/metric.xml.i>
+        #include <include/ospf/metric-type.xml.i>
+        #include <include/route-map.xml.i>
+      </children>
+    </tagNode>
   </children>
 </node>
 <node name="refresh">
diff --git a/src/conf_mode/protocols_ospf.py b/src/conf_mode/protocols_ospf.py
index 06a29106d..92532fcb5 100755
--- a/src/conf_mode/protocols_ospf.py
+++ b/src/conf_mode/protocols_ospf.py
@@ -87,7 +87,13 @@ def get_config(config=None):
         del default_values['area']['area_type']['nssa']
     if 'mpls_te' not in ospf:
         del default_values['mpls_te']
-    for protocol in ['bgp', 'connected', 'isis', 'kernel', 'rip', 'static']:
+
+    for protocol in ['bgp', 'connected', 'isis', 'kernel', 'rip', 'static', 'table']:
+        # table is a tagNode thus we need to clean out all occurances for the
+        # default values and load them in later individually
+        if protocol == 'table':
+            del default_values['redistribute']['table']
+            continue
         if dict_search(f'redistribute.{protocol}', ospf) is None:
             del default_values['redistribute'][protocol]
 
@@ -127,6 +133,12 @@ def get_config(config=None):
             ospf['interface'][interface] = dict_merge(default_values,
                 ospf['interface'][interface])
 
+    if 'redistribute' in ospf and 'table' in ospf['redistribute']:
+        default_values = defaults(base + ['redistribute', 'table'])
+        for table in ospf['redistribute']['table']:
+            ospf['redistribute']['table'][table] = dict_merge(default_values,
+                ospf['redistribute']['table'][table])
+
     # We also need some additional information from the config, prefix-lists
     # and route-maps for instance. They will be used in verify().
     #
-- 
cgit v1.2.3


From 7a5edd23864f5eb4d8c40e4e35212d88796656e1 Mon Sep 17 00:00:00 2001
From: Christian Poessinger <christian@poessinger.com>
Date: Tue, 21 Sep 2021 08:17:25 +0200
Subject: xml: ospf: fix routing-passive-interface-xml.i include

Commit a8b2e52148d ("xml: Update routing-passive-interface-xml.i file extension
to standard .xml.i") only altered the RIP include statement but did not alter
the OSPF include.
---
 interface-definitions/include/ospf/protocol-common-config.xml.i | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'interface-definitions/include/ospf')

diff --git a/interface-definitions/include/ospf/protocol-common-config.xml.i b/interface-definitions/include/ospf/protocol-common-config.xml.i
index d8556ebf5..0139296ec 100644
--- a/interface-definitions/include/ospf/protocol-common-config.xml.i
+++ b/interface-definitions/include/ospf/protocol-common-config.xml.i
@@ -606,7 +606,7 @@
     #include <include/router-id.xml.i>
   </children>
 </node>
-#include <include/routing-passive-interface-xml.i>
+#include <include/routing-passive-interface.xml.i>
 <leafNode name="passive-interface-exclude">
   <properties>
     <help>Interface to exclude when using 'passive-interface default'</help>
-- 
cgit v1.2.3


From 289a495c8f45322d58bd849aa8aca48cf0210b03 Mon Sep 17 00:00:00 2001
From: Christian Poessinger <christian@poessinger.com>
Date: Sun, 26 Sep 2021 11:08:57 +0200
Subject: ospfv3: T3859: add "log-adjacency-changes" CLI command

---
 data/templates/frr/ospf6d.frr.tmpl                        |  3 +++
 .../include/ospf/log-adjacency-changes.xml.i              | 15 +++++++++++++++
 .../include/ospf/protocol-common-config.xml.i             | 14 +-------------
 interface-definitions/protocols-ospfv3.xml.in             |  1 +
 4 files changed, 20 insertions(+), 13 deletions(-)
 create mode 100644 interface-definitions/include/ospf/log-adjacency-changes.xml.i

(limited to 'interface-definitions/include/ospf')

diff --git a/data/templates/frr/ospf6d.frr.tmpl b/data/templates/frr/ospf6d.frr.tmpl
index 0026c0d2c..a8c53738f 100644
--- a/data/templates/frr/ospf6d.frr.tmpl
+++ b/data/templates/frr/ospf6d.frr.tmpl
@@ -76,6 +76,9 @@ router ospf6
  distance ospf6 {{ 'intra-area ' + distance.ospfv3.intra_area if distance.ospfv3.intra_area is defined }} {{ 'inter-area ' + distance.ospfv3.inter_area if distance.ospfv3.inter_area is defined }} {{ 'external ' + distance.ospfv3.external if distance.ospfv3.external is defined }}
 {%   endif %}
 {% endif %}
+{% if log_adjacency_changes is defined %}
+ log-adjacency-changes {{ "detail" if log_adjacency_changes.detail is defined }}
+{% endif %}
 {% if parameters is defined and parameters is not none %}
 {%   if parameters.router_id is defined and parameters.router_id is not none %}
  ospf6 router-id {{ parameters.router_id }}
diff --git a/interface-definitions/include/ospf/log-adjacency-changes.xml.i b/interface-definitions/include/ospf/log-adjacency-changes.xml.i
new file mode 100644
index 000000000..24c6cbe7a
--- /dev/null
+++ b/interface-definitions/include/ospf/log-adjacency-changes.xml.i
@@ -0,0 +1,15 @@
+<!-- include start from ospf/metric-type.xml.i -->
+<node name="log-adjacency-changes">
+  <properties>
+    <help>Log adjacency state changes</help>
+  </properties>
+  <children>
+    <leafNode name="detail">
+      <properties>
+        <help>Log all state changes</help>
+        <valueless/>
+      </properties>
+    </leafNode>
+  </children>
+</node>
+<!-- include end -->
diff --git a/interface-definitions/include/ospf/protocol-common-config.xml.i b/interface-definitions/include/ospf/protocol-common-config.xml.i
index 0139296ec..80931ac15 100644
--- a/interface-definitions/include/ospf/protocol-common-config.xml.i
+++ b/interface-definitions/include/ospf/protocol-common-config.xml.i
@@ -435,19 +435,7 @@
     </leafNode>
   </children>
 </tagNode>
-<node name="log-adjacency-changes">
-  <properties>
-    <help>Log adjacency state changes</help>
-  </properties>
-  <children>
-    <leafNode name="detail">
-      <properties>
-        <help>Log all state changes</help>
-        <valueless/>
-      </properties>
-    </leafNode>
-  </children>
-</node>
+#include <include/ospf/log-adjacency-changes.xml.i>
 <node name="max-metric">
   <properties>
     <help>OSPF maximum and infinite-distance metric</help>
diff --git a/interface-definitions/protocols-ospfv3.xml.in b/interface-definitions/protocols-ospfv3.xml.in
index 7b42c448d..99cfec661 100644
--- a/interface-definitions/protocols-ospfv3.xml.in
+++ b/interface-definitions/protocols-ospfv3.xml.in
@@ -186,6 +186,7 @@
               #include <include/isis/passive.xml.i>
             </children>
           </tagNode>
+          #include <include/ospf/log-adjacency-changes.xml.i>
           <node name="parameters">
             <properties>
               <help>OSPFv3 specific parameters</help>
-- 
cgit v1.2.3


From 3bc79ff3cb40eeb36a33de7112d558abb96cb22f Mon Sep 17 00:00:00 2001
From: Christian Poessinger <christian@poessinger.com>
Date: Sun, 26 Sep 2021 13:08:37 +0200
Subject: ospf: T3757: add completion help when refering to area ID

This extends commit 6f87d8c910 ("ospf: T3757: support to configure area at an
interface level") with a completion helper to show which Area ID is already in
use when configuring the area for an interface.
---
 interface-definitions/include/ospf/protocol-common-config.xml.i | 3 +++
 1 file changed, 3 insertions(+)

(limited to 'interface-definitions/include/ospf')

diff --git a/interface-definitions/include/ospf/protocol-common-config.xml.i b/interface-definitions/include/ospf/protocol-common-config.xml.i
index 80931ac15..982e519a9 100644
--- a/interface-definitions/include/ospf/protocol-common-config.xml.i
+++ b/interface-definitions/include/ospf/protocol-common-config.xml.i
@@ -364,6 +364,9 @@
     <leafNode name="area">
       <properties>
         <help>Enable OSPF on this interface</help>
+        <completionHelp>
+          <path>protocols ospf area</path>
+        </completionHelp>
         <valueHelp>
           <format>u32</format>
           <description>OSPF area ID as decimal notation</description>
-- 
cgit v1.2.3