Lines Matching refs:tp
50 static u32 destroy_obj_hashfn(const struct tcf_proto *tp) in destroy_obj_hashfn() argument
52 return jhash_3words(tp->chain->index, tp->prio, in destroy_obj_hashfn()
53 (__force __u32)tp->protocol, 0); in destroy_obj_hashfn()
57 struct tcf_proto *tp) in tcf_proto_signal_destroying() argument
62 hash_add_rcu(block->proto_destroy_ht, &tp->destroy_ht_node, in tcf_proto_signal_destroying()
63 destroy_obj_hashfn(tp)); in tcf_proto_signal_destroying()
76 struct tcf_proto *tp) in tcf_proto_exists_destroying() argument
78 u32 hash = destroy_obj_hashfn(tp); in tcf_proto_exists_destroying()
85 if (tcf_proto_cmp(tp, iter)) { in tcf_proto_exists_destroying()
96 tcf_proto_signal_destroyed(struct tcf_chain *chain, struct tcf_proto *tp) in tcf_proto_signal_destroyed() argument
101 if (hash_hashed(&tp->destroy_ht_node)) in tcf_proto_signal_destroyed()
102 hash_del_rcu(&tp->destroy_ht_node); in tcf_proto_signal_destroyed()
211 static inline u32 tcf_auto_prio(struct tcf_proto *tp) in tcf_auto_prio() argument
215 if (tp) in tcf_auto_prio()
216 first = tp->prio - 1; in tcf_auto_prio()
254 struct tcf_proto *tp; in tcf_proto_create() local
257 tp = kzalloc(sizeof(*tp), GFP_KERNEL); in tcf_proto_create()
258 if (!tp) in tcf_proto_create()
261 tp->ops = tcf_proto_lookup_ops(kind, rtnl_held, extack); in tcf_proto_create()
262 if (IS_ERR(tp->ops)) { in tcf_proto_create()
263 err = PTR_ERR(tp->ops); in tcf_proto_create()
266 tp->classify = tp->ops->classify; in tcf_proto_create()
267 tp->protocol = protocol; in tcf_proto_create()
268 tp->prio = prio; in tcf_proto_create()
269 tp->chain = chain; in tcf_proto_create()
270 spin_lock_init(&tp->lock); in tcf_proto_create()
271 refcount_set(&tp->refcnt, 1); in tcf_proto_create()
273 err = tp->ops->init(tp); in tcf_proto_create()
275 module_put(tp->ops->owner); in tcf_proto_create()
278 return tp; in tcf_proto_create()
281 kfree(tp); in tcf_proto_create()
285 static void tcf_proto_get(struct tcf_proto *tp) in tcf_proto_get() argument
287 refcount_inc(&tp->refcnt); in tcf_proto_get()
292 static void tcf_proto_destroy(struct tcf_proto *tp, bool rtnl_held, in tcf_proto_destroy() argument
295 tp->ops->destroy(tp, rtnl_held, extack); in tcf_proto_destroy()
297 tcf_proto_signal_destroyed(tp->chain, tp); in tcf_proto_destroy()
298 tcf_chain_put(tp->chain); in tcf_proto_destroy()
299 module_put(tp->ops->owner); in tcf_proto_destroy()
300 kfree_rcu(tp, rcu); in tcf_proto_destroy()
303 static void tcf_proto_put(struct tcf_proto *tp, bool rtnl_held, in tcf_proto_put() argument
306 if (refcount_dec_and_test(&tp->refcnt)) in tcf_proto_put()
307 tcf_proto_destroy(tp, rtnl_held, true, extack); in tcf_proto_put()
310 static bool tcf_proto_check_delete(struct tcf_proto *tp) in tcf_proto_check_delete() argument
312 if (tp->ops->delete_empty) in tcf_proto_check_delete()
313 return tp->ops->delete_empty(tp); in tcf_proto_check_delete()
315 tp->deleting = true; in tcf_proto_check_delete()
316 return tp->deleting; in tcf_proto_check_delete()
319 static void tcf_proto_mark_delete(struct tcf_proto *tp) in tcf_proto_mark_delete() argument
321 spin_lock(&tp->lock); in tcf_proto_mark_delete()
322 tp->deleting = true; in tcf_proto_mark_delete()
323 spin_unlock(&tp->lock); in tcf_proto_mark_delete()
326 static bool tcf_proto_is_deleting(struct tcf_proto *tp) in tcf_proto_is_deleting() argument
330 spin_lock(&tp->lock); in tcf_proto_is_deleting()
331 deleting = tp->deleting; in tcf_proto_is_deleting()
332 spin_unlock(&tp->lock); in tcf_proto_is_deleting()
598 struct tcf_proto *tp, *tp_next; in tcf_chain_flush() local
601 tp = tcf_chain_dereference(chain->filter_chain, chain); in tcf_chain_flush()
602 while (tp) { in tcf_chain_flush()
603 tp_next = rcu_dereference_protected(tp->next, 1); in tcf_chain_flush()
604 tcf_proto_signal_destroying(chain, tp); in tcf_chain_flush()
605 tp = tp_next; in tcf_chain_flush()
607 tp = tcf_chain_dereference(chain->filter_chain, chain); in tcf_chain_flush()
613 while (tp) { in tcf_chain_flush()
614 tp_next = rcu_dereference_protected(tp->next, 1); in tcf_chain_flush()
615 tcf_proto_put(tp, rtnl_held, NULL); in tcf_chain_flush()
616 tp = tp_next; in tcf_chain_flush()
954 __tcf_get_next_proto(struct tcf_chain *chain, struct tcf_proto *tp) in __tcf_get_next_proto() argument
961 if (!tp) { in __tcf_get_next_proto()
962 tp = tcf_chain_dereference(chain->filter_chain, chain); in __tcf_get_next_proto()
963 } else if (tcf_proto_is_deleting(tp)) { in __tcf_get_next_proto()
968 prio = tp->prio + 1; in __tcf_get_next_proto()
969 tp = tcf_chain_dereference(chain->filter_chain, chain); in __tcf_get_next_proto()
971 for (; tp; tp = tcf_chain_dereference(tp->next, chain)) in __tcf_get_next_proto()
972 if (!tp->deleting && tp->prio >= prio) in __tcf_get_next_proto()
975 tp = tcf_chain_dereference(tp->next, chain); in __tcf_get_next_proto()
978 if (tp) in __tcf_get_next_proto()
979 tcf_proto_get(tp); in __tcf_get_next_proto()
983 return tp; in __tcf_get_next_proto()
995 tcf_get_next_proto(struct tcf_chain *chain, struct tcf_proto *tp) in tcf_get_next_proto() argument
997 struct tcf_proto *tp_next = __tcf_get_next_proto(chain, tp); in tcf_get_next_proto()
999 if (tp) in tcf_get_next_proto()
1000 tcf_proto_put(tp, true, NULL); in tcf_get_next_proto()
1405 struct tcf_proto *tp, *tp_prev; in tcf_block_playback_offloads() local
1415 for (tp = __tcf_get_next_proto(chain, NULL); tp; in tcf_block_playback_offloads()
1416 tp_prev = tp, in tcf_block_playback_offloads()
1417 tp = __tcf_get_next_proto(chain, tp), in tcf_block_playback_offloads()
1419 if (tp->ops->reoffload) { in tcf_block_playback_offloads()
1420 err = tp->ops->reoffload(tp, add, cb, cb_priv, in tcf_block_playback_offloads()
1435 tcf_proto_put(tp, true, NULL); in tcf_block_playback_offloads()
1529 const struct tcf_proto *tp, in __tcf_classify() argument
1542 for (; tp; tp = rcu_dereference_bh(tp->next)) { in __tcf_classify()
1546 if (tp->protocol != protocol && in __tcf_classify()
1547 tp->protocol != htons(ETH_P_ALL)) in __tcf_classify()
1550 err = tp->classify(skb, tp, res); in __tcf_classify()
1571 tp->chain->block->index, in __tcf_classify()
1572 tp->prio & 0xffff, in __tcf_classify()
1573 ntohs(tp->protocol)); in __tcf_classify()
1577 tp = first_tp; in __tcf_classify()
1584 const struct tcf_proto *tp, in tcf_classify() argument
1590 return __tcf_classify(skb, tp, tp, res, compat_mode, in tcf_classify()
1593 u32 last_executed_chain = tp ? tp->chain->index : 0; in tcf_classify()
1594 const struct tcf_proto *orig_tp = tp; in tcf_classify()
1611 tp = rcu_dereference_bh(fchain->filter_chain); in tcf_classify()
1616 ret = __tcf_classify(skb, tp, orig_tp, res, compat_mode, in tcf_classify()
1652 struct tcf_proto *tp) in tcf_chain_tp_insert() argument
1657 RCU_INIT_POINTER(tp->next, tcf_chain_tp_prev(chain, chain_info)); in tcf_chain_tp_insert()
1659 tcf_chain0_head_change(chain, tp); in tcf_chain_tp_insert()
1660 tcf_proto_get(tp); in tcf_chain_tp_insert()
1661 rcu_assign_pointer(*chain_info->pprev, tp); in tcf_chain_tp_insert()
1668 struct tcf_proto *tp) in tcf_chain_tp_remove() argument
1672 tcf_proto_mark_delete(tp); in tcf_chain_tp_remove()
1673 if (tp == chain->filter_chain) in tcf_chain_tp_remove()
1694 struct tcf_proto *tp; in tcf_chain_tp_insert_unique() local
1705 tp = tcf_chain_tp_find(chain, &chain_info, in tcf_chain_tp_insert_unique()
1707 if (!tp) in tcf_chain_tp_insert_unique()
1711 if (tp) { in tcf_chain_tp_insert_unique()
1713 tp_new = tp; in tcf_chain_tp_insert_unique()
1723 struct tcf_proto *tp, bool rtnl_held, in tcf_chain_tp_delete_empty() argument
1737 if (tp_iter == tp) { in tcf_chain_tp_delete_empty()
1748 if (!tp_iter || !tcf_proto_check_delete(tp)) { in tcf_chain_tp_delete_empty()
1753 tcf_proto_signal_destroying(chain, tp); in tcf_chain_tp_delete_empty()
1755 if (tp == chain->filter_chain) in tcf_chain_tp_delete_empty()
1760 tcf_proto_put(tp, rtnl_held, extack); in tcf_chain_tp_delete_empty()
1769 struct tcf_proto *tp; in tcf_chain_tp_find() local
1773 (tp = tcf_chain_dereference(*pprev, chain)); in tcf_chain_tp_find()
1774 pprev = &tp->next) { in tcf_chain_tp_find()
1775 if (tp->prio >= prio) { in tcf_chain_tp_find()
1776 if (tp->prio == prio) { in tcf_chain_tp_find()
1778 (tp->protocol != protocol && protocol)) in tcf_chain_tp_find()
1781 tp = NULL; in tcf_chain_tp_find()
1787 if (tp) { in tcf_chain_tp_find()
1788 chain_info->next = tp->next; in tcf_chain_tp_find()
1789 tcf_proto_get(tp); in tcf_chain_tp_find()
1793 return tp; in tcf_chain_tp_find()
1797 struct tcf_proto *tp, struct tcf_block *block, in tcf_fill_node() argument
1820 tcm->tcm_info = TC_H_MAKE(tp->prio, tp->protocol); in tcf_fill_node()
1821 if (nla_put_string(skb, TCA_KIND, tp->ops->kind)) in tcf_fill_node()
1823 if (nla_put_u32(skb, TCA_CHAIN, tp->chain->index)) in tcf_fill_node()
1828 if (tp->ops->terse_dump) { in tcf_fill_node()
1829 if (tp->ops->terse_dump(net, tp, fh, skb, tcm, in tcf_fill_node()
1836 if (tp->ops->dump && in tcf_fill_node()
1837 tp->ops->dump(net, tp, fh, skb, tcm, rtnl_held) < 0) in tcf_fill_node()
1851 struct nlmsghdr *n, struct tcf_proto *tp, in tfilter_notify() argument
1864 if (tcf_fill_node(net, skb, tp, block, q, parent, fh, portid, in tfilter_notify()
1880 struct nlmsghdr *n, struct tcf_proto *tp, in tfilter_del_notify() argument
1893 if (tcf_fill_node(net, skb, tp, block, q, parent, fh, portid, in tfilter_del_notify()
1901 err = tp->ops->delete(tp, fh, last, rtnl_held, extack); in tfilter_del_notify()
1923 struct tcf_proto *tp; in tfilter_notify_chain() local
1925 for (tp = tcf_get_next_proto(chain, NULL); in tfilter_notify_chain()
1926 tp; tp = tcf_get_next_proto(chain, tp)) in tfilter_notify_chain()
1927 tfilter_notify(net, oskb, n, tp, block, in tfilter_notify_chain()
1931 static void tfilter_put(struct tcf_proto *tp, void *fh) in tfilter_put() argument
1933 if (tp->ops->put && fh) in tfilter_put()
1934 tp->ops->put(tp, fh); in tfilter_put()
1953 struct tcf_proto *tp; in tc_new_tfilter() local
1977 tp = NULL; in tc_new_tfilter()
2046 tp = tcf_chain_tp_find(chain, &chain_info, protocol, in tc_new_tfilter()
2048 if (IS_ERR(tp)) { in tc_new_tfilter()
2050 err = PTR_ERR(tp); in tc_new_tfilter()
2054 if (tp == NULL) { in tc_new_tfilter()
2089 tp = tcf_chain_tp_insert_unique(chain, tp_new, protocol, prio, in tc_new_tfilter()
2091 if (IS_ERR(tp)) { in tc_new_tfilter()
2092 err = PTR_ERR(tp); in tc_new_tfilter()
2099 if (tca[TCA_KIND] && nla_strcmp(tca[TCA_KIND], tp->ops->kind)) { in tc_new_tfilter()
2105 fh = tp->ops->get(tp, t->tcm_handle); in tc_new_tfilter()
2114 tfilter_put(tp, fh); in tc_new_tfilter()
2120 if (chain->tmplt_ops && chain->tmplt_ops != tp->ops) { in tc_new_tfilter()
2121 tfilter_put(tp, fh); in tc_new_tfilter()
2131 err = tp->ops->change(net, skb, tp, cl, t->tcm_handle, tca, &fh, in tc_new_tfilter()
2134 tfilter_notify(net, skb, n, tp, block, q, parent, fh, in tc_new_tfilter()
2136 tfilter_put(tp, fh); in tc_new_tfilter()
2144 tcf_chain_tp_delete_empty(chain, tp, rtnl_held, NULL); in tc_new_tfilter()
2147 if (tp && !IS_ERR(tp)) in tc_new_tfilter()
2148 tcf_proto_put(tp, rtnl_held, NULL); in tc_new_tfilter()
2187 struct tcf_proto *tp = NULL; in tc_del_tfilter() local
2273 tp = tcf_chain_tp_find(chain, &chain_info, protocol, in tc_del_tfilter()
2275 if (!tp || IS_ERR(tp)) { in tc_del_tfilter()
2277 err = tp ? PTR_ERR(tp) : -ENOENT; in tc_del_tfilter()
2279 } else if (tca[TCA_KIND] && nla_strcmp(tca[TCA_KIND], tp->ops->kind)) { in tc_del_tfilter()
2284 tcf_proto_signal_destroying(chain, tp); in tc_del_tfilter()
2285 tcf_chain_tp_remove(chain, &chain_info, tp); in tc_del_tfilter()
2288 tcf_proto_put(tp, rtnl_held, NULL); in tc_del_tfilter()
2289 tfilter_notify(net, skb, n, tp, block, q, parent, fh, in tc_del_tfilter()
2296 fh = tp->ops->get(tp, t->tcm_handle); in tc_del_tfilter()
2304 err = tfilter_del_notify(net, skb, n, tp, block, in tc_del_tfilter()
2311 tcf_chain_tp_delete_empty(chain, tp, rtnl_held, extack); in tc_del_tfilter()
2316 if (tp && !IS_ERR(tp)) in tc_del_tfilter()
2317 tcf_proto_put(tp, rtnl_held, NULL); in tc_del_tfilter()
2347 struct tcf_proto *tp = NULL; in tc_get_tfilter() local
2414 tp = tcf_chain_tp_find(chain, &chain_info, protocol, in tc_get_tfilter()
2417 if (!tp || IS_ERR(tp)) { in tc_get_tfilter()
2419 err = tp ? PTR_ERR(tp) : -ENOENT; in tc_get_tfilter()
2421 } else if (tca[TCA_KIND] && nla_strcmp(tca[TCA_KIND], tp->ops->kind)) { in tc_get_tfilter()
2427 fh = tp->ops->get(tp, t->tcm_handle); in tc_get_tfilter()
2433 err = tfilter_notify(net, skb, n, tp, block, q, parent, in tc_get_tfilter()
2439 tfilter_put(tp, fh); in tc_get_tfilter()
2442 if (tp && !IS_ERR(tp)) in tc_get_tfilter()
2443 tcf_proto_put(tp, rtnl_held, NULL); in tc_get_tfilter()
2464 static int tcf_node_dump(struct tcf_proto *tp, void *n, struct tcf_walker *arg) in tcf_node_dump() argument
2469 return tcf_fill_node(net, a->skb, tp, a->block, a->q, a->parent, in tcf_node_dump()
2482 struct tcf_proto *tp, *tp_prev; in tcf_chain_dump() local
2485 for (tp = __tcf_get_next_proto(chain, NULL); in tcf_chain_dump()
2486 tp; in tcf_chain_dump()
2487 tp_prev = tp, in tcf_chain_dump()
2488 tp = __tcf_get_next_proto(chain, tp), in tcf_chain_dump()
2494 TC_H_MAJ(tcm->tcm_info) != tp->prio) in tcf_chain_dump()
2497 TC_H_MIN(tcm->tcm_info) != tp->protocol) in tcf_chain_dump()
2503 if (tcf_fill_node(net, skb, tp, block, q, parent, NULL, in tcf_chain_dump()
2510 if (!tp->ops->walk) in tcf_chain_dump()
2523 tp->ops->walk(tp, &arg.w, true); in tcf_chain_dump()
2532 tcf_proto_put(tp, true, NULL); in tcf_chain_dump()
3039 int tcf_exts_validate(struct net *net, struct tcf_proto *tp, struct nlattr **tb, in tcf_exts_validate() argument
3058 act = tcf_action_init_1(net, tp, tb[exts->police], in tcf_exts_validate()
3073 err = tcf_action_init(net, tp, tb[exts->action], in tcf_exts_validate()
3209 struct tcf_proto *tp, u32 *cnt, in tc_cls_offload_cnt_update() argument
3214 spin_lock(&tp->lock); in tc_cls_offload_cnt_update()
3224 spin_unlock(&tp->lock); in tc_cls_offload_cnt_update()
3228 tc_cls_offload_cnt_reset(struct tcf_block *block, struct tcf_proto *tp, in tc_cls_offload_cnt_reset() argument
3233 spin_lock(&tp->lock); in tc_cls_offload_cnt_reset()
3236 spin_unlock(&tp->lock); in tc_cls_offload_cnt_reset()
3294 int tc_setup_cb_add(struct tcf_block *block, struct tcf_proto *tp, in tc_setup_cb_add() argument
3325 if (tp->ops->hw_add) in tc_setup_cb_add()
3326 tp->ops->hw_add(tp, type_data); in tc_setup_cb_add()
3328 tc_cls_offload_cnt_update(block, tp, in_hw_count, flags, in tc_setup_cb_add()
3344 int tc_setup_cb_replace(struct tcf_block *block, struct tcf_proto *tp, in tc_setup_cb_replace() argument
3373 tc_cls_offload_cnt_reset(block, tp, old_in_hw_count, old_flags); in tc_setup_cb_replace()
3374 if (tp->ops->hw_del) in tc_setup_cb_replace()
3375 tp->ops->hw_del(tp, type_data); in tc_setup_cb_replace()
3381 if (tp->ops->hw_add) in tc_setup_cb_replace()
3382 tp->ops->hw_add(tp, type_data); in tc_setup_cb_replace()
3384 tc_cls_offload_cnt_update(block, tp, new_in_hw_count, in tc_setup_cb_replace()
3398 int tc_setup_cb_destroy(struct tcf_block *block, struct tcf_proto *tp, in tc_setup_cb_destroy() argument
3421 tc_cls_offload_cnt_reset(block, tp, in_hw_count, flags); in tc_setup_cb_destroy()
3422 if (tp->ops->hw_del) in tc_setup_cb_destroy()
3423 tp->ops->hw_del(tp, type_data); in tc_setup_cb_destroy()
3432 int tc_setup_cb_reoffload(struct tcf_block *block, struct tcf_proto *tp, in tc_setup_cb_reoffload() argument
3443 tc_cls_offload_cnt_update(block, tp, in_hw_count, flags, 1, in tc_setup_cb_reoffload()