openflow 流表操作

1.列出br-int网桥的接口
ovs-ofctl -O OpenFlow13 show br-int
[root@odl-controller ~]#  ovs-ofctl -O OpenFlow13 show br-int
OFPT_FEATURES_REPLY (OF1.3) (xid=0x2): dpid:0000484e1e128b23
n_tables:254, n_buffers:256
capabilities: FLOW_STATS TABLE_STATS PORT_STATS GROUP_STATS QUEUE_STATS
OFPST_PORT_DESC reply (OF1.3) (xid=0x3):
 LOCAL(br-int): addr:48:4e:1e:12:8b:23
     config:     PORT_DOWN
     state:      LINK_DOWN
     speed: 0 Mbps now, 0 Mbps max
OFPT_GET_CONFIG_REPLY (OF1.3) (xid=0x5): frags=normal miss_send_len=0

2.列出br-int网桥的接口
ovs-ofctl dump-ports -O OpenFlow13 br-int
[root@odl-compute ~]# ovs-ofctl dump-ports -O OpenFlow13 br-int
OFPST_PORT reply (OF1.3) (xid=0x2): 5 ports
  port  4: rx pkts=4448, bytes=225640, drop=0, errs=0, frame=0, over=0, crc=0
           tx pkts=5158, bytes=554865, drop=0, errs=0, coll=0
           duration=22948.948s
  port LOCAL: rx pkts=0, bytes=0, drop=0, errs=0, frame=0, over=0, crc=0
           tx pkts=0, bytes=0, drop=0, errs=0, coll=0
           duration=25797.287s
  port  1: rx pkts=16430, bytes=733284, drop=0, errs=0, frame=0, over=0, crc=0
           tx pkts=4830, bytes=526451, drop=0, errs=0, coll=0
           duration=24142.899s
  port  2: rx pkts=16179, bytes=706938, drop=0, errs=0, frame=0, over=0, crc=0
           tx pkts=4611, bytes=502043, drop=0, errs=0, coll=0
           duration=22950.396s
  port  3: rx pkts=17443, bytes=877154, drop=0, errs=0, frame=0, over=0, crc=0
           tx pkts=5108, bytes=549789, drop=0, errs=0, coll=0

           duration=22950.233s


3.列出br-int网桥的某个接口的详细信息
ovs-ofctl dump-ports -O OpenFlow13 br-int 1
[root@odl-compute ~]# ovs-ofctl dump-ports -O OpenFlow13 br-int 1
OFPST_PORT reply (OF1.3) (xid=0x2): 1 ports
  port  1: rx pkts=16462, bytes=734628, drop=0, errs=0, frame=0, over=0, crc=0
           tx pkts=4839, bytes=527432, drop=0, errs=0, coll=0
           duration=24184.573s

4.查看 Open vSwitch 中的端口信息
[root@odl-compute ~]# ovs-ofctl show -O OpenFlow13 br-int
OFPT_FEATURES_REPLY (OF1.3) (xid=0x2): dpid:0000049049c672bf
n_tables:254, n_buffers:256
capabilities: FLOW_STATS TABLE_STATS PORT_STATS GROUP_STATS QUEUE_STATS
OFPST_PORT_DESC reply (OF1.3) (xid=0x3):
 1(tap8f178fef-10): addr:fe:16:3e:7f:3a:32
     config:     0
     state:      0
     current:    10MB-FD COPPER
     speed: 10 Mbps now, 0 Mbps max
 2(tapc7a9a0a9-75): addr:fe:16:3e:bd:b2:4e
     config:     0
     state:      0
     current:    10MB-FD COPPER
     speed: 10 Mbps now, 0 Mbps max

5.获得网络接口的 OpenFlow 编号
[root@odl-compute ~]# ovs-vsctl get Interface tap8f178fef-10 ofport
1

6.查看网桥下的流表
ovs-ofctl dump-flows -O OpenFlow13 br-int
[root@odl-controller ~]#  ovs-ofctl dump-flows -O OpenFlow13 br-int
OFPST_FLOW reply (OF1.3) (xid=0x2):
 cookie=0x2b00000000000001, duration=6736.339s, table=0, n_packets=0, n_bytes=0, priority=100,dl_type=0x88cc actions=CONTROLLER:65535
 cookie=0x2b00000000000001, duration=6736.339s, table=0, n_packets=0, n_bytes=0, priority=0 actions=drop
 cookie=0x8000000, duration=6736.127s, table=17, n_packets=0, n_bytes=0, priority=0,metadata=0x8000000000000000/0xf000000000000000 actions=write_metadata:0x9000000000000000/0xf000000000000000,goto_table:80
 cookie=0x6800000, duration=6736.127s, table=18, n_packets=0, n_bytes=0, priority=0 actions=goto_table:38
 cookie=0x1080000, duration=6735.816s, table=19, n_packets=0, n_bytes=0, priority=100,arp,arp_op=1 actions=group:5000
 cookie=0x1080000, duration=6735.816s, table=19, n_packets=0, n_bytes=0, priority=100,arp,arp_op=2 actions=CONTROLLER:65535,resubmit(,17)

7.查看ovs下的 datapath 的信息
[root@odl-compute ~]# ovs-dpctl show
system@ovs-system:
lookups: hit:466965 missed:14862 lost:0
flows: 18
masks: hit:2249469 total:9 hit/pkt:4.67
port 0: ovs-system (internal)
port 1: br-int (internal)
port 2: tap8f178fef-10
port 3: tapc7a9a0a9-75
port 4: tap2fc1bba5-2b
port 5: tap58e233d9-53
port 6: tap21c9e170-b9
port 7: br-em2 (internal)
port 8: em2
port 9: tap08348107-b8
port 10: vxlan_sys_4789 (vxlan)

8.根据流量显示在流表中的走向
[root@odl-controller ~]# ovs-appctl ofproto/trace br-int in_port=2 | grep "Rule\|action"
Rule: table=0 cookie=0x8000001 priority=5,in_port=2
OpenFlow actions=write_metadata:0x40000000001/0xfffff0000000001,goto_table:36
Rule: table=254 cookie=0 priority=0,reg0=0x2
OpenFlow actions=drop
Datapath actions: drop

9.ovs设置控制器
ovs-vsctl set-controller br0 tcp:1.2.3.4:663

10.ovs添加流表
ovs-ofctl add-flow br0 in_port=1,actions=output:2

11.删除网桥中所有的流表
ovs-ofctl del-flows br0

12.删除根据匹配项删除网桥中的流表
ovs-ofctl del-flows br0 "in_port=1"
  • 0
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值