Lines Matching full:chain
54 const struct tcf_chain *chain; member
91 n->chain_index = tp->chain->index; in tcf_exts_miss_cookie_base_alloc()
92 n->chain = tp->chain; in tcf_exts_miss_cookie_base_alloc()
174 return jhash_3words(tp->chain->index, tp->prio, in destroy_obj_hashfn()
178 static void tcf_proto_signal_destroying(struct tcf_chain *chain, in tcf_proto_signal_destroying() argument
181 struct tcf_block *block = chain->block; in tcf_proto_signal_destroying()
192 return tp1->chain->index == tp2->chain->index && in tcf_proto_cmp()
197 static bool tcf_proto_exists_destroying(struct tcf_chain *chain, in tcf_proto_exists_destroying() argument
205 hash_for_each_possible_rcu(chain->block->proto_destroy_ht, iter, in tcf_proto_exists_destroying()
218 tcf_proto_signal_destroyed(struct tcf_chain *chain, struct tcf_proto *tp) in tcf_proto_signal_destroyed() argument
220 struct tcf_block *block = chain->block; in tcf_proto_signal_destroyed()
373 u32 prio, struct tcf_chain *chain, in tcf_proto_create() argument
392 tp->chain = chain; in tcf_proto_create()
448 static void tcf_chain_put(struct tcf_chain *chain);
454 tcf_block_filter_cnt_update(tp->chain->block, &tp->counted, false); in tcf_proto_destroy()
456 tcf_proto_signal_destroyed(tp->chain, tp); in tcf_proto_destroy()
457 tcf_chain_put(tp->chain); in tcf_proto_destroy()
508 struct tcf_chain *chain; in tcf_chain_create() local
512 chain = kzalloc(sizeof(*chain), GFP_KERNEL); in tcf_chain_create()
513 if (!chain) in tcf_chain_create()
515 list_add_tail_rcu(&chain->list, &block->chain_list); in tcf_chain_create()
516 mutex_init(&chain->filter_chain_lock); in tcf_chain_create()
517 chain->block = block; in tcf_chain_create()
518 chain->index = chain_index; in tcf_chain_create()
519 chain->refcnt = 1; in tcf_chain_create()
520 if (!chain->index) in tcf_chain_create()
521 block->chain0.chain = chain; in tcf_chain_create()
522 return chain; in tcf_chain_create()
532 static void tcf_chain0_head_change(struct tcf_chain *chain, in tcf_chain0_head_change() argument
536 struct tcf_block *block = chain->block; in tcf_chain0_head_change()
538 if (chain->index) in tcf_chain0_head_change()
549 static bool tcf_chain_detach(struct tcf_chain *chain) in tcf_chain_detach() argument
551 struct tcf_block *block = chain->block; in tcf_chain_detach()
555 list_del_rcu(&chain->list); in tcf_chain_detach()
556 if (!chain->index) in tcf_chain_detach()
557 block->chain0.chain = NULL; in tcf_chain_detach()
574 static void tcf_chain_destroy(struct tcf_chain *chain, bool free_block) in tcf_chain_destroy() argument
576 struct tcf_block *block = chain->block; in tcf_chain_destroy()
578 mutex_destroy(&chain->filter_chain_lock); in tcf_chain_destroy()
579 kfree_rcu(chain, rcu); in tcf_chain_destroy()
584 static void tcf_chain_hold(struct tcf_chain *chain) in tcf_chain_hold() argument
586 ASSERT_BLOCK_LOCKED(chain->block); in tcf_chain_hold()
588 ++chain->refcnt; in tcf_chain_hold()
591 static bool tcf_chain_held_by_acts_only(struct tcf_chain *chain) in tcf_chain_held_by_acts_only() argument
593 ASSERT_BLOCK_LOCKED(chain->block); in tcf_chain_held_by_acts_only()
596 * chain should not be shown to the user. in tcf_chain_held_by_acts_only()
598 return chain->refcnt == chain->action_refcnt; in tcf_chain_held_by_acts_only()
604 struct tcf_chain *chain; in tcf_chain_lookup() local
608 list_for_each_entry(chain, &block->chain_list, list) { in tcf_chain_lookup()
609 if (chain->index == chain_index) in tcf_chain_lookup()
610 return chain; in tcf_chain_lookup()
619 struct tcf_chain *chain; in tcf_chain_lookup_rcu() local
621 list_for_each_entry_rcu(chain, &block->chain_list, list) { in tcf_chain_lookup_rcu()
622 if (chain->index == chain_index) in tcf_chain_lookup_rcu()
623 return chain; in tcf_chain_lookup_rcu()
629 static int tc_chain_notify(struct tcf_chain *chain, struct sk_buff *oskb,
637 struct tcf_chain *chain = NULL; in __tcf_chain_get() local
641 chain = tcf_chain_lookup(block, chain_index); in __tcf_chain_get()
642 if (chain) { in __tcf_chain_get()
643 tcf_chain_hold(chain); in __tcf_chain_get()
647 chain = tcf_chain_create(block, chain_index); in __tcf_chain_get()
648 if (!chain) in __tcf_chain_get()
653 ++chain->action_refcnt; in __tcf_chain_get()
654 is_first_reference = chain->refcnt - chain->action_refcnt == 1; in __tcf_chain_get()
658 * non-action reference. Until then, the chain acts only as in __tcf_chain_get()
663 tc_chain_notify(chain, NULL, 0, NLM_F_CREATE | NLM_F_EXCL, in __tcf_chain_get()
666 return chain; in __tcf_chain_get()
670 return chain; in __tcf_chain_get()
692 static void __tcf_chain_put(struct tcf_chain *chain, bool by_act, in __tcf_chain_put() argument
695 struct tcf_block *block = chain->block; in __tcf_chain_put()
703 if (!chain->explicitly_created) { in __tcf_chain_put()
707 chain->explicitly_created = false; in __tcf_chain_put()
711 chain->action_refcnt--; in __tcf_chain_put()
714 * However, when block is unlocked chain can be changed concurrently, so in __tcf_chain_put()
717 refcnt = --chain->refcnt; in __tcf_chain_put()
718 non_act_refcnt = refcnt - chain->action_refcnt; in __tcf_chain_put()
719 tmplt_ops = chain->tmplt_ops; in __tcf_chain_put()
720 tmplt_priv = chain->tmplt_priv; in __tcf_chain_put()
722 if (non_act_refcnt == chain->explicitly_created && !by_act) { in __tcf_chain_put()
725 chain->index, block, NULL, 0, 0); in __tcf_chain_put()
726 /* Last reference to chain, no need to lock. */ in __tcf_chain_put()
727 chain->flushing = false; in __tcf_chain_put()
731 free_block = tcf_chain_detach(chain); in __tcf_chain_put()
736 tcf_chain_destroy(chain, free_block); in __tcf_chain_put()
740 static void tcf_chain_put(struct tcf_chain *chain) in tcf_chain_put() argument
742 __tcf_chain_put(chain, false, false); in tcf_chain_put()
745 void tcf_chain_put_by_act(struct tcf_chain *chain) in tcf_chain_put_by_act() argument
747 __tcf_chain_put(chain, true, false); in tcf_chain_put_by_act()
751 static void tcf_chain_put_explicitly_created(struct tcf_chain *chain) in tcf_chain_put_explicitly_created() argument
753 __tcf_chain_put(chain, false, true); in tcf_chain_put_explicitly_created()
756 static void tcf_chain_flush(struct tcf_chain *chain, bool rtnl_held) in tcf_chain_flush() argument
760 mutex_lock(&chain->filter_chain_lock); in tcf_chain_flush()
761 tp = tcf_chain_dereference(chain->filter_chain, chain); in tcf_chain_flush()
764 tcf_proto_signal_destroying(chain, tp); in tcf_chain_flush()
767 tp = tcf_chain_dereference(chain->filter_chain, chain); in tcf_chain_flush()
768 RCU_INIT_POINTER(chain->filter_chain, NULL); in tcf_chain_flush()
769 tcf_chain0_head_change(chain, NULL); in tcf_chain_flush()
770 chain->flushing = true; in tcf_chain_flush()
771 mutex_unlock(&chain->filter_chain_lock); in tcf_chain_flush()
937 chain0 = block->chain0.chain; in tcf_chain0_head_change_cb_add()
975 if (block->chain0.chain) in tcf_chain0_head_change_cb_del()
1072 __tcf_get_next_chain(struct tcf_block *block, struct tcf_chain *chain) in __tcf_get_next_chain() argument
1075 if (chain) in __tcf_get_next_chain()
1076 chain = list_is_last(&chain->list, &block->chain_list) ? in __tcf_get_next_chain()
1077 NULL : list_next_entry(chain, list); in __tcf_get_next_chain()
1079 chain = list_first_entry_or_null(&block->chain_list, in __tcf_get_next_chain()
1083 while (chain && tcf_chain_held_by_acts_only(chain)) in __tcf_get_next_chain()
1084 chain = list_is_last(&chain->list, &block->chain_list) ? in __tcf_get_next_chain()
1085 NULL : list_next_entry(chain, list); in __tcf_get_next_chain()
1087 if (chain) in __tcf_get_next_chain()
1088 tcf_chain_hold(chain); in __tcf_get_next_chain()
1091 return chain; in __tcf_get_next_chain()
1095 * block. It properly obtains block->lock and takes reference to chain before
1096 * returning it. Users of this function must be tolerant to concurrent chain
1097 * insertion/deletion or ensure that no concurrent chain modification is
1104 tcf_get_next_chain(struct tcf_block *block, struct tcf_chain *chain) in tcf_get_next_chain() argument
1106 struct tcf_chain *chain_next = __tcf_get_next_chain(block, chain); in tcf_get_next_chain()
1108 if (chain) in tcf_get_next_chain()
1109 tcf_chain_put(chain); in tcf_get_next_chain()
1116 __tcf_get_next_proto(struct tcf_chain *chain, struct tcf_proto *tp) in __tcf_get_next_proto() argument
1121 mutex_lock(&chain->filter_chain_lock); in __tcf_get_next_proto()
1124 tp = tcf_chain_dereference(chain->filter_chain, chain); in __tcf_get_next_proto()
1126 /* 'deleting' flag is set and chain->filter_chain_lock was in __tcf_get_next_proto()
1131 tp = tcf_chain_dereference(chain->filter_chain, chain); in __tcf_get_next_proto()
1133 for (; tp; tp = tcf_chain_dereference(tp->next, chain)) in __tcf_get_next_proto()
1137 tp = tcf_chain_dereference(tp->next, chain); in __tcf_get_next_proto()
1143 mutex_unlock(&chain->filter_chain_lock); in __tcf_get_next_proto()
1149 * chain. Users of this function must be tolerant to concurrent tp
1150 * insertion/deletion or ensure that no concurrent chain modification is
1157 tcf_get_next_proto(struct tcf_chain *chain, struct tcf_proto *tp) in tcf_get_next_proto() argument
1159 struct tcf_proto *tp_next = __tcf_get_next_proto(chain, tp); in tcf_get_next_proto()
1170 struct tcf_chain *chain; in tcf_block_flush_all_chains() local
1175 for (chain = tcf_get_next_chain(block, NULL); in tcf_block_flush_all_chains()
1176 chain; in tcf_block_flush_all_chains()
1177 chain = tcf_get_next_chain(block, chain)) { in tcf_block_flush_all_chains()
1178 tcf_chain_put_explicitly_created(chain); in tcf_block_flush_all_chains()
1179 tcf_chain_flush(chain, rtnl_held); in tcf_block_flush_all_chains()
1324 * deallocated when last chain is freed. However, if chain_list in __tcf_block_put()
1554 /* XXX: Standalone actions are not allowed to jump to any chain, and bound
1589 struct tcf_chain *chain, *chain_prev; in tcf_block_playback_offloads() local
1595 for (chain = __tcf_get_next_chain(block, NULL); in tcf_block_playback_offloads()
1596 chain; in tcf_block_playback_offloads()
1597 chain_prev = chain, in tcf_block_playback_offloads()
1598 chain = __tcf_get_next_chain(block, chain), in tcf_block_playback_offloads()
1600 if (chain->tmplt_ops && add) in tcf_block_playback_offloads()
1601 chain->tmplt_ops->tmplt_reoffload(chain, true, cb, in tcf_block_playback_offloads()
1603 for (tp = __tcf_get_next_proto(chain, NULL); tp; in tcf_block_playback_offloads()
1605 tp = __tcf_get_next_proto(chain, tp), in tcf_block_playback_offloads()
1618 if (chain->tmplt_ops && !add) in tcf_block_playback_offloads()
1619 chain->tmplt_ops->tmplt_reoffload(chain, false, cb, in tcf_block_playback_offloads()
1627 tcf_chain_put(chain); in tcf_block_playback_offloads()
1715 /* Main classifier routine: scans classifier chain attached
1745 /* We re-lookup the tp and chain based on index instead in __tcf_classify()
1747 * check if any of tp,chain,exts was replaced by the in __tcf_classify()
1750 if (unlikely(n->tp != tp || n->tp->chain != n->chain || in __tcf_classify()
1776 *last_executed_chain = first_tp->chain->index; in __tcf_classify()
1799 tp->chain->block->index, in __tcf_classify()
1823 u32 last_executed_chain = tp ? tp->chain->index : 0; in tcf_classify()
1833 if (ext && (ext->chain || ext->act_miss)) { in tcf_classify()
1835 u32 chain; in tcf_classify()
1846 chain = n->chain_index; in tcf_classify()
1848 chain = ext->chain; in tcf_classify()
1851 fchain = tcf_chain_lookup_rcu(block, chain); in tcf_classify()
1871 /* If we missed on some chain */ in tcf_classify()
1880 ext->chain = last_executed_chain; in tcf_classify()
1899 static struct tcf_proto *tcf_chain_tp_prev(struct tcf_chain *chain, in tcf_chain_tp_prev() argument
1902 return tcf_chain_dereference(*chain_info->pprev, chain); in tcf_chain_tp_prev()
1905 static int tcf_chain_tp_insert(struct tcf_chain *chain, in tcf_chain_tp_insert() argument
1909 if (chain->flushing) in tcf_chain_tp_insert()
1912 RCU_INIT_POINTER(tp->next, tcf_chain_tp_prev(chain, chain_info)); in tcf_chain_tp_insert()
1913 if (*chain_info->pprev == chain->filter_chain) in tcf_chain_tp_insert()
1914 tcf_chain0_head_change(chain, tp); in tcf_chain_tp_insert()
1921 static void tcf_chain_tp_remove(struct tcf_chain *chain, in tcf_chain_tp_remove() argument
1925 struct tcf_proto *next = tcf_chain_dereference(chain_info->next, chain); in tcf_chain_tp_remove()
1928 if (tp == chain->filter_chain) in tcf_chain_tp_remove()
1929 tcf_chain0_head_change(chain, next); in tcf_chain_tp_remove()
1933 static struct tcf_proto *tcf_chain_tp_find(struct tcf_chain *chain,
1943 static struct tcf_proto *tcf_chain_tp_insert_unique(struct tcf_chain *chain, in tcf_chain_tp_insert_unique() argument
1952 mutex_lock(&chain->filter_chain_lock); in tcf_chain_tp_insert_unique()
1954 if (tcf_proto_exists_destroying(chain, tp_new)) { in tcf_chain_tp_insert_unique()
1955 mutex_unlock(&chain->filter_chain_lock); in tcf_chain_tp_insert_unique()
1960 tp = tcf_chain_tp_find(chain, &chain_info, in tcf_chain_tp_insert_unique()
1963 err = tcf_chain_tp_insert(chain, &chain_info, tp_new); in tcf_chain_tp_insert_unique()
1964 mutex_unlock(&chain->filter_chain_lock); in tcf_chain_tp_insert_unique()
1977 static void tcf_chain_tp_delete_empty(struct tcf_chain *chain, in tcf_chain_tp_delete_empty() argument
1986 mutex_lock(&chain->filter_chain_lock); in tcf_chain_tp_delete_empty()
1988 /* Atomically find and remove tp from chain. */ in tcf_chain_tp_delete_empty()
1989 for (pprev = &chain->filter_chain; in tcf_chain_tp_delete_empty()
1990 (tp_iter = tcf_chain_dereference(*pprev, chain)); in tcf_chain_tp_delete_empty()
2004 mutex_unlock(&chain->filter_chain_lock); in tcf_chain_tp_delete_empty()
2008 tcf_proto_signal_destroying(chain, tp); in tcf_chain_tp_delete_empty()
2009 next = tcf_chain_dereference(chain_info.next, chain); in tcf_chain_tp_delete_empty()
2010 if (tp == chain->filter_chain) in tcf_chain_tp_delete_empty()
2011 tcf_chain0_head_change(chain, next); in tcf_chain_tp_delete_empty()
2013 mutex_unlock(&chain->filter_chain_lock); in tcf_chain_tp_delete_empty()
2018 static struct tcf_proto *tcf_chain_tp_find(struct tcf_chain *chain, in tcf_chain_tp_find() argument
2026 /* Check the chain for existence of proto-tcf with this priority */ in tcf_chain_tp_find()
2027 for (pprev = &chain->filter_chain; in tcf_chain_tp_find()
2028 (tp = tcf_chain_dereference(*pprev, chain)); in tcf_chain_tp_find()
2079 if (nla_put_u32(skb, TCA_CHAIN, tp->chain->index)) in tcf_fill_node()
2186 struct tcf_chain *chain, int event, in tfilter_notify_chain() argument
2191 for (tp = tcf_get_next_proto(chain, NULL); in tfilter_notify_chain()
2192 tp; tp = tcf_get_next_proto(chain, tp)) in tfilter_notify_chain()
2222 struct tcf_chain *chain; in tc_new_tfilter() local
2249 chain = NULL; in tc_new_tfilter()
2265 /* Find head of filter chain. */ in tc_new_tfilter()
2302 NL_SET_ERR_MSG(extack, "Specified chain index exceeds upper limit"); in tc_new_tfilter()
2306 chain = tcf_chain_get(block, chain_index, true); in tc_new_tfilter()
2307 if (!chain) { in tc_new_tfilter()
2308 NL_SET_ERR_MSG(extack, "Cannot create specified filter chain"); in tc_new_tfilter()
2313 mutex_lock(&chain->filter_chain_lock); in tc_new_tfilter()
2314 tp = tcf_chain_tp_find(chain, &chain_info, protocol, in tc_new_tfilter()
2325 if (chain->flushing) { in tc_new_tfilter()
2345 prio = tcf_auto_prio(tcf_chain_tp_prev(chain, in tc_new_tfilter()
2348 mutex_unlock(&chain->filter_chain_lock); in tc_new_tfilter()
2349 tp_new = tcf_proto_create(name, protocol, prio, chain, in tc_new_tfilter()
2357 tp = tcf_chain_tp_insert_unique(chain, tp_new, protocol, prio, in tc_new_tfilter()
2364 mutex_unlock(&chain->filter_chain_lock); in tc_new_tfilter()
2388 if (chain->tmplt_ops && chain->tmplt_ops != tp->ops) { in tc_new_tfilter()
2390 NL_SET_ERR_MSG(extack, "Chain template is set to a different filter kind"); in tc_new_tfilter()
2415 tcf_chain_tp_delete_empty(chain, tp, rtnl_held, NULL); in tc_new_tfilter()
2417 if (chain) { in tc_new_tfilter()
2421 tcf_chain_put(chain); in tc_new_tfilter()
2430 * of target chain. in tc_new_tfilter()
2439 mutex_unlock(&chain->filter_chain_lock); in tc_new_tfilter()
2456 struct tcf_chain *chain = NULL; in tc_del_tfilter() local
2479 /* Find head of filter chain. */ in tc_del_tfilter()
2490 /* Take rtnl mutex if flushing whole chain, block is shared (no qdisc in tc_del_tfilter()
2514 NL_SET_ERR_MSG(extack, "Specified chain index exceeds upper limit"); in tc_del_tfilter()
2518 chain = tcf_chain_get(block, chain_index, false); in tc_del_tfilter()
2519 if (!chain) { in tc_del_tfilter()
2520 /* User requested flush on non-existent chain. Nothing to do, in tc_del_tfilter()
2527 NL_SET_ERR_MSG(extack, "Cannot find specified filter chain"); in tc_del_tfilter()
2534 chain, RTM_DELTFILTER, extack); in tc_del_tfilter()
2535 tcf_chain_flush(chain, rtnl_held); in tc_del_tfilter()
2540 mutex_lock(&chain->filter_chain_lock); in tc_del_tfilter()
2541 tp = tcf_chain_tp_find(chain, &chain_info, protocol, in tc_del_tfilter()
2552 tcf_proto_signal_destroying(chain, tp); in tc_del_tfilter()
2553 tcf_chain_tp_remove(chain, &chain_info, tp); in tc_del_tfilter()
2554 mutex_unlock(&chain->filter_chain_lock); in tc_del_tfilter()
2562 mutex_unlock(&chain->filter_chain_lock); in tc_del_tfilter()
2578 tcf_chain_tp_delete_empty(chain, tp, rtnl_held, extack); in tc_del_tfilter()
2582 if (chain) { in tc_del_tfilter()
2585 tcf_chain_put(chain); in tc_del_tfilter()
2595 mutex_unlock(&chain->filter_chain_lock); in tc_del_tfilter()
2612 struct tcf_chain *chain = NULL; in tc_get_tfilter() local
2635 /* Find head of filter chain. */ in tc_get_tfilter()
2669 NL_SET_ERR_MSG(extack, "Specified chain index exceeds upper limit"); in tc_get_tfilter()
2673 chain = tcf_chain_get(block, chain_index, false); in tc_get_tfilter()
2674 if (!chain) { in tc_get_tfilter()
2675 NL_SET_ERR_MSG(extack, "Cannot find specified filter chain"); in tc_get_tfilter()
2680 mutex_lock(&chain->filter_chain_lock); in tc_get_tfilter()
2681 tp = tcf_chain_tp_find(chain, &chain_info, protocol, in tc_get_tfilter()
2683 mutex_unlock(&chain->filter_chain_lock); in tc_get_tfilter()
2708 if (chain) { in tc_get_tfilter()
2711 tcf_chain_put(chain); in tc_get_tfilter()
2742 static bool tcf_chain_dump(struct tcf_chain *chain, struct Qdisc *q, u32 parent, in tcf_chain_dump() argument
2747 struct tcf_block *block = chain->block; in tcf_chain_dump()
2752 for (tp = __tcf_get_next_proto(chain, NULL); in tcf_chain_dump()
2755 tp = __tcf_get_next_proto(chain, tp), in tcf_chain_dump()
2811 struct tcf_chain *chain, *chain_prev; in tc_dump_tfilter() local
2886 for (chain = __tcf_get_next_chain(block, NULL); in tc_dump_tfilter()
2887 chain; in tc_dump_tfilter()
2888 chain_prev = chain, in tc_dump_tfilter()
2889 chain = __tcf_get_next_chain(block, chain), in tc_dump_tfilter()
2892 nla_get_u32(tca[TCA_CHAIN]) != chain->index) in tc_dump_tfilter()
2894 if (!tcf_chain_dump(chain, q, parent, skb, cb, in tc_dump_tfilter()
2896 tcf_chain_put(chain); in tc_dump_tfilter()
2969 static int tc_chain_notify(struct tcf_chain *chain, struct sk_buff *oskb, in tc_chain_notify() argument
2974 struct tcf_block *block = chain->block; in tc_chain_notify()
2986 if (tc_chain_fill_node(chain->tmplt_ops, chain->tmplt_priv, in tc_chain_notify()
2987 chain->index, net, skb, block, portid, in tc_chain_notify()
3027 static int tc_chain_tmplt_add(struct tcf_chain *chain, struct net *net, in tc_chain_tmplt_add() argument
3040 NL_SET_ERR_MSG(extack, "Specified TC chain template name too long"); in tc_chain_tmplt_add()
3049 NL_SET_ERR_MSG(extack, "Chain templates are not supported with specified classifier"); in tc_chain_tmplt_add()
3054 tmplt_priv = ops->tmplt_create(net, chain, tca, extack); in tc_chain_tmplt_add()
3059 chain->tmplt_ops = ops; in tc_chain_tmplt_add()
3060 chain->tmplt_priv = tmplt_priv; in tc_chain_tmplt_add()
3075 /* Add/delete/get a chain */
3086 struct tcf_chain *chain; in tc_ctl_chain() local
3109 NL_SET_ERR_MSG(extack, "Specified chain index exceeds upper limit"); in tc_ctl_chain()
3115 chain = tcf_chain_lookup(block, chain_index); in tc_ctl_chain()
3117 if (chain) { in tc_ctl_chain()
3118 if (tcf_chain_held_by_acts_only(chain)) { in tc_ctl_chain()
3119 /* The chain exists only because there is in tc_ctl_chain()
3122 tcf_chain_hold(chain); in tc_ctl_chain()
3124 NL_SET_ERR_MSG(extack, "Filter chain already exists"); in tc_ctl_chain()
3130 NL_SET_ERR_MSG(extack, "Need both RTM_NEWCHAIN and NLM_F_CREATE to create a new chain"); in tc_ctl_chain()
3134 chain = tcf_chain_create(block, chain_index); in tc_ctl_chain()
3135 if (!chain) { in tc_ctl_chain()
3136 NL_SET_ERR_MSG(extack, "Failed to create filter chain"); in tc_ctl_chain()
3142 if (!chain || tcf_chain_held_by_acts_only(chain)) { in tc_ctl_chain()
3143 NL_SET_ERR_MSG(extack, "Cannot find specified filter chain"); in tc_ctl_chain()
3147 tcf_chain_hold(chain); in tc_ctl_chain()
3151 /* Modifying chain requires holding parent block lock. In case in tc_ctl_chain()
3152 * the chain was successfully added, take a reference to the in tc_ctl_chain()
3153 * chain. This ensures that an empty chain does not disappear at in tc_ctl_chain()
3156 tcf_chain_hold(chain); in tc_ctl_chain()
3157 chain->explicitly_created = true; in tc_ctl_chain()
3163 err = tc_chain_tmplt_add(chain, net, tca, extack); in tc_ctl_chain()
3165 tcf_chain_put_explicitly_created(chain); in tc_ctl_chain()
3169 tc_chain_notify(chain, NULL, 0, NLM_F_CREATE | NLM_F_EXCL, in tc_ctl_chain()
3174 chain, RTM_DELTFILTER, extack); in tc_ctl_chain()
3175 /* Flush the chain first as the user requested chain removal. */ in tc_ctl_chain()
3176 tcf_chain_flush(chain, true); in tc_ctl_chain()
3177 /* In case the chain was successfully deleted, put a reference in tc_ctl_chain()
3178 * to the chain previously taken during addition. in tc_ctl_chain()
3180 tcf_chain_put_explicitly_created(chain); in tc_ctl_chain()
3183 err = tc_chain_notify(chain, skb, n->nlmsg_seq, in tc_ctl_chain()
3186 NL_SET_ERR_MSG(extack, "Failed to send chain notify message"); in tc_ctl_chain()
3195 tcf_chain_put(chain); in tc_ctl_chain()
3216 struct tcf_chain *chain; in tc_dump_chain() local
3270 list_for_each_entry(chain, &block->chain_list, list) { in tc_dump_chain()
3272 nla_get_u32(tca[TCA_CHAIN]) != chain->index)) in tc_dump_chain()
3278 if (tcf_chain_held_by_acts_only(chain)) in tc_dump_chain()
3280 err = tc_chain_fill_node(chain->tmplt_ops, chain->tmplt_priv, in tc_dump_chain()
3281 chain->index, net, skb, block, in tc_dump_chain()