From 0693b0daabb6c63d370eeda0bb939c418e13885b Mon Sep 17 00:00:00 2001 From: Chirag Shah Date: Thu, 5 Dec 2019 20:47:01 -0800 Subject: [PATCH 01/32] yang: add vrf model module: frr-vrf +--rw lib +--rw vrf* [name] +--rw name string +--ro id? uint32 +--ro active? boolean +--rw netns {netns}? +--rw name? string Signed-off-by: Chirag Shah --- yang/frr-vrf.yang | 75 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 yang/frr-vrf.yang diff --git a/yang/frr-vrf.yang b/yang/frr-vrf.yang new file mode 100644 index 000000000000..40ead7e79c61 --- /dev/null +++ b/yang/frr-vrf.yang @@ -0,0 +1,75 @@ +module frr-vrf { + yang-version 1.1; + namespace "http://frrouting.org/yang/vrf"; + prefix frr-vrf; + + organization + "Free Range Routing"; + contact + "FRR Users List: + FRR Development List: "; + description + "This module defines a model for managing FRR VRF."; + + revision 2019-12-06 { + description + "Initial revision."; + } + + /* + * Network namespace feature + */ + feature netns { + description "Abstracts network namespace as VRF."; + } + + container lib { + list vrf { + key "name"; + description + "VRF."; + leaf name { + type string { + length "1..36"; + } + description + "VRF name."; + } + + leaf id { + type uint32 { + range "0..4294967295"; + } + config false; + description + "VRF Id."; + } + + leaf active { + type boolean; + default "false"; + config false; + description + "VRF active in kernel."; + } + + container netns { + if-feature "netns"; + leaf name { + type string; + description + "Namespace name."; + } + } + } + } + + typedef vrf-ref { + type leafref { + require-instance false; + path "/frr-vrf:lib/frr-vrf:vrf/frr-vrf:name"; + } + description + "Reference to a VRF"; + } +} From e095f16bdfb8935f2a2687dcf0019e2ccce25ee2 Mon Sep 17 00:00:00 2001 From: Chirag Shah Date: Sun, 8 Dec 2019 18:18:04 -0800 Subject: [PATCH 02/32] *: add frr-vrf yang module in makefile lib: Adding frr-vrf yang module to common place so it can be accessed from all frr modules. Signed-off-by: Chirag Shah --- lib/subdir.am | 1 + yang/subdir.am | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/subdir.am b/lib/subdir.am index 23b1950384ac..ae5f674860ec 100644 --- a/lib/subdir.am +++ b/lib/subdir.am @@ -104,6 +104,7 @@ lib_libfrr_la_SOURCES = \ nodist_lib_libfrr_la_SOURCES = \ yang/frr-interface.yang.c \ yang/frr-route-types.yang.c \ + yang/frr-vrf.yang.c \ yang/ietf/ietf-routing-types.yang.c \ yang/frr-module-translator.yang.c \ # end diff --git a/yang/subdir.am b/yang/subdir.am index b69239560ffe..6036d298bc9a 100644 --- a/yang/subdir.am +++ b/yang/subdir.am @@ -22,6 +22,7 @@ EXTRA_DIST += yang/embedmodel.py dist_yangmodels_DATA += yang/frr-module-translator.yang dist_yangmodels_DATA += yang/frr-test-module.yang dist_yangmodels_DATA += yang/frr-interface.yang +dist_yangmodels_DATA += yang/frr-vrf.yang dist_yangmodels_DATA += yang/frr-route-types.yang dist_yangmodels_DATA += yang/ietf/ietf-routing-types.yang From cf9325048f5860534d6939481be0edee0b36ef75 Mon Sep 17 00:00:00 2001 From: Chirag Shah Date: Thu, 5 Dec 2019 20:47:01 -0800 Subject: [PATCH 03/32] yang: add vrf model module: frr-vrf +--rw lib +--rw vrf* [name] +--rw name string +--ro id? uint32 +--ro active? boolean +--rw netns {netns}? +--rw name? string Signed-off-by: Chirag Shah --- yang/frr-vrf.yang | 75 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 yang/frr-vrf.yang diff --git a/yang/frr-vrf.yang b/yang/frr-vrf.yang new file mode 100644 index 000000000000..40ead7e79c61 --- /dev/null +++ b/yang/frr-vrf.yang @@ -0,0 +1,75 @@ +module frr-vrf { + yang-version 1.1; + namespace "http://frrouting.org/yang/vrf"; + prefix frr-vrf; + + organization + "Free Range Routing"; + contact + "FRR Users List: + FRR Development List: "; + description + "This module defines a model for managing FRR VRF."; + + revision 2019-12-06 { + description + "Initial revision."; + } + + /* + * Network namespace feature + */ + feature netns { + description "Abstracts network namespace as VRF."; + } + + container lib { + list vrf { + key "name"; + description + "VRF."; + leaf name { + type string { + length "1..36"; + } + description + "VRF name."; + } + + leaf id { + type uint32 { + range "0..4294967295"; + } + config false; + description + "VRF Id."; + } + + leaf active { + type boolean; + default "false"; + config false; + description + "VRF active in kernel."; + } + + container netns { + if-feature "netns"; + leaf name { + type string; + description + "Namespace name."; + } + } + } + } + + typedef vrf-ref { + type leafref { + require-instance false; + path "/frr-vrf:lib/frr-vrf:vrf/frr-vrf:name"; + } + description + "Reference to a VRF"; + } +} From 245daf032e21ca2c840c20c308c103e44192d33f Mon Sep 17 00:00:00 2001 From: Chirag Shah Date: Sun, 8 Dec 2019 18:18:04 -0800 Subject: [PATCH 04/32] *: add frr-vrf yang module in makefile lib: Adding frr-vrf yang module to common place so it can be accessed from all frr modules. Signed-off-by: Chirag Shah --- lib/subdir.am | 1 + yang/subdir.am | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/subdir.am b/lib/subdir.am index cb6fa7a3b81c..9bd7c60710f3 100644 --- a/lib/subdir.am +++ b/lib/subdir.am @@ -105,6 +105,7 @@ lib_libfrr_la_SOURCES = \ nodist_lib_libfrr_la_SOURCES = \ yang/frr-interface.yang.c \ yang/frr-route-types.yang.c \ + yang/frr-vrf.yang.c \ yang/ietf/ietf-routing-types.yang.c \ yang/frr-module-translator.yang.c \ # end diff --git a/yang/subdir.am b/yang/subdir.am index cfaf1a640179..184f7f7f7aaf 100644 --- a/yang/subdir.am +++ b/yang/subdir.am @@ -22,6 +22,7 @@ EXTRA_DIST += yang/embedmodel.py dist_yangmodels_DATA += yang/frr-module-translator.yang dist_yangmodels_DATA += yang/frr-test-module.yang dist_yangmodels_DATA += yang/frr-interface.yang +dist_yangmodels_DATA += yang/frr-vrf.yang dist_yangmodels_DATA += yang/frr-route-types.yang dist_yangmodels_DATA += yang/ietf/ietf-routing-types.yang From 87ee53fc9f01d1761739b6ff6681eb307b7b9072 Mon Sep 17 00:00:00 2001 From: Chirag Shah Date: Mon, 3 Feb 2020 13:31:32 -0800 Subject: [PATCH 05/32] yang: add vrf ref to interface model module: frr-interface +--rw lib +--rw interface* [name vrf] +--rw name string +--rw vrf frr-vrf:vrf-ref +--rw description? string Signed-off-by: Chirag Shah --- yang/frr-interface.yang | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/yang/frr-interface.yang b/yang/frr-interface.yang index 4f7f3beebd9a..c7031ed41d33 100644 --- a/yang/frr-interface.yang +++ b/yang/frr-interface.yang @@ -3,6 +3,10 @@ module frr-interface { namespace "http://frrouting.org/yang/interface"; prefix frr-interface; + import frr-vrf { + prefix frr-vrf; + } + organization "Free Range Routing"; contact @@ -25,7 +29,6 @@ module frr-interface { key "name vrf"; description "Interface."; - leaf name { type string { length "1..16"; @@ -33,13 +36,13 @@ module frr-interface { description "Interface name."; } + leaf vrf { - type string { - length "1..36"; - } + type frr-vrf:vrf-ref; description "VRF this interface is associated with."; } + leaf description { type string; description From 95f180450f9221cb653940c556b6511fe80c075e Mon Sep 17 00:00:00 2001 From: vdhingra Date: Tue, 3 Dec 2019 06:00:51 -0800 Subject: [PATCH 06/32] staticd: yang defination Yang files for staticd to use northbound APIs Co-authored-by: Santosh P K Co-authored-by: vishaldhingra Signed-off-by: vishaldhingra --- yang/frr-staticd.yang | 86 +++++++++++++++++++++++++++++++++++++++++++ yang/subdir.am | 4 ++ 2 files changed, 90 insertions(+) create mode 100644 yang/frr-staticd.yang diff --git a/yang/frr-staticd.yang b/yang/frr-staticd.yang new file mode 100644 index 000000000000..58933c904083 --- /dev/null +++ b/yang/frr-staticd.yang @@ -0,0 +1,86 @@ +module frr-staticd { + yang-version "1.1"; + namespace "http://frrouting.org/yang/staticd"; + + prefix frr-staticd; + + import frr-routing { + prefix "frr-rt"; + } + + import frr-nexthop { + prefix frr-nexthop; + } + + import ietf-inet-types { + prefix inet; + } + + organization + "Free Range Routing"; + + contact + "FRR Users List: + FRR Development List: "; + + description + "This module defines a model for managing FRR staticd information. + This YANG module augments the ietf-routing with additional + nexthop information"; + + revision 2019-12-03 { + description + "Initial revision."; + } + + identity static { + base frr-rt:routing-protocol; + description + "'Static' routing pseudo-protocol."; + } + + augment "/frr-rt:routing/frr-rt:control-plane-protocols/" + + "frr-rt:control-plane-protocol" { + container staticd { + when "../frr-rt:type = 'frr-staticd:static'" { + description + "This container is only valid for the 'static' routing + protocol."; + } + description + "Support for a 'static' pseudo-protocol instance + consists of a list of routes."; + + list prefix-list { + key "destination-prefix"; + description + "List of static IP routes."; + + leaf destination-prefix { + type inet:ip-address; + description + "IP destination prefix."; + } + + leaf distance { + type frr-rt:administrative-distance; + description + "Admin distance associated with this route."; + } + + leaf tag { + type uint32 { + range "1..4294967295"; + } + description + "Route tag"; + } + container frr-staticd-next-hop { + description + "Augment static route configuration 'nexthop-list'."; + uses frr-nexthop:frr-nexthop; + } + } + } + } +} diff --git a/yang/subdir.am b/yang/subdir.am index 184f7f7f7aaf..22525a40a455 100644 --- a/yang/subdir.am +++ b/yang/subdir.am @@ -49,3 +49,7 @@ endif if VRRPD dist_yangmodels_DATA += yang/frr-vrrpd.yang endif + +if STATICD +dist_yangmodels_DATA += yang/frr-staticd.yang +endif From f5319ffcff728589a7d32c5546e8ea4a478481eb Mon Sep 17 00:00:00 2001 From: vdhingra Date: Tue, 10 Dec 2019 21:57:37 -0800 Subject: [PATCH 07/32] lib: yang defination for basic frr-routing Yang files for basic frr-routing used by other daemons like staticd and pim Co-authored-by: Santosh P K Co-authored-by: vishaldhingra Signed-off-by: vishaldhingra --- lib/subdir.am | 1 + yang/frr-routing.yang | 135 ++++++++++++++++++++++++++++++++++++++++++ yang/subdir.am | 1 + 3 files changed, 137 insertions(+) create mode 100644 yang/frr-routing.yang diff --git a/lib/subdir.am b/lib/subdir.am index 9bd7c60710f3..689192a299e4 100644 --- a/lib/subdir.am +++ b/lib/subdir.am @@ -106,6 +106,7 @@ nodist_lib_libfrr_la_SOURCES = \ yang/frr-interface.yang.c \ yang/frr-route-types.yang.c \ yang/frr-vrf.yang.c \ + yang/frr-routing.yang.c \ yang/ietf/ietf-routing-types.yang.c \ yang/frr-module-translator.yang.c \ # end diff --git a/yang/frr-routing.yang b/yang/frr-routing.yang new file mode 100644 index 000000000000..615a81c72240 --- /dev/null +++ b/yang/frr-routing.yang @@ -0,0 +1,135 @@ +module frr-routing { + yang-version "1.1"; + namespace "http://frrouting.org/yang/routing"; + prefix "rt"; + + import ietf-yang-types { + prefix "yang"; + } + + import frr-vrf { + prefix frr-vrf; + } + + organization + "Free Range Routing"; + + contact + "FRR Users List: + FRR Development List: "; + + description + "This YANG module defines essential components for the management + of a routing subsystem."; + + revision 2019-08-15 { + description + "Initial revision."; + } + + /* Identities */ + + identity address-family { + description + "Base identity from which identities describing address + families are derived."; + } + + identity ipv4 { + base address-family; + description + "This identity represents an IPv4 address family."; + } + + identity ipv6 { + base address-family; + description + "This identity represents an IPv6 address family."; + } + + identity control-plane-protocol { + description + "Base identity from which control-plane protocol identities are + derived."; + } + + identity routing-protocol { + base control-plane-protocol; + description + "Identity from which Layer 3 routing protocol identities are + derived."; + } + + /* Type Definitions */ + + typedef administrative-distance { + type uint8 { + range "1..255"; + } + description + "Admin distance associated with the route."; + } + + /* Groupings */ + + grouping address-family { + description + "This grouping provides a leaf identifying an address + family."; + leaf address-family { + type identityref { + base address-family; + } + mandatory true; + description + "Address family."; + } + } + + grouping router-id { + description + "This grouping provides a router ID."; + leaf router-id { + type yang:dotted-quad; + description + "A 32-bit number in the form of a dotted quad that is used by + some routing protocols identifying a router."; + reference + "RFC 2328: OSPF Version 2"; + } + } + + /* Data nodes */ + + container routing { + description + "Configuration parameters for the routing subsystem."; + container control-plane-protocols { + description + "Support for control-plane protocol instances."; + list control-plane-protocol { + key "type name vrf"; + description + "Each entry contains a control-plane protocol instance."; + leaf type { + type identityref { + base control-plane-protocol; + } + description + "Type of the control-plane protocol"; + } + leaf name { + type string; + description + "An arbitrary name of the control-plane protocol + instance."; + } + leaf vrf { + type frr-vrf:vrf-ref; + description + "vrf for control-plane protocol"; + } + } + } + } +} diff --git a/yang/subdir.am b/yang/subdir.am index 184f7f7f7aaf..b248e169bf07 100644 --- a/yang/subdir.am +++ b/yang/subdir.am @@ -24,6 +24,7 @@ dist_yangmodels_DATA += yang/frr-test-module.yang dist_yangmodels_DATA += yang/frr-interface.yang dist_yangmodels_DATA += yang/frr-vrf.yang dist_yangmodels_DATA += yang/frr-route-types.yang +dist_yangmodels_DATA += yang/frr-routing.yang dist_yangmodels_DATA += yang/ietf/ietf-routing-types.yang if BFDD From a530bfe112725a4a0405691984082e4a271bf557 Mon Sep 17 00:00:00 2001 From: Santosh P K Date: Fri, 20 Dec 2019 00:30:57 -0800 Subject: [PATCH 08/32] lib: FRR next-hop yang data model. A common nexthop and group nexthop yang data model for all protocols in FRR. Co-authored-by: Santosh P K Co-authored-by: Vishaldhingra Signed-off-by: Santosh P K --- yang/frr-nexthop.yang | 150 ++++++++++++++++++++++++++---------------- 1 file changed, 93 insertions(+), 57 deletions(-) diff --git a/yang/frr-nexthop.yang b/yang/frr-nexthop.yang index 7d8ce1b8ed14..248dd56d937e 100644 --- a/yang/frr-nexthop.yang +++ b/yang/frr-nexthop.yang @@ -10,10 +10,15 @@ module frr-nexthop { import ietf-routing-types { prefix rt-types; } + import frr-interface { prefix frr-interface; } + import frr-vrf { + prefix "frr-vrf"; + } + organization "Free Range Routing"; contact @@ -27,10 +32,19 @@ module frr-nexthop { "Initial revision."; } - typedef gateway-address { - type inet:ip-address; + typedef optional-ip-address { + type union { + type inet:ip-address; + type string { + pattern + ''; + } + } } + /* + * Nexthop types. + */ typedef nexthop-type { type enumeration { enum "ifindex" { @@ -68,6 +82,9 @@ module frr-nexthop { "Nexthop types."; } + /* + * Blockhole nexthop type. + */ typedef blackhole-type { type enumeration { enum "unspec" { @@ -97,113 +114,132 @@ module frr-nexthop { } /* - * Nexthop object + * Common nexthop attributes grouping. */ - - grouping frr-nexthop { + grouping frr-nexthop-attributes { leaf nh-type { type nexthop-type; mandatory true; description "The nexthop type."; } - - leaf gateway { - type gateway-address; - description - "The nexthop gateway address."; - } - leaf vrf { - type string { - length "1..36"; - } + type frr-vrf:vrf-ref; description "The nexthop vrf name, if different from the route."; } - + leaf gateway { + type frr-nexthop:optional-ip-address; + description + "The nexthop gateway address."; + } leaf interface { type frr-interface:interface-ref; description "The nexthop egress interface."; } - leaf bh-type { + when "../nh-type = 'blackhole'"; type blackhole-type; description "A blackhole sub-type, if the nexthop is a blackhole type."; } - - leaf flags { - type uint32; + leaf onlink { + when "../nh-type = 'ip4-ifindex' or + ../nh-type = 'ip6-ifindex'"; + type boolean; + default false; description - "The nexthop's raw flags value."; + "Nexthop is directly connected."; } - - leaf is-duplicate { - type empty; + uses rt-types:mpls-label-stack { description - "Duplicate nexthop; will be ignored."; + "Nexthop's MPLS label stack."; } + } - leaf is-recursive { + /* + * operational common attributes for nexthop + */ + grouping frr-nexthop-operational { + leaf duplicate { + config false; type empty; description - "Nexthop must be resolved through another gateway."; + "Duplicate nexthop"; } - - leaf is-onlink { + leaf recursive { + config false; type empty; description - "Nexthop is directly connected."; + "Nexthop resolved through another gateway."; } - - leaf is-active { + leaf active { + config false; type empty; description "Nexthop is active."; } - - uses rt-types:mpls-label-stack { + leaf fib { + config false; + type empty; description - "Nexthop's MPLS label stack."; + "Nexthop is installed in fib."; } + } - leaf mtu { - type uint32; + /* + * Single nexthop grouping. + */ + grouping frr-nexthop { + container frr-nexthops { description - "The nexthop's specific MTU."; + "FRR nexthop object."; + list nexthop { + key "nh-type gateway interface"; + description + "A list of nexthop objects."; + + uses frr-nexthop-attributes; + } } } - // End of nexthop + /* - * Nexthop-group container + * Container for FRR nexthop group. */ - - grouping frr-nexthop-group { - description - "A nexthop-group, represented as a list of nexthop objects."; - leaf name { - type string; + grouping frr-nexthop-grouping { + list nexthop-group { + key "name"; description - "The nexthop-group name."; - } + "A group of nexthops."; - list entry { - key "id"; - description - "A list of nexthop objects."; - leaf id { - type uint32; + leaf name { + type string; description - "Identifies a nexthop within a nexthop group; the entries - are ordered by id value, and the value has no other meaning."; + "The nexthop-group name."; } uses frr-nexthop; } } - // End of frr-nexthop-group + container frr-nexthop-group { + description + "A nexthop-group, represented as a list of nexthop objects."; + + uses frr-nexthop-grouping; + } + + /* + * Agument weight attributes to nexthop group. + */ + augment "/frr-nexthop-group/nexthop-group/frr-nexthops/nexthop" { + leaf weight { + type uint8; + description + "Weight to be used by the nexthop for purposes of ECMP"; + } + } } From 6514ce84e50d7ce35c773bb4fd0bbf9c87c47dc5 Mon Sep 17 00:00:00 2001 From: Chirag Shah Date: Thu, 5 Dec 2019 20:47:01 -0800 Subject: [PATCH 09/32] yang: add vrf model module: frr-vrf +--rw lib +--rw vrf* [name] +--rw name string +--ro id? uint32 +--ro active? boolean +--rw netns {netns}? +--rw name? string Signed-off-by: Chirag Shah --- yang/frr-vrf.yang | 75 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 yang/frr-vrf.yang diff --git a/yang/frr-vrf.yang b/yang/frr-vrf.yang new file mode 100644 index 000000000000..40ead7e79c61 --- /dev/null +++ b/yang/frr-vrf.yang @@ -0,0 +1,75 @@ +module frr-vrf { + yang-version 1.1; + namespace "http://frrouting.org/yang/vrf"; + prefix frr-vrf; + + organization + "Free Range Routing"; + contact + "FRR Users List: + FRR Development List: "; + description + "This module defines a model for managing FRR VRF."; + + revision 2019-12-06 { + description + "Initial revision."; + } + + /* + * Network namespace feature + */ + feature netns { + description "Abstracts network namespace as VRF."; + } + + container lib { + list vrf { + key "name"; + description + "VRF."; + leaf name { + type string { + length "1..36"; + } + description + "VRF name."; + } + + leaf id { + type uint32 { + range "0..4294967295"; + } + config false; + description + "VRF Id."; + } + + leaf active { + type boolean; + default "false"; + config false; + description + "VRF active in kernel."; + } + + container netns { + if-feature "netns"; + leaf name { + type string; + description + "Namespace name."; + } + } + } + } + + typedef vrf-ref { + type leafref { + require-instance false; + path "/frr-vrf:lib/frr-vrf:vrf/frr-vrf:name"; + } + description + "Reference to a VRF"; + } +} From 5b15a51284d59d7d701faf0106d110426c51d133 Mon Sep 17 00:00:00 2001 From: Santosh P K Date: Thu, 20 Feb 2020 02:22:49 -0800 Subject: [PATCH 10/32] *: add frr-vrf yang module in makefile lib: Adding frr-vrf yang module to common place so it can be accessed from all frr modules. Signed-off-by: Chirag Shah --- lib/subdir.am | 1 + yang/subdir.am | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/subdir.am b/lib/subdir.am index 4f62eb226413..23aa637268fa 100644 --- a/lib/subdir.am +++ b/lib/subdir.am @@ -110,6 +110,7 @@ nodist_lib_libfrr_la_SOURCES = \ yang/frr-interface.yang.c \ yang/frr-route-map.yang.c \ yang/frr-route-types.yang.c \ + yang/frr-vrf.yang.c \ yang/ietf/ietf-routing-types.yang.c \ yang/frr-module-translator.yang.c \ # end diff --git a/yang/subdir.am b/yang/subdir.am index c1297dafd560..a7af431e9df7 100644 --- a/yang/subdir.am +++ b/yang/subdir.am @@ -24,6 +24,7 @@ dist_yangmodels_DATA += yang/frr-module-translator.yang dist_yangmodels_DATA += yang/frr-test-module.yang dist_yangmodels_DATA += yang/frr-interface.yang dist_yangmodels_DATA += yang/frr-route-map.yang +dist_yangmodels_DATA += yang/frr-vrf.yang dist_yangmodels_DATA += yang/frr-route-types.yang dist_yangmodels_DATA += yang/ietf/ietf-routing-types.yang From ee8ac97b603be47b23819e5adb252d864f2b5c58 Mon Sep 17 00:00:00 2001 From: Chirag Shah Date: Mon, 3 Feb 2020 13:31:32 -0800 Subject: [PATCH 11/32] yang: add vrf ref to interface model module: frr-interface +--rw lib +--rw interface* [name vrf] +--rw name string +--rw vrf frr-vrf:vrf-ref +--rw description? string Signed-off-by: Chirag Shah --- yang/frr-interface.yang | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/yang/frr-interface.yang b/yang/frr-interface.yang index 4f7f3beebd9a..c7031ed41d33 100644 --- a/yang/frr-interface.yang +++ b/yang/frr-interface.yang @@ -3,6 +3,10 @@ module frr-interface { namespace "http://frrouting.org/yang/interface"; prefix frr-interface; + import frr-vrf { + prefix frr-vrf; + } + organization "Free Range Routing"; contact @@ -25,7 +29,6 @@ module frr-interface { key "name vrf"; description "Interface."; - leaf name { type string { length "1..16"; @@ -33,13 +36,13 @@ module frr-interface { description "Interface name."; } + leaf vrf { - type string { - length "1..36"; - } + type frr-vrf:vrf-ref; description "VRF this interface is associated with."; } + leaf description { type string; description From 97928ec988d3ad42b0ea72134d46c34662af17c1 Mon Sep 17 00:00:00 2001 From: Santosh P K Date: Fri, 20 Dec 2019 00:30:57 -0800 Subject: [PATCH 12/32] lib: FRR next-hop yang data model. A common nexthop and group nexthop yang data model for all protocols in FRR. Co-authored-by: Santosh P K Co-authored-by: Vishaldhingra Signed-off-by: Santosh P K --- yang/frr-nexthop.yang | 150 ++++++++++++++++++++++++++---------------- 1 file changed, 93 insertions(+), 57 deletions(-) diff --git a/yang/frr-nexthop.yang b/yang/frr-nexthop.yang index 7d8ce1b8ed14..248dd56d937e 100644 --- a/yang/frr-nexthop.yang +++ b/yang/frr-nexthop.yang @@ -10,10 +10,15 @@ module frr-nexthop { import ietf-routing-types { prefix rt-types; } + import frr-interface { prefix frr-interface; } + import frr-vrf { + prefix "frr-vrf"; + } + organization "Free Range Routing"; contact @@ -27,10 +32,19 @@ module frr-nexthop { "Initial revision."; } - typedef gateway-address { - type inet:ip-address; + typedef optional-ip-address { + type union { + type inet:ip-address; + type string { + pattern + ''; + } + } } + /* + * Nexthop types. + */ typedef nexthop-type { type enumeration { enum "ifindex" { @@ -68,6 +82,9 @@ module frr-nexthop { "Nexthop types."; } + /* + * Blockhole nexthop type. + */ typedef blackhole-type { type enumeration { enum "unspec" { @@ -97,113 +114,132 @@ module frr-nexthop { } /* - * Nexthop object + * Common nexthop attributes grouping. */ - - grouping frr-nexthop { + grouping frr-nexthop-attributes { leaf nh-type { type nexthop-type; mandatory true; description "The nexthop type."; } - - leaf gateway { - type gateway-address; - description - "The nexthop gateway address."; - } - leaf vrf { - type string { - length "1..36"; - } + type frr-vrf:vrf-ref; description "The nexthop vrf name, if different from the route."; } - + leaf gateway { + type frr-nexthop:optional-ip-address; + description + "The nexthop gateway address."; + } leaf interface { type frr-interface:interface-ref; description "The nexthop egress interface."; } - leaf bh-type { + when "../nh-type = 'blackhole'"; type blackhole-type; description "A blackhole sub-type, if the nexthop is a blackhole type."; } - - leaf flags { - type uint32; + leaf onlink { + when "../nh-type = 'ip4-ifindex' or + ../nh-type = 'ip6-ifindex'"; + type boolean; + default false; description - "The nexthop's raw flags value."; + "Nexthop is directly connected."; } - - leaf is-duplicate { - type empty; + uses rt-types:mpls-label-stack { description - "Duplicate nexthop; will be ignored."; + "Nexthop's MPLS label stack."; } + } - leaf is-recursive { + /* + * operational common attributes for nexthop + */ + grouping frr-nexthop-operational { + leaf duplicate { + config false; type empty; description - "Nexthop must be resolved through another gateway."; + "Duplicate nexthop"; } - - leaf is-onlink { + leaf recursive { + config false; type empty; description - "Nexthop is directly connected."; + "Nexthop resolved through another gateway."; } - - leaf is-active { + leaf active { + config false; type empty; description "Nexthop is active."; } - - uses rt-types:mpls-label-stack { + leaf fib { + config false; + type empty; description - "Nexthop's MPLS label stack."; + "Nexthop is installed in fib."; } + } - leaf mtu { - type uint32; + /* + * Single nexthop grouping. + */ + grouping frr-nexthop { + container frr-nexthops { description - "The nexthop's specific MTU."; + "FRR nexthop object."; + list nexthop { + key "nh-type gateway interface"; + description + "A list of nexthop objects."; + + uses frr-nexthop-attributes; + } } } - // End of nexthop + /* - * Nexthop-group container + * Container for FRR nexthop group. */ - - grouping frr-nexthop-group { - description - "A nexthop-group, represented as a list of nexthop objects."; - leaf name { - type string; + grouping frr-nexthop-grouping { + list nexthop-group { + key "name"; description - "The nexthop-group name."; - } + "A group of nexthops."; - list entry { - key "id"; - description - "A list of nexthop objects."; - leaf id { - type uint32; + leaf name { + type string; description - "Identifies a nexthop within a nexthop group; the entries - are ordered by id value, and the value has no other meaning."; + "The nexthop-group name."; } uses frr-nexthop; } } - // End of frr-nexthop-group + container frr-nexthop-group { + description + "A nexthop-group, represented as a list of nexthop objects."; + + uses frr-nexthop-grouping; + } + + /* + * Agument weight attributes to nexthop group. + */ + augment "/frr-nexthop-group/nexthop-group/frr-nexthops/nexthop" { + leaf weight { + type uint8; + description + "Weight to be used by the nexthop for purposes of ECMP"; + } + } } From 8f8cac6a100f5a3401b4d51c62514d2c8d6bfe35 Mon Sep 17 00:00:00 2001 From: vdhingra Date: Tue, 3 Dec 2019 06:00:51 -0800 Subject: [PATCH 13/32] staticd: yang defination Yang files for staticd to use northbound APIs Co-authored-by: Santosh P K Co-authored-by: vishaldhingra Signed-off-by: vishaldhingra --- yang/frr-staticd.yang | 86 +++++++++++++++++++++++++++++++++++++++++++ yang/subdir.am | 4 ++ 2 files changed, 90 insertions(+) create mode 100644 yang/frr-staticd.yang diff --git a/yang/frr-staticd.yang b/yang/frr-staticd.yang new file mode 100644 index 000000000000..58933c904083 --- /dev/null +++ b/yang/frr-staticd.yang @@ -0,0 +1,86 @@ +module frr-staticd { + yang-version "1.1"; + namespace "http://frrouting.org/yang/staticd"; + + prefix frr-staticd; + + import frr-routing { + prefix "frr-rt"; + } + + import frr-nexthop { + prefix frr-nexthop; + } + + import ietf-inet-types { + prefix inet; + } + + organization + "Free Range Routing"; + + contact + "FRR Users List: + FRR Development List: "; + + description + "This module defines a model for managing FRR staticd information. + This YANG module augments the ietf-routing with additional + nexthop information"; + + revision 2019-12-03 { + description + "Initial revision."; + } + + identity static { + base frr-rt:routing-protocol; + description + "'Static' routing pseudo-protocol."; + } + + augment "/frr-rt:routing/frr-rt:control-plane-protocols/" + + "frr-rt:control-plane-protocol" { + container staticd { + when "../frr-rt:type = 'frr-staticd:static'" { + description + "This container is only valid for the 'static' routing + protocol."; + } + description + "Support for a 'static' pseudo-protocol instance + consists of a list of routes."; + + list prefix-list { + key "destination-prefix"; + description + "List of static IP routes."; + + leaf destination-prefix { + type inet:ip-address; + description + "IP destination prefix."; + } + + leaf distance { + type frr-rt:administrative-distance; + description + "Admin distance associated with this route."; + } + + leaf tag { + type uint32 { + range "1..4294967295"; + } + description + "Route tag"; + } + container frr-staticd-next-hop { + description + "Augment static route configuration 'nexthop-list'."; + uses frr-nexthop:frr-nexthop; + } + } + } + } +} diff --git a/yang/subdir.am b/yang/subdir.am index a7af431e9df7..9c3147e7adb5 100644 --- a/yang/subdir.am +++ b/yang/subdir.am @@ -51,3 +51,7 @@ endif if VRRPD dist_yangmodels_DATA += yang/frr-vrrpd.yang endif + +if STATICD +dist_yangmodels_DATA += yang/frr-staticd.yang +endif From 2aa6fcc7efff8840e61691d686fdb995b0a01a3b Mon Sep 17 00:00:00 2001 From: vdhingra Date: Tue, 10 Dec 2019 21:57:37 -0800 Subject: [PATCH 14/32] lib: yang defination for basic frr-routing Yang files for basic frr-routing used by other daemons like staticd and pim Co-authored-by: Santosh P K Co-authored-by: vishaldhingra Signed-off-by: vishaldhingra --- lib/subdir.am | 1 + yang/frr-routing.yang | 135 ++++++++++++++++++++++++++++++++++++++++++ yang/subdir.am | 1 + 3 files changed, 137 insertions(+) create mode 100644 yang/frr-routing.yang diff --git a/lib/subdir.am b/lib/subdir.am index 23aa637268fa..56d11c5852d1 100644 --- a/lib/subdir.am +++ b/lib/subdir.am @@ -111,6 +111,7 @@ nodist_lib_libfrr_la_SOURCES = \ yang/frr-route-map.yang.c \ yang/frr-route-types.yang.c \ yang/frr-vrf.yang.c \ + yang/frr-routing.yang.c \ yang/ietf/ietf-routing-types.yang.c \ yang/frr-module-translator.yang.c \ # end diff --git a/yang/frr-routing.yang b/yang/frr-routing.yang new file mode 100644 index 000000000000..615a81c72240 --- /dev/null +++ b/yang/frr-routing.yang @@ -0,0 +1,135 @@ +module frr-routing { + yang-version "1.1"; + namespace "http://frrouting.org/yang/routing"; + prefix "rt"; + + import ietf-yang-types { + prefix "yang"; + } + + import frr-vrf { + prefix frr-vrf; + } + + organization + "Free Range Routing"; + + contact + "FRR Users List: + FRR Development List: "; + + description + "This YANG module defines essential components for the management + of a routing subsystem."; + + revision 2019-08-15 { + description + "Initial revision."; + } + + /* Identities */ + + identity address-family { + description + "Base identity from which identities describing address + families are derived."; + } + + identity ipv4 { + base address-family; + description + "This identity represents an IPv4 address family."; + } + + identity ipv6 { + base address-family; + description + "This identity represents an IPv6 address family."; + } + + identity control-plane-protocol { + description + "Base identity from which control-plane protocol identities are + derived."; + } + + identity routing-protocol { + base control-plane-protocol; + description + "Identity from which Layer 3 routing protocol identities are + derived."; + } + + /* Type Definitions */ + + typedef administrative-distance { + type uint8 { + range "1..255"; + } + description + "Admin distance associated with the route."; + } + + /* Groupings */ + + grouping address-family { + description + "This grouping provides a leaf identifying an address + family."; + leaf address-family { + type identityref { + base address-family; + } + mandatory true; + description + "Address family."; + } + } + + grouping router-id { + description + "This grouping provides a router ID."; + leaf router-id { + type yang:dotted-quad; + description + "A 32-bit number in the form of a dotted quad that is used by + some routing protocols identifying a router."; + reference + "RFC 2328: OSPF Version 2"; + } + } + + /* Data nodes */ + + container routing { + description + "Configuration parameters for the routing subsystem."; + container control-plane-protocols { + description + "Support for control-plane protocol instances."; + list control-plane-protocol { + key "type name vrf"; + description + "Each entry contains a control-plane protocol instance."; + leaf type { + type identityref { + base control-plane-protocol; + } + description + "Type of the control-plane protocol"; + } + leaf name { + type string; + description + "An arbitrary name of the control-plane protocol + instance."; + } + leaf vrf { + type frr-vrf:vrf-ref; + description + "vrf for control-plane protocol"; + } + } + } + } +} diff --git a/yang/subdir.am b/yang/subdir.am index 9c3147e7adb5..399fa7d32e4c 100644 --- a/yang/subdir.am +++ b/yang/subdir.am @@ -26,6 +26,7 @@ dist_yangmodels_DATA += yang/frr-interface.yang dist_yangmodels_DATA += yang/frr-route-map.yang dist_yangmodels_DATA += yang/frr-vrf.yang dist_yangmodels_DATA += yang/frr-route-types.yang +dist_yangmodels_DATA += yang/frr-routing.yang dist_yangmodels_DATA += yang/ietf/ietf-routing-types.yang if BFDD From c590694916c690b9af4bfa4dba18948e8c56ebb6 Mon Sep 17 00:00:00 2001 From: Chirag Shah Date: Thu, 5 Dec 2019 20:47:01 -0800 Subject: [PATCH 15/32] yang: add vrf model module: frr-vrf +--rw lib +--rw vrf* [name] +--rw name string +--ro id? uint32 +--ro active? boolean +--rw netns {netns}? +--rw name? string Signed-off-by: Chirag Shah --- yang/frr-vrf.yang | 75 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 yang/frr-vrf.yang diff --git a/yang/frr-vrf.yang b/yang/frr-vrf.yang new file mode 100644 index 000000000000..40ead7e79c61 --- /dev/null +++ b/yang/frr-vrf.yang @@ -0,0 +1,75 @@ +module frr-vrf { + yang-version 1.1; + namespace "http://frrouting.org/yang/vrf"; + prefix frr-vrf; + + organization + "Free Range Routing"; + contact + "FRR Users List: + FRR Development List: "; + description + "This module defines a model for managing FRR VRF."; + + revision 2019-12-06 { + description + "Initial revision."; + } + + /* + * Network namespace feature + */ + feature netns { + description "Abstracts network namespace as VRF."; + } + + container lib { + list vrf { + key "name"; + description + "VRF."; + leaf name { + type string { + length "1..36"; + } + description + "VRF name."; + } + + leaf id { + type uint32 { + range "0..4294967295"; + } + config false; + description + "VRF Id."; + } + + leaf active { + type boolean; + default "false"; + config false; + description + "VRF active in kernel."; + } + + container netns { + if-feature "netns"; + leaf name { + type string; + description + "Namespace name."; + } + } + } + } + + typedef vrf-ref { + type leafref { + require-instance false; + path "/frr-vrf:lib/frr-vrf:vrf/frr-vrf:name"; + } + description + "Reference to a VRF"; + } +} From 2884b535add603e1b63e33d066c511bdaaf63849 Mon Sep 17 00:00:00 2001 From: Santosh P K Date: Thu, 20 Feb 2020 02:22:49 -0800 Subject: [PATCH 16/32] *: add frr-vrf yang module in makefile lib: Adding frr-vrf yang module to common place so it can be accessed from all frr modules. Signed-off-by: Chirag Shah --- lib/subdir.am | 1 + yang/subdir.am | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/subdir.am b/lib/subdir.am index 4f62eb226413..23aa637268fa 100644 --- a/lib/subdir.am +++ b/lib/subdir.am @@ -110,6 +110,7 @@ nodist_lib_libfrr_la_SOURCES = \ yang/frr-interface.yang.c \ yang/frr-route-map.yang.c \ yang/frr-route-types.yang.c \ + yang/frr-vrf.yang.c \ yang/ietf/ietf-routing-types.yang.c \ yang/frr-module-translator.yang.c \ # end diff --git a/yang/subdir.am b/yang/subdir.am index c1297dafd560..a7af431e9df7 100644 --- a/yang/subdir.am +++ b/yang/subdir.am @@ -24,6 +24,7 @@ dist_yangmodels_DATA += yang/frr-module-translator.yang dist_yangmodels_DATA += yang/frr-test-module.yang dist_yangmodels_DATA += yang/frr-interface.yang dist_yangmodels_DATA += yang/frr-route-map.yang +dist_yangmodels_DATA += yang/frr-vrf.yang dist_yangmodels_DATA += yang/frr-route-types.yang dist_yangmodels_DATA += yang/ietf/ietf-routing-types.yang From 745d6947fc46fe6551c694329fa25f18768067d7 Mon Sep 17 00:00:00 2001 From: Chirag Shah Date: Mon, 3 Feb 2020 13:31:32 -0800 Subject: [PATCH 17/32] yang: add vrf ref to interface model module: frr-interface +--rw lib +--rw interface* [name vrf] +--rw name string +--rw vrf frr-vrf:vrf-ref +--rw description? string Signed-off-by: Chirag Shah --- yang/frr-interface.yang | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/yang/frr-interface.yang b/yang/frr-interface.yang index 4f7f3beebd9a..c7031ed41d33 100644 --- a/yang/frr-interface.yang +++ b/yang/frr-interface.yang @@ -3,6 +3,10 @@ module frr-interface { namespace "http://frrouting.org/yang/interface"; prefix frr-interface; + import frr-vrf { + prefix frr-vrf; + } + organization "Free Range Routing"; contact @@ -25,7 +29,6 @@ module frr-interface { key "name vrf"; description "Interface."; - leaf name { type string { length "1..16"; @@ -33,13 +36,13 @@ module frr-interface { description "Interface name."; } + leaf vrf { - type string { - length "1..36"; - } + type frr-vrf:vrf-ref; description "VRF this interface is associated with."; } + leaf description { type string; description From 1dc094d48fdae1c08670aa3885ade9cb387befea Mon Sep 17 00:00:00 2001 From: Santosh P K Date: Fri, 20 Dec 2019 00:30:57 -0800 Subject: [PATCH 18/32] lib: FRR next-hop yang data model. A common nexthop and group nexthop yang data model for all protocols in FRR. Co-authored-by: Santosh P K Co-authored-by: Vishaldhingra Signed-off-by: Santosh P K --- yang/frr-nexthop.yang | 150 ++++++++++++++++++++++++++---------------- 1 file changed, 93 insertions(+), 57 deletions(-) diff --git a/yang/frr-nexthop.yang b/yang/frr-nexthop.yang index 7d8ce1b8ed14..248dd56d937e 100644 --- a/yang/frr-nexthop.yang +++ b/yang/frr-nexthop.yang @@ -10,10 +10,15 @@ module frr-nexthop { import ietf-routing-types { prefix rt-types; } + import frr-interface { prefix frr-interface; } + import frr-vrf { + prefix "frr-vrf"; + } + organization "Free Range Routing"; contact @@ -27,10 +32,19 @@ module frr-nexthop { "Initial revision."; } - typedef gateway-address { - type inet:ip-address; + typedef optional-ip-address { + type union { + type inet:ip-address; + type string { + pattern + ''; + } + } } + /* + * Nexthop types. + */ typedef nexthop-type { type enumeration { enum "ifindex" { @@ -68,6 +82,9 @@ module frr-nexthop { "Nexthop types."; } + /* + * Blockhole nexthop type. + */ typedef blackhole-type { type enumeration { enum "unspec" { @@ -97,113 +114,132 @@ module frr-nexthop { } /* - * Nexthop object + * Common nexthop attributes grouping. */ - - grouping frr-nexthop { + grouping frr-nexthop-attributes { leaf nh-type { type nexthop-type; mandatory true; description "The nexthop type."; } - - leaf gateway { - type gateway-address; - description - "The nexthop gateway address."; - } - leaf vrf { - type string { - length "1..36"; - } + type frr-vrf:vrf-ref; description "The nexthop vrf name, if different from the route."; } - + leaf gateway { + type frr-nexthop:optional-ip-address; + description + "The nexthop gateway address."; + } leaf interface { type frr-interface:interface-ref; description "The nexthop egress interface."; } - leaf bh-type { + when "../nh-type = 'blackhole'"; type blackhole-type; description "A blackhole sub-type, if the nexthop is a blackhole type."; } - - leaf flags { - type uint32; + leaf onlink { + when "../nh-type = 'ip4-ifindex' or + ../nh-type = 'ip6-ifindex'"; + type boolean; + default false; description - "The nexthop's raw flags value."; + "Nexthop is directly connected."; } - - leaf is-duplicate { - type empty; + uses rt-types:mpls-label-stack { description - "Duplicate nexthop; will be ignored."; + "Nexthop's MPLS label stack."; } + } - leaf is-recursive { + /* + * operational common attributes for nexthop + */ + grouping frr-nexthop-operational { + leaf duplicate { + config false; type empty; description - "Nexthop must be resolved through another gateway."; + "Duplicate nexthop"; } - - leaf is-onlink { + leaf recursive { + config false; type empty; description - "Nexthop is directly connected."; + "Nexthop resolved through another gateway."; } - - leaf is-active { + leaf active { + config false; type empty; description "Nexthop is active."; } - - uses rt-types:mpls-label-stack { + leaf fib { + config false; + type empty; description - "Nexthop's MPLS label stack."; + "Nexthop is installed in fib."; } + } - leaf mtu { - type uint32; + /* + * Single nexthop grouping. + */ + grouping frr-nexthop { + container frr-nexthops { description - "The nexthop's specific MTU."; + "FRR nexthop object."; + list nexthop { + key "nh-type gateway interface"; + description + "A list of nexthop objects."; + + uses frr-nexthop-attributes; + } } } - // End of nexthop + /* - * Nexthop-group container + * Container for FRR nexthop group. */ - - grouping frr-nexthop-group { - description - "A nexthop-group, represented as a list of nexthop objects."; - leaf name { - type string; + grouping frr-nexthop-grouping { + list nexthop-group { + key "name"; description - "The nexthop-group name."; - } + "A group of nexthops."; - list entry { - key "id"; - description - "A list of nexthop objects."; - leaf id { - type uint32; + leaf name { + type string; description - "Identifies a nexthop within a nexthop group; the entries - are ordered by id value, and the value has no other meaning."; + "The nexthop-group name."; } uses frr-nexthop; } } - // End of frr-nexthop-group + container frr-nexthop-group { + description + "A nexthop-group, represented as a list of nexthop objects."; + + uses frr-nexthop-grouping; + } + + /* + * Agument weight attributes to nexthop group. + */ + augment "/frr-nexthop-group/nexthop-group/frr-nexthops/nexthop" { + leaf weight { + type uint8; + description + "Weight to be used by the nexthop for purposes of ECMP"; + } + } } From 3cd3efec9ced0fcb3da15da2fd6893adf286079a Mon Sep 17 00:00:00 2001 From: vdhingra Date: Tue, 3 Dec 2019 06:00:51 -0800 Subject: [PATCH 19/32] staticd: yang defination Yang files for staticd to use northbound APIs Co-authored-by: Santosh P K Co-authored-by: vishaldhingra Signed-off-by: vishaldhingra --- yang/frr-staticd.yang | 86 +++++++++++++++++++++++++++++++++++++++++++ yang/subdir.am | 4 ++ 2 files changed, 90 insertions(+) create mode 100644 yang/frr-staticd.yang diff --git a/yang/frr-staticd.yang b/yang/frr-staticd.yang new file mode 100644 index 000000000000..58933c904083 --- /dev/null +++ b/yang/frr-staticd.yang @@ -0,0 +1,86 @@ +module frr-staticd { + yang-version "1.1"; + namespace "http://frrouting.org/yang/staticd"; + + prefix frr-staticd; + + import frr-routing { + prefix "frr-rt"; + } + + import frr-nexthop { + prefix frr-nexthop; + } + + import ietf-inet-types { + prefix inet; + } + + organization + "Free Range Routing"; + + contact + "FRR Users List: + FRR Development List: "; + + description + "This module defines a model for managing FRR staticd information. + This YANG module augments the ietf-routing with additional + nexthop information"; + + revision 2019-12-03 { + description + "Initial revision."; + } + + identity static { + base frr-rt:routing-protocol; + description + "'Static' routing pseudo-protocol."; + } + + augment "/frr-rt:routing/frr-rt:control-plane-protocols/" + + "frr-rt:control-plane-protocol" { + container staticd { + when "../frr-rt:type = 'frr-staticd:static'" { + description + "This container is only valid for the 'static' routing + protocol."; + } + description + "Support for a 'static' pseudo-protocol instance + consists of a list of routes."; + + list prefix-list { + key "destination-prefix"; + description + "List of static IP routes."; + + leaf destination-prefix { + type inet:ip-address; + description + "IP destination prefix."; + } + + leaf distance { + type frr-rt:administrative-distance; + description + "Admin distance associated with this route."; + } + + leaf tag { + type uint32 { + range "1..4294967295"; + } + description + "Route tag"; + } + container frr-staticd-next-hop { + description + "Augment static route configuration 'nexthop-list'."; + uses frr-nexthop:frr-nexthop; + } + } + } + } +} diff --git a/yang/subdir.am b/yang/subdir.am index a7af431e9df7..9c3147e7adb5 100644 --- a/yang/subdir.am +++ b/yang/subdir.am @@ -51,3 +51,7 @@ endif if VRRPD dist_yangmodels_DATA += yang/frr-vrrpd.yang endif + +if STATICD +dist_yangmodels_DATA += yang/frr-staticd.yang +endif From 30144e1e231b520e20caf236be6852823610470c Mon Sep 17 00:00:00 2001 From: vdhingra Date: Tue, 10 Dec 2019 21:57:37 -0800 Subject: [PATCH 20/32] lib: yang defination for basic frr-routing Yang files for basic frr-routing used by other daemons like staticd and pim Co-authored-by: Santosh P K Co-authored-by: vishaldhingra Signed-off-by: vishaldhingra --- lib/subdir.am | 1 + yang/frr-routing.yang | 135 ++++++++++++++++++++++++++++++++++++++++++ yang/subdir.am | 1 + 3 files changed, 137 insertions(+) create mode 100644 yang/frr-routing.yang diff --git a/lib/subdir.am b/lib/subdir.am index 23aa637268fa..56d11c5852d1 100644 --- a/lib/subdir.am +++ b/lib/subdir.am @@ -111,6 +111,7 @@ nodist_lib_libfrr_la_SOURCES = \ yang/frr-route-map.yang.c \ yang/frr-route-types.yang.c \ yang/frr-vrf.yang.c \ + yang/frr-routing.yang.c \ yang/ietf/ietf-routing-types.yang.c \ yang/frr-module-translator.yang.c \ # end diff --git a/yang/frr-routing.yang b/yang/frr-routing.yang new file mode 100644 index 000000000000..615a81c72240 --- /dev/null +++ b/yang/frr-routing.yang @@ -0,0 +1,135 @@ +module frr-routing { + yang-version "1.1"; + namespace "http://frrouting.org/yang/routing"; + prefix "rt"; + + import ietf-yang-types { + prefix "yang"; + } + + import frr-vrf { + prefix frr-vrf; + } + + organization + "Free Range Routing"; + + contact + "FRR Users List: + FRR Development List: "; + + description + "This YANG module defines essential components for the management + of a routing subsystem."; + + revision 2019-08-15 { + description + "Initial revision."; + } + + /* Identities */ + + identity address-family { + description + "Base identity from which identities describing address + families are derived."; + } + + identity ipv4 { + base address-family; + description + "This identity represents an IPv4 address family."; + } + + identity ipv6 { + base address-family; + description + "This identity represents an IPv6 address family."; + } + + identity control-plane-protocol { + description + "Base identity from which control-plane protocol identities are + derived."; + } + + identity routing-protocol { + base control-plane-protocol; + description + "Identity from which Layer 3 routing protocol identities are + derived."; + } + + /* Type Definitions */ + + typedef administrative-distance { + type uint8 { + range "1..255"; + } + description + "Admin distance associated with the route."; + } + + /* Groupings */ + + grouping address-family { + description + "This grouping provides a leaf identifying an address + family."; + leaf address-family { + type identityref { + base address-family; + } + mandatory true; + description + "Address family."; + } + } + + grouping router-id { + description + "This grouping provides a router ID."; + leaf router-id { + type yang:dotted-quad; + description + "A 32-bit number in the form of a dotted quad that is used by + some routing protocols identifying a router."; + reference + "RFC 2328: OSPF Version 2"; + } + } + + /* Data nodes */ + + container routing { + description + "Configuration parameters for the routing subsystem."; + container control-plane-protocols { + description + "Support for control-plane protocol instances."; + list control-plane-protocol { + key "type name vrf"; + description + "Each entry contains a control-plane protocol instance."; + leaf type { + type identityref { + base control-plane-protocol; + } + description + "Type of the control-plane protocol"; + } + leaf name { + type string; + description + "An arbitrary name of the control-plane protocol + instance."; + } + leaf vrf { + type frr-vrf:vrf-ref; + description + "vrf for control-plane protocol"; + } + } + } + } +} diff --git a/yang/subdir.am b/yang/subdir.am index 9c3147e7adb5..399fa7d32e4c 100644 --- a/yang/subdir.am +++ b/yang/subdir.am @@ -26,6 +26,7 @@ dist_yangmodels_DATA += yang/frr-interface.yang dist_yangmodels_DATA += yang/frr-route-map.yang dist_yangmodels_DATA += yang/frr-vrf.yang dist_yangmodels_DATA += yang/frr-route-types.yang +dist_yangmodels_DATA += yang/frr-routing.yang dist_yangmodels_DATA += yang/ietf/ietf-routing-types.yang if BFDD From 9503d08490106b4d13f5b5b1bc1b1dc0cf1d6784 Mon Sep 17 00:00:00 2001 From: Chirag Shah Date: Thu, 5 Dec 2019 20:47:01 -0800 Subject: [PATCH 21/32] yang: add vrf model module: frr-vrf +--rw lib +--rw vrf* [name] +--rw name string +--ro id? uint32 +--ro active? boolean +--rw netns {netns}? +--rw name? string Signed-off-by: Chirag Shah --- yang/frr-vrf.yang | 75 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 yang/frr-vrf.yang diff --git a/yang/frr-vrf.yang b/yang/frr-vrf.yang new file mode 100644 index 000000000000..40ead7e79c61 --- /dev/null +++ b/yang/frr-vrf.yang @@ -0,0 +1,75 @@ +module frr-vrf { + yang-version 1.1; + namespace "http://frrouting.org/yang/vrf"; + prefix frr-vrf; + + organization + "Free Range Routing"; + contact + "FRR Users List: + FRR Development List: "; + description + "This module defines a model for managing FRR VRF."; + + revision 2019-12-06 { + description + "Initial revision."; + } + + /* + * Network namespace feature + */ + feature netns { + description "Abstracts network namespace as VRF."; + } + + container lib { + list vrf { + key "name"; + description + "VRF."; + leaf name { + type string { + length "1..36"; + } + description + "VRF name."; + } + + leaf id { + type uint32 { + range "0..4294967295"; + } + config false; + description + "VRF Id."; + } + + leaf active { + type boolean; + default "false"; + config false; + description + "VRF active in kernel."; + } + + container netns { + if-feature "netns"; + leaf name { + type string; + description + "Namespace name."; + } + } + } + } + + typedef vrf-ref { + type leafref { + require-instance false; + path "/frr-vrf:lib/frr-vrf:vrf/frr-vrf:name"; + } + description + "Reference to a VRF"; + } +} From f899a08b4048faa07a0c65068aba12f75a612c0a Mon Sep 17 00:00:00 2001 From: Santosh P K Date: Thu, 20 Feb 2020 02:22:49 -0800 Subject: [PATCH 22/32] *: add frr-vrf yang module in makefile lib: Adding frr-vrf yang module to common place so it can be accessed from all frr modules. Signed-off-by: Chirag Shah --- lib/subdir.am | 1 + yang/subdir.am | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/subdir.am b/lib/subdir.am index 4f62eb226413..23aa637268fa 100644 --- a/lib/subdir.am +++ b/lib/subdir.am @@ -110,6 +110,7 @@ nodist_lib_libfrr_la_SOURCES = \ yang/frr-interface.yang.c \ yang/frr-route-map.yang.c \ yang/frr-route-types.yang.c \ + yang/frr-vrf.yang.c \ yang/ietf/ietf-routing-types.yang.c \ yang/frr-module-translator.yang.c \ # end diff --git a/yang/subdir.am b/yang/subdir.am index c1297dafd560..a7af431e9df7 100644 --- a/yang/subdir.am +++ b/yang/subdir.am @@ -24,6 +24,7 @@ dist_yangmodels_DATA += yang/frr-module-translator.yang dist_yangmodels_DATA += yang/frr-test-module.yang dist_yangmodels_DATA += yang/frr-interface.yang dist_yangmodels_DATA += yang/frr-route-map.yang +dist_yangmodels_DATA += yang/frr-vrf.yang dist_yangmodels_DATA += yang/frr-route-types.yang dist_yangmodels_DATA += yang/ietf/ietf-routing-types.yang From 5246d64976363b1f3fb00c811ab9180ea372268c Mon Sep 17 00:00:00 2001 From: Chirag Shah Date: Mon, 3 Feb 2020 13:31:32 -0800 Subject: [PATCH 23/32] yang: add vrf ref to interface model module: frr-interface +--rw lib +--rw interface* [name vrf] +--rw name string +--rw vrf frr-vrf:vrf-ref +--rw description? string Signed-off-by: Chirag Shah --- yang/frr-interface.yang | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/yang/frr-interface.yang b/yang/frr-interface.yang index 4f7f3beebd9a..c7031ed41d33 100644 --- a/yang/frr-interface.yang +++ b/yang/frr-interface.yang @@ -3,6 +3,10 @@ module frr-interface { namespace "http://frrouting.org/yang/interface"; prefix frr-interface; + import frr-vrf { + prefix frr-vrf; + } + organization "Free Range Routing"; contact @@ -25,7 +29,6 @@ module frr-interface { key "name vrf"; description "Interface."; - leaf name { type string { length "1..16"; @@ -33,13 +36,13 @@ module frr-interface { description "Interface name."; } + leaf vrf { - type string { - length "1..36"; - } + type frr-vrf:vrf-ref; description "VRF this interface is associated with."; } + leaf description { type string; description From 1feaebbc54d121e564add697fe9236c93b8c6a9d Mon Sep 17 00:00:00 2001 From: Santosh P K Date: Fri, 20 Dec 2019 00:30:57 -0800 Subject: [PATCH 24/32] lib: FRR next-hop yang data model. A common nexthop and group nexthop yang data model for all protocols in FRR. Co-authored-by: Santosh P K Co-authored-by: Vishaldhingra Signed-off-by: Santosh P K --- yang/frr-nexthop.yang | 150 ++++++++++++++++++++++++++---------------- 1 file changed, 93 insertions(+), 57 deletions(-) diff --git a/yang/frr-nexthop.yang b/yang/frr-nexthop.yang index 7d8ce1b8ed14..248dd56d937e 100644 --- a/yang/frr-nexthop.yang +++ b/yang/frr-nexthop.yang @@ -10,10 +10,15 @@ module frr-nexthop { import ietf-routing-types { prefix rt-types; } + import frr-interface { prefix frr-interface; } + import frr-vrf { + prefix "frr-vrf"; + } + organization "Free Range Routing"; contact @@ -27,10 +32,19 @@ module frr-nexthop { "Initial revision."; } - typedef gateway-address { - type inet:ip-address; + typedef optional-ip-address { + type union { + type inet:ip-address; + type string { + pattern + ''; + } + } } + /* + * Nexthop types. + */ typedef nexthop-type { type enumeration { enum "ifindex" { @@ -68,6 +82,9 @@ module frr-nexthop { "Nexthop types."; } + /* + * Blockhole nexthop type. + */ typedef blackhole-type { type enumeration { enum "unspec" { @@ -97,113 +114,132 @@ module frr-nexthop { } /* - * Nexthop object + * Common nexthop attributes grouping. */ - - grouping frr-nexthop { + grouping frr-nexthop-attributes { leaf nh-type { type nexthop-type; mandatory true; description "The nexthop type."; } - - leaf gateway { - type gateway-address; - description - "The nexthop gateway address."; - } - leaf vrf { - type string { - length "1..36"; - } + type frr-vrf:vrf-ref; description "The nexthop vrf name, if different from the route."; } - + leaf gateway { + type frr-nexthop:optional-ip-address; + description + "The nexthop gateway address."; + } leaf interface { type frr-interface:interface-ref; description "The nexthop egress interface."; } - leaf bh-type { + when "../nh-type = 'blackhole'"; type blackhole-type; description "A blackhole sub-type, if the nexthop is a blackhole type."; } - - leaf flags { - type uint32; + leaf onlink { + when "../nh-type = 'ip4-ifindex' or + ../nh-type = 'ip6-ifindex'"; + type boolean; + default false; description - "The nexthop's raw flags value."; + "Nexthop is directly connected."; } - - leaf is-duplicate { - type empty; + uses rt-types:mpls-label-stack { description - "Duplicate nexthop; will be ignored."; + "Nexthop's MPLS label stack."; } + } - leaf is-recursive { + /* + * operational common attributes for nexthop + */ + grouping frr-nexthop-operational { + leaf duplicate { + config false; type empty; description - "Nexthop must be resolved through another gateway."; + "Duplicate nexthop"; } - - leaf is-onlink { + leaf recursive { + config false; type empty; description - "Nexthop is directly connected."; + "Nexthop resolved through another gateway."; } - - leaf is-active { + leaf active { + config false; type empty; description "Nexthop is active."; } - - uses rt-types:mpls-label-stack { + leaf fib { + config false; + type empty; description - "Nexthop's MPLS label stack."; + "Nexthop is installed in fib."; } + } - leaf mtu { - type uint32; + /* + * Single nexthop grouping. + */ + grouping frr-nexthop { + container frr-nexthops { description - "The nexthop's specific MTU."; + "FRR nexthop object."; + list nexthop { + key "nh-type gateway interface"; + description + "A list of nexthop objects."; + + uses frr-nexthop-attributes; + } } } - // End of nexthop + /* - * Nexthop-group container + * Container for FRR nexthop group. */ - - grouping frr-nexthop-group { - description - "A nexthop-group, represented as a list of nexthop objects."; - leaf name { - type string; + grouping frr-nexthop-grouping { + list nexthop-group { + key "name"; description - "The nexthop-group name."; - } + "A group of nexthops."; - list entry { - key "id"; - description - "A list of nexthop objects."; - leaf id { - type uint32; + leaf name { + type string; description - "Identifies a nexthop within a nexthop group; the entries - are ordered by id value, and the value has no other meaning."; + "The nexthop-group name."; } uses frr-nexthop; } } - // End of frr-nexthop-group + container frr-nexthop-group { + description + "A nexthop-group, represented as a list of nexthop objects."; + + uses frr-nexthop-grouping; + } + + /* + * Agument weight attributes to nexthop group. + */ + augment "/frr-nexthop-group/nexthop-group/frr-nexthops/nexthop" { + leaf weight { + type uint8; + description + "Weight to be used by the nexthop for purposes of ECMP"; + } + } } From a715c1b8aecca7996619ef5e696fa16faac03081 Mon Sep 17 00:00:00 2001 From: vdhingra Date: Tue, 3 Dec 2019 06:00:51 -0800 Subject: [PATCH 25/32] staticd: yang defination Yang files for staticd to use northbound APIs Co-authored-by: Santosh P K Co-authored-by: vishaldhingra Signed-off-by: vishaldhingra --- yang/frr-staticd.yang | 86 +++++++++++++++++++++++++++++++++++++++++++ yang/subdir.am | 4 ++ 2 files changed, 90 insertions(+) create mode 100644 yang/frr-staticd.yang diff --git a/yang/frr-staticd.yang b/yang/frr-staticd.yang new file mode 100644 index 000000000000..58933c904083 --- /dev/null +++ b/yang/frr-staticd.yang @@ -0,0 +1,86 @@ +module frr-staticd { + yang-version "1.1"; + namespace "http://frrouting.org/yang/staticd"; + + prefix frr-staticd; + + import frr-routing { + prefix "frr-rt"; + } + + import frr-nexthop { + prefix frr-nexthop; + } + + import ietf-inet-types { + prefix inet; + } + + organization + "Free Range Routing"; + + contact + "FRR Users List: + FRR Development List: "; + + description + "This module defines a model for managing FRR staticd information. + This YANG module augments the ietf-routing with additional + nexthop information"; + + revision 2019-12-03 { + description + "Initial revision."; + } + + identity static { + base frr-rt:routing-protocol; + description + "'Static' routing pseudo-protocol."; + } + + augment "/frr-rt:routing/frr-rt:control-plane-protocols/" + + "frr-rt:control-plane-protocol" { + container staticd { + when "../frr-rt:type = 'frr-staticd:static'" { + description + "This container is only valid for the 'static' routing + protocol."; + } + description + "Support for a 'static' pseudo-protocol instance + consists of a list of routes."; + + list prefix-list { + key "destination-prefix"; + description + "List of static IP routes."; + + leaf destination-prefix { + type inet:ip-address; + description + "IP destination prefix."; + } + + leaf distance { + type frr-rt:administrative-distance; + description + "Admin distance associated with this route."; + } + + leaf tag { + type uint32 { + range "1..4294967295"; + } + description + "Route tag"; + } + container frr-staticd-next-hop { + description + "Augment static route configuration 'nexthop-list'."; + uses frr-nexthop:frr-nexthop; + } + } + } + } +} diff --git a/yang/subdir.am b/yang/subdir.am index a7af431e9df7..9c3147e7adb5 100644 --- a/yang/subdir.am +++ b/yang/subdir.am @@ -51,3 +51,7 @@ endif if VRRPD dist_yangmodels_DATA += yang/frr-vrrpd.yang endif + +if STATICD +dist_yangmodels_DATA += yang/frr-staticd.yang +endif From dbd8ec5f02d9efffe5bb53bbf091c5528c138a4a Mon Sep 17 00:00:00 2001 From: vdhingra Date: Tue, 10 Dec 2019 21:57:37 -0800 Subject: [PATCH 26/32] lib: yang defination for basic frr-routing Yang files for basic frr-routing used by other daemons like staticd and pim Co-authored-by: Santosh P K Co-authored-by: vishaldhingra Signed-off-by: vishaldhingra --- lib/subdir.am | 1 + yang/frr-routing.yang | 135 ++++++++++++++++++++++++++++++++++++++++++ yang/subdir.am | 1 + 3 files changed, 137 insertions(+) create mode 100644 yang/frr-routing.yang diff --git a/lib/subdir.am b/lib/subdir.am index 23aa637268fa..56d11c5852d1 100644 --- a/lib/subdir.am +++ b/lib/subdir.am @@ -111,6 +111,7 @@ nodist_lib_libfrr_la_SOURCES = \ yang/frr-route-map.yang.c \ yang/frr-route-types.yang.c \ yang/frr-vrf.yang.c \ + yang/frr-routing.yang.c \ yang/ietf/ietf-routing-types.yang.c \ yang/frr-module-translator.yang.c \ # end diff --git a/yang/frr-routing.yang b/yang/frr-routing.yang new file mode 100644 index 000000000000..615a81c72240 --- /dev/null +++ b/yang/frr-routing.yang @@ -0,0 +1,135 @@ +module frr-routing { + yang-version "1.1"; + namespace "http://frrouting.org/yang/routing"; + prefix "rt"; + + import ietf-yang-types { + prefix "yang"; + } + + import frr-vrf { + prefix frr-vrf; + } + + organization + "Free Range Routing"; + + contact + "FRR Users List: + FRR Development List: "; + + description + "This YANG module defines essential components for the management + of a routing subsystem."; + + revision 2019-08-15 { + description + "Initial revision."; + } + + /* Identities */ + + identity address-family { + description + "Base identity from which identities describing address + families are derived."; + } + + identity ipv4 { + base address-family; + description + "This identity represents an IPv4 address family."; + } + + identity ipv6 { + base address-family; + description + "This identity represents an IPv6 address family."; + } + + identity control-plane-protocol { + description + "Base identity from which control-plane protocol identities are + derived."; + } + + identity routing-protocol { + base control-plane-protocol; + description + "Identity from which Layer 3 routing protocol identities are + derived."; + } + + /* Type Definitions */ + + typedef administrative-distance { + type uint8 { + range "1..255"; + } + description + "Admin distance associated with the route."; + } + + /* Groupings */ + + grouping address-family { + description + "This grouping provides a leaf identifying an address + family."; + leaf address-family { + type identityref { + base address-family; + } + mandatory true; + description + "Address family."; + } + } + + grouping router-id { + description + "This grouping provides a router ID."; + leaf router-id { + type yang:dotted-quad; + description + "A 32-bit number in the form of a dotted quad that is used by + some routing protocols identifying a router."; + reference + "RFC 2328: OSPF Version 2"; + } + } + + /* Data nodes */ + + container routing { + description + "Configuration parameters for the routing subsystem."; + container control-plane-protocols { + description + "Support for control-plane protocol instances."; + list control-plane-protocol { + key "type name vrf"; + description + "Each entry contains a control-plane protocol instance."; + leaf type { + type identityref { + base control-plane-protocol; + } + description + "Type of the control-plane protocol"; + } + leaf name { + type string; + description + "An arbitrary name of the control-plane protocol + instance."; + } + leaf vrf { + type frr-vrf:vrf-ref; + description + "vrf for control-plane protocol"; + } + } + } + } +} diff --git a/yang/subdir.am b/yang/subdir.am index 9c3147e7adb5..399fa7d32e4c 100644 --- a/yang/subdir.am +++ b/yang/subdir.am @@ -26,6 +26,7 @@ dist_yangmodels_DATA += yang/frr-interface.yang dist_yangmodels_DATA += yang/frr-route-map.yang dist_yangmodels_DATA += yang/frr-vrf.yang dist_yangmodels_DATA += yang/frr-route-types.yang +dist_yangmodels_DATA += yang/frr-routing.yang dist_yangmodels_DATA += yang/ietf/ietf-routing-types.yang if BFDD From 2ee0effb5e2636cba0b27671c20f50cdfa4d7d09 Mon Sep 17 00:00:00 2001 From: Chirag Shah Date: Tue, 10 Mar 2020 18:20:49 -0700 Subject: [PATCH 27/32] lib: vrf northbound callbacks Signed-off-by: Chirag Shah --- lib/vrf.c | 145 ++++++++++++++++++++++++++++++++++++++++++++++ lib/vrf.h | 2 + lib/yang.c | 1 + yang/frr-vrf.yang | 53 ++++++----------- 4 files changed, 167 insertions(+), 34 deletions(-) diff --git a/lib/vrf.c b/lib/vrf.c index 370a1b235ae0..9346771b05e1 100644 --- a/lib/vrf.c +++ b/lib/vrf.c @@ -36,6 +36,7 @@ #include "privs.h" #include "nexthop_group.h" #include "lib_errors.h" +#include "northbound.h" /* default VRF ID value used when VRF backend is not NETNS */ #define VRF_DEFAULT_INTERNAL 0 @@ -1010,3 +1011,147 @@ vrf_id_t vrf_generate_id(void) return ++vrf_id_local; } + +/* ------- Northbound callbacks ------- */ + +/* + * XPath: /frr-vrf:lib/vrf + */ +static int lib_vrf_create(enum nb_event event, const struct lyd_node *dnode, + union nb_resource *resource) +{ + const char *vrfname; + struct vrf *vrfp; + + vrfname = yang_dnode_get_string(dnode, "./name"); + + if (event != NB_EV_APPLY) + return NB_OK; + + vrfp = vrf_get(VRF_UNKNOWN, vrfname); + + nb_running_set_entry(dnode, vrfp); + + return NB_OK; +} + +static int lib_vrf_destroy(enum nb_event event, const struct lyd_node *dnode) +{ + struct vrf *vrfp; + + + switch (event) { + case NB_EV_VALIDATE: + vrfp = nb_running_get_entry(dnode, NULL, true); + if (CHECK_FLAG(vrfp->status, VRF_ACTIVE)) { + zlog_debug("%s Only inactive VRFs can be deleted", + __func__); + return NB_ERR_VALIDATION; + } + break; + case NB_EV_PREPARE: + case NB_EV_ABORT: + break; + case NB_EV_APPLY: + vrfp = nb_running_unset_entry(dnode); + /* Clear configured flag and invoke delete. */ + UNSET_FLAG(vrfp->status, VRF_CONFIGURED); + vrf_delete(vrfp); + break; + } + + return NB_OK; +} + +static const void *lib_vrf_get_next(const void *parent_list_entry, + const void *list_entry) +{ + struct vrf *vrfp = (struct vrf *)list_entry; + + if (list_entry == NULL) { + vrfp = RB_MIN(vrf_name_head, &vrfs_by_name); + } else { + vrfp = RB_NEXT(vrf_name_head, vrfp); + } + + return vrfp; +} + +static int lib_vrf_get_keys(const void *list_entry, struct yang_list_keys *keys) +{ + struct vrf *vrfp = (struct vrf *)list_entry; + + keys->num = 1; + strlcpy(keys->key[0], vrfp->name, sizeof(keys->key[0])); + + return NB_OK; +} + +static const void *lib_vrf_lookup_entry(const void *parent_list_entry, + const struct yang_list_keys *keys) +{ + const char *vrfname = keys->key[0]; + + struct vrf *vrf = vrf_lookup_by_name(vrfname); + + return vrf; +} + +/* + * XPath: /frr-vrf:lib/vrf/id + */ +static struct yang_data *lib_vrf_state_id_get_elem(const char *xpath, + const void *list_entry) +{ + struct vrf *vrfp = (struct vrf *)list_entry; + + return yang_data_new_uint32(xpath, vrfp->vrf_id); +} + +/* + * XPath: /frr-vrf:lib/vrf/active + */ +static struct yang_data *lib_vrf_state_active_get_elem(const char *xpath, + const void *list_entry) +{ + struct vrf *vrfp = (struct vrf *)list_entry; + + if (vrfp->status == VRF_ACTIVE) + return yang_data_new_bool( + xpath, vrfp->status == VRF_ACTIVE ? true : false); + + return NULL; +} + +/* clang-format off */ +const struct frr_yang_module_info frr_vrf_info = { + .name = "frr-vrf", + .nodes = { + { + .xpath = "/frr-vrf:lib/vrf", + .cbs = { + .create = lib_vrf_create, + .destroy = lib_vrf_destroy, + .get_next = lib_vrf_get_next, + .get_keys = lib_vrf_get_keys, + .lookup_entry = lib_vrf_lookup_entry, + } + }, + { + .xpath = "/frr-vrf:lib/vrf/state/id", + .cbs = { + .get_elem = lib_vrf_state_id_get_elem, + } + }, + { + .xpath = "/frr-vrf:lib/vrf/state/active", + .cbs = { + .get_elem = lib_vrf_state_active_get_elem, + } + }, + { + .xpath = NULL, + }, + } +}; + diff --git a/lib/vrf.h b/lib/vrf.h index f231d2433fbc..3b02c21823d7 100644 --- a/lib/vrf.h +++ b/lib/vrf.h @@ -322,6 +322,8 @@ extern int vrf_enable(struct vrf *vrf); extern void vrf_delete(struct vrf *vrf); extern vrf_id_t vrf_generate_id(void); +extern const struct frr_yang_module_info frr_vrf_info; + #ifdef __cplusplus } #endif diff --git a/lib/yang.c b/lib/yang.c index 93e6db305530..a0d1695c3994 100644 --- a/lib/yang.c +++ b/lib/yang.c @@ -74,6 +74,7 @@ static const char *yang_module_imp_clb(const char *mod_name, static const char *const frr_native_modules[] = { "frr-interface", + "frr-vrf", "frr-ripd", "frr-ripngd", "frr-isisd", diff --git a/yang/frr-vrf.yang b/yang/frr-vrf.yang index 40ead7e79c61..4924a86e89a1 100644 --- a/yang/frr-vrf.yang +++ b/yang/frr-vrf.yang @@ -16,11 +16,13 @@ module frr-vrf { "Initial revision."; } - /* - * Network namespace feature - */ - feature netns { - description "Abstracts network namespace as VRF."; + typedef vrf-ref { + type leafref { + path "/frr-vrf:lib/frr-vrf:vrf/frr-vrf:name"; + require-instance false; + } + description + "Reference to a VRF"; } container lib { @@ -36,40 +38,23 @@ module frr-vrf { "VRF name."; } - leaf id { - type uint32 { - range "0..4294967295"; - } - config false; - description - "VRF Id."; - } - - leaf active { - type boolean; - default "false"; + container state { config false; - description - "VRF active in kernel."; - } + leaf id { + type uint32 { + range "0..4294967295"; + } + description + "VRF Id."; + } - container netns { - if-feature "netns"; - leaf name { - type string; + leaf active { + type boolean; + default "false"; description - "Namespace name."; + "VRF active in kernel."; } } } } - - typedef vrf-ref { - type leafref { - require-instance false; - path "/frr-vrf:lib/frr-vrf:vrf/frr-vrf:name"; - } - description - "Reference to a VRF"; - } } From fc8bee313f1ed9fb203f3f9271654d57191567a2 Mon Sep 17 00:00:00 2001 From: Chirag Shah Date: Wed, 11 Mar 2020 13:14:08 -0700 Subject: [PATCH 28/32] *: include vrf northbound module in init Signed-off-by: Chirag Shah --- babeld/babel_main.c | 8 ++++---- bfdd/bfdd.c | 1 + bgpd/bgp_main.c | 1 + eigrpd/eigrp_main.c | 1 + isisd/isis_main.c | 1 + ldpd/ldpd.c | 1 + ospf6d/ospf6_main.c | 1 + ospfd/ospf_main.c | 1 + pimd/pim_main.c | 1 + ripd/rip_main.c | 1 + ripngd/ripng_main.c | 1 + sharpd/sharp_main.c | 1 + staticd/static_main.c | 1 + zebra/main.c | 1 + 14 files changed, 17 insertions(+), 4 deletions(-) diff --git a/babeld/babel_main.c b/babeld/babel_main.c index 6f4b905c15ed..e7ba29ed06e4 100644 --- a/babeld/babel_main.c +++ b/babeld/babel_main.c @@ -136,10 +136,10 @@ struct option longopts[] = { 0 } }; -static const struct frr_yang_module_info *const babeld_yang_modules[] = - { - &frr_interface_info, - }; +static const struct frr_yang_module_info *const babeld_yang_modules[] = { + &frr_interface_info, + &frr_vrf_info, +}; FRR_DAEMON_INFO(babeld, BABELD, .vty_port = BABEL_VTY_PORT, diff --git a/bfdd/bfdd.c b/bfdd/bfdd.c index 69f268ab016e..8348be427f30 100644 --- a/bfdd/bfdd.c +++ b/bfdd/bfdd.c @@ -112,6 +112,7 @@ static struct quagga_signal_t bfd_signals[] = { static const struct frr_yang_module_info *const bfdd_yang_modules[] = { &frr_interface_info, &frr_bfdd_info, + &frr_vrf_info, }; FRR_DAEMON_INFO(bfdd, BFD, .vty_port = 2617, diff --git a/bgpd/bgp_main.c b/bgpd/bgp_main.c index c4ece2f082e2..28838d34757c 100644 --- a/bgpd/bgp_main.c +++ b/bgpd/bgp_main.c @@ -361,6 +361,7 @@ static void bgp_vrf_terminate(void) static const struct frr_yang_module_info *const bgpd_yang_modules[] = { &frr_interface_info, &frr_route_map_info, + &frr_vrf_info, }; FRR_DAEMON_INFO(bgpd, BGP, .vty_port = BGP_VTY_PORT, diff --git a/eigrpd/eigrp_main.c b/eigrpd/eigrp_main.c index add758fa210a..cdf1c6acdb42 100644 --- a/eigrpd/eigrp_main.c +++ b/eigrpd/eigrp_main.c @@ -141,6 +141,7 @@ static const struct frr_yang_module_info *const eigrpd_yang_modules[] = { &frr_eigrpd_info, &frr_interface_info, &frr_route_map_info, + &frr_vrf_info, }; FRR_DAEMON_INFO(eigrpd, EIGRP, .vty_port = EIGRP_VTY_PORT, diff --git a/isisd/isis_main.c b/isisd/isis_main.c index f7fe089b99a2..4c841dffe2fb 100644 --- a/isisd/isis_main.c +++ b/isisd/isis_main.c @@ -168,6 +168,7 @@ static const struct frr_yang_module_info *const isisd_yang_modules[] = { &frr_isisd_info, #endif /* ifndef FABRICD */ &frr_route_map_info, + &frr_vrf_info, }; #ifdef FABRICD diff --git a/ldpd/ldpd.c b/ldpd/ldpd.c index 78b1c3e54430..bf1e7e696af9 100644 --- a/ldpd/ldpd.c +++ b/ldpd/ldpd.c @@ -180,6 +180,7 @@ static struct quagga_signal_t ldp_signals[] = }; static const struct frr_yang_module_info *const ldpd_yang_modules[] = { + &frr_vrf_info, }; FRR_DAEMON_INFO(ldpd, LDP, diff --git a/ospf6d/ospf6_main.c b/ospf6d/ospf6_main.c index e4bed7a79d0a..4dbe5ca321f5 100644 --- a/ospf6d/ospf6_main.c +++ b/ospf6d/ospf6_main.c @@ -168,6 +168,7 @@ struct quagga_signal_t ospf6_signals[] = { static const struct frr_yang_module_info *const ospf6d_yang_modules[] = { &frr_interface_info, &frr_route_map_info, + &frr_vrf_info, }; FRR_DAEMON_INFO(ospf6d, OSPF6, .vty_port = OSPF6_VTY_PORT, diff --git a/ospfd/ospf_main.c b/ospfd/ospf_main.c index 4d6ebb40eb04..6a3ba9902d50 100644 --- a/ospfd/ospf_main.c +++ b/ospfd/ospf_main.c @@ -128,6 +128,7 @@ struct quagga_signal_t ospf_signals[] = { static const struct frr_yang_module_info *const ospfd_yang_modules[] = { &frr_interface_info, &frr_route_map_info, + &frr_vrf_info, }; FRR_DAEMON_INFO(ospfd, OSPF, .vty_port = OSPF_VTY_PORT, diff --git a/pimd/pim_main.c b/pimd/pim_main.c index 93b561ba0f39..5c4c7151a534 100644 --- a/pimd/pim_main.c +++ b/pimd/pim_main.c @@ -75,6 +75,7 @@ struct zebra_privs_t pimd_privs = { static const struct frr_yang_module_info *const pimd_yang_modules[] = { &frr_interface_info, &frr_route_map_info, + &frr_vrf_info, }; FRR_DAEMON_INFO(pimd, PIM, .vty_port = PIMD_VTY_PORT, diff --git a/ripd/rip_main.c b/ripd/rip_main.c index 73e94deefccd..9ec32a53e306 100644 --- a/ripd/rip_main.c +++ b/ripd/rip_main.c @@ -117,6 +117,7 @@ static const struct frr_yang_module_info *const ripd_yang_modules[] = { &frr_interface_info, &frr_ripd_info, &frr_route_map_info, + &frr_vrf_info, }; FRR_DAEMON_INFO(ripd, RIP, .vty_port = RIP_VTY_PORT, diff --git a/ripngd/ripng_main.c b/ripngd/ripng_main.c index 99adb2cba740..fbac750db3bf 100644 --- a/ripngd/ripng_main.c +++ b/ripngd/ripng_main.c @@ -117,6 +117,7 @@ static const struct frr_yang_module_info *const ripngd_yang_modules[] = { &frr_interface_info, &frr_ripngd_info, &frr_route_map_info, + &frr_vrf_info, }; FRR_DAEMON_INFO(ripngd, RIPNG, .vty_port = RIPNG_VTY_PORT, diff --git a/sharpd/sharp_main.c b/sharpd/sharp_main.c index 5133523f018a..120d7049189e 100644 --- a/sharpd/sharp_main.c +++ b/sharpd/sharp_main.c @@ -114,6 +114,7 @@ struct quagga_signal_t sharp_signals[] = { static const struct frr_yang_module_info *const sharpd_yang_modules[] = { &frr_interface_info, &frr_route_map_info, + &frr_vrf_info, }; FRR_DAEMON_INFO(sharpd, SHARP, .vty_port = SHARP_VTY_PORT, diff --git a/staticd/static_main.c b/staticd/static_main.c index 3aa8a8db3ebb..c77a99f28049 100644 --- a/staticd/static_main.c +++ b/staticd/static_main.c @@ -104,6 +104,7 @@ struct quagga_signal_t static_signals[] = { }; static const struct frr_yang_module_info *const staticd_yang_modules[] = { + &frr_vrf_info, }; #define STATIC_VTY_PORT 2616 diff --git a/zebra/main.c b/zebra/main.c index dab14491940d..3de178567a47 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -245,6 +245,7 @@ struct quagga_signal_t zebra_signals[] = { static const struct frr_yang_module_info *const zebra_yang_modules[] = { &frr_interface_info, &frr_route_map_info, + &frr_vrf_info, }; FRR_DAEMON_INFO( From 4d780b129691b872e222341f06326ff6e3d7e20c Mon Sep 17 00:00:00 2001 From: Chirag Shah Date: Sat, 21 Mar 2020 14:35:14 -0700 Subject: [PATCH 29/32] lib: convert vrf cmd to northbound config callback Signed-off-by: Chirag Shah --- lib/vrf.c | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/lib/vrf.c b/lib/vrf.c index 9346771b05e1..6f04e2300e0b 100644 --- a/lib/vrf.c +++ b/lib/vrf.c @@ -37,6 +37,7 @@ #include "nexthop_group.h" #include "lib_errors.h" #include "northbound.h" +#include "northbound_cli.h" /* default VRF ID value used when VRF backend is not NETNS */ #define VRF_DEFAULT_INTERNAL 0 @@ -604,6 +605,8 @@ int vrf_handler_create(struct vty *vty, const char *vrfname, struct vrf **vrf) { struct vrf *vrfp; + char xpath_list[XPATH_MAXLEN]; + int ret; if (strlen(vrfname) > VRF_NAMSIZ) { if (vty) @@ -618,13 +621,24 @@ int vrf_handler_create(struct vty *vty, const char *vrfname, return CMD_WARNING_CONFIG_FAILED; } - vrfp = vrf_get(VRF_UNKNOWN, vrfname); - - if (vty) - VTY_PUSH_CONTEXT(VRF_NODE, vrfp); + if (vty) { + snprintf(xpath_list, sizeof(xpath_list), + "/frr-vrf:lib/vrf[name='%s']", vrfname); + + nb_cli_enqueue_change(vty, xpath_list, NB_OP_CREATE, NULL); + ret = nb_cli_apply_changes(vty, xpath_list); + if (ret == CMD_SUCCESS) { + VTY_PUSH_XPATH(VRF_NODE, xpath_list); + vrfp = vrf_lookup_by_name(vrfname); + if (vrfp) + VTY_PUSH_CONTEXT(VRF_NODE, vrfp); + } + } else { + vrfp = vrf_get(VRF_UNKNOWN, vrfname); - if (vrf) - *vrf = vrfp; + if (vrf) + *vrf = vrfp; + } return CMD_SUCCESS; } @@ -727,6 +741,7 @@ DEFUN (no_vrf, "VRF's name\n") { const char *vrfname = argv[2]->arg; + char xpath_list[XPATH_MAXLEN]; struct vrf *vrfp; @@ -742,11 +757,11 @@ DEFUN (no_vrf, return CMD_WARNING_CONFIG_FAILED; } - /* Clear configured flag and invoke delete. */ - UNSET_FLAG(vrfp->status, VRF_CONFIGURED); - vrf_delete(vrfp); + snprintf(xpath_list, sizeof(xpath_list), "/frr-vrf:lib/vrf[name='%s']", + vrfname); - return CMD_SUCCESS; + nb_cli_enqueue_change(vty, xpath_list, NB_OP_DESTROY, NULL); + return nb_cli_apply_changes(vty, xpath_list); } @@ -1039,7 +1054,6 @@ static int lib_vrf_destroy(enum nb_event event, const struct lyd_node *dnode) { struct vrf *vrfp; - switch (event) { case NB_EV_VALIDATE: vrfp = nb_running_get_entry(dnode, NULL, true); @@ -1054,6 +1068,7 @@ static int lib_vrf_destroy(enum nb_event event, const struct lyd_node *dnode) break; case NB_EV_APPLY: vrfp = nb_running_unset_entry(dnode); + /* Clear configured flag and invoke delete. */ UNSET_FLAG(vrfp->status, VRF_CONFIGURED); vrf_delete(vrfp); From 93624af97323ac4a189e2278bdc97631e845a17d Mon Sep 17 00:00:00 2001 From: Chirag Shah Date: Sat, 21 Mar 2020 16:46:24 -0700 Subject: [PATCH 30/32] yang: revert leafref to get interface cmd working Unable to access interface command: root@bharat:~/stash/libyang/build# dpkg-query -W | grep libyang libyang-dev 0.16.105-3~ubuntu18.04.1 libyang0.16 0.16.105-3~ubuntu18.04.1 root@bharat:~/stash/libyang/build# vtysh bharat# config t bharat(config)# interface lo % Configuration failed: validation error. Please check the logs for more details. Logfile: 2020/03/21 16:48:55 ZEBRA: libyang: Leafref "/frr-vrf:lib/frr-vrf:vrf/frr-vrf:name" of value "default" points to a non-existing leaf. (/frr-interface:lib/interface[name='lo'][vrf='default']/vrf) 2020/03/21 16:48:55 ZEBRA: [EC 100663337] nb_candidate_commit_prepare: failed to validate candidate configuration CI system failure: 2020/03/21 18:53:18 ZEBRA: libyang: Leafref "/frr-vrf:lib/frr-vrf:vrf/frr-vrf:name" of value "default" points to a non-existing leaf. (/frr-interface:lib/interface[name='r1-eth0'][vrf='default']/vrf) 2020/03/21 18:53:18 ZEBRA: [EC 100663337] nb_candidate_commit_prepare: failed to validate candidate configuration 2020/03/21 18:53:18 ZEBRA: libyang: Leafref "/frr-vrf:lib/frr-vrf:vrf/frr-vrf:name" of value "default" points to a non-existing leaf. (/frr-interface:lib/interface[name='r1-eth1'][vrf='default']/vrf) Signed-off-by: Chirag Shah --- yang/frr-interface.yang | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/yang/frr-interface.yang b/yang/frr-interface.yang index c7031ed41d33..23b4324d5ae4 100644 --- a/yang/frr-interface.yang +++ b/yang/frr-interface.yang @@ -38,7 +38,11 @@ module frr-interface { } leaf vrf { - type frr-vrf:vrf-ref; + type string { + length "1..16"; + } + /* yang version 0.16 having issue accessing leafref. */ + /* type frr-vrf:vrf-ref;*/ description "VRF this interface is associated with."; } From 2209fc5839d0ca69fc184c2a5379f5ce942125aa Mon Sep 17 00:00:00 2001 From: Chirag Shah Date: Tue, 24 Mar 2020 13:14:25 -0700 Subject: [PATCH 31/32] lib: static yang array size gcc 4 workaround gcc 4 variable size array is not calcualated properely As an example, on Centos 7, yang module fails to load upon daemon start. Signed-off-by: chirag shah --- lib/northbound.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/northbound.h b/lib/northbound.h index 76a11e518cc0..fd549d5f96fa 100644 --- a/lib/northbound.h +++ b/lib/northbound.h @@ -417,7 +417,11 @@ struct frr_yang_module_info { /* Priority - lower priorities are processed first. */ uint32_t priority; +#if defined(__GNUC__) && ((__GNUC__ - 0) < 5) && !defined(__clang__) + } nodes[1000]; +#else } nodes[]; +#endif }; /* Northbound error codes. */ From 391aa5b01b23444c6bd82bf9c781075befd041a2 Mon Sep 17 00:00:00 2001 From: Santosh P K Date: Fri, 20 Mar 2020 00:14:01 -0700 Subject: [PATCH 32/32] ospfd: Configuration Yang for OSPF. Signed-off-by: Santosh P K --- yang/frr-ospfd.yang | 903 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 903 insertions(+) create mode 100644 yang/frr-ospfd.yang diff --git a/yang/frr-ospfd.yang b/yang/frr-ospfd.yang new file mode 100644 index 000000000000..9781ec8fd280 --- /dev/null +++ b/yang/frr-ospfd.yang @@ -0,0 +1,903 @@ +module frr-ospfd { + yang-version "1.1"; + namespace "http://frrouting.org/yang/ospfd"; + + prefix frr-ospfd; + + import frr-routing { + prefix "frr-rt"; + } + + import ietf-inet-types { + prefix inet; + } + + import frr-interface { + prefix frr-interface; + } + + import frr-route-types { + prefix frr-route-types; + } + + + organization + "Free Range Routing"; + + contact + "FRR Users List: + FRR Development List: "; + + description + "This module defines a model for managing FRR ospfd information. + This YANG module augments the basic routing with additional + ospf information"; + + revision 2019-03-01 { + description + "Initial revision."; + } + + /* Policy types to be removed later, once policy Yang finalized */ + typedef rmap-ref { + type string; + } + + typedef plist-ref { + type string; + } + + typedef access-list-ref { + type string; + } + + + identity ospf { + base frr-rt:routing-protocol; + description + "'Ospf' routing ospf-protocol."; + } + + + grouping nssa-grouping { + container nssa { + presence "Present if the nssa is enabled"; + + leaf no-summary { + type empty; + description + "Do not inject inter-area routes into nssa"; + } + leaf translate-always { + type empty; + description + "NSSA-ABR to always translate"; + } + leaf translate-candidate { + type empty; + description + "NSSA-ABR for translate election"; + } + leaf translate-never { + type empty; + description + "NSSA-ABR to never translate"; + } + } + } + + grouping range-grouing { + container ranges { + list range { + key "prefix"; + description + "A list of range objects"; + + leaf prefix { + type inet:ipv4-prefix; + description + "Area range prefix"; + } + leaf advertise { + type empty; + description + "Advertise this range"; + } + leaf not-advertise { + type empty; + description + "DoNotAdvertise this range"; + } + leaf cost { + type uint32 { + range "0..16777215"; + } + description + "Metric for this range"; + } + leaf substitute { + type inet:ipv4-prefix; + description + "Network prefix to be announced instead of range"; + } + } + } + } + + grouping stub-grouping { + container stub { + presence "Present when area is strub"; + + leaf no-summary { + type empty; + description + "Do not inject inter-area routes into stub"; + } + } + } + + grouping shortcut-grouping { + container shortcut { + leaf default { + type empty; + description + "Default shortcutting behavior"; + } + leaf disable { + type empty; + description + "Disable shortcutting through the area"; + } + leaf eanble { + type empty; + description + "Enable shortcutting through the area"; + } + } + } + + grouping authentication-group { + container authentication { + presence "Enable authentication."; + description + "Enable authentication on this virtual link."; + leaf message-digest { + type empty; + description + "Use message-digest authentication."; + } + leaf null { + type empty; + description + "Use null authentication."; + } + } + list message-digest-key { + key "key_id"; + + leaf key_id { + type uint8; + description + "Key id"; + } + leaf mds-key { + type string; + description + "The OSPF password."; + } + } + leaf authentication-key { + type string; + description + "The OSPF password."; + } + } + + grouping virtual-link-group { + list virtual-link { + key "neighbor area_id"; + description + "Virtual link parameters."; + + leaf neighbor { + type inet:ipv4-address; + description + "Router ID of the remote ABR."; + } + leaf area_id { + type inet:ipv4-address; + } + + uses authentication-group; + + + container timers { + leaf dead-interval { + type uint16; + description + "Interval time after which a neighbor is declared down."; + } + leaf hello-interval { + type uint16; + description + "Time between HELLO packets."; + } + leaf retransmit-interval { + type uint16; + description + "Time between retransmitting lost link state advertisements."; + } + leaf transmit-delay { + type uint16; + description + "Link state transmit delay."; + } + } + } + } + + grouping area-groupings { + container areas { + list area { + key "area_id"; + description + "A list of area objects"; + + leaf area_id { + type inet:ipv4-address; + } + container authentication { + presence "Enable authentication"; + + leaf message-digest { + type empty; + description + "Use message-digest authentication"; + } + } + leaf default-cost { + type uint32 { + range "0..16777215"; + } + description + "Advertised default summary cost"; + } + leaf export-list { + type access-list-ref; + description + "Filter for networks announced to other areas."; + } + leaf import-list { + type access-list-ref; + description + "Filter for networks from other areas announced to the specified one."; + } + container filter-list { + leaf prefix { + type plist-ref; + description + "Filter networks between OSPF areas."; + } + leaf in { + type empty; + } + leaf out { + type empty; + } + } + + uses nssa-grouping; + uses range-grouing; + uses stub-grouping; + uses shortcut-grouping; + uses virtual-link-group; + } + } + } + + + /* router ospf attributes */ + grouping route-ospf-leaf-attributes { + leaf auto-cost-reference-bandwidth { + type uint32 { + range "1..4294967"; + } + description + "The reference bandwidth in terms of Mbits per second."; + } + leaf capability-opaque { + type empty; + description + "Opaque LSA."; + } + leaf compatible-rfc1583 { + type empty; + description + "Compatible with RFC 1583."; + } + leaf default-metric { + type uint32 { + range "0..16777214"; + } + description + "Metric of redistributed routes."; + } + leaf write-multiplier { + type uint8 { + range "1..100"; + } + description + "Maximum number of interface serviced per write."; + } + container router-info { + leaf as { + type empty; + description + "Enable the Router Information functionality with Area flooding scope."; + } + leaf area { + type inet:ipv4-address; + description + "Enable the Router Information functionality with AS flooding scope."; + } + } + } + + grouping metric_common_group { + leaf metric { + type uint32 { + range "0..16777214"; + } + description + "OSPF default metric."; + } + leaf metric-type { + type enumeration { + enum "type-1" { + value 1; + } + enum "type-2" { + value 2; + } + } + description + "Metric type (1/2)."; + } + leaf route-map { + type rmap-ref; + description + "Route map reference."; + } + } + + grouping default-info-group { + container default-inforamtion { + leaf originte { + type empty; + description + "Distribute a default route"; + } + leaf always { + type empty; + description + "Always advertise default route."; + } + uses metric_common_group; + } + } + + grouping redistribute-group { + list redistribute { + key "protocol"; + leaf protocol { + type frr-route-types:frr-route-types-v4; + description + "Protocol."; + } + uses metric_common_group; + } + } + + grouping distance_group { + container distance { + leaf admin-value { + type uint8 { + range "1..255"; + } + description + "Admin value."; + } + container ospf { + leaf external { + type uint8 { + range "1..255"; + } + description + "Distance for external routes."; + } + leaf inter-area { + type uint8 { + range "1..255"; + } + description + "Distance for inter-area routes."; + } + leaf intra-area { + type uint8 { + range "1..255"; + } + description + "Distance for intra-area routes."; + } + } + } + } + + grouping distribute-list-group { + container distribute-list { + list dlist { + key "name protocol"; + leaf name { + type string; + description + "Filter networks in routing updates."; + } + leaf protocol { + type frr-route-types:frr-route-types-v4; + description + "Protocol."; + } + leaf out { + type empty; + description + "In direction."; + } + leaf in { + type empty; + description + "Out direction."; + } + } + } + } + + grouping max-metric-group { + container max-metric { + container router-lsa { + description + "Advertise own Router-LSA with infinite distance (stub router)."; + leaf administrative { + type empty; + description + "Administratively applied, for an indefinite period."; + } + leaf on-shutdown { + type uint8 { + range "5..100"; + } + description + "Advertise stub-router prior to full shutdown of OSPF."; + } + leaf on-startup { + type uint32 { + range "5..86400"; + } + description + "Automatically advertise stub Router-LSA on startup of OSPF."; + } + } + } + } + + grouping mpls-te-group { + container mpls-te { + leaf on { + type empty; + description + "Enable the MPLS-TE functionality."; + + } + leaf router-address { + type inet:ipv4-address; + description + "Stable IP address of the advertising router."; + } + container inrer-as { + leaf as { + type empty; + description + "AS native mode self originate INTER_AS LSA with Type 11 (as flooding scope)."; + } + leaf area { + type inet:ipv4-address; + description + "AREA native mode self originate INTER_AS LSA with Type 10 (area flooding scope)."; + } + } + } + } + + grouping ospf-group { + container ospf { + leaf abr-type { + type enumeration { + enum "cisco" { + value 1; + description + "Alternative ABR, cisco implementation."; + } + enum "ibm" { + value 2; + description + "Alternative ABR, IBM implementation."; + } + enum "shortcut" { + value 3; + description + "Shortcut ABR."; + } + enum "standard" { + value 4; + description + "Standard behavior (RFC2328)."; + } + } + } + leaf opaque-lsa { + type empty; + description + "Enable the Opaque-LSA capability (rfc2370)"; + } + leaf rfc1583compatibility { + type empty; + description + "Enable the RFC1583Compatibility flag."; + } + leaf router-id { + type inet:ipv4-address; + description + "Router-id for the OSPF process."; + } + leaf write-multiplier { + type uint8 { + range "1..100"; + } + description + "Write multiplier."; + } + } + } + + grouping timer-group { + container timers { + leaf refresh-interval { + type uint16 { + range "10..1800"; + } + description + "Timer value in seconds."; + } + leaf lsa-min-interval { + type uint32 { + range "0..600000"; + } + description + "Minimum delay in receiving new version of a LSA."; + } + container throttle { + leaf lsa-all { + type uint16 { + range "0..5000"; + } + description + "LSA delay between transmissions."; + } + leaf spf { + type uint32 { + range "0..600000"; + } + description + "Delay from first change received till SPF calculation."; + } + } + } + } + + grouping segment-routing-group { + container segment-routing { + container global-block { + description + "Segment Routing Global Block label range."; + leaf lower-bound { + type uint32 { + range "0..1048575"; + } + } + leaf upper-bound { + type uint32 { + range "0..1048575"; + } + } + } + leaf node-msd { + type uint8 { + range "1..16"; + } + description + "Maximum Stack Depth for this router."; + } + leaf on { + type empty; + description + "Enable Segment Routing."; + } + list indices { + key "index"; + leaf index { + type uint16; + description + "SID index for this prefix."; + } + leaf prefix { + type inet:ipv4-prefix; + description + "Prefix SID."; + } + leaf no-php-flag { + type empty; + description + "Don't request Penultimate Hop Popping (PHP)."; + } + } + } + } + + grouping ospf-list-group { + list neighbor { + key "ip"; + description + "Neighbor list."; + leaf ip { + type inet:ipv4-address; + description + "Neighbor IP address."; + } + leaf priority { + type uint8; + description + "Neighbor Priority."; + } + leaf poll-interval { + type uint16 { + range "1..65535"; + } + description + "Dead Neighbor Polling interval."; + } + } + list network { + key "prefix"; + description + "Enable routing on list of IP network."; + leaf prefix { + type inet:ipv4-prefix; + description + "Prefix on which routing needs to be enabled."; + } + leaf area { + type inet:ipv4-address; + description + "Area ID for this network."; + } + } + list passive-interface { + key "interface"; + description + "Suppress routing updates on list interface."; + leaf interface { + type frr-interface:interface-ref; + description + "Suppress routing updates on an interface."; + } + leaf address { + type inet:ipv4-address; + description + "Interface address."; + } + } + } + + grouping cpe-group { + container cpe { + description + "PCE Router Information."; + + leaf address { + type inet:ipv4-address; + description + "IP address of the PCE."; + } + list domain { + key "as"; + leaf as { + type uint16; + description + "AS number where the PCE as visibilities for path computation."; + } + } + list neighbor { + key "as"; + leaf as { + type uint16; + description + "AS number of PCE neighbors."; + } + } + leaf flag { + type uint32; + description + "Capabilities of the PCE for path computation."; + } + leaf scope { + type uint32; + description + "Path scope visibilities of the PCE for path computation."; + } + } + } + + + grouping interface-ospf-attribute-group { + leaf area { + description + "Ospf area ID."; + type inet:ipv4-address; + } + uses authentication-group; + leaf cost { + description + "Interface cost"; + type uint16 { + range "1..65535"; + } + } + container dead-interval { + leaf interval { + type uint16 { + range "1..65535"; + } + } + container minimal { + leaf hello-multiplier { + type uint8 { + range "1..10"; + } + } + } + } + leaf hello-interval { + description + "Time between HELLO packets."; + type uint16 { + range "1..65535"; + } + } + leaf retransmit-interval { + type uint16; + description + "Time between retransmitting lost link state advertisements."; + } + leaf transmit-delay { + type uint16; + description + "Link state transmit delay."; + } + leaf mtu-ignore { + description + "Disable MTU mismatch detection on this interface."; + type empty; + } + leaf priority { + description + "Router priority."; + type uint8; + } + } + + grouping inteface-ospf-group { + list instance { + key "id"; + leaf id { + type uint16; + description + "Ospf instance ID."; + } + leaf bfd { + description + "BFD support."; + type empty; + } + leaf network { + type enumeration { + enum "broadcast" { + value 1; + } + enum "non-broadcast" { + value 2; + } + enum "point-to-multipoint" { + value 3; + } + enum "point-to-point" { + value 4; + } + } + } + uses interface-ospf-attribute-group; + + list interface-address { + key "address"; + leaf address { + description + "Address of interface"; + type inet:ipv4-address; + } + + uses interface-ospf-attribute-group; + + } + } + } + + augment "/frr-rt:routing/frr-rt:control-plane-protocols/" + + "frr-rt:control-plane-protocol" { + container ospf { + when "../frr-rt:type = 'frr-ospfd:ospf'" { + description + "This container is only valid for the 'ospf' routing + protocol."; + } + description + "Support for a 'ospf' pseudo-protocol instance + consists of a list of routes."; + + list instance { + key "id"; + description + "List of ospf instance."; + + leaf id { + type uint16; + description + "Ospf instance ID."; + } + + uses route-ospf-leaf-attributes; + uses default-info-group; + uses redistribute-group; + uses distance_group; + uses distribute-list-group; + uses max-metric-group; + uses mpls-te-group; + uses ospf-group; + uses timer-group; + uses segment-routing-group; + uses ospf-list-group; + uses cpe-group; + uses area-groupings; + } + } + } + + /* + * Per-interface configuration data + */ + augment "/frr-interface:lib/frr-interface:interface" { + container ospf { + description + "OSPF interface parameters."; + uses inteface-ospf-group; + } + } + +}