|
| 1 | +# Vxlan configs for CPU traffic |
| 2 | +# High Level Design Document |
| 3 | +### Rev 1.3 |
| 4 | + |
| 5 | +# Table of Contents |
| 6 | + * [List of Tables](#list-of-tables) |
| 7 | + |
| 8 | + * [Revision](#revision) |
| 9 | + |
| 10 | + * [Scope](#scope) |
| 11 | + |
| 12 | + * [Definitions/Abbreviation](#definitionsabbreviation) |
| 13 | + |
| 14 | + * [Overview](#overview) |
| 15 | + |
| 16 | + * [Requirements Overview](#5-requirements-overview) |
| 17 | + |
| 18 | + * [Architecture design](#6-architecture-design) |
| 19 | + |
| 20 | + * [Cofiguration and management](#7-configuration-and-management) |
| 21 | + |
| 22 | +# 1 Revision |
| 23 | +| Rev | Date | Author | Change Description | |
| 24 | +|:---:|:-----------:|:------------------:|-----------------------------------| |
| 25 | +| 0.1 | | Bharath Veeranna | Initial version | |
| 26 | + |
| 27 | + |
| 28 | +# 2 Scope |
| 29 | +This documents specifically deals with kernel routes and interfaces that are required by the CPU to communicate to a VxLAN endpoint. This is for a specific use case where CPU generated packets (such as BGP, ping etc) shoud be encapped/decapped with VxLAN. Transit traffic (which are not destined to CPU) are not in the scope of this document. NPU config required for transit traffic are discussed in [VxLAN HLD](https://github.com/sonic-net/SONiC/blob/master/doc/vxlan/Vxlan_hld.md). |
| 30 | + |
| 31 | +# 3 Definitions/Abbreviation |
| 32 | +###### Table 1: Abbreviations |
| 33 | +| | | |
| 34 | +|--------------------------|--------------------------------| |
| 35 | +| VNI | Vxlan Network Identifier | |
| 36 | +| VTEP | Vxlan Tunnel End Point | |
| 37 | +| VNet | Virtual Network | |
| 38 | + |
| 39 | +# 4 Overview |
| 40 | +This document provides information about kernel routes required for SONiC to encap/decap VxLAN traffic originated/destined to CPU. For scenarios where SONiC needs to communicate to an endpoint that is behind a VTEP, the kernel needs to be aware of the VTEP and have routes to encap/decap the packets before sending it over the wire. For example, if SONiC needs to establish BGP over VxLAN, the kernel should know the VTEP and overlay routes to send and receive the packet. If the kernel is unaware of the VTEP, it will treat it as unreachable and drop the packets in kernel. |
| 41 | + |
| 42 | +Additionally, SONiC may need Loopback interfaces attached to the VNET which can be used as the overlay source for any communication to external VTEPs. |
| 43 | + |
| 44 | +# 5 Requirements Overview |
| 45 | +## 5.1 Functional requirements |
| 46 | +This section describes the SONiC requirements for Vxlan kernel interface and routes required for the OS to handle VxLAN encap/decap for traffic originated/destined to CPU. |
| 47 | + - SONiC should be able to encap/decap VxLAN traffic originated/destined to CPU |
| 48 | + - Processes on CPU could leverage these routes to communicate to VxLAN endpoints (establish BGP, ping etc) |
| 49 | + |
| 50 | +## 5.2 Orchagent requirements |
| 51 | + |
| 52 | +### Vnet Route orchagent: |
| 53 | + - Should be able to create kernel interface and routes for VxLAN endpoints |
| 54 | + - Should be able to create Loopback interfaces and attach it to VNET. |
| 55 | + |
| 56 | + |
| 57 | +## 5.3 CLI requirements |
| 58 | +- User should be able to specify if vnet tunnel routes should be installed on kernel. |
| 59 | +- User should be able to bind the loopback interface to a VNET |
| 60 | + |
| 61 | +``` |
| 62 | + - config vnet add-route <vnet-name> <prefix> <endpoint> <vni> <mac_address> <install_on_kernel> |
| 63 | + - config interface vnet bind <interface> <vnet> |
| 64 | +``` |
| 65 | + |
| 66 | +# 6 Architecture Design |
| 67 | + |
| 68 | +## 6.1 Config DB |
| 69 | +Following new flag will be added to VNET_ROUTE_TUNNEL table to indicate if the flag has to installed on the kernel. By default the flag would be false. |
| 70 | + |
| 71 | +### 6.1.1 VXLAN ROUTE TUNNEL |
| 72 | +``` |
| 73 | +VNET_ROUTE_TUNNEL_TABLE:{{vnet_name}}:{{prefix}} |
| 74 | + "endpoint": {{ip_address}} |
| 75 | + "mac_address":{{mac_address}} (OPTIONAL) |
| 76 | + "vni": {{vni}}(OPTIONAL) |
| 77 | + "install_on_kernel": "true" / "false" (OPTIONAL) |
| 78 | +``` |
| 79 | + |
| 80 | +### 6.1.2 Loopback interfaces |
| 81 | +``` |
| 82 | +LOOPBACK_INTERFACE_TABLE:{{loopback_name}} |
| 83 | + "vnet_name": {{vnet_name}} (OPTIONAL) |
| 84 | +
|
| 85 | +LOOPBACK_INTERFACE_TABLE:{{loopback_name}}:{{ip_address}} |
| 86 | +``` |
| 87 | + |
| 88 | +### 6.1.3 ConfigDB Schemas |
| 89 | +``` |
| 90 | +; Defines schema for VNet Route tunnel table attributes |
| 91 | +key = VNET_ROUTE_TUNNEL_TABLE:vnet_name:prefix ; Vnet route tunnel table with prefix |
| 92 | +; field = value |
| 93 | +ENDPOINT = ipv4 ; Host VM IP address |
| 94 | +MAC_ADDRESS = 12HEXDIG ; Inner dest mac in encapsulated packet (Optional) |
| 95 | +VNI = DIGITS ; VNI value in encapsulated packet (Optional) |
| 96 | +INSTALL_ON_KERNEL = true/false ; Indicates if this route should be installed on kernel |
| 97 | +``` |
| 98 | + |
| 99 | +``` |
| 100 | +; Defines schema for Loopback interface table |
| 101 | +key = LOOPBACK_INTERFACE_TABLE:loopback_name:prefix ; Loopback interface with prefix |
| 102 | +; field = value |
| 103 | +vnet_name = string ; vnet name |
| 104 | +``` |
| 105 | + |
| 106 | +Please refer to the [schema](https://github.com/sonic-net/sonic-swss/blob/master/doc/swss-schema.md) document for details on value annotations. |
| 107 | + |
| 108 | + |
| 109 | +### 6.2.1 APP DB Schemas |
| 110 | + |
| 111 | +``` |
| 112 | +; Defines schema for VNet Route tunnel table attributes |
| 113 | +key = VNET_ROUTE_TUNNEL_TABLE:vnet_name:prefix ; Vnet route tunnel table with prefix |
| 114 | +; field = value |
| 115 | +ENDPOINT = ipv4 ; Host VM IP address |
| 116 | +MAC_ADDRESS = 12HEXDIG ; Inner dest mac in encapsulated packet (Optional) |
| 117 | +VNI = DIGITS ; VNI value in encapsulated packet (Optional) |
| 118 | +INSTALL_ON_KERNEL = true/false ; Indicates if this route should be installed on kernel |
| 119 | +``` |
| 120 | + |
| 121 | +## 6.3 Orchestration Agent |
| 122 | +Following orchagents shall be modified. |
| 123 | + |
| 124 | + ### VnetOrch/VnetRouteOrch |
| 125 | +VnetRouteOrch is reponsible for programming VNET_ROUTE_TUNNEL_TABLE in SAI. When VnetRouteOrch programs the tunnel routes in NPU, it will also install the kernel routes if the `install_on_kernel` flag is set to true. |
| 126 | + |
| 127 | +For the config below: |
| 128 | + |
| 129 | +``` |
| 130 | +VXLAN_TUNNEL|{{tunnel_name}} |
| 131 | + "src_ip": {{ip_address}} |
| 132 | + "dst_ip": {{ip_address}} (OPTIONAL) |
| 133 | +
|
| 134 | +VNET|{{vnet_name}} |
| 135 | + "vxlan_tunnel": {{tunnel_name}} |
| 136 | + "vni": {{vni}} |
| 137 | + "src_mac": {{src_mac}} |
| 138 | +
|
| 139 | +VNET_ROUTE_TUNNEL_TABLE:{{vnet_name}}:{{prefix}} |
| 140 | + "endpoint": {{endpoint_ip_address}} |
| 141 | + "mac_address":{{overlay_dmac_address}} (OPTIONAL) |
| 142 | + "vni": {{route_vni}}(OPTIONAL) |
| 143 | + "install_on_kernel": "true" |
| 144 | +``` |
| 145 | + |
| 146 | +the following linux kernel interface and routes will be added: |
| 147 | + |
| 148 | +``` |
| 149 | +sudo ip link add Vxlan{{route_vni}} address {{src_mac}} type vxlan id {{route_vni}} local {{tunnel_src_ip}} remote {{endpoint_ip_address}} |
| 150 | +sudo ip link set Vxlan_{{vnet_name}}_{{prefix}} vrf {{vnet_name}} |
| 151 | +sudo ip link set Vxlan_{{vnet_name}}_{{prefix}} up |
| 152 | +sudo ip route add {{prefix}} dev Vxlan_{{vnet_name}}_{{prefix}} vrf {{vnet_name}} |
| 153 | +sudo ip neigh add {{prefix}} lladdr {{overlay_dmac_address}} dev Vxlan_{{vnet_name}}_{{prefix}} |
| 154 | +``` |
| 155 | + |
| 156 | +# 7 Configuration and management |
| 157 | + |
| 158 | +## 7.1 YANG model |
| 159 | +Yang model for vnet and loopback will be changed to include the new fields. In [sonic-vnet.yang](https://github.com/sonic-net/sonic-buildimage/blob/master/src/sonic-yang-models/yang-models/sonic-vnet.yang), VNET_ROUTE_TUNNEL will include `install_on_kernel` flag: |
| 160 | + |
| 161 | +``` |
| 162 | + container VNET_ROUTE_TUNNEL { |
| 163 | +
|
| 164 | + description "ConfigDB VNET_ROUTE_TUNNEL table"; |
| 165 | + |
| 166 | + list VNET_ROUTE_TUNNEL_LIST { |
| 167 | + key "vnet_name prefix"; |
| 168 | +
|
| 169 | + leaf vnet_name { |
| 170 | + description "VNET name"; |
| 171 | + type leafref { |
| 172 | + path "/svnet:sonic-vnet/svnet:VNET/svnet:VNET_LIST/svnet:name"; |
| 173 | + } |
| 174 | + } |
| 175 | + |
| 176 | + leaf prefix { |
| 177 | + description "IPv4 prefix in CIDR format"; |
| 178 | + type stypes:sonic-ip4-prefix; |
| 179 | + } |
| 180 | + |
| 181 | + leaf endpoint { |
| 182 | + description "Endpoint/nexthop tunnel IP"; |
| 183 | + type inet:ipv4-address; |
| 184 | + mandatory true; |
| 185 | + } |
| 186 | +
|
| 187 | + leaf mac_address { |
| 188 | + description "Inner dest mac in encapsulated packet"; |
| 189 | + type yang:mac-address; |
| 190 | + } |
| 191 | +
|
| 192 | + leaf vni { |
| 193 | + description "A valid and active vni value in encapsulated packet"; |
| 194 | + type stypes:vnid_type; |
| 195 | + } |
| 196 | +
|
| 197 | + leaf install_on_kernel { |
| 198 | + description "Flag to install this route on kernel."; |
| 199 | + type boolean; |
| 200 | + } |
| 201 | + } |
| 202 | + /* end of list VNET_ROUTE_TUNNEL_LIST */ |
| 203 | + } |
| 204 | +``` |
| 205 | + |
| 206 | +The yang model for loopback interface [sonic-loopback-interface.yang](https://github.com/sonic-net/sonic-buildimage/blob/master/src/sonic-yang-models/yang-models/sonic-loopback-interface.yang) will include vnet_name field: |
| 207 | + |
| 208 | +``` |
| 209 | + list LOOPBACK_INTERFACE_LIST { |
| 210 | + key "name"; |
| 211 | +
|
| 212 | + leaf name{ |
| 213 | + type stypes:interface_name; |
| 214 | + } |
| 215 | +
|
| 216 | + leaf vrf_name { |
| 217 | + type leafref { |
| 218 | + path "/vrf:sonic-vrf/vrf:VRF/vrf:VRF_LIST/vrf:name"; |
| 219 | + } |
| 220 | + } |
| 221 | +
|
| 222 | + leaf vnet_name { |
| 223 | + type leafref { |
| 224 | + path "/svnet:sonic-vnet/svnet:VNET/svnet:VNET_LIST/svnet:name"; |
| 225 | + } |
| 226 | + } |
| 227 | +
|
| 228 | + leaf nat_zone { |
| 229 | + description "NAT Zone for the loopback interface"; |
| 230 | + type uint8 { |
| 231 | + range "0..3" { |
| 232 | + error-message "Invalid nat zone for the loopback interface."; |
| 233 | + error-app-tag nat-zone-invalid; |
| 234 | + } |
| 235 | + } |
| 236 | + default "0"; |
| 237 | + } |
| 238 | +
|
| 239 | + leaf admin_status { |
| 240 | + type stypes:admin_status; |
| 241 | + default up; |
| 242 | + } |
| 243 | + } |
| 244 | +``` |
| 245 | + |
| 246 | + |
0 commit comments