ovs internal & patch port

Posted dream397

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ovs internal & patch port相关的知识,希望对你有一定的参考价值。

[root@kunpeng82 devuser]# ovs-vsctl add-br s1
[root@kunpeng82 devuser]# ovs-vsctl add-br s2

 技术图片

 

 

[root@kunpeng82 devuser]# ovs-vsctl add-port s1 s1_p1
ovs-vsctl: Error detected while setting up s1_p1: could not open network device s1_p1 (No such device).  See ovs-vswitchd log for details.
ovs-vsctl: The default log directory is "/var/log/openvswitch".
[root@kunpeng82 devuser]# ovs-vsctl add-port s1 s1_p2
ovs-vsctl: Error detected while setting up s1_p2: could not open network device s1_p2 (No such device).  See ovs-vswitchd log for details.
ovs-vsctl: The default log directory is "/var/log/openvswitch".

 

[root@kunpeng82 ovs]# ovs-vsctl add-port s2 s2_p3
ovs-vsctl: Error detected while setting up s2_p3: could not open network device s2_p3 (No such device).  See ovs-vswitchd log for details.
ovs-vsctl: The default log directory is "/var/log/openvswitch".
[root@kunpeng82 ovs]# ovs-vsctl add-port s2 s2_p4
ovs-vsctl: Error detected while setting up s2_p4: could not open network device s2_p4 (No such device).  See ovs-vswitchd log for details.
ovs-vsctl: The default log directory is "/var/log/openvswitch".

 

[root@kunpeng82 ovs]# ip netns add ns_s1
[root@kunpeng82 ovs]# ip link set s1_p1 netns ns_s1
Cannot find device "s1_p1"

[root@kunpeng82 ovs]# ovs-vsctl set Interface s1_p1 type=internal
[root@kunpeng82 ovs]# ip link set s1_p1 netns ns_s1
[root@kunpeng82 ovs]#


[root@kunpeng82 ovs]# ip netns exec ns_s1 ip addr add 192.168.1.103/24 dev s1_p1
[root@kunpeng82 ovs]# ip netns exec ns_s1 ifconfig s1_p1 up
[root@kunpeng82 ovs]#

 

==================================================================================

[root@kunpeng82 ovs]# ovs-vsctl set Interface s2_p4 type=internal

[root@kunpeng82 ovs]# ip link set s2_p4 netns ns_s2
[root@kunpeng82 ovs]# ip netns exec ns_s2 ip addr add 192.168.1.104/24 dev s2_p4

[root@kunpeng82 ovs]# ip netns exec ns_s2 ifconfig s2_p4 up

 

技术图片

 

 查了下原因,原来是lo处于down状态

技术图片

 

 技术图片

 

 

 

Bridge "s1"
        Port "s1_p2"
            Interface "s1_p2"
                error: "could not open network device s1_p2 (No such device)"
        Port "s1"
            Interface "s1"
                type: internal
        Port "s1_p1"
            Interface "s1_p1"
                type: internal
    Bridge "s2"
        Port "s2_p3"
            Interface "s2_p3"
                error: "could not open network device s2_p3 (No such device)"
        Port "s2"
            Interface "s2"
                type: internal
        Port "s2_p4"
            Interface "s2_p4"
                type: internal
[root@kunpeng82 ovs]# ovs-ofctl show s1
OFPT_FEATURES_REPLY (xid=0x2): dpid:0000121c99afe147
n_tables:254, n_buffers:0
capabilities: FLOW_STATS TABLE_STATS PORT_STATS QUEUE_STATS ARP_MATCH_IP
actions: output enqueue set_vlan_vid set_vlan_pcp strip_vlan mod_dl_src mod_dl_dst mod_nw_src mod_nw_dst mod_nw_tos mod_tp_src mod_tp_dst
 1(s1_p1): addr:00:00:00:00:00:00
     config:     PORT_DOWN
     state:      LINK_DOWN
     speed: 0 Mbps now, 0 Mbps max
 LOCAL(s1): addr:12:1c:99:af:e1:47
     config:     PORT_DOWN
     state:      LINK_DOWN
     speed: 0 Mbps now, 0 Mbps max
OFPT_GET_CONFIG_REPLY (xid=0x4): frags=normal miss_send_len=0
[root@kunpeng82 ovs]# ovs-appctl fdb/show s1
 port  VLAN  MAC                Age
    1     0  3e:db:bf:e6:e9:83   62
