ovs mac learn

 

1、给table 2 添加一条规则

[root@kunpeng82 devuser]# ovs-ofctl add-flow vswtich1 "table=2 actions=learn(table=10,NXM_OF_VLAN_TCI[0..11], \
NXM_OF_ETH_DST[]=NXM_OF_ETH_SRC[], \
load:NXM_OF_IN_PORT[]->NXM_NX_REG0[0..15]), \
resubmit(,3)"

[root@kunpeng82 devuser]# ovs-ofctl dump-flows vswitch1 table=2
cookie=0x0, duration=14.634s, table=2, n_packets=0, n_bytes=0, actions=learn(table=10,NXM_OF_VLAN_TCI[0..11],NXM_OF_ETH_DST[]=NXM_OF_ETH_SRC[],load:NXM_OF_IN_PORT[]->NXM_NX_REG0[0..15]),resubmit(,3)

 

2、 ping

[root@kunpeng82 devuser]# ip netns exec ns7 ping 192.168.1.200
PING 192.168.1.200 (192.168.1.200) 56(84) bytes of data.
64 bytes from 192.168.1.200: icmp_seq=1 ttl=64 time=0.410 ms
64 bytes from 192.168.1.200: icmp_seq=2 ttl=64 time=0.028 ms
^C
--- 192.168.1.200 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1018ms
rtt min/avg/max/mdev = 0.028/0.219/0.410/0.191 ms
[root@kunpeng82 devuser]# ovs-appctl fdb/show vswitch1
 port  VLAN  MAC                Age
    8   200  8a:6a:5f:bb:b0:9a  199
    9   200  8a:74:77:07:f2:fc  199

[root@kunpeng82 devuser]# ovs-ofctl dump-flows vswitch1 table=10   ---什么也没有
[root@kunpeng82 devuser]#

 

 

3、 给table 2  、table 3新增两条规则

[root@kunpeng82 devuser]# ovs-ofctl add-flow  vswitch1 "table=1, priority=99, in_port=9, actions=resubmit(,2)"
[root@kunpeng82 devuser]# ovs-ofctl dump-flows vswitch1 table=3
[root@kunpeng82 devuser]# ovs-ofctl add-flow vswitch1 "table=3,priority=0,actions=NORMAL"

4、再次ping

[root@kunpeng82 devuser]# ip netns exec ns7 ping 192.168.1.200
PING 192.168.1.200 (192.168.1.200) 56(84) bytes of data.
From 192.168.1.117 icmp_seq=1 Destination Host Unreachable
From 192.168.1.117 icmp_seq=2 Destination Host Unreachable
From 192.168.1.117 icmp_seq=3 Destination Host Unreachable
^C
--- 192.168.1.200 ping statistics ---
4 packets transmitted, 0 received, +3 errors, 100% packet loss, time 3108ms
pipe 4
[root@kunpeng82 devuser]# ovs-ofctl dump-flows vswitch1 table=10   有了
 cookie=0x0, duration=13.756s, table=10, n_packets=0, n_bytes=0, vlan_tci=0x0000/0x0fff,dl_dst=8a:74:77:07:f2:fc actions=load:0x9->NXM_NX_REG0[0..15]
[root@kunpeng82 devuser]# ovs-appctl fdb/show vswitch1
 port  VLAN  MAC                Age
    9   200  8a:74:77:07:f2:fc   42
[root@kunpeng82 devuser]# 

 

5、 目前是无法ping 通192.168.1.200,现在针对patch_to_vswitch0再添加一条flow

[root@kunpeng82 devuser]# ovs-ofctl show vswitch1
OFPT_FEATURES_REPLY (xid=0x2): dpid:000006692ef32b44
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
6(tap6_br): addr:c2:74:7d:d9:d9:14
config: 0
state: 0
current: 10GB-FD COPPER
speed: 10000 Mbps now, 0 Mbps max
8(patch_to_vswitc): addr:52:89:c8:d7:62:ce
config: 0
state: 0
speed: 0 Mbps now, 0 Mbps max


ovs-ofctl add-flow vswitch1 "table=1, priority=99, in_port=8, actions=resubmit(,2)"

6、第三次ping

[root@kunpeng82 devuser]# ovs-ofctl dump-flows vswitch1 
 cookie=0x0, duration=1099.950s, table=0, n_packets=48, n_bytes=2156, priority=0 actions=resubmit(,1)
 cookie=0x0, duration=879.592s, table=1, n_packets=19, n_bytes=826, priority=99,in_port="tap7_br" actions=resubmit(,2)
 cookie=0x0, duration=4.751s, table=1, n_packets=0, n_bytes=0, priority=99,in_port="patch_to_vswitc" actions=resubmit(,2)
 cookie=0x0, duration=1652.407s, table=2, n_packets=19, n_bytes=826, actions=learn(table=10,NXM_OF_VLAN_TCI[0..11],NXM_OF_ETH_DST[]=NXM_OF_ETH_SRC[],load:NXM_OF_IN_PORT[]->NXM_NX_REG0[0..15]),resubmit(,3)
 cookie=0x0, duration=860.999s, table=3, n_packets=19, n_bytes=826, priority=0 actions=NORMAL
 cookie=0x0, duration=852.830s, table=10, n_packets=0, n_bytes=0, vlan_tci=0x0000/0x0fff,dl_dst=8a:74:77:07:f2:fc actions=load:0x9->NXM_NX_REG0[0..15]
[root@kunpeng82 devuser]# ip netns exec ns7 ping 192.168.1.200
PING 192.168.1.200 (192.168.1.200) 56(84) bytes of data.
64 bytes from 192.168.1.200: icmp_seq=1 ttl=64 time=0.928 ms
64 bytes from 192.168.1.200: icmp_seq=2 ttl=64 time=0.030 ms
64 bytes from 192.168.1.200: icmp_seq=3 ttl=64 time=0.014 ms
64 bytes from 192.168.1.200: icmp_seq=4 ttl=64 time=0.012 ms
^C
--- 192.168.1.200 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3108ms
rtt min/avg/max/mdev = 0.012/0.246/0.928/0.393 ms
[root@kunpeng82 devuser]# ovs-ofctl dump-flows vswitch1 table=10
 cookie=0x0, duration=963.752s, table=10, n_packets=0, n_bytes=0, vlan_tci=0x0000/0x0fff,dl_dst=8a:74:77:07:f2:fc actions=load:0x9->NXM_NX_REG0[0..15]
 cookie=0x0, duration=98.632s, table=10, n_packets=0, n_bytes=0, vlan_tci=0x00c8/0x0fff,dl_dst=8a:6a:5f:bb:b0:9a actions=load:0x8->NXM_NX_REG0[0..15]
[root@kunpeng82 devuser]# 

[root@kunpeng82 devuser]# ovs-appctl fdb/show vswitch1
port VLAN MAC Age
8 200 8a:6a:5f:bb:b0:9a 2
9 200 8a:74:77:07:f2:fc 2

 

 

上一篇:《构建实时机器学习系统》


下一篇:TCP learn