netfilter: flowtable: add nf_flow_offload_tuple() helper
Consolidate code to configure the flow_cls_offload structure into one helper function. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
This commit is contained in:
parent
28b3a4270c
commit
ae29045018
@ -592,23 +592,25 @@ static void nf_flow_offload_init(struct flow_cls_offload *cls_flow,
|
|||||||
cls_flow->cookie = (unsigned long)tuple;
|
cls_flow->cookie = (unsigned long)tuple;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int flow_offload_tuple_add(struct flow_offload_work *offload,
|
static int nf_flow_offload_tuple(struct nf_flowtable *flowtable,
|
||||||
struct nf_flow_rule *flow_rule,
|
struct flow_offload *flow,
|
||||||
enum flow_offload_tuple_dir dir)
|
struct nf_flow_rule *flow_rule,
|
||||||
|
enum flow_offload_tuple_dir dir,
|
||||||
|
int priority, int cmd,
|
||||||
|
struct list_head *block_cb_list)
|
||||||
{
|
{
|
||||||
struct nf_flowtable *flowtable = offload->flowtable;
|
|
||||||
struct flow_cls_offload cls_flow = {};
|
struct flow_cls_offload cls_flow = {};
|
||||||
struct flow_block_cb *block_cb;
|
struct flow_block_cb *block_cb;
|
||||||
struct netlink_ext_ack extack;
|
struct netlink_ext_ack extack;
|
||||||
__be16 proto = ETH_P_ALL;
|
__be16 proto = ETH_P_ALL;
|
||||||
int err, i = 0;
|
int err, i = 0;
|
||||||
|
|
||||||
nf_flow_offload_init(&cls_flow, proto, offload->priority,
|
nf_flow_offload_init(&cls_flow, proto, priority, cmd,
|
||||||
FLOW_CLS_REPLACE,
|
&flow->tuplehash[dir].tuple, &extack);
|
||||||
&offload->flow->tuplehash[dir].tuple, &extack);
|
if (cmd == FLOW_CLS_REPLACE)
|
||||||
cls_flow.rule = flow_rule->rule;
|
cls_flow.rule = flow_rule->rule;
|
||||||
|
|
||||||
list_for_each_entry(block_cb, &flowtable->flow_block.cb_list, list) {
|
list_for_each_entry(block_cb, block_cb_list, list) {
|
||||||
err = block_cb->cb(TC_SETUP_CLSFLOWER, &cls_flow,
|
err = block_cb->cb(TC_SETUP_CLSFLOWER, &cls_flow,
|
||||||
block_cb->cb_priv);
|
block_cb->cb_priv);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
@ -620,23 +622,22 @@ static int flow_offload_tuple_add(struct flow_offload_work *offload,
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int flow_offload_tuple_add(struct flow_offload_work *offload,
|
||||||
|
struct nf_flow_rule *flow_rule,
|
||||||
|
enum flow_offload_tuple_dir dir)
|
||||||
|
{
|
||||||
|
return nf_flow_offload_tuple(offload->flowtable, offload->flow,
|
||||||
|
flow_rule, dir, offload->priority,
|
||||||
|
FLOW_CLS_REPLACE,
|
||||||
|
&offload->flowtable->flow_block.cb_list);
|
||||||
|
}
|
||||||
|
|
||||||
static void flow_offload_tuple_del(struct flow_offload_work *offload,
|
static void flow_offload_tuple_del(struct flow_offload_work *offload,
|
||||||
enum flow_offload_tuple_dir dir)
|
enum flow_offload_tuple_dir dir)
|
||||||
{
|
{
|
||||||
struct nf_flowtable *flowtable = offload->flowtable;
|
nf_flow_offload_tuple(offload->flowtable, offload->flow, NULL, dir,
|
||||||
struct flow_cls_offload cls_flow = {};
|
offload->priority, FLOW_CLS_DESTROY,
|
||||||
struct flow_block_cb *block_cb;
|
&offload->flowtable->flow_block.cb_list);
|
||||||
struct netlink_ext_ack extack;
|
|
||||||
__be16 proto = ETH_P_ALL;
|
|
||||||
|
|
||||||
nf_flow_offload_init(&cls_flow, proto, offload->priority,
|
|
||||||
FLOW_CLS_DESTROY,
|
|
||||||
&offload->flow->tuplehash[dir].tuple, &extack);
|
|
||||||
|
|
||||||
list_for_each_entry(block_cb, &flowtable->flow_block.cb_list, list)
|
|
||||||
block_cb->cb(TC_SETUP_CLSFLOWER, &cls_flow, block_cb->cb_priv);
|
|
||||||
|
|
||||||
set_bit(NF_FLOW_HW_DEAD, &offload->flow->flags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int flow_offload_rule_add(struct flow_offload_work *offload,
|
static int flow_offload_rule_add(struct flow_offload_work *offload,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user