Skip to content

Commit ec0cd56

Browse files
authored
[yang] interface: add missing mac_addr leaf (#20968)
Why I did it YANG configuration verification fails during config replace. How I did it mac_addr support was added in the INTERFACE, PORTCHANNEL_INTERFACE, and VLAN_INTERFACE tables by sonic-net/sonic-swss#814 in 2020 but the YANG models were never updated to reflect that change. Updated yang model to reflect change. How to verify it Add mac_addr to the various INTERFACE tables then run config replace and it succeeds. Tested branch (Please provide the tested image version) master as of 20241109 Description for the changelog YANG INTERFACE: add missing mac_addr leaf Link to config_db schema for YANG module changes There is no actual INTERFACE section in the docs (there probably should be). A picture of a cute animal (not mandatory but encouraged) Fixes #14253
1 parent 4e318ac commit ec0cd56

File tree

11 files changed

+488
-71
lines changed

11 files changed

+488
-71
lines changed

src/sonic-yang-models/doc/Configuration.md

+91-67
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
* [Console](#console)
2626
* [CRM](#crm)
2727
* [CRM DASH](#crm-dash)
28-
* [Data Plane L3 Interfaces](#data-plane-l3-interfaces)
2928
* [DEFAULT_LOSSLESS_BUFFER_PARAMETER](#DEFAULT_LOSSLESS_BUFFER_PARAMETER)
3029
* [Device Metadata](#device-metadata)
3130
* [Device neighbor metada](#device-neighbor-metada)
@@ -41,10 +40,10 @@
4140
* [FLEX_COUNTER_TABLE](#flex_counter_table)
4241
* [GRPCCLIENT](#grpcclient)
4342
* [Hash](#hash)
44-
* [IPv6 Link-local] (#ipv6-link-local)
4543
* [KDUMP](#kdump)
4644
* [Kubernetes Master](#kubernetes-master)
4745
* [L2 Neighbors](#l2-neighbors)
46+
* [L3 Interfaces](#l3-interfaces)
4847
* [Loopback Interface](#loopback-interface)
4948
* [LOSSLESS_TRAFFIC_PATTERN](#LOSSLESS_TRAFFIC_PATTERN)
5049
* [Memory Statistics](#memory-statistics)
@@ -928,47 +927,6 @@ It currently allows user to administratively bring down a line-card or fabric-ca
928927
}
929928
```
930929

931-
### Data Plane L3 Interfaces
932-
933-
IP configuration for data plane are defined in **INTERFACE**, **VLAN_SUB_INTERFACE**,
934-
**PORTCHANNEL_INTERFACE** and **VLAN_INTERFACE** table. The objects
935-
in all four tables have the interface (could be physical port, port
936-
channel, vlan or vlan sub interface) that IP address is attached to as first-level key, and
937-
IP prefix as second-level key. IP interface address objects don't have any attributes.
938-
IP interface attributes, resides in those tables as well, key is the interface name
939-
and value is a list of field-values representing the interface attributes, e.g. loopback action.
940-
941-
```
942-
{
943-
"INTERFACE": {
944-
"Ethernet0|10.0.0.0/31": {},
945-
"Ethernet4|10.0.0.2/31": {},
946-
"Ethernet8|10.0.0.4/31": {}
947-
"Ethernet8": {
948-
"loopback_action": "drop"
949-
}
950-
},
951-
952-
"PORTCHANNEL_INTERFACE": {
953-
"PortChannel01|10.0.0.56/31": {},
954-
"PortChannel01|FC00::71/126": {},
955-
"PortChannel02|10.0.0.58/31": {},
956-
"PortChannel02|FC00::75/126": {}
957-
},
958-
959-
"VLAN_INTERFACE": {
960-
"Vlan1000|192.168.0.1/27": {}
961-
},
962-
963-
"VLAN_SUB_INTERFACE": {
964-
"Ethernet4.1|10.0.0.2/31": {},
965-
"Ethernet4.1": {
966-
"loopback_action": "drop"
967-
}
968-
}
969-
}
970-
```
971-
972930

973931
### DEFAULT_LOSSLESS_BUFFER_PARAMETER
974932

@@ -1339,30 +1297,6 @@ The configuration is applied globally for each ECMP and LAG on a switch.
13391297
}
13401298
```
13411299

1342-
### IPv6 Link-local
1343-
```
1344-
{
1345-
"INTERFACE": {
1346-
"Ethernet8": {
1347-
"ipv6_use_link_local_only": "disable"
1348-
}
1349-
},
1350-
1351-
"PORTCHANNEL_INTERFACE": {
1352-
"PortChannel01": {
1353-
"ipv6_use_link_local_only": "enable"
1354-
}
1355-
},
1356-
1357-
"VLAN_INTERFACE": {
1358-
"Vlan1000": {
1359-
"ipv6_use_link_local_only": "enable"
1360-
}
1361-
}
1362-
}
1363-
1364-
```
1365-
13661300
### KDUMP
13671301

13681302
```
@@ -1450,6 +1384,96 @@ loopback address can also be defined.
14501384
}
14511385
```
14521386

1387+
### L3 Interfaces
1388+
1389+
Configuration for L3 data plane interfaces are defined in the `INTERFACE`,
1390+
`VLAN_INTERFACE`, `VLAN_SUB_INTERFACE` and `PORTCHANNEL_INTERFACE` tables,
1391+
respectively.
1392+
1393+
The objects in all four tables have the interface as the key with the following
1394+
required patterns:
1395+
- `INTERFACE`: Any valid port name from the `PORT` table. Typically `Ethernet{0-999}`.
1396+
- `VLAN_INTERFACE`: `Vlan{1-4095}`
1397+
- `PORTCHANNEL_INTERFACE`: `PortChannel{0-9999}`
1398+
- `VLAN_SUB_INTERFACE`: Any valid `INTERFACE` or `PORTCHANNEL_INTERFACE` name followed by a `.` and a number between 1 and 4094. E.g. `Ethernet1.4`
1399+
1400+
1401+
These tables have a number of shared attributes as described below:
1402+
* `vrf_name`: Valid VRF name from the `VRF` table. Default: `default`
1403+
* `nat_zone`: NAT Zone for this interface. `0..3`
1404+
* `mpls`: Enable/disable MPLS routing for the interface. `enable` or `disable`. Default `disable`.
1405+
* `ipv6_use_link_local_only`: Enable/Disable IPv6 link local address on interface. `enable` or `disable`. Default `disable`.
1406+
* `mac_addr`: Assign administrator-provided MAC address to Interface. If not specified will use the system MAC (same for all interfaces). Not applicable to `VLAN_SUB_INTERFACE` as it will use the parent interface's mac address.
1407+
* `loopback_action`: Packet action when a packet ingress and gets routed on the same IP interface. `drop` or `forward`.
1408+
1409+
1410+
```json
1411+
1412+
{
1413+
"INTERFACE": {
1414+
"Ethernet0": {
1415+
"ipv6_use_link_local_only": "enable",
1416+
"mac_addr": "12:34:56:78:90:ab"
1417+
},
1418+
"Ethernet1": {
1419+
"loopback_action": "drop"
1420+
}
1421+
},
1422+
"VLAN_INTERFACE": {
1423+
"Vlan201": {
1424+
"vrf_name": "red",
1425+
"mac_addr": "AB:CD:EF:12:34:56"
1426+
}
1427+
},
1428+
"PORTCHANNEL_INTERFACE": {
1429+
"PortChannel101": {
1430+
"mac_addr": "1c:23:a8:56:de:2f"
1431+
}
1432+
},
1433+
"VLAN_SUB_INTERFACE": {
1434+
"Ethernet0.555": {
1435+
"vrf_name": "Blue",
1436+
"vlan": "555"
1437+
}
1438+
}
1439+
}
1440+
```
1441+
1442+
#### Assigning IP addresses to L3 Interfaces
1443+
1444+
The interface name and IP prefix act as multi-level key for the interface
1445+
objects. The IP prefixes are stored in the same tables as the interface
1446+
attributes: `INTERFACE`, `VLAN_INTERFACE`, `VLAN_SUB_INTERFACE` and `PORTCHANNEL_INTERFACE`.
1447+
1448+
In the example below we will show one interface with attributes for clarity,
1449+
but otherwise this is simply an example of how IP addresses may be configured.
1450+
1451+
```json
1452+
{
1453+
"INTERFACE": {
1454+
"Ethernet0": {
1455+
"ipv6_use_link_local_only": "enable",
1456+
"mac_addr": "12:34:56:78:90:ab"
1457+
},
1458+
"Ethernet0|10.0.0.0/31": {},
1459+
"Ethernet4|10.0.0.2/31": {},
1460+
"Ethernet8|10.0.0.4/31": {},
1461+
},
1462+
"PORTCHANNEL_INTERFACE": {
1463+
"PortChannel01|10.0.0.56/31": {},
1464+
"PortChannel01|FC00::71/126": {},
1465+
"PortChannel02|10.0.0.58/31": {},
1466+
"PortChannel02|FC00::75/126": {}
1467+
},
1468+
"VLAN_INTERFACE": {
1469+
"Vlan1000|192.168.0.1/27": {}
1470+
},
1471+
"VLAN_SUB_INTERFACE": {
1472+
"Ethernet4.1|10.0.0.2/31": {}
1473+
}
1474+
}
1475+
```
1476+
14531477
### Loopback Interface
14541478

14551479
Loopback interface configuration lies in **LOOPBACK_INTERFACE** table

src/sonic-yang-models/tests/files/sample_config_db.json

+6-3
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@
134134
"PortChannel0003": {
135135
"nat_zone": "1",
136136
"loopback_action": "drop",
137-
"ipv6_use_link_local_only": "enable"
137+
"ipv6_use_link_local_only": "enable",
138+
"mac_addr": "02:26:9b:73:c1:1a"
138139
},
139140
"PortChannel0004": {"vrf_name": "Vrf_blue"},
140141
"PortChannel42|10.1.0.1/31": {},
@@ -151,7 +152,8 @@
151152
"Vlan111": {
152153
"nat_zone": "0",
153154
"loopback_action": "forward",
154-
"ipv6_use_link_local_only": "disable"
155+
"ipv6_use_link_local_only": "disable",
156+
"mac_addr": "02:ab:cd:ef:12:34"
155157
},
156158
"Vlan777": {},
157159
"Vlan111|2a04:5555:45:6709::1/64": {
@@ -1201,7 +1203,8 @@
12011203
"Ethernet18": {
12021204
"nat_zone": "1",
12031205
"loopback_action": "forward",
1204-
"ipv6_use_link_local_only": "enable"
1206+
"ipv6_use_link_local_only": "enable",
1207+
"mac_addr": "12:34:56:78:90:ab"
12051208
},
12061209
"Ethernet112|2a04:5555:40:a709::2/126": {
12071210
"scope": "global",

src/sonic-yang-models/tests/yang_model_tests/tests/interface.json

+10
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,15 @@
2929
"INTERFACE_INVALID_ENABLE_IPV6_LINK_LOCAL": {
3030
"desc": "Enable the ipv6 link-local as true.",
3131
"eStr": "Invalid value \"true\" in \"ipv6_use_link_local_only\" element."
32+
},
33+
"INTERFACE_MAC_ADDR": {
34+
"desc": "Set administrator-provided interface mac address."
35+
},
36+
"INTERFACE_UPPER_MAC_ADDR": {
37+
"desc": "Set UPPERCASE administrator-provided interface mac address."
38+
},
39+
"INTERFACE_INVALID_MAC_ADDR": {
40+
"desc": "Set invalid interface mac address.",
41+
"eStrKey": "Pattern"
3242
}
3343
}

src/sonic-yang-models/tests/yang_model_tests/tests/portchannel.json

+10
Original file line numberDiff line numberDiff line change
@@ -85,5 +85,15 @@
8585
"PORTCHANNEL_INTERFACE_INVALID_ENABLE_IPV6_LINK_LOCAL": {
8686
"desc": "Enable the ipv6 link-local as true.",
8787
"eStr": "Invalid value \"true\" in \"ipv6_use_link_local_only\" element."
88+
},
89+
"PORTCHANNEL_INTERFACE_MAC_ADDR": {
90+
"desc": "Set administrator-provided interface mac address."
91+
},
92+
"PORTCHANNEL_INTERFACE_UPPER_MAC_ADDR": {
93+
"desc": "Set UPPERCASE administrator-provided interface mac address."
94+
},
95+
"PORTCHANNEL_INTERFACE_INVALID_MAC_ADDR": {
96+
"desc": "Set invalid interface mac address.",
97+
"eStrKey": "Pattern"
8898
}
8999
}

src/sonic-yang-models/tests/yang_model_tests/tests/vlan.json

+10
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,16 @@
9191
"desc": "Enable the ipv6 link-local as true.",
9292
"eStr": "Invalid value \"true\" in \"ipv6_use_link_local_only\" element."
9393
},
94+
"VLAN_INTERFACE_MAC_ADDR": {
95+
"desc": "Set administrator-provided interface mac address."
96+
},
97+
"VLAN_INTERFACE_UPPER_MAC_ADDR": {
98+
"desc": "Set UPPERCASE administrator-provided interface mac address."
99+
},
100+
"VLAN_INTERFACE_INVALID_MAC_ADDR": {
101+
"desc": "Set invalid interface mac address.",
102+
"eStrKey": "Pattern"
103+
},
94104
"VLAN_MEMBERS_WITHOUT_CREATING_VLAN":{
95105
"desc": "Vlan members without Creating Vlan",
96106
"eStrKey": "LeafRef"

src/sonic-yang-models/tests/yang_model_tests/tests_config/interface.json

+87
Original file line numberDiff line numberDiff line change
@@ -274,5 +274,92 @@
274274
]
275275
}
276276
}
277+
},
278+
"INTERFACE_MAC_ADDR": {
279+
"sonic-interface:sonic-interface": {
280+
"sonic-interface:INTERFACE": {
281+
"INTERFACE_LIST": [
282+
{
283+
"name": "Ethernet8",
284+
"mac_addr": "02:26:9b:73:c1:1a"
285+
}
286+
]
287+
}
288+
},
289+
"sonic-port:sonic-port": {
290+
"sonic-port:PORT": {
291+
"PORT_LIST": [
292+
{
293+
"admin_status": "up",
294+
"alias": "eth8",
295+
"description": "Ethernet8",
296+
"fec": "rs",
297+
"lanes": "65",
298+
"mtu": 9000,
299+
"name": "Ethernet8",
300+
"speed": 25000,
301+
"mode":"trunk"
302+
}
303+
]
304+
}
305+
}
306+
},
307+
"INTERFACE_UPPER_MAC_ADDR": {
308+
"sonic-interface:sonic-interface": {
309+
"sonic-interface:INTERFACE": {
310+
"INTERFACE_LIST": [
311+
{
312+
"name": "Ethernet8",
313+
"mac_addr": "02:AB:CD:EF:12:34"
314+
}
315+
]
316+
}
317+
},
318+
"sonic-port:sonic-port": {
319+
"sonic-port:PORT": {
320+
"PORT_LIST": [
321+
{
322+
"admin_status": "up",
323+
"alias": "eth8",
324+
"description": "Ethernet8",
325+
"fec": "rs",
326+
"lanes": "65",
327+
"mtu": 9000,
328+
"name": "Ethernet8",
329+
"speed": 25000,
330+
"mode":"trunk"
331+
}
332+
]
333+
}
334+
}
335+
},
336+
"INTERFACE_INVALID_MAC_ADDR": {
337+
"sonic-interface:sonic-interface": {
338+
"sonic-interface:INTERFACE": {
339+
"INTERFACE_LIST": [
340+
{
341+
"name": "Ethernet8",
342+
"mac_addr": "badaddr"
343+
}
344+
]
345+
}
346+
},
347+
"sonic-port:sonic-port": {
348+
"sonic-port:PORT": {
349+
"PORT_LIST": [
350+
{
351+
"admin_status": "up",
352+
"alias": "eth8",
353+
"description": "Ethernet8",
354+
"fec": "rs",
355+
"lanes": "65",
356+
"mtu": 9000,
357+
"name": "Ethernet8",
358+
"speed": 25000,
359+
"mode":"trunk"
360+
}
361+
]
362+
}
363+
}
277364
}
278365
}

0 commit comments

Comments
 (0)