Matching GRE Checksum/Key/Sequence
GRE optional fields (checksum, key and sequence) can be matched now using the new gre_option
item. The new item requires a GRE item such as gre_key
, and its pattern must correspond with the c_bit/k_bit/s_bit
in the GRE pattern.
To match on checksum field with value 0x11 to queue 1:
testpmd> flow create 0
ingress pattern eth / ipv4 / gre c_bit is 1
/ gre_option checksum is 0x11
/ end actions queue index 1
/ end
To encap packets with GRE header:
testpmd> set raw_decap 1
eth / end_set
testpmd> set raw_encap 1
eth src is FA:16
:3E:01
:02
:43
dst is FA:16
:3E:01
:01
:42
/ ipv4 src is 10.10
.10.10
dst is 20.20
.20.20
/ gre c_bit is 1
/ gre_option checksum is 300
/ end_set
testpmd> flow create 1
group 0
ingress transfer pattern eth / ipv4 src is 1.1
.1.1
/ port_id id is 1
/ end actions raw_decap index 1
/ raw_encap index 1
/ port_id id 0
/ end
To decap GRE header:
testpmd> set raw_decap 0
eth / ipv4 / gre / gre_option / end_set
testpmd> set raw_encap 0
eth src is 10
:22
:33
:44
:55
:60
dst is a0:bb:cc:dd:ee:f2 testpmd> type is 0x0800
/ end_set
testpmd> flow create 0
ingress group 0
transfer pattern eth / ipv4 / gre c_bit is 1
/ gre_option checksum is 300
/ ipv4 src is 1.1
.1.1
/ end actions raw_decap index 0
/ raw_encap index 0
/ port_id id 1
/ end
struct rte_flow_attr attr;
struct rte_flow_error error;
struct rte_flow_item pattern[MAX_PATTERN_NUM];
struct rte_flow_action action[MAX_ACTION_NUM];
struct rte_flow_action_queue queue = { .index = 1
};
memset(&attr, 0
, sizeof(struct rte_flow_attr));
attr.ingress = 1
;
attr.group = 1
;
attr.priority = 1
;
struct rte_flow_item_gre gre_spec = {
.c_rsvd0_ver = RTE_BE16(0x8000
),
};
struct rte_flow_item_gre_opt gre_opt_spec = {
. checksum_rsvd = {
.checksum = RTE_BE16(0x11
),
}
};
pattern[0
].type = RTE_FLOW_ITEM_TYPE_ETH;
pattern[1
].type = RTE_FLOW_ITEM_TYPE_IPV4;
pattern[2
].type = RTE_FLOW_ITEM_TYPE_GRE;
pattern[2
].spec = &gre_spec;
pattern[3
].type = RTE_FLOW_ITEM_TYPE_GRE_OPTION;
pattern[3
].spec = &gre_opt_spec;
pattern[4
].type = RTE_FLOW_ITEM_TYPE_END;
action[0
].type = RTE_FLOW_ACTION_TYPE_QUEUE;
action[0
].conf = &queue;
action[1
].type = RTE_FLOW_ACTION_TYPE_END;
res = rte_flow_validate(port_id, &attr, pattern, action, &error);
if
(!res)
flow = rte_flow_create(port_id, &attr, pattern, action, &error);
return
flow;