加载中…
个人资料
zhangguoqing
zhangguoqing
  • 博客等级:
  • 博客积分:0
  • 博客访问:1,037
  • 关注人气:33
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

OpenStack Neutron-VXLAN模式的br-tun流表分析

(2014-08-06 16:02:05)
标签:

vxlan

neuron

流表

openvswitch

br-tun

分类: OpenStack

OpenStack Neutron-VXLAN模式的br-tun流表分析

 

使用RDO[rdo-release-havana-9.noarch]部署OpenStack Havana版本,详见官方文档

管理网络:192.168.100.0/24

数据网络:192.168.10.0/24

Public网络:10.1.101.0/24


控制+网络节点: eth0 :192.168.100.108 eth1:192.168.10.108       eth2:10.1.101.108

计算节点computer-01eth0:192.168.100.106     eth1:192.168.10.106

计算节点computer-02eth0:192.168.100.107     eth1:192.168.10.107

 

RDO配置文件关键项:

CONFIG_NEUTRON_OVS_TENANT_NETWORK_TYPE=gre

CONFIG_NEUTRON_OVS_TUNNEL_RANGES=1:1000

CONFIG_NEUTRON_OVS_TUNNEL_IF=eth1

CONFIG_NOVA_COMPUTE_HOSTS=192.168.100.106, 192.168.100.107

 先部署为gre网络模式,然后通过修改neutronplugin的配置文件,转换为vxlan模式。

详细请参考http://blog.sina.com.cn/s/blog_6de3aa8a0101omhx.html

 

 

实验一  环境准备及初始化

 在没有任何租户网络的情况下,网络节点

http://s12/mw690/0020LIaCgy6L24HlKXh9b&690Neutron-VXLAN模式的br-tun流表分析" TITLE="OpenStack Neutron-VXLAN模式的br-tun流表分析" />
 

网络节点br-tun上面有4个端口
端口              1(patch-int): addr:1e:56:76:c0:c4:fb               br-int相连

端口              2(vxlan-2): addr:0e:49:27:40:0c:4c                 computer-01相连

端口              3(vxlan-3): addr:aa:3f:91:6d:fb:69                  computer-02相连

端口LOCAL      LOCAL(br-tun): addr:6a:09:cf:75:fa:4e           本地的内部OVS端口br-tun

 

 

查看openflow规则ovs-ofctl dump-flows br-tun

http://s16/mw690/0020LIaCgy6L24ODyB9ef&690Neutron-VXLAN模式的br-tun流表分析" TITLE="OpenStack Neutron-VXLAN模式的br-tun流表分析" />

可以看出Openflow的规则使用不同的表(table),但是table的显示是有顺序的,并且同一个table上的每条规则会一个权值(priority)priority值越大就会越优先选择用来检查规则。

 

详细看table=0,数据包最先被它匹配处理:

table=0, priority=1,in_port=3 actions=resubmit(,3)

table=0, priority=1,in_port=1 actions=resubmit(,1)

table=0, priority=1,in_port=2 actions=resubmit(,3)

table=0 , priority=0 actions=drop

前三条规则priority=1会先被依次执行;

从端口3(vxlan-3)进来的数据包会继续交由table=3处理;

从端口1(patch-int)进来的数据包会继续交由table=1处理;

从端口2(vxlan-2)进来的数据包会继续交由table=3处理;

 

可以发现继续交由table=1的数据包,来自端口1(本地br-int)意味着数据包来自Linux network namespace  qrouterqdhcp。来自端口2和端口3的数据都会继续交由table=3处理,此时table=3并没实质上的网络数据包处理规则,只是简单的丢弃。其它端口的数据则会使用table=0的第四条规则,全部丢弃。

 

详细看table=1

table=1, priority=0,dl_dst=00:00:00:00:00:00/01:00:00:00:00:00 actions=resubmit(,20)

table=1, priority=0,dl_dst=01:00:00:00:00:00/01:00:00:00:00:00 actions=resubmit(,21)

任何来本地br-int上面的数据包都会提交到table=1上面处理;table=1根据数据包的类型来决定如何处理。如果网络数据包是多播包或者广播包,则会actions=resubmit(,21),否则(单播包)会actions=resubmit(,20)table=20它会再继续交由table=21处理,table=21会直接丢弃网络数据包。

http://s7/mw690/0020LIaCgy6L24XXZgW66&690Neutron-VXLAN模式的br-tun流表分析" TITLE="OpenStack Neutron-VXLAN模式的br-tun流表分析" />
上图显示的是一个单播包的处理过程。

 [另外两个计算节点的情况与此类似]

 

 


