summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorVlad Buslov <vladbu@mellanox.com>2021-12-10 10:47:28 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-12-14 10:18:04 +0100
commitda1d324088c40fa0a382224c466175fc5c704106 (patch)
tree90a8060249d9df5e2c7d700d581ff8b285f16380 /include
parentf602ed9f8574512e7ea1ab65c3db7ba71053bf27 (diff)
downloadlinux-stable-da1d324088c40fa0a382224c466175fc5c704106.tar.gz
linux-stable-da1d324088c40fa0a382224c466175fc5c704106.tar.bz2
linux-stable-da1d324088c40fa0a382224c466175fc5c704106.zip
net: sched: add helper function to take reference to Qdisc
[ Upstream commit 9d7e82cec35c027756ec97e274f878251f271181 ] Implement function to take reference to Qdisc that relies on rcu read lock instead of rtnl mutex. Function only takes reference to Qdisc if reference counter isn't zero. Intended to be used by unlocked cls API. Signed-off-by: Vlad Buslov <vladbu@mellanox.com> Acked-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net> [Lee: Sent to Stable] Link: https://syzkaller.appspot.com/bug?id=d7e411c5472dd5da33d8cc921ccadc747743a568 Reported-by: syzbot+5f229e48cccc804062c0@syzkaller.appspotmail.com Signed-off-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include')
-rw-r--r--include/net/sch_generic.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index 04a5133d875e..c0147888b155 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -118,6 +118,19 @@ static inline void qdisc_refcount_inc(struct Qdisc *qdisc)
refcount_inc(&qdisc->refcnt);
}
+/* Intended to be used by unlocked users, when concurrent qdisc release is
+ * possible.
+ */
+
+static inline struct Qdisc *qdisc_refcount_inc_nz(struct Qdisc *qdisc)
+{
+ if (qdisc->flags & TCQ_F_BUILTIN)
+ return qdisc;
+ if (refcount_inc_not_zero(&qdisc->refcnt))
+ return qdisc;
+ return NULL;
+}
+
static inline bool qdisc_is_running(struct Qdisc *qdisc)
{
if (qdisc->flags & TCQ_F_NOLOCK)