|
| 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 document is an extension to the VxLAN feature implementation defined in [VxLAN HLD](https://github.com/sonic-net/SONiC/blob/master/doc/vxlan/Vxlan_hld.md). 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 | +| BGP | Border Gateway Protocol | |
| 36 | +| VNI | Vxlan Network Identifier | |
| 37 | +| VTEP | Vxlan Tunnel End Point | |
| 38 | +| VNet | Virtual Network | |
| 39 | + |
| 40 | +# 4 Overview |
| 41 | +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. |
| 42 | + |
| 43 | +Currently, SONiC creates kernel routes, bridge and vxlan interfaces for a VNET. For example, consider a VNET `Vnet_1000` as defined below: |
| 44 | + |
| 45 | +``` |
| 46 | +--- CONFIG_DB |
| 47 | + |--- VNET |
| 48 | + | |--- Vnet_1000 |
| 49 | + | |--- VNI = 1000 |
| 50 | + | |--- source_tunnel |
| 51 | + | |
| 52 | + |--- VNET_ROUTE_TUNNEL |
| 53 | + |--- Vnet_1000|10.0.0.2/32 |
| 54 | + |--- endpoint = 100.100.100.1 |
| 55 | + |--- vni = 2000 |
| 56 | +
|
| 57 | +--- Kernel |
| 58 | + |--- Vnet_1000 |
| 59 | + |--- Brvxlan1000 -> A bridge for Vnet that terminates Vxlan and does L2 forwarding |
| 60 | + |--- Vxlan1000 -> vxlan interface |
| 61 | +``` |
| 62 | + |
| 63 | +For the above config, SONiC creates kernel configs for a L2 bridge and a VxLAN interface. For the vxlan routes that are added using `VXLAN_ROUTE_TUNNEL`, there are no kernel configurations applied. The kernel cannot initiate communication to the vnet endpoints behind VTEP since the kernel interface and routes for these prefixes are not installed on the kernel. This document enhances the VxLAN capabilities of SONiC to have the kernel routes and vxlan P2P interface to communicate with the remote endpoints defined in `VNET_ROUTE_TUNNEL`. This can be used for traffic originated by CPU (like BGP, ping etc) and destined to a remote VTEP endpoint. |
| 64 | + |
| 65 | +Additionally, SONiC may need Loopback interfaces attached to the VNET which can be used as the overlay source for any communication to external VTEPs. |
| 66 | + |
| 67 | +# 5 Requirements Overview |
| 68 | +## 5.1 Functional requirements |
| 69 | +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. |
| 70 | + - SONiC should be able to encap/decap VxLAN traffic originated/destined to CPU |
| 71 | + - Processes on CPU could leverage these routes to communicate to VxLAN endpoints (establish BGP, ping etc) |
| 72 | + |
| 73 | +## 5.2 Config Manager requirements |
| 74 | + |
| 75 | +### Vnet Manager: |
| 76 | +A new component called VnetMgr will be introduced that will handle kernel programming for `VNET_ROUTE_TUNNEL` endpoints. |
| 77 | +- VnetMgr should handle vxlan interface creation and deletion for routes defined in VNET_ROUTE_TUNNEL. |
| 78 | +- VnetMgr should install/delete kernel routes for the VTEP endpoints. |
| 79 | + |
| 80 | + |
| 81 | +## 5.3 CLI requirements |
| 82 | +- User should be able to specify if vnet tunnel routes should be installed on kernel. |
| 83 | +- User should be able to bind the loopback interface to a VNET |
| 84 | + |
| 85 | +``` |
| 86 | + - config vnet add-route <vnet-name> <prefix> <endpoint> <vni> <mac_address> <install_on_kernel> |
| 87 | + - config interface vnet bind <interface> <vnet> |
| 88 | +``` |
| 89 | + |
| 90 | +# 6 Architecture Design |
| 91 | + |
| 92 | +## 6.1 Config DB |
| 93 | +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. |
| 94 | + |
| 95 | +### 6.1.1 VXLAN ROUTE TUNNEL |
| 96 | +``` |
| 97 | +VNET_ROUTE_TUNNEL_TABLE:{{vnet_name}}:{{prefix}} |
| 98 | + "endpoint": {{ip_address}} |
| 99 | + "mac_address":{{mac_address}} (OPTIONAL) |
| 100 | + "vni": {{vni}}(OPTIONAL) |
| 101 | + "install_on_kernel": "true" / "false" (OPTIONAL) |
| 102 | +``` |
| 103 | + |
| 104 | +### 6.1.2 Loopback interfaces |
| 105 | +``` |
| 106 | +LOOPBACK_INTERFACE_TABLE:{{loopback_name}} |
| 107 | + "vnet_name": {{vnet_name}} (OPTIONAL) |
| 108 | +
|
| 109 | +LOOPBACK_INTERFACE_TABLE:{{loopback_name}}:{{ip_address}} |
| 110 | +``` |
| 111 | + |
| 112 | +### 6.1.3 ConfigDB Schemas |
| 113 | +``` |
| 114 | +; Defines schema for VNet Route tunnel table attributes |
| 115 | +key = VNET_ROUTE_TUNNEL_TABLE:vnet_name:prefix ; Vnet route tunnel table with prefix |
| 116 | +; field = value |
| 117 | +ENDPOINT = ipv4 ; Host VM IP address |
| 118 | +MAC_ADDRESS = 12HEXDIG ; Inner dest mac in encapsulated packet (Optional) |
| 119 | +VNI = DIGITS ; VNI value in encapsulated packet (Optional) |
| 120 | +INSTALL_ON_KERNEL = true/false ; Indicates if this route should be installed on kernel |
| 121 | +``` |
| 122 | + |
| 123 | +``` |
| 124 | +; Defines schema for Loopback interface table |
| 125 | +key = LOOPBACK_INTERFACE_TABLE:loopback_name:prefix ; Loopback interface with prefix |
| 126 | +; field = value |
| 127 | +vnet_name = string ; vnet name |
| 128 | +``` |
| 129 | + |
| 130 | +Please refer to the [schema](https://github.com/sonic-net/sonic-swss/blob/master/doc/swss-schema.md) document for details on value annotations. |
| 131 | + |
| 132 | + |
| 133 | +### 6.2.1 APP DB Schemas |
| 134 | + |
| 135 | +``` |
| 136 | +; Defines schema for VNet Route tunnel table attributes |
| 137 | +key = VNET_ROUTE_TUNNEL_TABLE:vnet_name:prefix ; Vnet route tunnel table with prefix |
| 138 | +; field = value |
| 139 | +ENDPOINT = ipv4 ; Host VM IP address |
| 140 | +MAC_ADDRESS = 12HEXDIG ; Inner dest mac in encapsulated packet (Optional) |
| 141 | +VNI = DIGITS ; VNI value in encapsulated packet (Optional) |
| 142 | +INSTALL_ON_KERNEL = true/false ; Indicates if this route should be installed on kernel |
| 143 | +``` |
| 144 | + |
| 145 | +## 6.3 Config Manager |
| 146 | +A new config manager called VnetMgr will be added which will handle kernel routes programming for `VNET_ROUTE_TUNNEL`. |
| 147 | + |
| 148 | + ### VnetMgr |
| 149 | + |
| 150 | + |
| 151 | +For the config below: |
| 152 | + |
| 153 | +``` |
| 154 | +VXLAN_TUNNEL|{{tunnel_name}} |
| 155 | + "src_ip": {{ip_address}} |
| 156 | + "dst_ip": {{ip_address}} (OPTIONAL) |
| 157 | +
|
| 158 | +VNET|{{vnet_name}} |
| 159 | + "vxlan_tunnel": {{tunnel_name}} |
| 160 | + "vni": {{vni}} |
| 161 | + "src_mac": {{src_mac}} |
| 162 | +
|
| 163 | +VNET_ROUTE_TUNNEL_TABLE:{{vnet_name}}:{{prefix}} |
| 164 | + "endpoint": {{endpoint_ip_address}} |
| 165 | + "mac_address":{{overlay_dmac_address}} (OPTIONAL) |
| 166 | + "vni": {{route_vni}}(OPTIONAL) |
| 167 | + "install_on_kernel": "true" |
| 168 | +``` |
| 169 | + |
| 170 | +the following linux kernel interface and routes will be added: |
| 171 | + |
| 172 | +``` |
| 173 | +sudo ip link add Vxlan{{route_vni}} address {{src_mac}} type vxlan id {{route_vni}} local {{tunnel_src_ip}} remote {{endpoint_ip_address}} |
| 174 | +sudo ip link set Vxlan_{{vnet_name}}_{{prefix}} vrf {{vnet_name}} |
| 175 | +sudo ip link set Vxlan_{{vnet_name}}_{{prefix}} up |
| 176 | +sudo ip route add {{prefix}} dev Vxlan_{{vnet_name}}_{{prefix}} vrf {{vnet_name}} |
| 177 | +sudo ip neigh add {{prefix}} lladdr {{overlay_dmac_address}} dev Vxlan_{{vnet_name}}_{{prefix}} |
| 178 | +``` |
| 179 | + |
| 180 | +# 7 Configuration and management |
| 181 | + |
| 182 | +## 7.1 YANG model |
| 183 | +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: |
| 184 | + |
| 185 | +``` |
| 186 | + container VNET_ROUTE_TUNNEL { |
| 187 | +
|
| 188 | + description "ConfigDB VNET_ROUTE_TUNNEL table"; |
| 189 | + |
| 190 | + list VNET_ROUTE_TUNNEL_LIST { |
| 191 | + key "vnet_name prefix"; |
| 192 | +
|
| 193 | + leaf vnet_name { |
| 194 | + description "VNET name"; |
| 195 | + type leafref { |
| 196 | + path "/svnet:sonic-vnet/svnet:VNET/svnet:VNET_LIST/svnet:name"; |
| 197 | + } |
| 198 | + } |
| 199 | + |
| 200 | + leaf prefix { |
| 201 | + description "IPv4 prefix in CIDR format"; |
| 202 | + type stypes:sonic-ip4-prefix; |
| 203 | + } |
| 204 | + |
| 205 | + leaf endpoint { |
| 206 | + description "Endpoint/nexthop tunnel IP"; |
| 207 | + type inet:ipv4-address; |
| 208 | + mandatory true; |
| 209 | + } |
| 210 | +
|
| 211 | + leaf mac_address { |
| 212 | + description "Inner dest mac in encapsulated packet"; |
| 213 | + type yang:mac-address; |
| 214 | + } |
| 215 | +
|
| 216 | + leaf vni { |
| 217 | + description "A valid and active vni value in encapsulated packet"; |
| 218 | + type stypes:vnid_type; |
| 219 | + } |
| 220 | +
|
| 221 | + leaf install_on_kernel { |
| 222 | + description "Flag to install this route on kernel."; |
| 223 | + type boolean; |
| 224 | + } |
| 225 | + } |
| 226 | + /* end of list VNET_ROUTE_TUNNEL_LIST */ |
| 227 | + } |
| 228 | +``` |
| 229 | + |
| 230 | +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: |
| 231 | + |
| 232 | +``` |
| 233 | + list LOOPBACK_INTERFACE_LIST { |
| 234 | + key "name"; |
| 235 | +
|
| 236 | + leaf name{ |
| 237 | + type stypes:interface_name; |
| 238 | + } |
| 239 | +
|
| 240 | + leaf vrf_name { |
| 241 | + type leafref { |
| 242 | + path "/vrf:sonic-vrf/vrf:VRF/vrf:VRF_LIST/vrf:name"; |
| 243 | + } |
| 244 | + } |
| 245 | +
|
| 246 | + leaf vnet_name { |
| 247 | + type leafref { |
| 248 | + path "/svnet:sonic-vnet/svnet:VNET/svnet:VNET_LIST/svnet:name"; |
| 249 | + } |
| 250 | + } |
| 251 | +
|
| 252 | + leaf nat_zone { |
| 253 | + description "NAT Zone for the loopback interface"; |
| 254 | + type uint8 { |
| 255 | + range "0..3" { |
| 256 | + error-message "Invalid nat zone for the loopback interface."; |
| 257 | + error-app-tag nat-zone-invalid; |
| 258 | + } |
| 259 | + } |
| 260 | + default "0"; |
| 261 | + } |
| 262 | +
|
| 263 | + leaf admin_status { |
| 264 | + type stypes:admin_status; |
| 265 | + default up; |
| 266 | + } |
| 267 | + } |
| 268 | +``` |
| 269 | + |
| 270 | + |
0 commit comments