Move interface acls to separate yang module
[honeycomb.git] / v3po / api / src / main / yang / v3po.yang
1 module v3po {
2   yang-version 1;
3   namespace "urn:opendaylight:params:xml:ns:yang:v3po";
4   prefix "v3po";
5
6   revision "2016-12-14" {
7     description
8       "This revision adds the following new features:
9        - ingress/egress ACLs support
10        - default-action and interface-mode type as a part of ietf-acl configuration";
11   }
12
13   revision "2015-01-05" {
14     description "Initial revision of v3po model";
15   }
16
17   import iana-if-type {
18     prefix "ianaift";
19   }
20   import ietf-interfaces {
21     prefix "if";
22   }
23   import ietf-yang-types {
24     prefix "yang";
25   }
26   import ietf-inet-types {
27     prefix "inet";
28   }
29   import ietf-ip {
30     prefix "ip";
31   }
32   import yang-ext {
33     prefix "ext";
34   }
35   import vpp-acl {
36     prefix "vpp-acl";
37   }
38
39   typedef bridge-domain-ref {
40     type leafref {
41       path "/vpp/bridge-domains/bridge-domain/name";
42     }
43     description
44       "This type is used by to reference a bridge domain table";
45   }
46
47   typedef bridged-virtual-interface-ref {
48     type leafref {
49       path "/if:interfaces/if:interface/l2/bridged-virtual-interface";
50     }
51     description
52       "This type is used by to reference a bridged virtual interface";
53   }
54
55   identity vxlan-tunnel {
56     base if:interface-type;
57   }
58
59   identity gre-tunnel {
60     base if:interface-type;
61   }
62
63   identity vhost-user {
64     base if:interface-type;
65   }
66
67   identity tap {
68     base if:interface-type;
69   }
70
71   identity l2-fib-action {
72     description "Base identity for l2-fib actions";
73   }
74
75   identity l2-fib-forward {
76     base l2-fib-action;
77     description
78       "Forwards packet with configured mac address";
79   }
80
81   identity l2-fib-filter {
82     base l2-fib-action;
83     description
84       "Drops packet with configured mac address";
85   }
86
87   typedef l2-fib-action {
88     type identityref {
89       base "l2-fib-action";
90     }
91     description "Identifies a specific L2 FIB action";
92   }
93
94   typedef vxlan-vni {
95     // FIXME: should be in a vxlan-specific model
96     description "VNI used in a VXLAN tunnel";
97     type uint32 {
98       range "0..16777215";
99     }
100   }
101
102   typedef vhost-user-role {
103     type enumeration {
104       enum "server";
105       enum "client";
106     }
107   }
108
109   identity vxlan-gpe-tunnel {
110     base if:interface-type;
111   }
112
113   typedef vxlan-gpe-vni {
114     description "VNI used in a VXLAN-GPE tunnel";
115     type uint32 {
116       range "0..16777215";
117     }
118   }
119
120   typedef vxlan-gpe-next-protocol {
121     type enumeration {
122       enum "ipv4" {
123         value 1;
124       }
125       enum "ipv6" {
126         value 2;
127       }
128       enum "ethernet" {
129         value 3;
130       }
131       enum "nsh" {
132         value 4;
133       }
134     }
135   }
136
137   grouping bridge-domain-attributes {
138     leaf flood {
139       type boolean;
140       default true;
141       description
142       "Enable/disable L2 flooding.";
143     }
144     leaf forward {
145       type boolean;
146       default true;
147       description
148       "Enable/disable L2 forwarding.";
149     }
150     leaf learn {
151       type boolean;
152       default true;
153       description
154       "Enable/disable L2 learning.";
155     }
156     leaf unknown-unicast-flood {
157       type boolean;
158       default true;
159     }
160     leaf arp-termination {
161       type boolean;
162       default false;
163     }
164
165     container arp-termination-table {
166       when "../v3po:arp-termination = 'true'";
167
168       // TODO(HONEYCOMB-133): add support for read (after VPP-230 is done)
169       list arp-termination-table-entry {
170         key "ip-address phys-address";
171         leaf ip-address {
172           // FIXME: change to ip-address-no-zone after https://bugs.opendaylight.org/show_bug.cgi?id=6413 is resolved
173           type inet:ip-address;
174         }
175         leaf phys-address {
176           type yang:phys-address;
177         }
178       }
179     }
180   }
181
182   // TODO express constraints for L2 FIB entries in YANG if possible
183   grouping l2-fib-attributes {
184     container l2-fib-table {
185       list l2-fib-entry {
186         key "phys-address";
187
188         leaf phys-address {
189           type yang:phys-address;
190         }
191
192         leaf outgoing-interface {
193           type string;
194           // mandatory true;
195           // mandatory for forward action
196           // FIXME VPP's CLI does not require to set iface id for filter action
197           // VPP's binary api in constrast to CLI does some checks on the iface id value,
198           // so currently it has to be set for all actions
199           description
200             "One of interfaces assigned to the FIB table's bridge-domain.";
201         }
202         leaf static-config {
203           type boolean;
204           default false;
205           description
206             "Static entries cannot be overridden by mac learning.";
207         }
208         leaf action {
209           type l2-fib-action;
210           mandatory true;
211           description
212             "L2 FIB action. For filter action, entry must be configured as static.";
213         }
214         leaf bridged-virtual-interface {
215           when "../action = 'forward'";
216           type boolean;
217           config false; // FIXME setting bvi is currently not supported by VPP's binary api
218         }
219       }
220     }
221   }
222
223   grouping tap-interface-base-attributes {
224     leaf tap-name {
225       type string{
226         pattern "[a-zA-Z0-9\-;.+@$#^&*!_()=\[\]]*";
227       }
228     }
229   }
230
231   grouping tap-interface-config-attributes {
232     leaf mac {
233       type yang:phys-address;
234       mandatory false;
235       description "Mac address to be set for the tap interface. Random will be used if not configured";
236     }
237
238     leaf device-instance {
239       type uint32;
240       mandatory false;
241       description "Custom device instance. Autogenerated will be used if not configured";
242     }
243   }
244
245   grouping ethernet-base-attributes {
246     leaf mtu {
247       type uint16 {
248         range "64..9216";
249       }
250       units "octets";
251       default 9216;
252       description
253       "The size, in octets, of the largest packet that the
254        hardware interface will send and receive.";
255     }
256   }
257
258   grouping ethernet-state-attributes {
259     leaf manufacturer-description {
260       type string;
261       config false;
262     }
263     leaf duplex {
264       type enumeration {
265         enum "half";
266         enum "full";
267       }
268       config false;
269     }
270   }
271
272   grouping vhost-user-interface-base-attributes {
273     leaf socket {
274       type string {
275         length 1..255;
276       }
277     }
278     leaf role {
279       type vhost-user-role;
280       default "server";
281     }
282     description "vhost-user settings";
283   }
284
285   grouping vhost-user-interface-state-attributes {
286     leaf features {
287       type uint64;
288       config false;
289     }
290     leaf virtio-net-hdr-size {
291       type uint32;
292       config false;
293     }
294     leaf num-memory-regions {
295       type uint32;
296       config false;
297     }
298     leaf connect-error {
299       type string;
300       config false;
301     }
302   }
303
304   grouping vxlan-base-attributes {
305     // FIXME: this should be in an vxlan-specific extension
306     leaf src {
307       /*mandatory true;*/
308       type inet:ip-address;
309     }
310     leaf dst {
311       /*mandatory true;*/
312       type inet:ip-address;
313     }
314     leaf vni {
315       /*mandatory true;*/
316       type vxlan-vni;
317     }
318     leaf encap-vrf-id {
319       type uint32;
320     }
321   }
322
323   grouping gre-base-attributes {
324     leaf src {
325       /*mandatory true;*/
326       type inet:ip-address;
327     }
328     leaf dst {
329       /*mandatory true;*/
330       type inet:ip-address;
331     }
332     leaf outer-fib-id {
333       type uint32;
334     }
335   }
336
337   grouping vxlan-gpe-base-attributes {
338     leaf local {
339       /*mandatory true;*/
340       type inet:ip-address;
341     }
342     leaf remote {
343       /*mandatory true;*/
344       type inet:ip-address;
345     }
346     leaf vni {
347       /*mandatory true;*/
348       type vxlan-gpe-vni;
349     }
350     leaf next-protocol {
351       type vxlan-gpe-next-protocol;
352     }
353     leaf encap-vrf-id {
354       type uint32;
355     }
356     leaf decap-vrf-id {
357       type uint32;
358     }
359   }
360
361   grouping l2-base-attributes {
362       description
363       "Parameters for configuring Layer2 features on interfaces.";
364
365       choice interconnection {
366         case xconnect-based {
367           leaf xconnect-outgoing-interface {
368             /* Don't allow selection of this interface */
369             must "../../if:name != current()";
370             type if:interface-ref; // todo use interface-state-ref for operational data?
371             description
372               "L2 xconnect mode";
373           }
374         }
375         case bridge-based {
376           leaf bridge-domain {
377             type bridge-domain-ref;
378             mandatory true;
379             description
380               "Interfaces in a bridge-domain forward packets to other
381                interfaces in the same bridge-domain based on
382                destination mac address.";
383           }
384           leaf split-horizon-group {
385             when "../bridge-domain";
386             type uint8 {
387               range "0..255";
388             }
389             default 0; //no split horizon group
390             description
391               "Interface's split-horizon group. Interfaces in the same
392                bridge-domain and split-horizon group can not forward
393                packets between each other. ";
394           }
395           leaf bridged-virtual-interface {
396             when "../bridge-domain";
397             type boolean;
398             default false;
399             description
400               "Interface forward packets in the bridge-domain
401                associated with the BVI.";
402           }
403         }
404       }
405   }
406
407   grouping proxy-arp-attributes {
408         description
409         "Parameters for configuring Proxy ARP on interfaces.";
410
411       leaf vrf-id {
412         type uint32;
413         default 0;
414       }
415       leaf low-addr {
416           type inet:ipv4-address;
417       }
418       leaf high-addr {
419           type inet:ipv4-address;
420       }
421   }
422
423   augment /if:interfaces/if:interface {
424     ext:augment-identifier "vpp-interface-augmentation";
425
426     // FIXME using ietf-interfaces model for vpp interfaces makes it hard to implement because:
427     // 1. The link between interface type and this augmentation is unclear
428     // 2. Only this augmentation with combination of ifc type is trigger to do something for vpp, what if user only configures base interface stuff ? + We need to get leaves defined by ietf-interfaces when we are processing this augment
429     // 3. The ietf-interfaces model does not define groupings which makes types reuse difficult
430
431     container tap {
432       when "../if:type = 'v3po:tap'";
433       uses tap-interface-base-attributes;
434       uses tap-interface-config-attributes;
435     }
436
437     container ethernet {
438       when "../if:type = 'ianaift:ethernetCsmacd'";
439       uses ethernet-base-attributes;
440     }
441
442     container routing {
443       leaf vrf-id { // todo no routing info for oper, is it possible to get it from the vpp?
444         type uint32;
445         default 0;
446       }
447     }
448
449     container vhost-user {
450       when "../if:type = 'v3po:vhost-user'";
451       uses vhost-user-interface-base-attributes;
452     }
453
454     container vxlan {
455       when "../if:type = 'v3po:vxlan-tunnel'";
456       uses vxlan-base-attributes;
457     }
458
459     container gre {
460       when "../if:type = 'v3po:gre-tunnel'";
461       uses gre-base-attributes;
462     }
463
464     container l2 {
465       must "(not (../if:ipv4[if:enabled = 'true']/if:address/if:ip) and " +
466       "not (../if:ipv6[if:enabled = 'true']/if:address/if:ip))";
467
468       uses l2-base-attributes;
469     }
470
471     container vxlan-gpe {
472       when "../if:type = 'v3po:vxlan-gpe-tunnel'";
473
474       uses vxlan-gpe-base-attributes;
475     }
476
477     container proxy-arp {
478       uses proxy-arp-attributes;
479     }
480
481     container acl {
482       container ingress {
483         uses vpp-acl:acl-base-attributes;
484       }
485       container egress {
486         uses vpp-acl:acl-base-attributes;
487       }
488     }
489
490     container ietf-acl {
491       container ingress {
492         uses vpp-acl:ietf-acl-base-attributes;
493       }
494       container egress {
495         uses vpp-acl:ietf-acl-base-attributes;
496       }
497     }
498   }
499
500   container vpp {
501     description
502     "VPP config data";
503
504     container bridge-domains {
505       list bridge-domain {
506         key "name";
507
508         leaf name {
509           type string;
510         }
511
512         uses bridge-domain-attributes;
513         uses l2-fib-attributes;
514
515         description
516           "bridge-domain configuration";
517       }
518     }
519   }
520
521   augment /if:interfaces-state/if:interface {
522     ext:augment-identifier "vpp-interface-state-augmentation";
523
524     leaf description {
525       type string;
526     }
527
528     container tap {
529       when "../if:type = 'v3po:tap'";
530       uses tap-interface-base-attributes;
531     }
532
533     container ethernet {
534       when "../if:type = 'ianaift:ethernetCsmacd'";
535       uses ethernet-base-attributes;
536       uses ethernet-state-attributes;
537     }
538
539     container vhost-user {
540       when "../if:type = 'v3po:vhost-user'";
541       uses vhost-user-interface-base-attributes;
542       uses vhost-user-interface-state-attributes;
543     }
544
545     container vxlan {
546       when "../if:type = 'v3po:vxlan-tunnel'";
547       uses vxlan-base-attributes;
548     }
549     container vxlan-gpe {
550       when "../if:type = 'v3po:vxlan-gpe-tunnel'";
551
552       uses vxlan-gpe-base-attributes;
553     }
554
555     container gre {
556       when "../if:type = 'gre-tunnel'";
557       uses gre-base-attributes;
558     }
559
560     container l2 {
561       must "(not (../if:ipv4[if:enabled = 'true']/if:address/if:ip) and " +
562       "not (../if:ipv6[if:enabled = 'true']/if:address/if:ip))";
563
564       uses l2-base-attributes;
565     }
566
567     container proxy-arp {
568       uses proxy-arp-attributes;
569     }
570
571     container acl {
572       container ingress {
573         uses vpp-acl:acl-base-attributes;
574       }
575       container egress {
576         uses vpp-acl:acl-base-attributes;
577       }
578     }
579
580     container ietf-acl {
581       container ingress {
582         uses vpp-acl:ietf-acl-base-attributes;
583       }
584       container egress {
585         uses vpp-acl:ietf-acl-base-attributes;
586       }
587     }
588   }
589
590   augment /if:interfaces-state/if:interface/if:statistics {
591     ext:augment-identifier "vpp-interface-statistics-augmentation";
592     leaf in-errors-no-buf {
593       type yang:counter64;
594     }
595     leaf in-errors-miss {
596       type yang:counter64;
597     }
598     leaf out-discards-fifo-full {
599       type yang:counter64;
600     }
601   }
602
603   container vpp-state {
604     config false;
605
606     description
607       "VPP operational data";
608
609     container bridge-domains {
610       // FIXME: Should this live in bridge-domain.yang in a modular fashion ?
611       list bridge-domain {
612
613         key "name";
614         leaf name {
615           type string;
616         }
617
618         uses bridge-domain-attributes;
619         uses l2-fib-attributes;
620
621         description
622           "bridge-domain operational data";
623       }
624     }
625
626     container version {
627       leaf name {
628         type string;
629       }
630       leaf build-directory {
631         type string;
632       }
633       leaf build-date {
634         type string;
635       }
636       leaf branch {
637         type string;
638       }
639       description
640       "vlib version info";
641     }
642   }
643
644   // VPP Notifications
645
646   typedef interface-status {
647     type enumeration {
648       enum up {
649         value 1;
650       }
651       enum down {
652         value 0;
653       }
654     }
655   }
656
657   typedef interface-name-or-index {
658     type union {
659       type string;
660       type uint32;
661     }
662   }
663
664   notification interface-state-change {
665     leaf name {
666         type interface-name-or-index;
667     }
668
669     leaf admin-status {
670         type interface-status;
671     }
672
673     leaf oper-status {
674         type interface-status;
675     }
676   }
677
678   notification interface-deleted {
679     leaf name {
680         type interface-name-or-index;
681     }
682   }
683 }