aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/yang/openconfig/openconfig-network-instance.yang
blob: 0d42a11ccfb266bef8c2819f11b5adf67ba9ac51 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
module openconfig-network-instance {

  yang-version "1";

  // namespace
  namespace "http://openconfig.net/yang/network-instance";

  prefix "oc-netinst";

  // import some basic types
  //import ietf-inet-types { prefix inet; }
  import ietf-yang-types { prefix "yang"; }
  import ietf-inet-types { prefix "inet"; }
  import openconfig-network-instance-types { prefix "oc-ni-types"; }
  import openconfig-policy-types { prefix "oc-pol-types"; }
  import openconfig-routing-policy { prefix "oc-rpol"; }
  import openconfig-local-routing { prefix "oc-loc-rt"; }
  import openconfig-interfaces { prefix "oc-if"; }
  import openconfig-extensions { prefix "oc-ext"; }
  import openconfig-network-instance-l3 { prefix "oc-ni-l3"; }
  import openconfig-types { prefix "oc-types"; }
  import openconfig-bgp { prefix "oc-bgp"; }
  import openconfig-mpls { prefix "oc-mpls"; }
  import openconfig-vlan { prefix "oc-vlan"; }
  import openconfig-ospfv2 { prefix "oc-ospfv2"; }
  import openconfig-policy-forwarding { prefix "oc-pf"; }
  import openconfig-segment-routing { prefix "oc-sr"; }
  import openconfig-isis { prefix "oc-isis"; }
  import openconfig-aft { prefix "oc-aft"; }
  import openconfig-pim { prefix "oc-pim"; }
  import openconfig-igmp { prefix "oc-igmp"; }

  // include submodules
  include openconfig-network-instance-l2;

  // meta
  organization "OpenConfig working group";

  contact
    "OpenConfig working group
    www.openconfig.net";

  description
    "An OpenConfig description of a network-instance. This may be
    a Layer 3 forwarding construct such as a virtual routing and
    forwarding (VRF) instance, or a Layer 2 instance such as a
    virtual switch instance (VSI). Mixed Layer 2 and Layer 3
    instances are also supported.";

  oc-ext:openconfig-version "0.11.0";

  revision "2018-08-11" {
    description
      "Add vlan id as additional key in MAC table";
    reference "0.11.0";
  }

  revision "2018-06-22" {
    description
      "Fix typo in OSPF when statement";
    reference "0.10.2";
  }

  revision "2018-06-05" {
    description
      "Fix bugs in when statements";
    reference "0.10.1";
  }

  revision "2018-02-19" {
    description
      "Add PIM and IGMP to network instance";
    reference "0.10.0";
  }

  revision "2017-12-13" {
    description
      "Fix incorrect constraint on SR and MPLS containers";
    reference "0.9.0";
  }

  revision "2017-08-24" {
    description
      "Minor formatting fixes";
    reference "0.8.1";
  }

  revision "2017-02-28" {
    description
      "Add OSPFv2 to network instance";
    reference "0.8.0";
  }

  revision "2017-01-26" {
    description
      "Add policy forwarding to network instance";
    reference "0.7.0";
  }

  revision "2017-01-13" {
    description
      "Add AFT to the network instance";
    reference "0.6.0";
  }

  revision "2016-12-15" {
    description
      "Add segment routing to network instance";
    reference "0.5.0";
  }

  revision "2016-11-10" {
    description
      "Add IS-IS to OpenConfig network instance";
    reference "0.4.1";
  }

  revision "2016-10-12" {
    description
      "Update table connections";
    reference "0.4.0";
  }

  revision "2016-09-28" {
    description
      "Change L2 instance to submodule; add MAC table";
    reference "0.3.0";
  }

  revision "2016-08-11" {
    description
      "Resolve repeated container names in routing protocols";
    reference "0.2.3";
  }

  revision "2016-07-08" {
    description
      "Updated with refactored routing protocol models";
    reference "0.2.1";
  }

  revision "2016-03-29" {
    description
      "Initial revision";
    reference "0.2.0";
  }

