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

OVS 的數據流向都是由 Flow 規則控制的,今天咱們就來分析 VxLAN 的 Flow 規則。
提個醒:這多是本教程最燒腦的一節,let's rock it !cookie

下面分析控制節點上的 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=NORMALspa

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

br-tun 的 flow ruleip

這些纔是真正處理 VXLAN 數據包的 rule,流程以下:ci

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 會帶着你們回顧一下這些知識,給你們一些深刻學習的建議,同時也會談談對後續新教程的一些想法。

相關文章
相關標籤/搜索