OSDN Git Service

netfilter: flowtable: add vlan pop action offload support
authorwenxu <wenxu@ucloud.cn>
Sat, 3 Apr 2021 13:59:43 +0000 (21:59 +0800)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 13 Apr 2021 11:09:41 +0000 (13:09 +0200)
This patch adds vlan pop action offload in the flowtable offload.

Signed-off-by: wenxu <wenxu@ucloud.cn>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nf_flow_table_offload.c

index dc1d6b4..b87f8c3 100644 (file)
@@ -619,6 +619,7 @@ nf_flow_rule_route_common(struct net *net, const struct flow_offload *flow,
                          struct nf_flow_rule *flow_rule)
 {
        const struct flow_offload_tuple *other_tuple;
+       const struct flow_offload_tuple *tuple;
        int i;
 
        flow_offload_decap_tunnel(flow, dir, flow_rule);
@@ -628,6 +629,20 @@ nf_flow_rule_route_common(struct net *net, const struct flow_offload *flow,
            flow_offload_eth_dst(net, flow, dir, flow_rule) < 0)
                return -1;
 
+       tuple = &flow->tuplehash[dir].tuple;
+
+       for (i = 0; i < tuple->encap_num; i++) {
+               struct flow_action_entry *entry;
+
+               if (tuple->in_vlan_ingress & BIT(i))
+                       continue;
+
+               if (tuple->encap[i].proto == htons(ETH_P_8021Q)) {
+                       entry = flow_action_entry_next(flow_rule);
+                       entry->id = FLOW_ACTION_VLAN_POP;
+               }
+       }
+
        other_tuple = &flow->tuplehash[!dir].tuple;
 
        for (i = 0; i < other_tuple->encap_num; i++) {