MPLS: 32位header,其中20位可做label,可堆叠
QinQ: VLAN header堆叠
# 第一步:允许QinQ
ovs-vsctl set Open_vSwitch . other_config:vlan-limit=2
######### $s1 - classifier:
sudo ovs-ofctl -O OpenFlow13 add-flow $s1 "table=0,in_port=$ein1,actions=goto_table:1"
# sudo ovs-ofctl -O OpenFlow13 add-flow $s1 "table=1,actions=output:$e12"
sudo ovs-ofctl -O OpenFlow13 add-flow $s1 "table=1,eth_type=0x806,actions=push_vlan:0x8100,set_field:0x1010->vlan_vid,output:$e12"
######### $s2 - forwarder:
sudo ovs-ofctl -O OpenFlow13 add-flow $s2 "table=0,actions=push_mpls:0x8847,set_field:11->mpls_label,push_mpls:0x8847,set_field:22->mpls_label,output:$e23"
sudo ovs-ofctl -O OpenFlow13 add-flow $s2 "table=0,actions=goto_table:1"
# table 1: 写metadata
sudo ovs-ofctl -O OpenFlow13 add-flow $s2 "table=1,vlan_vid=0x1000/0x1000,actions=set_field:0x1000000000000000->metadata,move:eth_type->OXM_OF_METADATA[0..15],move:vlan_vid->OXM_OF_METADATA[31..42],pop_vlan,goto_table:2"
sudo ovs-ofctl -O OpenFlow13 add-flow $s2 "table=1,actions=set_field:0->metadata,move:eth_type->OXM_OF_METADATA[0..15],goto_table:2"
# table 2: 处理eth_type
sudo ovs-ofctl -O OpenFlow13 add-flow $s2 "table=2,actions=push_mpls:0x8847,move:OXM_OF_METADATA[0..19]->mpls_label,goto_table:3"
# table 3: 处理VLAN
sudo ovs-ofctl -O OpenFlow13 add-flow $s2 "table=3,metadata=0x1000000000000000/0x1000000000000000,actions=push_mpls:0x8847,move:OXM_OF_METADATA[31..50]->mpls_label,goto_table:4"
sudo ovs-ofctl -O OpenFlow13 add-flow $s2 "table=3,actions=goto_table:4"
# table 4: 加SFC header
sudo ovs-ofctl -O OpenFlow13 add-flow $s2 "table=4,actions=push_mpls:0x8847,set_field:0x0101->mpls_label,output:$e23"