|
|
楼主 |
发表于 2019-10-25 10:00:36
|
显示全部楼层
实现第一个Table 0,Admission control# t f7 ~8 `' ?1 T% a6 p) v- p0 H
: L' N- `* T9 |- _
包进入vswitch的时候首先进入Table 0,我们在这里可以设定规则,控制那些包可以进入,那些包不可以进入。+ J( [, D* }' p& {
# a, [& o0 r$ }比如,如果source address是multicast的就不允许进入。, K, U1 `1 @( _% F' Y
. r6 A+ c$ k. m" s, T. w, l01:00:00:00:00:00/01:00:00:00:00:00是广播地址
8 }& M9 h& X+ o, R' b% B6 h, z00:00:00:00:00:00/01:00:00:00:00:00是单播地址
9 j2 X1 Z; E6 T( i6 g这种表示形式类似CIDR+ S! U* r5 y! R2 }7 }1 c2 r
于是我们添加下面的规则:
* @* T: s K3 D: V" f( D# p4 s, Y9 Asudo ovs-ofctl add-flow helloworld "table=0, dl_src=01:00:00:00:00:00/01:00:00:00:00:00, actions=drop"
+ O: X" l5 I6 d7 M+ A3 z6 MSTP的也不接受
6 M! U5 S, d7 B# R' Fsudo ovs-ofctl add-flow helloworld "table=0, dl_dst=01:80:c2:00:00:00/ff:ff:ff:ff:ff:f0, actions=drop"
6 B8 L3 R3 i4 u: y: Z0 {3 Z我们在添加最后一个flow,这个flow的priority低于default,如果上面两个不匹配,则我们进入table 1' b5 ^ w6 Q5 |' H' W+ S) a4 V
sudo ovs-ofctl add-flow helloworld "table=0, priority=0, actions=resubmit(,1)" L" K1 |5 O# k# C$ K& j
我们查看一下所有的flow
8 r8 s, c8 g d& v5 w$ l6 I+ U6 d+ c$ sudo ovs-ofctl dump-flows helloworld
& N% t& x' N2 ]9 S4 b* v- KNXST_FLOW reply (xid=0x4):
& p4 }* w, o3 scookie=0x0, duration=42.162s, table=0, n_packets=0, n_bytes=0, idle_age=42, priority=0 actions=resubmit(,1) & b d& e S2 ^6 J! ^; |) z) g
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 5 V: F- |" X, F' B
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=drop
1 a- }# l) B1 |6 U9 N5 G# r$ M0 p
测试Table 0
9 Z. ]7 a. u2 b% B k7 I9 c: t" _# C$ u- E# |8 B. R" |
有个很好的工具ovs-appctl ofproto/trace
8 _9 J$ P2 w9 T* j' R) g9 }0 h! r4 t6 `/ {# L ]8 H
不满足条件DROP( [8 N# U+ }+ W; \& j' ]
L+ ~3 y/ ?8 T3 W
$ sudo ovs-appctl ofproto/trace helloworld in_port=1,dl_dst=01:80:c2:00:00:05 ( \* y, W t5 s0 F
Flow: 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 " n. E3 Z. J# x; q) x5 S/ d
Rule: table=0 cookie=0 dl_dst=01:80:c2:00:00:00/ff:ff:ff:ff:ff:f0
; w. a" v0 B) p) ~$ G# s3 l8 BOpenFlow actions=drop
: g4 r/ h' z0 h, c( [9 | B# x7 u2 y+ n9 t
Final flow: unchanged ) l9 U" u. H$ V$ 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:00/ff:ff:ff:ff:ff:f0,dl_type=0x0000,nw_frag=no : X) v! k2 y! {3 J4 C' W4 N4 M) }
Datapath actions: drop
d6 g* A) Q/ o0 o) o" P0 H% {& K6 }3 @( w
满足条件RESUBMIT1 D% b) M2 S- c4 d6 }* q/ Z: M5 Q8 c
/ i, y. k- R8 n: b/ g- h; _$ sudo ovs-appctl ofproto/trace helloworld in_port=1,dl_dst=01:80:c2:00:00:10
/ ^. D& y" T% s3 |& B- A/ c7 S6 WFlow: 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
3 P$ [8 f' s1 e6 } g1 O' r( \Rule: table=0 cookie=0 priority=0 # y" N8 X9 y) a# E! O; v) E
OpenFlow actions=resubmit(,1)
4 O) [: |8 @5 \6 @4 F6 f4 t1 F, d0 ^
Resubmitted flow: unchanged
4 a9 W' K n) X L# @' H; O Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
" y8 }% h7 l1 U, Y Resubmitted odp: drop ' R1 ?1 {1 @$ [' p9 g+ A
No match/ R( S4 }6 ]3 i
' [6 }( g. Q- I- B
Final flow: unchanged
% w. M# [2 U! j: d9 }/ qRelevant 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 ! k& R# w' T; g+ o
Datapath actions: drop
* A1 }/ h' E* z0 T$ d* F7 ^, v2 ^7 ~) j' p R
实现第二个Table 1:VLAN Input Processing# ?' B( c' p- r) @% r/ U- P, J' G
: K) i O3 `. U; g6 r首先添加一个最低优先级的DROP的规则
( G: p. h( i( G, I" Y
3 ?& P$ j! G& U. H, A, v _% Bsudo ovs-ofctl add-flow helloworld "table=1, priority=0, actions=drop"
( g a: y* a7 s5 l% [2 M% |' W% l1 M, O
对于port 1,是trunk口,无论有没有VLAN Header都接受。
) w( {) _/ b5 \6 R! ]" v
1 R x% [4 i" G: |) K' s) u$ ~& c0 tsudo ovs-ofctl add-flow helloworld "table=1, priority=99, in_port=1, actions=resubmit(,2)"
# ~; H; k; X# i* _' P* d& h, P \ t, w
对于port 2, 3, 4, 我们希望没有VLAN Tag,然后我们给打上VLAN Tag
7 S; B7 `0 c0 `0 q$ G* ~' ]/ j' K d, T U
$ sudo ovs-ofctl add-flows helloworld - <<'EOF' 2 F$ e3 {2 V% P8 L5 ~
table=1, priority=99, in_port=2, vlan_tci=0, actions=mod_vlan_vid:20, resubmit(,2)
( f6 E7 S" M Y/ Mtable=1, priority=99, in_port=3, vlan_tci=0, actions=mod_vlan_vid:30, resubmit(,2) $ U& N. M3 _2 ~9 Z7 i8 A
table=1, priority=99, in_port=4, vlan_tci=0, actions=mod_vlan_vid:30, resubmit(,2)
0 K6 b2 J. b' j: l$ QEOF$ R2 K- B: x1 m" N' Q; P% n" ~
, B8 w# z2 n1 F9 ^
$ sudo ovs-ofctl dump-flows helloworld
( S7 {5 {! v3 d/ ANXST_FLOW reply (xid=0x4): 3 I2 b( S/ p2 n- H- T. j+ d
cookie=0x0, duration=4478.582s, table=0, n_packets=0, n_bytes=0, idle_age=4478, priority=0 actions=resubmit(,1) 0 ^, M8 u4 M3 f; G) i W
cookie=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 . u% c% r& F- L, ?% W/ ^ x
cookie=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
9 {' @6 _# }2 A# {- _" {+ pcookie=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) % A' x2 Y/ a1 g$ D
cookie=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) + L) v' e8 C! p' `7 `3 F
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) + P6 d# Y+ s# M7 Y1 @6 o
cookie=0x0, duration=220.318s, table=1, n_packets=0, n_bytes=0, idle_age=220, priority=99,in_port=1 actions=resubmit(,2)
6 @+ v% | r$ h# I9 {cookie=0x0, duration=298.739s, table=1, n_packets=0, n_bytes=0, idle_age=298, priority=0 actions=drop6 _$ R4 ?5 {1 A! j. _& Y
# J( ?9 ]9 n, r+ B3 H
测试一个从port 1进入,tag为5的& d# f# `! Y7 s" a
% R, d# Q, b; e- k) h. f0 s) j$ sudo ovs-appctl ofproto/trace helloworld in_port=1,vlan_tci=5
2 @( A1 I' p2 w! E0 `2 C- X G' 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
$ W* H! u5 k0 A2 c; CRule: table=0 cookie=0 priority=0
1 Y& y+ l6 m/ q9 ?OpenFlow actions=resubmit(,1)
# b+ [0 R. l! o& |
; g4 p ^ {8 b" {' A! H Resubmitted flow: unchanged . C, q' `) e' j
Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0 4 }; C% P- n; Z5 @6 w1 J2 ^4 ~; m; F
Resubmitted odp: drop
6 J) a" k/ O; o. o Rule: table=1 cookie=0 priority=99,in_port=1 1 I) U( g3 Y5 C2 Q$ t
OpenFlow actions=resubmit(,2)+ h& A( L& W L) V
8 Y- n; Y& D" S, w+ C6 A5 R Resubmitted flow: unchanged % J* D& C4 Q0 l1 _7 v
Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
8 _' ]7 z7 r. ?0 L c7 ~1 O' }4 Y: m Resubmitted odp: drop # r. J3 L9 I8 O3 ?( I, s) z9 S4 Y
No match. F; l+ e- U6 r/ V% D$ Y; e
! y, ~/ { x! s, ]Final flow: unchanged
7 w n' E+ T2 t+ w) o) cRelevant 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 5 |' d, y7 _7 e+ \ d) B, R& ~
Datapath actions: drop
" E" Y# @4 ^4 o ]! m" e
7 Y" X, b0 g2 U7 O1 k测试二,从port 2进入,没有打Tag的: F9 N0 F9 l- b1 t# y
7 `2 P( r" k( @) C
$ sudo ovs-appctl ofproto/trace helloworld in_port=2 " t, _) l* Q1 ^5 x. @: ]
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 ! a, Z( }! k/ l) J
Rule: table=0 cookie=0 priority=0
! K2 o+ o" t3 n" _OpenFlow actions=resubmit(,1)# O$ b# ~2 m' V: z2 k
. R. s' ^- f: w% ~! T% r% T Resubmitted flow: unchanged
" W6 I- M, n1 [; Q+ S8 B Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
3 A8 n, p8 w3 \9 c6 z2 x Resubmitted odp: drop
! t7 b0 J9 l0 _2 G8 W. J Rule: table=1 cookie=0 priority=99,in_port=2,vlan_tci=0x0000 9 A% n3 k& n( b3 [
OpenFlow actions=mod_vlan_vid:20,resubmit(,2)
- z& ]0 B; q( ?+ ^5 U" y! x
7 x$ n# E* ^8 f 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
& b3 R E; Y a" | Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
8 G5 W0 u, S" @4 G Resubmitted odp: drop
( \9 j5 b. o& |& K4 x No match
" o J+ k# h. a' b7 N: C$ g7 {$ h- B# a R
Final flow: unchanged ) O0 u( K( K7 @/ ^3 j ]; w
Relevant 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
' J3 V* _0 i; _! J$ `& Y- @6 \Datapath actions: drop
* ^" U. ]- g* x% W- W1 R9 i
* Y; j. |+ t! W( C# h测试三:从port进入,带Tag 5的
! |$ O8 H6 B- w1 D1 q! M& v0 }1 H
$ sudo ovs-appctl ofproto/trace helloworld in_port=2,vlan_tci=5
+ \1 \6 g: Z- F3 J. c9 rFlow: 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 ' C( S' P5 Y* b' y" ]/ N) G% e/ a0 Q* O
Rule: table=0 cookie=0 priority=0 . a& B1 t! C# A# S g% O/ h
OpenFlow actions=resubmit(,1)- c! K. C/ r: o" Y
9 m$ d s& D7 R, J Resubmitted flow: unchanged ; L! L& o2 @ B+ m7 r) g
Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
. X+ G! d9 l3 T/ G. t$ I4 W$ Q& A Resubmitted odp: drop + H4 R. Z4 X7 Q5 v9 o K4 C
Rule: table=1 cookie=0 priority=0 , v8 S& ^# U ^; \0 o: ?. M
OpenFlow actions=drop& |# r6 X* S& I% v8 {0 Z9 C# q; p
( ^/ F3 A6 f* D/ H y' x0 U* PFinal flow: unchanged
B$ w4 f. C$ J6 k5 ARelevant 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
7 N( \: \5 i: y: m" aDatapath actions: drop1 U' n2 E& [+ U: t+ E% c
9 l+ }1 Q5 h: M实现第三个Table 2: MAC, VLAN learning for ingress port
# v0 b- X/ M' M! R2 _* _ q2 p
对于普通的switch,都会有这个学习的过程,当一个包到来的时候,由于包里面有MAC,VLAN Tag,以及从哪个口进来的这个信息。于是switch学习后,维护了一个表格port –> MAC –> VLAN Tag。) E' n5 y2 C( e* T, {9 C+ M; B
3 M- E D6 M$ e4 `6 b, G4 Q+ q$ K
这样以后如果有需要发给这个MAC的包,不用ARP,switch自然之道应该发给哪个port,应该打什么VLAN Tag。
* s0 V4 T/ V8 K( m0 W" P: _5 o7 Z' o; w1 I$ _- z" l5 p$ L
OVS也要学习这个,并维护三个之间的mapping关系。& ?$ k4 r' ~5 L, x% ~
% q& Q9 h- B3 { @ J) c
在我们的例子中,无论是从port进来的本身就带Tag的,还是从port 2, 3, 4进来的后来被打上Tag的,都需要学习。
# ?2 f* \" y; c& d3 \4 _# `4 s
6 B z9 a4 w2 }5 Q( q/ Fsudo 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)"
: x* n, A$ ?' {' ` s
" S' }9 t$ @+ t# `2 v这一句比较难理解。3 a& z, r* H7 Q8 a
" T+ g* m* ^9 ~- D/ |1 F) D
learn表示这是一个学习的action
$ V( L+ X3 @$ ^8 V+ G
. @9 h% g& U/ C& ptable 10,这是一个MAC learning table,学习的结果会放在这个table中。
; C, d5 [, X, C2 ?& t& L/ F! O. ?" ]1 ~7 @
NXM_OF_VLAN_TCI这个是VLAN Tag,在MAC Learning table中,每一个entry都是仅仅对某一个VLAN来说的,不同VLAN的learning table是分开的。在学习的结果的entry中,会标出这个entry是对于哪个VLAN的。
! |8 O# ~( X. V* v5 ~9 }4 A! w: n7 i! A! h- p1 _
NXM_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里面,因为这是为发送用的。* N; x% z, M- [+ J5 d V9 r
9 ]: I1 G& S' |; [
NXM_OF_IN_PORT[]->NXM_NX_REG0将portf放入register.0 E0 F% [- R r6 L% B* T' J
2 n9 R) g6 h( P7 w( R* I# V" p
一般对于学习的entry还需要有hard_timeout,这是的每个学习结果都会expire,需要重新学习。
' ?8 y* S; H0 V2 q L
+ L4 ]: S1 e5 O7 p' x我们再来分析一个实践中,openstack中使用openvswitch的情况,这是br-tun上的规则。) k( d3 W' O& T" d" U9 l! C
0 W% ?( K# u1 D& Y
cookie=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
v8 T" X2 c- x5 |( Fcookie=0x0, duration=802187.786s, table=20, n_packets=0, n_bytes=0, idle_age=65534, hard_age=65534, priority=0 actions=resubmit(,21)
5 s! n5 g0 h- }4 A9 L1 q 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 ; ?: C- \8 r8 f. M! ]& c
cookie=0x0, duration=802187.653s, table=21, n_packets=17, n_bytes=1426, idle_age=65534, hard_age=65534, priority=0 actions=drop
) P7 e9 e0 B% T* O. xcookie=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% c, [" ^0 k: e
! J# o- q' G2 N# O& s这里table 10是用来学习的。table 20是learning table。如果table 20是空的,也即还没有学到什么,则会通过priority=0的规则resubmit到table 21.$ i9 F+ a: n) q* p
2 d( |- O b+ W0 |table 21是发送规则,将br-int上的vlan tag消除,然后打上gre tunnel的id。/ w+ O& V3 M( s
7 I# x: u8 q( C2 i9 m7 x
上面的情况中,table 20不是空的,也即发送给dl_dst=fa:16:3e:7e:ab:cc的包不用走默认规则,直接通过table 20就发送出去了。
' b# a5 a; q% {% M: q
' k% d( g ]( L7 itable 20的规则是通过table 10学习得到的,table 10是一个接受规则。最终output 1,发送给了br-int
6 o+ R+ {& \+ z+ N! R" B
$ e6 u# }0 K# R3 y' |+ G. {NXM_OF_VLAN_TCI[0..11]是记录vlan tag,所以学习结果中有dl_vlan=1# M; s/ q* F* Y' K8 L+ t# f' N
J% Z. a6 i5 p. vNXM_OF_ETH_DST[]=NXM_OF_ETH_SRC[]是将mac source address记录,所以结果中有dl_dst=fa:16:3e:7e:ab:cc
4 ^6 \* ?" h5 i; Y- r4 n2 a% z
5 n$ o" Z# ?& Vload:0->NXM_OF_VLAN_TCI[]意思是发送出去的时候,vlan tag设为0,所以结果中有actions=strip_vlan
/ U: \4 p/ g0 T, }4 I
3 D/ \. U d6 Z6 sload:NXM_NX_TUN_ID[]->NXM_NX_TUN_ID[]意思是发出去的时候,设置tunnul id,所以结果中有set_tunnel:0x3e9* C5 d7 {, p* H0 M6 g& Z" x
9 o9 v( `1 D4 E/ m# _7 M3 b
output:NXM_OF_IN_PORT[]意思是发送给哪个port,由于是从port2进来的,因而结果中有output:20 [' _1 n7 X% h) Q* y
' O/ ^9 |# k L: o; a' g测试一:从port 1来一个vlan为20的mac为50:00:00:00:00:01的包5 e0 c' i' N( W8 W& O, s
5 a9 q/ n7 d6 E/ \
$ sudo ovs-appctl ofproto/trace helloworld in_port=1,vlan_tci=20,dl_src=50:00:00:00:00:01 -generate
2 l9 [& S/ h9 A, T" A9 p' fFlow: 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 z' |' X' r, j( ]% A8 bRule: table=0 cookie=0 priority=0
. J* a/ O4 B6 p1 V4 Q6 qOpenFlow actions=resubmit(,1)$ q$ P" J' s1 y5 T+ F) P( v/ O
' S8 w7 [5 F4 r# Z; d" F$ O% Y
Resubmitted flow: unchanged
3 w5 `6 L- i, F Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0 6 o1 q* X+ x& {* Q
Resubmitted odp: drop , j, P' x' Z% q; E5 Q" l: V
Rule: table=1 cookie=0 priority=99,in_port=1 1 |! I( Q! @/ L, |" V8 i0 M
OpenFlow actions=resubmit(,2)
" ^2 K3 U" h& Y2 O
5 g2 F0 a l, {8 U M1 ?$ b Resubmitted flow: unchanged # G+ I1 h: j* X& \
Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
/ G& h( O% n; d; V! H Resubmitted odp: drop 6 U( c( c/ F- _1 z9 L- _3 r& h
Rule: table=2 cookie=0
! o/ n K, f3 N% U" C4 C 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 D) q0 z7 \( M6 c" f. F
1 v# B3 ~' q+ k
Resubmitted flow: unchanged
; k0 l: H& G. N- g' w Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
5 B/ d" [9 W' I/ p Resubmitted odp: drop
3 ~8 n9 n- @" _- y" Y No match
2 [0 P4 ~. g U+ k; g! g' i# [5 K6 v# [3 Y! V; `
Final flow: unchanged ; j: }9 `$ [: |1 h5 ~4 Q& l6 @$ [
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 , ?; ^7 }0 ?' S
Datapath actions: drop
5 ?) X6 N- O) T* ?& k3 f& p
h& Y+ ]: y2 h5 X% H6 Q. y% U$ sudo ovs-ofctl dump-flows helloworld
- u, g0 r/ X6 E4 m' ONXST_FLOW reply (xid=0x4):
, L. f3 n) M% d; ^5 ucookie=0x0, duration=90537.25s, table=0, n_packets=0, n_bytes=0, idle_age=65534, hard_age=65534, priority=0 actions=resubmit(,1) b$ L) K1 N7 n
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
2 N/ n; I) T% _* P5 C# Rcookie=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
0 i8 R, ]: E @; |2 m" f6 }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) / C6 P, m# `5 N
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)
/ I8 d/ Q9 M$ h8 M1 G! |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) . C, k# Y9 [( k( x& R* \/ F' K
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) # ]# _6 m$ ^6 P z6 ~' y7 b
cookie=0x0, duration=86357.407s, table=1, n_packets=0, n_bytes=0, idle_age=65534, hard_age=65534, priority=0 actions=drop $ }7 L( X3 H% D
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) " Q5 s6 i4 g! H* N+ K) Y4 h$ r
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]
8 i/ E" c# A! ]) \: a1 u5 G5 X* I$ m, A
table 10多了一条,vlan为20,dl_dst为50:00:00:00:00:01,发送的时候从port 1出去。* G4 `* n3 I9 A0 A i# a2 V
/ i( X& Q0 D0 ?测试二:从port 2进来,被打上了vlan 20,mac为50:00:00:00:00:02$ o$ j; Z, b; w5 B$ f$ I r+ C$ q
9 y0 S3 ?. C' _
$ sudo ovs-appctl ofproto/trace helloworld in_port=2,dl_src=50:00:00:00:00:02 -generate 1 C2 T; ~/ r8 K/ ?) I+ Z
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 9 @7 N5 C" a m* {
Rule: table=0 cookie=0 priority=0
; i6 X/ @/ @. o+ ~, v$ Q* _. rOpenFlow actions=resubmit(,1)! Y4 E& |, t- v9 o9 i# p& z. @3 }4 s1 A
6 r6 I. i! h( t- \ Resubmitted flow: unchanged . F/ n& W$ q/ Z p V- e2 w8 \7 i' X
Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
' r G" L' ]: u2 m( r Resubmitted odp: drop " Z; t" `, n" o3 r# V6 u
Rule: table=1 cookie=0 priority=99,in_port=2,vlan_tci=0x0000 p# T, x" @. x R
OpenFlow actions=mod_vlan_vid:20,resubmit(,2)( u, l5 z' z# p% |
6 e' A/ y5 Z8 u& [3 s 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 # E( I7 I8 }7 z; o# z
Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
% _. D( k5 _: y8 Q: y Resubmitted odp: drop
' `& P* x1 @: _) p' v; k Rule: table=2 cookie=0
: t2 G$ a3 [7 p r, P C 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)) }* j+ c# B8 \& w0 m7 m" A: w: D: H4 a
6 w1 ~' O5 i. Q. |& }3 T Resubmitted flow: unchanged 4 I: }1 S" A$ k: p, w
Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0 - P3 N$ u8 ?) m3 \! H
Resubmitted odp: drop " \7 M3 M$ v- M: Y7 x' U: j
No match
8 q+ I( m0 q( y% B* L0 J- J: h9 k5 L
& w: _+ [8 t+ ?Final flow: unchanged
* o$ c( x+ K5 |) I0 nRelevant 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
9 U* t( a: t( v Z6 FDatapath actions: drop% ]! ?6 _7 ~/ f+ w* X+ K4 d
7 _& c! }$ q. ~ ~7 d8 Y8 R
$ sudo ovs-ofctl dump-flows helloworld 4 l4 K0 f- D+ k0 j
NXST_FLOW reply (xid=0x4):
/ W, T! w% p3 }# l; Xcookie=0x0, duration=90823.14s, table=0, n_packets=0, n_bytes=0, idle_age=65534, hard_age=65534, priority=0 actions=resubmit(,1)
+ v( ~; q7 j" x$ ~" D; x' h' [cookie=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
! W- `1 Z1 q- j% t% }1 J5 Ycookie=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 - o; d0 f6 p2 z4 L
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) 2 a- t% N3 l! ?8 t$ _
cookie=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)
7 F4 |( v0 H$ ^* Ncookie=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)
& n w% P3 H# P: tcookie=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) ( i! F( `: X9 e( p: o
cookie=0x0, duration=86643.297s, table=1, n_packets=0, n_bytes=0, idle_age=65534, hard_age=65534, priority=0 actions=drop 6 F$ \. ^ z/ a
cookie=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) 8 `6 J1 d" K- ~4 p8 Z
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] - F& D: c, e) X9 J$ o$ u. g1 u
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]
2 G( C/ \) d7 X3 |7 ~- h. m) [) f& b6 O
实现第四个table 3: Look Up Destination Port: U) U% `4 g% y
: ?& A% n5 X& J/ }5 J P3 L
在table 2中,vswtich通过进入的包,学习了vlanid –> mac –> port的映射后,对于要发送的包,可以根据学习到的table 10里面的内容,根据destination mac和vlan,来找到相应的port发送出去,而不用每次都flood
* P8 f5 d$ f$ x3 q" M
8 `" r3 e: l; usudo ovs-ofctl add-flow helloworld "table=3 priority=50 actions=resubmit(,10), resubmit(,4)"
5 L. y/ J. P7 o! p( ?
" t1 h O+ r& P4 ?1 {添加这条规则,首先到table 10中查找learn table entry,如果找不到则到table 4
' N' E. R( x' j8 V9 ~8 @& h) {! z3 q" A! T9 j& R( o
如果包本身就是multicast的或者broadcast的,则不用去table 10里面取查找。! f; g$ m3 E- _' t5 b2 X& I
: `0 U8 c$ U- {7 ^sudo 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)"
/ o5 \- `; _8 ^7 h' |
3 p6 s/ E, @! n% S( G我们进行一项测试
9 P* ?8 }# t; ?+ \$ ]- T; {8 a, D; c: [
$ 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; X$ ?! r! G* I
Flow: 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
4 n, E; {% F8 n( q6 {: J1 |3 kRule: table=0 cookie=0 priority=0 0 G' S( B! z5 f' q. b
OpenFlow actions=resubmit(,1)9 B" k) }0 x- [2 z3 ^
- q+ `: h( \7 \$ x
Resubmitted flow: unchanged
" h! B& k1 N6 x Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
& Q3 Z/ q# y- |7 Z* x) }0 V Resubmitted odp: drop
5 [2 T; b' d2 x3 \- Z( i Rule: table=1 cookie=0 priority=99,in_port=1 8 B1 J3 q4 U4 u. K
OpenFlow actions=resubmit(,2)% z, f. N5 _4 K. d
8 U6 b5 f8 n$ a
Resubmitted flow: unchanged
' B6 V7 B5 z5 k3 M5 ?. t0 g Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0 0 h: Z9 ~5 A7 \1 F& b
Resubmitted odp: drop
1 G% \' Q7 f( B4 R: r0 d Rule: table=2 cookie=0 : W, R5 z: G& j) l0 g5 g
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 E" J3 Z; l* {, g% d L8 L5 `. h2 R6 S7 V" Y: a' H! U
Resubmitted flow: unchanged $ T& Y: s* n: q7 U2 T8 D
Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0 C, U+ p! ~! j
Resubmitted odp: drop 2 }2 l& J: B. D: o6 @; A
Rule: table=3 cookie=0 priority=50
3 J. n4 f/ n9 w# s8 z8 P OpenFlow actions=resubmit(,10),resubmit(,4)
2 C( L2 H* L# n' @3 A) n" }/ o# R ?, o! I' y
Resubmitted flow: unchanged
# r( |; @- R5 `* k Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
$ {* L& H2 }+ O, C3 k5 }/ u8 k2 M Resubmitted odp: drop * P- V" V, T3 {& F1 U
No match
- J- l5 }2 C$ h9 S
, W" ^; b! q* t5 c2 Q- m+ \, ?6 [+ G Resubmitted flow: unchanged 6 B7 Q& Y3 X. m6 m% j6 {" C
Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
, y6 o7 ~, A5 W6 j2 G* Q( q Resubmitted odp: drop : V: n- u% S2 _+ d& b& u0 `1 F# r
No match
# F1 S& p& N; I1 _# w: M; |7 X* s
9 n" q3 _& e$ S! m: K! AFinal flow: unchanged + g& B: l3 T' ~
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 ( u, f$ X# V2 x+ W
Datapath actions: drop
, |3 E" K9 N/ I3 T, `
8 j, R# I0 t1 Y由于目标地址f0:00:00:00:00:01没有在table 10中找到,因而到达table 4.& Z! g4 c4 ]+ A4 {7 x
3 S/ U L3 z# N, e* J! |但是这次测试使得table 10中学习到了mac地址90:00:00:00:00:01
7 ?3 @/ j4 j7 _& ]. K- S/ s) Z* }
8 Z( Y2 p9 ~2 @) ~$ sudo ovs-ofctl dump-flows helloworld 0 q! d& y# e1 Q% ]" N
NXST_FLOW reply (xid=0x4):
" @+ A+ p/ X) a! \cookie=0x0, duration=91588.452s, table=0, n_packets=0, n_bytes=0, idle_age=65534, hard_age=65534, priority=0 actions=resubmit(,1)
; B- o, P% u2 x# Z8 l. g6 P$ Scookie=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 * h7 j4 ^0 `" _; y3 ]
cookie=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
" b6 }' ^5 B2 p kcookie=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)
1 H |) e; F& Scookie=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) & h$ @& E9 c* G& T( E- y7 k% ~+ q2 \
cookie=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) % ~8 R% @3 ~! j/ ~1 v1 l
cookie=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) 0 A8 r: X: F. f! u+ _
cookie=0x0, duration=87408.609s, table=1, n_packets=0, n_bytes=0, idle_age=65534, hard_age=65534, priority=0 actions=drop
# C) L7 _( g( vcookie=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)
) y3 s/ O$ t# \9 e9 o! U) a4 Vcookie=0x0, duration=352.841s, table=3, n_packets=0, n_bytes=0, idle_age=352, priority=50 actions=resubmit(,10),resubmit(,4) : l" K* i$ h3 g6 p. m" @" ]
cookie=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)
" _, I. v4 k; f 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] # U9 u) g" b1 Q: q5 C- q7 D
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] + ?* \& Y5 O% Q0 K% p
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]
+ T7 u9 }. C6 k6 X
4 e4 U/ f% t& M8 b a0 U下面我们进行另一个测试
5 S* Y6 B: E D0 v
3 Z; P9 a9 u9 e$ 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 . M" y- H4 ^- W( ^7 }
Flow: 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
; p9 M7 E% f2 c2 c7 eRule: table=0 cookie=0 priority=0 ' V% M$ q) u/ C N
OpenFlow actions=resubmit(,1)
" e z0 H; C. t! ~( X5 ^, F% R/ k6 n( _+ B1 x7 a. w- K8 L
Resubmitted flow: unchanged
. d* |' f- D8 r, [7 F5 I6 m. q Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
; Q, G% ^* E( W& O Resubmitted odp: drop & A& {% o- v) N c
Rule: table=1 cookie=0 priority=99,in_port=2,vlan_tci=0x0000 " b5 ^1 w! L0 i
OpenFlow actions=mod_vlan_vid:20,resubmit(,2)
6 m( e) a2 f6 ~; ^, o2 S# A! K; K) A0 S. h9 i2 x
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 # Y- n: s- m2 c- k$ i) |1 l
Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
- ~2 X1 T) `5 N- z3 v Resubmitted odp: drop : x% V/ N% |; B& y5 Z* M
Rule: table=2 cookie=0 1 I, k2 u2 m1 p' O7 i! v
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 S# g p# r3 {$ ]9 c. D
- d! I$ M X+ q( M5 ] Resubmitted flow: unchanged 7 |% f r2 p6 N
Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
8 ]: o# M' F7 r& I' Q% c: \ Resubmitted odp: drop / W# r4 ~- ^1 |5 [- D2 J# ^
Rule: table=3 cookie=0 priority=50 % m1 d& P$ ^: ~" e4 b% p; b
OpenFlow actions=resubmit(,10),resubmit(,4)- W6 s$ H# G4 G6 @9 e' W
3 i+ \. t# K& R6 v
Resubmitted flow: unchanged
; R# Q& ^! }, D+ W! k Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0 ' y Y, E; C6 ^
Resubmitted odp: drop
2 c' R n' y7 a; N# F Rule: table=10 cookie=0 vlan_tci=0x0014/0x0fff,dl_dst=f0:00:00:00:00:01
. a/ R* a" {$ g8 c OpenFlow actions=load:0x1->NXM_NX_REG0[0..15]
% z: S1 i# t+ T# N& x. X1 J6 i0 x
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 2 ]5 q& A$ x5 c
Resubmitted regs: reg0=0x1 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
, X4 I0 Z; M+ @3 V3 k6 N i3 s7 E Resubmitted odp: drop
* W4 T0 o& Z* l# X) L- P No match$ V H! c/ H3 q8 s! F8 N ~7 H4 S
6 c7 B0 T: U# I+ A
Final flow: unchanged 3 x0 A4 i7 t9 J. W+ f
Relevant 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 4 ]* w( V$ e$ Y9 p* |, F
Datapath actions: drop
' q0 ~7 Y5 p7 o5 }! r4 q
& @) R) M5 ^9 E9 }因为刚才学习到了mac地址f0:00:00:00:00:01,所以这次在table 10中找到了这条记录,这次同时也学习到了mac地址90:00:00:00:00:01
7 i* _) Y, I4 w% r. x7 J4 X) w1 T j. v6 l% n6 t6 t
下面我们再发送第一次的包$ ~ J* x8 r. H- @- T0 Y
. S7 }4 k! R; f; N" \1 W$ 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 ; C8 k k) Z! H( h6 ]
Flow: 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
; t' k* ~( x5 \* WRule: table=0 cookie=0 priority=0
* o5 U+ H& h r# Q# p$ h/ hOpenFlow actions=resubmit(,1). d2 u# U# `1 t# ^ o9 a
; o* A# H& k& t" U5 Q; t: s8 N
Resubmitted flow: unchanged
+ f$ d2 G1 @6 E& ~- ~/ l: C: H2 I% { Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0 . S9 H: P' _ j, _8 E
Resubmitted odp: drop
6 j5 L: K" a" g7 B' \: ^/ ~0 a Rule: table=1 cookie=0 priority=99,in_port=1
$ n: Q% D# ?- V$ m, | OpenFlow actions=resubmit(,2)
' r2 c( a: }5 i7 R7 p, _& ~
+ Y' I2 _: L4 M: u/ W) x Resubmitted flow: unchanged
2 Y0 d. z [6 B Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0 ( N9 f7 d" u. Z( b7 ]+ O
Resubmitted odp: drop * B8 }1 D/ q3 P) [, k" F
Rule: table=2 cookie=0
1 @0 A, J2 \, g* z/ V& u 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 ^$ K& d) i1 T" W$ p |4 U6 N0 y$ o( p1 o
Resubmitted flow: unchanged / W4 k, _9 D& Y5 @# H
Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
" q( S. `8 P* N2 H& B Resubmitted odp: drop $ y V4 F0 t5 _( i4 z$ L
Rule: table=3 cookie=0 priority=50 9 b _6 J' z" z& v/ C9 D0 Y
OpenFlow actions=resubmit(,10),resubmit(,4)
! k6 t8 V* ^; U7 y% T6 N# ~0 {
, @8 z! ^2 {( D$ G0 B4 f Resubmitted flow: unchanged
: I H5 v+ i' H+ v ^$ z7 U/ @9 D Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0 ! z) M" D3 I' E- F) {! N6 l
Resubmitted odp: drop 9 H) {8 _/ U: Z4 @# V" [. y
Rule: table=10 cookie=0 vlan_tci=0x0014/0x0fff,dl_dst=90:00:00:00:00:01
) r# q N; o ` B OpenFlow actions=load:0x2->NXM_NX_REG0[0..15]
: ^1 B) ]2 x8 r0 L. Y
/ Z4 {+ x( _0 Y; y. g# M7 C6 N2 | 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 / h' x% p! d8 ?0 ?
Resubmitted regs: reg0=0x2 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0 2 ~' u3 [( U' M) e5 C4 S4 H
Resubmitted odp: drop
1 g7 V8 [+ u7 G% O, P No match! q$ m1 n. ~1 ~2 ^
0 ]1 V1 B8 q U5 QFinal flow: unchanged
6 _' |" V8 G1 R" HRelevant 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
) \8 k0 B0 Q' |* ^9 {7 p; w YDatapath actions: drop
( o+ p/ h' J. a' t: d9 h( x( k p2 P/ O! t, \) Q
发现也在table 10中找到了记录
" {# O1 y; I8 z. d* z+ M2 P8 R0 z+ s9 o' [% k/ W
实现第五个table 4: Output Processing% P# {% q! B* i
6 K4 W+ n, A7 {
这个时候,register 0中包含了output port,如果是0则说明是flood。
& a4 B4 I: K7 V) l* R
% @: b0 i( d+ V1 ^% I( p# R对于port 1来讲,是trunk port,所以携带的vlan tag就让他带着,从port 1出去。4 Z" m/ ~. c! H4 @, h& [0 Y
3 |& I2 A6 Q: Q0 h7 c2 A& k
sudo ovs-ofctl add-flow helloworld "table=4 reg0=1 actions=1"
) b# V& }! s8 [2 z1 | T) v
: T: g ], O( |% j- u% d7 H* X对于port 2来讲,是vlan 20的,然而出去的时候,vlan tag会被抹掉,从port 2发出去 X9 m# s* @6 c I6 [
; f+ n5 }+ U4 X3 K* o
对于port 3, 4来讲,是vlan 30的,然而出去的时候,vlan tag会被抹掉,从port 3, 4出去
2 H* u2 P% S, C$ ?( n# I) j7 s& ?, F5 g7 i* g6 e3 Z
$ sudo ovs-ofctl add-flows helloworld - <<'EOF'
+ y! }, {1 E- S e- z table=4 reg0=2 actions=strip_vlan,2 ! I: L( m8 r/ _7 \" V9 `4 d
table=4 reg0=3 actions=strip_vlan,3 ; K( x: q3 m5 V
table=4 reg0=4 actions=strip_vlan,4
8 a( H/ h6 v' C: L4 D/ G+ T/ qEOF
3 t/ U. w2 q1 t( w. i! ~4 o! j5 [ y# H: J) l% k6 {( {
对于broadcast来讲,我们希望一个vlan的broadcast仅仅在这个vlan里面发送,不影响其他的vlan。4 W6 d/ S% `$ B5 }' i, i; E
; P" ]# y; B) }: |$ sudo ovs-ofctl add-flows helloworld - <<'EOF' 6 d! b; v2 w4 A3 H" J: O' ~2 _
table=4 reg0=0 priority=99 dl_vlan=20 actions=1,strip_vlan,2 - X# A# n( \3 ~" M. t' Y( \1 |
table=4 reg0=0 priority=99 dl_vlan=30 actions=1,strip_vlan,3,4
& _9 t3 b f/ ~3 J! o3 `2 H+ K3 T5 ~/ ~( G table=4 reg0=0 priority=50 actions=1
1 X7 k/ t. |, e4 P& LEOF* V- {# y, E/ W( R3 G) L1 \1 O- {
: \+ M, P7 F" r6 V' s6 H所以对于register = 0的,也即是broadcast的,属于vlan 20的,则从port 1, 2出去,属于vlan 30的,则从port 1, 3, 4出去。
) z- g/ x2 e0 i0 J
3 {1 [* R# K0 U7 t. W$ sudo ovs-ofctl dump-flows helloworld
9 \$ f1 ? m0 `! ?NXST_FLOW reply (xid=0x4): 0 Z& b& P" O# a5 G& e# t! w* f
cookie=0x0, duration=92909.119s, table=0, n_packets=0, n_bytes=0, idle_age=65534, hard_age=65534, priority=0 actions=resubmit(,1)
& P! K0 j1 y9 {, i- f: Ucookie=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 ( ]0 |& E/ W) A1 t( f* E! W
cookie=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 " ?$ f! `4 T( w ^
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) , P4 t& Z5 J( g O- }% _
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)
' }0 x! L- {5 }7 d! E$ |* Kcookie=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) # ?5 k; e% X2 c* K& N
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) 1 x, c& }2 o& J; p+ J
cookie=0x0, duration=88729.276s, table=1, n_packets=0, n_bytes=0, idle_age=65534, hard_age=65534, priority=0 actions=drop " E) I0 u' H/ b: k7 x9 e
cookie=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: G. y. ~6 i7 ^+ Rcookie=0x0, duration=1673.508s, table=3, n_packets=0, n_bytes=0, idle_age=1673, priority=50 actions=resubmit(,10),resubmit(,4) - R5 u% `. D/ ~/ K/ ~& f- y
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) ! E2 ^7 L4 M# t1 n( W
cookie=0x0, duration=332.478s, table=4, n_packets=0, n_bytes=0, idle_age=332, reg0=0x3 actions=strip_vlan,output:3
2 e0 a2 T/ H0 t8 W' {cookie=0x0, duration=228.839s, table=4, n_packets=0, n_bytes=0, idle_age=228, priority=50,reg0=0x0 actions=output:1 8 i4 y7 H* T: ]8 X! V. e8 Y
cookie=0x0, duration=483.068s, table=4, n_packets=0, n_bytes=0, idle_age=483, reg0=0x1 actions=output:1
4 Z) u1 P1 Z$ f2 Z7 p9 Wcookie=0x0, duration=332.478s, table=4, n_packets=0, n_bytes=0, idle_age=332, reg0=0x4 actions=strip_vlan,output:4 , R0 [ L4 s2 Y
cookie=0x0, duration=332.478s, table=4, n_packets=0, n_bytes=0, idle_age=332, reg0=0x2 actions=strip_vlan,output:2
& i' Q, @" `6 E* j4 n% t; f" C# [9 qcookie=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 3 @% B1 C0 R# {+ t7 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
2 I E+ C5 F$ T* Z, r2 Y5 scookie=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]
4 j/ V1 Y' ]9 J* p2 ycookie=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]
' v8 A8 j8 n1 U `cookie=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] ) Q: q. q# |8 t C, p
cookie=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]
n* U6 c1 v' S9 [
% ~& }9 a T9 ~" V! A! U: C: [首先来测试一个multicast和broadcast
1 N( D2 [& |2 \! \% X; n* z' T9 `+ O; Q2 B F
如果是一个port 1来的vlan 30的broadcast
- y% e! G; `$ S( e+ ?
+ P/ G0 w+ F8 w% ^' t- G. ^$ sudo ovs-appctl ofproto/trace helloworld in_port=1,dl_dst=ff:ff:ff:ff:ff:ff,dl_vlan=30
5 O: r; W T! x) c1 W! mFlow: 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 & D9 z+ B7 Y' l9 E: z
Rule: table=0 cookie=0 priority=0 ( J1 u- Z$ s8 C4 H
OpenFlow actions=resubmit(,1)
7 v0 a. \7 A6 O$ j4 D- W: \8 K5 H3 E7 ~1 q6 }
Resubmitted flow: unchanged $ P9 I: W$ m+ `; r& O" L
Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
) S# i+ I; O% @! E. Q Resubmitted odp: drop & `+ c! H+ }# R( b! i
Rule: table=1 cookie=0 priority=99,in_port=1
2 S- s3 e2 Z$ B* ]1 @% w OpenFlow actions=resubmit(,2)
& p7 |% f' ]0 y
8 ^0 ~8 T6 E! Q- \7 \5 ~# }5 y Resubmitted flow: unchanged
' P2 A3 L7 G3 ]' P: F. H0 w Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0 6 Q0 X- D5 R" V' W
Resubmitted odp: drop O; x, v/ L! ]% n* v
Rule: table=2 cookie=0
* ?5 i! t4 p# Z5 z% U 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)
! L+ W, F2 d5 U. X2 V$ `
( s" ]) T7 [( z' g9 U8 U Resubmitted flow: unchanged 4 A" M" v, V+ v! N
Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0 1 \+ n( P( P! }) z! q8 l
Resubmitted odp: drop 9 d5 l$ G% a+ x; W. o" V2 z& H
Rule: table=3 cookie=0 priority=99,dl_dst=01:00:00:00:00:00/01:00:00:00:00:00
. d+ @$ G0 D' ~ OpenFlow actions=resubmit(,4); K2 I) U( y4 a1 Q3 R* O
* {' E, j! k) B6 E& f. J
Resubmitted flow: unchanged
: T' \4 ]2 X, S! j5 l1 c4 O3 J Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
( S6 @7 G. g( b Resubmitted odp: drop 6 N7 f0 ^8 G' D- C2 H
Rule: table=4 cookie=0 priority=99,reg0=0x0,dl_vlan=30 $ K& X @5 `2 x% M
OpenFlow actions=output:1,strip_vlan,output:3,output:4 $ m. P) M" v6 j# k$ I) B( A
skipping output to input port$ i7 ]$ \ ?; n* ?' o, Q$ V" |! S
0 i" C& _6 O9 w7 g( p
Final 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
. [% t, Z, B& J0 M5 PRelevant 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 4 A8 P) B7 I+ I+ l7 k
Datapath actions: pop_vlan,12,13& N& E) L( I+ S' j" l+ `
0 i+ S7 M) o& ^% ~- h6 f2 M6 Q
结果是port 1就不发送了,发送给了port 3, 4! o; l1 P8 |3 c7 E1 M0 U: l4 p* z
6 @8 g& ~7 ?' Z) _0 U$ sudo ovs-appctl ofproto/trace helloworld in_port=3,dl_dst=ff:ff:ff:ff:ff:ff + n5 s' W' |' \1 @1 h t7 \
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 " t4 Q# |! Q; S/ [7 p
Rule: table=0 cookie=0 priority=0 5 \3 A! p; m. n
OpenFlow actions=resubmit(,1), ]8 A5 r' \( X/ M6 @' c
- b- S5 s+ C1 o9 B
Resubmitted flow: unchanged ; @ k, X, s7 f. O6 o
Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0 ; W; S+ a' K" }' e+ K
Resubmitted odp: drop * a4 _5 Q1 S4 ^5 l7 n1 ?$ d
Rule: table=1 cookie=0 priority=99,in_port=3,vlan_tci=0x0000
! c: ^% l# U1 I$ x( H4 B OpenFlow actions=mod_vlan_vid:30,resubmit(,2)
" S( G" C T8 Q; r2 A# ]; Y% B
) B2 h+ f& p5 k1 A# }5 a) o 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
2 P& z* P- `* Z4 W Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
2 w2 H: v z3 d" ^) ~5 Z Resubmitted odp: drop
! Z# z" \, f( T Rule: table=2 cookie=0 / U* B; ^. b" n L2 l* f! O
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)
0 d9 i8 |+ [: ?2 {' B! s1 G: L0 W/ q6 T% H1 V: U1 E
Resubmitted flow: unchanged
9 {+ }' a/ ~" k" X/ ? Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
0 m* g9 z, c1 _& y Resubmitted odp: drop 4 O0 w, N: R$ `, s, r: ^2 T% H
Rule: table=3 cookie=0 priority=99,dl_dst=01:00:00:00:00:00/01:00:00:00:00:00 * w t( _) K- o& a
OpenFlow actions=resubmit(,4). Q* `! C: ^8 o9 X& H
) H0 y% K" y8 o7 x; H8 M Resubmitted flow: unchanged 0 y% N4 g8 C' L0 p# j! u
Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
2 i6 N# ^" w: _2 m2 l. L. ? Resubmitted odp: drop 7 D- h2 Q6 l) B
Rule: table=4 cookie=0 priority=99,reg0=0x0,dl_vlan=30
) f0 O: u6 S' A3 D+ e8 _ OpenFlow actions=output:1,strip_vlan,output:3,output:4 . r7 [: W# V1 t( F$ `3 |, j6 S
skipping output to input port1 X/ D/ e7 B. F4 Q0 V# ]
& q4 ~( D+ e; C0 D. x7 e# v) UFinal 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
2 @$ b+ e* b) W p. E7 @! E8 H- oRelevant 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 ( q# @$ Q1 P1 T, D6 V" ^
Datapath actions: push_vlan(vid=30,pcp=0),10,pop_vlan,13$ Z0 t. O! T+ L: E0 _8 _- \5 y; s4 N
" l8 b. F/ |4 @+ J& v) b2 d接着我们测试mac learning
0 Z2 ]" i+ L! J* r4 R2 e
3 P0 X- x$ ]) W* F9 r$ 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 . F: r8 p( M8 U% m
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
9 ]: Q1 X7 E' U0 n& I* |Rule: table=0 cookie=0 priority=0
, F; K" t& r, g" ?OpenFlow actions=resubmit(,1)# ?9 b3 y3 m" s( H; C; b
! k; k" @3 ]0 r @* Z Resubmitted flow: unchanged
6 i! j( I6 @, V8 H! L: |8 S% [ Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0 % v' D0 ^( a6 N
Resubmitted odp: drop
: x, a$ _! x+ S; q5 q+ C0 p Rule: table=1 cookie=0 priority=99,in_port=1
* w' [( F" I) B3 o OpenFlow actions=resubmit(,2)
+ s/ b7 L0 \( D, v2 `
/ d S' e# M0 n: y Resubmitted flow: unchanged 1 Y ~$ w# u0 [. d. Y$ ~, F N
Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
; `" x0 F9 h1 `7 G3 B% i' t( ] Resubmitted odp: drop / \' Z* C/ Y0 R
Rule: table=2 cookie=0
: ?8 x( c7 Y( C2 C. F! y0 e @ 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)
' ~) E! T+ R" b/ K f {9 a @$ R; G0 i: i! g
Resubmitted flow: unchanged 2 x" `$ T4 n1 r q' B# n. d. k P
Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0 . ]* P# ]* Z7 _6 ^4 P! W
Resubmitted odp: drop
/ Q# A, N6 d( w. s+ N4 A5 a Rule: table=3 cookie=0 priority=50 $ f2 }3 Q+ B6 Q8 b
OpenFlow actions=resubmit(,10),resubmit(,4)1 l: @# q/ t) h2 @' Q
* g$ F* G9 G4 d1 U" M
Resubmitted flow: unchanged m g8 L) z$ Z
Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
% }% R" {7 P. y. L9 W Resubmitted odp: drop
8 R- G0 `" J: W; R& N1 } No match
7 Q1 f2 R% Z* Y) ] |5 D' h) Q
+ e3 B/ s9 \6 i" _2 F5 G% R8 p' h) d Resubmitted flow: unchanged
, u4 c8 U9 I: h9 ^2 h) A2 W- N2 D Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0 1 D: E1 J$ X0 u% K# J0 M# d
Resubmitted odp: drop
, I0 @" T4 a# |- v4 |. @0 }' { Rule: table=4 cookie=0 priority=99,reg0=0x0,dl_vlan=30 6 M E8 X8 q5 j$ k Y0 p4 g
OpenFlow actions=output:1,strip_vlan,output:3,output:4
# H y8 C' o7 D K) C8 s D; v skipping output to input port- z4 \: H! E4 B y6 Y' ~5 w
2 R) Z2 m* u- M: \
Final 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 & d' Y2 l. w* _ l7 B: X3 W
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
' m$ V- x! E% t9 y& _5 _* R# VDatapath actions: pop_vlan,12,13. F! E4 Z& v0 V- q' g. j% G* C+ o0 P+ n
+ b( o- v4 u' {/ L8 P8 U! K7 V
由于这两个地址没有出现过,则除了进行学习以外,广播发送给port 3,4
& L7 s$ F$ | O- w0 B' X* g8 h, j
) m$ u0 o) x% I3 z8 \* g& [3 a$ 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
( \* k# d: |) d Z% z. r1 r/ nFlow: 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 8 d( {) n6 c6 Y0 T6 v& m
Rule: table=0 cookie=0 priority=0
# r2 F# u5 Q3 O n, W4 e7 dOpenFlow actions=resubmit(,1)# h0 _) {' t9 _: e1 s
3 f0 ^3 {- d6 I$ C/ z- M
Resubmitted flow: unchanged
+ p: C9 S# `& x8 V2 c- y& |9 } Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
6 F4 V% Y$ Q! u3 d- [* v+ y H# m. p0 f Resubmitted odp: drop
! u t: r1 ]! H) |# I0 ?; {4 A Rule: table=1 cookie=0 priority=99,in_port=4,vlan_tci=0x0000
/ W- F0 m. L" E$ M [! Q9 r- d OpenFlow actions=mod_vlan_vid:30,resubmit(,2)
& m4 m! L- d }8 W$ J) A& @" K% @" J: H9 D( A! K
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
# `/ I/ E7 }2 W Q6 p1 |6 N! q Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
: Q/ q" P' j7 |* q& q Resubmitted odp: drop ], g: B3 ?! J! H7 B6 t
Rule: table=2 cookie=0
) l3 H0 ?- E+ t2 |, w 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 Y: S( {: |* _+ Q* r' k' \. Y+ m3 z& R. c3 S, s7 P. Q" t$ D- I
Resubmitted flow: unchanged
) X! D/ l# e3 j% c, _$ ? Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0 $ S# E! y8 T5 L- ]4 P3 t
Resubmitted odp: drop $ V3 j, P6 c" p) s
Rule: table=3 cookie=0 priority=50
/ @9 [) f6 H' f5 I2 _/ o7 ?) O2 { OpenFlow actions=resubmit(,10),resubmit(,4)! e5 d2 Y8 b8 P7 T" ]
! M" A7 a7 Z- d% R" R l4 N8 y1 N Resubmitted flow: unchanged ; M# k Y8 G: Q' O
Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
9 ^' v' _4 F& K' C Resubmitted odp: drop
; n7 l3 B4 z) O2 Y. { Rule: table=10 cookie=0 vlan_tci=0x001e/0x0fff,dl_dst=10:00:00:00:00:01
8 l9 _- k) q. V' R& W. x OpenFlow actions=load:0x1->NXM_NX_REG0[0..15]
% @$ ~5 V* R6 Q0 w# D( x% o/ I8 C5 x$ {3 a' t
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 3 n; f5 q: l: m8 P& Y
Resubmitted regs: reg0=0x1 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0 & ^$ a* l+ D* d2 U# K7 P1 V& b! [ d
Resubmitted odp: drop
! V% h; v& b# @1 @% |, q z, ^ Rule: table=4 cookie=0 reg0=0x1 / c4 o9 p# m3 R% o& h( A; T) z
OpenFlow actions=output:1
2 N( [8 R, Y2 I: f9 b% O$ E5 f; ~2 {
Final flow: unchanged 9 q9 ]/ t- A4 I( U7 l* L! J1 o5 ~, {9 Y
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 2 u0 ?. s( N5 h$ H F
Datapath actions: push_vlan(vid=30,pcp=0),10/ O7 y5 x4 L. f
) i# M& G8 u+ ?8 a/ ?: S回复的时候,由于学习过了,则仅仅从port 1发送出去。, M( ~( |* E7 e0 n* j. G
/ }+ s, z9 y$ w8 c( i: g( l
$ 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
2 p' Z- ^6 t: RFlow: 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 ) f! g1 s; T, g {- ]/ T* Y
Rule: table=0 cookie=0 priority=0
, _3 j9 Y5 u8 b) u; }! J" IOpenFlow actions=resubmit(,1)
, Z9 j7 H- u) J- R6 I9 b2 ~$ f0 `5 I7 i% ]+ b
Resubmitted flow: unchanged 2 t R! `( h! s4 Y
Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
$ D* n) B" C* D Resubmitted odp: drop + f# i, G# ?2 {# F& F! c% [7 a
Rule: table=1 cookie=0 priority=99,in_port=1 " l7 n0 P, k" v0 s: c/ r; R
OpenFlow actions=resubmit(,2)
, M; j6 T* ?) S. E
7 b# q+ w" ]+ L K0 U" X, k" v+ U1 @ Resubmitted flow: unchanged
0 a4 R5 \5 R" J$ J/ m, ?$ M Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0 ) I* @6 j4 |" _+ T8 F- Q
Resubmitted odp: drop
1 j( _' H% q2 F) e9 u Rule: table=2 cookie=0
3 \9 u) B+ H$ z. g& ^ 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* I3 w( f' {* q C0 ]1 ]9 P/ \4 s9 m( I7 t
Resubmitted flow: unchanged
( I: L; S8 ], K& f2 F* f Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0 b, g( t+ Z8 X* w0 M y
Resubmitted odp: drop
$ E: E2 z0 H) Q' e: h Rule: table=3 cookie=0 priority=50 . c4 M3 v* T; m h, E4 J
OpenFlow actions=resubmit(,10),resubmit(,4)
" a" Y1 [3 u9 F5 }) p! f# z0 ]& _- l9 u
Resubmitted flow: unchanged
) c6 b% F2 Q7 M6 G Resubmitted regs: reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0 & ~2 y$ ]8 B) W1 N X; Y1 n3 }0 B
Resubmitted odp: drop . c9 b: Z0 j n- p+ S
Rule: table=10 cookie=0 vlan_tci=0x001e/0x0fff,dl_dst=20:00:00:00:00:01 : H5 o; b5 y) r; p( E( G8 b% i
OpenFlow actions=load:0x4->NXM_NX_REG0[0..15], F P0 p) n* f
0 N X4 R4 ]0 Y. g, y 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
) o) c# ^( L/ n1 i+ p0 H Resubmitted regs: reg0=0x4 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0
( q1 U( o7 |1 e- ?( Q" J Resubmitted odp: drop ) ?/ F' `( y$ T/ d3 c
Rule: table=4 cookie=0 reg0=0x4 # g! y! q) j$ t: l9 T& v8 v
OpenFlow actions=strip_vlan,output:4# ` X& D, Y& v7 M( H
& o3 } A& a b' W$ L* oFinal 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
% Y4 U% v; s6 C! f- l5 URelevant 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 4 a0 f/ X( k) S! O
Datapath actions: pop_vlan,13
, Y/ ^/ @/ `, d* z3 \* `9 Z5 Z6 n) t8 v1 f+ A$ Z0 Z: s
由于在回复中进行了学习,因而发送的时候,仅仅发送port 4 |
|