Skip to content

Commit 544ca84

Browse files
committed
yang: leaf-list needs to use ordered-by user
RFC 7950 defines an ordered-by clause when a list needs to maintain its order: https://datatracker.ietf.org/doc/html/rfc7950#section-7.7.7 The default ordering is "system", which means the user specified order doesn't need to be preserved. Prior to this libyang commit there was no difference between system and user ordering: CESNET/libyang@6cf1d16 Since SONiC depends on list ordering being maintained, either explicitly due to the order actually mattering, or implicitly due to the reverse translation performed during config valiation, we need to tag all leaf-list references as `ordered-by user`.
1 parent 20d3bd8 commit 544ca84

22 files changed

+51
-2
lines changed

src/sonic-yang-models/yang-models/sonic-bgp-allowed-prefix.yang

+8
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,13 @@ module sonic-bgp-allowed-prefix {
9696

9797
leaf-list prefixes_v4 {
9898
type bgp-allowed-ipv4-prefix;
99+
ordered-by user;
99100
description "BGP V4 allowed prefix list";
100101
}
101102

102103
leaf-list prefixes_v6 {
103104
type bgp-allowed-ipv6-prefix;
105+
ordered-by user;
104106
description "BGP V6 allowed prefix list";
105107
}
106108
}
@@ -139,11 +141,13 @@ module sonic-bgp-allowed-prefix {
139141

140142
leaf-list prefixes_v4 {
141143
type bgp-allowed-ipv4-prefix;
144+
ordered-by user;
142145
description "BGP V4 allowed prefix list";
143146
}
144147

145148
leaf-list prefixes_v6 {
146149
type bgp-allowed-ipv6-prefix;
150+
ordered-by user;
147151
description "BGP V6 allowed prefix list";
148152
}
149153
}
@@ -175,11 +179,13 @@ module sonic-bgp-allowed-prefix {
175179

176180
leaf-list prefixes_v4 {
177181
type bgp-allowed-ipv4-prefix;
182+
ordered-by user;
178183
description "BGP V4 allowed prefix list";
179184
}
180185

181186
leaf-list prefixes_v6 {
182187
type bgp-allowed-ipv6-prefix;
188+
ordered-by user;
183189
description "BGP V6 allowed prefix list";
184190
}
185191
}
@@ -223,11 +229,13 @@ module sonic-bgp-allowed-prefix {
223229

224230
leaf-list prefixes_v4 {
225231
type bgp-allowed-ipv4-prefix;
232+
ordered-by user;
226233
description "BGP V4 allowed prefix list";
227234
}
228235

229236
leaf-list prefixes_v6 {
230237
type bgp-allowed-ipv6-prefix;
238+
ordered-by user;
231239
description "BGP V6 allowed prefix list";
232240
}
233241
}

src/sonic-yang-models/yang-models/sonic-bgp-common.yang

+2
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ module sonic-bgp-common {
386386
type leafref {
387387
path "/rmap:sonic-route-map/rmap:ROUTE_MAP_SET/rmap:ROUTE_MAP_SET_LIST/rmap:name";
388388
}
389+
ordered-by user;
389390
description "Route-map filter for incoming routes";
390391
max-elements 1;
391392
}
@@ -394,6 +395,7 @@ module sonic-bgp-common {
394395
type leafref {
395396
path "/rmap:sonic-route-map/rmap:ROUTE_MAP_SET/rmap:ROUTE_MAP_SET_LIST/rmap:name";
396397
}
398+
ordered-by user;
397399
description "Route-map filter for outgoing routes";
398400
max-elements 1;
399401
}

src/sonic-yang-models/yang-models/sonic-bgp-global.yang

+1
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ module sonic-bgp-global {
304304
type uint32 {
305305
range "1..4294967295";
306306
}
307+
ordered-by user;
307308
description
308309
"Peer ASs in BGP confederation";
309310
}

src/sonic-yang-models/yang-models/sonic-bgp-peerrange.yang

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ module sonic-bgp-peerrange {
5656

5757
leaf-list ip_range {
5858
type stypes:sonic-ip-prefix;
59+
ordered-by user;
5960
description "A range of addresses";
6061
}
6162
}

