From: wenxu <wenxu@xxxxxxxxx> Add nft_tunnel_obj offload for both encap and decap actions Signed-off-by: wenxu <wenxu@xxxxxxxxx> --- v6: no change net/netfilter/nft_tunnel.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/net/netfilter/nft_tunnel.c b/net/netfilter/nft_tunnel.c index aa3dc52..b47838d 100644 --- a/net/netfilter/nft_tunnel.c +++ b/net/netfilter/nft_tunnel.c @@ -669,6 +669,25 @@ static void nft_tunnel_obj_destroy(const struct nft_ctx *ctx, metadata_dst_free(priv->md); } +static int nft_tunnel_obj_offload(struct nft_offload_ctx *ctx, + struct nft_flow_rule *flow, + struct nft_object *obj) +{ + struct nft_tunnel_obj *priv = nft_obj_data(obj); + struct flow_action_entry *entry; + + entry = &flow->rule->action.entries[ctx->num_actions++]; + + if (!priv->tunnel_key_release) { + entry->id = FLOW_ACTION_TUNNEL_ENCAP; + entry->tunnel = &priv->md->u.tun_info; + } else { + entry->id = FLOW_ACTION_TUNNEL_DECAP; + } + + return 0; +} + static struct nft_object_type nft_tunnel_obj_type; static const struct nft_object_ops nft_tunnel_obj_ops = { .type = &nft_tunnel_obj_type, @@ -677,6 +696,7 @@ static void nft_tunnel_obj_destroy(const struct nft_ctx *ctx, .init = nft_tunnel_obj_init, .destroy = nft_tunnel_obj_destroy, .dump = nft_tunnel_obj_dump, + .offload = nft_tunnel_obj_offload, }; static struct nft_object_type nft_tunnel_obj_type __read_mostly = { -- 1.8.3.1