Run OvS with ovs-sandbox
Orion Electric Age

Prepare the Linux environment, you can run a virtual machine, a centos 7.4 image, with virtual box.

Install development enviroment

1
2
$ yum install git
$ yum groupinstall "Development tools"

Download Open vSwitch source code

1
2
3
$ git clone https://github.com/openvswitch/ovs.git
$ git branch --remote
$ git branch branch-2.10

Compile Open vSwitch

1
2
3
4
5
$ cd ./ovs
$ sh ./boot.sh
$ ./configure
$ make
$ ./tutorial/ovs-sandbox

Open vSwitch Advanced Features

We will construct Open vSwitch flow tables for a VLAN-capable, MAC-learning switch that has four ports:

  • p1: a trunk port that carries all VLANs, on OpenFlow port 1.
  • p2: an access port for VLAN 20, on OpenFlow port 2.
  • p3, p4: both access ports for VLAN 30, on OpenFlow ports 3 and 4, respectively.

Our switch design will consist of five main flow tables, each of which implements one stage in the switch pipeline:

  • Table 0: Admission control.
  • Table 1: VLAN input processing.
  • Table 2: Learn source MAC and VLAN for ingress port.
  • Table 3: Look up learned port for destination MAC and VLAN.
  • Table 4: Output processing.

Setup the switch and ports

1
2
3
4
5
$ ovs-vsctl add-br br0 -- set Bridge br0 fail-mode=secure \
$ ovs-vsctl add-port br0 p1 -- set Interface p1 ofport_request=1; ovs-ofctl mod-port br0 p1 up
$ ovs-vsctl add-port br0 p2 -- set Interface p2 ofport_request=2; ovs-ofctl mod-port br0 p2 up
$ ovs-vsctl add-port br0 p3 -- set Interface p3 ofport_request=3; ovs-ofctl mod-port br0 p3 up
$ ovs-vsctl add-port br0 p4 -- set Interface p4 ofport_request=4; ovs-ofctl mod-port br0 p4 up

Implementing tables

Table 0: Multicase source address and stp packets are not forwarded, the others are valid.

1
2
3
$ ovs-ofctl add-flow br0 "table=0, dl_src=01:00:00:00:00:00/01:00:00:00:00:00, actions=drop"
$ ovs-ofctl add-flow br0 "table=0, dl_dst=01:80:c2:00:00:00/ff:ff:ff:ff:ff:f0, actions=drop"
$ ovs-ofctl add-flow br0 "table=0, priority=0, actions=resubmit(,1)"

Table 1: vlan input processing, the default policy is “drop”.

1
2
3
4
5
6
7
$ ovs-ofctl add-flow br0 "table=1, priority=0, actions=drop"
$ ovs-ofctl add-flow br0 "table=1, priority=99, in_port=1, actions=resubmit(,2)"
$ ovs-ofctl add-flows br0 - <<'EOF'
table=1, priority=99, in_port=2, vlan_tci=0, actions=mod_vlan_vid:20, resubmit(,2)
table=1, priority=99, in_port=3, vlan_tci=0, actions=mod_vlan_vid:30, resubmit(,2)
table=1, priority=99, in_port=4, vlan_tci=0, actions=mod_vlan_vid:30, resubmit(,2)
EOF

Table 2: MAC+VLAN Learning for Ingress Port

1
2
3
4
5
$ ovs-ofctl add-flow br0 \
"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)"

Table 3: Look Up Destination Port

1
2
3
4
$ ovs-ofctl add-flow br0 \
"table=3 priority=50 actions=resubmit(,10), resubmit(,4)"
$ ovs-ofctl add-flow br0 \
"table=3 priority=99 dl_dst=01:00:00:00:00:00/01:00:00:00:00:00 actions=resubmit(,4)"

Table 4: Output Processing

1
2
3
4
5
6
7
8
9
10
11
$ ovs-ofctl add-flow br0 "table=4 reg0=1 actions=1"
$ ovs-ofctl add-flows br0 - <<'EOF'
table=4 reg0=2 actions=strip_vlan,2
table=4 reg0=3 actions=strip_vlan,3
table=4 reg0=4 actions=strip_vlan,4
EOF
$ ovs-ofctl add-flows br0 - <<'EOF'
table=4 reg0=0 priority=99 dl_vlan=20 actions=1,strip_vlan,2
table=4 reg0=0 priority=99 dl_vlan=30 actions=1,strip_vlan,3,4
table=4 reg0=0 priority=50 actions=1
EOF