src/sonic-yang-models/yang-models/sonic-bgp-sentinel.yang

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ module sonic-bgp-sentinel {
5050

5151
leaf-list ip_range {
5252
type stypes:sonic-ip-prefix;
53+
ordered-by user;
5354
description "A range of addresses";
5455
}
5556
}

src/sonic-yang-models/yang-models/sonic-buffer-port-egress-profile-list.yang

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ module sonic-buffer-port-egress-profile-list {
4646
type leafref {
4747
path "/bpf:sonic-buffer-profile/bpf:BUFFER_PROFILE/bpf:BUFFER_PROFILE_LIST/bpf:name";
4848
}
49+
ordered-by user;
4950
description "a list of references to BUFFER_PROFILE_TABLE object for a port";
5051
}
5152

src/sonic-yang-models/yang-models/sonic-buffer-port-ingress-profile-list.yang

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ module sonic-buffer-port-ingress-profile-list {
4646
type leafref {
4747
path "/bpf:sonic-buffer-profile/bpf:BUFFER_PROFILE/bpf:BUFFER_PROFILE_LIST/bpf:name";
4848
}
49+
ordered-by user;
4950
description "a list of references to BUFFER_PROFILE_TABLE object for a port";
5051
}
5152

src/sonic-yang-models/yang-models/sonic-dash.yang

+6
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ module sonic-dash {
6464

6565
leaf-list address_spaces {
6666
type stypes:sonic-ip-prefix;
67+
ordered-by user;
6768
}
6869

6970
} /* end of list DASH_VNET_LIST */
@@ -270,28 +271,33 @@ module sonic-dash {
270271
leaf-list ip_protocol {
271272
description "IP Protocol (tcp or udp or icmp etc)";
272273
type stypes:ip-protocol-type;
274+
ordered-by user;
273275
}
274276

275277
leaf-list src_addr {
276278
type stypes:sonic-ip-prefix;
279+
ordered-by user;
277280
}
278281

279282
leaf-list dst_addr {
280283
type stypes:sonic-ip-prefix;
284+
ordered-by user;
281285
}
282286

283287
leaf-list src_port {
284288
description "List of L4 source port range as pattern '0-65365'";
285289
type string {
286290
pattern '([0-9]{1,4}|[0-5][0-9]{4}|[6][0-4][0-9]{3}|[6][5][0-2][0-9]{2}|[6][5][3][0-5]{2}|[6][5][3][6][0-5])-([0-9]{1,4}|[0-5][0-9]{4}|[6][0-4][0-9]{3}|[6][5][0-2][0-9]{2}|[6][5][3][0-5]{2}|[6][5][3][6][0-5])';
287291
}
292+
ordered-by user;
288293
}
289294

290295
leaf-list dst_port {
291296
description "List of L4 dst port range as pattern '0-65365'";
292297
type string {
293298
pattern '([0-9]{1,4}|[0-5][0-9]{4}|[6][0-4][0-9]{3}|[6][5][0-2][0-9]{2}|[6][5][3][0-5]{2}|[6][5][3][6][0-5])-([0-9]{1,4}|[0-5][0-9]{4}|[6][0-4][0-9]{3}|[6][5][0-2][0-9]{2}|[6][5][3][0-5]{2}|[6][5][3][6][0-5])';
294299
}
300+
ordered-by user;
295301
}
296302

297303
} /* end of list DASH_ACL_RULE_LIST */

src/sonic-yang-models/yang-models/sonic-device_metadata.yang

