summaryrefslogtreecommitdiff
path: root/net/sched/cls_api.c
diff options
context:
space:
mode:
authorWANG Cong <xiyou.wangcong@gmail.com>2017-05-23 09:42:37 -0700
committerDavid S. Miller <davem@davemloft.net>2017-05-25 12:15:05 -0400
commit367a8ce896f14018cc2c6cf2681aa440fff274f4 (patch)
tree50c730e41e49111e669a94750700c3acddb7b1ef /net/sched/cls_api.c
parentee538dcea28930bd95606fe00a834935d6fb5613 (diff)
downloadlinux-rpi-367a8ce896f14018cc2c6cf2681aa440fff274f4.tar.gz
linux-rpi-367a8ce896f14018cc2c6cf2681aa440fff274f4.tar.bz2
linux-rpi-367a8ce896f14018cc2c6cf2681aa440fff274f4.zip
net_sched: only create filter chains for new filters/actions
tcf_chain_get() always creates a new filter chain if not found in existing ones. This is totally unnecessary when we get or delete filters, new chain should be only created for new filters (or new actions). Fixes: 5bc1701881e3 ("net: sched: introduce multichain support for filters") Cc: Jamal Hadi Salim <jhs@mojatatu.com> Cc: Jiri Pirko <jiri@mellanox.com> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched/cls_api.c')
-rw-r--r--net/sched/cls_api.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index 89fbb35bc666..39da0c5801c9 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -220,7 +220,8 @@ static void tcf_chain_destroy(struct tcf_chain *chain)
kfree(chain);
}
-struct tcf_chain *tcf_chain_get(struct tcf_block *block, u32 chain_index)
+struct tcf_chain *tcf_chain_get(struct tcf_block *block, u32 chain_index,
+ bool create)
{
struct tcf_chain *chain;
@@ -230,7 +231,10 @@ struct tcf_chain *tcf_chain_get(struct tcf_block *block, u32 chain_index)
return chain;
}
}
- return tcf_chain_create(block, chain_index);
+ if (create)
+ return tcf_chain_create(block, chain_index);
+ else
+ return NULL;
}
EXPORT_SYMBOL(tcf_chain_get);
@@ -511,9 +515,10 @@ replay:
err = -EINVAL;
goto errout;
}
- chain = tcf_chain_get(block, chain_index);
+ chain = tcf_chain_get(block, chain_index,
+ n->nlmsg_type == RTM_NEWTFILTER);
if (!chain) {
- err = -ENOMEM;
+ err = n->nlmsg_type == RTM_NEWTFILTER ? -ENOMEM : -EINVAL;
goto errout;
}