OVS VxLAN Flow 分析 - 每天5分鍾玩轉 OpenStack(149)


 

 

OVS 的數據流向都是由 Flow 規則控制的,今天我們就來分析 VxLAN 的 Flow 規則。

提個醒:這可能是本教程最燒腦的一節,let's rock it !


下面分析控制節點上的 flow rule,計算節點類似。


br-int 的 flow rule

br-int 的 rule 看上去雖然多,其實邏輯很簡單,br-int 被當作一個二層交換機,其重要的 rule 是下面這條:

cookie=0xaaa0e760a7848ec3, duration=52798.625s, table=0, n_packets=143, n_bytes=14594, idle_age=9415, priority=0 actions=NORMAL

此規則的含義是:根據 vlan 和 mac 進行轉發。


br-tun 的 flow rule

這些才是真正處理 VXLAN 數據包的 rule,流程如下:

fr.png

上圖各方塊中的數字對應 rule 中 table 的序號,比如編號為0的方塊對應下面三條 rule。


table 0

cookie=0xaaa0e760a7848ec3, duration=76707.867s, table=0, n_packets=70, n_bytes=6600, idle_age=33324, hard_age=65534, priority=1,in_port=1 actions=resubmit(,2)

cookie=0xaaa0e760a7848ec3, duration=76543.287s, table=0, n_packets=56, n_bytes=4948, idle_age=33324, hard_age=65534, priority=1,in_port=2 actions=resubmit(,4)

cookie=0xaaa0e760a7848ec3, duration=76707.867s, table=0, n_packets=0, n_bytes=0, idle_age=65534, hard_age=65534, priority=0 actions=drop

結合如下 port 編號:

table 0 flow rule 的含義為:

  1. 從 port 1(patch-int)進來的包,扔給 table 2 處理:actions=resubmit(,2)

  2. 從 port 2(vxlan-a642100b)進來的包,扔給 table 4 處理:actions=resubmit(,4)

即第一條 rule 處理來自內部 br-int(這上面掛載着所有的網絡服務,包括路由、DHCP 等)的數據;第二條 rule 處理來自外部 VXLAN 隧道的數據。


table 4

cookie=0xaaa0e760a7848ec3, duration=76647.039s, table=4, n_packets=56, n_bytes=4948, idle_age=33324, hard_age=65534, priority=1,tun_id=0x64 actions=mod_vlan_vid:1,resubmit(,10)

table 4 flow rule 的含義為: 如果數據包的 VXLAN tunnel ID 為 100(tun_id=0x64),action 是添加內部 VLAN ID 1(tag=1),然后扔給 table 10 去學習。


table 10

cookie=0xaaa0e760a7848ec3, duration=76707.865s, table=10, n_packets=56, n_bytes=4948, idle_age=33324, hard_age=65534, priority=1 actions=learn(table=20,hard_timeout=300,priority=1,cookie=0xaaa0e760a7848ec3,NXM_OF_VLAN_TCI[0..11],NXM_OF_ETH_DST[]=NXM_OF_ETH_SRC[],load:0->NXM_OF_VLAN_TCI[],load:NXM_NX_TUN_ID[]->NXM_NX_TUN_ID[],output:NXM_OF_IN_PORT[]),output:1

table 10 flow rule 的含義為: 學習外部(從 tunnel)進來的包,往 table 20 中添加對返程包的正常轉發規則,然后從 port 1(patch-int)扔給 br-int。


rule 中下面的內容為學習規則,這里就不詳細討論了。

NXM_OF_VLAN_TCI[0..11],NXM_OF_ETH_DST[]=NXM_OF_ETH_SRC[],load:0->NXM_OF_VLAN_TCI[],load:NXM_NX_TUN_ID[]->NXM_NX_TUN_ID[],output:NXM_OF_IN_PORT[]

table 2

cookie=0xaaa0e760a7848ec3, duration=76707.866s, table=2, n_packets=28, n_bytes=3180, idle_age=33324, hard_age=65534, priority=0,dl_dst=00:00:00:00:00:00/01:00:00:00:00:00 actions=resubmit(,20)

cookie=0xaaa0e760a7848ec3, duration=76707.866s, table=2, n_packets=42, n_bytes=3420, idle_age=33379, hard_age=65534, priority=0,dl_dst=01:00:00:00:00:00/01:00:00:00:00:00 actions=resubmit(,22)

table 2 flow rule 的含義為:

  1. br-int 發過來數據如果是單播包,扔給 table 20 處理:resubmit(,20)

  2. br-int 發過來數據如果是多播或廣播包,扔 table 22 處理:resubmit(,22)

table 20

cookie=0xaaa0e760a7848ec3, duration=76543.287s, table=20, n_packets=28, n_bytes=3180, idle_age=33324, hard_age=65534, priority=2,dl_vlan=1,dl_dst=fa:16:3e:fd:8a:ed actions=strip_vlan,set_tunnel:0x64,output:2

cookie=0xaaa0e760a7848ec3, duration=76707.865s, table=20, n_packets=0, n_bytes=0, idle_age=65534, hard_age=65534, priority=0 actions=resubmit(,22)

table 20 flow rule 的含義為:

  1. 第一條規則就是 table 10 學習來的結果。內部 VLAN 號為 1(tag=1),目標 MAC 是 fa:16:3e:fd:8a:ed(virros-vm2)的數據包,即發送給 virros-vm2 的包,action 是去掉 VLAN 號,添加 VXLAN tunnel ID 100(十六進制 0x64),並從 port 2 (tunnel 端口 vxlan-a642100b) 發出。

  2. 對於沒學習到規則的數據包,則扔給 table 22 處理。

table 22

cookie=0xaaa0e760a7848ec3, duration=76543.282s, table=22, n_packets=2, n_bytes=84, idle_age=33379, hard_age=65534, dl_vlan=1 actions=strip_vlan,set_tunnel:0x64,output:2

cookie=0xaaa0e760a7848ec3, duration=76707.82s, table=22, n_packets=40, n_bytes=3336, idle_age=65534, hard_age=65534, priority=0 actions=drop

table 22 flow rule 的含義為: 如果數據包的內部 VLAN 號為 1(tag=1),action 是去掉 VLAN 號,添加 VXLAN tunnel ID 100(十六進制 0x64),並從 port 2 (tunnel 端口 vxlan-a642100b) 發出。


VXLAN 的路由和 floating IP 支持

對於多 VXLAN 之間的 routing 以及 floating IP,實現方式與 vlan 非常類似,這里不再贅述,請參看前面 vlan 相關章節。

總結

本章重點討論 Neutron 的架構,並通過分析 Linux Bridge 和 Open vSwitch 兩個 mechnism driver 的技術細節,實踐了 local,flat,vlan,vxlan 四種網絡類型,同時也討論了 routing 以及 floating IP 的實現細節。


Linux Bridge 和 Open vSwitch 都支持 Securet Group,Firewall as a Service ,Load Balancing as a Service 等高級功能,其實現方式也大致相同。


通過本章的學習,大家應該能夠掌握 Neutron 的理論知識並應用到實踐部署中。


到這里,OpenStack 的核心技術全部討論完了,下一次 CloudMan 會帶着大家回顧一下這些知識,給大家一些深入學習的建議,同時也會談談對后續新教程的一些想法。



免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM