-
Notifications
You must be signed in to change notification settings - Fork 192
Dpctl Flow Mod Cases
- Match Fields List
- Instructions List
- Actions List
- [Flow mod Cases] (#Mod)
Flow-mod is the most variable command of dpctl. The number of match fields, instructions and actions, always raise doubts on how to add some specific flow. So this page aims to be a reference for people starting to get used with the wide range of possibilities that flow mod brings.
We will start start with lists of all match fields, instructions and actions, because the first doubt is always: How is that field named?
## Match FieldsField name | Description |
---|---|
in_port | Switch input port |
meta | Metadata passed between tables |
eth_dst | Ethernet destination address |
eth_type | Ethernet source address |
eth_src | Ethernet frame type |
vlan_vid | VLAN id |
vlan_pcp | VLAN priority |
ip_dscp | IP DSCP |
ip_ecn | IP ECN |
ip_proto | IP protocol |
ip_src | IPv4 source address |
ip_dst | IPv4 destination address |
tcp_src | TCP source port |
tcp_dst | TCP destiny port |
udp_src | UDP source port |
udp_dst | UDP destiny port |
sctp_src | SCTP source port |
sctp_dst | SCTP destination port |
icmp_code | ICMP type |
icmp_type | ICMP code |
arp_op | ARP opcode |
arp_spa | ARP source IPv4 address |
arp_tpa | ARP target IPv4 address |
arp_sha | ARP source hardware address |
arp_tha | ARP target hardware address |
ipv6_src | IPv6 source address |
ipv6_dst | IPv6 destination address |
ipv6_flabel | IPv6 Flow Label |
icmpv6_code | ICMPv6 type |
icmpv6_type | ICMPv6 code |
ipv6_nd_target | Target address for ND |
ipv6_nd_sll | Source link-layer for ND |
ipv6_nd_tll | Target link-layer for ND |
mpls_label | MPLS label |
mpls_tc | MPLS TC |
pbb_isid | PBB I-SID |
tunn_id | Logical Port Metadata |
ext_hdr | IPv6 Extension Header pseudo-field |
Field name | Description |
---|---|
goto | Go to the next flow table |
meta | Write on the metadata field |
write | Write actions in the action set |
apply | Applies the action(s) immediately |
clear | Clear the action set |
meter | Apply meter |
Field name | Description |
---|---|
output | Output packet to a port |
ttl_out | Copy TTL from the next to outermost header to the outermost |
ttl_in | Copy TLL from the outermost header to the next to outermost |
mpls_ttl | Set MPLS TTL |
mpls_dec | Decrease MPLS TTL |
push_vlan | Push VLAN tag |
pop_vlan | Pop VLAN tag |
push_pbb | Push PBB I-TAG tag |
pop_pbb | Pop PBB I-TAG tag |
push_mpls | Push MPLS tag |
pop_mpls | Pop MPLS tag |
queue | Set queue id |
group | Apply group entry |
nw_ttl | Set IP TTL |
nw_dec | Decrement IP TTL |
set_field | Set one packet field |
The simplest flow mod is the one which matches all fields. To create this flow just omit the match fields.
dpctl unix:/tmp/ofd flow-mod cmd=add,table=0 apply:output=2
SENDING:
flow_mod{table="0", cmd="add", cookie="0x0", mask="0x0", idle="0", hard="0", prio="32768", buf="none",
port="any", group="any", flags="0x0", match=oxm{all match}, insts=[apply{acts=[out{port="2"}]}]}
OK.
Inport is one of the most common fields to match. In our example we will see how easy is to establish connection between two hosts attached to the ports 1 and 2.
dpctl unix:/tmp/ofd flow-mod cmd=add,table=0 in_port=1 apply:output=2
SENDING:
flow_mod{table="0", cmd="add", cookie="0x0", mask="0x0", idle="0", hard="0", prio="32768", buf="none", port="any", group="any", flags="0x0", match=oxm{in_port="1"}, insts=[apply{acts=[out{port="2"}]}]}
OK.
dpctl unix:/tmp/ofd flow-mod cmd=add,table=0 in_port=2 apply:output=1
SENDING:
flow_mod{table="0", cmd="add", cookie="0x0", mask="0x0", idle="0", hard="0", prio="32768", buf="none", port="any", group="any", flags="0x0", match=oxm{in_port="2"}, insts=[apply{acts=[out{port="1"}]}]}
OK.
After the addition of these flows, packets should be forwarded in both ways. Pretty easy.
#### Ethernet headerThe fields to match in the Ethernet header are the source and destination MAC and the Ethernet type. The Ethernet type is should be a very common field, as it is a pre-requisite for upper layer fields.
In the first example, we will install flows that usually installed by a learning switch application.
dpctl unix:/tmp/ofd flow-mod cmd=add,table=0 in_port=1,eth_dst=00:00:00:00:00:01 apply:output=2
SENDING:
flow_mod{table="0", cmd="add", cookie="0x0", mask="0x0", idle="0", hard="0", prio="32768", buf="none", port="any", group="any", flags="0x0", match=oxm{in_port="1",eth_src=00:00:00:00:00:01, eth_dst="00:00:00:00:00:01"}, insts=[apply{acts=[out{port="2"}]}]}
OK.
dpctl unix:/tmp/ofd flow-mod cmd=add,table=0 in_port=2,eth_dst=00:00:00:00:00:01 apply:output=1
SENDING:
flow_mod{table="0", cmd="add", cookie="0x0", mask="0x0", idle="0", hard="0", prio="32768", buf="none", port="any", group="any", flags="0x0", match=oxm{in_port="2",eth_src=00:00:00:00:00:02, eth_dst="00:00:00:00:00:01"}, insts=[apply{acts=[out{port="1"}]}]}
OK.
In our second example, we will install a flow that will forward only IPv4 packets between two hosts, adding the ethernet type 0x800 to the match fields of our previous example.
dpctl unix:/tmp/ofd flow-mod cmd=add,table=0 in_port=2,eth_type=0x800,eth_src=00:00:00:00:00:02,eth_dst=00:00:00:00:00:01 apply:output=1
SENDING:
flow_mod{table="0", cmd="add", cookie="0x0", mask="0x0", idle="0", hard="0", prio="32768", buf="none", port="any", group="any", flags="0x0", match=oxm{eth_dst="00:00:00:00:00:01", in_port="2", eth_src="00:00:00:00:00:02", eth_type="0x800"}, insts=[apply{acts=[out{port="1"}]}]}
OK.
dpctl unix:/tmp/ofd flow-mod cmd=add,table=0 in_port=1,eth_type=0x800,eth_src=00:00:00:00:00:01,eth_dst=00:00:00:00:00:02 apply:output=2
SENDING:
flow_mod{table="0", cmd="add", cookie="0x0", mask="0x0", idle="0", hard="0", prio="32768", buf="none", port="any", group="any", flags="0x0", match=oxm{eth_dst="00:00:00:00:00:02", in_port="1", eth_src="00:00:00:00:00:01", eth_type="0x800"}, insts=[apply{acts=[out{port="2"}]}]}
OK.
match push pop
output, dec ttl, set ttl
match on label, push, pop, set ttl, dec ttl