vxlan 端口是ovs 的OVS_VPORT_TYPE_VXLAN 類型的隧道端口,用戶態netdev 庫通過netdev_vport_tunnel_register() 註冊vport_class 結構,它包含如vxlan、gre 等各種類型隧道的相關處理函數。
一、添加vxlan 端口
添加命令爲ovs-vsctl add-port br0 vxlan – set interface vxlan type=vxlan,用戶態處理流程和上節的添加端口相同,不同時的是對vxlan 端口的參數配置,發往內核dp 的消息類型爲OVS_VPORT_TYPE_VXLAN,流程如下:
二、內核vxlan 創建
內核ovs_vport_cmd_new ()函數中ovs_vport_add()調用ovs_vxlan_vport_ops 對應的操作函數,其中創建函數vxlan_tnl_create()流程如下:
三、vport 數據結構
根據上述流程分析,vxlan 類型的vport 數據結構如下:
四、vxlan 報文格式
五、vxlan 收包處理
vxlan 隧道報文的處理的入口函數是udp sock 監聽函數vxlan_udp_encap_recv(),處理流程如下:
六、vxlan 發包處理
vlan 在執行action 時,判斷需要發送數據的時候調用發送函數,函數調用do_execute_actions()->do_output()->ovs_vport_send()->vxlan_tnl_send(),這裏vxlan_tnl_send()函數即爲創建vport 端口是註冊ovs_vxlan_vport_ops的send 函數,主要處理流程如下: