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