  revision "2015-10-18" {
    description
      "Initial revision";
    reference "0.1.0";
  }

  typedef network-instance-ref {
    type leafref {
      path "/network-instances/network-instance/config/name";
    }
    description
      "A re-usable type that can be referenced within other
       modules that references a network instance.";
  }

  grouping network-instance-top {
    description
      "Top-level grouping containing a list of network instances.";

    container network-instances {
      description
        "The L2, L3, or L2+L3 forwarding instances that are
        configured on the local system";

      list network-instance {
        key "name";

        description
          "Network instances configured on the local system";

        leaf name {
          type leafref {
            path "../config/name";
          }
          description
            "A unique name identifying the network instance";
        }

        uses l2ni-instance {
            when "config/type = 'L2VSI' or config/type = 'L2P2P'" +
                 " or config/type = 'L2L3' or config/type = 'DEFAULT_INSTANCE'" {
                    description
                      "Layer 2 configuration parameters included when
                      a network instance is a Layer 2 instance or a
                      combined L2L3 instance";
            }
        }

        container config {
          description
            "Configuration parameters relating to a network
            instance";
          uses network-instance-config;
          uses network-instance-type-dependent-config;
        }


        container state {
          config false;
          description
            "Operational state parameters relating to a network
            instance";
          uses network-instance-config;
          uses network-instance-type-dependent-config;
          uses network-instance-state;
        }

        container encapsulation {
          when "../config/type != 'DEFAULT_INSTANCE'" {
            description
              "Only allow the encapsulation of the instance to be
              set when the instance is not the default instance";
          }
          description
            "Configuration parameters relating to the encapsulation
            used for the network instance";

          container config {
            description
              "Configuration parameters relating to the encapsulation
              of the network instance";

            uses encapsulation-config;

            uses l2ni-encapsulation-config {
              when "../../config/type = 'L2VSI' or ../../config/type = 'L2P2P'
                      or ../../config/type = 'L2L3'" {
                        description
                          "Only allow L2 encapsulations to be set
                          when the instance is of a type that supports
                          L2";
              }
            }
          }

          container state {
            config false;
            description
              "State parameters relating to the encapsulation of
              the network instance";
            uses encapsulation-config;

            uses l2ni-encapsulation-config {
              when "../../config/type = 'L2VSI' or ../../config/type = 'L2P2P'
                      or ../../config/type = 'L2L3'" {
                        description
                          "Only allow L2 encapsulations to be set
                          when the instance is of a type that supports
                          L2";
              }
            }
          }
        }

        container inter-instance-policies {
          description
            "Policies dictating how RIB or FIB entries are imported
            to and exported from this instance";

          uses oc-rpol:apply-policy-group;
        }

        container table-connections {
          description
            "Policies dictating how RIB or FIB entries are propagated
            between tables";

          list table-connection {
            key "src-protocol dst-protocol address-family";

            description
              "A list of connections between pairs of routing or
              forwarding tables, the leaking of entries between
              which is specified by the import policy.

              A connection connecting a source table to a destination
              table implies that routes that match the policy specified
              for the connection are available for the destination
              protocol to advertise, or match within its policies.";

            leaf src-protocol {
              type leafref {
                path "../config/src-protocol";
              }
              description
                "The name of the protocol associated with the table
                which should be utilised as the source of forwarding
                or routing information";
            }

            leaf dst-protocol {
              type leafref {
                path "../config/dst-protocol";
              }
              description
                "The table to which routing entries should be
                exported";
            }

            leaf address-family {
              type leafref {
                path "../config/address-family";
              }
              description
                "The address family associated with the connection";
            }

            container config {
              description
                "Configuration parameters relating to the connection
                between tables";
              uses inter-table-policies-config;
            }
            container state {
              config false;
              description
                "State parameters relating to the connection between
                tables";
              uses inter-table-policies-config;
            }
          }
        }

        container interfaces {
          description
            "The interfaces that are associated with this network
            instance";

          list interface {
            key "id";
            unique "config/interface config/subinterface";

            description
              "An interface associated with the network instance";

            leaf id {
              type leafref {
                path "../config/id";
              }
              description
                "A reference to an identifier for this interface which
                acts as a key for this list";
            }

            container config {
              description
                "Configuration parameters relating to the associated
                interface";
              uses instance-interfaces-config;
            }

            container state {
              config false;
              description
                "Operational state parameters relating to the
                associated interface";

              uses instance-interfaces-config;
              uses instance-interfaces-state;
            }
          }
        }

        uses oc-ni-l3:l3ni-route-limit-structural {
          when "type = 'L3VRF' or type = 'L2L3'" {
            description
              "Layer 3 VRF or L2/L3 instances can have route limits
              applied. This is not supported for the default instance.";
          }
        }

        container tables {
          description
            "The routing tables that are managed by this network
            instance";

          list table {
            key "protocol address-family";

            description
              "A network instance manages one or more forwarding or
              routing tables. These may reflect a Layer 2 forwarding
              information base, a Layer 3 routing table, or an MPLS
              LFIB.

              The table populated by a protocol within an instance is
              identified by the protocol identifier (e.g., BGP, IS-IS)
              and the address family (e.g., IPv4, IPv6) supported by
              that protocol. Multiple instances of the same protocol
              populate a single table -- such that
              a single IS-IS or OSPF IPv4 table exists per network
              instance.

              An implementation is expected to create entries within
              this list when the relevant protocol context is enabled.
              i.e., when a BGP instance is created with IPv4 and IPv6
              address families enabled, the protocol=BGP,
              address-family=IPv4 table is created by the system.";

            leaf protocol {
              type leafref {
                path "../config/protocol";
              }
              description
                "A reference to the protocol that populates
                the table";
            }

            leaf address-family {
              type leafref {
                path "../config/address-family";
              }
              description
                "A reference to the address-family that the
                table represents";
            }

            container config {
              description
                "Configuration parameters relating to the
                table";
              uses table-config;
            }

            container state {
              config false;
              description
                "State parameters related to the table";
              uses table-config;
            }
          }
        }

        container connection-points {
          description
            "The set of connection points within a forwarding
            instance";

          list connection-point {
            key "connection-point-id";

            description
              "A connection point within a Layer 2 network instance.
              Each connection-point consists of a set of interfaces
              only one of which is active at any one time. Other than
              the specification of whether an interface is local
              (i.e., exists within this network-instance), or remote,
              all configuration and state parameters are common";

            leaf connection-point-id {
              type leafref {
                path "../config/connection-point-id";
              }
              description
                "A locally significant reference for the
                connection-point";
            }

            container config {
              description
                "Configuration parameters relating to a Layer 2
                network instance connection point";
              uses instance-connection-point-config;
            }
            container state {
              config false;
              description
                "Operational state parameters relating to a Layer 2
                network instance connection point";

              uses instance-connection-point-config;
              uses instance-connection-point-state;
            }

            container endpoints {
              when "../../../config/type = 'L2P2P' " +
                 "or ../../../config/type = 'L2VSI'" {
                description
                  "Configuration parameters to associate interfaces
                   into a common group for use in Layer 2 network
                   instances";
              }

              description
                "The set of endpoints which are grouped within the
                connection point";

              list endpoint {
                key "endpoint-id";

                description
                  "A list of the endpoints (interfaces or remote
                  connection points that can be used for this
                  connection point). The active endpoint is selected
                  based on the precedence that it is configured
                  with";

                leaf endpoint-id {
                  type leafref {
                    path "../config/endpoint-id";
                  }
                  description
                    "A pointer to the configured identifier for the
                    endpoint";
                }

                container config {
                  description
                    "Configuration parameters relating to the
                    endpoint";
                  uses instance-endpoint-config;
                }
                container state {
                  config false;
                  description
                    "Operational state parameters relating to the
                    endpoint";
                  uses instance-endpoint-config;
                  uses instance-endpoint-state;
                }

                container local {
                  when "../config/type = 'LOCAL'" {
                    description
                      "Only include the local configuration when
                      the endpoint is specified to be local to
                      the network element";
                  }

                  description
                    "Configuration and operational state parameters
                    relating to a local interface";

                  container config {
                    description
                      "Configuration parameters relating to a local
                      endpoint";
                    uses instance-endpoint-local-config;
                  }

                  container state {
                    config false;
                    description
                      "Operational state parameters relating to a
                      local endpoint";
                    uses instance-endpoint-local-config;
                  }
                }

                container remote {
                  when "../config/type = 'REMOTE'" {
                    description
                      "Only include the remote configuration when
                      the endpoint is specified to be remote to
                      the network element";
                  }

                  description
                    "Configuration and operational state parameters
                    relating to a remote interface";

                  container config {
                    description
                      "Configuration parameters relating to a remote
                      endpoint";
                    uses instance-endpoint-remote-config;
                  }

                  container state {
                    config false;
                    description
                      "Operational state parameters relating to
                      a remote endpoint";
                    uses instance-endpoint-remote-config;
                  }
                }
              }
            }
          }
        }

