module ietf-flexible-encapsulation {
namespace
"urn:ietf:params:xml:ns:yang:ietf-flexible-encapsulation";
prefix flex;
import ietf-interfaces {
prefix if;
}
import ietf-interfaces-common {
prefix if-cmn;
}
import ieee802-dot1q-types {
prefix dot1q-types;
}
organization
"IETF NETMOD (NETCONF Data Modeling Language) Working Group";
contact
"WG Web:
WG List:
WG Chair: Lou Berger
WG Chair: Kent Watsen
Editor: Robert Wilton
";
description
"This YANG module describes interface configuration for flexible
VLAN matches and rewrites.";
revision 2016-10-21 {
description "Latest draft revision";
reference
"Internet-Draft draft-wilton-netmod-intf-vlan-yang-04";
}
feature flexible-encapsulation-rewrites {
description
"This feature indicates whether the network element supports
flexible Ethernet encapsulation that allows for matching VLAN
ranges and performing independent tag manipulations";
}
feature flexible-rewrites {
description
"This feature indicates whether the network element supports
specifying flexible rewrite operations";
}
feature asymmetric-rewrites {
description
"This feature indicates whether the network element supports
specifying different rewrite operations for the ingress
rewrite operation and egress rewrite operation.";
}
feature tag-rewrites {
description
"This feature indicates whether the network element supports
the flexible rewrite functionality specifying flexible tag
rewrites";
}
/*
* flexible-match grouping.
*
* This grouping represents a flexible match.
*
* The rules for a flexible match are:
* 1. default, untagged, priority tag, or a stack of tags.
* - Each tag in the stack of tags matches:
* 1. tag type (802.1Q or 802.1ad) +
* 2. tag value:
* i. single tag
* ii. set of tag ranges/values.
* iii. "any" keyword
*/
grouping flexible-match {
description "Flexible match";
choice match-type {
mandatory true;
description "Provides a choice of how the frames may be
matched";
case default {
description "Default match";
leaf default {
type empty;
description
"Default match. Matches all traffic not matched to any
other peer sub-interface by a more specific
encapsulation.";
} // leaf default
} // case default
case untagged {
description "Match untagged Ethernet frames only";
leaf untagged {
type empty;
description
"Untagged match. Matches all untagged traffic.";
} // leaf untagged
} // case untagged
case priority-tagged {
description "Match priority tagged Ethernet frames only";
container priority-tagged {
description "Priority tag match";
leaf tag-type {
type dot1q-types:dot1q-tag-type;
description "The 802.1Q tag type of matched priority
tagged packets";
}
}
}
case vlan-tagged {
container vlan-tagged {
description "Matches VLAN tagged frames";
list tag {
must 'index != 0 or ' +
'count(../tag/index) != 2 or ' +
'dot1q-tag/tag-type = "s-vlan"' {
error-message
"When matching two tags, the outer tag must be of
S-VLAN tag type";
description
"For IEEE 802.1Q interoperability, when matching two
tags, it is required that the outer tag is an
S-VLAN, and the inner tag is a C-VLAN";
}
must 'index != 1 or ' +
'count(../tag/index) != 2 or ' +
'dot1q-tag/tag-type = "c-vlan"' {
error-message
"When matching two tags, the inner tag must be of
C-VLAN tag type";
description
"For IEEE 802.1Q interoperability, when matching two
tags, it is required that the outer tag is an
S-VLAN, and the inner tag is a C-VLAN";
}
key "index";
min-elements 1;
max-elements 2;
description "The tags to match, with the outermost tag to
match assigned index 0";
leaf index {
type uint8 {
range "0..1";
}
must ". = 0 or
count(../../tag[index = 0]/index) > 0" {
error-message "An inner tag can only be matched on
when also matching on an outer tag";
description "Only allow matching on an inner tag, if
also matching on the outer tags at the
same time";
}
description
"The index into the tag stack, outermost tag first";
}
uses dot1q-types:dot1q-tag-ranges-or-any-classifier;
}
leaf match-exact-tags {
type empty;
description
"If set, indicates that all 802.1Q VLAN tags in the
Ethernet frame header must be explicitly matched, i.e.
the EtherType following the matched tags must not be a
802.1Q tag EtherType. If unset then extra 802.1Q VLAN
tags are allowed.";
}
}
}
} // encaps-type
}
/*
* Grouping for tag-rewrite that can be expressed either
* symmetrically, or in the ingress and/or egress directions
* independently.
*/
grouping tag-rewrite {
description "Flexible rewrite";
leaf pop-tags {
type uint8 {
range 1..2;
}
description "The number of tags to pop (or translate if used in
conjunction with push-tags)";
}
list push-tags {
must 'index != 0 or ' +
'count(../push-tags/index) != 2 or ' +
'dot1q-tag/tag-type = "s-vlan"' {
error-message
"When pushing two tags, the outer tag must be of
S-VLAN tag type";
description
"For IEEE 802.1Q interoperability, when pushing two
tags, it is required that the outer tag is an
S-VLAN, and the inner tag is a C-VLAN";
}
must 'index != 1 or ' +
'count(../push-tags/index) != 2 or ' +
'dot1q-tag/tag-type = "c-vlan"' {
error-message
"When pushing two tags, the inner tag must be of
C-VLAN tag type";
description
"For IEEE 802.1Q interoperability, when pushing two
tags, it is required that the outer tag is an
S-VLAN, and the inner tag is a C-VLAN";
}
key "index";
max-elements 2;
description "The number of tags to push (or translate if used
in conjunction with pop-tags)";
/*
* Server should order by increasing index.
*/
leaf index {
type uint8 {
range 0..1;
}
/*
* Only allow a push of an inner tag if an outer tag is also
* being pushed.
*/
must ". != 0 or
count(../../push-tags[index = 0]/index) > 0" {
error-message "An inner tag can only be pushed if an outer
tag is also specified";
description "Only allow a push of an inner tag if an outer
tag is also being pushed";
}
description "The index into the tag stack";
}
uses dot1q-types:dot1q-tag-classifier;
}
}
/*
* Grouping for all flexible rewrites of fields in the L2 header.
*
* This currently only includes flexible tag rewrites, but is
* designed to be extensible to cover rewrites of other fields in
* the L2 header if required.
*/
grouping flexible-rewrite {
description "Flexible rewrite";
/*
* Tag rewrite.
*
* All tag rewrites are formed using a combination of pop-tags
* and push-tags operations.
*/
container tag-rewrite {
if-feature tag-rewrites;
description "Tag rewrite. Translate operations are expressed
as a combination of tag push and pop operations.";
uses tag-rewrite;
}
}
augment "/if:interfaces/if:interface/if-cmn:encapsulation/" +
"if-cmn:encaps-type" {
when "../if:type = 'if-cmn:ethSubInterface' and
../if-cmn:transport-layer = 'layer-2'" {
description "Applies only to Ethernet sub-interfaces that are
operating at transport layer 2";
}
description
"Add flexible match and rewrite for VLAN sub-interfaces";
/*
* A flexible encapsulation allows for the matching of ranges and
* sets of VLAN Ids. The structure is also designed to be
* extended to allow for matching/rewriting other fields within
* the L2 frame header if required.
*/
case flexible {
if-feature flexible-encapsulation-rewrites;
description "Flexible encapsulation and rewrite";
container flexible {
description "Flexible encapsulation and rewrite";
container match {
description
"The match used to classify frames to this interface";
uses flexible-match;
}
container rewrite {
if-feature flexible-rewrites;
description "L2 frame rewrite operations";
choice direction {
description "Whether the rewrite policy is symmetrical or
asymmetrical";
case symmetrical {
container symmetrical {
uses flexible-rewrite;
description
"Symmetrical rewrite. Expressed in the ingress
direction, but the reverse operation is applied
to egress traffic";
}
}
/*
* Allow asymmetrical rewrites to be specified.
*/
case asymmetrical {
if-feature asymmetric-rewrites;
description "Asymmetrical rewrite";
container ingress {
uses flexible-rewrite;
description "Ingress rewrite";
}
container egress {
uses flexible-rewrite;
description "Egress rewrite";
}
}
}
}
}
}
}
augment "/if:interfaces/if:interface" {
when "if:type = 'if-cmn:ethSubInterface' and
if-cmn:transport-layer = 'layer-2'" {
description "Any L2 Ethernet sub-interfaces";
}
description "Add flexible encapsulation configuration for VLAN
sub-interfaces";
/*
* All flexible encapsulation specific interface configuration
* (except for the actual encapsulation and rewrite) is contained
* by a flexible-encapsulation container on the interface.
*/
container flexible-encapsulation {
description
"All per interface flexible encapsulation related fields";
/*
* For encapsulations that match a range of VLANs (or Any),
* allow configuration to specify the default VLAN tag values
* to use for any traffic that is locally sourced from an
* interface on the device.
*/
container local-traffic-default-encaps {
description "The VLAN tags to use by default for locally
sourced traffic";
list tag {
key "index";
max-elements 2;
description
"The VLAN tags to use by locally sourced traffic";
leaf index {
type uint8 {
range "0..1";
}
/*
* Only allow an inner tag to be specified if an outer
* tag has also been specified.
*/
must ". = 0 or
count(../../tag[index = 0]/index) > 0" {
error-message "An inner tag can only be specified if an
outer tag has also been specified";
description "Ensure that an inner tag cannot be
specified without an outer tag'";
}
description "The index into the tag stack, outermost tag
assigned index 0";
}
uses dot1q-types:dot1q-tag-classifier;
}
}
}
}
}