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()
640 static void tcf_block_unbind(struct tcf_block *block,
645 struct tcf_block *block = block_cb->indr.data; in tc_block_indr_cleanup() local
653 &block->flow_block, tcf_block_shared(block), in tc_block_indr_cleanup()
656 down_write(&block->cb_lock); in tc_block_indr_cleanup()
659 tcf_block_unbind(block, &bo); in tc_block_indr_cleanup()
660 up_write(&block->cb_lock); in tc_block_indr_cleanup()
664 static bool tcf_block_offload_in_use(struct tcf_block *block) in tcf_block_offload_in_use() argument
666 return atomic_read(&block->offloadcnt); in tcf_block_offload_in_use()
669 static int tcf_block_offload_cmd(struct tcf_block *block, in tcf_block_offload_cmd() argument
678 &block->flow_block, tcf_block_shared(block), in tcf_block_offload_cmd()
691 return tcf_block_setup(block, &bo); in tcf_block_offload_cmd()
694 flow_indr_dev_setup_offload(dev, sch, TC_SETUP_BLOCK, block, &bo, in tcf_block_offload_cmd()
696 tcf_block_setup(block, &bo); in tcf_block_offload_cmd()
701 static int tcf_block_offload_bind(struct tcf_block *block, struct Qdisc *q, in tcf_block_offload_bind() argument
708 down_write(&block->cb_lock); in tcf_block_offload_bind()
710 /* If tc offload feature is disabled and the block we try to bind in tcf_block_offload_bind()
715 tcf_block_offload_in_use(block)) { in tcf_block_offload_bind()
716 NL_SET_ERR_MSG(extack, "Bind to offloaded block failed as dev has offload disabled"); in tcf_block_offload_bind()
721 err = tcf_block_offload_cmd(block, dev, q, ei, FLOW_BLOCK_BIND, extack); in tcf_block_offload_bind()
727 up_write(&block->cb_lock); in tcf_block_offload_bind()
731 if (tcf_block_offload_in_use(block)) in tcf_block_offload_bind()
735 block->nooffloaddevcnt++; in tcf_block_offload_bind()
737 up_write(&block->cb_lock); in tcf_block_offload_bind()
741 static void tcf_block_offload_unbind(struct tcf_block *block, struct Qdisc *q, in tcf_block_offload_unbind() argument
747 down_write(&block->cb_lock); in tcf_block_offload_unbind()
748 err = tcf_block_offload_cmd(block, dev, q, ei, FLOW_BLOCK_UNBIND, NULL); in tcf_block_offload_unbind()
751 up_write(&block->cb_lock); in tcf_block_offload_unbind()
755 WARN_ON(block->nooffloaddevcnt-- == 0); in tcf_block_offload_unbind()
756 up_write(&block->cb_lock); in tcf_block_offload_unbind()
760 tcf_chain0_head_change_cb_add(struct tcf_block *block, in tcf_chain0_head_change_cb_add() argument
775 mutex_lock(&block->lock); in tcf_chain0_head_change_cb_add()
776 chain0 = block->chain0.chain; in tcf_chain0_head_change_cb_add()
780 list_add(&item->list, &block->chain0.filter_chain_list); in tcf_chain0_head_change_cb_add()
781 mutex_unlock(&block->lock); in tcf_chain0_head_change_cb_add()
792 mutex_lock(&block->lock); in tcf_chain0_head_change_cb_add()
793 list_add(&item->list, &block->chain0.filter_chain_list); in tcf_chain0_head_change_cb_add()
794 mutex_unlock(&block->lock); in tcf_chain0_head_change_cb_add()
804 tcf_chain0_head_change_cb_del(struct tcf_block *block, in tcf_chain0_head_change_cb_del() argument
809 mutex_lock(&block->lock); in tcf_chain0_head_change_cb_del()
810 list_for_each_entry(item, &block->chain0.filter_chain_list, list) { in tcf_chain0_head_change_cb_del()
814 if (block->chain0.chain) in tcf_chain0_head_change_cb_del()
817 mutex_unlock(&block->lock); in tcf_chain0_head_change_cb_del()
823 mutex_unlock(&block->lock); in tcf_chain0_head_change_cb_del()
834 static int tcf_block_insert(struct tcf_block *block, struct net *net, in tcf_block_insert() argument
842 err = idr_alloc_u32(&tn->idr, block, &block->index, block->index, in tcf_block_insert()
850 static void tcf_block_remove(struct tcf_block *block, struct net *net) in tcf_block_remove() argument
855 idr_remove(&tn->idr, block->index); in tcf_block_remove()
863 struct tcf_block *block; in tcf_block_create() local
865 block = kzalloc(sizeof(*block), GFP_KERNEL); in tcf_block_create()
866 if (!block) { in tcf_block_create()
867 NL_SET_ERR_MSG(extack, "Memory allocation for block failed"); in tcf_block_create()
870 mutex_init(&block->lock); in tcf_block_create()
871 mutex_init(&block->proto_destroy_lock); in tcf_block_create()
872 init_rwsem(&block->cb_lock); in tcf_block_create()
873 flow_block_init(&block->flow_block); in tcf_block_create()
874 INIT_LIST_HEAD(&block->chain_list); in tcf_block_create()
875 INIT_LIST_HEAD(&block->owner_list); in tcf_block_create()
876 INIT_LIST_HEAD(&block->chain0.filter_chain_list); in tcf_block_create()
878 refcount_set(&block->refcnt, 1); in tcf_block_create()
879 block->net = net; in tcf_block_create()
880 block->index = block_index; in tcf_block_create()
883 if (!tcf_block_shared(block)) in tcf_block_create()
884 block->q = q; in tcf_block_create()
885 return block; in tcf_block_create()
897 struct tcf_block *block; in tcf_block_refcnt_get() local
900 block = tcf_block_lookup(net, block_index); in tcf_block_refcnt_get()
901 if (block && !refcount_inc_not_zero(&block->refcnt)) in tcf_block_refcnt_get()
902 block = NULL; in tcf_block_refcnt_get()
905 return block; in tcf_block_refcnt_get()
909 __tcf_get_next_chain(struct tcf_block *block, struct tcf_chain *chain) in __tcf_get_next_chain() argument
911 mutex_lock(&block->lock); in __tcf_get_next_chain()
913 chain = list_is_last(&chain->list, &block->chain_list) ? in __tcf_get_next_chain()
916 chain = list_first_entry_or_null(&block->chain_list, in __tcf_get_next_chain()
921 chain = list_is_last(&chain->list, &block->chain_list) ? in __tcf_get_next_chain()
926 mutex_unlock(&block->lock); in __tcf_get_next_chain()
932 * block. It properly obtains block->lock and takes reference to chain before
941 tcf_get_next_chain(struct tcf_block *block, struct tcf_chain *chain) in tcf_get_next_chain() argument
943 struct tcf_chain *chain_next = __tcf_get_next_chain(block, chain); in tcf_get_next_chain()
1006 static void tcf_block_flush_all_chains(struct tcf_block *block, bool rtnl_held) in tcf_block_flush_all_chains() argument
1010 /* Last reference to block. At this point chains cannot be added or in tcf_block_flush_all_chains()
1013 for (chain = tcf_get_next_chain(block, NULL); in tcf_block_flush_all_chains()
1015 chain = tcf_get_next_chain(block, chain)) { in tcf_block_flush_all_chains()
1125 struct tcf_block *block; in __tcf_block_find() local
1128 block = tcf_block_refcnt_get(net, block_index); in __tcf_block_find()
1129 if (!block) { in __tcf_block_find()
1130 NL_SET_ERR_MSG(extack, "Block of given index was not found"); in __tcf_block_find()
1136 block = cops->tcf_block(q, cl, extack); in __tcf_block_find()
1137 if (!block) in __tcf_block_find()
1140 if (tcf_block_shared(block)) { in __tcf_block_find()
1141 …NL_SET_ERR_MSG(extack, "This filter block is shared. Please use the block index to manipulate the … in __tcf_block_find()
1145 /* Always take reference to block in order to support execution in __tcf_block_find()
1147 * must release block when it is finished using it. 'if' block in __tcf_block_find()
1148 * of this conditional obtain reference to block by calling in __tcf_block_find()
1151 refcount_inc(&block->refcnt); in __tcf_block_find()
1154 return block; in __tcf_block_find()
1157 static void __tcf_block_put(struct tcf_block *block, struct Qdisc *q, in __tcf_block_put() argument
1160 if (refcount_dec_and_mutex_lock(&block->refcnt, &block->lock)) { in __tcf_block_put()
1161 /* Flushing/putting all chains will cause the block to be in __tcf_block_put()
1163 * is empty, block has to be manually deallocated. After block in __tcf_block_put()
1165 * increment it or add new chains to block. in __tcf_block_put()
1167 bool free_block = list_empty(&block->chain_list); in __tcf_block_put()
1169 mutex_unlock(&block->lock); in __tcf_block_put()
1170 if (tcf_block_shared(block)) in __tcf_block_put()
1171 tcf_block_remove(block, block->net); in __tcf_block_put()
1174 tcf_block_offload_unbind(block, q, ei); in __tcf_block_put()
1177 tcf_block_destroy(block); in __tcf_block_put()
1179 tcf_block_flush_all_chains(block, rtnl_held); in __tcf_block_put()
1181 tcf_block_offload_unbind(block, q, ei); in __tcf_block_put()
1185 static void tcf_block_refcnt_put(struct tcf_block *block, bool rtnl_held) in tcf_block_refcnt_put() argument
1187 __tcf_block_put(block, NULL, NULL, rtnl_held); in tcf_block_refcnt_put()
1190 /* Find tcf block.
1199 struct tcf_block *block; in tcf_block_find() local
1212 block = __tcf_block_find(net, *q, *cl, ifindex, block_index, extack); in tcf_block_find()
1213 if (IS_ERR(block)) { in tcf_block_find()
1214 err = PTR_ERR(block); in tcf_block_find()
1218 return block; in tcf_block_find()
1228 static void tcf_block_release(struct Qdisc *q, struct tcf_block *block, in tcf_block_release() argument
1231 if (!IS_ERR_OR_NULL(block)) in tcf_block_release()
1232 tcf_block_refcnt_put(block, rtnl_held); in tcf_block_release()
1249 tcf_block_owner_netif_keep_dst(struct tcf_block *block, in tcf_block_owner_netif_keep_dst() argument
1253 if (block->keep_dst && in tcf_block_owner_netif_keep_dst()
1259 void tcf_block_netif_keep_dst(struct tcf_block *block) in tcf_block_netif_keep_dst() argument
1263 block->keep_dst = true; in tcf_block_netif_keep_dst()
1264 list_for_each_entry(item, &block->owner_list, list) in tcf_block_netif_keep_dst()
1265 tcf_block_owner_netif_keep_dst(block, item->q, in tcf_block_netif_keep_dst()
1270 static int tcf_block_owner_add(struct tcf_block *block, in tcf_block_owner_add() argument
1281 list_add(&item->list, &block->owner_list); in tcf_block_owner_add()
1285 static void tcf_block_owner_del(struct tcf_block *block, in tcf_block_owner_del() argument
1291 list_for_each_entry(item, &block->owner_list, list) { in tcf_block_owner_del()
1306 struct tcf_block *block = NULL; in tcf_block_get_ext() local
1310 /* block_index not 0 means the shared block is requested */ in tcf_block_get_ext()
1311 block = tcf_block_refcnt_get(net, ei->block_index); in tcf_block_get_ext()
1313 if (!block) { in tcf_block_get_ext()
1314 block = tcf_block_create(net, q, ei->block_index, extack); in tcf_block_get_ext()
1315 if (IS_ERR(block)) in tcf_block_get_ext()
1316 return PTR_ERR(block); in tcf_block_get_ext()
1317 if (tcf_block_shared(block)) { in tcf_block_get_ext()
1318 err = tcf_block_insert(block, net, extack); in tcf_block_get_ext()
1324 err = tcf_block_owner_add(block, q, ei->binder_type); in tcf_block_get_ext()
1328 tcf_block_owner_netif_keep_dst(block, q, ei->binder_type); in tcf_block_get_ext()
1330 err = tcf_chain0_head_change_cb_add(block, ei, extack); in tcf_block_get_ext()
1334 err = tcf_block_offload_bind(block, q, ei, extack); in tcf_block_get_ext()
1338 *p_block = block; in tcf_block_get_ext()
1342 tcf_chain0_head_change_cb_del(block, ei); in tcf_block_get_ext()
1344 tcf_block_owner_del(block, q, ei->binder_type); in tcf_block_get_ext()
1347 tcf_block_refcnt_put(block, true); in tcf_block_get_ext()
1376 void tcf_block_put_ext(struct tcf_block *block, struct Qdisc *q, in tcf_block_put_ext() argument
1379 if (!block) in tcf_block_put_ext()
1381 tcf_chain0_head_change_cb_del(block, ei); in tcf_block_put_ext()
1382 tcf_block_owner_del(block, q, ei->binder_type); in tcf_block_put_ext()
1384 __tcf_block_put(block, q, ei, true); in tcf_block_put_ext()
1388 void tcf_block_put(struct tcf_block *block) in tcf_block_put() argument
1392 if (!block) in tcf_block_put()
1394 tcf_block_put_ext(block, block->q, &ei); in tcf_block_put()
1400 tcf_block_playback_offloads(struct tcf_block *block, flow_setup_cb_t *cb, in tcf_block_playback_offloads() argument
1408 lockdep_assert_held(&block->cb_lock); in tcf_block_playback_offloads()
1410 for (chain = __tcf_get_next_chain(block, NULL); in tcf_block_playback_offloads()
1413 chain = __tcf_get_next_chain(block, chain), in tcf_block_playback_offloads()
1437 tcf_block_playback_offloads(block, cb, cb_priv, false, offload_in_use, in tcf_block_playback_offloads()
1442 static int tcf_block_bind(struct tcf_block *block, in tcf_block_bind() argument
1448 lockdep_assert_held(&block->cb_lock); in tcf_block_bind()
1451 err = tcf_block_playback_offloads(block, block_cb->cb, in tcf_block_bind()
1453 tcf_block_offload_in_use(block), in tcf_block_bind()
1458 block->lockeddevcnt++; in tcf_block_bind()
1462 list_splice(&bo->cb_list, &block->flow_block.cb_list); in tcf_block_bind()
1470 tcf_block_playback_offloads(block, block_cb->cb, in tcf_block_bind()
1472 tcf_block_offload_in_use(block), in tcf_block_bind()
1475 block->lockeddevcnt--; in tcf_block_bind()
1483 static void tcf_block_unbind(struct tcf_block *block, in tcf_block_unbind() argument
1488 lockdep_assert_held(&block->cb_lock); in tcf_block_unbind()
1491 tcf_block_playback_offloads(block, block_cb->cb, in tcf_block_unbind()
1493 tcf_block_offload_in_use(block), in tcf_block_unbind()
1498 block->lockeddevcnt--; in tcf_block_unbind()
1502 static int tcf_block_setup(struct tcf_block *block, in tcf_block_setup() argument
1509 err = tcf_block_bind(block, bo); in tcf_block_setup()
1513 tcf_block_unbind(block, bo); in tcf_block_setup()
1570 tp->chain->block->index, in __tcf_classify()
1798 struct tcf_proto *tp, struct tcf_block *block, in tcf_fill_node() argument
1819 tcm->tcm_block_index = block->index; in tcf_fill_node()
1853 struct tcf_block *block, struct Qdisc *q, in tfilter_notify() argument
1865 if (tcf_fill_node(net, skb, tp, block, q, parent, fh, portid, in tfilter_notify()
1885 struct tcf_block *block, struct Qdisc *q, in tfilter_del_notify() argument
1897 if (tcf_fill_node(net, skb, tp, block, q, parent, fh, portid, in tfilter_del_notify()
1925 struct tcf_block *block, struct Qdisc *q, in tfilter_notify_chain() argument
1934 tfilter_notify(net, oskb, n, tp, block, in tfilter_notify_chain()
1959 struct tcf_block *block; in tc_new_tfilter() local
1985 block = NULL; in tc_new_tfilter()
2013 * block is shared (no qdisc found), qdisc is not unlocked, classifier in tc_new_tfilter()
2027 block = __tcf_block_find(net, q, cl, t->tcm_ifindex, t->tcm_block_index, in tc_new_tfilter()
2029 if (IS_ERR(block)) { in tc_new_tfilter()
2030 err = PTR_ERR(block); in tc_new_tfilter()
2033 block->classid = parent; in tc_new_tfilter()
2041 chain = tcf_chain_get(block, chain_index, true); in tc_new_tfilter()
2133 tfilter_notify(net, skb, n, tp, block, q, parent, fh, in tc_new_tfilter()
2151 tcf_block_release(q, block, rtnl_held); in tc_new_tfilter()
2185 struct tcf_block *block = NULL; in tc_del_tfilter() local
2221 /* Take rtnl mutex if flushing whole chain, block is shared (no qdisc in tc_del_tfilter()
2236 block = __tcf_block_find(net, q, cl, t->tcm_ifindex, t->tcm_block_index, in tc_del_tfilter()
2238 if (IS_ERR(block)) { in tc_del_tfilter()
2239 err = PTR_ERR(block); in tc_del_tfilter()
2249 chain = tcf_chain_get(block, chain_index, false); in tc_del_tfilter()
2264 tfilter_notify_chain(net, skb, block, q, parent, n, in tc_del_tfilter()
2288 tfilter_notify(net, skb, n, tp, block, q, parent, fh, in tc_del_tfilter()
2303 err = tfilter_del_notify(net, skb, n, tp, block, in tc_del_tfilter()
2319 tcf_block_release(q, block, rtnl_held); in tc_del_tfilter()
2345 struct tcf_block *block = NULL; in tc_get_tfilter() local
2378 /* Take rtnl mutex if block is shared (no qdisc found), qdisc is not in tc_get_tfilter()
2392 block = __tcf_block_find(net, q, cl, t->tcm_ifindex, t->tcm_block_index, in tc_get_tfilter()
2394 if (IS_ERR(block)) { in tc_get_tfilter()
2395 err = PTR_ERR(block); in tc_get_tfilter()
2405 chain = tcf_chain_get(block, chain_index, false); in tc_get_tfilter()
2432 err = tfilter_notify(net, skb, n, tp, block, q, parent, in tc_get_tfilter()
2445 tcf_block_release(q, block, rtnl_held); in tc_get_tfilter()
2457 struct tcf_block *block; member
2468 return tcf_fill_node(net, a->skb, tp, a->block, a->q, a->parent, in tcf_node_dump()
2479 struct tcf_block *block = chain->block; in tcf_chain_dump() local
2502 if (tcf_fill_node(net, skb, tp, block, q, parent, NULL, in tcf_chain_dump()
2514 arg.block = block; in tcf_chain_dump()
2546 struct tcf_block *block; in tc_dump_tfilter() local
2570 block = tcf_block_refcnt_get(net, tcm->tcm_block_index); in tc_dump_tfilter()
2571 if (!block) in tc_dump_tfilter()
2573 /* If we work with block index, q is NULL and parent value in tc_dump_tfilter()
2606 block = cops->tcf_block(q, cl, NULL); in tc_dump_tfilter()
2607 if (!block) in tc_dump_tfilter()
2609 parent = block->classid; in tc_dump_tfilter()
2610 if (tcf_block_shared(block)) in tc_dump_tfilter()
2617 for (chain = __tcf_get_next_chain(block, NULL); in tc_dump_tfilter()
2620 chain = __tcf_get_next_chain(block, chain), in tc_dump_tfilter()
2634 tcf_block_refcnt_put(block, true); in tc_dump_tfilter()
2647 struct tcf_block *block, in tc_chain_fill_node() argument
2667 if (block->q) { in tc_chain_fill_node()
2668 tcm->tcm_ifindex = qdisc_dev(block->q)->ifindex; in tc_chain_fill_node()
2669 tcm->tcm_parent = block->q->handle; in tc_chain_fill_node()
2672 tcm->tcm_block_index = block->index; in tc_chain_fill_node()
2698 struct tcf_block *block = chain->block; in tc_chain_notify() local
2699 struct net *net = block->net; in tc_chain_notify()
2708 chain->index, net, skb, block, portid, in tc_chain_notify()
2727 struct tcf_block *block, struct sk_buff *oskb, in tc_chain_notify_delete() argument
2731 struct net *net = block->net; in tc_chain_notify_delete()
2739 block, portid, seq, flags, RTM_DELCHAIN) <= 0) { in tc_chain_notify_delete()
2808 struct tcf_block *block; in tc_ctl_chain() local
2826 block = tcf_block_find(net, &q, &parent, &cl, in tc_ctl_chain()
2828 if (IS_ERR(block)) in tc_ctl_chain()
2829 return PTR_ERR(block); in tc_ctl_chain()
2838 mutex_lock(&block->lock); in tc_ctl_chain()
2839 chain = tcf_chain_lookup(block, chain_index); in tc_ctl_chain()
2858 chain = tcf_chain_create(block, chain_index); in tc_ctl_chain()
2875 /* Modifying chain requires holding parent block lock. In case in tc_ctl_chain()
2883 mutex_unlock(&block->lock); in tc_ctl_chain()
2897 tfilter_notify_chain(net, skb, block, q, parent, n, in tc_ctl_chain()
2921 tcf_block_release(q, block, true); in tc_ctl_chain()
2928 mutex_unlock(&block->lock); in tc_ctl_chain()
2938 struct tcf_block *block; in tc_dump_chain() local
2955 block = tcf_block_refcnt_get(net, tcm->tcm_block_index); in tc_dump_chain()
2956 if (!block) in tc_dump_chain()
2958 /* If we work with block index, q is NULL and parent value in tc_dump_chain()
2993 block = cops->tcf_block(q, cl, NULL); in tc_dump_chain()
2994 if (!block) in tc_dump_chain()
2996 if (tcf_block_shared(block)) in tc_dump_chain()
3003 mutex_lock(&block->lock); in tc_dump_chain()
3004 list_for_each_entry(chain, &block->chain_list, list) { in tc_dump_chain()
3015 chain->index, net, skb, block, in tc_dump_chain()
3023 mutex_unlock(&block->lock); in tc_dump_chain()
3026 tcf_block_refcnt_put(block, true); in tc_dump_chain()
3191 static void tcf_block_offload_inc(struct tcf_block *block, u32 *flags) in tcf_block_offload_inc() argument
3196 atomic_inc(&block->offloadcnt); in tcf_block_offload_inc()
3199 static void tcf_block_offload_dec(struct tcf_block *block, u32 *flags) in tcf_block_offload_dec() argument
3204 atomic_dec(&block->offloadcnt); in tcf_block_offload_dec()
3207 static void tc_cls_offload_cnt_update(struct tcf_block *block, in tc_cls_offload_cnt_update() argument
3211 lockdep_assert_held(&block->cb_lock); in tc_cls_offload_cnt_update()
3216 tcf_block_offload_inc(block, flags); in tc_cls_offload_cnt_update()
3221 tcf_block_offload_dec(block, flags); in tc_cls_offload_cnt_update()
3227 tc_cls_offload_cnt_reset(struct tcf_block *block, struct tcf_proto *tp, in tc_cls_offload_cnt_reset() argument
3230 lockdep_assert_held(&block->cb_lock); in tc_cls_offload_cnt_reset()
3233 tcf_block_offload_dec(block, flags); in tc_cls_offload_cnt_reset()
3239 __tc_setup_cb_call(struct tcf_block *block, enum tc_setup_type type, in __tc_setup_cb_call() argument
3246 list_for_each_entry(block_cb, &block->flow_block.cb_list, list) { in __tc_setup_cb_call()
3258 int tc_setup_cb_call(struct tcf_block *block, enum tc_setup_type type, in tc_setup_cb_call() argument
3261 bool take_rtnl = READ_ONCE(block->lockeddevcnt) && !rtnl_held; in tc_setup_cb_call()
3267 down_read(&block->cb_lock); in tc_setup_cb_call()
3268 /* Need to obtain rtnl lock if block is bound to devs that require it. in tc_setup_cb_call()
3269 * In block bind code cb_lock is obtained while holding rtnl, so we must in tc_setup_cb_call()
3272 if (!rtnl_held && !take_rtnl && block->lockeddevcnt) { in tc_setup_cb_call()
3273 up_read(&block->cb_lock); in tc_setup_cb_call()
3278 ok_count = __tc_setup_cb_call(block, type, type_data, err_stop); in tc_setup_cb_call()
3280 up_read(&block->cb_lock); in tc_setup_cb_call()
3288 * successfully offloaded, increment block offloads counter. On failure,
3293 int tc_setup_cb_add(struct tcf_block *block, struct tcf_proto *tp, in tc_setup_cb_add() argument
3297 bool take_rtnl = READ_ONCE(block->lockeddevcnt) && !rtnl_held; in tc_setup_cb_add()
3303 down_read(&block->cb_lock); in tc_setup_cb_add()
3304 /* Need to obtain rtnl lock if block is bound to devs that require it. in tc_setup_cb_add()
3305 * In block bind code cb_lock is obtained while holding rtnl, so we must in tc_setup_cb_add()
3308 if (!rtnl_held && !take_rtnl && block->lockeddevcnt) { in tc_setup_cb_add()
3309 up_read(&block->cb_lock); in tc_setup_cb_add()
3314 /* Make sure all netdevs sharing this block are offload-capable. */ in tc_setup_cb_add()
3315 if (block->nooffloaddevcnt && err_stop) { in tc_setup_cb_add()
3320 ok_count = __tc_setup_cb_call(block, type, type_data, err_stop); in tc_setup_cb_add()
3327 tc_cls_offload_cnt_update(block, tp, in_hw_count, flags, in tc_setup_cb_add()
3330 up_read(&block->cb_lock); in tc_setup_cb_add()
3338 * successfully offloaded, increment block offload counter. On failure,
3343 int tc_setup_cb_replace(struct tcf_block *block, struct tcf_proto *tp, in tc_setup_cb_replace() argument
3349 bool take_rtnl = READ_ONCE(block->lockeddevcnt) && !rtnl_held; in tc_setup_cb_replace()
3355 down_read(&block->cb_lock); in tc_setup_cb_replace()
3356 /* Need to obtain rtnl lock if block is bound to devs that require it. in tc_setup_cb_replace()
3357 * In block bind code cb_lock is obtained while holding rtnl, so we must in tc_setup_cb_replace()
3360 if (!rtnl_held && !take_rtnl && block->lockeddevcnt) { in tc_setup_cb_replace()
3361 up_read(&block->cb_lock); in tc_setup_cb_replace()
3366 /* Make sure all netdevs sharing this block are offload-capable. */ in tc_setup_cb_replace()
3367 if (block->nooffloaddevcnt && err_stop) { in tc_setup_cb_replace()
3372 tc_cls_offload_cnt_reset(block, tp, old_in_hw_count, old_flags); in tc_setup_cb_replace()
3376 ok_count = __tc_setup_cb_call(block, type, type_data, err_stop); in tc_setup_cb_replace()
3383 tc_cls_offload_cnt_update(block, tp, new_in_hw_count, in tc_setup_cb_replace()
3386 up_read(&block->cb_lock); in tc_setup_cb_replace()
3393 /* Destroy filter and decrement block offload counter, if filter was previously
3397 int tc_setup_cb_destroy(struct tcf_block *block, struct tcf_proto *tp, in tc_setup_cb_destroy() argument
3401 bool take_rtnl = READ_ONCE(block->lockeddevcnt) && !rtnl_held; in tc_setup_cb_destroy()
3407 down_read(&block->cb_lock); in tc_setup_cb_destroy()
3408 /* Need to obtain rtnl lock if block is bound to devs that require it. in tc_setup_cb_destroy()
3409 * In block bind code cb_lock is obtained while holding rtnl, so we must in tc_setup_cb_destroy()
3412 if (!rtnl_held && !take_rtnl && block->lockeddevcnt) { in tc_setup_cb_destroy()
3413 up_read(&block->cb_lock); in tc_setup_cb_destroy()
3418 ok_count = __tc_setup_cb_call(block, type, type_data, err_stop); in tc_setup_cb_destroy()
3420 tc_cls_offload_cnt_reset(block, tp, in_hw_count, flags); in tc_setup_cb_destroy()
3424 up_read(&block->cb_lock); in tc_setup_cb_destroy()
3431 int tc_setup_cb_reoffload(struct tcf_block *block, struct tcf_proto *tp, in tc_setup_cb_reoffload() argument
3442 tc_cls_offload_cnt_update(block, tp, in_hw_count, flags, 1, in tc_setup_cb_reoffload()
3760 NL_SET_ERR_MSG(extack, "Block number may not be zero"); in tcf_qevent_parse_block_index()
3790 return tcf_block_get_ext(&qe->block, sch, &qe->info, extack); in tcf_qevent_init()
3797 tcf_block_put_ext(qe->block, sch, &qe->info); in tcf_qevent_destroy()
3814 /* Bounce newly-configured block or change in block. */ in tcf_qevent_validate_change()