Dump all the table flows

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# ovs-ofctl dump-flows br0
cookie=0x0, duration=4157.126s, table=0, n_packets=0, n_bytes=0, dl_src=01:00:00:00:00:00/01:00:00:00:00:00 actions=drop
cookie=0x0, duration=4146.396s, table=0, n_packets=0, n_bytes=0, dl_dst=01:80:c2:00:00:00/ff:ff:ff:ff:ff:f0 actions=drop
cookie=0x0, duration=4136.741s, table=0, n_packets=0, n_bytes=0, priority=0 actions=resubmit(,1)
cookie=0x0, duration=4073.263s, table=1, n_packets=0, n_bytes=0, priority=99,in_port=p1 actions=resubmit(,2)
cookie=0x0, duration=3829.544s, table=1, n_packets=0, n_bytes=0, priority=99,in_port=p2,vlan_tci=0x0000 actions=mod_vlan_vid:20,resubmit(,2)
cookie=0x0, duration=3829.468s, table=1, n_packets=0, n_bytes=0, priority=99,in_port=p3,vlan_tci=0x0000 actions=mod_vlan_vid:30,resubmit(,2)
cookie=0x0, duration=3829.468s, table=1, n_packets=0, n_bytes=0, priority=99,in_port=p4,vlan_tci=0x0000 actions=mod_vlan_vid:30,resubmit(,2)
cookie=0x0, duration=4089.873s, table=1, n_packets=0, n_bytes=0, priority=0 actions=drop
cookie=0x0, duration=3682.963s, table=2, n_packets=0, n_bytes=0, actions=learn(table=10,NXM_OF_VLAN_TCI[0..11],NXM_OF_ETH_DST[]=NXM_OF_ETH_SRC[],load:NXM_OF_IN_PORT[]->NXM_NX_REG0[0..15]),resubmit(,3)
cookie=0x0, duration=3645.636s, table=3, n_packets=0, n_bytes=0, priority=99,dl_dst=01:00:00:00:00:00/01:00:00:00:00:00 actions=resubmit(,4)
cookie=0x0, duration=3549.407s, table=3, n_packets=0, n_bytes=0, priority=50 actions=resubmit(,10),resubmit(,4)
cookie=0x0, duration=3512.926s, table=4, n_packets=0, n_bytes=0, reg0=0x1 actions=output:p1
cookie=0x0, duration=1534.991s, table=4, n_packets=0, n_bytes=0, reg0=0x2 actions=strip_vlan,output:p2
cookie=0x0, duration=1534.990s, table=4, n_packets=0, n_bytes=0, reg0=0x3 actions=strip_vlan,output:p3
cookie=0x0, duration=1534.990s, table=4, n_packets=0, n_bytes=0, reg0=0x4 actions=strip_vlan,output:p4
cookie=0x0, duration=1515.987s, table=4, n_packets=0, n_bytes=0, priority=50,reg0=0 actions=output:p1
cookie=0x0, duration=1515.987s, table=4, n_packets=0, n_bytes=0, priority=99,reg0=0,dl_vlan=20 actions=output:p1,strip_vlan,output:p2
cookie=0x0, duration=1515.987s, table=4, n_packets=0, n_bytes=0, priority=99,reg0=0,dl_vlan=30 actions=output:p1,strip_vlan,output:p3,output:p4

Testing Tables

Testing Table 0

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# ovs-appctl ofproto/trace br0 in_port=1,dl_dst=01:80:c2:00:00:05
Flow: 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

bridge("br0")
-------------
0. dl_dst=01:80:c2:00:00:00/ff:ff:ff:ff:ff:f0, priority 32768
drop

Final flow: unchanged
Megaflow: recirc_id=0,eth,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
Datapath actions: drop

# ovs-appctl ofproto/trace br0 in_port=1,dl_dst=01:80:c2:00:00:10
Flow: 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

bridge("br0")
-------------
0. priority 0
resubmit(,1)
1. in_port=1, priority 99
resubmit(,2)
2. priority 32768
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])
>> suppressing side effects, so learn action ignored
resubmit(,3)
3. dl_dst=01:00:00:00:00:00/01:00:00:00:00:00, priority 99
resubmit(,4)
4. reg0=0, priority 50
output:1
>> skipping output to input port

Final flow: unchanged
Megaflow: recirc_id=0,eth,in_port=1,vlan_tci=0x0000/0x1fff,dl_src=00:00:00:00:00:00,dl_dst=01:80:c2:00:00:10/ff:ff:ff:ff:ff:f0,dl_type=0x0000
Datapath actions: drop

Testing Table 1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# ovs-appctl ofproto/trace br0 in_port=1,vlan_tci=5
Flow: in_port=1,vlan_tci=0x0005,vlan_tci1=0x0000,dl_src=00:00:00:00:00:00,dl_dst=00:00:00:00:00:00,dl_type=0x0000

bridge("br0")
-------------
0. priority 0
resubmit(,1)
1. in_port=1, priority 99
resubmit(,2)
2. priority 32768
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])
>> suppressing side effects, so learn action ignored
resubmit(,3)
3. priority 50
resubmit(,10)
10. No match.
drop
resubmit(,4)
4. reg0=0, priority 50
output:1
>> skipping output to input port

Final flow: unchanged
Megaflow: recirc_id=0,eth,in_port=1,vlan_tci=0x0005/0x1fff,dl_src=00:00:00:00:00:00,dl_dst=00:00:00:00:00:00/ff:ff:ff:ff:ff:f0,dl_type=0x0000
Datapath actions: drop

# ovs-appctl ofproto/trace br0 in_port=2
Flow: 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

bridge("br0")
-------------
0. priority 0
resubmit(,1)
1. in_port=2,vlan_tci=0x0000, priority 99
mod_vlan_vid:20
resubmit(,2)
2. priority 32768
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])
>> suppressing side effects, so learn action ignored
resubmit(,3)
3. priority 50
resubmit(,10)
10. No match.
drop
resubmit(,4)
4. reg0=0,dl_vlan=20, priority 99
output:1
strip_vlan
output:2
>> skipping output to input port

Final flow: unchanged
Megaflow: recirc_id=0,eth,in_port=2,vlan_tci=0x0000,dl_src=00:00:00:00:00:00,dl_dst=00:00:00:00:00:00/ff:ff:ff:ff:ff:f0,dl_type=0x0000
Datapath actions: push_vlan(vid=20,pcp=0),1

# ovs-appctl ofproto/trace br0 in_port=2
Flow: 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

bridge("br0")
-------------
0. priority 0
resubmit(,1)
1. in_port=2,vlan_tci=0x0000, priority 99
mod_vlan_vid:20
resubmit(,2)
2. priority 32768
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])
>> suppressing side effects, so learn action ignored
resubmit(,3)
3. priority 50
resubmit(,10)
10. No match.
drop
resubmit(,4)
4. reg0=0,dl_vlan=20, priority 99
output:1
strip_vlan
output:2
>> skipping output to input port

Final flow: unchanged
Megaflow: recirc_id=0,eth,in_port=2,vlan_tci=0x0000,dl_src=00:00:00:00:00:00,dl_dst=00:00:00:00:00:00/ff:ff:ff:ff:ff:f0,dl_type=0x0000
Datapath actions: push_vlan(vid=20,pcp=0),1
[root@localhost ovs]#
[root@localhost ovs]#
[root@localhost ovs]# ovs-appctl ofproto/trace br0 in_port=2,vlan_tci=5
Flow: in_port=2,vlan_tci=0x0005,vlan_tci1=0x0000,dl_src=00:00:00:00:00:00,dl_dst=00:00:00:00:00:00,dl_type=0x0000

bridge("br0")
-------------
0. priority 0
resubmit(,1)
1. priority 0
drop

Final flow: unchanged
Megaflow: recirc_id=0,eth,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
Datapath actions: drop

Testing Table 2

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# ovs-appctl ofproto/trace br0 \
> in_port=1,vlan_tci=20,dl_src=50:00:00:00:00:01 -generate
Flow: in_port=1,vlan_tci=0x0014,vlan_tci1=0x0000,dl_src=50:00:00:00:00:01,dl_dst=00:00:00:00:00:00,dl_type=0x0000

bridge("br0")
-------------
0. priority 0
resubmit(,1)
1. in_port=1, priority 99
resubmit(,2)
2. priority 32768
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])
-> table=10 vlan_tci=0x0014/0x0fff,dl_dst=50:00:00:00:00:01 priority=32768 actions=load:0x1->NXM_NX_REG0[0..15]
resubmit(,3)
3. priority 50
resubmit(,10)
10. No match.
drop
resubmit(,4)
4. reg0=0, priority 50
output:1
>> skipping output to input port

Final flow: unchanged
Megaflow: recirc_id=0,eth,in_port=1,vlan_tci=0x0014/0x1fff,dl_src=50:00:00:00:00:01,dl_dst=00:00:00:00:00:00,dl_type=0x0000
Datapath actions: drop

# ovs-appctl ofproto/trace br0 \
> in_port=2,dl_src=50:00:00:00:00:01 -generate
Flow: in_port=2,vlan_tci=0x0000,dl_src=50:00:00:00:00:01,dl_dst=00:00:00:00:00:00,dl_type=0x0000

bridge("br0")
-------------
0. priority 0
resubmit(,1)
1. in_port=2,vlan_tci=0x0000, priority 99
mod_vlan_vid:20
resubmit(,2)
2. priority 32768
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])
-> table=10 vlan_tci=0x0014/0x0fff,dl_dst=50:00:00:00:00:01 priority=32768 actions=load:0x2->NXM_NX_REG0[0..15]
resubmit(,3)
3. priority 50
resubmit(,10)
10. No match.
drop
resubmit(,4)
4. reg0=0,dl_vlan=20, priority 99
output:1
strip_vlan
output:2
>> skipping output to input port

Final flow: unchanged
Megaflow: recirc_id=0,eth,in_port=2,vlan_tci=0x0000,dl_src=50:00:00:00:00:01,dl_dst=00:00:00:00:00:00,dl_type=0x0000
Datapath actions: push_vlan(vid=20,pcp=0),1

Testing Table 3

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# ovs-appctl ofproto/trace br0 \
> in_port=1,dl_vlan=20,dl_src=f0:00:00:00:00:01,dl_dst=90:00:00:00:00:01 \
> -generate
Flow: in_port=1,dl_vlan=20,dl_vlan_pcp=0,vlan_tci1=0x0000,dl_src=f0:00:00:00:00:01,dl_dst=90:00:00:00:00:01,dl_type=0x0000

bridge("br0")
-------------
0. priority 0
resubmit(,1)
1. in_port=1, priority 99
resubmit(,2)
2. priority 32768
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])
-> table=10 vlan_tci=0x0014/0x0fff,dl_dst=f0:00:00:00:00:01 priority=32768 actions=load:0x1->NXM_NX_REG0[0..15]
resubmit(,3)
3. priority 50
resubmit(,10)
10. No match.
drop
resubmit(,4)
4. reg0=0,dl_vlan=20, priority 99
output:1
>> skipping output to input port
strip_vlan
output:2

Final flow: in_port=1,vlan_tci=0x0000,dl_src=f0:00:00:00:00:01,dl_dst=90:00:00:00:00:01,dl_type=0x0000
Megaflow: recirc_id=0,eth,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
Datapath actions: pop_vlan,2

# ovs-appctl ofproto/trace br0 \
> in_port=2,dl_src=90:00:00:00:00:01,dl_dst=f0:00:00:00:00:01 -generate
Flow: 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

bridge("br0")
-------------
0. priority 0
resubmit(,1)
1. in_port=2,vlan_tci=0x0000, priority 99
mod_vlan_vid:20
resubmit(,2)
2. priority 32768
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])
-> table=10 vlan_tci=0x0014/0x0fff,dl_dst=90:00:00:00:00:01 priority=32768 actions=load:0x2->NXM_NX_REG0[0..15]
resubmit(,3)
3. priority 50
resubmit(,10)
10. vlan_tci=0x0014/0x0fff,dl_dst=f0:00:00:00:00:01, priority 32768
load:0x1->NXM_NX_REG0[0..15]
resubmit(,4)
4. reg0=0x1, priority 32768
output:1

Final flow: reg0=0x1,in_port=2,dl_vlan=20,dl_vlan_pcp=0,vlan_tci1=0x0000,dl_src=90:00:00:00:00:01,dl_dst=f0:00:00:00:00:01,dl_type=0x0000
Megaflow: recirc_id=0,eth,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
Datapath actions: push_vlan(vid=20,pcp=0),1

# ovs-appctl ofproto/trace br0 \
> in_port=1,dl_vlan=20,dl_src=f0:00:00:00:00:01,dl_dst=90:00:00:00:00:01 \
> -generate
Flow: in_port=1,dl_vlan=20,dl_vlan_pcp=0,vlan_tci1=0x0000,dl_src=f0:00:00:00:00:01,dl_dst=90:00:00:00:00:01,dl_type=0x0000

bridge("br0")
-------------
0. priority 0
resubmit(,1)
1. in_port=1, priority 99
resubmit(,2)
2. priority 32768
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])
-> table=10 vlan_tci=0x0014/0x0fff,dl_dst=f0:00:00:00:00:01 priority=32768 actions=load:0x1->NXM_NX_REG0[0..15]
resubmit(,3)
3. priority 50
resubmit(,10)
10. vlan_tci=0x0014/0x0fff,dl_dst=90:00:00:00:00:01, priority 32768
load:0x2->NXM_NX_REG0[0..15]
resubmit(,4)
4. reg0=0x2, priority 32768
strip_vlan
output:2

Final flow: reg0=0x2,in_port=1,vlan_tci=0x0000,dl_src=f0:00:00:00:00:01,dl_dst=90:00:00:00:00:01,dl_type=0x0000
Megaflow: recirc_id=0,eth,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
Datapath actions: pop_vlan,2

Testing Table 4

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
# ovs-appctl ofproto/trace br0 \
> in_port=1,dl_dst=ff:ff:ff:ff:ff:ff,dl_vlan=30
Flow: in_port=1,dl_vlan=30,dl_vlan_pcp=0,vlan_tci1=0x0000,dl_src=00:00:00:00:00:00,dl_dst=ff:ff:ff:ff:ff:ff,dl_type=0x0000

bridge("br0")
-------------
0. priority 0
resubmit(,1)
1. in_port=1, priority 99
resubmit(,2)
2. priority 32768
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])
>> suppressing side effects, so learn action ignored
resubmit(,3)
3. dl_dst=01:00:00:00:00:00/01:00:00:00:00:00, priority 99
resubmit(,4)
4. reg0=0,dl_vlan=30, priority 99
output:1
>> skipping output to input port
strip_vlan
output:3
output:4

Final flow: 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
Megaflow: recirc_id=0,eth,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
Datapath actions: pop_vlan,3,4

# ovs-appctl ofproto/trace br0 in_port=3,dl_dst=ff:ff:ff:ff:ff:ff
Flow: 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

bridge("br0")
-------------
0. priority 0
resubmit(,1)
1. in_port=3,vlan_tci=0x0000, priority 99
mod_vlan_vid:30
resubmit(,2)
2. priority 32768
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])
>> suppressing side effects, so learn action ignored
resubmit(,3)
3. dl_dst=01:00:00:00:00:00/01:00:00:00:00:00, priority 99
resubmit(,4)
4. reg0=0,dl_vlan=30, priority 99
output:1
strip_vlan
output:3
>> skipping output to input port
output:4

Final flow: unchanged
Megaflow: recirc_id=0,eth,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
Datapath actions: push_vlan(vid=30,pcp=0),1,pop_vlan,4

# ovs-appctl ofproto/trace br0 \
> in_port=1,dl_dst=ff:ff:ff:ff:ff:ff
Flow: 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

bridge("br0")
-------------
0. priority 0
resubmit(,1)
1. in_port=1, priority 99
resubmit(,2)
2. priority 32768
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])
>> suppressing side effects, so learn action ignored
resubmit(,3)
3. dl_dst=01:00:00:00:00:00/01:00:00:00:00:00, priority 99
resubmit(,4)
4. reg0=0, priority 50
output:1
>> skipping output to input port

Final flow: unchanged
Megaflow: recirc_id=0,eth,in_port=1,vlan_tci=0x0000/0x1fff,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
Datapath actions: drop

# ovs-appctl ofproto/trace br0 \
> in_port=1,dl_dst=ff:ff:ff:ff:ff:ff,dl_vlan=55
Flow: in_port=1,dl_vlan=55,dl_vlan_pcp=0,vlan_tci1=0x0000,dl_src=00:00:00:00:00:00,dl_dst=ff:ff:ff:ff:ff:ff,dl_type=0x0000

bridge("br0")
-------------
0. priority 0
resubmit(,1)
1. in_port=1, priority 99
resubmit(,2)
2. priority 32768
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])
>> suppressing side effects, so learn action ignored
resubmit(,3)
3. dl_dst=01:00:00:00:00:00/01:00:00:00:00:00, priority 99
resubmit(,4)
4. reg0=0, priority 50
output:1
>> skipping output to input port

Final flow: unchanged
Megaflow: recirc_id=0,eth,in_port=1,dl_vlan=55,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
Datapath actions: drop

# ovs-appctl ofproto/trace br0 \
> in_port=1,dl_dst=ff:ff:ff:ff:ff:ff,dl_vlan=20
Flow: in_port=1,dl_vlan=20,dl_vlan_pcp=0,vlan_tci1=0x0000,dl_src=00:00:00:00:00:00,dl_dst=ff:ff:ff:ff:ff:ff,dl_type=0x0000

bridge("br0")
-------------
0. priority 0
resubmit(,1)
1. in_port=1, priority 99
resubmit(,2)
2. priority 32768
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])
>> suppressing side effects, so learn action ignored
resubmit(,3)
3. dl_dst=01:00:00:00:00:00/01:00:00:00:00:00, priority 99
resubmit(,4)
4. reg0=0,dl_vlan=20, priority 99
output:1
>> skipping output to input port
strip_vlan
output:2

Final flow: 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
Megaflow: recirc_id=0,eth,in_port=1,dl_vlan=20,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
Datapath actions: pop_vlan,2

# ovs-appctl ofproto/trace br0 \
> in_port=2,dl_dst=ff:ff:ff:ff:ff:ff
Flow: in_port=2,vlan_tci=0x0000,dl_src=00:00:00:00:00:00,dl_dst=ff:ff:ff:ff:ff:ff,dl_type=0x0000

bridge("br0")
-------------
0. priority 0
resubmit(,1)
1. in_port=2,vlan_tci=0x0000, priority 99
mod_vlan_vid:20
resubmit(,2)
2. priority 32768
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])
>> suppressing side effects, so learn action ignored
resubmit(,3)
3. dl_dst=01:00:00:00:00:00/01:00:00:00:00:00, priority 99
resubmit(,4)
4. reg0=0,dl_vlan=20, priority 99
output:1
strip_vlan
output:2
>> skipping output to input port

Final flow: unchanged
Megaflow: recirc_id=0,eth,in_port=2,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
Datapath actions: push_vlan(vid=20,pcp=0),1

# ovs-appctl ofproto/trace br0 \
> in_port=4,dl_dst=ff:ff:ff:ff:ff:ff
Flow: in_port=4,vlan_tci=0x0000,dl_src=00:00:00:00:00:00,dl_dst=ff:ff:ff:ff:ff:ff,dl_type=0x0000

bridge("br0")
-------------
0. priority 0
resubmit(,1)
1. in_port=4,vlan_tci=0x0000, priority 99
mod_vlan_vid:30
resubmit(,2)
2. priority 32768
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])
>> suppressing side effects, so learn action ignored
resubmit(,3)
3. dl_dst=01:00:00:00:00:00/01:00:00:00:00:00, priority 99
resubmit(,4)
4. reg0=0,dl_vlan=30, priority 99
output:1
strip_vlan
output:3
output:4
>> skipping output to input port

Final flow: unchanged
Megaflow: recirc_id=0,eth,in_port=4,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
Datapath actions: push_vlan(vid=30,pcp=0),1,pop_vlan,3

# ovs-appctl ofproto/trace br0 \
> in_port=4,dl_dst=01:00:00:00:00:00
Flow: in_port=4,vlan_tci=0x0000,dl_src=00:00:00:00:00:00,dl_dst=01:00:00:00:00:00,dl_type=0x0000

bridge("br0")
-------------
0. priority 0
resubmit(,1)
1. in_port=4,vlan_tci=0x0000, priority 99
mod_vlan_vid:30
resubmit(,2)
2. priority 32768
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])
>> suppressing side effects, so learn action ignored
resubmit(,3)
3. dl_dst=01:00:00:00:00:00/01:00:00:00:00:00, priority 99
resubmit(,4)
4. reg0=0,dl_vlan=30, priority 99
output:1
strip_vlan
output:3
output:4
>> skipping output to input port

Final flow: unchanged
Megaflow: recirc_id=0,eth,in_port=4,vlan_tci=0x0000,dl_src=00:00:00:00:00:00,dl_dst=01:00:00:00:00:00/ff:ff:ff:ff:ff:f0,dl_type=0x0000
Datapath actions: push_vlan(vid=30,pcp=0),1,pop_vlan,3

# ovs-appctl ofproto/trace br0 \
> in_port=1,dl_dst=90:12:34:56:78:90,dl_vlan=20
Flow: in_port=1,dl_vlan=20,dl_vlan_pcp=0,vlan_tci1=0x0000,dl_src=00:00:00:00:00:00,dl_dst=90:12:34:56:78:90,dl_type=0x0000

bridge("br0")
-------------
0. priority 0
resubmit(,1)
1. in_port=1, priority 99
resubmit(,2)
2. priority 32768
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])
>> suppressing side effects, so learn action ignored
resubmit(,3)
3. priority 50
resubmit(,10)
10. No match.
drop
resubmit(,4)
4. reg0=0,dl_vlan=20, priority 99
output:1
>> skipping output to input port
strip_vlan
output:2

Final flow: in_port=1,vlan_tci=0x0000,dl_src=00:00:00:00:00:00,dl_dst=90:12:34:56:78:90,dl_type=0x0000
Megaflow: recirc_id=0,eth,in_port=1,dl_vlan=20,dl_vlan_pcp=0,dl_src=00:00:00:00:00:00,dl_dst=90:12:34:56:78:90,dl_type=0x0000
Datapath actions: pop_vlan,2

# ovs-appctl ofproto/trace br0 \
> in_port=1,dl_dst=90:12:34:56:78:90,dl_vlan=30
Flow: in_port=1,dl_vlan=30,dl_vlan_pcp=0,vlan_tci1=0x0000,dl_src=00:00:00:00:00:00,dl_dst=90:12:34:56:78:90,dl_type=0x0000

bridge("br0")
-------------
0. priority 0
resubmit(,1)
1. in_port=1, priority 99
resubmit(,2)
2. priority 32768
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])
>> suppressing side effects, so learn action ignored
resubmit(,3)
3. priority 50
resubmit(,10)
10. No match.
drop
resubmit(,4)
4. reg0=0,dl_vlan=30, priority 99
output:1
>> skipping output to input port
strip_vlan
output:3
output:4

Final flow: in_port=1,vlan_tci=0x0000,dl_src=00:00:00:00:00:00,dl_dst=90:12:34:56:78:90,dl_type=0x0000
Megaflow: recirc_id=0,eth,in_port=1,dl_vlan=30,dl_vlan_pcp=0,dl_src=00:00:00:00:00:00,dl_dst=90:12:34:56:78:90,dl_type=0x0000
Datapath actions: pop_vlan,3,4

# ovs-appctl ofproto/trace br0 \
> in_port=1,dl_vlan=30,dl_src=10:00:00:00:00:01,dl_dst=20:00:00:00:00:01 \
> -generate
Flow: in_port=1,dl_vlan=30,dl_vlan_pcp=0,vlan_tci1=0x0000,dl_src=10:00:00:00:00:01,dl_dst=20:00:00:00:00:01,dl_type=0x0000

bridge("br0")
-------------
0. priority 0
resubmit(,1)
1. in_port=1, priority 99
resubmit(,2)
2. priority 32768
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])
-> table=10 vlan_tci=0x001e/0x0fff,dl_dst=10:00:00:00:00:01 priority=32768 actions=load:0x1->NXM_NX_REG0[0..15]
resubmit(,3)
3. priority 50
resubmit(,10)
10. No match.
drop
resubmit(,4)
4. reg0=0,dl_vlan=30, priority 99
output:1
>> skipping output to input port
strip_vlan
output:3
output:4

Final flow: 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
Megaflow: recirc_id=0,eth,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
Datapath actions: pop_vlan,3,4

# ovs-appctl ofproto/trace br0 \
> in_port=4,dl_src=20:00:00:00:00:01,dl_dst=10:00:00:00:00:01 -generate
Flow: 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

bridge("br0")
-------------
0. priority 0
resubmit(,1)
1. in_port=4,vlan_tci=0x0000, priority 99
mod_vlan_vid:30
resubmit(,2)
2. priority 32768
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])
-> table=10 vlan_tci=0x001e/0x0fff,dl_dst=20:00:00:00:00:01 priority=32768 actions=load:0x4->NXM_NX_REG0[0..15]
resubmit(,3)
3. priority 50
resubmit(,10)
10. vlan_tci=0x001e/0x0fff,dl_dst=10:00:00:00:00:01, priority 32768
load:0x1->NXM_NX_REG0[0..15]
resubmit(,4)
4. reg0=0x1, priority 32768
output:1

Final flow: reg0=0x1,in_port=4,dl_vlan=30,dl_vlan_pcp=0,vlan_tci1=0x0000,dl_src=20:00:00:00:00:01,dl_dst=10:00:00:00:00:01,dl_type=0x0000
Megaflow: recirc_id=0,eth,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
Datapath actions: push_vlan(vid=30,pcp=0),1

# ovs-appctl ofproto/trace br0 \
> in_port=1,dl_vlan=30,dl_src=10:00:00:00:00:01,dl_dst=20:00:00:00:00:01 \
> -generate
Flow: in_port=1,dl_vlan=30,dl_vlan_pcp=0,vlan_tci1=0x0000,dl_src=10:00:00:00:00:01,dl_dst=20:00:00:00:00:01,dl_type=0x0000

bridge("br0")
-------------
0. priority 0
resubmit(,1)
1. in_port=1, priority 99
resubmit(,2)
2. priority 32768
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])
-> table=10 vlan_tci=0x001e/0x0fff,dl_dst=10:00:00:00:00:01 priority=32768 actions=load:0x1->NXM_NX_REG0[0..15]
resubmit(,3)
3. priority 50
resubmit(,10)
10. vlan_tci=0x001e/0x0fff,dl_dst=20:00:00:00:00:01, priority 32768
load:0x4->NXM_NX_REG0[0..15]
resubmit(,4)
4. reg0=0x4, priority 32768
strip_vlan
output:4

Final flow: reg0=0x4,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
Megaflow: recirc_id=0,eth,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
Datapath actions: pop_vlan,4

The learning tables: table 10

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# ovs-ofctl dump-flows br0
cookie=0x0, duration=5216.779s, table=0, n_packets=0, n_bytes=0, dl_src=01:00:00:00:00:00/01:00:00:00:00:00 actions=drop
cookie=0x0, duration=5206.049s, table=0, n_packets=0, n_bytes=0, dl_dst=01:80:c2:00:00:00/ff:ff:ff:ff:ff:f0 actions=drop
cookie=0x0, duration=5196.394s, table=0, n_packets=0, n_bytes=0, priority=0 actions=resubmit(,1)
cookie=0x0, duration=5132.916s, table=1, n_packets=0, n_bytes=0, priority=99,in_port=p1 actions=resubmit(,2)
cookie=0x0, duration=4889.197s, table=1, n_packets=0, n_bytes=0, priority=99,in_port=p2,vlan_tci=0x0000 actions=mod_vlan_vid:20,resubmit(,2)
cookie=0x0, duration=4889.121s, table=1, n_packets=0, n_bytes=0, priority=99,in_port=p3,vlan_tci=0x0000 actions=mod_vlan_vid:30,resubmit(,2)
cookie=0x0, duration=4889.121s, table=1, n_packets=0, n_bytes=0, priority=99,in_port=p4,vlan_tci=0x0000 actions=mod_vlan_vid:30,resubmit(,2)
cookie=0x0, duration=5149.526s, table=1, n_packets=0, n_bytes=0, priority=0 actions=drop
cookie=0x0, duration=4742.616s, table=2, n_packets=0, n_bytes=0, actions=learn(table=10,NXM_OF_VLAN_TCI[0..11],NXM_OF_ETH_DST[]=NXM_OF_ETH_SRC[],load:NXM_OF_IN_PORT[]->NXM_NX_REG0[0..15]),resubmit(,3)
cookie=0x0, duration=4705.289s, table=3, n_packets=0, n_bytes=0, priority=99,dl_dst=01:00:00:00:00:00/01:00:00:00:00:00 actions=resubmit(,4)
cookie=0x0, duration=4609.060s, table=3, n_packets=0, n_bytes=0, priority=50 actions=resubmit(,10),resubmit(,4)
cookie=0x0, duration=4572.579s, table=4, n_packets=0, n_bytes=0, reg0=0x1 actions=output:p1
cookie=0x0, duration=2594.644s, table=4, n_packets=0, n_bytes=0, reg0=0x2 actions=strip_vlan,output:p2
cookie=0x0, duration=2594.643s, table=4, n_packets=0, n_bytes=0, reg0=0x3 actions=strip_vlan,output:p3
cookie=0x0, duration=2594.643s, table=4, n_packets=0, n_bytes=0, reg0=0x4 actions=strip_vlan,output:p4
cookie=0x0, duration=2575.640s, table=4, n_packets=0, n_bytes=0, priority=50,reg0=0 actions=output:p1
cookie=0x0, duration=2575.640s, table=4, n_packets=0, n_bytes=0, priority=99,reg0=0,dl_vlan=20 actions=output:p1,strip_vlan,output:p2
cookie=0x0, duration=2575.640s, table=4, n_packets=0, n_bytes=0, priority=99,reg0=0,dl_vlan=30 actions=output:p1,strip_vlan,output:p3,output:p4
cookie=0x0, duration=602.623s, table=10, n_packets=0, n_bytes=0, vlan_tci=0x0014/0x0fff,dl_dst=50:00:00:00:00:01 actions=load:0x2->NXM_NX_REG0[0..15]
cookie=0x0, duration=537.283s, table=10, n_packets=0, n_bytes=0, vlan_tci=0x0014/0x0fff,dl_dst=f0:00:00:00:00:01 actions=load:0x1->NXM_NX_REG0[0..15]
cookie=0x0, duration=494.330s, table=10, n_packets=0, n_bytes=0, vlan_tci=0x0014/0x0fff,dl_dst=90:00:00:00:00:01 actions=load:0x2->NXM_NX_REG0[0..15]
cookie=0x0, duration=134.061s, table=10, n_packets=0, n_bytes=0, vlan_tci=0x001e/0x0fff,dl_dst=10:00:00:00:00:01 actions=load:0x1->NXM_NX_REG0[0..15]
cookie=0x0, duration=101.484s, table=10, n_packets=0, n_bytes=0, vlan_tci=0x001e/0x0fff,dl_dst=20:00:00:00:00:01 actions=load:0x4->NXM_NX_REG0[0..15]

Reference

Open vSwitch on Linux
Open vSwitch Advanced Features