- 积分
- 16840
在线时间 小时
最后登录1970-1-1
|

楼主 |
发表于 2019-10-25 10:00:36
|
显示全部楼层
实现第一个Table 0,Admission control
# U+ t, P% t+ H
3 d& }2 {% P; M/ P: _0 n包进入vswitch的时候首先进入Table 0,我们在这里可以设定规则,控制那些包可以进入,那些包不可以进入。
; G( V, H3 H6 M' I/ H! Q' o6 ^' l
比如,如果source address是multicast的就不允许进入。
* X/ t0 y0 J) z& E' O) B+ f
/ n0 h4 D2 T8 e! E2 i D# }; w01:00:00:00:00:00/01:00:00:00:00:00是广播地址
6 Z- ]' J: W: [; @7 ^! u" m00:00:00:00:00:00/01:00:00:00:00:00是单播地址
?, q" x" F. g+ H* T这种表示形式类似CIDR
( X: q' t% a* Z, z0 U于是我们添加下面的规则:' m( r1 n. Y4 M' t2 r2 ^5 s
sudo ovs-ofctl add-flow helloworld "table=0, dl_src=01:00:00:00:00:00/01:00:00:00:00:00, actions=drop"
4 k& l# J) X: a9 l6 C2 x3 USTP的也不接受
9 T/ _0 s( u( q* Y# J1 Ssudo ovs-ofctl add-flow helloworld "table=0, dl_dst=01:80:c2:00:00:00/ff:ff:ff:ff:ff:f0, actions=drop"; r9 h) D/ P2 l2 X9 W
我们在添加最后一个flow,这个flow的priority低于default,如果上面两个不匹配,则我们进入table 1
8 F! X1 |) T! B. v L3 a zsudo ovs-ofctl add-flow helloworld "table=0, priority=0, actions=resubmit(,1)"1 {6 I. y, @4 g# H. L
我们查看一下所有的flow4 T/ P: H/ H0 E3 g2 c. K
$ sudo ovs-ofctl dump-flows helloworld
6 T7 j. V( D! H2 NNXST_FLOW reply (xid=0x4):
) |% J3 S0 n- W7 s8 K* b5 o, ?0 scookie=0x0, duration=42.162s, table=0, n_packets=0, n_bytes=0, idle_age=42, priority=0 actions=resubmit(,1) . A+ V# Q7 A. ?5 C
cookie=0x0, duration=232.121s, table=0, n_packets=0, n_bytes=0, idle_age=232, dl_src=01:00:00:00:00:00/01:00:00:00:00:00 actions=drop 6 ]; |* H: Q3 @- {/ u0 P
cookie=0x0, duration=167.636s, table=0, n_packets=0, n_bytes=0, idle_age=167, dl_dst=01:80:c2:00:00:00/ff:ff:ff:ff:ff:f0 actions=drop3 b0 k0 d$ _+ Y. L: X) q
+ _0 g3 H, p( ]; [. u4 M测试Table 0; u; @& p1 T# ]
. N/ b4 y3 c$ P
有个很好的工具ovs-appctl ofproto/trace* B2 o1 o+ c$ ]4 q9 T# M5 T
) n G# g# t8 K
不满足条件DROP
6 O8 }+ O) ], g' ^1 c! x: S& `" a0 h8 o+ n' @: I4 T
$ sudo ovs-appctl ofproto/trace helloworld in_port=1,dl_dst=01:80:c2:00:00:05
4 p+ L0 j: y/ R# }, i2 V5 eFlow: metadata=0,in_port=1,vlan_tci=0x0000,dl_src=00:00:00:00:00:00,dl_dst=01:80:c2:00:00:05,dl_type=0x0000 9 U1 I5 ?3 L! e' F; V. G
Rule: table=0 cookie=0 dl_dst=01:80:c2:00:00:00/ff:ff:ff:ff:ff:f0 ! j k% ] d# ~
OpenFlow actions=drop
- {6 E7 Y7 B0 g% w2 H
; f+ a, p, s+ \& y, b5 F" N8 [Final flow: unchanged - M6 C+ \( U5 F- O
Relevant fields: skb_priority=0,in_port=1,dl_src=00:00:00:00:00:00/01:00:00:00:00:00,dl_dst=01:80:c2:00:00:00/ff:ff:ff:ff:ff:f0,dl_type=0x0000,nw_frag=no 5 F/ ~ U |! N( `' H; h$ w1 d
Datapath actions: drop4 C* L* ~" V& X
6 E( ]) y/ y) o ]
满足条件RESUBMIT/ N8 k; v/ _9 y7 C0 `% S3 r
) H; E& s8 o3 j. ^$ sudo ovs-appctl ofproto/trace helloworld in_port=1,dl_dst=01:80:c2:00:00:10 3 i; _) s6 P- P/ @$ u* N
Flow: metadata=0,in_port=1,vlan_tci=0x0000,dl_src=00:00:00:00:00:00,dl_dst=01:80:c2:00:00:10,dl_type=0x0000
: F) @0 C% @4 d$ n& e) x- G' ^Rule: table=0 cookie=0 priority=0 6 p- _4 G! j* k( t: J* i5 N
OpenFlow actions=resubmit(,1) D& b. C! z# h
/ ?' {9 o- G, a* A& u& e
Resubmitted flow: unchanged
5 x2 w& [$ O: g: b9 f* D( U$ H Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0 / a* J" M2 D n; F+ ?+ a
Resubmitted odp: drop ; }8 |1 {, k4 J
No match* b7 L5 G5 z G# j& J* C* P
5 u2 }1 _! e$ M' d% TFinal flow: unchanged 5 t8 s! A1 [% v5 J! c9 Q
Relevant fields: skb_priority=0,in_port=1,dl_src=00:00:00:00:00:00/01:00:00:00:00:00,dl_dst=01:80:c2:00:00:10/ff:ff:ff:ff:ff:f0,dl_type=0x0000,nw_frag=no
+ ?" l9 o( D# q2 N: f1 NDatapath actions: drop
$ i, x1 H0 v+ d8 x% \2 \
3 T7 ]# \2 }7 W1 t5 C实现第二个Table 1:VLAN Input Processing8 e# P8 A+ Q- f% u" Q& V: O
. N- [0 p0 G! T7 }" ]- i, c1 v- D首先添加一个最低优先级的DROP的规则
C; W& D4 D# \4 ]( }: @$ \
( _6 o/ `+ q: R$ m: U1 }0 [sudo ovs-ofctl add-flow helloworld "table=1, priority=0, actions=drop"
2 {' Q; u, f) n+ w8 |1 ]8 i; y7 v& C' m
对于port 1,是trunk口,无论有没有VLAN Header都接受。
; U, X! b& Q, q* S2 C& R1 Q; O. G; v# @2 B b. h$ r4 {2 N/ |
sudo ovs-ofctl add-flow helloworld "table=1, priority=99, in_port=1, actions=resubmit(,2)"2 T1 O( |1 k6 H* O0 r8 C
$ g: ^0 f$ ]& f- g$ i5 d7 x
对于port 2, 3, 4, 我们希望没有VLAN Tag,然后我们给打上VLAN Tag, w/ w `. X |& J; d
1 b& \ _+ ?2 y
$ sudo ovs-ofctl add-flows helloworld - <<'EOF' / j+ N! Z4 N, v1 q) u
table=1, priority=99, in_port=2, vlan_tci=0, actions=mod_vlan_vid:20, resubmit(,2) . y% V5 \- Z N7 \0 g8 j$ n
table=1, priority=99, in_port=3, vlan_tci=0, actions=mod_vlan_vid:30, resubmit(,2) , D' J# `8 i" u3 {% y3 c
table=1, priority=99, in_port=4, vlan_tci=0, actions=mod_vlan_vid:30, resubmit(,2) ' ^/ Z+ p0 K2 ]$ M; M8 e
EOF
2 r0 H, k4 A/ [# K& r0 n/ q- W2 Z! u( V6 e* N
$ sudo ovs-ofctl dump-flows helloworld $ [ w! O* l$ s; Y/ [
NXST_FLOW reply (xid=0x4):
5 S& p* y+ l1 e# ^0 V: N2 D! scookie=0x0, duration=4478.582s, table=0, n_packets=0, n_bytes=0, idle_age=4478, priority=0 actions=resubmit(,1)
5 B& O8 O0 W, O, T7 fcookie=0x0, duration=4668.541s, table=0, n_packets=0, n_bytes=0, idle_age=4668, dl_src=01:00:00:00:00:00/01:00:00:00:00:00 actions=drop
/ b* _, z/ @+ |3 R0 gcookie=0x0, duration=4604.056s, table=0, n_packets=0, n_bytes=0, idle_age=4604, dl_dst=01:80:c2:00:00:00/ff:ff:ff:ff:ff:f0 actions=drop
% M6 Z( y3 v" ?0 P4 qcookie=0x0, duration=89.273s, table=1, n_packets=0, n_bytes=0, idle_age=89, priority=99,in_port=2,vlan_tci=0x0000 actions=mod_vlan_vid:20,resubmit(,2)
$ Q: g5 E6 [" {) v* R+ xcookie=0x0, duration=89.273s, table=1, n_packets=0, n_bytes=0, idle_age=89, priority=99,in_port=4,vlan_tci=0x0000 actions=mod_vlan_vid:30,resubmit(,2) G& x, ?( E# d
cookie=0x0, duration=89.273s, table=1, n_packets=0, n_bytes=0, idle_age=89, priority=99,in_port=3,vlan_tci=0x0000 actions=mod_vlan_vid:30,resubmit(,2)
* j. N# Y8 d0 O2 G$ scookie=0x0, duration=220.318s, table=1, n_packets=0, n_bytes=0, idle_age=220, priority=99,in_port=1 actions=resubmit(,2) 5 S5 @8 J/ z: `) F* A! z% V
cookie=0x0, duration=298.739s, table=1, n_packets=0, n_bytes=0, idle_age=298, priority=0 actions=drop1 Z0 }" f1 M. y7 |+ H
4 A, z: }3 C! i$ t1 \% ] a测试一个从port 1进入,tag为5的( `3 C2 Q# Z5 ]* ]0 v& b \. G
& R2 Y N, I8 R3 D, |
$ sudo ovs-appctl ofproto/trace helloworld in_port=1,vlan_tci=5
" u* m$ B9 `, `: x0 {7 ], i9 o) GFlow: metadata=0,in_port=1,vlan_tci=0x0005,dl_src=00:00:00:00:00:00,dl_dst=00:00:00:00:00:00,dl_type=0x0000
" k9 Q' X, A0 b' Y8 rRule: table=0 cookie=0 priority=0 3 X# f# g/ y G1 I
OpenFlow actions=resubmit(,1)
9 `9 H% w |- F; L7 B, `% f! ~
* d4 T+ z8 s/ s Resubmitted flow: unchanged 2 Y4 A% h; y% N% r: d9 O
Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
# W+ m1 p! `3 B, `- I Resubmitted odp: drop
+ J( P* u* c4 \9 k& q Rule: table=1 cookie=0 priority=99,in_port=1 7 z6 o3 w9 ^- w# C8 \7 F
OpenFlow actions=resubmit(,2)2 n- @: T/ t9 U* Y9 I( B
" Z* b8 x& ~+ o. ]3 I7 a
Resubmitted flow: unchanged . ?! _$ P+ H* Z
Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0 3 @4 f5 u N3 U5 }8 Y+ y
Resubmitted odp: drop & ?, Q) I% e6 }& k' [6 {! B
No match9 x1 c' h, P0 E! Q' R9 b( K
- t# e9 p3 d' k2 [3 [7 L2 @Final flow: unchanged
+ r, c3 L. X* s WRelevant fields: skb_priority=0,in_port=1,dl_src=00:00:00:00:00:00/01:00:00:00:00:00,dl_dst=00:00:00:00:00:00/ff:ff:ff:ff:ff:f0,dl_type=0x0000,nw_frag=no ' n* S F. ?5 E% Y" S
Datapath actions: drop* c; T( U' b9 a% S8 J4 T
8 T/ C1 k1 r, w测试二,从port 2进入,没有打Tag的% O$ |+ h2 ?7 L# Y3 ^7 I7 I" m @
: ^# {+ _* A. k2 v% \0 h
$ sudo ovs-appctl ofproto/trace helloworld in_port=2 6 d$ L& h* m' a6 w
Flow: metadata=0,in_port=2,vlan_tci=0x0000,dl_src=00:00:00:00:00:00,dl_dst=00:00:00:00:00:00,dl_type=0x0000
- P( H @9 i0 v3 ~' e" U wRule: table=0 cookie=0 priority=0 2 P' |/ U, j8 r/ {
OpenFlow actions=resubmit(,1)
# `! @; K$ W3 z! d' e% i9 t! E
1 A' C0 ^) |/ G5 t9 M: t Resubmitted flow: unchanged
, T1 r- J# s& o9 J j: O: Y Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0 % l U1 w& S `$ y' j
Resubmitted odp: drop 3 j* N5 j! B2 F: t% [% L4 q8 o5 ]
Rule: table=1 cookie=0 priority=99,in_port=2,vlan_tci=0x0000
( o. V6 \+ ~. P, u8 X6 Z$ @ OpenFlow actions=mod_vlan_vid:20,resubmit(,2)0 }7 p$ S1 e) ?; f& b/ E
; T8 o. l3 q3 s0 u f% A; r* ^ o
Resubmitted flow: metadata=0,in_port=2,dl_vlan=20这里被打上了Tag,dl_vlan_pcp=0,dl_src=00:00:00:00:00:00,dl_dst=00:00:00:00:00:00,dl_type=0x0000 7 ~3 ]6 ?' |; I2 ^
Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0 3 c/ O( |8 v/ b a/ _* T( a8 k3 ?
Resubmitted odp: drop 0 h# S5 u, E* f3 f, T" \: R
No match
, ^* S8 \6 j& a" J& e! b# X% [' C. A5 `9 {* [9 s
Final flow: unchanged
% w9 P/ Y: ~9 Z8 e6 e+ A/ j, FRelevant fields: skb_priority=0,in_port=2,vlan_tci=0x0000,dl_src=00:00:00:00:00:00/01:00:00:00:00:00,dl_dst=00:00:00:00:00:00/ff:ff:ff:ff:ff:f0,dl_type=0x0000,nw_frag=no
/ F2 y" |6 A e* v3 W/ O# ~Datapath actions: drop
2 E. T) y' t0 Y0 i
: a2 p, d1 I4 m3 u测试三:从port进入,带Tag 5的
8 ^' e" z+ d: o8 j2 a" |# S. k5 T- `& B( C$ P/ R
$ sudo ovs-appctl ofproto/trace helloworld in_port=2,vlan_tci=5
4 E7 \ B& }' O2 x. ]+ d5 sFlow: metadata=0,in_port=2,vlan_tci=0x0005,dl_src=00:00:00:00:00:00,dl_dst=00:00:00:00:00:00,dl_type=0x0000 1 v. i2 Q7 K7 N" O
Rule: table=0 cookie=0 priority=0
6 t; z1 S( N$ \' d* LOpenFlow actions=resubmit(,1)0 d" P- a j/ T& F0 c
T: m% q( D+ d" A
Resubmitted flow: unchanged
/ N3 g y7 r* x5 f Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
6 Q! |5 X! y# }, l |& ?& s8 {0 X Resubmitted odp: drop
3 A; E& X; ~. M, d" I2 D1 [ Rule: table=1 cookie=0 priority=0
^% A2 K7 O* F. w OpenFlow actions=drop$ Y5 d# ^4 ]: u4 x1 X
( }/ Y6 e+ S1 @' T4 sFinal flow: unchanged 5 d# `/ c' l5 p8 {9 N5 C
Relevant fields: skb_priority=0,in_port=2,vlan_tci=0x0005,dl_src=00:00:00:00:00:00/01:00:00:00:00:00,dl_dst=00:00:00:00:00:00/ff:ff:ff:ff:ff:f0,dl_type=0x0000,nw_frag=no . Y4 D9 e5 l% t/ q# d6 J/ Z: }
Datapath actions: drop) k2 `% z/ U. W' a3 N4 Z1 b6 }0 D. [5 N
; i4 S! j# K W; O0 B- q实现第三个Table 2: MAC, VLAN learning for ingress port
" O2 L- `+ u9 P
1 A9 r; y; [7 z7 x对于普通的switch,都会有这个学习的过程,当一个包到来的时候,由于包里面有MAC,VLAN Tag,以及从哪个口进来的这个信息。于是switch学习后,维护了一个表格port –> MAC –> VLAN Tag。# ?, J& \; k2 s! |- t4 V
* T0 Z7 t! M0 E) j+ f
这样以后如果有需要发给这个MAC的包,不用ARP,switch自然之道应该发给哪个port,应该打什么VLAN Tag。6 i. H7 g; w6 Y, G. N; p' R/ `, Z
& k2 @ O- T+ C( @8 N* N: @3 i5 f! e* LOVS也要学习这个,并维护三个之间的mapping关系。5 c9 L; S& @1 W& F8 I% S1 j2 n
: w. z4 e: A6 b `& S3 l
在我们的例子中,无论是从port进来的本身就带Tag的,还是从port 2, 3, 4进来的后来被打上Tag的,都需要学习。
0 E6 b" c5 g. j& S
' T4 [. O& V& [% ksudo ovs-ofctl add-flow helloworld "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)"6 V9 w6 B& ]6 L9 c+ E7 s
" {% k, H* J. I4 H1 ?0 o8 A这一句比较难理解。
1 w: p/ n! C" N+ a- ^
8 _9 ?; p7 k+ C0 Z4 c! d, D olearn表示这是一个学习的action
2 ~- M k5 Q& ~! D1 P2 y- q
* \7 V& T- [& q# e2 itable 10,这是一个MAC learning table,学习的结果会放在这个table中。# p8 g( c0 C) d/ ], r
F: H. d- @ K6 A
NXM_OF_VLAN_TCI这个是VLAN Tag,在MAC Learning table中,每一个entry都是仅仅对某一个VLAN来说的,不同VLAN的learning table是分开的。在学习的结果的entry中,会标出这个entry是对于哪个VLAN的。
8 n2 j: m) n$ G
( e9 m9 v/ } |* m6 q) A/ A% ONXM_OF_ETH_DST[]=NXM_OF_ETH_SRC[]这个的意思是当前包里面的MAC Source Address会被放在学习结果的entry里面的dl_dst里面。这是因为每个switch都是通过Ingress包来学习,某个MAC从某个port进来,switch就应该记住以后发往这个MAC的包要从这个port出去,因而MAC source address就被放在了Mac destination address里面,因为这是为发送用的。
! \' {7 E4 R- x: _
6 {+ ~ q! q* g, D# C* R. MNXM_OF_IN_PORT[]->NXM_NX_REG0将portf放入register.$ T1 y- [1 l7 ^; o7 `
4 G' j) X- E! K6 {; s# K' W' q一般对于学习的entry还需要有hard_timeout,这是的每个学习结果都会expire,需要重新学习。
% c6 r$ B# d0 O/ e& ^! f- i
9 D4 z( B6 B, e' P: Y& I8 d! O我们再来分析一个实践中,openstack中使用openvswitch的情况,这是br-tun上的规则。( `# M; |. t0 r& t/ q
4 N) A8 ?0 ~0 t. acookie=0x0, duration=802188.071s, table=10, n_packets=4885, n_bytes=347789, idle_age=730, hard_age=65534, 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
5 }7 K. u/ S x% icookie=0x0, duration=802187.786s, table=20, n_packets=0, n_bytes=0, idle_age=65534, hard_age=65534, priority=0 actions=resubmit(,21)
9 f2 G* \) `2 Z8 W' k' d cookie=0x0, duration=802038.514s, table=20, n_packets=1239, n_bytes=83620, idle_age=735, hard_age=65534, priority=2,dl_vlan=1,dl_dst=fa:16:3e:7e:ab:cc actions=strip_vlan,set_tunnel:0x3e9,output:2 5 k/ | Q/ d0 h
cookie=0x0, duration=802187.653s, table=21, n_packets=17, n_bytes=1426, idle_age=65534, hard_age=65534, priority=0 actions=drop 8 C6 M9 {& P8 E( o( T# P. O4 e1 b
cookie=0x0, duration=802055.878s, table=21, n_packets=40, n_bytes=1736, idle_age=65534, hard_age=65534, dl_vlan=1 actions=strip_vlan,set_tunnel:0x3e9,output:2
9 l7 i. d( l9 q7 i3 F* j' G# Q" P1 u8 K7 _# f
这里table 10是用来学习的。table 20是learning table。如果table 20是空的,也即还没有学到什么,则会通过priority=0的规则resubmit到table 21.
6 ~' K! p$ m% f9 m5 N3 u& S+ k% F; @" ^7 y
table 21是发送规则,将br-int上的vlan tag消除,然后打上gre tunnel的id。
|& l2 z0 P& Q- b: b+ q
/ Z& C! [* ]2 x! H8 |) H: P上面的情况中,table 20不是空的,也即发送给dl_dst=fa:16:3e:7e:ab:cc的包不用走默认规则,直接通过table 20就发送出去了。* u4 n4 [2 v! U5 [
7 p9 @' C% {2 W/ F) Y! ]/ T
table 20的规则是通过table 10学习得到的,table 10是一个接受规则。最终output 1,发送给了br-int$ _4 ~+ P6 t" [* ]" ^3 `" r1 d6 Q
- _7 `6 c8 c. I; ~& A; JNXM_OF_VLAN_TCI[0..11]是记录vlan tag,所以学习结果中有dl_vlan=19 b4 ~' x7 {7 ]/ T/ O: O2 u, ~
3 n7 i5 _" P1 y' H8 }. H5 ]7 MNXM_OF_ETH_DST[]=NXM_OF_ETH_SRC[]是将mac source address记录,所以结果中有dl_dst=fa:16:3e:7e:ab:cc0 P) f- ^( j7 }8 }: P6 f
- I7 }# T# A" r0 j6 X! ?% c' q) B- _
load:0->NXM_OF_VLAN_TCI[]意思是发送出去的时候,vlan tag设为0,所以结果中有actions=strip_vlan
. R3 C& ]. F# d4 t# i9 c! P' I8 Y4 }8 N6 W# [. G' W( I) `+ M! Y& I
load:NXM_NX_TUN_ID[]->NXM_NX_TUN_ID[]意思是发出去的时候,设置tunnul id,所以结果中有set_tunnel:0x3e9
2 K) Q1 O- R7 J( y) s# `1 b
# d! ]- n0 x: B6 f* d5 noutput:NXM_OF_IN_PORT[]意思是发送给哪个port,由于是从port2进来的,因而结果中有output:2# H! l0 C4 R2 U3 w2 C) f
7 J: O9 m2 o& h测试一:从port 1来一个vlan为20的mac为50:00:00:00:00:01的包5 M' W) U: b7 U# C
: }7 {. o# d1 _$ V" H
$ sudo ovs-appctl ofproto/trace helloworld in_port=1,vlan_tci=20,dl_src=50:00:00:00:00:01 -generate
2 K6 e& v( s8 d/ _$ P# c* ?Flow: metadata=0,in_port=1,vlan_tci=0x0014,dl_src=50:00:00:00:00:01,dl_dst=00:00:00:00:00:00,dl_type=0x0000
2 W, d8 l: i4 j2 B! c$ D+ d- WRule: table=0 cookie=0 priority=0
* ^/ g# o5 w9 }. i; I9 Q: WOpenFlow actions=resubmit(,1). I: O8 Y4 D" Q9 X( i8 C6 L
- Z, A! J+ y, i) Q, l
Resubmitted flow: unchanged * D- _+ U& l) z5 \- F2 V
Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
+ A0 b' R2 A7 O D6 b Resubmitted odp: drop
# y" \0 \$ ]4 g8 S& V2 [, p Rule: table=1 cookie=0 priority=99,in_port=1 ) U% B8 N* s- b3 G p
OpenFlow actions=resubmit(,2)
& r1 s) {! K6 }) a% P, |* Y3 A1 k) e. T( C
Resubmitted flow: unchanged 6 O4 R0 s& b! T6 j
Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0 , u8 E, L; i# s ^' U" j% Q
Resubmitted odp: drop * N& t! r2 i- R- e+ |4 U8 H
Rule: table=2 cookie=0
% M6 E+ r; c" U# n) K OpenFlow 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)
5 o _0 U2 P6 S& J/ T- R9 N% B% I$ i
) n; e5 x0 d( M8 Z; f5 W) Y1 v Resubmitted flow: unchanged % w1 i x. d, m: }# [
Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
6 f, b, P+ L9 d1 \- T) { Resubmitted odp: drop
; m g& X, {- A) W No match6 `9 N! S* w& `7 G! Y4 N6 p& G
' G% h' s* z1 y6 |6 u. cFinal flow: unchanged 7 J9 f2 {3 E( {: g
Relevant fields: skb_priority=0,in_port=1,vlan_tci=0x0014/0x0fff,dl_src=50:00:00:00:00:01,dl_dst=00:00:00:00:00:00/ff:ff:ff:ff:ff:f0,dl_type=0x0000,nw_frag=no
( I# e+ _( e) a. gDatapath actions: drop
7 n t. S( I) `( b8 R+ f% R
% K' J- _, K3 ^, F( g( |; W" ?3 T$ sudo ovs-ofctl dump-flows helloworld : v9 f' R- B& x; _) s$ a
NXST_FLOW reply (xid=0x4): ) k! {& e* F4 c2 U
cookie=0x0, duration=90537.25s, table=0, n_packets=0, n_bytes=0, idle_age=65534, hard_age=65534, priority=0 actions=resubmit(,1) 6 f. @+ } a- W; d- U
cookie=0x0, duration=90727.209s, table=0, n_packets=0, n_bytes=0, idle_age=65534, hard_age=65534, dl_src=01:00:00:00:00:00/01:00:00:00:00:00 actions=drop
& S6 U9 A( J! c. n- O) Vcookie=0x0, duration=90662.724s, table=0, n_packets=0, n_bytes=0, idle_age=65534, hard_age=65534, dl_dst=01:80:c2:00:00:00/ff:ff:ff:ff:ff:f0 actions=drop 6 T" c5 o; Q/ A. m/ ~( A% t8 |( S
cookie=0x0, duration=86147.941s, table=1, n_packets=0, n_bytes=0, idle_age=65534, hard_age=65534, priority=99,in_port=2,vlan_tci=0x0000 actions=mod_vlan_vid:20,resubmit(,2) u! _0 y# e }4 T7 r
cookie=0x0, duration=86147.941s, table=1, n_packets=0, n_bytes=0, idle_age=65534, hard_age=65534, priority=99,in_port=4,vlan_tci=0x0000 actions=mod_vlan_vid:30,resubmit(,2)
L7 O4 o) `! Z4 H+ o& ]( v9 }cookie=0x0, duration=86147.941s, table=1, n_packets=0, n_bytes=0, idle_age=65534, hard_age=65534, priority=99,in_port=3,vlan_tci=0x0000 actions=mod_vlan_vid:30,resubmit(,2) 7 R# `" A9 |, o
cookie=0x0, duration=86278.986s, table=1, n_packets=0, n_bytes=0, idle_age=65534, hard_age=65534, priority=99,in_port=1 actions=resubmit(,2)
& n) l+ i) X; ^' e! ^cookie=0x0, duration=86357.407s, table=1, n_packets=0, n_bytes=0, idle_age=65534, hard_age=65534, priority=0 actions=drop * g6 p% y, z! |- A6 p
cookie=0x0, duration=83587.281s, table=2, n_packets=0, n_bytes=0, idle_age=65534, hard_age=65534, 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)
) Z( d8 B& ~8 ^" q cookie=0x0, duration=31.258s, table=10, n_packets=0, n_bytes=0, idle_age=31, vlan_tci=0x0014/0x0fff,dl_dst=50:00:00:00:00:01 actions=load:0x1->NXM_NX_REG0[0..15]2 x; a' `8 `( }9 J# ?5 k& x6 I) e
5 l3 n% i) o; R4 [table 10多了一条,vlan为20,dl_dst为50:00:00:00:00:01,发送的时候从port 1出去。
* X% b1 I" F* w1 O$ S8 \+ q0 l3 Q
# C& m7 Q4 k5 u- R- O测试二:从port 2进来,被打上了vlan 20,mac为50:00:00:00:00:02
( w6 w/ o6 z( K+ I4 M) |/ _5 U7 d2 J9 A
$ sudo ovs-appctl ofproto/trace helloworld in_port=2,dl_src=50:00:00:00:00:02 -generate ' S1 G d' e8 g' x. X f
Flow: metadata=0,in_port=2,vlan_tci=0x0000,dl_src=50:00:00:00:00:02,dl_dst=00:00:00:00:00:00,dl_type=0x0000 0 P3 P0 q) z( Y9 u
Rule: table=0 cookie=0 priority=0 ; S4 y( I/ F! O
OpenFlow actions=resubmit(,1)
8 B; B' R5 A! \; k, \
% u+ a" T2 M+ x5 [$ J/ E& H Resubmitted flow: unchanged + y# A. t8 D3 h. ?3 C
Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0 ; k, ]$ @4 x$ l
Resubmitted odp: drop 7 ^2 d+ h' Z+ M. L( t
Rule: table=1 cookie=0 priority=99,in_port=2,vlan_tci=0x0000 ) `3 C* P# v" {
OpenFlow actions=mod_vlan_vid:20,resubmit(,2)
8 c, a5 ]( X/ u7 k9 I2 C( c' F" s* R; e
Resubmitted flow: metadata=0,in_port=2,dl_vlan=20,dl_vlan_pcp=0,dl_src=50:00:00:00:00:02,dl_dst=00:00:00:00:00:00,dl_type=0x0000
0 r: o) }) [: G7 Z" _% i Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0 $ {& B2 g' y5 L- Z O8 W, J
Resubmitted odp: drop
+ ?; y4 h1 `( e6 D1 m3 c Rule: table=2 cookie=0 % P8 O' {" m) u( H4 I; Z+ U4 j
OpenFlow 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)8 _" [, t8 h) ~ a. C
* t: f7 r* s7 t# {/ h5 x
Resubmitted flow: unchanged
5 |: L- j' W0 V9 d! h3 x! m: C Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0 " h& g* O+ [1 o3 R) p+ L
Resubmitted odp: drop - R: P& L: S3 F' G6 p" T$ X
No match+ v' i2 q; A: D3 ]+ A! P" |
7 K V+ k1 W( g4 Q# g
Final flow: unchanged $ i$ Y' `2 _$ g
Relevant fields: skb_priority=0,in_port=2,vlan_tci=0x0000,dl_src=50:00:00:00:00:02,dl_dst=00:00:00:00:00:00/ff:ff:ff:ff:ff:f0,dl_type=0x0000,nw_frag=no 2 f6 m# u+ P1 z- b9 S
Datapath actions: drop3 {: l1 l8 H# K% w
4 V3 p( ]. v: ]& s d$ sudo ovs-ofctl dump-flows helloworld
" f9 O$ H/ q: T' }) M9 u' a; `0 R8 \NXST_FLOW reply (xid=0x4): ( q3 O3 e" ]5 h, Z4 Y" A3 z& J
cookie=0x0, duration=90823.14s, table=0, n_packets=0, n_bytes=0, idle_age=65534, hard_age=65534, priority=0 actions=resubmit(,1)
& C, F0 g; B- Y9 bcookie=0x0, duration=91013.099s, table=0, n_packets=0, n_bytes=0, idle_age=65534, hard_age=65534, dl_src=01:00:00:00:00:00/01:00:00:00:00:00 actions=drop
0 C( i7 [# ?: j3 ?2 zcookie=0x0, duration=90948.614s, table=0, n_packets=0, n_bytes=0, idle_age=65534, hard_age=65534, dl_dst=01:80:c2:00:00:00/ff:ff:ff:ff:ff:f0 actions=drop . _( y$ S( j; c' m$ T9 t# w! _8 F8 r
cookie=0x0, duration=86433.831s, table=1, n_packets=0, n_bytes=0, idle_age=65534, hard_age=65534, priority=99,in_port=2,vlan_tci=0x0000 actions=mod_vlan_vid:20,resubmit(,2)
. _, v7 `$ u4 Q' Z+ d+ fcookie=0x0, duration=86433.831s, table=1, n_packets=0, n_bytes=0, idle_age=65534, hard_age=65534, priority=99,in_port=4,vlan_tci=0x0000 actions=mod_vlan_vid:30,resubmit(,2)
! R F3 l/ [( K! @cookie=0x0, duration=86433.831s, table=1, n_packets=0, n_bytes=0, idle_age=65534, hard_age=65534, priority=99,in_port=3,vlan_tci=0x0000 actions=mod_vlan_vid:30,resubmit(,2) : }; e- S: `3 {9 O2 t7 Y
cookie=0x0, duration=86564.876s, table=1, n_packets=0, n_bytes=0, idle_age=65534, hard_age=65534, priority=99,in_port=1 actions=resubmit(,2) 1 h9 g' x6 |- Z8 ^
cookie=0x0, duration=86643.297s, table=1, n_packets=0, n_bytes=0, idle_age=65534, hard_age=65534, priority=0 actions=drop
7 ]+ L7 p. r3 K) Scookie=0x0, duration=83873.171s, table=2, n_packets=0, n_bytes=0, idle_age=65534, hard_age=65534, 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)
1 h2 d% B7 f$ N cookie=0x0, duration=4.472s, table=10, n_packets=0, n_bytes=0, idle_age=4, vlan_tci=0x0014/0x0fff,dl_dst=50:00:00:00:00:02 actions=load:0x2->NXM_NX_REG0[0..15] 0 o! \2 ]3 g2 z* d+ B3 p$ M
cookie=0x0, duration=317.148s, table=10, n_packets=0, n_bytes=0, idle_age=317, vlan_tci=0x0014/0x0fff,dl_dst=50:00:00:00:00:01 actions=load:0x1->NXM_NX_REG0[0..15]
$ C; L5 | ?$ J- E4 K: R6 I) S7 b8 n; M+ S+ l/ r( k, o. J3 |
实现第四个table 3: Look Up Destination Port
+ C" O5 x( k* i% @+ Y0 Z7 I3 w5 G7 n9 a) d7 {& _9 {
在table 2中,vswtich通过进入的包,学习了vlanid –> mac –> port的映射后,对于要发送的包,可以根据学习到的table 10里面的内容,根据destination mac和vlan,来找到相应的port发送出去,而不用每次都flood
0 ?: P9 o4 X! J: b
9 U% K2 a% K! A, Zsudo ovs-ofctl add-flow helloworld "table=3 priority=50 actions=resubmit(,10), resubmit(,4)"
! j& X" [* |3 ?8 L3 N) f
* Y% Q: n+ b$ h0 p1 T. E$ h添加这条规则,首先到table 10中查找learn table entry,如果找不到则到table 4/ o- W& D* `) }3 R: L) t2 ?3 {! c
, L/ @$ ?4 _6 h8 W/ x如果包本身就是multicast的或者broadcast的,则不用去table 10里面取查找。
! j* _/ s) ]' B5 S4 Z$ s5 g
q- D" l W% }; l H1 Z) }6 f# r- Zsudo ovs-ofctl add-flow helloworld "table=3 priority=99 dl_dst=01:00:00:00:00:00/01:00:00:00:00:00 actions=resubmit(,4)"& b) W- r- K7 U( N2 e
2 M+ J9 c& \3 `我们进行一项测试
0 ~& o; a1 k6 x- X+ H* L, x# H9 K9 G% ?* z& z- p0 j
$ sudo ovs-appctl ofproto/trace helloworld in_port=1,dl_vlan=20,dl_src=f0:00:00:00:00:01,dl_dst=90:00:00:00:00:01 -generate
/ U+ T0 \# v2 J3 i& ~% l' HFlow: metadata=0,in_port=1,dl_vlan=20,dl_vlan_pcp=0,dl_src=f0:00:00:00:00:01,dl_dst=90:00:00:00:00:01,dl_type=0x0000 : Z) ?' }0 M* W; W8 O Q5 O' \
Rule: table=0 cookie=0 priority=0
+ x8 |* P8 O; l! v8 hOpenFlow actions=resubmit(,1)
$ H" q& H! h2 `$ K$ S) [; V
) v7 ]& k/ n4 @2 X8 [( Y0 { Resubmitted flow: unchanged 6 j" N% z( E U, C
Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0 & M( h, C" b: }( H4 d
Resubmitted odp: drop 4 W" [0 l, A# n" h# j
Rule: table=1 cookie=0 priority=99,in_port=1
' w4 `& d. B3 m2 k" n# n1 Y OpenFlow actions=resubmit(,2)
" g$ E: |3 h# a% f, C; `( C/ u) b! W; `" o! B4 f T0 R
Resubmitted flow: unchanged
* r: y0 G( [) h9 G2 t Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0 ' [( m/ N/ j, e) ^8 j+ S, {
Resubmitted odp: drop
, w4 E: E* w& g& i) l2 O) S. W Rule: table=2 cookie=0
9 e& X6 j: Q6 h5 r3 j* g0 e, ?- B OpenFlow 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) B+ ^3 V; ~1 @
/ c3 {, z( O G4 u$ u% m' B Resubmitted flow: unchanged
8 i# a0 c) O# |( T+ V5 c Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
8 @2 [. e. l- ?9 C' f" _4 Q Resubmitted odp: drop
" ~# |. V }9 }% j Rule: table=3 cookie=0 priority=50
+ E, q8 z: F2 \$ O* n# ~4 T OpenFlow actions=resubmit(,10),resubmit(,4)8 t" Q8 \+ Q# i+ Y3 X
" e7 i- b. i, F/ z4 h, a1 v, P
Resubmitted flow: unchanged : g. v U% k) o G, |! _+ E
Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
+ L4 ^0 ^: W; R8 {! F7 K Resubmitted odp: drop
0 V% }7 R3 Y: S: j8 x# ` No match
6 o5 W) i) }$ V' W% d- H4 V! O. P v$ S/ T1 y( y
Resubmitted flow: unchanged
/ c' N) k) ?: t0 ~! ^5 X3 d1 K Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0 ) N+ f' x& Y/ Q. A3 C( O" O6 r
Resubmitted odp: drop # @2 K$ n' r" v
No match! i. X0 ?8 Y$ S" u
) f7 g* b3 ?, v! ]% @! e1 LFinal flow: unchanged 2 G! B8 E9 B1 A
Relevant fields: skb_priority=0,in_port=1,vlan_tci=0x0014/0x0fff,dl_src=f0:00:00:00:00:01,dl_dst=90:00:00:00:00:01,dl_type=0x0000,nw_frag=no
! z( m& [$ \0 FDatapath actions: drop7 f! u L6 ?" b+ U
, P4 }8 H' t* k( m* d
由于目标地址f0:00:00:00:00:01没有在table 10中找到,因而到达table 4.8 O. O. Z8 \- S9 Q3 Z# i
w) T! a2 i5 ^& K" {
但是这次测试使得table 10中学习到了mac地址90:00:00:00:00:01
+ p9 A$ t" q% m/ Y( L8 o: ~+ t/ p( C- A, u
$ sudo ovs-ofctl dump-flows helloworld
) ?. E$ }* F( T, E5 }NXST_FLOW reply (xid=0x4): ! S6 H/ k$ _4 }, {% L. J$ i6 ^
cookie=0x0, duration=91588.452s, table=0, n_packets=0, n_bytes=0, idle_age=65534, hard_age=65534, priority=0 actions=resubmit(,1)
" m, f& c0 G. ~cookie=0x0, duration=91778.411s, table=0, n_packets=0, n_bytes=0, idle_age=65534, hard_age=65534, dl_src=01:00:00:00:00:00/01:00:00:00:00:00 actions=drop
8 E3 H0 E8 {/ B4 h: k+ icookie=0x0, duration=91713.926s, table=0, n_packets=0, n_bytes=0, idle_age=65534, hard_age=65534, dl_dst=01:80:c2:00:00:00/ff:ff:ff:ff:ff:f0 actions=drop ) ]* q6 B! \4 [5 {$ q. @
cookie=0x0, duration=87199.143s, table=1, n_packets=0, n_bytes=0, idle_age=65534, hard_age=65534, priority=99,in_port=2,vlan_tci=0x0000 actions=mod_vlan_vid:20,resubmit(,2) 3 i' }; S; T4 y1 A0 f. ~
cookie=0x0, duration=87199.143s, table=1, n_packets=0, n_bytes=0, idle_age=65534, hard_age=65534, priority=99,in_port=4,vlan_tci=0x0000 actions=mod_vlan_vid:30,resubmit(,2)
9 z6 v9 L5 D2 [+ }/ `$ V9 rcookie=0x0, duration=87199.143s, table=1, n_packets=0, n_bytes=0, idle_age=65534, hard_age=65534, priority=99,in_port=3,vlan_tci=0x0000 actions=mod_vlan_vid:30,resubmit(,2)
; m& w. u' e7 W) o. Z# E3 Bcookie=0x0, duration=87330.188s, table=1, n_packets=0, n_bytes=0, idle_age=65534, hard_age=65534, priority=99,in_port=1 actions=resubmit(,2)
# J( E0 Z( a/ B# J) Q: @1 b8 G6 bcookie=0x0, duration=87408.609s, table=1, n_packets=0, n_bytes=0, idle_age=65534, hard_age=65534, priority=0 actions=drop
, U# X; l* p! F' c$ A; ^cookie=0x0, duration=84638.483s, table=2, n_packets=0, n_bytes=0, idle_age=65534, hard_age=65534, 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) ( V2 N6 D* X: [
cookie=0x0, duration=352.841s, table=3, n_packets=0, n_bytes=0, idle_age=352, priority=50 actions=resubmit(,10),resubmit(,4)
- i$ h4 r1 ?4 y( G$ Q+ U. gcookie=0x0, duration=212.704s, table=3, n_packets=0, n_bytes=0, idle_age=212, priority=99,dl_dst=01:00:00:00:00:00/01:00:00:00:00:00 actions=resubmit(,4) ' C8 [3 j+ ?4 J- g
cookie=0x0, duration=117.364s, table=10, n_packets=0, n_bytes=0, idle_age=117, vlan_tci=0x0014/0x0fff,dl_dst=f0:00:00:00:00:01 actions=load:0x1->NXM_NX_REG0[0..15] 9 s1 {. F( `6 Q0 u3 Y, n6 H. U! ^9 b
cookie=0x0, duration=769.784s, table=10, n_packets=0, n_bytes=0, idle_age=769, vlan_tci=0x0014/0x0fff,dl_dst=50:00:00:00:00:02 actions=load:0x2->NXM_NX_REG0[0..15] 8 v/ c# C" g) {8 l
cookie=0x0, duration=1082.46s, table=10, n_packets=0, n_bytes=0, idle_age=1082, vlan_tci=0x0014/0x0fff,dl_dst=50:00:00:00:00:01 actions=load:0x1->NXM_NX_REG0[0..15]! Y; H3 ^* X/ f7 D% k
9 M9 q* `6 U* }! r, A下面我们进行另一个测试& @- B9 d$ X* A
$ R4 V, t+ Y, M/ g- |2 g
$ sudo ovs-appctl ofproto/trace helloworld in_port=2,dl_src=90:00:00:00:00:01,dl_dst=f0:00:00:00:00:01 -generate
+ g4 }+ M/ j$ I+ cFlow: metadata=0,in_port=2,vlan_tci=0x0000,dl_src=90:00:00:00:00:01,dl_dst=f0:00:00:00:00:01,dl_type=0x0000
( x. g! q3 `% j$ o" [9 xRule: table=0 cookie=0 priority=0 / B8 S# V( [# F& G( O. i% M
OpenFlow actions=resubmit(,1), f" O& `4 [8 T+ b0 e: x
f0 ], R' _# s4 I% y) `* O
Resubmitted flow: unchanged
% V9 i- K2 P: S6 s Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0 . O3 V1 u! O$ k) I) c6 R; C
Resubmitted odp: drop 7 x* A; o; ^) B' m- j/ a& u, g
Rule: table=1 cookie=0 priority=99,in_port=2,vlan_tci=0x0000 " d# O* V* M' }6 i! [; t+ ?
OpenFlow actions=mod_vlan_vid:20,resubmit(,2)+ O5 j1 r0 |: ]6 n. O
# q3 b" L+ K. i6 h0 ?$ O s( F Resubmitted flow: metadata=0,in_port=2,dl_vlan=20,dl_vlan_pcp=0,dl_src=90:00:00:00:00:01,dl_dst=f0:00:00:00:00:01,dl_type=0x0000 : C* ~. O7 I" y0 t# E8 K
Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0 ' V. [1 Z) j* `( g
Resubmitted odp: drop
! A8 ]! B6 e) Z5 \! t Rule: table=2 cookie=0
- h2 Q3 [; n) U6 j OpenFlow 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)" y" ~. s( h9 G- Q
+ p, N( {% z( {& v
Resubmitted flow: unchanged 2 Q- `6 ^) x$ l! v9 h
Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0 / D, K" O* H2 ?2 s2 R
Resubmitted odp: drop $ K8 p* R; c/ _0 T7 e# Q, q+ r
Rule: table=3 cookie=0 priority=50 1 k7 i z6 J) t F
OpenFlow actions=resubmit(,10),resubmit(,4)* d: k& ~$ d* b
8 _6 ]% ?9 z# Z# d m
Resubmitted flow: unchanged
( Z; m( v. I% r% B; i. r Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0 % M, F5 W0 q7 J
Resubmitted odp: drop
- F, d. O0 @: b2 Y4 L* ? Rule: table=10 cookie=0 vlan_tci=0x0014/0x0fff,dl_dst=f0:00:00:00:00:01
* S- a& s- v& x3 _ OpenFlow actions=load:0x1->NXM_NX_REG0[0..15]/ [' d8 h4 x6 I' b
2 ~+ ^, {2 B* O' t/ E
Resubmitted flow: reg0=0x1,metadata=0,in_port=2,dl_vlan=20,dl_vlan_pcp=0,dl_src=90:00:00:00:00:01,dl_dst=f0:00:00:00:00:01,dl_type=0x0000
3 b/ _5 m2 ^! z* e: j. O Resubmitted regs: reg0=0x1 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0 8 H( R. t. \# |- K4 n, K! O$ v
Resubmitted odp: drop
8 c& {+ R& g' z$ P& y No match4 `- J; _. z4 \" k% s8 C
, u, b* o( X4 {: R2 i% h
Final flow: unchanged
1 v4 P: M- }5 V% A$ L& LRelevant fields: skb_priority=0,in_port=2,vlan_tci=0x0000,dl_src=90:00:00:00:00:01,dl_dst=f0:00:00:00:00:01,dl_type=0x0000,nw_frag=no 7 ` o; s& ^1 N$ p% y4 R9 m
Datapath actions: drop
9 Y9 j |& a2 Y: `
& t8 b4 b! p1 I2 s因为刚才学习到了mac地址f0:00:00:00:00:01,所以这次在table 10中找到了这条记录,这次同时也学习到了mac地址90:00:00:00:00:01. K; ]% x! a1 `$ t" w" W
4 Z, V/ X# ? W% J/ l! Z
下面我们再发送第一次的包
2 ]" i1 w& i9 V' A
! n% a9 o4 N6 H1 G, `/ k- q+ i$ sudo ovs-appctl ofproto/trace helloworld in_port=1,dl_vlan=20,dl_src=f0:00:00:00:00:01,dl_dst=90:00:00:00:00:01 -generate
( o0 V) r3 K; `9 w& Y% w aFlow: metadata=0,in_port=1,dl_vlan=20,dl_vlan_pcp=0,dl_src=f0:00:00:00:00:01,dl_dst=90:00:00:00:00:01,dl_type=0x0000 ; E b+ W i) R! r2 W4 \: _/ |# I
Rule: table=0 cookie=0 priority=0
" e2 ]+ n/ W, iOpenFlow actions=resubmit(,1)( I* A* {. h" ]$ e: J! w, H
: t2 K: V+ g9 R2 D7 [
Resubmitted flow: unchanged
* P9 H! [ C, Q# V& Z Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
' z# R' b% Q7 g2 l$ x2 [ Resubmitted odp: drop 8 B7 U% g# @7 c9 n
Rule: table=1 cookie=0 priority=99,in_port=1 5 I; L1 ]! P+ j) K$ H: O: N% z4 w
OpenFlow actions=resubmit(,2)
) v( d1 Y( |" z" I! @7 L3 V G w. P, [
Resubmitted flow: unchanged
- ]' l# H1 r/ Z+ @4 U Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
) j* _0 m2 o7 r9 k Resubmitted odp: drop 4 ^! g3 ^, D" ^7 g
Rule: table=2 cookie=0 / _+ z; X2 K: I7 Y# E# Y/ s/ [
OpenFlow 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)
% {9 [+ W6 U1 E [3 I, M
' z: i& t1 I* t# _6 {0 O3 C Resubmitted flow: unchanged & Z5 S* P b A+ z9 h
Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0 G+ q" R) {0 h0 r. x3 t
Resubmitted odp: drop : J B8 K# @4 w/ u
Rule: table=3 cookie=0 priority=50
* i, I7 Y: I L) l2 N OpenFlow actions=resubmit(,10),resubmit(,4)
# `7 P9 u( U: p2 ~! S+ R- p7 o% a, n1 _' V5 L% C
Resubmitted flow: unchanged
6 K) \, J& L4 l* [4 f Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
: |* @% b4 r3 A$ a Resubmitted odp: drop
- t! p2 v! V; \: `/ A8 p: l" m& I Rule: table=10 cookie=0 vlan_tci=0x0014/0x0fff,dl_dst=90:00:00:00:00:01 ) u! x# M2 U* x, ^
OpenFlow actions=load:0x2->NXM_NX_REG0[0..15]: F5 \. y* U& c6 w; S
- X" @3 z/ |! S
Resubmitted flow: reg0=0x2,metadata=0,in_port=1,dl_vlan=20,dl_vlan_pcp=0,dl_src=f0:00:00:00:00:01,dl_dst=90:00:00:00:00:01,dl_type=0x0000
0 y( V& H' D6 `" p# l Resubmitted regs: reg0=0x2 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
7 E6 t7 Q. T) @1 W" s( |3 m0 o Resubmitted odp: drop
) d1 b# S8 Z+ K. A& b7 ^3 l No match
# F0 @2 }6 s* F1 R. t8 R; f$ m6 h" n) n% Z$ k% }
Final flow: unchanged
! L" W9 k7 |4 c8 NRelevant fields: skb_priority=0,in_port=1,vlan_tci=0x0014/0x0fff,dl_src=f0:00:00:00:00:01,dl_dst=90:00:00:00:00:01,dl_type=0x0000,nw_frag=no
& H1 G5 T1 e7 o! V% R$ _# O7 ADatapath actions: drop
: u7 p# x; d% C9 @- M. Q9 f7 O8 e% t0 N! w1 U+ p, @
发现也在table 10中找到了记录
: I! L" ^# q5 j/ D: S
U! t' W# O( j% e4 }4 F; D实现第五个table 4: Output Processing
7 ^! M1 {+ G3 C" w8 d& [0 m1 B. g a
这个时候,register 0中包含了output port,如果是0则说明是flood。% I9 F) w, S6 h0 E" W4 D
& q8 C7 N y2 L+ W; v# L对于port 1来讲,是trunk port,所以携带的vlan tag就让他带着,从port 1出去。
4 i2 E7 \- b) Y" O( w
7 `4 X+ M0 T- k1 T8 gsudo ovs-ofctl add-flow helloworld "table=4 reg0=1 actions=1"
K1 E+ o2 E3 ~
6 d/ b3 N9 P, o$ ]5 M3 Z* ^$ t对于port 2来讲,是vlan 20的,然而出去的时候,vlan tag会被抹掉,从port 2发出去( v6 [" M8 k/ S. O1 K& L
0 q H( y5 q6 y' @ V
对于port 3, 4来讲,是vlan 30的,然而出去的时候,vlan tag会被抹掉,从port 3, 4出去 j8 N5 Q* ^6 j- D* r) ~1 m9 F I
# h l: [# y0 U0 B
$ sudo ovs-ofctl add-flows helloworld - <<'EOF'
; p5 o; `4 ~6 a. R table=4 reg0=2 actions=strip_vlan,2
% ]% f4 G3 M2 ~, P0 C+ s table=4 reg0=3 actions=strip_vlan,3
2 J. Q1 `' Z# Y table=4 reg0=4 actions=strip_vlan,4 " \7 l7 X6 G- Y
EOF
3 s) m3 Q4 r1 {5 o
% _1 k$ d2 I7 a; ~对于broadcast来讲,我们希望一个vlan的broadcast仅仅在这个vlan里面发送,不影响其他的vlan。
6 F4 Y, ?5 n/ g. t% l" ^5 s: U4 L; J! m! J5 P7 F
$ sudo ovs-ofctl add-flows helloworld - <<'EOF'
* h3 U/ G Z3 G E6 @0 Y5 M- l table=4 reg0=0 priority=99 dl_vlan=20 actions=1,strip_vlan,2 2 {# Q& h8 a; q$ N' S! f( b
table=4 reg0=0 priority=99 dl_vlan=30 actions=1,strip_vlan,3,4
: ]1 s: f" w7 _7 z& A table=4 reg0=0 priority=50 actions=1
) a4 d8 n" _6 W8 {6 KEOF; ]( b# D* u5 J: `! {' X
0 U- N, i7 ]. ^
所以对于register = 0的,也即是broadcast的,属于vlan 20的,则从port 1, 2出去,属于vlan 30的,则从port 1, 3, 4出去。
. X8 ]9 e+ f% L4 t2 U" ^# `) U8 `5 P; U; T% w3 @" M
$ sudo ovs-ofctl dump-flows helloworld
2 M. N/ e) Q8 e$ B) n& a; [4 m' fNXST_FLOW reply (xid=0x4): , o3 e8 G9 s \* z: Q; l# o" o; B
cookie=0x0, duration=92909.119s, table=0, n_packets=0, n_bytes=0, idle_age=65534, hard_age=65534, priority=0 actions=resubmit(,1) 1 l6 q5 N( Y7 [5 E3 j6 m7 S; ^. p
cookie=0x0, duration=93099.078s, table=0, n_packets=0, n_bytes=0, idle_age=65534, hard_age=65534, dl_src=01:00:00:00:00:00/01:00:00:00:00:00 actions=drop
' `8 I3 W w" G; J2 V7 Ccookie=0x0, duration=93034.593s, table=0, n_packets=0, n_bytes=0, idle_age=65534, hard_age=65534, dl_dst=01:80:c2:00:00:00/ff:ff:ff:ff:ff:f0 actions=drop " e/ V8 f8 g! ?- B
cookie=0x0, duration=88519.81s, table=1, n_packets=0, n_bytes=0, idle_age=65534, hard_age=65534, priority=99,in_port=2,vlan_tci=0x0000 actions=mod_vlan_vid:20,resubmit(,2) ( i8 F: ?/ \8 @% `
cookie=0x0, duration=88519.81s, table=1, n_packets=0, n_bytes=0, idle_age=65534, hard_age=65534, priority=99,in_port=4,vlan_tci=0x0000 actions=mod_vlan_vid:30,resubmit(,2)
f, D+ b# z+ n: Qcookie=0x0, duration=88519.81s, table=1, n_packets=0, n_bytes=0, idle_age=65534, hard_age=65534, priority=99,in_port=3,vlan_tci=0x0000 actions=mod_vlan_vid:30,resubmit(,2) ' B5 d- r" Q8 R4 _2 U. x
cookie=0x0, duration=88650.855s, table=1, n_packets=0, n_bytes=0, idle_age=65534, hard_age=65534, priority=99,in_port=1 actions=resubmit(,2) 4 l' G4 v, Q* ]4 M* O2 c* C7 a
cookie=0x0, duration=88729.276s, table=1, n_packets=0, n_bytes=0, idle_age=65534, hard_age=65534, priority=0 actions=drop
1 Q% o! C0 y! H4 bcookie=0x0, duration=85959.15s, table=2, n_packets=0, n_bytes=0, idle_age=65534, hard_age=65534, 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)
" |; H: T# ?7 i% ecookie=0x0, duration=1673.508s, table=3, n_packets=0, n_bytes=0, idle_age=1673, priority=50 actions=resubmit(,10),resubmit(,4)
' D# C F' k0 p9 ]7 }1 {cookie=0x0, duration=1533.371s, table=3, n_packets=0, n_bytes=0, idle_age=1533, priority=99,dl_dst=01:00:00:00:00:00/01:00:00:00:00:00 actions=resubmit(,4) 5 j5 a/ K1 R* K8 J$ z6 P. x# w
cookie=0x0, duration=332.478s, table=4, n_packets=0, n_bytes=0, idle_age=332, reg0=0x3 actions=strip_vlan,output:3 - _3 i6 O5 W* t6 l2 z
cookie=0x0, duration=228.839s, table=4, n_packets=0, n_bytes=0, idle_age=228, priority=50,reg0=0x0 actions=output:1 $ j2 j! H- g* R9 H% A- U! U
cookie=0x0, duration=483.068s, table=4, n_packets=0, n_bytes=0, idle_age=483, reg0=0x1 actions=output:1 1 w& B9 n' ], W
cookie=0x0, duration=332.478s, table=4, n_packets=0, n_bytes=0, idle_age=332, reg0=0x4 actions=strip_vlan,output:4
1 J! X! S/ \, g* e6 |( O6 R- \cookie=0x0, duration=332.478s, table=4, n_packets=0, n_bytes=0, idle_age=332, reg0=0x2 actions=strip_vlan,output:2 Q, T `+ J$ w w- m" E6 d; B. t
cookie=0x0, duration=228.84s, table=4, n_packets=0, n_bytes=0, idle_age=228, priority=99,reg0=0x0,dl_vlan=30 actions=output:1,strip_vlan,output:3,output:4 ) U" D7 x1 x, c% m- ]/ p
cookie=0x0, duration=228.84s, table=4, n_packets=0, n_bytes=0, idle_age=228, priority=99,reg0=0x0,dl_vlan=20 actions=output:1,strip_vlan,output:2
* m2 m/ S- J/ D0 z) D; w1 kcookie=0x0, duration=1438.031s, table=10, n_packets=0, n_bytes=0, idle_age=1438, hard_age=1109, vlan_tci=0x0014/0x0fff,dl_dst=f0:00:00:00:00:01 actions=load:0x1->NXM_NX_REG0[0..15]
E5 [, N% _5 zcookie=0x0, duration=2090.451s, table=10, n_packets=0, n_bytes=0, idle_age=2090, vlan_tci=0x0014/0x0fff,dl_dst=50:00:00:00:00:02 actions=load:0x2->NXM_NX_REG0[0..15]
+ P2 x" v A' ^/ M- T( u/ r0 W0 hcookie=0x0, duration=1258.881s, table=10, n_packets=0, n_bytes=0, idle_age=1258, vlan_tci=0x0014/0x0fff,dl_dst=90:00:00:00:00:01 actions=load:0x2->NXM_NX_REG0[0..15]
# g* _# ?& u1 @7 a5 @3 Jcookie=0x0, duration=2403.127s, table=10, n_packets=0, n_bytes=0, idle_age=2403, vlan_tci=0x0014/0x0fff,dl_dst=50:00:00:00:00:01 actions=load:0x1->NXM_NX_REG0[0..15]
$ J" c5 ^0 t, N6 N3 T1 d; \3 p$ G9 H4 w0 ~
首先来测试一个multicast和broadcast2 K" l) o/ X" ~+ ^
8 X: R* W) X G! d# t1 F: ~7 j$ ~4 b
如果是一个port 1来的vlan 30的broadcast: z% d* m7 x* c7 k9 q3 T7 o$ ^7 k2 w
: S, B9 T" b* E. y) c0 C$ sudo ovs-appctl ofproto/trace helloworld in_port=1,dl_dst=ff:ff:ff:ff:ff:ff,dl_vlan=30 * X D: ^) l* u( U! \2 d8 j
Flow: metadata=0,in_port=1,dl_vlan=30,dl_vlan_pcp=0,dl_src=00:00:00:00:00:00,dl_dst=ff:ff:ff:ff:ff:ff,dl_type=0x0000
9 _! z" {' F: N( f5 V2 b$ j1 WRule: table=0 cookie=0 priority=0
0 m8 l! _9 |/ I# {, p& Q# rOpenFlow actions=resubmit(,1)
4 k" M9 ?1 O' ^( S' d/ w, J" G' w0 @: V; Q7 Z: |
Resubmitted flow: unchanged % o1 O% V ^! s
Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
0 M" N* d% @3 L' \1 S2 F! G- q3 l Resubmitted odp: drop
" K% p2 z* T2 r Rule: table=1 cookie=0 priority=99,in_port=1
( E) x x* V" u4 G- ^' J# g/ ~ OpenFlow actions=resubmit(,2)
9 w+ i, G9 e9 m, d2 \. _) u7 g7 c3 @
Resubmitted flow: unchanged / k- L7 x% b5 C( Z
Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
" \4 J# q# C5 d9 C Resubmitted odp: drop
, z$ P- S& T3 i5 ~$ ^1 H/ F& P4 p Rule: table=2 cookie=0
+ i) j- G [8 v) d8 Y OpenFlow 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), s& U7 |$ s1 s1 }
, W3 U2 _( @/ ~. C
Resubmitted flow: unchanged
9 ^, ^( `" u2 T- L: \) L+ v+ K; K Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
& W+ V- h9 a' ?6 v8 e Resubmitted odp: drop
! T/ Z+ }( G5 \ Rule: table=3 cookie=0 priority=99,dl_dst=01:00:00:00:00:00/01:00:00:00:00:00
% {, E4 N, V" T+ Y* H OpenFlow actions=resubmit(,4) A+ {, K: ]$ p9 X; W) W
2 [3 k5 B; N: S3 U) K! \ Resubmitted flow: unchanged 0 S {) o# O5 F6 S
Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
4 Y# r3 t5 P/ t" y Resubmitted odp: drop 0 V+ t) }7 p$ J) I. l/ r0 C
Rule: table=4 cookie=0 priority=99,reg0=0x0,dl_vlan=30
6 E1 {, p9 y5 \" V OpenFlow actions=output:1,strip_vlan,output:3,output:4
D2 x1 i. f$ X2 ~ skipping output to input port8 Q$ x& K$ E" ]$ u! x/ |
* C7 K( A& g+ d5 N* l1 ?4 B# f; wFinal flow: metadata=0,in_port=1,vlan_tci=0x0000,dl_src=00:00:00:00:00:00,dl_dst=ff:ff:ff:ff:ff:ff,dl_type=0x0000
1 Z' p5 v. R, t8 z6 CRelevant fields: skb_priority=0,in_port=1,dl_vlan=30,dl_vlan_pcp=0,dl_src=00:00:00:00:00:00,dl_dst=ff:ff:ff:ff:ff:f0/ff:ff:ff:ff:ff:f0,dl_type=0x0000,nw_frag=no
7 {' A+ P1 ~2 `( b& j2 jDatapath actions: pop_vlan,12,13+ y: O2 {" B. L/ X3 e9 Q
7 U% }- m6 Q4 O; [ [/ z
结果是port 1就不发送了,发送给了port 3, 4- `6 l0 d% C/ K
# C B& ^. n7 k* b2 L) Z$ sudo ovs-appctl ofproto/trace helloworld in_port=3,dl_dst=ff:ff:ff:ff:ff:ff
' R% E* D1 ?2 WFlow: metadata=0,in_port=3,vlan_tci=0x0000,dl_src=00:00:00:00:00:00,dl_dst=ff:ff:ff:ff:ff:ff,dl_type=0x0000 , u9 }! v! w( z) V; W- d
Rule: table=0 cookie=0 priority=0
" B1 U: p6 W& l: a+ b' w% L, S, KOpenFlow actions=resubmit(,1)
6 C% ]9 ^& O) K$ @' I8 l7 W ~ b
; a: @( ^' T9 J5 o& T X f# V- } Resubmitted flow: unchanged ( \' M: P8 E, a) U% T* M
Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0 : M' o& V: d6 W2 L, L4 q( w5 V
Resubmitted odp: drop ) X$ b: o1 r1 I7 V7 O
Rule: table=1 cookie=0 priority=99,in_port=3,vlan_tci=0x0000 7 k+ M( n, F9 w9 ~. a
OpenFlow actions=mod_vlan_vid:30,resubmit(,2)1 o5 H/ v4 ?+ d" e0 ^) ?
, S$ k% L2 N/ S( {# u2 c1 g* { Resubmitted flow: metadata=0,in_port=3,dl_vlan=30,dl_vlan_pcp=0,dl_src=00:00:00:00:00:00,dl_dst=ff:ff:ff:ff:ff:ff,dl_type=0x0000
5 l0 E, v6 Z$ S+ V1 o; O Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0 & a8 z- h4 y! F
Resubmitted odp: drop 0 e4 Y* b7 ~- E) i8 B3 n* f1 X
Rule: table=2 cookie=0 , \3 ?) x6 I# D+ }( L
OpenFlow 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)7 d! B0 M- S7 a( c
$ q- U/ @! W \% x( D0 [
Resubmitted flow: unchanged / W% C) {4 R4 q; o4 @; k# D& C
Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
# P: r/ `& n$ V0 k1 S9 n Resubmitted odp: drop 4 m5 B1 S3 ?" i- ]+ L/ L
Rule: table=3 cookie=0 priority=99,dl_dst=01:00:00:00:00:00/01:00:00:00:00:00 $ X8 ^! n* T; y
OpenFlow actions=resubmit(,4)4 D! C! I7 A' [- ]. m4 P
2 W b0 m1 N6 D% C6 O
Resubmitted flow: unchanged
4 l6 a+ n& n7 @1 k: m Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
" R6 G+ T6 B1 H! S- h# d Resubmitted odp: drop , q% ^7 R) y7 {
Rule: table=4 cookie=0 priority=99,reg0=0x0,dl_vlan=30 * c9 g! }: ^8 C% d: A
OpenFlow actions=output:1,strip_vlan,output:3,output:4 * g! L3 q0 @' c: w0 a4 ]1 d8 k
skipping output to input port8 s4 q' k! G j( _+ F
6 o# o; I& I1 Y/ o" H0 S3 ?
Final flow: metadata=0,in_port=3,vlan_tci=0x0000,dl_src=00:00:00:00:00:00,dl_dst=ff:ff:ff:ff:ff:ff,dl_type=0x0000 7 A, U8 T0 u8 ?0 @" `: }7 Y3 A
Relevant fields: skb_priority=0,in_port=3,vlan_tci=0x0000,dl_src=00:00:00:00:00:00,dl_dst=ff:ff:ff:ff:ff:f0/ff:ff:ff:ff:ff:f0,dl_type=0x0000,nw_frag=no
9 \. `4 n2 y9 KDatapath actions: push_vlan(vid=30,pcp=0),10,pop_vlan,13
5 }5 [6 r3 \( z7 h
' p/ X0 w6 \( a" a+ l8 Z接着我们测试mac learning
& v( g3 r% g, N% k; z/ d1 Y' o* c& a7 g& |! T9 X
$ sudo ovs-appctl ofproto/trace helloworld in_port=1,dl_vlan=30,dl_src=10:00:00:00:00:01,dl_dst=20:00:00:00:00:01 -generate 7 k/ S* d) k! U8 Z6 } i
Flow: metadata=0,in_port=1,dl_vlan=30,dl_vlan_pcp=0,dl_src=10:00:00:00:00:01,dl_dst=20:00:00:00:00:01,dl_type=0x0000 6 P3 U5 H* S) h! x+ [6 `; s( D
Rule: table=0 cookie=0 priority=0
) D v! J/ l- i" H) IOpenFlow actions=resubmit(,1)* Y# o4 t7 W6 g* X( Z- ^
# J( ?+ B, ~' C& n Resubmitted flow: unchanged 8 u& r2 M3 Q4 U
Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0 : X3 u7 x# n6 l/ g: t
Resubmitted odp: drop . z$ f. Y+ I% v1 N
Rule: table=1 cookie=0 priority=99,in_port=1 ( y5 Z% g. C8 Y- k, N, \% G7 n
OpenFlow actions=resubmit(,2)
, ]+ y A. }; B B, X, I/ B7 k v1 X& L2 \4 N4 r" E
Resubmitted flow: unchanged 6 E" D: ~% e9 T) B$ |7 x' R5 m$ z
Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
' L! h3 p: B& N! h ?6 p Resubmitted odp: drop
( x: f! Q8 c1 _" \: n( m Rule: table=2 cookie=0 : L; ]1 T1 H1 x! R7 z5 ]
OpenFlow 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)7 ^0 {' t! \9 |( r# Z" x- Q
0 e8 m- G E+ r+ W Resubmitted flow: unchanged
% r, |' `! h2 P& e6 ?) \* @ Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
& X) ?7 E3 _2 j+ t4 F7 s* o9 d Resubmitted odp: drop " s' R% V3 \9 j7 N# l, a
Rule: table=3 cookie=0 priority=50 9 z Q- z: e, E- K1 S
OpenFlow actions=resubmit(,10),resubmit(,4) d) n* \2 o- q" d
' I) Z) U" q& f* _" }" c0 H Resubmitted flow: unchanged , C+ x9 T: r- m; G- J, D$ H7 P
Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0 " b7 s8 |8 ?( n
Resubmitted odp: drop / O8 P" e5 H) p& w" u/ C% \# ^
No match0 b7 H" P6 [! c, z
$ n, X$ A& A) G! i% m4 d6 q) N- F4 P Resubmitted flow: unchanged 0 I3 t( s7 H& h' k7 x/ Y
Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
+ M4 t! D6 e; F$ R3 L k9 N Resubmitted odp: drop / b# ?- m/ i; ?! E w( \4 A
Rule: table=4 cookie=0 priority=99,reg0=0x0,dl_vlan=30
+ k: h3 [: l% f2 G7 Z5 ?8 \ OpenFlow actions=output:1,strip_vlan,output:3,output:4
6 }: |& K+ n: \4 |* t k8 y' [. m( t skipping output to input port w/ b/ A n9 u# \+ q
% ^# u5 \; X8 a3 _! R* p* EFinal flow: metadata=0,in_port=1,vlan_tci=0x0000,dl_src=10:00:00:00:00:01,dl_dst=20:00:00:00:00:01,dl_type=0x0000
% p8 {+ ?/ M4 l" Y d( e4 ^Relevant fields: skb_priority=0,in_port=1,dl_vlan=30,dl_vlan_pcp=0,dl_src=10:00:00:00:00:01,dl_dst=20:00:00:00:00:01,dl_type=0x0000,nw_frag=no
) p4 `: n8 f) \& N( K5 ~; _Datapath actions: pop_vlan,12,13/ s. b1 J1 m B0 O, u2 U5 c+ S
1 F" V9 b* B8 n- N1 T& i由于这两个地址没有出现过,则除了进行学习以外,广播发送给port 3,4
! u3 k( A6 o) B. L. x5 z9 L1 ^) |" V7 A6 R {. o
$ sudo ovs-appctl ofproto/trace helloworld in_port=4,dl_src=20:00:00:00:00:01,dl_dst=10:00:00:00:00:01 -generate 5 ~+ a1 S# x# Z6 o! K
Flow: metadata=0,in_port=4,vlan_tci=0x0000,dl_src=20:00:00:00:00:01,dl_dst=10:00:00:00:00:01,dl_type=0x0000
" D% @+ R/ D4 {( |+ VRule: table=0 cookie=0 priority=0
$ o$ [* ^3 a( hOpenFlow actions=resubmit(,1)
2 H A( T# B, v9 Y. i& f0 {0 I- y2 e5 L% |; {
Resubmitted flow: unchanged 4 q% G; [0 ^. a1 w+ v) Q% a
Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
. O' `- t9 j& [% ^3 ^ Resubmitted odp: drop
8 z {: ]+ C y$ l- w% J4 a* N: f3 S Rule: table=1 cookie=0 priority=99,in_port=4,vlan_tci=0x0000
' b7 U( z1 r: M/ H4 d OpenFlow actions=mod_vlan_vid:30,resubmit(,2). R; ~# C, K! c+ O; S+ J
3 a5 M9 \$ g+ }8 o
Resubmitted flow: metadata=0,in_port=4,dl_vlan=30,dl_vlan_pcp=0,dl_src=20:00:00:00:00:01,dl_dst=10:00:00:00:00:01,dl_type=0x0000 * z$ w! N; ]% |; r9 q9 q7 h$ }
Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
( m2 V# z+ g4 h7 c4 Q, q Resubmitted odp: drop
; w, j0 l6 g% @0 ^5 T* n( _) l" e Rule: table=2 cookie=0 . d! `0 l+ f+ w, q; U2 ^6 J
OpenFlow 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)6 K" y7 N% \9 N8 s: L- s B
6 r: K5 S1 P' n, }/ T Resubmitted flow: unchanged , v3 c6 u3 D. ~9 }& D+ t+ n. G1 p
Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
/ n4 O8 w9 O# m; P# ~# b3 `) i3 [7 j Resubmitted odp: drop $ e- a V7 x/ R* ^# k3 M
Rule: table=3 cookie=0 priority=50 # R% I- e4 F1 J
OpenFlow actions=resubmit(,10),resubmit(,4)6 P4 a0 l0 P# f$ D5 Y
! _4 _' `* C9 b
Resubmitted flow: unchanged
5 i, ^" |$ v2 Z) B$ Q Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0 ; I2 u$ ]) L6 y0 p: E+ |- K
Resubmitted odp: drop 5 A" p% o# T3 O& n& s' y' P) m
Rule: table=10 cookie=0 vlan_tci=0x001e/0x0fff,dl_dst=10:00:00:00:00:01 5 I7 J0 ~, O% [ r2 u7 v
OpenFlow actions=load:0x1->NXM_NX_REG0[0..15]3 P8 o# e7 F0 ^/ h, X$ u. A
1 F3 K- ?& C8 B# t% m; o7 q- V d% o Resubmitted flow: reg0=0x1,metadata=0,in_port=4,dl_vlan=30,dl_vlan_pcp=0,dl_src=20:00:00:00:00:01,dl_dst=10:00:00:00:00:01,dl_type=0x0000 * P; |1 k7 d% ]1 G2 t3 F" d
Resubmitted regs: reg0=0x1 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0 , r+ m E r2 x. A" k
Resubmitted odp: drop ) o! H# y- I. _7 Q' c
Rule: table=4 cookie=0 reg0=0x1 2 }+ c5 e/ l; \0 o" [
OpenFlow actions=output:1
" J+ H% }9 M Q7 M# y
! K) x) `- Z$ Q$ y4 L/ lFinal flow: unchanged : k0 t/ ~& f# L" j
Relevant fields: skb_priority=0,in_port=4,vlan_tci=0x0000,dl_src=20:00:00:00:00:01,dl_dst=10:00:00:00:00:01,dl_type=0x0000,nw_frag=no w/ E( ]0 D3 @ F* T: n
Datapath actions: push_vlan(vid=30,pcp=0),10
' y3 e2 i1 Q8 _# I* e" N7 @4 Z
回复的时候,由于学习过了,则仅仅从port 1发送出去。
( P4 M/ S W" ?, T! ]7 r1 x2 V8 s% `9 ~* a1 I: v1 F
$ sudo ovs-appctl ofproto/trace helloworld in_port=1,dl_vlan=30,dl_src=10:00:00:00:00:01,dl_dst=20:00:00:00:00:01 -generate
9 h/ A' F7 ~+ AFlow: metadata=0,in_port=1,dl_vlan=30,dl_vlan_pcp=0,dl_src=10:00:00:00:00:01,dl_dst=20:00:00:00:00:01,dl_type=0x0000
l2 t; }8 `( z* qRule: table=0 cookie=0 priority=0 2 V3 f5 @' _. u+ ]
OpenFlow actions=resubmit(,1)
0 W- c' c m6 o L
5 q. H6 r# n* j3 V9 ~5 I& p Resubmitted flow: unchanged 3 _+ L, h7 h8 I* ~4 z
Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
& g3 ?/ I) [, `8 t' w8 j Resubmitted odp: drop
7 \3 Z5 { G8 ~( i! E! U% c0 d Rule: table=1 cookie=0 priority=99,in_port=1
6 Z' J+ w9 @) v. p OpenFlow actions=resubmit(,2)
' O5 q$ S( _* Q# E' ^+ ~0 ] m) l# ]# v9 |
Resubmitted flow: unchanged
# c/ A8 W6 Y& R" Z Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
" W* t9 X/ o) |1 o7 O0 z Resubmitted odp: drop
5 ^% C. R3 ~9 H8 M( H4 }: A3 b Rule: table=2 cookie=0 9 J# l5 F& w8 r1 }
OpenFlow 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)% I" z+ A, i; g- Y) L1 S+ Q. M
! h% D9 @4 N! H: P
Resubmitted flow: unchanged 8 ?# J1 Y8 O( @0 l* {
Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
: I1 i3 |& D4 u Resubmitted odp: drop 4 V1 [2 x9 d( X* l! o* ?1 j
Rule: table=3 cookie=0 priority=50
3 \$ M( D8 K+ Q9 Z# Y- ? N OpenFlow actions=resubmit(,10),resubmit(,4)/ u1 _- C, ?3 c" q
6 f- v# q0 F% ~ U9 w
Resubmitted flow: unchanged
) i% H5 V4 T. o3 J0 Y% Z; h' B Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
) k7 T* R2 J: J" \ Y; ^ Resubmitted odp: drop / ^% I- I: t3 }5 X7 u, P
Rule: table=10 cookie=0 vlan_tci=0x001e/0x0fff,dl_dst=20:00:00:00:00:01 - p; U! b- @0 x( }9 z, j& s" W0 J
OpenFlow actions=load:0x4->NXM_NX_REG0[0..15]: j8 O- I' o6 {) Q. s \
! V+ P) H2 u! j2 |$ q2 i+ [
Resubmitted flow: reg0=0x4,metadata=0,in_port=1,dl_vlan=30,dl_vlan_pcp=0,dl_src=10:00:00:00:00:01,dl_dst=20:00:00:00:00:01,dl_type=0x0000
/ w6 n! T8 @6 ?" s* I8 p- B9 o$ z Resubmitted regs: reg0=0x4 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
+ \% a8 n' [: H6 G# H# ^$ Y' `# l Resubmitted odp: drop
; f% w& A7 k) p+ T Rule: table=4 cookie=0 reg0=0x4 1 l9 ]6 B! p' N0 z$ H% S
OpenFlow actions=strip_vlan,output:4 S/ n) g2 d) z' l* F/ [2 \
& n9 G1 E! Y0 j$ r* g
Final flow: reg0=0x4,metadata=0,in_port=1,vlan_tci=0x0000,dl_src=10:00:00:00:00:01,dl_dst=20:00:00:00:00:01,dl_type=0x0000 ' t, u/ m8 l' g' j9 n0 ~
Relevant fields: skb_priority=0,in_port=1,dl_vlan=30,dl_vlan_pcp=0,dl_src=10:00:00:00:00:01,dl_dst=20:00:00:00:00:01,dl_type=0x0000,nw_frag=no / K7 x6 [1 {. y2 n7 J! |
Datapath actions: pop_vlan,13
' Y7 S0 f# j2 c& T" i+ i
4 I( _$ T# j, ]+ H/ v# j; Y由于在回复中进行了学习,因而发送的时候,仅仅发送port 4 |
|