Lines Matching full:block
181 struct tcf_block *block = chain->block; in tcf_proto_signal_destroying() local
183 mutex_lock(&block->proto_destroy_lock); in tcf_proto_signal_destroying()
184 hash_add_rcu(block->proto_destroy_ht, &tp->destroy_ht_node, in tcf_proto_signal_destroying()
186 mutex_unlock(&block->proto_destroy_lock); in tcf_proto_signal_destroying()
205 hash_for_each_possible_rcu(chain->block->proto_destroy_ht, iter, in tcf_proto_exists_destroying()
220 struct tcf_block *block = chain->block; in tcf_proto_signal_destroyed() local
222 mutex_lock(&block->proto_destroy_lock); in tcf_proto_signal_destroyed()
225 mutex_unlock(&block->proto_destroy_lock); in tcf_proto_signal_destroyed()
460 #define ASSERT_BLOCK_LOCKED(block) \ argument
461 lockdep_assert_held(&(block)->lock)
469 static struct tcf_chain *tcf_chain_create(struct tcf_block *block, in tcf_chain_create() argument
474 ASSERT_BLOCK_LOCKED(block); in tcf_chain_create()
479 list_add_tail_rcu(&chain->list, &block->chain_list); in tcf_chain_create()
481 chain->block = block; in tcf_chain_create()
485 block->chain0.chain = chain; in tcf_chain_create()
500 struct tcf_block *block = chain->block; in tcf_chain0_head_change() local
505 mutex_lock(&block->lock); in tcf_chain0_head_change()
506 list_for_each_entry(item, &block->chain0.filter_chain_list, list) in tcf_chain0_head_change()
508 mutex_unlock(&block->lock); in tcf_chain0_head_change()
511 /* Returns true if block can be safely freed. */
515 struct tcf_block *block = chain->block; in tcf_chain_detach() local
517 ASSERT_BLOCK_LOCKED(block); in tcf_chain_detach()
521 block->chain0.chain = NULL; in tcf_chain_detach()
523 if (list_empty(&block->chain_list) && in tcf_chain_detach()
524 refcount_read(&block->refcnt) == 0) in tcf_chain_detach()
530 static void tcf_block_destroy(struct tcf_block *block) in tcf_block_destroy() argument
532 mutex_destroy(&block->lock); in tcf_block_destroy()
533 mutex_destroy(&block->proto_destroy_lock); in tcf_block_destroy()
534 xa_destroy(&block->ports); in tcf_block_destroy()
535 kfree_rcu(block, rcu); in tcf_block_destroy()
540 struct tcf_block *block = chain->block; in tcf_chain_destroy() local
545 tcf_block_destroy(block); in tcf_chain_destroy()
550 ASSERT_BLOCK_LOCKED(chain->block); in tcf_chain_hold()
557 ASSERT_BLOCK_LOCKED(chain->block); in tcf_chain_held_by_acts_only()
565 static struct tcf_chain *tcf_chain_lookup(struct tcf_block *block, in tcf_chain_lookup() argument
570 ASSERT_BLOCK_LOCKED(block); in tcf_chain_lookup()
572 list_for_each_entry(chain, &block->chain_list, list) { in tcf_chain_lookup()
580 static struct tcf_chain *tcf_chain_lookup_rcu(const struct tcf_block *block, in tcf_chain_lookup_rcu() argument
585 list_for_each_entry_rcu(chain, &block->chain_list, list) { in tcf_chain_lookup_rcu()
597 static struct tcf_chain *__tcf_chain_get(struct tcf_block *block, in __tcf_chain_get() argument
604 mutex_lock(&block->lock); in __tcf_chain_get()
605 chain = tcf_chain_lookup(block, chain_index); in __tcf_chain_get()
611 chain = tcf_chain_create(block, chain_index); in __tcf_chain_get()
619 mutex_unlock(&block->lock); in __tcf_chain_get()
633 mutex_unlock(&block->lock); in __tcf_chain_get()
637 static struct tcf_chain *tcf_chain_get(struct tcf_block *block, u32 chain_index, in tcf_chain_get() argument
640 return __tcf_chain_get(block, chain_index, create, false); in tcf_chain_get()
643 struct tcf_chain *tcf_chain_get_by_act(struct tcf_block *block, u32 chain_index) in tcf_chain_get_by_act() argument
645 return __tcf_chain_get(block, chain_index, true, true); in tcf_chain_get_by_act()
653 struct tcf_block *block, struct sk_buff *oskb,
659 struct tcf_block *block = chain->block; in __tcf_chain_put() local
665 mutex_lock(&block->lock); in __tcf_chain_put()
668 mutex_unlock(&block->lock); in __tcf_chain_put()
677 /* tc_chain_notify_delete can't be called while holding block lock. in __tcf_chain_put()
678 * However, when block is unlocked chain can be changed concurrently, so in __tcf_chain_put()
689 chain->index, block, NULL, 0, 0); in __tcf_chain_put()
696 mutex_unlock(&block->lock); in __tcf_chain_put()
744 static int tcf_block_setup(struct tcf_block *block,
757 bo->block = flow_block; in tcf_block_offload_init()
765 static void tcf_block_unbind(struct tcf_block *block,
770 struct tcf_block *block = block_cb->indr.data; in tc_block_indr_cleanup() local
778 &block->flow_block, tcf_block_shared(block), in tc_block_indr_cleanup()
781 down_write(&block->cb_lock); in tc_block_indr_cleanup()
784 tcf_block_unbind(block, &bo); in tc_block_indr_cleanup()
785 up_write(&block->cb_lock); in tc_block_indr_cleanup()
789 static bool tcf_block_offload_in_use(struct tcf_block *block) in tcf_block_offload_in_use() argument
791 return atomic_read(&block->offloadcnt); in tcf_block_offload_in_use()
794 static int tcf_block_offload_cmd(struct tcf_block *block, in tcf_block_offload_cmd() argument
803 &block->flow_block, tcf_block_shared(block), in tcf_block_offload_cmd()
816 return tcf_block_setup(block, &bo); in tcf_block_offload_cmd()
819 flow_indr_dev_setup_offload(dev, sch, TC_SETUP_BLOCK, block, &bo, in tcf_block_offload_cmd()
821 tcf_block_setup(block, &bo); in tcf_block_offload_cmd()
826 static int tcf_block_offload_bind(struct tcf_block *block, struct Qdisc *q, in tcf_block_offload_bind() argument
833 down_write(&block->cb_lock); in tcf_block_offload_bind()
835 /* If tc offload feature is disabled and the block we try to bind in tcf_block_offload_bind()
840 tcf_block_offload_in_use(block)) { in tcf_block_offload_bind()
841 NL_SET_ERR_MSG(extack, "Bind to offloaded block failed as dev has offload disabled"); in tcf_block_offload_bind()
846 err = tcf_block_offload_cmd(block, dev, q, ei, FLOW_BLOCK_BIND, extack); in tcf_block_offload_bind()
852 up_write(&block->cb_lock); in tcf_block_offload_bind()
856 if (tcf_block_offload_in_use(block)) in tcf_block_offload_bind()
860 block->nooffloaddevcnt++; in tcf_block_offload_bind()
862 up_write(&block->cb_lock); in tcf_block_offload_bind()
866 static void tcf_block_offload_unbind(struct tcf_block *block, struct Qdisc *q, in tcf_block_offload_unbind() argument
872 down_write(&block->cb_lock); in tcf_block_offload_unbind()
873 err = tcf_block_offload_cmd(block, dev, q, ei, FLOW_BLOCK_UNBIND, NULL); in tcf_block_offload_unbind()
876 up_write(&block->cb_lock); in tcf_block_offload_unbind()
880 WARN_ON(block->nooffloaddevcnt-- == 0); in tcf_block_offload_unbind()
881 up_write(&block->cb_lock); in tcf_block_offload_unbind()
885 tcf_chain0_head_change_cb_add(struct tcf_block *block, in tcf_chain0_head_change_cb_add() argument
900 mutex_lock(&block->lock); in tcf_chain0_head_change_cb_add()
901 chain0 = block->chain0.chain; in tcf_chain0_head_change_cb_add()
905 list_add(&item->list, &block->chain0.filter_chain_list); in tcf_chain0_head_change_cb_add()
906 mutex_unlock(&block->lock); in tcf_chain0_head_change_cb_add()
917 mutex_lock(&block->lock); in tcf_chain0_head_change_cb_add()
918 list_add(&item->list, &block->chain0.filter_chain_list); in tcf_chain0_head_change_cb_add()
919 mutex_unlock(&block->lock); in tcf_chain0_head_change_cb_add()
929 tcf_chain0_head_change_cb_del(struct tcf_block *block, in tcf_chain0_head_change_cb_del() argument
934 mutex_lock(&block->lock); in tcf_chain0_head_change_cb_del()
935 list_for_each_entry(item, &block->chain0.filter_chain_list, list) { in tcf_chain0_head_change_cb_del()
939 if (block->chain0.chain) in tcf_chain0_head_change_cb_del()
942 mutex_unlock(&block->lock); in tcf_chain0_head_change_cb_del()
948 mutex_unlock(&block->lock); in tcf_chain0_head_change_cb_del()
959 static int tcf_block_insert(struct tcf_block *block, struct net *net, in tcf_block_insert() argument
967 err = idr_alloc_u32(&tn->idr, block, &block->index, block->index, in tcf_block_insert()
975 static void tcf_block_remove(struct tcf_block *block, struct net *net) in tcf_block_remove() argument
980 idr_remove(&tn->idr, block->index); in tcf_block_remove()
988 struct tcf_block *block; in tcf_block_create() local
990 block = kzalloc(sizeof(*block), GFP_KERNEL); in tcf_block_create()
991 if (!block) { in tcf_block_create()
992 NL_SET_ERR_MSG(extack, "Memory allocation for block failed"); in tcf_block_create()
995 mutex_init(&block->lock); in tcf_block_create()
996 mutex_init(&block->proto_destroy_lock); in tcf_block_create()
997 init_rwsem(&block->cb_lock); in tcf_block_create()
998 flow_block_init(&block->flow_block); in tcf_block_create()
999 INIT_LIST_HEAD(&block->chain_list); in tcf_block_create()
1000 INIT_LIST_HEAD(&block->owner_list); in tcf_block_create()
1001 INIT_LIST_HEAD(&block->chain0.filter_chain_list); in tcf_block_create()
1003 refcount_set(&block->refcnt, 1); in tcf_block_create()
1004 block->net = net; in tcf_block_create()
1005 block->index = block_index; in tcf_block_create()
1006 xa_init(&block->ports); in tcf_block_create()
1009 if (!tcf_block_shared(block)) in tcf_block_create()
1010 block->q = q; in tcf_block_create()
1011 return block; in tcf_block_create()
1024 struct tcf_block *block; in tcf_block_refcnt_get() local
1027 block = tcf_block_lookup(net, block_index); in tcf_block_refcnt_get()
1028 if (block && !refcount_inc_not_zero(&block->refcnt)) in tcf_block_refcnt_get()
1029 block = NULL; in tcf_block_refcnt_get()
1032 return block; in tcf_block_refcnt_get()
1036 __tcf_get_next_chain(struct tcf_block *block, struct tcf_chain *chain) in __tcf_get_next_chain() argument
1038 mutex_lock(&block->lock); in __tcf_get_next_chain()
1040 chain = list_is_last(&chain->list, &block->chain_list) ? in __tcf_get_next_chain()
1043 chain = list_first_entry_or_null(&block->chain_list, in __tcf_get_next_chain()
1048 chain = list_is_last(&chain->list, &block->chain_list) ? in __tcf_get_next_chain()
1053 mutex_unlock(&block->lock); in __tcf_get_next_chain()
1059 * block. It properly obtains block->lock and takes reference to chain before
1068 tcf_get_next_chain(struct tcf_block *block, struct tcf_chain *chain) in tcf_get_next_chain() argument
1070 struct tcf_chain *chain_next = __tcf_get_next_chain(block, chain); in tcf_get_next_chain()
1132 static void tcf_block_flush_all_chains(struct tcf_block *block, bool rtnl_held) in tcf_block_flush_all_chains() argument
1136 /* Last reference to block. At this point chains cannot be added or in tcf_block_flush_all_chains()
1139 for (chain = tcf_get_next_chain(block, NULL); in tcf_block_flush_all_chains()
1141 chain = tcf_get_next_chain(block, chain)) { in tcf_block_flush_all_chains()
1251 struct tcf_block *block; in __tcf_block_find() local
1254 block = tcf_block_refcnt_get(net, block_index); in __tcf_block_find()
1255 if (!block) { in __tcf_block_find()
1256 NL_SET_ERR_MSG(extack, "Block of given index was not found"); in __tcf_block_find()
1262 block = cops->tcf_block(q, cl, extack); in __tcf_block_find()
1263 if (!block) in __tcf_block_find()
1266 if (tcf_block_shared(block)) { in __tcf_block_find()
1267 …NL_SET_ERR_MSG(extack, "This filter block is shared. Please use the block index to manipulate the … in __tcf_block_find()
1271 /* Always take reference to block in order to support execution in __tcf_block_find()
1273 * must release block when it is finished using it. 'if' block in __tcf_block_find()
1274 * of this conditional obtain reference to block by calling in __tcf_block_find()
1277 refcount_inc(&block->refcnt); in __tcf_block_find()
1280 return block; in __tcf_block_find()
1283 static void __tcf_block_put(struct tcf_block *block, struct Qdisc *q, in __tcf_block_put() argument
1286 if (refcount_dec_and_mutex_lock(&block->refcnt, &block->lock)) { in __tcf_block_put()
1287 /* Flushing/putting all chains will cause the block to be in __tcf_block_put()
1289 * is empty, block has to be manually deallocated. After block in __tcf_block_put()
1291 * increment it or add new chains to block. in __tcf_block_put()
1293 bool free_block = list_empty(&block->chain_list); in __tcf_block_put()
1295 mutex_unlock(&block->lock); in __tcf_block_put()
1296 if (tcf_block_shared(block)) in __tcf_block_put()
1297 tcf_block_remove(block, block->net); in __tcf_block_put()
1300 tcf_block_offload_unbind(block, q, ei); in __tcf_block_put()
1303 tcf_block_destroy(block); in __tcf_block_put()
1305 tcf_block_flush_all_chains(block, rtnl_held); in __tcf_block_put()
1307 tcf_block_offload_unbind(block, q, ei); in __tcf_block_put()
1311 static void tcf_block_refcnt_put(struct tcf_block *block, bool rtnl_held) in tcf_block_refcnt_put() argument
1313 __tcf_block_put(block, NULL, NULL, rtnl_held); in tcf_block_refcnt_put()
1316 /* Find tcf block.
1325 struct tcf_block *block; in tcf_block_find() local
1338 block = __tcf_block_find(net, *q, *cl, ifindex, block_index, extack); in tcf_block_find()
1339 if (IS_ERR(block)) { in tcf_block_find()
1340 err = PTR_ERR(block); in tcf_block_find()
1344 return block; in tcf_block_find()
1354 static void tcf_block_release(struct Qdisc *q, struct tcf_block *block, in tcf_block_release() argument
1357 if (!IS_ERR_OR_NULL(block)) in tcf_block_release()
1358 tcf_block_refcnt_put(block, rtnl_held); in tcf_block_release()
1375 tcf_block_owner_netif_keep_dst(struct tcf_block *block, in tcf_block_owner_netif_keep_dst() argument
1379 if (block->keep_dst && in tcf_block_owner_netif_keep_dst()
1385 void tcf_block_netif_keep_dst(struct tcf_block *block) in tcf_block_netif_keep_dst() argument
1389 block->keep_dst = true; in tcf_block_netif_keep_dst()
1390 list_for_each_entry(item, &block->owner_list, list) in tcf_block_netif_keep_dst()
1391 tcf_block_owner_netif_keep_dst(block, item->q, in tcf_block_netif_keep_dst()
1396 static int tcf_block_owner_add(struct tcf_block *block, in tcf_block_owner_add() argument
1407 list_add(&item->list, &block->owner_list); in tcf_block_owner_add()
1411 static void tcf_block_owner_del(struct tcf_block *block, in tcf_block_owner_del() argument
1417 list_for_each_entry(item, &block->owner_list, list) { in tcf_block_owner_del()
1427 static bool tcf_block_tracks_dev(struct tcf_block *block, in tcf_block_tracks_dev() argument
1430 return tcf_block_shared(block) && in tcf_block_tracks_dev()
1441 struct tcf_block *block = NULL; in tcf_block_get_ext() local
1445 /* block_index not 0 means the shared block is requested */ in tcf_block_get_ext()
1446 block = tcf_block_refcnt_get(net, ei->block_index); in tcf_block_get_ext()
1448 if (!block) { in tcf_block_get_ext()
1449 block = tcf_block_create(net, q, ei->block_index, extack); in tcf_block_get_ext()
1450 if (IS_ERR(block)) in tcf_block_get_ext()
1451 return PTR_ERR(block); in tcf_block_get_ext()
1452 if (tcf_block_shared(block)) { in tcf_block_get_ext()
1453 err = tcf_block_insert(block, net, extack); in tcf_block_get_ext()
1459 err = tcf_block_owner_add(block, q, ei->binder_type); in tcf_block_get_ext()
1463 tcf_block_owner_netif_keep_dst(block, q, ei->binder_type); in tcf_block_get_ext()
1465 err = tcf_chain0_head_change_cb_add(block, ei, extack); in tcf_block_get_ext()
1469 err = tcf_block_offload_bind(block, q, ei, extack); in tcf_block_get_ext()
1473 if (tcf_block_tracks_dev(block, ei)) { in tcf_block_get_ext()
1474 err = xa_insert(&block->ports, dev->ifindex, dev, GFP_KERNEL); in tcf_block_get_ext()
1476 NL_SET_ERR_MSG(extack, "block dev insert failed"); in tcf_block_get_ext()
1481 *p_block = block; in tcf_block_get_ext()
1486 tcf_chain0_head_change_cb_del(block, ei); in tcf_block_get_ext()
1488 tcf_block_owner_del(block, q, ei->binder_type); in tcf_block_get_ext()
1491 tcf_block_refcnt_put(block, true); in tcf_block_get_ext()
1520 void tcf_block_put_ext(struct tcf_block *block, struct Qdisc *q, in tcf_block_put_ext() argument
1525 if (!block) in tcf_block_put_ext()
1527 if (tcf_block_tracks_dev(block, ei)) in tcf_block_put_ext()
1528 xa_erase(&block->ports, dev->ifindex); in tcf_block_put_ext()
1529 tcf_chain0_head_change_cb_del(block, ei); in tcf_block_put_ext()
1530 tcf_block_owner_del(block, q, ei->binder_type); in tcf_block_put_ext()
1532 __tcf_block_put(block, q, ei, true); in tcf_block_put_ext()
1536 void tcf_block_put(struct tcf_block *block) in tcf_block_put() argument
1540 if (!block) in tcf_block_put()
1542 tcf_block_put_ext(block, block->q, &ei); in tcf_block_put()
1548 tcf_block_playback_offloads(struct tcf_block *block, flow_setup_cb_t *cb, in tcf_block_playback_offloads() argument
1556 lockdep_assert_held(&block->cb_lock); in tcf_block_playback_offloads()
1558 for (chain = __tcf_get_next_chain(block, NULL); in tcf_block_playback_offloads()
1561 chain = __tcf_get_next_chain(block, chain), in tcf_block_playback_offloads()
1591 tcf_block_playback_offloads(block, cb, cb_priv, false, offload_in_use, in tcf_block_playback_offloads()
1596 static int tcf_block_bind(struct tcf_block *block, in tcf_block_bind() argument
1602 lockdep_assert_held(&block->cb_lock); in tcf_block_bind()
1605 err = tcf_block_playback_offloads(block, block_cb->cb, in tcf_block_bind()
1607 tcf_block_offload_in_use(block), in tcf_block_bind()
1612 block->lockeddevcnt++; in tcf_block_bind()
1616 list_splice(&bo->cb_list, &block->flow_block.cb_list); in tcf_block_bind()
1625 tcf_block_playback_offloads(block, block_cb->cb, in tcf_block_bind()
1627 tcf_block_offload_in_use(block), in tcf_block_bind()
1630 block->lockeddevcnt--; in tcf_block_bind()
1638 static void tcf_block_unbind(struct tcf_block *block, in tcf_block_unbind() argument
1643 lockdep_assert_held(&block->cb_lock); in tcf_block_unbind()
1646 tcf_block_playback_offloads(block, block_cb->cb, in tcf_block_unbind()
1648 tcf_block_offload_in_use(block), in tcf_block_unbind()
1653 block->lockeddevcnt--; in tcf_block_unbind()
1657 static int tcf_block_setup(struct tcf_block *block, in tcf_block_setup() argument
1664 err = tcf_block_bind(block, bo); in tcf_block_setup()
1668 tcf_block_unbind(block, bo); in tcf_block_setup()
1762 tp->chain->block->index, in __tcf_classify()
1776 const struct tcf_block *block, in tcf_classify() argument
1793 if (block) { in tcf_classify()
1814 fchain = tcf_chain_lookup_rcu(block, chain); in tcf_classify()
2015 struct tcf_proto *tp, struct tcf_block *block, in tcf_fill_node() argument
2037 tcm->tcm_block_index = block->index; in tcf_fill_node()
2077 struct tcf_block *block, struct Qdisc *q, in tfilter_notify() argument
2092 if (tcf_fill_node(net, skb, tp, block, q, parent, fh, portid, in tfilter_notify()
2109 struct tcf_block *block, struct Qdisc *q, in tfilter_del_notify() argument
2124 if (tcf_fill_node(net, skb, tp, block, q, parent, fh, portid, in tfilter_del_notify()
2147 struct tcf_block *block, struct Qdisc *q, in tfilter_notify_chain() argument
2156 tfilter_notify(net, oskb, n, tp, block, q, parent, NULL, in tfilter_notify_chain()
2186 struct tcf_block *block; in tc_new_tfilter() local
2210 block = NULL; in tc_new_tfilter()
2241 * block is shared (no qdisc found), qdisc is not unlocked, classifier in tc_new_tfilter()
2255 block = __tcf_block_find(net, q, cl, t->tcm_ifindex, t->tcm_block_index, in tc_new_tfilter()
2257 if (IS_ERR(block)) { in tc_new_tfilter()
2258 err = PTR_ERR(block); in tc_new_tfilter()
2261 block->classid = parent; in tc_new_tfilter()
2269 chain = tcf_chain_get(block, chain_index, true); in tc_new_tfilter()
2367 tfilter_notify(net, skb, n, tp, block, q, parent, fh, in tc_new_tfilter()
2385 tcf_block_release(q, block, rtnl_held); in tc_new_tfilter()
2419 struct tcf_block *block = NULL; in tc_del_tfilter() local
2452 /* Take rtnl mutex if flushing whole chain, block is shared (no qdisc in tc_del_tfilter()
2467 block = __tcf_block_find(net, q, cl, t->tcm_ifindex, t->tcm_block_index, in tc_del_tfilter()
2469 if (IS_ERR(block)) { in tc_del_tfilter()
2470 err = PTR_ERR(block); in tc_del_tfilter()
2480 chain = tcf_chain_get(block, chain_index, false); in tc_del_tfilter()
2495 tfilter_notify_chain(net, skb, block, q, parent, n, in tc_del_tfilter()
2519 tfilter_notify(net, skb, n, tp, block, q, parent, fh, in tc_del_tfilter()
2534 err = tfilter_del_notify(net, skb, n, tp, block, q, parent, fh, in tc_del_tfilter()
2549 tcf_block_release(q, block, rtnl_held); in tc_del_tfilter()
2575 struct tcf_block *block = NULL; in tc_get_tfilter() local
2608 /* Take rtnl mutex if block is shared (no qdisc found), qdisc is not in tc_get_tfilter()
2622 block = __tcf_block_find(net, q, cl, t->tcm_ifindex, t->tcm_block_index, in tc_get_tfilter()
2624 if (IS_ERR(block)) { in tc_get_tfilter()
2625 err = PTR_ERR(block); in tc_get_tfilter()
2635 chain = tcf_chain_get(block, chain_index, false); in tc_get_tfilter()
2662 err = tfilter_notify(net, skb, n, tp, block, q, parent, in tc_get_tfilter()
2675 tcf_block_release(q, block, rtnl_held); in tc_get_tfilter()
2687 struct tcf_block *block; member
2698 return tcf_fill_node(net, a->skb, tp, a->block, a->q, a->parent, in tcf_node_dump()
2709 struct tcf_block *block = chain->block; in tcf_chain_dump() local
2732 if (tcf_fill_node(net, skb, tp, block, q, parent, NULL, in tcf_chain_dump()
2744 arg.block = block; in tcf_chain_dump()
2777 struct tcf_block *block; in tc_dump_tfilter() local
2801 block = tcf_block_refcnt_get(net, tcm->tcm_block_index); in tc_dump_tfilter()
2802 if (!block) in tc_dump_tfilter()
2804 /* If we work with block index, q is NULL and parent value in tc_dump_tfilter()
2837 block = cops->tcf_block(q, cl, NULL); in tc_dump_tfilter()
2838 if (!block) in tc_dump_tfilter()
2840 parent = block->classid; in tc_dump_tfilter()
2841 if (tcf_block_shared(block)) in tc_dump_tfilter()
2848 for (chain = __tcf_get_next_chain(block, NULL); in tc_dump_tfilter()
2851 chain = __tcf_get_next_chain(block, chain), in tc_dump_tfilter()
2865 tcf_block_refcnt_put(block, true); in tc_dump_tfilter()
2878 struct tcf_block *block, in tc_chain_fill_node() argument
2899 if (block->q) { in tc_chain_fill_node()
2900 tcm->tcm_ifindex = qdisc_dev(block->q)->ifindex; in tc_chain_fill_node()
2901 tcm->tcm_parent = block->q->handle; in tc_chain_fill_node()
2904 tcm->tcm_block_index = block->index; in tc_chain_fill_node()
2936 struct tcf_block *block = chain->block; in tc_chain_notify() local
2937 struct net *net = block->net; in tc_chain_notify()
2949 chain->index, net, skb, block, portid, in tc_chain_notify()
2966 struct tcf_block *block, struct sk_buff *oskb, in tc_chain_notify_delete() argument
2970 struct net *net = block->net; in tc_chain_notify_delete()
2981 block, portid, seq, flags, RTM_DELCHAIN, NULL) <= 0) { in tc_chain_notify_delete()
3049 struct tcf_block *block; in tc_ctl_chain() local
3064 block = tcf_block_find(net, &q, &parent, &cl, in tc_ctl_chain()
3066 if (IS_ERR(block)) in tc_ctl_chain()
3067 return PTR_ERR(block); in tc_ctl_chain()
3076 mutex_lock(&block->lock); in tc_ctl_chain()
3077 chain = tcf_chain_lookup(block, chain_index); in tc_ctl_chain()
3096 chain = tcf_chain_create(block, chain_index); in tc_ctl_chain()
3113 /* Modifying chain requires holding parent block lock. In case in tc_ctl_chain()
3121 mutex_unlock(&block->lock); in tc_ctl_chain()
3135 tfilter_notify_chain(net, skb, block, q, parent, n, in tc_ctl_chain()
3159 tcf_block_release(q, block, true); in tc_ctl_chain()
3166 mutex_unlock(&block->lock); in tc_ctl_chain()
3176 struct tcf_block *block; in tc_dump_chain() local
3192 block = tcf_block_refcnt_get(net, tcm->tcm_block_index); in tc_dump_chain()
3193 if (!block) in tc_dump_chain()
3221 block = cops->tcf_block(q, cl, NULL); in tc_dump_chain()
3222 if (!block) in tc_dump_chain()
3224 if (tcf_block_shared(block)) in tc_dump_chain()
3231 mutex_lock(&block->lock); in tc_dump_chain()
3232 list_for_each_entry(chain, &block->chain_list, list) { in tc_dump_chain()
3243 chain->index, net, skb, block, in tc_dump_chain()
3251 mutex_unlock(&block->lock); in tc_dump_chain()
3254 tcf_block_refcnt_put(block, true); in tc_dump_chain()
3481 static void tcf_block_offload_inc(struct tcf_block *block, u32 *flags) in tcf_block_offload_inc() argument
3486 atomic_inc(&block->offloadcnt); in tcf_block_offload_inc()
3489 static void tcf_block_offload_dec(struct tcf_block *block, u32 *flags) in tcf_block_offload_dec() argument
3494 atomic_dec(&block->offloadcnt); in tcf_block_offload_dec()
3497 static void tc_cls_offload_cnt_update(struct tcf_block *block, in tc_cls_offload_cnt_update() argument
3501 lockdep_assert_held(&block->cb_lock); in tc_cls_offload_cnt_update()
3506 tcf_block_offload_inc(block, flags); in tc_cls_offload_cnt_update()
3511 tcf_block_offload_dec(block, flags); in tc_cls_offload_cnt_update()
3517 tc_cls_offload_cnt_reset(struct tcf_block *block, struct tcf_proto *tp, in tc_cls_offload_cnt_reset() argument
3520 lockdep_assert_held(&block->cb_lock); in tc_cls_offload_cnt_reset()
3523 tcf_block_offload_dec(block, flags); in tc_cls_offload_cnt_reset()
3529 __tc_setup_cb_call(struct tcf_block *block, enum tc_setup_type type, in __tc_setup_cb_call() argument
3536 list_for_each_entry(block_cb, &block->flow_block.cb_list, list) { in __tc_setup_cb_call()
3548 int tc_setup_cb_call(struct tcf_block *block, enum tc_setup_type type, in tc_setup_cb_call() argument
3551 bool take_rtnl = READ_ONCE(block->lockeddevcnt) && !rtnl_held; in tc_setup_cb_call()
3557 down_read(&block->cb_lock); in tc_setup_cb_call()
3558 /* Need to obtain rtnl lock if block is bound to devs that require it. in tc_setup_cb_call()
3559 * In block bind code cb_lock is obtained while holding rtnl, so we must in tc_setup_cb_call()
3562 if (!rtnl_held && !take_rtnl && block->lockeddevcnt) { in tc_setup_cb_call()
3563 up_read(&block->cb_lock); in tc_setup_cb_call()
3568 ok_count = __tc_setup_cb_call(block, type, type_data, err_stop); in tc_setup_cb_call()
3570 up_read(&block->cb_lock); in tc_setup_cb_call()
3578 * successfully offloaded, increment block offloads counter. On failure,
3583 int tc_setup_cb_add(struct tcf_block *block, struct tcf_proto *tp, in tc_setup_cb_add() argument
3587 bool take_rtnl = READ_ONCE(block->lockeddevcnt) && !rtnl_held; in tc_setup_cb_add()
3593 down_read(&block->cb_lock); in tc_setup_cb_add()
3594 /* Need to obtain rtnl lock if block is bound to devs that require it. in tc_setup_cb_add()
3595 * In block bind code cb_lock is obtained while holding rtnl, so we must in tc_setup_cb_add()
3598 if (!rtnl_held && !take_rtnl && block->lockeddevcnt) { in tc_setup_cb_add()
3599 up_read(&block->cb_lock); in tc_setup_cb_add()
3604 /* Make sure all netdevs sharing this block are offload-capable. */ in tc_setup_cb_add()
3605 if (block->nooffloaddevcnt && err_stop) { in tc_setup_cb_add()
3610 ok_count = __tc_setup_cb_call(block, type, type_data, err_stop); in tc_setup_cb_add()
3617 tc_cls_offload_cnt_update(block, tp, in_hw_count, flags, in tc_setup_cb_add()
3620 up_read(&block->cb_lock); in tc_setup_cb_add()
3628 * successfully offloaded, increment block offload counter. On failure,
3633 int tc_setup_cb_replace(struct tcf_block *block, struct tcf_proto *tp, in tc_setup_cb_replace() argument
3639 bool take_rtnl = READ_ONCE(block->lockeddevcnt) && !rtnl_held; in tc_setup_cb_replace()
3645 down_read(&block->cb_lock); in tc_setup_cb_replace()
3646 /* Need to obtain rtnl lock if block is bound to devs that require it. in tc_setup_cb_replace()
3647 * In block bind code cb_lock is obtained while holding rtnl, so we must in tc_setup_cb_replace()
3650 if (!rtnl_held && !take_rtnl && block->lockeddevcnt) { in tc_setup_cb_replace()
3651 up_read(&block->cb_lock); in tc_setup_cb_replace()
3656 /* Make sure all netdevs sharing this block are offload-capable. */ in tc_setup_cb_replace()
3657 if (block->nooffloaddevcnt && err_stop) { in tc_setup_cb_replace()
3662 tc_cls_offload_cnt_reset(block, tp, old_in_hw_count, old_flags); in tc_setup_cb_replace()
3666 ok_count = __tc_setup_cb_call(block, type, type_data, err_stop); in tc_setup_cb_replace()
3673 tc_cls_offload_cnt_update(block, tp, new_in_hw_count, in tc_setup_cb_replace()
3676 up_read(&block->cb_lock); in tc_setup_cb_replace()
3683 /* Destroy filter and decrement block offload counter, if filter was previously
3687 int tc_setup_cb_destroy(struct tcf_block *block, struct tcf_proto *tp, in tc_setup_cb_destroy() argument
3691 bool take_rtnl = READ_ONCE(block->lockeddevcnt) && !rtnl_held; in tc_setup_cb_destroy()
3697 down_read(&block->cb_lock); in tc_setup_cb_destroy()
3698 /* Need to obtain rtnl lock if block is bound to devs that require it. in tc_setup_cb_destroy()
3699 * In block bind code cb_lock is obtained while holding rtnl, so we must in tc_setup_cb_destroy()
3702 if (!rtnl_held && !take_rtnl && block->lockeddevcnt) { in tc_setup_cb_destroy()
3703 up_read(&block->cb_lock); in tc_setup_cb_destroy()
3708 ok_count = __tc_setup_cb_call(block, type, type_data, err_stop); in tc_setup_cb_destroy()
3710 tc_cls_offload_cnt_reset(block, tp, in_hw_count, flags); in tc_setup_cb_destroy()
3714 up_read(&block->cb_lock); in tc_setup_cb_destroy()
3721 int tc_setup_cb_reoffload(struct tcf_block *block, struct tcf_proto *tp, in tc_setup_cb_reoffload() argument
3732 tc_cls_offload_cnt_update(block, tp, in_hw_count, flags, 1, in tc_setup_cb_reoffload()
3891 NL_SET_ERR_MSG(extack, "Block number may not be zero"); in tcf_qevent_parse_block_index()
3918 return tcf_block_get_ext(&qe->block, sch, &qe->info, extack); in tcf_qevent_init()
3925 tcf_block_put_ext(qe->block, sch, &qe->info); in tcf_qevent_destroy()
3942 /* Bounce newly-configured block or change in block. */ in tcf_qevent_validate_change()