-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
Copy pathsonic-pbh.yang
268 lines (215 loc) · 5.8 KB
/
sonic-pbh.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
module sonic-pbh {
yang-version 1.1;
namespace "https://github.com/sonic-net/sonic-pbh";
prefix pbh;
import ietf-inet-types {
prefix inet;
}
import sonic-types {
prefix stypes;
}
import sonic-port {
prefix port;
}
import sonic-portchannel {
prefix lag;
}
description "PBH YANG Module for SONiC OS: hashing for NVGRE & VxLAN with IPv4/IPv6 inner 5-tuple";
revision 2021-04-23 {
description "First Revision";
}
typedef hash-field {
description "Represents native hash field";
type stypes:hash-field {
enum INNER_IP_PROTOCOL;
enum INNER_L4_DST_PORT;
enum INNER_L4_SRC_PORT;
enum INNER_DST_IPV4;
enum INNER_SRC_IPV4;
enum INNER_DST_IPV6;
enum INNER_SRC_IPV6;
}
}
typedef packet-action {
description "Represents packet action";
type enumeration {
enum SET_ECMP_HASH;
enum SET_LAG_HASH;
}
}
typedef flow-counter {
description "Represents flow counter state";
type enumeration {
enum DISABLED;
enum ENABLED;
}
}
container sonic-pbh {
container PBH_HASH_FIELD {
description "PBH_HASH_FIELD part of config_db.json";
list PBH_HASH_FIELD_LIST {
key "hash_field_name";
leaf hash_field_name {
description "The name of this hash field";
type string {
length 1..255;
}
}
leaf hash_field {
description "Configures native hash field for this hash field";
mandatory true;
type pbh:hash-field;
}
leaf ip_mask {
description "Configures IPv4/IPv6 address mask for this hash field";
mandatory true;
type inet:ip-address-no-zone;
must "(boolean(../hash_field[.='INNER_DST_IPV4' or .='INNER_SRC_IPV4']) and contains(current(), '.'))
or (boolean(../hash_field[.='INNER_DST_IPV6' or .='INNER_SRC_IPV6']) and contains(current(), ':'))";
when "boolean(../hash_field[.='INNER_DST_IPV4' or .='INNER_SRC_IPV4' or .='INNER_DST_IPV6' or .='INNER_SRC_IPV6'])";
}
leaf sequence_id {
description "Configures in which order the fields are hashed and defines which fields should be associative";
mandatory true;
type uint32;
}
}
/* end of PBH_HASH_FIELD_LIST */
}
/* end of container PBH_HASH_FIELD */
container PBH_HASH {
description "PBH_HASH part of config_db.json";
list PBH_HASH_LIST {
key "hash_name";
leaf hash_name {
description "The name of this hash";
type string {
length 1..255;
}
}
leaf-list hash_field_list {
description "The list of hash fields to apply with this hash";
min-elements 1;
type leafref {
path "/pbh:sonic-pbh/pbh:PBH_HASH_FIELD/pbh:PBH_HASH_FIELD_LIST/pbh:hash_field_name";
}
}
}
/* end of PBH_HASH_LIST */
}
/* end of container PBH_HASH */
container PBH_RULE {
description "PBH_RULE part of config_db.json";
list PBH_RULE_LIST {
key "table_name rule_name";
leaf table_name {
description "The name of table which holds this rule";
type leafref {
path "/pbh:sonic-pbh/pbh:PBH_TABLE/pbh:PBH_TABLE_LIST/pbh:table_name";
}
}
leaf rule_name {
description "The name of this rule";
type string {
length 1..255;
}
}
leaf priority {
description "Configures priority for this rule";
mandatory true;
type uint32;
}
leaf gre_key {
description "Configures packet match for this rule: GRE key (value/mask)";
type string {
pattern "(0x){1}[a-fA-F0-9]{1,8}/(0x){1}[a-fA-F0-9]{1,8}";
}
}
leaf ether_type {
description "Configures packet match for this rule: EtherType (IANA Ethertypes)";
type string {
pattern "(0x){1}[a-fA-F0-9]{1,4}";
}
}
leaf ip_protocol {
description "Configures packet match for this rule: IP protocol (IANA Protocol Numbers)";
type string {
pattern "(0x){1}[a-fA-F0-9]{1,2}";
}
}
leaf ipv6_next_header {
description "Configures packet match for this rule: IPv6 Next header (IANA Protocol Numbers)";
type string {
pattern "(0x){1}[a-fA-F0-9]{1,2}";
}
}
leaf l4_dst_port {
description "Configures packet match for this rule: L4 destination port";
type string {
pattern "(0x){1}[a-fA-F0-9]{1,4}";
}
}
leaf inner_ether_type {
description "Configures packet match for this rule: inner EtherType (IANA Ethertypes)";
type string {
pattern "(0x){1}[a-fA-F0-9]{1,4}";
}
}
leaf hash {
description "The hash to apply with this rule";
mandatory true;
type leafref {
path "/pbh:sonic-pbh/pbh:PBH_HASH/pbh:PBH_HASH_LIST/pbh:hash_name";
}
}
leaf packet_action {
description "Configures packet action for this rule";
type pbh:packet-action;
default "SET_ECMP_HASH";
}
leaf flow_counter {
description "Enables/Disables packet/byte counter for this rule";
type pbh:flow-counter;
default "DISABLED";
}
}
/* end of PBH_RULE_LIST */
}
/* end of container PBH_RULE */
container PBH_TABLE {
description "PBH_TABLE part of config_db.json";
list PBH_TABLE_LIST {
key "table_name";
leaf table_name {
description "The name of this table";
type string {
length 1..255;
}
}
leaf-list interface_list {
description "Interfaces to which this table is applied";
min-elements 1;
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";
}
}
}
leaf description {
description "The description of this table";
mandatory true;
type string {
length 1..255;
}
}
}
/* end of PBH_TABLE_LIST */
}
/* end of container PBH_TABLE */
}
/* end of container sonic-pbh */
}
/* end of module sonic-pbh */