Lines Matching full:block
61 struct tcf_block *block = chain->block; in tcf_proto_signal_destroying() local
63 mutex_lock(&block->proto_destroy_lock); in tcf_proto_signal_destroying()
64 hash_add_rcu(block->proto_destroy_ht, &tp->destroy_ht_node, in tcf_proto_signal_destroying()
66 mutex_unlock(&block->proto_destroy_lock); in tcf_proto_signal_destroying()
85 hash_for_each_possible_rcu(chain->block->proto_destroy_ht, iter, in tcf_proto_exists_destroying()
100 struct tcf_block *block = chain->block; in tcf_proto_signal_destroyed() local
102 mutex_lock(&block->proto_destroy_lock); in tcf_proto_signal_destroyed()
105 mutex_unlock(&block->proto_destroy_lock); in tcf_proto_signal_destroyed()
339 #define ASSERT_BLOCK_LOCKED(block) \ argument
340 lockdep_assert_held(&(block)->lock)
348 static struct tcf_chain *tcf_chain_create(struct tcf_block *block, in tcf_chain_create() argument
353 ASSERT_BLOCK_LOCKED(block); in tcf_chain_create()
358 list_add_tail_rcu(&chain->list, &block->chain_list); in tcf_chain_create()
360 chain->block = block; in tcf_chain_create()
364 block->chain0.chain = chain; in tcf_chain_create()
379 struct tcf_block *block = chain->block; in tcf_chain0_head_change() local
384 mutex_lock(&block->lock); in tcf_chain0_head_change()
385 list_for_each_entry(item, &block->chain0.filter_chain_list, list) in tcf_chain0_head_change()
387 mutex_unlock(&block->lock); in tcf_chain0_head_change()
390 /* Returns true if block can be safely freed. */
394 struct tcf_block *block = chain->block; in tcf_chain_detach() local
396 ASSERT_BLOCK_LOCKED(block); in tcf_chain_detach()
400 block->chain0.chain = NULL; in tcf_chain_detach()
402 if (list_empty(&block->chain_list) && in tcf_chain_detach()
403 refcount_read(&block->refcnt) == 0) in tcf_chain_detach()
409 static void tcf_block_destroy(struct tcf_block *block) in tcf_block_destroy() argument
411 mutex_destroy(&block->lock); in tcf_block_destroy()
412 mutex_destroy(&block->proto_destroy_lock); in tcf_block_destroy()
413 kfree_rcu(block, rcu); in tcf_block_destroy()
418 struct tcf_block *block = chain->block; in tcf_chain_destroy() local
423 tcf_block_destroy(block); in tcf_chain_destroy()
428 ASSERT_BLOCK_LOCKED(chain->block); in tcf_chain_hold()
435 ASSERT_BLOCK_LOCKED(chain->block); in tcf_chain_held_by_acts_only()
443 static struct tcf_chain *tcf_chain_lookup(struct tcf_block *block, in tcf_chain_lookup() argument
448 ASSERT_BLOCK_LOCKED(block); in tcf_chain_lookup()
450 list_for_each_entry(chain, &block->chain_list, list) { in tcf_chain_lookup()
458 static struct tcf_chain *tcf_chain_lookup_rcu(const struct tcf_block *block, in tcf_chain_lookup_rcu() argument
463 list_for_each_entry_rcu(chain, &block->chain_list, list) { in tcf_chain_lookup_rcu()
474 static struct tcf_chain *__tcf_chain_get(struct tcf_block *block, in __tcf_chain_get() argument
481 mutex_lock(&block->lock); in __tcf_chain_get()
482 chain = tcf_chain_lookup(block, chain_index); in __tcf_chain_get()
488 chain = tcf_chain_create(block, chain_index); in __tcf_chain_get()
496 mutex_unlock(&block->lock); in __tcf_chain_get()
510 mutex_unlock(&block->lock); in __tcf_chain_get()
514 static struct tcf_chain *tcf_chain_get(struct tcf_block *block, u32 chain_index, in tcf_chain_get() argument
517 return __tcf_chain_get(block, chain_index, create, false); in tcf_chain_get()
520 struct tcf_chain *tcf_chain_get_by_act(struct tcf_block *block, u32 chain_index) in tcf_chain_get_by_act() argument
522 return __tcf_chain_get(block, chain_index, true, true); in tcf_chain_get_by_act()
530 struct tcf_block *block, struct sk_buff *oskb,
536 struct tcf_block *block = chain->block; in __tcf_chain_put() local
542 mutex_lock(&block->lock); in __tcf_chain_put()
545 mutex_unlock(&block->lock); in __tcf_chain_put()
554 /* tc_chain_notify_delete can't be called while holding block lock. in __tcf_chain_put()
555 * However, when block is unlocked chain can be changed concurrently, so in __tcf_chain_put()
565 block, NULL, 0, 0, false); in __tcf_chain_put()
572 mutex_unlock(&block->lock); in __tcf_chain_put()
620 static int tcf_block_setup(struct tcf_block *block,
633 bo->block = flow_block; in tcf_block_offload_init()
641 static void tcf_block_unbind(struct tcf_block *block,
646 struct tcf_block *block = block_cb->indr.data; in tc_block_indr_cleanup() local
654 &block->flow_block, tcf_block_shared(block), in tc_block_indr_cleanup()
657 down_write(&block->cb_lock); in tc_block_indr_cleanup()
660 tcf_block_unbind(block, &bo); in tc_block_indr_cleanup()
661 up_write(&block->cb_lock); in tc_block_indr_cleanup()
665 static bool tcf_block_offload_in_use(struct tcf_block *block) in tcf_block_offload_in_use() argument
667 return atomic_read(&block->offloadcnt); in tcf_block_offload_in_use()
670 static int tcf_block_offload_cmd(struct tcf_block *block, in tcf_block_offload_cmd() argument
679 &block->flow_block, tcf_block_shared(block), in tcf_block_offload_cmd()
692 return tcf_block_setup(block, &bo); in tcf_block_offload_cmd()
695 flow_indr_dev_setup_offload(dev, sch, TC_SETUP_BLOCK, block, &bo, in tcf_block_offload_cmd()
697 tcf_block_setup(block, &bo); in tcf_block_offload_cmd()
702 static int tcf_block_offload_bind(struct tcf_block *block, struct Qdisc *q, in tcf_block_offload_bind() argument
709 down_write(&block->cb_lock); in tcf_block_offload_bind()
711 /* If tc offload feature is disabled and the block we try to bind in tcf_block_offload_bind()
716 tcf_block_offload_in_use(block)) { in tcf_block_offload_bind()
717 NL_SET_ERR_MSG(extack, "Bind to offloaded block failed as dev has offload disabled"); in tcf_block_offload_bind()
722 err = tcf_block_offload_cmd(block, dev, q, ei, FLOW_BLOCK_BIND, extack); in tcf_block_offload_bind()
728 up_write(&block->cb_lock); in tcf_block_offload_bind()
732 if (tcf_block_offload_in_use(block)) in tcf_block_offload_bind()
736 block->nooffloaddevcnt++; in tcf_block_offload_bind()
738 up_write(&block->cb_lock); in tcf_block_offload_bind()
742 static void tcf_block_offload_unbind(struct tcf_block *block, struct Qdisc *q, in tcf_block_offload_unbind() argument
748 down_write(&block->cb_lock); in tcf_block_offload_unbind()
749 err = tcf_block_offload_cmd(block, dev, q, ei, FLOW_BLOCK_UNBIND, NULL); in tcf_block_offload_unbind()
752 up_write(&block->cb_lock); in tcf_block_offload_unbind()
756 WARN_ON(block->nooffloaddevcnt-- == 0); in tcf_block_offload_unbind()
757 up_write(&block->cb_lock); in tcf_block_offload_unbind()
761 tcf_chain0_head_change_cb_add(struct tcf_block *block, in tcf_chain0_head_change_cb_add() argument
776 mutex_lock(&block->lock); in tcf_chain0_head_change_cb_add()
777 chain0 = block->chain0.chain; in tcf_chain0_head_change_cb_add()
781 list_add(&item->list, &block->chain0.filter_chain_list); in tcf_chain0_head_change_cb_add()
782 mutex_unlock(&block->lock); in tcf_chain0_head_change_cb_add()
793 mutex_lock(&block->lock); in tcf_chain0_head_change_cb_add()
794 list_add(&item->list, &block->chain0.filter_chain_list); in tcf_chain0_head_change_cb_add()
795 mutex_unlock(&block->lock); in tcf_chain0_head_change_cb_add()
805 tcf_chain0_head_change_cb_del(struct tcf_block *block, in tcf_chain0_head_change_cb_del() argument
810 mutex_lock(&block->lock); in tcf_chain0_head_change_cb_del()
811 list_for_each_entry(item, &block->chain0.filter_chain_list, list) { in tcf_chain0_head_change_cb_del()
815 if (block->chain0.chain) in tcf_chain0_head_change_cb_del()
818 mutex_unlock(&block->lock); in tcf_chain0_head_change_cb_del()
824 mutex_unlock(&block->lock); in tcf_chain0_head_change_cb_del()
835 static int tcf_block_insert(struct tcf_block *block, struct net *net, in tcf_block_insert() argument
843 err = idr_alloc_u32(&tn->idr, block, &block->index, block->index, in tcf_block_insert()
851 static void tcf_block_remove(struct tcf_block *block, struct net *net) in tcf_block_remove() argument
856 idr_remove(&tn->idr, block->index); in tcf_block_remove()
864 struct tcf_block *block; in tcf_block_create() local
866 block = kzalloc(sizeof(*block), GFP_KERNEL); in tcf_block_create()
867 if (!block) { in tcf_block_create()
868 NL_SET_ERR_MSG(extack, "Memory allocation for block failed"); in tcf_block_create()
871 mutex_init(&block->lock); in tcf_block_create()
872 mutex_init(&block->proto_destroy_lock); in tcf_block_create()
873 init_rwsem(&block->cb_lock); in tcf_block_create()
874 flow_block_init(&block->flow_block); in tcf_block_create()
875 INIT_LIST_HEAD(&block->chain_list); in tcf_block_create()
876 INIT_LIST_HEAD(&block->owner_list); in tcf_block_create()
877 INIT_LIST_HEAD(&block->chain0.filter_chain_list); in tcf_block_create()
879 refcount_set(&block->refcnt, 1); in tcf_block_create()
880 block->net = net; in tcf_block_create()
881 block->index = block_index; in tcf_block_create()
884 if (!tcf_block_shared(block)) in tcf_block_create()
885 block->q = q; in tcf_block_create()
886 return block; in tcf_block_create()
898 struct tcf_block *block; in tcf_block_refcnt_get() local
901 block = tcf_block_lookup(net, block_index); in tcf_block_refcnt_get()
902 if (block && !refcount_inc_not_zero(&block->refcnt)) in tcf_block_refcnt_get()
903 block = NULL; in tcf_block_refcnt_get()
906 return block; in tcf_block_refcnt_get()
910 __tcf_get_next_chain(struct tcf_block *block, struct tcf_chain *chain) in __tcf_get_next_chain() argument
912 mutex_lock(&block->lock); in __tcf_get_next_chain()
914 chain = list_is_last(&chain->list, &block->chain_list) ? in __tcf_get_next_chain()
917 chain = list_first_entry_or_null(&block->chain_list, in __tcf_get_next_chain()
922 chain = list_is_last(&chain->list, &block->chain_list) ? in __tcf_get_next_chain()
927 mutex_unlock(&block->lock); in __tcf_get_next_chain()
933 * block. It properly obtains block->lock and takes reference to chain before
942 tcf_get_next_chain(struct tcf_block *block, struct tcf_chain *chain) in tcf_get_next_chain() argument
944 struct tcf_chain *chain_next = __tcf_get_next_chain(block, chain); in tcf_get_next_chain()
1007 static void tcf_block_flush_all_chains(struct tcf_block *block, bool rtnl_held) in tcf_block_flush_all_chains() argument
1011 /* Last reference to block. At this point chains cannot be added or in tcf_block_flush_all_chains()
1014 for (chain = tcf_get_next_chain(block, NULL); in tcf_block_flush_all_chains()
1016 chain = tcf_get_next_chain(block, chain)) { in tcf_block_flush_all_chains()
1126 struct tcf_block *block; in __tcf_block_find() local
1129 block = tcf_block_refcnt_get(net, block_index); in __tcf_block_find()
1130 if (!block) { in __tcf_block_find()
1131 NL_SET_ERR_MSG(extack, "Block of given index was not found"); in __tcf_block_find()
1137 block = cops->tcf_block(q, cl, extack); in __tcf_block_find()
1138 if (!block) in __tcf_block_find()
1141 if (tcf_block_shared(block)) { in __tcf_block_find()
1142 …NL_SET_ERR_MSG(extack, "This filter block is shared. Please use the block index to manipulate the … in __tcf_block_find()
1146 /* Always take reference to block in order to support execution in __tcf_block_find()
1148 * must release block when it is finished using it. 'if' block in __tcf_block_find()
1149 * of this conditional obtain reference to block by calling in __tcf_block_find()
1152 refcount_inc(&block->refcnt); in __tcf_block_find()
1155 return block; in __tcf_block_find()
1158 static void __tcf_block_put(struct tcf_block *block, struct Qdisc *q, in __tcf_block_put() argument
1161 if (refcount_dec_and_mutex_lock(&block->refcnt, &block->lock)) { in __tcf_block_put()
1162 /* Flushing/putting all chains will cause the block to be in __tcf_block_put()
1164 * is empty, block has to be manually deallocated. After block in __tcf_block_put()
1166 * increment it or add new chains to block. in __tcf_block_put()
1168 bool free_block = list_empty(&block->chain_list); in __tcf_block_put()
1170 mutex_unlock(&block->lock); in __tcf_block_put()
1171 if (tcf_block_shared(block)) in __tcf_block_put()
1172 tcf_block_remove(block, block->net); in __tcf_block_put()
1175 tcf_block_offload_unbind(block, q, ei); in __tcf_block_put()
1178 tcf_block_destroy(block); in __tcf_block_put()
1180 tcf_block_flush_all_chains(block, rtnl_held); in __tcf_block_put()
1182 tcf_block_offload_unbind(block, q, ei); in __tcf_block_put()
1186 static void tcf_block_refcnt_put(struct tcf_block *block, bool rtnl_held) in tcf_block_refcnt_put() argument
1188 __tcf_block_put(block, NULL, NULL, rtnl_held); in tcf_block_refcnt_put()
1191 /* Find tcf block.
1200 struct tcf_block *block; in tcf_block_find() local
1213 block = __tcf_block_find(net, *q, *cl, ifindex, block_index, extack); in tcf_block_find()
1214 if (IS_ERR(block)) { in tcf_block_find()
1215 err = PTR_ERR(block); in tcf_block_find()
1219 return block; in tcf_block_find()
1229 static void tcf_block_release(struct Qdisc *q, struct tcf_block *block, in tcf_block_release() argument
1232 if (!IS_ERR_OR_NULL(block)) in tcf_block_release()
1233 tcf_block_refcnt_put(block, rtnl_held); in tcf_block_release()
1250 tcf_block_owner_netif_keep_dst(struct tcf_block *block, in tcf_block_owner_netif_keep_dst() argument
1254 if (block->keep_dst && in tcf_block_owner_netif_keep_dst()
1260 void tcf_block_netif_keep_dst(struct tcf_block *block) in tcf_block_netif_keep_dst() argument
1264 block->keep_dst = true; in tcf_block_netif_keep_dst()
1265 list_for_each_entry(item, &block->owner_list, list) in tcf_block_netif_keep_dst()
1266 tcf_block_owner_netif_keep_dst(block, item->q, in tcf_block_netif_keep_dst()
1271 static int tcf_block_owner_add(struct tcf_block *block, in tcf_block_owner_add() argument
1282 list_add(&item->list, &block->owner_list); in tcf_block_owner_add()
1286 static void tcf_block_owner_del(struct tcf_block *block, in tcf_block_owner_del() argument
1292 list_for_each_entry(item, &block->owner_list, list) { in tcf_block_owner_del()
1307 struct tcf_block *block = NULL; in tcf_block_get_ext() local
1311 /* block_index not 0 means the shared block is requested */ in tcf_block_get_ext()
1312 block = tcf_block_refcnt_get(net, ei->block_index); in tcf_block_get_ext()
1314 if (!block) { in tcf_block_get_ext()
1315 block = tcf_block_create(net, q, ei->block_index, extack); in tcf_block_get_ext()
1316 if (IS_ERR(block)) in tcf_block_get_ext()
1317 return PTR_ERR(block); in tcf_block_get_ext()
1318 if (tcf_block_shared(block)) { in tcf_block_get_ext()
1319 err = tcf_block_insert(block, net, extack); in tcf_block_get_ext()
1325 err = tcf_block_owner_add(block, q, ei->binder_type); in tcf_block_get_ext()
1329 tcf_block_owner_netif_keep_dst(block, q, ei->binder_type); in tcf_block_get_ext()
1331 err = tcf_chain0_head_change_cb_add(block, ei, extack); in tcf_block_get_ext()
1335 err = tcf_block_offload_bind(block, q, ei, extack); in tcf_block_get_ext()
1339 *p_block = block; in tcf_block_get_ext()
1343 tcf_chain0_head_change_cb_del(block, ei); in tcf_block_get_ext()
1345 tcf_block_owner_del(block, q, ei->binder_type); in tcf_block_get_ext()
1348 tcf_block_refcnt_put(block, true); in tcf_block_get_ext()
1377 void tcf_block_put_ext(struct tcf_block *block, struct Qdisc *q, in tcf_block_put_ext() argument
1380 if (!block) in tcf_block_put_ext()
1382 tcf_chain0_head_change_cb_del(block, ei); in tcf_block_put_ext()
1383 tcf_block_owner_del(block, q, ei->binder_type); in tcf_block_put_ext()
1385 __tcf_block_put(block, q, ei, true); in tcf_block_put_ext()
1389 void tcf_block_put(struct tcf_block *block) in tcf_block_put() argument
1393 if (!block) in tcf_block_put()
1395 tcf_block_put_ext(block, block->q, &ei); in tcf_block_put()
1401 tcf_block_playback_offloads(struct tcf_block *block, flow_setup_cb_t *cb, in tcf_block_playback_offloads() argument
1409 lockdep_assert_held(&block->cb_lock); in tcf_block_playback_offloads()
1411 for (chain = __tcf_get_next_chain(block, NULL); in tcf_block_playback_offloads()
1414 chain = __tcf_get_next_chain(block, chain), in tcf_block_playback_offloads()
1438 tcf_block_playback_offloads(block, cb, cb_priv, false, offload_in_use, in tcf_block_playback_offloads()
1443 static int tcf_block_bind(struct tcf_block *block, in tcf_block_bind() argument
1449 lockdep_assert_held(&block->cb_lock); in tcf_block_bind()
1452 err = tcf_block_playback_offloads(block, block_cb->cb, in tcf_block_bind()
1454 tcf_block_offload_in_use(block), in tcf_block_bind()
1459 block->lockeddevcnt++; in tcf_block_bind()
1463 list_splice(&bo->cb_list, &block->flow_block.cb_list); in tcf_block_bind()
1471 tcf_block_playback_offloads(block, block_cb->cb, in tcf_block_bind()
1473 tcf_block_offload_in_use(block), in tcf_block_bind()
1476 block->lockeddevcnt--; in tcf_block_bind()
1484 static void tcf_block_unbind(struct tcf_block *block, in tcf_block_unbind() argument
1489 lockdep_assert_held(&block->cb_lock); in tcf_block_unbind()
1492 tcf_block_playback_offloads(block, block_cb->cb, in tcf_block_unbind()
1494 tcf_block_offload_in_use(block), in tcf_block_unbind()
1499 block->lockeddevcnt--; in tcf_block_unbind()
1503 static int tcf_block_setup(struct tcf_block *block, in tcf_block_setup() argument
1510 err = tcf_block_bind(block, bo); in tcf_block_setup()
1514 tcf_block_unbind(block, bo); in tcf_block_setup()
1571 tp->chain->block->index, in __tcf_classify()
1799 struct tcf_proto *tp, struct tcf_block *block, in tcf_fill_node() argument
1820 tcm->tcm_block_index = block->index; in tcf_fill_node()
1854 struct tcf_block *block, struct Qdisc *q, in tfilter_notify() argument
1866 if (tcf_fill_node(net, skb, tp, block, q, parent, fh, portid, in tfilter_notify()
1886 struct tcf_block *block, struct Qdisc *q, in tfilter_del_notify() argument
1898 if (tcf_fill_node(net, skb, tp, block, q, parent, fh, portid, in tfilter_del_notify()
1926 struct tcf_block *block, struct Qdisc *q, in tfilter_notify_chain() argument
1935 tfilter_notify(net, oskb, n, tp, block, in tfilter_notify_chain()
1960 struct tcf_block *block; in tc_new_tfilter() local
1986 block = NULL; in tc_new_tfilter()
2016 * block is shared (no qdisc found), qdisc is not unlocked, classifier in tc_new_tfilter()
2030 block = __tcf_block_find(net, q, cl, t->tcm_ifindex, t->tcm_block_index, in tc_new_tfilter()
2032 if (IS_ERR(block)) { in tc_new_tfilter()
2033 err = PTR_ERR(block); in tc_new_tfilter()
2036 block->classid = parent; in tc_new_tfilter()
2044 chain = tcf_chain_get(block, chain_index, true); in tc_new_tfilter()
2136 tfilter_notify(net, skb, n, tp, block, q, parent, fh, in tc_new_tfilter()
2154 tcf_block_release(q, block, rtnl_held); in tc_new_tfilter()
2188 struct tcf_block *block = NULL; in tc_del_tfilter() local
2224 /* Take rtnl mutex if flushing whole chain, block is shared (no qdisc in tc_del_tfilter()
2239 block = __tcf_block_find(net, q, cl, t->tcm_ifindex, t->tcm_block_index, in tc_del_tfilter()
2241 if (IS_ERR(block)) { in tc_del_tfilter()
2242 err = PTR_ERR(block); in tc_del_tfilter()
2252 chain = tcf_chain_get(block, chain_index, false); in tc_del_tfilter()
2267 tfilter_notify_chain(net, skb, block, q, parent, n, in tc_del_tfilter()
2291 tfilter_notify(net, skb, n, tp, block, q, parent, fh, in tc_del_tfilter()
2306 err = tfilter_del_notify(net, skb, n, tp, block, in tc_del_tfilter()
2322 tcf_block_release(q, block, rtnl_held); in tc_del_tfilter()
2348 struct tcf_block *block = NULL; in tc_get_tfilter() local
2381 /* Take rtnl mutex if block is shared (no qdisc found), qdisc is not in tc_get_tfilter()
2395 block = __tcf_block_find(net, q, cl, t->tcm_ifindex, t->tcm_block_index, in tc_get_tfilter()
2397 if (IS_ERR(block)) { in tc_get_tfilter()
2398 err = PTR_ERR(block); in tc_get_tfilter()
2408 chain = tcf_chain_get(block, chain_index, false); in tc_get_tfilter()
2435 err = tfilter_notify(net, skb, n, tp, block, q, parent, in tc_get_tfilter()
2448 tcf_block_release(q, block, rtnl_held); in tc_get_tfilter()
2460 struct tcf_block *block; member
2471 return tcf_fill_node(net, a->skb, tp, a->block, a->q, a->parent, in tcf_node_dump()
2482 struct tcf_block *block = chain->block; in tcf_chain_dump() local
2505 if (tcf_fill_node(net, skb, tp, block, q, parent, NULL, in tcf_chain_dump()
2517 arg.block = block; in tcf_chain_dump()
2549 struct tcf_block *block; in tc_dump_tfilter() local
2573 block = tcf_block_refcnt_get(net, tcm->tcm_block_index); in tc_dump_tfilter()
2574 if (!block) in tc_dump_tfilter()
2576 /* If we work with block index, q is NULL and parent value in tc_dump_tfilter()
2609 block = cops->tcf_block(q, cl, NULL); in tc_dump_tfilter()
2610 if (!block) in tc_dump_tfilter()
2612 parent = block->classid; in tc_dump_tfilter()
2613 if (tcf_block_shared(block)) in tc_dump_tfilter()
2620 for (chain = __tcf_get_next_chain(block, NULL); in tc_dump_tfilter()
2623 chain = __tcf_get_next_chain(block, chain), in tc_dump_tfilter()
2637 tcf_block_refcnt_put(block, true); in tc_dump_tfilter()
2650 struct tcf_block *block, in tc_chain_fill_node() argument
2670 if (block->q) { in tc_chain_fill_node()
2671 tcm->tcm_ifindex = qdisc_dev(block->q)->ifindex; in tc_chain_fill_node()
2672 tcm->tcm_parent = block->q->handle; in tc_chain_fill_node()
2675 tcm->tcm_block_index = block->index; in tc_chain_fill_node()
2701 struct tcf_block *block = chain->block; in tc_chain_notify() local
2702 struct net *net = block->net; in tc_chain_notify()
2711 chain->index, net, skb, block, portid, in tc_chain_notify()
2730 struct tcf_block *block, struct sk_buff *oskb, in tc_chain_notify_delete() argument
2734 struct net *net = block->net; in tc_chain_notify_delete()
2742 block, portid, seq, flags, RTM_DELCHAIN) <= 0) { in tc_chain_notify_delete()
2811 struct tcf_block *block; in tc_ctl_chain() local
2830 block = tcf_block_find(net, &q, &parent, &cl, in tc_ctl_chain()
2832 if (IS_ERR(block)) in tc_ctl_chain()
2833 return PTR_ERR(block); in tc_ctl_chain()
2842 mutex_lock(&block->lock); in tc_ctl_chain()
2843 chain = tcf_chain_lookup(block, chain_index); in tc_ctl_chain()
2862 chain = tcf_chain_create(block, chain_index); in tc_ctl_chain()
2879 /* Modifying chain requires holding parent block lock. In case in tc_ctl_chain()
2887 mutex_unlock(&block->lock); in tc_ctl_chain()
2901 tfilter_notify_chain(net, skb, block, q, parent, n, in tc_ctl_chain()
2925 tcf_block_release(q, block, true); in tc_ctl_chain()
2932 mutex_unlock(&block->lock); in tc_ctl_chain()
2942 struct tcf_block *block; in tc_dump_chain() local
2959 block = tcf_block_refcnt_get(net, tcm->tcm_block_index); in tc_dump_chain()
2960 if (!block) in tc_dump_chain()
2962 /* If we work with block index, q is NULL and parent value in tc_dump_chain()
2997 block = cops->tcf_block(q, cl, NULL); in tc_dump_chain()
2998 if (!block) in tc_dump_chain()
3000 if (tcf_block_shared(block)) in tc_dump_chain()
3007 mutex_lock(&block->lock); in tc_dump_chain()
3008 list_for_each_entry(chain, &block->chain_list, list) { in tc_dump_chain()
3019 chain->index, net, skb, block, in tc_dump_chain()
3027 mutex_unlock(&block->lock); in tc_dump_chain()
3030 tcf_block_refcnt_put(block, true); in tc_dump_chain()
3203 static void tcf_block_offload_inc(struct tcf_block *block, u32 *flags) in tcf_block_offload_inc() argument
3208 atomic_inc(&block->offloadcnt); in tcf_block_offload_inc()
3211 static void tcf_block_offload_dec(struct tcf_block *block, u32 *flags) in tcf_block_offload_dec() argument
3216 atomic_dec(&block->offloadcnt); in tcf_block_offload_dec()
3219 static void tc_cls_offload_cnt_update(struct tcf_block *block, in tc_cls_offload_cnt_update() argument
3223 lockdep_assert_held(&block->cb_lock); in tc_cls_offload_cnt_update()
3228 tcf_block_offload_inc(block, flags); in tc_cls_offload_cnt_update()
3233 tcf_block_offload_dec(block, flags); in tc_cls_offload_cnt_update()
3239 tc_cls_offload_cnt_reset(struct tcf_block *block, struct tcf_proto *tp, in tc_cls_offload_cnt_reset() argument
3242 lockdep_assert_held(&block->cb_lock); in tc_cls_offload_cnt_reset()
3245 tcf_block_offload_dec(block, flags); in tc_cls_offload_cnt_reset()
3251 __tc_setup_cb_call(struct tcf_block *block, enum tc_setup_type type, in __tc_setup_cb_call() argument
3258 list_for_each_entry(block_cb, &block->flow_block.cb_list, list) { in __tc_setup_cb_call()
3270 int tc_setup_cb_call(struct tcf_block *block, enum tc_setup_type type, in tc_setup_cb_call() argument
3273 bool take_rtnl = READ_ONCE(block->lockeddevcnt) && !rtnl_held; in tc_setup_cb_call()
3279 down_read(&block->cb_lock); in tc_setup_cb_call()
3280 /* Need to obtain rtnl lock if block is bound to devs that require it. in tc_setup_cb_call()
3281 * In block bind code cb_lock is obtained while holding rtnl, so we must in tc_setup_cb_call()
3284 if (!rtnl_held && !take_rtnl && block->lockeddevcnt) { in tc_setup_cb_call()
3285 up_read(&block->cb_lock); in tc_setup_cb_call()
3290 ok_count = __tc_setup_cb_call(block, type, type_data, err_stop); in tc_setup_cb_call()
3292 up_read(&block->cb_lock); in tc_setup_cb_call()
3300 * successfully offloaded, increment block offloads counter. On failure,
3305 int tc_setup_cb_add(struct tcf_block *block, struct tcf_proto *tp, in tc_setup_cb_add() argument
3309 bool take_rtnl = READ_ONCE(block->lockeddevcnt) && !rtnl_held; in tc_setup_cb_add()
3315 down_read(&block->cb_lock); in tc_setup_cb_add()
3316 /* Need to obtain rtnl lock if block is bound to devs that require it. in tc_setup_cb_add()
3317 * In block bind code cb_lock is obtained while holding rtnl, so we must in tc_setup_cb_add()
3320 if (!rtnl_held && !take_rtnl && block->lockeddevcnt) { in tc_setup_cb_add()
3321 up_read(&block->cb_lock); in tc_setup_cb_add()
3326 /* Make sure all netdevs sharing this block are offload-capable. */ in tc_setup_cb_add()
3327 if (block->nooffloaddevcnt && err_stop) { in tc_setup_cb_add()
3332 ok_count = __tc_setup_cb_call(block, type, type_data, err_stop); in tc_setup_cb_add()
3339 tc_cls_offload_cnt_update(block, tp, in_hw_count, flags, in tc_setup_cb_add()
3342 up_read(&block->cb_lock); in tc_setup_cb_add()
3350 * successfully offloaded, increment block offload counter. On failure,
3355 int tc_setup_cb_replace(struct tcf_block *block, struct tcf_proto *tp, in tc_setup_cb_replace() argument
3361 bool take_rtnl = READ_ONCE(block->lockeddevcnt) && !rtnl_held; in tc_setup_cb_replace()
3367 down_read(&block->cb_lock); in tc_setup_cb_replace()
3368 /* Need to obtain rtnl lock if block is bound to devs that require it. in tc_setup_cb_replace()
3369 * In block bind code cb_lock is obtained while holding rtnl, so we must in tc_setup_cb_replace()
3372 if (!rtnl_held && !take_rtnl && block->lockeddevcnt) { in tc_setup_cb_replace()
3373 up_read(&block->cb_lock); in tc_setup_cb_replace()
3378 /* Make sure all netdevs sharing this block are offload-capable. */ in tc_setup_cb_replace()
3379 if (block->nooffloaddevcnt && err_stop) { in tc_setup_cb_replace()
3384 tc_cls_offload_cnt_reset(block, tp, old_in_hw_count, old_flags); in tc_setup_cb_replace()
3388 ok_count = __tc_setup_cb_call(block, type, type_data, err_stop); in tc_setup_cb_replace()
3395 tc_cls_offload_cnt_update(block, tp, new_in_hw_count, in tc_setup_cb_replace()
3398 up_read(&block->cb_lock); in tc_setup_cb_replace()
3405 /* Destroy filter and decrement block offload counter, if filter was previously
3409 int tc_setup_cb_destroy(struct tcf_block *block, struct tcf_proto *tp, in tc_setup_cb_destroy() argument
3413 bool take_rtnl = READ_ONCE(block->lockeddevcnt) && !rtnl_held; in tc_setup_cb_destroy()
3419 down_read(&block->cb_lock); in tc_setup_cb_destroy()
3420 /* Need to obtain rtnl lock if block is bound to devs that require it. in tc_setup_cb_destroy()
3421 * In block bind code cb_lock is obtained while holding rtnl, so we must in tc_setup_cb_destroy()
3424 if (!rtnl_held && !take_rtnl && block->lockeddevcnt) { in tc_setup_cb_destroy()
3425 up_read(&block->cb_lock); in tc_setup_cb_destroy()
3430 ok_count = __tc_setup_cb_call(block, type, type_data, err_stop); in tc_setup_cb_destroy()
3432 tc_cls_offload_cnt_reset(block, tp, in_hw_count, flags); in tc_setup_cb_destroy()
3436 up_read(&block->cb_lock); in tc_setup_cb_destroy()
3443 int tc_setup_cb_reoffload(struct tcf_block *block, struct tcf_proto *tp, in tc_setup_cb_reoffload() argument
3454 tc_cls_offload_cnt_update(block, tp, in_hw_count, flags, 1, in tc_setup_cb_reoffload()
3773 NL_SET_ERR_MSG(extack, "Block number may not be zero"); in tcf_qevent_parse_block_index()
3803 return tcf_block_get_ext(&qe->block, sch, &qe->info, extack); in tcf_qevent_init()
3810 tcf_block_put_ext(qe->block, sch, &qe->info); in tcf_qevent_destroy()
3827 /* Bounce newly-configured block or change in block. */ in tcf_qevent_validate_change()