• Home
  • Raw
  • Download

Lines Matching +full:tp +full:- +full:link

1 // SPDX-License-Identifier: GPL-2.0-or-later
33 struct tcf_proto *tp; member
34 struct list_head link; member
39 static int basic_classify(struct sk_buff *skb, const struct tcf_proto *tp, in basic_classify() argument
43 struct basic_head *head = rcu_dereference_bh(tp->root); in basic_classify()
46 list_for_each_entry_rcu(f, &head->flist, link) { in basic_classify()
47 __this_cpu_inc(f->pf->rcnt); in basic_classify()
48 if (!tcf_em_tree_match(skb, &f->ematches, NULL)) in basic_classify()
50 __this_cpu_inc(f->pf->rhit); in basic_classify()
51 *res = f->res; in basic_classify()
52 r = tcf_exts_exec(skb, &f->exts, res); in basic_classify()
57 return -1; in basic_classify()
60 static void *basic_get(struct tcf_proto *tp, u32 handle) in basic_get() argument
62 struct basic_head *head = rtnl_dereference(tp->root); in basic_get()
65 list_for_each_entry(f, &head->flist, link) { in basic_get()
66 if (f->handle == handle) { in basic_get()
74 static int basic_init(struct tcf_proto *tp) in basic_init() argument
80 return -ENOBUFS; in basic_init()
81 INIT_LIST_HEAD(&head->flist); in basic_init()
82 idr_init(&head->handle_idr); in basic_init()
83 rcu_assign_pointer(tp->root, head); in basic_init()
89 tcf_exts_destroy(&f->exts); in __basic_delete_filter()
90 tcf_em_tree_destroy(&f->ematches); in __basic_delete_filter()
91 tcf_exts_put_net(&f->exts); in __basic_delete_filter()
92 free_percpu(f->pf); in __basic_delete_filter()
106 static void basic_destroy(struct tcf_proto *tp, bool rtnl_held, in basic_destroy() argument
109 struct basic_head *head = rtnl_dereference(tp->root); in basic_destroy()
112 list_for_each_entry_safe(f, n, &head->flist, link) { in basic_destroy()
113 list_del_rcu(&f->link); in basic_destroy()
114 tcf_unbind_filter(tp, &f->res); in basic_destroy()
115 idr_remove(&head->handle_idr, f->handle); in basic_destroy()
116 if (tcf_exts_get_net(&f->exts)) in basic_destroy()
117 tcf_queue_work(&f->rwork, basic_delete_filter_work); in basic_destroy()
121 idr_destroy(&head->handle_idr); in basic_destroy()
125 static int basic_delete(struct tcf_proto *tp, void *arg, bool *last, in basic_delete() argument
128 struct basic_head *head = rtnl_dereference(tp->root); in basic_delete()
131 list_del_rcu(&f->link); in basic_delete()
132 tcf_unbind_filter(tp, &f->res); in basic_delete()
133 idr_remove(&head->handle_idr, f->handle); in basic_delete()
134 tcf_exts_get_net(&f->exts); in basic_delete()
135 tcf_queue_work(&f->rwork, basic_delete_filter_work); in basic_delete()
136 *last = list_empty(&head->flist); in basic_delete()
145 static int basic_set_parms(struct net *net, struct tcf_proto *tp, in basic_set_parms() argument
153 err = tcf_exts_validate(net, tp, tb, est, &f->exts, ovr, true, extack); in basic_set_parms()
157 err = tcf_em_tree_validate(tp, tb[TCA_BASIC_EMATCHES], &f->ematches); in basic_set_parms()
162 f->res.classid = nla_get_u32(tb[TCA_BASIC_CLASSID]); in basic_set_parms()
163 tcf_bind_filter(tp, &f->res, base); in basic_set_parms()
166 f->tp = tp; in basic_set_parms()
171 struct tcf_proto *tp, unsigned long base, u32 handle, in basic_change() argument
176 struct basic_head *head = rtnl_dereference(tp->root); in basic_change()
182 return -EINVAL; in basic_change()
190 if (handle && fold->handle != handle) in basic_change()
191 return -EINVAL; in basic_change()
196 return -ENOBUFS; in basic_change()
198 err = tcf_exts_init(&fnew->exts, net, TCA_BASIC_ACT, TCA_BASIC_POLICE); in basic_change()
204 err = idr_alloc_u32(&head->handle_idr, fnew, &handle, in basic_change()
207 err = idr_alloc_u32(&head->handle_idr, fnew, &handle, in basic_change()
212 fnew->handle = handle; in basic_change()
213 fnew->pf = alloc_percpu(struct tc_basic_pcnt); in basic_change()
214 if (!fnew->pf) { in basic_change()
215 err = -ENOMEM; in basic_change()
219 err = basic_set_parms(net, tp, fnew, base, tb, tca[TCA_RATE], ovr, in basic_change()
223 idr_remove(&head->handle_idr, fnew->handle); in basic_change()
230 idr_replace(&head->handle_idr, fnew, fnew->handle); in basic_change()
231 list_replace_rcu(&fold->link, &fnew->link); in basic_change()
232 tcf_unbind_filter(tp, &fold->res); in basic_change()
233 tcf_exts_get_net(&fold->exts); in basic_change()
234 tcf_queue_work(&fold->rwork, basic_delete_filter_work); in basic_change()
236 list_add_rcu(&fnew->link, &head->flist); in basic_change()
241 free_percpu(fnew->pf); in basic_change()
242 tcf_exts_destroy(&fnew->exts); in basic_change()
247 static void basic_walk(struct tcf_proto *tp, struct tcf_walker *arg, in basic_walk() argument
250 struct basic_head *head = rtnl_dereference(tp->root); in basic_walk()
253 list_for_each_entry(f, &head->flist, link) { in basic_walk()
254 if (arg->count < arg->skip) in basic_walk()
257 if (arg->fn(tp, f, arg) < 0) { in basic_walk()
258 arg->stop = 1; in basic_walk()
262 arg->count++; in basic_walk()
271 if (f && f->res.classid == classid) { in basic_bind_class()
273 __tcf_bind_filter(q, &f->res, base); in basic_bind_class()
275 __tcf_unbind_filter(q, &f->res); in basic_bind_class()
279 static int basic_dump(struct net *net, struct tcf_proto *tp, void *fh, in basic_dump() argument
288 return skb->len; in basic_dump()
290 t->tcm_handle = f->handle; in basic_dump()
296 if (f->res.classid && in basic_dump()
297 nla_put_u32(skb, TCA_BASIC_CLASSID, f->res.classid)) in basic_dump()
301 struct tc_basic_pcnt *pf = per_cpu_ptr(f->pf, cpu); in basic_dump()
303 gpf.rcnt += pf->rcnt; in basic_dump()
304 gpf.rhit += pf->rhit; in basic_dump()
312 if (tcf_exts_dump(skb, &f->exts) < 0 || in basic_dump()
313 tcf_em_tree_dump(skb, &f->ematches, TCA_BASIC_EMATCHES) < 0) in basic_dump()
318 if (tcf_exts_dump_stats(skb, &f->exts) < 0) in basic_dump()
321 return skb->len; in basic_dump()
325 return -1; in basic_dump()