OVS调试介绍
基本概念
基本命令
ovs-vsctl
# ovs-vsctl show
96a55a7e-f49c-4dbe-b359-bafdff2ccad7
Manager "ptcp:6640:92.0.0.12"
Bridge br-tun
Controller "tcp:127.0.0.1:6633"
is_connected: true
fail_mode: secure
Port br-tun
Interface br-tun
type: internal
Port "vxlan-5c00000b"
Interface "vxlan-5c00000b"
type: vxlan
options: {df_default="true", in_key=flow, local_ip="92.0.0.12", out_key=flow, remote_ip="92.0.0.11"}
Port patch-int
Interface patch-int
type: patch
options: {peer=patch-tun}
Bridge br-int
Controller "tcp:127.0.0.1:6633"
is_connected: true
fail_mode: secure
Port "qvo4fab3e51-fc"
tag: 3
Interface "qvo4fab3e51-fc"
Port int-br-ex
Interface int-br-ex
type: patch
options: {peer=phy-br-ex}
Port patch-tun
Interface patch-tun
type: patch
options: {peer=patch-int}
Port br-int
Interface br-int
type: internal
Bridge br-ex
Controller "tcp:127.0.0.1:6633"
is_connected: true
fail_mode: secure
Port phy-br-ex
Interface phy-br-ex
type: patch
options: {peer=int-br-ex}
Port "ens4"
Interface "ens4"
Port br-ex
Interface br-ex
type: internal
网桥查询
# ovs-vsctl list-br
br-ex
br-int
br-tun
端口查询
# ovs-vsctl list-ports br-tun
patch-int
vxlan-5c00000b
接口查询
# ovs-vsctl list-ifaces br-tun
patch-int
vxlan-5c00000b
端口、接口归属查询
# ovs-vsctl port-to-br vxlan-5c00000b
br-tun
# ovs-vsctl iface-to-br vxlan-5c00000b
br-tun
ovs-ofctl
查询网桥流表
### 样例
# ovs-ofctl dump-flows br-tun
NXST_FLOW reply (xid=0x4):
# 从port1进来的包转到表1处理
cookie=0x0, duration=10970.064s, table=0, n_packets=189, n_bytes=16232, idle_age=16, priority=1,in_port=1 actions=resubmit(,1)
# 从port2进来的包转到表2处理
cookie=0x0, duration=10906.954s, table=0, n_packets=29, n_bytes=5736, idle_age=16, priority=1,in_port=2 actions=resubmit(,2)
# 不匹配上面两条则drop
cookie=0x0, duration=10969.922s, table=0, n_packets=3, n_bytes=230, idle_age=10962, priority=0 actions=drop
# 表1,单播包转到表20处理
cookie=0x0, duration=10969.777s, table=1, n_packets=26, n_bytes=5266, idle_age=16, priority=0,dl_dst=00:00:00:00:00:00/01:00:00:00:00:00 actions=resubmit(,20)
# 多播包转到表21处理
cookie=0x0, duration=10969.631s, table=1, n_packets=163, n_bytes=10966, idle_age=21, priority=0,dl_dst=01:00:00:00:00:00/01:00:00:00:00:00 actions=resubmit(,21)
# 表2,port2进来的包在这里处理了.同样是转给表10处理
cookie=0x0, duration=688.456s, table=2, n_packets=29, n_bytes=5736, idle_age=16, priority=1,tun_id=0x1 actions=mod_vlan_vid:1,resubmit(,10)
# 表10,进行规则学习,具体就不解释了。学习到的规则后续会给表20来使用
cookie=0x0, duration=10969.2s, table=10, n_packets=29, n_bytes=5736, idle_age=16, priority=1 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[]),output:1
# 表20, 根据目的mac设置tun_id,通过指定的port发出去
cookie=0x0, duration=682.603s, table=20, n_packets=26, n_bytes=5266, hard_timeout=300, idle_age=16, hard_age=16, priority=1,vlan_tci=0x0001/0x0fff,dl_dst=fa:16:3e:32:0d:db actions=load:0->NXM_OF_VLAN_TCI[],load:0x1->NXM_NX_TUN_ID[],output:2
# 无规则的交给表21处理
cookie=0x0, duration=10969.057s, table=20, n_packets=0, n_bytes=0, idle_age=10969, priority=0 actions=resubmit(,21)
# 表21,根据vlan找到对应的出去的口
cookie=0x0, duration=688.6s, table=21, n_packets=161, n_bytes=10818, idle_age=21, priority=1,dl_vlan=1 actions=strip_vlan,set_tunnel:0x1,output:2
# drop
cookie=0x0, duration=10968.912s, table=21, n_packets=2, n_bytes=148, idle_age=689, priority=0 actions=drop
查询网桥信息
# ovs-ofctl show br-tun
OFPT_FEATURES_REPLY (xid=0x2): dpid:000096d30367a84a
n_tables:254, n_buffers:256
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(patch-int): addr:4e:cb:5f:17:d4:d6
config: 0
state: 0
speed: 0 Mbps now, 0 Mbps max
6(vxlan-5c00000b): addr:ca:48:f4:a1:7e:cb
config: 0
state: 0
speed: 0 Mbps now, 0 Mbps max
LOCAL(br-tun): addr:96:d3:03:67:a8:4a
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
ovs-dpctl
Datapath统计信息查询:hit表示datapath命中数,missed未命中,lost表示没有传递到用户空间就丢弃了
# ovs-dpctl show
system@ovs-system:
lookups: hit:99183 missed:37588 lost:1
flows: 2
masks: hit:231338 total:4 hit/pkt:1.69
port 0: ovs-system (internal)
port 1: br-ex (internal)
port 2: ens4
port 3: br-int (internal)
port 4: br-tun (internal)
port 5: qvo4fab3e51-fc
port 6: vxlan_sys_4789 (vxlan)
查询端口详细统计信息
# ovs-dpctl show -s
system@ovs-system:
lookups: hit:99202 missed:37594 lost:1
flows: 5
masks: hit:231423 total:4 hit/pkt:1.69
port 0: ovs-system (internal)
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 aborted:0 carrier:0
collisions:0
RX bytes:0 TX bytes:0
port 1: br-ex (internal)
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:136729 aborted:0 carrier:0
collisions:0
RX bytes:0 TX bytes:0
port 2: ens4
RX packets:138249 errors:0 dropped:0 overruns:0 frame:0
TX packets:24986 errors:0 dropped:0 aborted:0 carrier:0
collisions:0
RX bytes:8046532 (7.7 MiB) TX bytes:1052004 (1.0 MiB)
port 3: br-int (internal)
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:57 aborted:0 carrier:0
collisions:0
RX bytes:0 TX bytes:0
port 4: br-tun (internal)
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 aborted:0 carrier:0
collisions:0
RX bytes:0 TX bytes:0
port 5: qvo4fab3e51-fc
RX packets:23 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 aborted:0 carrier:0
collisions:0
RX bytes:2364 (2.3 KiB) TX bytes:648
port 6: vxlan_sys_4789 (vxlan)
RX packets:0 errors:? dropped:? overruns:? frame:?
TX packets:0 errors:? dropped:? aborted:? carrier:?
collisions:?
RX bytes:0 TX bytes:0
查询指定端口统计信息
# ovs-ofctl dump-ports br-tun 6
OFPST_PORT reply (xid=0x2): 1 ports
port 6: rx pkts=0, bytes=0, drop=?, errs=?, frame=?, over=?, crc=?
tx pkts=0, bytes=0, drop=?, errs=?, coll=?
ovs-appctl
查询网桥转发规则
# ovs-appctl fdb/show br-tun
port VLAN MAC Age
调试
日志查询
### 可使用 ps -ef|grep ovsdb-server 查询conf.db的具体路径
# ovsdb-tool show-log -m /var/lib/openvswitch/conf.db
端口抓包(方式一)
### 通过进入设备OVS端口所在的网络空间进行监听,例如监听br-tun的patch-int端口
# ip netns list
# ip netns exec [NAME] bash
# ip addr show
# tcpdump -i [DEV]
端口抓包(方式二)
### 通过设置端口镜像来抓取没有具体设备的OVS端口,例如监听br-tun的patch-int端口
# ip link add name snooper0 type dummy
# ip link set dev snooper0 up
# ovs-vsctl add-port br-tun snooper0
# ovs-vsctl -- set Bridge br-tun mirrors=@m -- --id=@snooper0 get Port snooper0 -- --id=@patch-int get Port patch-int -- --id=@m create Mirror name=mymirror select-dst-port=@patch-int select-src-port=@patch-int output-port=@snooper0 select_all=1
# ovs-vsctl clear Bridge br-tun mirrors
# ovs-vsctl del-port br-tun snooper0
# ip link delete dev snooper0
流表匹配
# ovs-appctl ofproto/trace br-tun dl_vlan=1
参考文档
OVS调试介绍的更多相关文章
- Linux调试介绍
1. 介绍 本文介绍了调试的一些常用函数和工具 2. 函数 用户态函数: backtrace()/backtrace_symbols() 内核态函数: dump_stack() 3. 工具 工具: g ...
- Linux之GDB调试介绍与应用20170601
一.GDB调试命令 描述 backtrace(或bt) 查看各级函数调用及参数 finish 连续运行到当前函数返回为止,然后停下来等待命令 frame(或f) 帧编号 选择栈帧 info(或i) ...
- Eclipse 的 Debug 介绍与技巧【转载】
没有任何程序员能够一气呵成的写出没有任何 Bug 的代码,所以很多程序员有相当一部分时间是花费在 Debug 上的,程序调试是每个程序员必须面对的工作.如何使用 Eclipse 进行有效的.尤其是高效 ...
- 移动应用调试之Inspect远程调试
移动应用调试之Inspect远程调试 一.准备工作 chrome浏览器,建议最新版本 如果你点击inspect打开的DevTools窗口一片空白,且刷新无效时,那极有可能是由于被墙的缘故. 二.Ins ...
- [How to] 真机调试
1.简介 真机调试介绍. 在xcode7之前需要每年99刀的代价才能活着开发者权限并能够在真机上调试,现在如果单纯的想在真机上调是就不必花这个钱了. 2.步骤 完毕.
- 051 01 Android 零基础入门 01 Java基础语法 05 Java流程控制之循环结构 13 Eclipse下程序调试——debug入门1
051 01 Android 零基础入门 01 Java基础语法 05 Java流程控制之循环结构 13 Eclipse下程序调试--debug入门1 本文知识点: 程序调试--debug入门1 程序 ...
- 移动应用产品开发-android开发(二)
这段时间实在太忙了,也没什么精力来写博客,还是没养成写博客的习惯,还是得记载下来,不然时间久了就忘记了. 早上一大早就来公司了,趁还早,拟定今天的工作内容和计划后,赶紧记载点东西. 最近做androi ...
- 云计算底层技术-虚拟网络设备(Bridge,VLAN)( 转发)
云计算底层技术-虚拟网络设备(Bridge,VLAN) Posted on September 24, 2017 by opengers in openstack openstack底层技术-各种虚拟 ...
- pycharm 下使用tensorflow 之环境配置
我们常常看代码使用ide里面看,而且还可以看到调试信息(虽然tensorflow有专门的调试介绍哈) 但是,常常代码在终端里面执行可以直接执行,但是到pycharm里面就会出现各种问题,常见的就是找不 ...
随机推荐
- sed 简单用法
sed的一个简单用法: eg:在某一个文件中的一个aaa字段前后添加某些字段. 在aaa前面添加字段:sed -ne 's/aaa/&HELLO/p' test 输出结果:aaaHELLO 在 ...
- java ClassLoader类加载器
原文 首先来了解一下字节码和class文件的区别: 我们知道,新建一个java对象的时候,JVM要将这个对象对应的字节码加载到内存中,这个字节码的原始信息存放在classpath(就是我们新建Java ...
- JavaScript及jQuery学习小结
最近几天学习了很多关于JavaScript和jQuery的文章,稍作梳理后,总结如下. 1.jQuery入门系列 环境搭建 只需引用一个jQuery库文件,即可完成jQuery的环境搭建. 选择器 j ...
- 【shell】shuf命令,随机排序
shuf命令主要用来对输入的每一行进行随机排序输出,我们可以利用这个属性,实现在几个文件中随机读取一个的功能 如下,zls.txt文件有三行,我们想要随机从中读取一行. 可以看到,每次读取顺序都不一样 ...
- 《C prime plus (第五版)》 ---第11章 字符串和字符串函数---3
字符串函数总结: 下面是头文件 string.h 中定义的函数: 序号 函数 & 描述 1 void *memchr(const void *str, int c, size_t n)在参数 ...
- WIFI模块ESP8266的使用指南【转】
本文转载自:http://www.itdadao.com/articles/c15a814052p0.html 本文主要对讲述ESP8266模块硬件连接工作,以及作为服务器和客户端情况下的配置实现的详 ...
- HDU4529 郑厂长系列故事——N骑士问题 —— 状压DP
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4529 郑厂长系列故事——N骑士问题 Time Limit: 6000/3000 MS (Java/Ot ...
- hdu 1002 A + B Problem II(大数)
题意:就是求a+b (a,b都不超过1000位) 思路:用数组存储 第一道大数的题目,虽然很水,纪念一下! 代码: #include<cstdio> #include<cstring ...
- Java常用类Date、Calendar、SimpleDateFormat详解
Date类 java.util 包提供了 Date 类来封装当前的日期和时间,Date 类提供两个构造函数来实例化 Date 对象 第一个构造函数使用当前日期和时间来初始化对象 Date( ) 第 ...
- hdu-5802 Windows 10(贪心)
题目链接: Windows 10 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others ...