Open vSwitch中PATCH类型的端口有如下定义:“A pair of virtual devices that act as a patch cable”(一根虚拟电缆),同时在OpenvSwitch官方FAQ可以找到PATCH端口的用途“If
you still want to connect two bridges, you can use a pair of patch ports”(用于连接两个网桥)。

简单化,patch port成对,可以看作是一根虚拟电缆,用来连接两个网桥,如下图:


ovs-vsctl add-br br1  
ovs-vsctl add-br br2  


ovs-vsctl add-port br1 tap1 -- set Interface tap1 type=internal  
ovs-vsctl add-port br2 tap2 -- set Interface tap2 type=internal  


ip link set tap1 netns ns1  
ip link set tap2 netns ns2  


ip netns exec ns1 ip addr add dev tap1  
ip netns exec ns1 ip link set tap1 up  
ip netns exec ns1 ip link set lo up

ip netns exec ns2 ip addr add dev tap2  
ip netns exec ns2 ip link set tap2 up  
ip netns exec ns2 ip link set lo up  

创建patch port

ovs-vsctl add-port br1 patch-ovs-1 -- set Interface patch-ovs-1 type=patch -- set Interface patch-ovs-1 options:peer=patch-ovs-2

ovs-vsctl add-port br2 patch-ovs-2 -- set Interface patch-ovs-2 type=patch -- set Interface patch-ovs-2 options:peer=patch-ovs-1  


ip netns exec ns1 ping  
ip netns exec ns2 ping  
comments powered by Disqus