Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions include/net/sch_generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <linux/rwsem.h>
#include <linux/atomic.h>
#include <linux/hashtable.h>
#include <linux/rh_kabi.h>
#include <net/gen_stats.h>
#include <net/rtnetlink.h>
#include <net/flow_offload.h>
Expand Down Expand Up @@ -376,6 +377,10 @@ struct tcf_proto_ops {
struct nlattr **tca,
struct netlink_ext_ack *extack);
void (*tmplt_destroy)(void *tmplt_priv);
RH_KABI_BROKEN_INSERT(void (*tmplt_reoffload)(struct tcf_chain *chain,
bool add,
flow_setup_cb_t *cb,
void *cb_priv))
struct tcf_exts * (*get_exts)(const struct tcf_proto *tp,
u32 handle);

Expand Down
9 changes: 8 additions & 1 deletion net/sched/cls_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -1536,6 +1536,9 @@ tcf_block_playback_offloads(struct tcf_block *block, flow_setup_cb_t *cb,
chain_prev = chain,
chain = __tcf_get_next_chain(block, chain),
tcf_chain_put(chain_prev)) {
if (chain->tmplt_ops && add)
chain->tmplt_ops->tmplt_reoffload(chain, true, cb,
cb_priv);
for (tp = __tcf_get_next_proto(chain, NULL); tp;
tp_prev = tp,
tp = __tcf_get_next_proto(chain, tp),
Expand All @@ -1551,6 +1554,9 @@ tcf_block_playback_offloads(struct tcf_block *block, flow_setup_cb_t *cb,
goto err_playback_remove;
}
}
if (chain->tmplt_ops && !add)
chain->tmplt_ops->tmplt_reoffload(chain, false, cb,
cb_priv);
}

return 0;
Expand Down Expand Up @@ -2950,7 +2956,8 @@ static int tc_chain_tmplt_add(struct tcf_chain *chain, struct net *net,
ops = tcf_proto_lookup_ops(name, true, extack);
if (IS_ERR(ops))
return PTR_ERR(ops);
if (!ops->tmplt_create || !ops->tmplt_destroy || !ops->tmplt_dump) {
if (!ops->tmplt_create || !ops->tmplt_destroy || !ops->tmplt_dump ||
!ops->tmplt_reoffload) {
NL_SET_ERR_MSG(extack, "Chain templates are not supported with specified classifier");
module_put(ops->owner);
return -EOPNOTSUPP;
Expand Down
23 changes: 23 additions & 0 deletions net/sched/cls_flower.c
Original file line number Diff line number Diff line change
Expand Up @@ -2695,6 +2695,28 @@ static void fl_tmplt_destroy(void *tmplt_priv)
kfree(tmplt);
}

static void fl_tmplt_reoffload(struct tcf_chain *chain, bool add,
flow_setup_cb_t *cb, void *cb_priv)
{
struct fl_flow_tmplt *tmplt = chain->tmplt_priv;
struct flow_cls_offload cls_flower = {};

cls_flower.rule = flow_rule_alloc(0);
if (!cls_flower.rule)
return;

cls_flower.common.chain_index = chain->index;
cls_flower.command = add ? FLOW_CLS_TMPLT_CREATE :
FLOW_CLS_TMPLT_DESTROY;
cls_flower.cookie = (unsigned long) tmplt;
cls_flower.rule->match.dissector = &tmplt->dissector;
cls_flower.rule->match.mask = &tmplt->mask;
cls_flower.rule->match.key = &tmplt->dummy_key;

cb(TC_SETUP_CLSFLOWER, &cls_flower, cb_priv);
kfree(cls_flower.rule);
}

static int fl_dump_key_val(struct sk_buff *skb,
void *val, int val_type,
void *mask, int mask_type, int len)
Expand Down Expand Up @@ -3596,6 +3618,7 @@ static struct tcf_proto_ops cls_fl_ops __read_mostly = {
.bind_class = fl_bind_class,
.tmplt_create = fl_tmplt_create,
.tmplt_destroy = fl_tmplt_destroy,
.tmplt_reoffload = fl_tmplt_reoffload,
.tmplt_dump = fl_tmplt_dump,
.get_exts = fl_get_exts,
.owner = THIS_MODULE,
Expand Down
Loading