netfilter: nft_objref: add nft_objref_type offload
Subsystems (2)
PATCH v2 10/11 netfilter: nft_objref: add nft_objref_type offload
From: wenxu <[email protected]>
support offload for nft_objref_type
Signed-off-by wenxu <[email protected]>
--- include/net/netfilter/nf_tables.h | 3 +++ net/netfilter/nft_objref.c | 15 +++++++++++++++ 2 files changed, 18 insertions(+)
include/net/netfilter/nf_tables.h +3 -0
@@ -1122,6 +1122,9 @@ struct nft_object_ops {int (*dump)(struct sk_buff *skb,struct nft_object *obj,bool reset); +int (*offload)(struct nft_offload_ctx *ctx, +struct nft_flow_rule *flow, +struct nft_object *obj);const struct nft_object_type *type; };
net/netfilter/nft_objref.c +15 -0
@@ -10,6 +10,7 @@#include <linux/netfilter.h> #include <linux/netfilter/nf_tables.h> #include <net/netfilter/nf_tables.h> +#include <net/netfilter/nf_tables_offload.h> #define nft_objref_priv (expr) *((struct nft_object **)nft_expr_priv(expr))
@@ -82,6 +83,18 @@ static void nft_objref_activate(const struct nft_ctx *ctx, obj->use++; } +static int nft_objref_offload (struct nft_offload_ctx *ctx, +struct nft_flow_rule *flow, +const struct nft_expr *expr) +{ +struct nft_object *obj =nft_objref_priv (expr); + +if (obj->ops->offload) +return obj->ops->offload (ctx, flow, obj); +else +return -EOPNOTSUPP ; +} +static struct nft_expr_type nft_objref_type;static const struct nft_expr_ops nft_objref_ops = { .type = &nft_objref_type,
@@ -91,6 +104,8 @@ static void nft_objref_activate(const struct nft_ctx *ctx, .activate = nft_objref_activate, .deactivate = nft_objref_deactivate, .dump = nft_objref_dump, + .offload = nft_objref_offload, + .offload_actions = nft_offload_action, };struct nft_objref_map {
Signature · 1 line
1.8.3.1
PATCH v2 11/11 netfilter: nft_tunnel: support nft_tunnel_obj offload
From: wenxu <[email protected]>
Add nft_tunnel_obj offload for both encap and decap actions
Signed-off-by wenxu <[email protected]>
--- net/netfilter/nft_tunnel.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
net/netfilter/nft_tunnel.c +20 -0
@@ -633,6 +633,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,
@@ -641,6 +660,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 = {
Signature · 1 line
1.8.3.1