Thread (37 messages) 37 messages, 6 authors, 2016-09-12

[RFC Patch net-next 4/6] net_sched: introduce tcf_hash_copy()

flat view
STALE3686d

From: Cong Wang <hidden>
Date: 2016-09-02 05:57:49
Subsystem: networking [general], tc subsystem, the rest · Maintainers: "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Jamal Hadi Salim, Jiri Pirko, Linus Torvalds

Signed-off-by: Cong Wang <redacted>
---
 include/net/act_api.h |  1 +
 net/sched/act_api.c   | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+)
diff --git a/include/net/act_api.h b/include/net/act_api.h
index a374bab..17837af 100644
--- a/include/net/act_api.h
+++ b/include/net/act_api.h
@@ -166,6 +166,7 @@ void tcf_hash_cleanup(struct tc_action *a, struct nlattr *est);
 void tcf_hash_insert(struct tc_action_net *tn, struct tc_action *a);
 void tcf_hash_replace(struct tc_action_net *tn, struct tc_action **old,
 		      struct tc_action *new, int bind);
+bool tcf_hash_copy(struct tc_action *dst, const struct tc_action *src);
 
 int __tcf_hash_release(struct tc_action *a, bool bind, bool strict);
 
diff --git a/net/sched/act_api.c b/net/sched/act_api.c
index d0a7db2..2f8db3c 100644
--- a/net/sched/act_api.c
+++ b/net/sched/act_api.c
@@ -296,6 +296,24 @@ int tcf_hash_create(struct tc_action_net *tn, u32 index, struct nlattr *est,
 }
 EXPORT_SYMBOL(tcf_hash_create);
 
+bool tcf_hash_copy(struct tc_action *dst, const struct tc_action *src)
+{
+	if (src) {
+		memcpy(dst, src, sizeof(*src));
+		spin_lock_init(&dst->tcfa_lock);
+		INIT_HLIST_NODE(&dst->tcfa_head);
+		INIT_LIST_HEAD(&dst->list);
+
+		/* tcf_hash_check() is called before this */
+		dst->tcfa_refcnt = src->tcfa_refcnt - 1;
+		if (src->tcfa_bindcnt)
+			dst->tcfa_bindcnt = src->tcfa_bindcnt - 1;
+		return true;
+	}
+	return false;
+}
+EXPORT_SYMBOL(tcf_hash_copy);
+
 void tcf_hash_insert(struct tc_action_net *tn, struct tc_action *a)
 {
 	struct tcf_hashinfo *hinfo = tn->hinfo;
-- 
2.1.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help