        uses oc-mpls:mpls-top {
          when "config/type = 'DEFAULT_INSTANCE'" {
            description
              "MPLS configuration is only valid within the default
              network instance.";
          }
        }

        uses oc-sr:sr-top {
          when "config/type = 'DEFAULT_INSTANCE'" {
            description
              "Segment routing configuration is only valid with the default
              network instance.";
          }
        }

        uses oc-vlan:vlan-top;

        uses oc-pf:policy-forwarding-top;

        uses oc-aft:aft-top;

        container protocols {
          description
            "The routing protocols that are enabled for this
            network-instance.";

          list protocol {
            key "identifier name";

            description
              "A process (instance) of a routing protocol. Some
              systems may not support more than one instance of
              a particular routing protocol";

            leaf identifier {
              type leafref {
                path "../config/identifier";
              }
              description
                "The protocol name for the routing or forwarding
                protocol to be instantiated";
            }

            leaf name {
              type leafref {
                path "../config/name";
              }
              description
                "An operator-assigned identifier for the routing
                or forwarding protocol. For some processes this
                leaf may be system defined.";
            }

            container config {
              description
                "Configuration parameters relating to the routing
                protocol instance";

              uses protocols-config;
            }

            container state {
              config false;
              description
                "State parameters relating to the routing protocol
                instance";

              uses protocols-config;
              uses protocols-state;
            }

            uses oc-loc-rt:local-static-top {
              when "config/identifier = 'STATIC'" {
                description
                  "Include static route parameters only when the
                  protocol is set to static";
              }
              description
                "Configuration and state parameters relating to
                static routes";
            }

            uses oc-loc-rt:local-aggregate-top {
              when "config/identifier = 'LOCAL_AGGREGATE'" {
                description
                  "Include aggregate route parameters only when the
                  protocol is set to aggregate";
              }
              description
                "Configuration and state parameters relating to
                locally generated aggregate routes";
            }

            uses oc-bgp:bgp-top {
              when "config/identifier = 'BGP'" {
                description
                  "Include BGP parameters only when the protocol
                  is of type BGP";
              }
              description
                "Configuration and state parameters relating to
                Border Gateway Protocol (BGP)";
            }

            uses oc-ospfv2:ospfv2-top {
              when "config/identifier = 'OSPF'" {
                description
                  "Include OSPFv2 parameters only when the protocol
                  is of type OSPFv2";
              }
            }

            uses oc-isis:isis-top {
              when "config/identifier = 'ISIS'" {
                description
                  "Include IS-IS configuration when the protocol is of type
                  IS-IS";
              }
              description
                "Configuration and state parameters relating to Intermediate
                System to Intermediate System (IS-IS).";
            }

            uses oc-pim:pim-top {
              when "config/identifier = 'PIM'" {
                description
                  "Include PIM configuration when the protocol is of type
                  PIM";
              }
              description
                "Configuration and state parameters relating to Protocol
                Indepdendent Multicast (PIM).";
            }

            uses oc-igmp:igmp-top {
              when "config/identifier = 'IGMP'" {
                description
                  "Include IGMP configuration when the protocol is of type
                  IGMP";
              }
              description
                "Configuration and state parameters relating to the Internet
                Group Management Protocol (IGMP).";
            }
          }
        }
      }
    }
  }

  grouping network-instance-type-dependent-config {
    description
      "Type dependent network instance configuration";

    uses oc-ni-l3:l3ni-instance-common-config {
      when "type = 'L3VRF' or type = 'L2L3'" {
        description
          "Layer 3 VRF configuration parameters included when a
          network instance is a L3VRF or combined L2L3 instance";
      }
    }

    uses l2ni-instance-common-config {
      when "type = 'L2VSI' or type = 'L2P2P'" +
           " or type = 'L2L3'" {
              description
                "Layer 2 configuration parameters included when
                a network instance is a Layer 2 instance or a
                combined L2L3 instance";
      }
    }
  }

  grouping instance-endpoint-config {
    description
      "Configuration data relating to an forwarding-instance
      endpoint";

    leaf endpoint-id {
      type string;
      description
        "An identifier for the endpoint";
    }

    leaf precedence {
      type uint16;
      description
        "The precedence of the endpoint - the lowest precendence
        viable endpoint will be utilised as the active endpoint
        within a connection";
    }

    leaf type {
      type identityref {
        base "oc-ni-types:ENDPOINT_TYPE";
      }
      description
        "The type of endpoint that is referred to by the current
        endpoint";
    }

  }

  grouping instance-endpoint-local-config {
    description
      "Configuration parameters relating to an endpoint that is local
      to the current system";

      uses oc-if:interface-ref-common;
  }

  grouping instance-endpoint-remote-config {
    description
      "Configuration parameters relating to an endpoint that is
      remote from the local system";
    leaf remote-system {
      type inet:ip-address;
      description
        "The IP address of the device which hosts the
        remote end-point";
    }

    leaf virtual-circuit-identifier {
      type uint32;
      description
        "The virtual-circuit identifier that identifies the
        connection at the remote end-point";
    }
  }

  grouping instance-endpoint-state {
    description
      "Operational state data relating to a forwarding-instance
      endpoint";
    leaf active {
      type boolean;
      description
        "When the backup endpoint is active, the value of this
        parameter is set to true";
    }
  }

  grouping instance-connection-point-config {
    description
      "Configuration data relating to a forwarding-instance
      connection point";

    leaf connection-point-id {
      type string;
      description
        "An identifier for a connection point";
    }
  }

  grouping instance-connection-point-state {
    description
      "Operational state data relating to a forwarding-instance
      connection point";
  }

  grouping table-config {
    description
      "Config parameters relating to an L2/L2.5/L3 table that exists
      within a network instance";

    leaf protocol {
      type leafref {
        path "../../../../protocols/protocol/config/identifier";
      }
      description
        "Reference to the protocol that the table is associated with.";
    }

    leaf address-family {
      type identityref {
        base oc-types:ADDRESS_FAMILY;
      }
      description
        "The address family (IPv4, IPv6) of the table's entries";
    }
  }

  grouping instance-interfaces-config {
    description
      "Configuration parameters related to an interface associated
      with the network instance";

    leaf id {
      type string;
      description
        "A unique identifier for this interface - this is expressed
        as a free-text string";
    }

    uses oc-if:interface-ref-common;

    leaf-list associated-address-families {
      type identityref {
        base oc-types:ADDRESS_FAMILY;
      }
      description
        "The address families on the subinterface which are to be
        associated with this network instance. When this leaf-list
        is empty and the network instance requires Layer 3 information
        the address families for which the network instance is
        enabled should be imported. If the value of this leaf-list
        is specified then the association MUST only be made for
        those address families that are included in the list.";
    }
  }

  grouping instance-interfaces-state {
    description
      "Operational state parameters relating to an interface
      associated with this network instance";
  }

  grouping inter-table-policies-config {
    description
      "Configuration entries that relate to how RIB or FIB entries
      are propagated between tables within the same network
      instance";

    leaf src-protocol {
      type leafref {
        // we are at table-connections/table-connection/config/.
        path "../../../../tables/table/config/protocol";
      }
      description
        "The source protocol for the table connection";
    }

    leaf address-family {
      type leafref {
        // we are at table-connections/table-connection/config/.
        path "../../../../tables/" +
          "table[protocol=current()/../src-protocol]/" +
          "config/address-family";
      }
      description
        "The address family associated with the connection. This
        must be defined for the source protocol. The target
        address family is implicitly defined by the address family
        specified for the source protocol.";
    }

    leaf dst-protocol {
      type leafref {
        path "../../../../tables/table/config/protocol";
      }
      description
        "The destination protocol for the table connection";
    }

    uses oc-rpol:apply-policy-import-config;
  }

  grouping network-instance-config {
    description
      "Configuration parameters relating to a top-level network
      instance";

    leaf name {
      type string;
      description
        "An operator-assigned unique name for the forwarding
        instance";
    }

    leaf type {
      type identityref {
        base "oc-ni-types:NETWORK_INSTANCE_TYPE";
      }
      description
        "The type of network instance. The value of this leaf
        indicates the type of forwarding entries that should be
        supported by this network instance";
    }

    leaf enabled {
      type boolean;
      description
        "Whether the network instance should be configured to be
        active on the network element";
    }

    leaf description {
      type string;
      description
        "A free-form string to be used by the network operator to
        describe the function of this network instance";
    }

    leaf router-id {
      type yang:dotted-quad;
      description
        "A identifier for the local network instance - typically
        used within associated routing protocols or signalling
        routing information in another network instance";
    }

    leaf route-distinguisher {
      type oc-ni-types:route-distinguisher;
      description
        "The route distinguisher that should be used for the local
        VRF or VSI instance when it is signalled via BGP.";
    }
  }

  grouping network-instance-state {
    description
      "Operational state parameters relating to a network instance";
  }

  grouping protocols-config {
    description
      "Configuration parameters relating to a generic protocol
      instance within a network instance";

    leaf identifier {
      type identityref {
        base "oc-pol-types:INSTALL_PROTOCOL_TYPE";
      }
      description
        "The protocol identifier for the instance";
    }

    leaf name {
      type string;
      description
        "A unique name for the protocol instance";
    }

    leaf enabled {
      type boolean;
      description
        "A boolean value indicating whether the local protocol
        instance is enabled.";
    }

    leaf default-metric {
      type uint32;
      description
        "The default metric within the RIB for entries that are
        installed by this protocol instance. This value may
        be overridden by protocol specific configuration options.
        The lower the metric specified the more preferable the RIB
        entry is to be selected for use within the network instance.
        Where multiple entries have the same metric value then these
        equal cost paths should be treated according to the specified
        ECMP path selection behaviour for the instance";
    }
  }

  grouping protocols-state {
    description
      "Operational state parameters relating to a protocol instance";
  }

  grouping instance-interface-association-config {
    description
      "Grouping containing leaves that are to be augmented into an
      interface or subinterface to include mapping to a network
      instance";

    leaf network-instance {
      type leafref {
        path "/network-instances/network-instance/name";
      }
      description
        "The network instance that this interface is associated
        with";
    }
  }

  grouping encapsulation-config {
    description
      "Type agnostic configuration parameters relating to the
      encapsulation of the network instance";

    leaf encapsulation-type {
      type identityref {
        base oc-ni-types:ENCAPSULATION;
      }
      description
        "The on-the-wire encapsulation that should be used when
        sending traffic from this network instance";
    }

    // rjs: This is left here as I suspect that this can
    // be used in EVPN. Need to validate implementations, otherwise
    // move to L3. (TODO)
    leaf label-allocation-mode {
      type identityref {
        base oc-ni-types:LABEL_ALLOCATION_MODE;
      }
      description
        "The label allocation mode to be used for L3 entries
        in the network instance";
    }
  }

  uses network-instance-top;
}