+1
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ module sonic-device_metadata {
252252

253253
leaf-list supporting_bulk_counter_groups {
254254
type string;
255+
ordered-by user;
255256
description "This field contains a list of counter groups that support bulk operation.";
256257
}
257258

src/sonic-yang-models/yang-models/sonic-dhcp-server-ipv4.yang

+4
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ module sonic-dhcp-server-ipv4 {
9696
type leafref {
9797
path "/dhcp-server-ipv4:sonic-dhcp-server-ipv4/dhcp-server-ipv4:DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS/dhcp-server-ipv4:DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS_LIST/dhcp-server-ipv4:name";
9898
}
99+
ordered-by user;
99100
}
100101

101102
leaf state {
@@ -186,6 +187,7 @@ module sonic-dhcp-server-ipv4 {
186187
leaf-list range {
187188
description "Range of IPs";
188189
type inet:ipv4-address;
190+
ordered-by user;
189191
}
190192

191193
must "((count(range) <= 2) and (count(range) >= 1))";
@@ -232,6 +234,7 @@ module sonic-dhcp-server-ipv4 {
232234
error-message "Statement of 'ips' and 'ranges' cannot both exist";
233235
}
234236
type inet:ipv4-address;
237+
ordered-by user;
235238
}
236239

237240
leaf-list ranges {
@@ -242,6 +245,7 @@ module sonic-dhcp-server-ipv4 {
242245
type leafref {
243246
path "/dhcp-server-ipv4:sonic-dhcp-server-ipv4/dhcp-server-ipv4:DHCP_SERVER_IPV4_RANGE/dhcp-server-ipv4:DHCP_SERVER_IPV4_RANGE_LIST/dhcp-server-ipv4:name";
244247
}
248+
ordered-by user;
245249
}
246250
}
247251
/* end of DHCP_SERVER_IPV4_PORT_LIST */

src/sonic-yang-models/yang-models/sonic-dhcpv6-relay.yang

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ module sonic-dhcpv6-relay {
3737
leaf-list dhcpv6_servers {
3838
description "Configure the dhcp v6 servers";
3939
type inet:ipv6-address;
40+
ordered-by user;
4041
}
4142

4243
leaf rfc6939_support {

src/sonic-yang-models/yang-models/sonic-hash.yang

+2
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,13 @@ module sonic-hash {
5454
leaf-list ecmp_hash {
5555
description "Hash fields for hashing packets going through ECMP";
5656
type hash:hash-field;
57+
ordered-by user;
5758
}
5859

5960
leaf-list lag_hash {
6061
description "Hash fields for hashing packets going through LAG";
6162
type hash:hash-field;
63+
ordered-by user;
6264
}
6365

6466
leaf ecmp_hash_algorithm {

src/sonic-yang-models/yang-models/sonic-mgmt_interface.yang

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ module sonic-mgmt_interface {
5555
type stypes:sonic-ip-prefix;
5656
type inet:ip-address;
5757
}
58-
58+
ordered-by user;
5959
description
6060
"This configuration allows addtional routes to be added to default VRF table
6161
or mgmt VRF table, based on if Management VRF is configured.

src/sonic-yang-models/yang-models/sonic-ntp.yang

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ module sonic-ntp {
109109
pattern 'eth0';
110110
}
111111
}
112-
112+
ordered-by user;
113113
description
114114
"This is the interface whose IP address is used as the source IP address for
115115
generating NTP traffic. User is required to make sure that the NTP server

src/sonic-yang-models/yang-models/sonic-pbh.yang

+2
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ module sonic-pbh {
120120
type leafref {
121121
path "/pbh:sonic-pbh/pbh:PBH_HASH_FIELD/pbh:PBH_HASH_FIELD_LIST/pbh:hash_field_name";
122122
}
123+
ordered-by user;
123124
}
124125

125126
}
@@ -248,6 +249,7 @@ module sonic-pbh {
248249
path "/lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name";
249250
}
250251
}
252+
ordered-by user;
251253
}
252254

253255
leaf description {

src/sonic-yang-models/yang-models/sonic-port.yang

+2
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ module sonic-port{
136136
pattern "all";
137137
}
138138
}
139+
ordered-by user;
139140
}
140141

141142
must "(count(adv_speeds[text()='all']) = 0) or (count(adv_speeds) = 1)";
@@ -155,6 +156,7 @@ module sonic-port{
155156
pattern "all";
156157
}
157158
}
159+
ordered-by user;
158160
}
159161

160162
must "(count(adv_interface_types[text()='all']) = 0) or (count(adv_interface_types) = 1)";

