Skip to content

Commit

Permalink
add Tunnel yang model (#12232)
Browse files Browse the repository at this point in the history
#### Why I did it
Add yang model for TUNNEL config
#### How I did it
created sonic-tunnel.yang file and tests
#### How to verify it
`make target/python-wheels/bullseye/sonic_yang_models-1.0-py3-none-any.whl`

#### Link to config_db schema for YANG module changes
https://github.com/sonic-net/sonic-buildimage/blob/master/src/sonic-yang-models/doc/Configuration.md#tunnel
  • Loading branch information
Ndancejic committed Dec 30, 2022
1 parent e0c29aa commit 86a5a7f
Show file tree
Hide file tree
Showing 6 changed files with 379 additions and 8 deletions.
56 changes: 56 additions & 0 deletions src/sonic-yang-models/doc/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Table of Contents
* [TC to Priority group map](#tc-to-priority-group-map)
* [TC to Queue map](#tc-to-queue-map)
* [Telemetry](#telemetry)
* [Tunnel](#tunnel)
* [Versions](#versions)
* [VLAN](#vlan)
* [VLAN_MEMBER](#vlan_member)
Expand Down Expand Up @@ -1594,6 +1595,61 @@ Container side configuration:
}
```

### Tunnel

This table configures the MUX tunnel for Dual-ToR setup
```
{
"TUNNEL": {
"MuxTunnel0": {
"dscp_mode": "uniform",
"dst_ip": "10.1.0.32",
"ecn_mode": "copy_from_outer",
"encap_ecn_mode": "standard",
"ttl_mode": "pipe",
"tunnel_type": "IPINIP"
}
}
}
```

different example for configuring MUX tunnel
```
{
"TUNNEL": {
"MuxTunnel0": {
"dscp_mode": "pipe",
"dst_ip": "10.1.0.32",
"ecn_mode": "standard",
"encap_ecn_mode": "standard",
"ttl_mode": "uniform",
"tunnel_type": "IPINIP"
}
}
}
```

example mux tunnel configuration for when tunnel_qos_remap is enabled
```
{
"TUNNEL": {
"MuxTunnel0": {
"tunnel_type": "IPINIP",
"src_ip": "10.1.0.33",
"dst_ip": "10.1.0.32",
"dscp_mode": "pipe",
"encap_ecn_mode": "standard",
"ecn_mode": "copy_from_outer",
"ttl_mode": "uniform",
"decap_dscp_to_tc_map": "DecapDscpToTcMap",
"decap_tc_to_pg_map": "DecapTcToPgMap",
"encap_tc_to_dscp_map": "EncapTcToQueueMap",
"encap_tc_to_queue_map": "EncapTcToDscpMap"
}
}
}
```

### Versions

This table is where the curret version of the software is recorded.
Expand Down
1 change: 1 addition & 0 deletions src/sonic-yang-models/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ def run(self):
'./yang-models/sonic-system-aaa.yang',
'./yang-models/sonic-system-tacacs.yang',
'./yang-models/sonic-telemetry.yang',
'./yang-models/sonic-tunnel.yang',
'./yang-models/sonic-types.yang',
'./yang-models/sonic-versions.yang',
'./yang-models/sonic-vlan.yang',
Expand Down
47 changes: 39 additions & 8 deletions src/sonic-yang-models/tests/files/sample_config_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -1144,14 +1144,45 @@
"TELEMETRY": {
"certs": {
"ca_crt": "/etc/sonic/telemetry/dsmsroot.cer",
"server_crt": "/etc/sonic/telemetry/streamingtelemetryserver.cer",
"server_key": "/etc/sonic/telemetry/streamingtelemetryserver.key"
},
"gnmi": {
"client_auth": "true",
"log_level": "2",
"port": "50051"
}
"server_crt": "/etc/sonic/telemetry/streamingtelemetryserver.cer",
"server_key": "/etc/sonic/telemetry/streamingtelemetryserver.key"
},
"gnmi": {
"client_auth": "true",
"log_level": "2",
"port": "50051"
}
},
"TUNNEL": {
"MuxTunnel0": {
"dscp_mode": "uniform",
"dst_ip": "10.1.0.32",
"ecn_mode": "copy_from_outer",
"encap_ecn_mode": "standard",
"ttl_mode": "pipe",
"tunnel_type": "IPINIP"
},
"MuxTunnel1": {
"dscp_mode": "pipe",
"dst_ip": "10.1.0.32",
"ecn_mode": "standard",
"encap_ecn_mode": "standard",
"ttl_mode": "uniform",
"tunnel_type": "IPINIP"
},
"MuxTunnel2": {
"tunnel_type": "IPINIP",
"src_ip": "10.1.0.33",
"dst_ip": "10.1.0.32",
"dscp_mode": "pipe",
"encap_ecn_mode": "standard",
"ecn_mode": "copy_from_outer",
"ttl_mode": "uniform",
"decap_dscp_to_tc_map": "Dscp_to_tc_map1",
"decap_tc_to_pg_map": "tc_to_pg_map1",
"encap_tc_to_dscp_map": "EncapTcToQueueMap",
"encap_tc_to_queue_map": "tc_to_q_map1"
}
},
"RESTAPI": {
"certs": {
Expand Down
18 changes: 18 additions & 0 deletions src/sonic-yang-models/tests/yang_model_tests/tests/tunnel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"TUNNEL_LOAD_NORMAL": {
"desc": "Load TUNNEL for dualtor device."
},
"TUNNEL_INVALID_ADDR": {
"desc": "Load TUNNEL with invalid IPv4 Address.",
"eStr": ["does not satisfy the constraint"]
},
"TUNNEL_SRC_IP_NOT_PEER_SWITCH": {
"desc": "Load TUNNEL with wrong IPv4 Address.",
"eStr": ["points to a non-existing leaf."]
},
"TUNNEL_MISSING_MUX_TUNNEL": {
"desc": "Load MUX_TUNNEL missing name.",
"eStr": ["Missing required element"]
}
}

143 changes: 143 additions & 0 deletions src/sonic-yang-models/tests/yang_model_tests/tests_config/tunnel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
{
"TUNNEL_LOAD_NORMAL": {
"sonic-peer-switch:sonic-peer-switch": {
"sonic-peer-switch:PEER_SWITCH": {
"PEER_SWITCH_LIST": [
{
"peer_switch": "vlab-05",
"address_ipv4": "10.1.0.33"
}
]
}
},
"sonic-dscp-tc-map:sonic-dscp-tc-map": {
"sonic-dscp-tc-map:DSCP_TO_TC_MAP": {
"DSCP_TO_TC_MAP_LIST": [
{
"name": "DecapDscpToTcMap",
"DSCP_TO_TC_MAP": [
{
"dscp": "1",
"tc": "1"
}
]
}
]
}
},
"sonic-tc-priority-group-map:sonic-tc-priority-group-map": {
"sonic-tc-priority-group-map:TC_TO_PRIORITY_GROUP_MAP": {
"TC_TO_PRIORITY_GROUP_MAP_LIST": [
{
"name": "DecapTcToPgMap",
"TC_TO_PRIORITY_GROUP_MAP": [
{
"tc": "1",
"pg": "1"
}
]
}
]
}
},
"sonic-tc-queue-map:sonic-tc-queue-map": {
"sonic-tc-queue-map:TC_TO_QUEUE_MAP": {
"TC_TO_QUEUE_MAP_LIST": [
{
"name": "EncapTcToQueueMap",
"TC_TO_QUEUE_MAP": [
{
"tc": "1",
"qindex": "1"
}
]
}
]
}
},
"sonic-tunnel:sonic-tunnel": {
"sonic-tunnel:TUNNEL": {
"TUNNEL_LIST": [
{
"mux_tunnel": "MuxTunnel0",
"dscp_mode": "pipe",
"src_ip": "10.1.0.33",
"dst_ip": "10.1.0.32",
"ecn_mode": "standard",
"encap_ecn_mode": "standard",
"ttl_mode": "pipe",
"tunnel_type": "IPINIP",
"decap_dscp_to_tc_map": "DecapDscpToTcMap",
"decap_tc_to_pg_map": "DecapTcToPgMap",
"encap_tc_to_dscp_map": "EncapTcToDscpMap",
"encap_tc_to_queue_map": "EncapTcToQueueMap"
}
]
}
}
},

"TUNNEL_INVALID_ADDR": {
"sonic-tunnel:sonic-tunnel": {
"sonic-tunnel:TUNNEL": {
"TUNNEL_LIST": [
{
"mux_tunnel": "MuxTunnel0",
"dscp_mode": "pipe",
"dst_ip": "10.1.0.33/32",
"ecn_mode": "standard",
"encap_ecn_mode": "standard",
"ttl_mode": "pipe",
"tunnel_type": "IPINIP"
}
]
}
}
},

"TUNNEL_SRC_IP_NOT_PEER_SWITCH": {
"sonic-peer-switch:sonic-peer-switch": {
"sonic-peer-switch:PEER_SWITCH": {
"PEER_SWITCH_LIST": [
{
"peer_switch": "vlab-05",
"address_ipv4": "10.1.0.33"
}
]
}
},
"sonic-tunnel:sonic-tunnel": {
"sonic-tunnel:TUNNEL": {
"TUNNEL_LIST": [
{
"mux_tunnel": "MuxTunnel0",
"dscp_mode": "pipe",
"dst_ip": "10.1.0.32",
"src_ip": "10.1.0.32",
"ecn_mode": "standard",
"encap_ecn_mode": "standard",
"ttl_mode": "pipe",
"tunnel_type": "IPINIP"
}
]
}
}
},

"TUNNEL_MISSING_MUX_TUNNEL": {
"sonic-tunnel:sonic-tunnel": {
"sonic-tunnel:TUNNEL": {
"TUNNEL_LIST": [
{
"dscp_mode": "pipe",
"dst_ip": "10.1.0.32",
"ecn_mode": "standard",
"encap_ecn_mode": "standard",
"ttl_mode": "pipe",
"tunnel_type": "IPINIP"
}
]
}
}
}
}
Loading

0 comments on commit 86a5a7f

Please sign in to comment.