net: flow_offload: add flow_block_cb_alloc() and flow_block_cb_free()
Add a new helper function to allocate flow_block_cb objects. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
32f8c4093a
commit
d63db30c85
@ -260,6 +260,20 @@ struct flow_block_offload {
|
||||
struct netlink_ext_ack *extack;
|
||||
};
|
||||
|
||||
struct flow_block_cb {
|
||||
struct list_head list;
|
||||
tc_setup_cb_t *cb;
|
||||
void *cb_ident;
|
||||
void *cb_priv;
|
||||
void (*release)(void *cb_priv);
|
||||
unsigned int refcnt;
|
||||
};
|
||||
|
||||
struct flow_block_cb *flow_block_cb_alloc(struct net *net, tc_setup_cb_t *cb,
|
||||
void *cb_ident, void *cb_priv,
|
||||
void (*release)(void *cb_priv));
|
||||
void flow_block_cb_free(struct flow_block_cb *block_cb);
|
||||
|
||||
int flow_block_cb_setup_simple(struct flow_block_offload *f,
|
||||
struct list_head *driver_list, tc_setup_cb_t *cb,
|
||||
void *cb_ident, void *cb_priv, bool ingress_only);
|
||||
|
@ -166,6 +166,34 @@ void flow_rule_match_enc_opts(const struct flow_rule *rule,
|
||||
}
|
||||
EXPORT_SYMBOL(flow_rule_match_enc_opts);
|
||||
|
||||
struct flow_block_cb *flow_block_cb_alloc(struct net *net, tc_setup_cb_t *cb,
|
||||
void *cb_ident, void *cb_priv,
|
||||
void (*release)(void *cb_priv))
|
||||
{
|
||||
struct flow_block_cb *block_cb;
|
||||
|
||||
block_cb = kzalloc(sizeof(*block_cb), GFP_KERNEL);
|
||||
if (!block_cb)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
block_cb->cb = cb;
|
||||
block_cb->cb_ident = cb_ident;
|
||||
block_cb->cb_priv = cb_priv;
|
||||
block_cb->release = release;
|
||||
|
||||
return block_cb;
|
||||
}
|
||||
EXPORT_SYMBOL(flow_block_cb_alloc);
|
||||
|
||||
void flow_block_cb_free(struct flow_block_cb *block_cb)
|
||||
{
|
||||
if (block_cb->release)
|
||||
block_cb->release(block_cb->cb_priv);
|
||||
|
||||
kfree(block_cb);
|
||||
}
|
||||
EXPORT_SYMBOL(flow_block_cb_free);
|
||||
|
||||
int flow_block_cb_setup_simple(struct flow_block_offload *f,
|
||||
struct list_head *driver_block_list,
|
||||
tc_setup_cb_t *cb, void *cb_ident, void *cb_priv,
|
||||
|
Loading…
Reference in New Issue
Block a user