Commit 57d8e7c
authored
Field numbers for multi-key leafs pointing to the same field should be unique. (#610)
* Field numbers for multi-key leafs pointing to the same field should be unique.
This OpenConfig snippet is causing duplicate field numbers to be generated due to the list keys both pointing to the same path:
```yang
list inter-area-propagation-policy {
key "src-area dst-area";
description
"A list of connections between pairs of areas - routes are
propagated from the source (src) area to the destination (dst)
area according to the policy specified";
leaf src-area {
type leafref {
path "../config/src-area";
}
description
"Reference to the source area";
}
leaf dst-area {
type leafref {
path "../config/dst-area";
}
description
"Reference to the destination area";
}
```
This change makes `genListKeyProto` use the non-resolved entry path when
determining the field number of its oneof fields. The new
`proto-test-g.yang` file has the following diff after this change:
--- want
+++ got
@@ -28,12 +28,12 @@
}
message ElistKey {
oneof one {
- sint64 one_sint64 = 380657501;
- string one_string = 434013286;
+ sint64 one_sint64 = 278603474;
+ string one_string = 515705169;
}
oneof two {
- sint64 two_sint64 = 380657501;
- string two_string = 434013286;
+ sint64 two_sint64 = 322077556;
+ string two_string = 157954079;
}
Elist elist = 3;
}
I've verified that two fields in a container that both point to the same
leaf doesn't have this problem.
* Only change tag numbers when collision occurs to preserve backwards compatibility
* Update integration test files
* Add comment on what path we're using to generate proto tag numbers1 parent 426a1fd commit 57d8e7c
File tree
5 files changed
+152
-9
lines changed- ygen
- testdata/proto
5 files changed
+152
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2152 | 2152 | | |
2153 | 2153 | | |
2154 | 2154 | | |
| 2155 | + | |
| 2156 | + | |
| 2157 | + | |
| 2158 | + | |
| 2159 | + | |
| 2160 | + | |
| 2161 | + | |
| 2162 | + | |
| 2163 | + | |
| 2164 | + | |
| 2165 | + | |
| 2166 | + | |
2155 | 2167 | | |
2156 | 2168 | | |
2157 | 2169 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1038 | 1038 | | |
1039 | 1039 | | |
1040 | 1040 | | |
1041 | | - | |
| 1041 | + | |
1042 | 1042 | | |
1043 | 1043 | | |
1044 | 1044 | | |
| |||
1128 | 1128 | | |
1129 | 1129 | | |
1130 | 1130 | | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
1131 | 1135 | | |
1132 | 1136 | | |
1133 | 1137 | | |
| |||
1209 | 1213 | | |
1210 | 1214 | | |
1211 | 1215 | | |
1212 | | - | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
1213 | 1228 | | |
1214 | 1229 | | |
1215 | 1230 | | |
| |||
1312 | 1327 | | |
1313 | 1328 | | |
1314 | 1329 | | |
1315 | | - | |
| 1330 | + | |
| 1331 | + | |
1316 | 1332 | | |
1317 | 1333 | | |
1318 | 1334 | | |
1319 | | - | |
| 1335 | + | |
1320 | 1336 | | |
1321 | 1337 | | |
1322 | 1338 | | |
| |||
1344 | 1360 | | |
1345 | 1361 | | |
1346 | 1362 | | |
1347 | | - | |
| 1363 | + | |
1348 | 1364 | | |
1349 | 1365 | | |
1350 | 1366 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1822 | 1822 | | |
1823 | 1823 | | |
1824 | 1824 | | |
1825 | | - | |
1826 | | - | |
1827 | | - | |
| 1825 | + | |
| 1826 | + | |
| 1827 | + | |
| 1828 | + | |
| 1829 | + | |
1828 | 1830 | | |
1829 | 1831 | | |
1830 | 1832 | | |
| |||
1859 | 1861 | | |
1860 | 1862 | | |
1861 | 1863 | | |
| 1864 | + | |
| 1865 | + | |
| 1866 | + | |
| 1867 | + | |
| 1868 | + | |
| 1869 | + | |
| 1870 | + | |
| 1871 | + | |
| 1872 | + | |
| 1873 | + | |
| 1874 | + | |
| 1875 | + | |
| 1876 | + | |
| 1877 | + | |
| 1878 | + | |
| 1879 | + | |
| 1880 | + | |
| 1881 | + | |
| 1882 | + | |
| 1883 | + | |
| 1884 | + | |
| 1885 | + | |
| 1886 | + | |
| 1887 | + | |
| 1888 | + | |
| 1889 | + | |
| 1890 | + | |
| 1891 | + | |
| 1892 | + | |
1862 | 1893 | | |
1863 | 1894 | | |
1864 | 1895 | | |
| |||
2001 | 2032 | | |
2002 | 2033 | | |
2003 | 2034 | | |
2004 | | - | |
| 2035 | + | |
| 2036 | + | |
| 2037 | + | |
| 2038 | + | |
2005 | 2039 | | |
2006 | 2040 | | |
2007 | 2041 | | |
| |||
Lines changed: 41 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
0 commit comments