实验二  创建租户网络环境

通过上面的分析发现,第一阶段所有的数据包都会被丢弃,因为系统中目前还没有任何租户网络。接下来创建外部网络Ext-Net和租户网络环境:

neutron net-create Ext-Net --provider:network_type vxlan --provider:segmentation_id 1 --router:external true

neutron subnet-create  --allocation-pool start=10.1.101.240,end=10.1.101.252 --gateway 10.1.101.254  Ext-Net 10.1.101.0/24 --enable_dhcp=False

 

# bash  A_vxlan_prepare.sh

[root@ctrl ~(keystone_admin)]# cat A_vxlan_prepare.sh

#!/bin/bash

 

# Create Tenant and User #

tenant=TenantA

user=UserA

usermail=usera@stackinsider.com

role=_member_

 

if keystone tenant-list | grep -q $tenant;then

    echo "Tenant $tenant existed!"

else

    tenant_id=`keystone tenant-create --name $tenant | awk '/id/{print $4}'`

fi

 

if keystone user-list | grep -q $user;then

    echo "User $user existed!"

else

    keystone user-create --name=$user --pass=password --tenant-id $tenant_id --email=$usermail

fi

 

#keystone user-role-add --tenant $tenant --user $user --role $role

 

#neutron --os-tenant-name $tenant --os-username $user --os-password password --os-auth-url=http://localhost:5000/v2.0 net-create $tenant-Net  --provider:network_type vxlan

neutron --os-tenant-name $tenant --os-username $user --os-password password --os-auth-url=http://localhost:5000/v2.0 net-create $tenant-Net

subnet_id=`neutron --os-tenant-name $tenant --os-username $user --os-password password --os-auth-url=http://localhost:5000/v2.0 subnet-create $tenant-Net 10.0.0.0/24 | awk '$2~/^id/{print $4}'`

neutron --os-tenant-name $tenant --os-username $user --os-password password --os-auth-url=http://localhost:5000/v2.0 router-create $tenant-R1

neutron --os-tenant-name $tenant --os-username $user --os-password password --os-auth-url=http://localhost:5000/v2.0 router-interface-add $tenant-R1 ${subnet_id}

neutron router-gateway-set $tenant-R1 Ext-Net

 

###

#neutron --os-tenant-name $tenant --os-username $user --os-password password --os-auth-url=http://localhost:5000/v2.0 security-group-list

neutron --os-tenant-name $tenant --os-username $user --os-password password --os-auth-url=http://localhost:5000/v2.0 security-group-rule-create --protocol icmp --direction ingress default

neutron --os-tenant-name $tenant --os-username $user --os-password password --os-auth-url=http://localhost:5000/v2.0 security-group-rule-create --protocol icmp --direction egress default

neutron --os-tenant-name $tenant --os-username $user --os-password password --os-auth-url=http://localhost:5000/v2.0 security-group-rule-create --protocol tcp --direction egress --port-range-min 1 --port-range-max 65535 default

neutron --os-tenant-name $tenant --os-username $user --os-password password --os-auth-url=http://localhost:5000/v2.0 security-group-rule-create --protocol tcp --direction ingress --port-range-min 1 --port-range-max 65535 default

 

执行上面脚本后的TenantA的网络拓扑。

 http://s8/bmiddle/0020LIaCgy6L253BGXJ87&690Neutron-VXLAN模式的br-tun流表分析" TITLE="OpenStack Neutron-VXLAN模式的br-tun流表分析" />

脚本的主要功能如下: 

OpenStack环境中为TenantA添加一个路由器TenantA-R

使路由器TenantA-R与外部公共网络Ext-Net相连接,并设置默认网关;

添加一个网络广播域(即添加一个网络,并设置子网10.0.0.0/24);

如此一来,路由器TenantA-R会出现在网络节点的Linux network namespace中(qrouter),并且会有一个外部网络段的IP(如下图qg网卡)与qrouter相连。子网10.0.0.0/24的第一个网口(如系统qr设备)地址10.0.0.1就是子网的默认网关。

http://s1/mw690/0020LIaCgy6L258tTDa50&690Neutron-VXLAN模式的br-tun流表分析" TITLE="OpenStack Neutron-VXLAN模式的br-tun流表分析" />

在查看网络节点上的br-tun流表

http://s1/mw690/0020LIaCgy6L25cp30Ya0&690Neutron-VXLAN模式的br-tun流表分析" TITLE="OpenStack Neutron-VXLAN模式的br-tun流表分析" />

可以看出:

