-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
sonic-vlan.yang
294 lines (237 loc) · 6.12 KB
/
sonic-vlan.yang
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
module sonic-vlan {
yang-version 1.1;
namespace "http://github.com/sonic-net/sonic-vlan";
prefix vlan;
import ietf-inet-types {
prefix inet;
}
import ietf-yang-types {
prefix yang;
}
import sonic-types {
prefix stypes;
}
import sonic-extension {
prefix ext;
}
import sonic-port {
prefix port;
revision-date 2019-07-01;
}
import sonic-portchannel {
prefix lag;
}
import sonic-vrf {
prefix vrf;
}
import sonic-mirror-session {
prefix sms;
}
import sonic-interface {
prefix intf;
}
description "VLAN yang Module for SONiC OS";
revision 2024-03-07 {
description "Add Constraints that are implemented in CLI";
}
revision 2021-04-28 {
description "Modify Vlan name constraint to allow only legal Vlan names";
}
revision 2021-04-22 {
description "Modify Vlan Member to include PortChannel along with Port";
}
revision 2021-03-30 {
description "Modify the type of vrf name";
}
revision 2019-07-01 {
description "First Revision";
}
container sonic-vlan {
container VLAN_INTERFACE {
description "VLAN_INTERFACE part of config_db.json";
list VLAN_INTERFACE_LIST {
description "VLAN INTERFACE part of config_db.json with vrf";
key "name";
leaf name {
type leafref {
path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name";
}
}
leaf vrf_name {
type leafref{
path "/vrf:sonic-vrf/vrf:VRF/vrf:VRF_LIST/vrf:name";
}
}
leaf nat_zone {
description "NAT Zone for the vlan interface";
type uint8 {
range "0..3" {
error-message "Invalid nat zone for the vlan interface.";
error-app-tag nat-zone-invalid;
}
}
default "0";
}
leaf mpls {
description "Enable/disable MPLS routing for the vlan interface";
type enumeration {
enum enable;
enum disable;
}
}
leaf grat_arp {
type string {
pattern "enabled|disabled";
}
}
leaf proxy_arp {
type string {
pattern "enabled|disabled";
}
}
leaf ipv6_use_link_local_only {
description "Enable/Disable IPv6 link local address on vlan interface";
type stypes:mode-status;
default disable;
}
leaf loopback_action {
description "Packet action when a packet ingress and gets routed on the same IP interface";
type stypes:loopback_action;
}
}
/* end of VLAN_INTERFACE_LIST */
list VLAN_INTERFACE_IPPREFIX_LIST {
key "name ip-prefix";
leaf name {
/* This node must be present in VLAN_INTERFACE_LIST */
must "(current() = ../../VLAN_INTERFACE_LIST[name=current()]/name)"
{
error-message "Must condition not satisfied, Try adding Vlan<vlanid>: {}, Example: 'Vlan100': {}";
}
type leafref {
path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name";
}
}
leaf ip-prefix {
type union {
type stypes:sonic-ip4-prefix;
type stypes:sonic-ip6-prefix;
}
}
leaf scope {
type enumeration {
enum global;
enum local;
}
}
leaf family {
/* family leaf needed for backward compatibility
Both ip4 and ip6 address are string in IETF RFC 6021,
so must statement can check based on : or ., family
should be IPv4 or IPv6 according.
*/
must "(contains(../ip-prefix, ':') and current()='IPv6') or
(contains(../ip-prefix, '.') and current()='IPv4')";
type stypes:ip-family;
}
leaf secondary {
description "Optional field to specify if the prefix is secondary subnet";
type boolean;
}
}
/* end of VLAN_INTERFACE_IPPREFIX_LIST */
}
/* end of VLAN_INTERFACE container */
container VLAN {
description "VLAN part of config_db.json";
list VLAN_LIST {
key "name";
leaf name {
type string {
pattern 'Vlan(409[0-5]|40[0-8][0-9]|[1-3][0-9]{3}|[1-9][0-9]{2}|[1-9][0-9]|[2-9])';
}
}
leaf vlanid {
type uint16 {
range 2..4094;
}
must "substring-after(../name, 'Vlan') = current()"{
error-message "The vlanid must correspond to the VLAN name";
}
}
leaf alias {
type string;
}
leaf description {
type string {
length 1..255;
}
}
leaf-list dhcp_servers {
description "Configure the dhcp v4 servers";
type inet:ip-address;
}
leaf-list dhcpv6_servers {
description "Configure the dhcp v6 servers";
type inet:ipv6-address;
}
leaf mtu {
type uint16 {
range 1..9216;
}
}
leaf admin_status {
type stypes:admin_status;
}
leaf mac {
type yang:mac-address;
}
}
/* end of VLAN_LIST */
}
/* end of container VLAN */
container VLAN_MEMBER {
description "VLAN_MEMBER part of config_db.json";
list VLAN_MEMBER_LIST {
key "name port";
leaf name {
type leafref {
path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name";
}
}
leaf port {
/* key elements are mandatory by default */
type union {
type leafref {
path "/port:sonic-port/port:PORT/port:PORT_LIST/port:name";
}
type leafref {
path "/lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name";
}
}
must "not(/sms:sonic-mirror-session/sms:MIRROR_SESSION/sms:MIRROR_SESSION_LIST[sms:dst_port=current()])"
{
error-message "Port is used as a destination port in a mirror session.";
}
must "not(/lag:sonic-portchannel/lag:PORTCHANNEL_MEMBER/lag:PORTCHANNEL_MEMBER_LIST[lag:port=current()]/lag:name)" {
error-message "Port is a member of a port channel.";
}
must "not(/intf:sonic-interface/intf:INTERFACE/intf:INTERFACE_LIST[intf:name=current()])" {
error-message "Port is a router interface.";
}
must "count(../../vlan:VLAN_MEMBER_LIST[vlan:port=current() and vlan:tagging_mode='untagged']) <= 1" {
error-message "Port can be untagged in at most one VLAN.";
}
}
leaf tagging_mode {
mandatory true;
type stypes:vlan_tagging_mode;
}
}
/* end of list VLAN_MEMBER_LIST */
}
/* end of container VLAN_MEMBER */
}
/* end of container sonic-vlan */
}
/* end of module sonic-vlan */