src/sonic-yang-models/yang-models/sonic-route-common.yang

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ module sonic-route-common {
6161
type leafref {
6262
path "/rmap:sonic-route-map/rmap:ROUTE_MAP_SET/rmap:ROUTE_MAP_SET_LIST/rmap:name";
6363
}
64+
ordered-by user;
6465
max-elements 1;
6566
description "Router filter to apply while redistributing the routes from another protocol.";
6667
}

src/sonic-yang-models/yang-models/sonic-route-map.yang

+4
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,15 @@ module sonic-route-map {
210210
pattern 'Vlan([0-9]{1,3}|[1-3][0-9]{3}|[4][0][0-8][0-9]|[4][0][9][0-4])';
211211
}
212212
}
213+
ordered-by user;
213214
description
214215
"IP addresse or interface for match operation.";
215216
max-elements 1;
216217
}
217218

218219
leaf-list match_tag {
219220
type uint32;
221+
ordered-by user;
220222
description
221223
"Value of the tag match member";
222224
max-elements 1;
@@ -326,6 +328,7 @@ module sonic-route-map {
326328

327329
leaf-list set_community_inline {
328330
type string;
331+
ordered-by user;
329332
description "Set community string";
330333
}
331334

@@ -338,6 +341,7 @@ module sonic-route-map {
338341

339342
leaf-list set_ext_community_inline {
340343
type string;
344+
ordered-by user;
341345
description "Set extended community string";
342346
}
343347

src/sonic-yang-models/yang-models/sonic-routing-policy-sets.yang

+3
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ module sonic-routing-policy-sets {
150150

151151
leaf-list community_member {
152152
type string;
153+
ordered-by user;
153154
description
154155
"members of the community set.";
155156
}
@@ -190,6 +191,7 @@ module sonic-routing-policy-sets {
190191

191192
leaf-list community_member {
192193
type string;
194+
ordered-by user;
193195
description
194196
"members of the community set.";
195197
}
@@ -214,6 +216,7 @@ module sonic-routing-policy-sets {
214216

215217
leaf-list as_path_set_member {
216218
type string;
219+
ordered-by user;
217220
description
218221
"AS path expression -- list of ASes in the set";
219222
}

src/sonic-yang-models/yang-models/sonic-suppress-asic-sdk-health-event.yang

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ module sonic-suppress-asic-sdk-health-event {
5151
enum cpu_hw;
5252
enum asic_hw;
5353
}
54+
ordered-by user;
5455
description "Category of the ASIC/SDK health event to suppress";
5556
}
5657
}

src/sonic-yang-models/yang-models/sonic-vlan.yang

+2
Original file line numberDiff line numberDiff line change
@@ -218,11 +218,13 @@ module sonic-vlan {
218218
leaf-list dhcp_servers {
219219
description "Configure the dhcp v4 servers";
220220
type inet:ip-address;
221+
ordered-by user;
221222
}
222223

223224
leaf-list dhcpv6_servers {
224225
description "Configure the dhcp v6 servers";
225226
type inet:ipv6-address;
227+
ordered-by user;
226228
}
227229

228230
leaf mtu {

src/sonic-yang-models/yang-templates/sonic-acl.yang.j2

+5
Original file line numberDiff line numberDiff line change
@@ -302,11 +302,13 @@ module sonic-acl {
302302

303303
leaf-list MATCHES {
304304
type string;
305+
ordered-by user;
305306
min-elements 1;
306307
}
307308

308309
leaf-list ACTIONS {
309310
type string;
311+
ordered-by user;
310312
default "";
311313
}
312314

@@ -315,6 +317,7 @@ module sonic-acl {
315317
enum PORT;
316318
enum PORTCHANNEL;
317319
}
320+
ordered-by user;
318321
min-elements 1;
319322
}
320323
}
@@ -357,6 +360,7 @@ module sonic-acl {
357360

358361
leaf-list services {
359362
type string;
363+
ordered-by user;
360364
}
361365

362366
/* Validating 'services' exist if ACL type is 'CTRLPLANE' */
@@ -375,6 +379,7 @@ module sonic-acl {
375379
pattern "";
376380
}
377381
}
382+
ordered-by user;
378383
/* Today in SONiC, we do not delete the list once
379384
* created, instead we set to empty list. Due to that
380385
* below default values are needed.

0 commit comments

Comments
 (0)