(1)新增了一条table=3的规则[ table=3, priority=1,tun_id=0x2 actions=mod_vlan_vid:2,resubmit(,10) ]。它描述了tunnel_idvlan_id的映射关系, tunnel_id 0x2是全局唯一的。进而将数据包交由转发到table=10处理。

(2)table=10共有两个action:第一个action是执行MAC地址学习和插入(从tunnel_idvlan_id的映射过程中)学习到的MAC地址,数据出口vxlan端口是table=20。第二个actionoutput:1,将数据送到prot1(即本地br-int)

(3)table=21添加了一条本地vlan_id到全局tunnel_id的映射规则[table=21, priority=1,dl_vlan=2 actions=strip_vlan,set_tunnel:0x2,output:3,output:2 ]。它的action是将本地valn_id=2vlan数据包,剥去vlan标签再打包成tunnel_id=0x2vxlan数据包,广播到其它的隧道端口VTEP(详见http://blog.sina.com.cn/s/blog_6de3aa8a0101oisp.html),本处是端口2(vxlan-2)和端口3(vxlan-3)。默认情况下对未知的单播包也是做同样处理。

说明:可见此条规则默认是将所有的数据包都进行广播到其它所有的vxlan端口隧道,这样的处理是很粗糙的,没有实现vlan的修剪。(These packets are sent by default to ALL nodes in the vxlan mesh. This is a very bad behaviour. The network implementation does not support VLAN pruning.

 



实验三  创建一个虚拟机

 

使用下面命令创建一个虚拟机

nova --os-tenant-name TenantA --os-username UserA --os-password password --os-auth-url=http://localhost:5000/v2.0 boot --flavor 6 --image cirros cirros-0001

虚拟机启动在了computer-02节点上,对应3(vxlan-3): addr:aa:3f:91:6d:fb:69

 

computer-02上面的隧道端口(VTEP)

http://s7/mw690/0020LIaCgy6L25iFuqG26&690Neutron-VXLAN模式的br-tun流表分析" TITLE="OpenStack Neutron-VXLAN模式的br-tun流表分析" />

TenantA Linux network namespace,注意qrouterqdhcpMAC地址

http://s5/mw690/0020LIaCgy6L25nvndq74&690Neutron-VXLAN模式的br-tun流表分析" TITLE="OpenStack Neutron-VXLAN模式的br-tun流表分析" />

computer-02当启动虚拟机时的流表情况

http://s3/mw690/0020LIaCgy6L25rWHpE22&690Neutron-VXLAN模式的br-tun流表分析" TITLE="OpenStack Neutron-VXLAN模式的br-tun流表分析" />

上图正是虚拟机通过DHCP获得私有IP地址的流表时的情况。可以发现table=20新增了两条规则:

table=20, priority=1,vlan_tci=0x0002/0x0fff,dl_dst=fa:16:3e:7e:74:2e actions=load:0->NXM_OF_VLAN_TCI[],load:0x2->NXM_NX_TUN_ID[],output:2

table=20, priority=1,vlan_tci=0x0002/0x0fff,dl_dst=fa:16:3e:e0:62:9e actions=load:0->NXM_OF_VLAN_TCI[],load:0x2->NXM_NX_TUN_ID[],output:2

以上两条规则是table=10学习并插入进来的,包括routerMAC地址(第一条fa:16:3e:7e:74:2e[qrouer:qr])和dhcpMAC地址(第二条 fa:16:3e:e0:62:9e[qdhcp:tap]);出口port都是2(vxlan-1),即网络节点上的br-tun隧道端口。

 

 computer-02虚拟机启动完毕时的流表情况

http://s13/mw690/0020LIaCgy6L25xhnfS1c&690Neutron-VXLAN模式的br-tun流表分析" TITLE="OpenStack Neutron-VXLAN模式的br-tun流表分析" />


网络节点上面的流表情况

http://s7/mw690/0020LIaCty6L25FoBp4d6&690Neutron-VXLAN模式的br-tun流表分析" TITLE="OpenStack Neutron-VXLAN模式的br-tun流表分析" />

网络节点上table=20也同样增加了两条同computer-02上类似的规则:

table=20, priority=1,vlan_tci=0x0002/0x0fff,dl_dst=8e:a3:42:bf:74:a5 actions=load:0->NXM_OF_VLAN_TCI[],load:0x2->NXM_NX_TUN_ID[],output:3

http://s10/mw690/0020LIaCty6L25Iv3Hrb9&690Neutron-VXLAN模式的br-tun流表分析" TITLE="OpenStack Neutron-VXLAN模式的br-tun流表分析" />

发现这条规则的dl_dst=8e:a3:42:bf:74:a5 MAC地址是computer-02节点上qbrqvbMAC地址。qbrqvb连接情况如下:

http://s8/mw690/0020LIaCgy6L25Kc6F1e7&690Neutron-VXLAN模式的br-tun流表分析" TITLE="OpenStack Neutron-VXLAN模式的br-tun流表分析" />

table=20, priority=1,vlan_tci=0x0002/0x0fff,dl_dst=fa:16:3e:9c:d6:4e actions=load:0->NXM_OF_VLAN_TCI[],load:0x2->NXM_NX_TUN_ID[],output:3

http://s6/mw690/0020LIaCgy6L25Om49n25&690Neutron-VXLAN模式的br-tun流表分析" TITLE="OpenStack Neutron-VXLAN模式的br-tun流表分析" />
这个IP地址dl_dst=fa:16:3e:9c:d6:4e就是新创建虚拟机的eth0网卡的MAC地址。

 

上面这两条table=20的规则output端口均为3(vxlan-3),即通往computer-02

 

网络节点虚拟机启动完毕时的流表情况

http://s7/mw690/0020LIaCgy6L25Tnopwa6&690Neutron-VXLAN模式的br-tun流表分析" TITLE="OpenStack Neutron-VXLAN模式的br-tun流表分析" />

http://s7/bmiddle/0020LIaCgy6L25WHYrA46&690Neutron-VXLAN模式的br-tun流表分析" TITLE="OpenStack Neutron-VXLAN模式的br-tun流表分析" />




实验四  虚拟机向外发送单播包

在虚拟机中,发送单播包,pingqrouterqg 10.1.101.240

http://s4/mw690/0020LIaCgy6L261CBYT73&690Neutron-VXLAN模式的br-tun流表分析" TITLE="OpenStack Neutron-VXLAN模式的br-tun流表分析" />


网络节点上的流表情况:

http://s6/mw690/0020LIaCgy6L26iIjhb75&690Neutron-VXLAN模式的br-tun流表分析" TITLE="OpenStack Neutron-VXLAN模式的br-tun流表分析" />
table=20增加了一条学习到的规则:

table=20, priority=1,vlan_tci=0x0002/0x0fff,dl_dst=fa:16:3e:9c:d6:4e actions=load:0->NXM_OF_VLAN_TCI[],load:0x2->NXM_NX_TUN_ID[],output:3

MAC地址fa:16:3e:9c:d6:4e 是虚拟机eth0网卡MAC地址;output3(vxlan3),连通computer-02

 

computer-02节点(虚拟机所在的宿主机)上的流表情况:

http://s16/mw690/0020LIaCgy6L267AibZbf&690Neutron-VXLAN模式的br-tun流表分析" TITLE="OpenStack Neutron-VXLAN模式的br-tun流表分析" />

table=20增加了一条学习到的规则:

table=20, priority=1,vlan_tci=0x0002/0x0fff,dl_dst=fa:16:3e:7e:74:2e actions=load:0->NXM_OF_VLAN_TCI[],load:0x2->NXM_NX_TUN_ID[],output:2MAC地址fa:16:3e:7e:74:2e qrouter qr设备网卡MAC地址,就是虚拟机所在私有网段10.0.0.0/24的网关10.0.0.1的物理地址;output2(vxlan1),连通网络节点。

  

综述,虚拟机中的单播包通往router的过程如下:

第一阶段(在虚拟机的宿主计算节点computer-02上的处理过程)

[root@com-02 ~]# brctl show

bridge name         bridge id               STP enabled     interfaces

qbr7930f598-f4   8000.8ea342bf74a5   no            qvb7930f598-f4

                                                     tap7930f598-f4

 

[root@com-02 ~]# ovs-ofctl show br-tun | grep -v -E "REPLY|n_tables|capabilities:|actions:|config:|state:"

 1(patch-int): addr:ee:3d:38:db:6e:a6

     speed: 0 Mbps now, 0 Mbps max

 2(vxlan-1): addr:82:45:57:3f:51:a0

     speed: 0 Mbps now, 0 Mbps max

 3(vxlan-2): addr:fa:eb:af:8e:73:f0

     speed: 0 Mbps now, 0 Mbps max

 LOCAL(br-tun): addr:12:69:6d:2a:ca:41

     speed: 0 Mbps now, 0 Mbps max

 

[root@com-02 ~]# ovs-vsctl show

24a10adb-d04b-4245-a048-05104704ea4c

    Bridge br-tun

        Port patch-int

            Interface patch-int

                type: patch

                options: {peer=patch-tun}

        Port "vxlan-1"

            Interface "vxlan-1"

                type: vxlan

                options: {in_key=flow, local_ip="192.168.10.107", out_key=flow, remote_ip="192.168.10.108"}[网络节点IP]

        Port "vxlan-2"

            Interface "vxlan-2"

                type: vxlan

                options: {in_key=flow, local_ip="192.168.10.107", out_key=flow, remote_ip="192.168.10.106"}

        Port br-tun

            Interface br-tun

                type: internal

    Bridge br-int

        Port patch-tun

            Interface patch-tun

                type: patch

                options: {peer=patch-int}

        Port "qvo7930f598-f4"

            tag: 2

            Interface "qvo7930f598-f4"

        Port br-int

            Interface br-int

                type: internal

    ovs_version: "1.11.0"

 

(1)计算节点computer-02上的虚拟机cirros-0001,从网卡eth0(fa:16:3e:9c:d6:4e)发出的数据包,通过tap7930f598-f4,到Linux Bridge qbr7930f598-f4,再到qvb7930f598-f4;最后通过br-int上面的port  qvo7930f598-f4patch-tun进入到OVS网桥br-tun上,交给流表处理。数据包入口为“端口1(patch-int): addr:ee:3d:38:db:6e:a6”。

(2)table=0处理,选择规则table=0, priority=1,in_port=1 actions=resubmit(,1);此条规则将数据包交由table=1处理

(3) table=1处理,它是一个单播包选择规则table=1, priority=0,dl_dst=00:00:00:00:00:00/01:00:00:00:00:00 actions=resubmit(,20)处理,交由table=20处理。

(4)table=20处理,首先选择table=20, priority=1,vlan_tci=0x0002/0x0fff,dl_dst=fa:16:3e:7e:74:2e actions=load:0->NXM_OF_VLAN_TCI[],load:0x2->NXM_NX_TUN_ID[],output:2这条规则(priority=1)处理。这条规则使由table=10通过Learn MAC Addresses插入的。可以匹配到MAC地址fa:16:3e:7e:74:2e (它是qrouter qr设备10.0.0.1网卡MAC地址),action是设置tunnel_id0x0002(vlan_tci=0x0002/0x0fff && load:0x2->NXM_NX_TUN_ID[]),填充数据包vlan_id位为 ”0” (load:0->NXM_OF_VLAN_TCI[]) 即剥去802.1Q协议的vlan标签。最后output:2将数据包发送到端口2(vxlan-1): addr:82:45:57:3f:51:a0,通向网络节点的br-tun[后续处理,见下面第二阶段]

 

[注意]若没有匹配到table=20MAC地址会选择priority=0的规则[ table=20, priority=0 actions=resubmit(,21) ],交由table=21处理;table=21的规则[ table=21, priority=1,dl_vlan=2 actions=strip_vlan,set_tunnel:0x2,output:3,output:2 ]被选择,会将数据包的本地vlan_id=2的标签剥去(strip_vlan),打上tunnel标签(set_tunnel:0x2),最后floods到其它所有的vxlan隧道端点VTEP。这里是output:3,output:2,分别对端口3(vxlan-2): addr:fa:eb:af:8e:73:f0(通向computer-01)和应端口2(vxlan-1): addr:82:45:57:3f:51:a0(通向网络节点) [这个数据包泛洪过程大概就是table=10MAC地址学习手段吧?我不确定,还需要进一步确认!]

 

 

第二阶段(在网络节点上的处理过程)

[root@ctrl ~(keystone_admin)]# brctl show

bridge name     bridge id               STP enabled     interfaces

[root@ctrl ~(keystone_admin)]# ovs-ofctl show br-tun | grep -v -E "REPLY|n_tables|capabilities:|actions:|config:|state:"

 1(patch-int): addr:1e:56:76:c0:c4:fb

     speed: 0 Mbps now, 0 Mbps max

 2(vxlan-2): addr:0e:49:27:40:0c:4c

     speed: 0 Mbps now, 0 Mbps max

 3(vxlan-3): addr:aa:3f:91:6d:fb:69

     speed: 0 Mbps now, 0 Mbps max

 LOCAL(br-tun): addr:6a:09:cf:75:fa:4e

     speed: 0 Mbps now, 0 Mbps max

[root@ctrl ~(keystone_admin)]#

[root@ctrl ~(keystone_admin)]# ovs-vsctl show

2889511f-81eb-4ef6-9ca2-ae417944f0a0

    Bridge br-int

        Port br-int

            Interface br-int

                type: internal

        Port "tap3b882f73-19"

            tag: 2

            Interface "tap3b882f73-19"

                type: internal

        Port "qr-ad0faddd-f8"

            tag: 2

            Interface "qr-ad0faddd-f8"

                type: internal

        Port patch-tun

            Interface patch-tun

                type: patch

                options: {peer=patch-int}

    Bridge br-tun

        Port "vxlan-3"

            Interface "vxlan-3"

               type: vxlan

               options: {in_key=flow, local_ip="192.168.10.108", out_key=flow, remote_ip="192.168.10.107"}[computer-02节点IP]

        Port patch-int

            Interface patch-int

                type: patch

                options: {peer=patch-tun}

        Port "vxlan-2"

            Interface "vxlan-2"

                type: vxlan

                options: {in_key=flow, local_ip="192.168.10.108", out_key=flow, remote_ip="192.168.10.106"}

        Port br-tun

            Interface br-tun

                type: internal

    Bridge br-ex

        Port "eth2"

            Interface "eth2"

        Port br-ex

            Interface br-ex

                type: internal

        Port "qg-4ec0d169-6b"

            Interface "qg-4ec0d169-6b"

                type: internal

    ovs_version: "1.11.0"

(1)网络节点上面br-tun收到了来自computer-02的数据包,br-tun的入口为端口3(vxlan-3)computer-02相连。table=0处理,选择table=0 , priority=1,in_port=3 actions=resubmit(,3)这条规则,将数据包交由table=3处理。

(2)table=3处理,选择 table=3, priority=1,tun_id=0x2 actions=mod_vlan_vid:2,resubmit(,10)这条规则处理,发现tun_id=0x2actionmod_vlan_vid:2即做tun_idvlan_id的转换,剥去vxlan隧道标签,重新修改封装为vlan数据包,最后交由table=10

(3)table=10处理,第一个action是进行MAC地址学习actions=learn (table=20,hard_timeout=300,priority=1,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=20中,变为(table=20, n_packets=9, n_bytes=962, hard_timeout=300, idle_age=86, hard_age=86, priority=1,vlan_tci=0x0002/0x0fff,dl_dst=fa:16:3e:7e:74:2e actions=load:0->NXM_OF_VLAN_TCI[],load:0x2->NXM_NX_TUN_ID[],output:2)。第二个actionoutput:1,将数据包送到端口1(patch-int): addr:ee:3d:38:db:6e:a6

(4)通过br-tun上面的patch-int,数据包自然 会被传输到br-int网桥上,br-int网桥上有个端口是qr-ad0faddd-f8 (MAC地址是FA:16:3E:7E:74:2E IP地址是10.0.0.1),它正是虚拟机所在子网10.0.0.0/24的网关端口,此时数据包已经进入到qrouter (Linux network namespace)中了,进而通过qrouter的路由找到qg-4ec0d169-6b端口,它的IP地址10.1.101.240就是虚拟机所ping的地址。

 

[值得思考的细节] 当虚拟机再次发来单播数据包时,网络节点这里是怎么使用到新增加的table=20(table=20, priority=1,vlan_tci=0x0002/0x0fff,dl_dst=fa:16:3e:9c:d6:4e actions=load:0->NXM_OF_VLAN_TCI[],load:0x2->NXM_NX_TUN_ID[],output:3)[fa:16:3e:9c:d6:4e是虚拟机MAC地址]这条规则的?事实上从计算节点过来的数据包最终都会交到table=10处理的。因为仅有网络节点入口端口为1(patch-int)时,才有可能将数据包交到table=20处理。那么table=20新增加的作用就是当网络节点上从端口为1(patch-int)进来的数据包要与MAC地址为fa:16:3e:9c:d6:4e的虚拟机单播通信时,此条规则才会被启用,免去了table=10的学习过程,可以通过这条规则的action(outpute:端口号)直接到虚拟机所在计算节点computer-02br-tun上,通过流表规则数据包转至computer-02br-int,再通过qvoqvbqbrtap设备,最终到达虚拟机的eth0网卡(MAC地址是fa:16:3e:9c:d6:4e)[详细过程见下一个实验。]

 

[注意] 经过一段时间后,网络节点和计算节点computer-02上面新增的br-tun流表table=20的规则会自动消失。

 



实验五  外部向虚拟机发送数据包

 小实验()

在网络节点,直接通过Linux network namespace 向虚拟机发送icmp

[root@ctrl ~(keystone_admin)]# ip netns exec qrouter-c7a14caa-94b5-485f-ad42-b5f07d3a76ac ping 10.0.0.2     

PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data.

64 bytes from 10.0.0.2: icmp_seq=1 ttl=64 time=8.66 ms

64 bytes from 10.0.0.2: icmp_seq=2 ttl=64 time=1.94 ms

64 bytes from 10.0.0.2: icmp_seq=3 ttl=64 time=3.20 ms

64 bytes from 10.0.0.2: icmp_seq=4 ttl=64 time=1.51 ms

64 bytes from 10.0.0.2: icmp_seq=5 ttl=64 time=1.78 ms

64 bytes from 10.0.0.2: icmp_seq=6 ttl=64 time=1.37 ms

再来查看网络节点和计算节点computer-02上面的br-tun流表,发现并没有任何变化,现在的状态与实验四的结果一样。同时也能验证上面的结论是正确的J

 小实验()

为虚拟机cirros-0001[位于computer-02]分配一个floatingip 10.1.101.241,然后在computer-01上面,通过floatingip向虚拟机发送icmp数据包。

http://s10/mw690/0020LIaCgy6L26qCBhn79&690Neutron-VXLAN模式的br-tun流表分析" TITLE="OpenStack Neutron-VXLAN模式的br-tun流表分析" />

实验发现,无论在哪里直接ping 虚拟机的floatingip 10.1.101.241其效果与上面的小实验()几乎完全相同,各物理节点上的br-tun流表并没有发生任何变化,详细过程表述如下:

第一阶段(网络节点上的处理过程)

[root@ctrl ~(keystone_admin)]# ovs-ofctl show br-tun | grep -v -E "REPLY|n_tables|capabilities:|actions:|config:|state:"

 1(patch-int): addr:1e:56:76:c0:c4:fb

     speed: 0 Mbps now, 0 Mbps max

 2(vxlan-2): addr:0e:49:27:40:0c:4c

     speed: 0 Mbps now, 0 Mbps max

 3(vxlan-3): addr:aa:3f:91:6d:fb:69

     speed: 0 Mbps now, 0 Mbps max

 LOCAL(br-tun): addr:6a:09:cf:75:fa:4e

     speed: 0 Mbps now, 0 Mbps max

 

[root@ctrl ~(keystone_admin)]# ovs-vsctl show

2889511f-81eb-4ef6-9ca2-ae417944f0a0

    Bridge br-int

        Port br-int

            Interface br-int

                type: internal

        Port "tap3b882f73-19"

            tag: 2

            Interface "tap3b882f73-19"

                type: internal

        Port "qr-ad0faddd-f8"

            tag: 2

            Interface "qr-ad0faddd-f8"

                type: internal

        Port patch-tun

            Interface patch-tun

                type: patch

                options: {peer=patch-int}

    Bridge br-tun

        Port "vxlan-3"

            Interface "vxlan-3"

                type: vxlan

                options: {in_key=flow, local_ip="192.168.10.108", out_key=flow, remote_ip="192.168.10.107"}

        Port patch-int

            Interface patch-int

                type: patch

                options: {peer=patch-tun}

        Port "vxlan-2"

            Interface "vxlan-2"

                type: vxlan

                options: {in_key=flow, local_ip="192.168.10.108", out_key=flow, remote_ip="192.168.10.106"}

        Port br-tun

            Interface br-tun

                type: internal

    Bridge br-ex

        Port "eth2"

            Interface "eth2"

        Port br-ex

            Interface br-ex

                type: internal

        Port "qg-4ec0d169-6b"

            Interface "qg-4ec0d169-6b"

                type: internal

ovs_version: "1.11.0"

 http://s1/mw690/0020LIaCgy6L26xQF8s60&690Neutron-VXLAN模式的br-tun流表分析" TITLE="OpenStack Neutron-VXLAN模式的br-tun流表分析" />

(1)floatingip 10.1.101.241就是Ext-Net外部网络的一个IP地址,最终都会找到网络节点10.1.101.108。通过物理网卡eth2OVS网桥br-ex上面。

(2)网络节点的OVS网桥br-ex上面有一些qg 端口(这里目前只有qg-4ec0d169-6b IP地址为10.1.101.240)。匹配到qg后就已经进入到了Linux network namespace qrouter中了,而Linux network namespace又与网络节点的br-int相连。

(3)OVS上的br-int通过端口patch-tun将数据包交给br-tun的流表处理,入口为端口1(patch-int): addr:1e:56:76:c0:c4:fb,则会首先由table=0处理

(4) table=0处理,选择table=0, priority=1,in_port=1 actions=resubmit(,1)这条规则处理,将数据包交由table=1处理。

(5) table=1处理,判断是单播包,选择table=1, priority=0,dl_dst=00:00:00:00:00:00/01:00:00:00:00:00 actions=resubmit(,20)处理,将数据包交由table=20处理。

(6) table=20处理,首先会匹配table=20, priority=1,vlan_tci=0x0002/0x0fff,dl_dst=fa:16:3e:9c:d6:4e actions=load:0->NXM_OF_VLAN_TCI[],load:0x2->NXM_NX_TUN_ID[],output:3 这条规则。发现规则中的MAC地址fa:16:3e:9c:d6:4e刚好是目标虚拟机的MAC地址。最后action output:3,将数据包交由端口3(vxlan-3): addr:aa:3f:91:6d:fb:69处理,端口3刚好连接着虚拟机所在的宿主节点上。[后续处理,详见第二阶段]

 

第二阶段(计算节点computer-02上的处理过程)

[root@com-02 ~]# brctl show

bridge name      bridge id               STP enabled     interfaces

qbr7930f598-f4   8000.8ea342bf74a5       no            qvb7930f598-f4

                                                      tap7930f598-f4

 

[root@com-02 ~]# ovs-ofctl show br-tun | grep -v -E "REPLY|n_tables|capabilities:|actions:|config:|state:"

 1(patch-int): addr:ee:3d:38:db:6e:a6

     speed: 0 Mbps now, 0 Mbps max

 2(vxlan-1): addr:82:45:57:3f:51:a0

     speed: 0 Mbps now, 0 Mbps max

 3(vxlan-2): addr:fa:eb:af:8e:73:f0

     speed: 0 Mbps now, 0 Mbps max

 LOCAL(br-tun): addr:12:69:6d:2a:ca:41

     speed: 0 Mbps now, 0 Mbps max

[root@com-02 ~]# ovs-vsctl show

24a10adb-d04b-4245-a048-05104704ea4c

    Bridge br-tun

        Port patch-int

            Interface patch-int

                type: patch

                options: {peer=patch-tun}

        Port "vxlan-1"

            Interface "vxlan-1"

                type: vxlan

                options: {in_key=flow, local_ip="192.168.10.107", out_key=flow, remote_ip="192.168.10.108"}

        Port "vxlan-2"

            Interface "vxlan-2"

                type: vxlan

                options: {in_key=flow, local_ip="192.168.10.107", out_key=flow, remote_ip="192.168.10.106"}

        Port br-tun

            Interface br-tun

                type: internal

    Bridge br-int

        Port patch-tun

            Interface patch-tun

                type: patch

                options: {peer=patch-int}

        Port "qvo7930f598-f4"

            tag: 2

            Interface "qvo7930f598-f4"

        Port br-int

            Interface br-int

                type: internal

    ovs_version: "1.11.0"

http://s11/mw690/0020LIaCgy6L26E0rQmda&690Neutron-VXLAN模式的br-tun流表分析" TITLE="OpenStack Neutron-VXLAN模式的br-tun流表分析" />

(1)计算节点computer-02OVS网桥br-tun收到了来自网络节点上的数据包,入口端口 2(vxlan-1): addr:82:45:57:3f:51:a0,首先由table=0处理。

(2) table=0处理,匹配table=0, priority=1,in_port=2 actions=resubmit(,3) 这条规则,加油table=3处理。

(3) table=3处理,匹配table=3, priority=1,tun_id=0x2 actions=mod_vlan_vid:2,resubmit(,10)这条规则,交由table=10处理。

(4) table=10处理,仅一条规则。第一个action是进行MAC地址学习,并将学习的规则插入到table=20中。另一个actionoutput:1将数据包交到端口1(patch-int): addr:ee:3d:38:db:6e:a6,通过br-tunpatch-int交到计算节点computer-02br-int上。

(5)br-int再依次通过qvo7930f598-f4qvb7930f598-f4qbr7930f598-f4tap7930f598-f4设备最终到达虚拟机物理网卡eth0 MAC地址为fa:16:3e:9c:d6:4e

 

 


实验六  虚拟机与虚拟机之间发送数据包

再创建一个虚拟机cirros-0002,最好指定创建在计算节点computer-01上。然后两虚拟机之间互ping,观察br-tun 流表变化。()

 

 


 

以上是个人的理解和观点,仅供参考,欢迎雅正!!!


引文:

http://www.opencloudblog.com/?p=300

http://blog.sina.com.cn/s/blog_6de3aa8a0101omhx.html

http://blog.sina.com.cn/s/blog_6de3aa8a0101pfgz.html

 

 

 





 

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有