[root@kunpeng82 ovs]# cat conn.sh 
ovs-vsctl set Interface s1_p1 ofport_request=10
ovs-vsctl set Interface s1_p1 type=internal
ovs-vsctl set Interface s1_p2 ofport_request=11

ovs-vsctl set Interface s2_p3 ofport_request=1
ovs-vsctl set Interface s2_p4 type=internal
ovs-vsctl set Interface s2_p4 ofport_request=2

#ovs-vsctl set Interface s1_p2 type=patch
#ovs-vsctl set Interface s1_p2  options:peer=s2_p3
#ovs-vsctl set Interface s2_p3 type=patch
#ovs-vsctl set Interface s2_p3  options:peer=s1_p2

[root@kunpeng82 ovs]# bash conn.sh 
[root@kunpeng82 ovs]# ovs-ofctl show s1
OFPT_FEATURES_REPLY (xid=0x2): dpid:0000121c99afe147
n_tables:254, n_buffers:0
capabilities: FLOW_STATS TABLE_STATS PORT_STATS QUEUE_STATS ARP_MATCH_IP
actions: output enqueue set_vlan_vid set_vlan_pcp strip_vlan mod_dl_src mod_dl_dst mod_nw_src mod_nw_dst mod_nw_tos mod_tp_src mod_tp_dst
 10(s1_p1): addr:02:22:cd:30:d8:12
     config:     PORT_DOWN
     state:      LINK_DOWN
     speed: 0 Mbps now, 0 Mbps max
 LOCAL(s1): addr:12:1c:99:af:e1:47
     config:     PORT_DOWN
     state:      LINK_DOWN
     speed: 0 Mbps now, 0 Mbps max
OFPT_GET_CONFIG_REPLY (xid=0x4): frags=normal miss_send_len=0

[root@kunpeng82 ovs]# ovs-ofctl show s2
OFPT_FEATURES_REPLY (xid=0x2): dpid:0000bac4cfc32341
n_tables:254, n_buffers:0
capabilities: FLOW_STATS TABLE_STATS PORT_STATS QUEUE_STATS ARP_MATCH_IP
actions: output enqueue set_vlan_vid set_vlan_pcp strip_vlan mod_dl_src mod_dl_dst mod_nw_src mod_nw_dst mod_nw_tos mod_tp_src mod_tp_dst
2(s2_p4): addr:00:00:00:00:00:00
config: PORT_DOWN
state: LINK_DOWN
speed: 0 Mbps now, 0 Mbps max
LOCAL(s2): addr:ba:c4:cf:c3:23:41
config: PORT_DOWN
state: LINK_DOWN
speed: 0 Mbps now, 0 Mbps max
OFPT_GET_CONFIG_REPLY (xid=0x4): frags=normal miss_send_len=0

 

 

技术图片

 

 

 

[root@kunpeng82 ovs]# ovs-ofctl add-flow s1 "in_port=10, actions=output:10"
[root@kunpeng82 ovs]# ovs-ofctl dumps-flow s1
ovs-ofctl: unknown command ‘dumps-flow‘; use --help for help
[root@kunpeng82 ovs]# ovs-ofctl dump-flows s1
 cookie=0x0, duration=113.408s, table=0, n_packets=0, n_bytes=0, in_port="s1_p1" actions=output:"s1_p1"
 cookie=0x0, duration=3138.806s, table=0, n_packets=26, n_bytes=2012, priority=0 actions=NORMAL

  

 现在ip netns exec ns_s1 ping 192.168.1.104 

技术图片

 

 

[root@kunpeng82 ovs]# ovs-ofctl add-flow s1 "in_port=10, actions=output:11"
[root@kunpeng82 ovs]# ovs-ofctl add-flow s1 "in_port=11, actions=output:10"
[root@kunpeng82 ovs]# ovs-ofctl add-flow s2 "in_port=1, actions=output:2"
[root@kunpeng82 ovs]# ovs-ofctl add-flow s2 "in_port=2, actions=output:1"

  

以上是关于ovs internal & patch port的主要内容,如果未能解决你的问题,请参考以下文章

ovs patch端口实现原理

openvswitch patch port使用方法

openvswitch patch port使用方法

Haribit Intern day4 基于esp32 ov2640人脸识别实时监控可行性研究

STM32H750获取OV7670摄像头图像及上位机解码(一维码&二维码)

[20181007]12cR2 Using SQL Patch 2.txt