1. 程式人生 > >深入理解Neutron -- OpenStack網路實現:VLAN模式

深入理解Neutron -- OpenStack網路實現:VLAN模式

網路節點


類似GRE模式下,br-eth1收到到達的網包,int-br-eth1和phy-br-eth1上分別進行vlan轉換,保證到達br-int上的網包都是帶有內部vlan tag,到達br-eth1上的都是帶有外部vlan tag。br-ex則完成到OpenStack以外網路的連線。檢視網橋資訊,包括三個網橋,br-eth1、br-int和br-ex。

#ovs
3bd78da8-d3b5-4112-a766-79506a7e2801
    Bridge br-ex
        Port "qg-VVV"
            Interface "qg-VVV"
                type: internal
        Port br-ex
            Interface br-ex
                type: internal
        Port "eth0"
            Interface "eth0"
    Bridge br-int
        Port br-int
            Interface br-int
                type: internal
        Port "int-br-eth1"
            Interface "int-br-eth0"
        Port "tapXXX"
            tag: 1
            Interface "tapXXX"
                type: internal
Port "tapWWW"
            tag: 2
            Interface "tapWWW"
                type: internal
        Port "qr-YYY"
            tag: 1
            Interface "qr-YYY"
                type: internal
        Port "qr-ZZZ"
            tag: 2
            Interface "qr-ZZZ"
                type: internal
    Bridge "br-eth1"
        Port "phy-br-eth1"
            Interface "phy-br-eth1"
        Port "br-eth1"
            Interface "br-eth1"
                type: internal
        Port "eth1"
            Interface "eth1"

br-eth1

br-eth1主要負責把物理網路上外部vlan轉化為local vlan。

#ovs-ofctl dump-flows br-eth1
NXST_FLOW reply (xid=0x4):
 cookie=0x0, duration=144.33s, table=0, n_packets=13, n_bytes=28404, idle_age=24, hard_age=65534, priority=4,in_port=5,dl_vlan=101 actions=mod_vlan_vid:1,NORMAL
 cookie=0x0, duration=144.33s, table=0, n_packets=13, n_bytes=28404, idle_age=24, hard_age=65534, priority=4,in_port=5,dl_vlan=102 actions=mod_vlan_vid:2,NORMAL
 cookie=0x0, duration=608.373s, table=0, n_packets=23, n_bytes=1706, idle_age=65534, hard_age=65534, priority=2,in_port=5 actions=drop
 cookie=0x0, duration=675.373s, table=0, n_packets=58, n_bytes=10625, idle_age=24, hard_age=65534, priority=1 actions=NORMAL

br-int

br-int上掛載了大量的agent來提供各種網路服務,另外負責對發往br-eth1的流量,實現local vlan轉化為外部vlan。

#ovs-ofctl dump-flows br-int
NXST_FLOW reply (xid=0x4):
 cookie=0x0, duration=147294.121s, table=0, n_packets=224, n_bytes=33961, idle_age=13, hard_age=65534, priority=3,in_port=4,dl_vlan=1 actions=mod_vlan_vid:101,NORMAL
 cookie=0x0, duration=603538.84s, table=0, n_packets=19, n_bytes=2234, idle_age=18963, hard_age=65534, priority=2,in_port=4 actions=drop
 cookie=0x0, duration=603547.134s, table=0, n_packets=31901, n_bytes=6419756, idle_age=13, hard_age=65534, priority=1 actions=NORMAL

dnsmasq負責提供DHCP服務,繫結到某個特定的名字空間上,每個需要DHCP服務的租戶網路有自己專屬隔離的DHCP服務(圖中的tapXXX和tapWWW上各自監聽了一個dnsmasq)。

路由是L3 agent來實現,每個子網在br-int上有一個埠(qr-YYY和qr-ZZZ,已配置IP,分別是各自內部子網的閘道器),L3 agent繫結到上面。要訪問外部的公共網路,需要通過L3 agent發出,而不是經過int-br-ex到phy-br-ex(實際上並沒有網包從這個veth pair傳輸)。如果要使用外部可見的floating IP,L3 agent仍然需要通過iptables來進行NAT。

每個L3 agent或dnsmasq都在各自獨立的名字空間中,如下圖所示,其中同一租戶的兩個子網都使用了同一個路由器。


對於子網使用不同路由器的情況,多個路由器會在自己獨立的名字空間中。例如要實現兩個租戶的兩個子網的情況,如下圖所示。


這種情況下,網路節點上的名字空間如下圖所示。


br-ex

br-ex要做的事情很簡單,只需要正常轉發即可。

#ovs-ofctl dump-flows br-ex
NXST_FLOW reply (xid=0x4):
 cookie=0x0, duration=6770.969s, table=0, n_packets=5411, n_bytes=306944, idle_age=0, hard_age=65534, priority=0 actions=NORMAL