Lines Matching +full:dont +full:- +full:validate
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * net/sched/ife.c Inter-FE action based on ForCES WG InterFE LFB
6 * draft-ietf-forces-interfelfb-03
9 * "Distributing Linux Traffic Control Classifier-Action
48 if (mi->metaval) in ife_encode_meta_u16()
49 edata = *(u16 *)mi->metaval; in ife_encode_meta_u16()
57 return ife_tlv_meta_encode(skbdata, mi->metaid, 2, &edata); in ife_encode_meta_u16()
63 if (mi->metaval) in ife_get_meta_u32()
64 return nla_put_u32(skb, mi->metaid, *(u32 *)mi->metaval); in ife_get_meta_u32()
66 return nla_put(skb, mi->metaid, 0, NULL); in ife_get_meta_u32()
72 if (metaval || mi->metaval) in ife_check_meta_u32()
81 if (metaval || mi->metaval) in ife_check_meta_u16()
92 if (mi->metaval) in ife_encode_meta_u32()
93 edata = *(u32 *)mi->metaval; in ife_encode_meta_u32()
101 return ife_tlv_meta_encode(skbdata, mi->metaid, 4, &edata); in ife_encode_meta_u32()
107 if (mi->metaval) in ife_get_meta_u16()
108 return nla_put_u16(skb, mi->metaid, *(u16 *)mi->metaval); in ife_get_meta_u16()
110 return nla_put(skb, mi->metaid, 0, NULL); in ife_get_meta_u16()
116 mi->metaval = kmemdup(metaval, sizeof(u32), gfp); in ife_alloc_meta_u32()
117 if (!mi->metaval) in ife_alloc_meta_u32()
118 return -ENOMEM; in ife_alloc_meta_u32()
126 mi->metaval = kmemdup(metaval, sizeof(u16), gfp); in ife_alloc_meta_u16()
127 if (!mi->metaval) in ife_alloc_meta_u16()
128 return -ENOMEM; in ife_alloc_meta_u16()
136 kfree(mi->metaval); in ife_release_meta_gen()
145 return -EINVAL; in ife_validate_meta_u32()
155 return -EINVAL; in ife_validate_meta_u16()
168 if (o->metaid == metaid) { in find_ife_oplist()
169 if (!try_module_get(o->owner)) in find_ife_oplist()
184 if (!mops->metaid || !mops->metatype || !mops->name || in register_ife_op()
185 !mops->check_presence || !mops->encode || !mops->decode || in register_ife_op()
186 !mops->get || !mops->alloc) in register_ife_op()
187 return -EINVAL; in register_ife_op()
192 if (m->metaid == mops->metaid || in register_ife_op()
193 (strcmp(mops->name, m->name) == 0)) { in register_ife_op()
195 return -EEXIST; in register_ife_op()
199 if (!mops->release) in register_ife_op()
200 mops->release = ife_release_meta_gen; in register_ife_op()
202 list_add_tail(&mops->list, &ifeoplist); in register_ife_op()
211 int err = -ENOENT; in unregister_ife_op()
215 if (m->metaid == mops->metaid) { in unregister_ife_op()
216 list_del(&mops->list); in unregister_ife_op()
236 if (ops->validate) in ife_validate_metatype()
237 return ops->validate(val, len); in ife_validate_metatype()
239 if (ops->metatype == NLA_U32) in ife_validate_metatype()
241 else if (ops->metatype == NLA_U16) in ife_validate_metatype()
271 ret = -ENOENT; in load_metaops_and_vet()
275 request_module("ife-meta-%s", ife_meta_id2name(metaid)); in load_metaops_and_vet()
287 module_put(ops->owner); in load_metaops_and_vet()
304 return -ENOMEM; in __add_metainfo()
306 mi->metaid = metaid; in __add_metainfo()
307 mi->ops = ops; in __add_metainfo()
309 ret = ops->alloc(mi, metaval, atomic ? GFP_ATOMIC : GFP_KERNEL); in __add_metainfo()
317 spin_lock_bh(&ife->tcf_lock); in __add_metainfo()
318 list_add_tail(&mi->metalist, &ife->metalist); in __add_metainfo()
320 spin_unlock_bh(&ife->tcf_lock); in __add_metainfo()
331 if (!try_module_get(ops->owner)) in add_metainfo_and_get_ops()
332 return -ENOENT; in add_metainfo_and_get_ops()
335 module_put(ops->owner); in add_metainfo_and_get_ops()
346 return -ENOENT; in add_metainfo()
350 module_put(ops->owner); in add_metainfo()
362 rc = add_metainfo_and_get_ops(o, ife, o->metaid, exists); in use_all_metadata()
371 return -EINVAL; in use_all_metadata()
382 if (list_empty(&ife->metalist)) in dump_metalist()
389 list_for_each_entry(e, &ife->metalist, metalist) { in dump_metalist()
390 if (!e->ops->get(skb, e)) in dump_metalist()
403 return -1; in dump_metalist()
406 /* under ife->tcf_lock */
412 list_for_each_entry_safe(e, n, &ife->metalist, metalist) { in _tcf_ife_cleanup()
413 list_del(&e->metalist); in _tcf_ife_cleanup()
414 if (e->metaval) { in _tcf_ife_cleanup()
415 if (e->ops->release) in _tcf_ife_cleanup()
416 e->ops->release(e); in _tcf_ife_cleanup()
418 kfree(e->metaval); in _tcf_ife_cleanup()
420 module_put(e->ops->owner); in _tcf_ife_cleanup()
430 spin_lock_bh(&ife->tcf_lock); in tcf_ife_cleanup()
432 spin_unlock_bh(&ife->tcf_lock); in tcf_ife_cleanup()
434 p = rcu_dereference_protected(ife->params, 1); in tcf_ife_cleanup()
503 return -EINVAL; in tcf_ife_init()
512 return -EINVAL; in tcf_ife_init()
520 if (parm->flags & ~IFE_ENCODE) in tcf_ife_init()
521 return -EINVAL; in tcf_ife_init()
525 return -ENOMEM; in tcf_ife_init()
542 index = parm->index; in tcf_ife_init()
566 return -EEXIST; in tcf_ife_init()
571 INIT_LIST_HEAD(&ife->metalist); in tcf_ife_init()
573 err = tcf_action_check_ctrlact(parm->action, tp, &goto_ch, extack); in tcf_ife_init()
577 p->flags = parm->flags; in tcf_ife_init()
579 if (parm->flags & IFE_ENCODE) { in tcf_ife_init()
588 if (parm->flags & IFE_ENCODE) { in tcf_ife_init()
590 ether_addr_copy(p->eth_dst, daddr); in tcf_ife_init()
592 eth_zero_addr(p->eth_dst); in tcf_ife_init()
595 ether_addr_copy(p->eth_src, saddr); in tcf_ife_init()
597 eth_zero_addr(p->eth_src); in tcf_ife_init()
599 p->eth_type = ife_type; in tcf_ife_init()
607 /* if no passed metadata allow list or passed allow-all in tcf_ife_init()
618 spin_lock_bh(&ife->tcf_lock); in tcf_ife_init()
620 goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch); in tcf_ife_init()
621 p = rcu_replace_pointer(ife->params, p, 1); in tcf_ife_init()
624 spin_unlock_bh(&ife->tcf_lock); in tcf_ife_init()
647 .index = ife->tcf_index, in tcf_ife_dump()
648 .refcnt = refcount_read(&ife->tcf_refcnt) - ref, in tcf_ife_dump()
649 .bindcnt = atomic_read(&ife->tcf_bindcnt) - bind, in tcf_ife_dump()
653 spin_lock_bh(&ife->tcf_lock); in tcf_ife_dump()
654 opt.action = ife->tcf_action; in tcf_ife_dump()
655 p = rcu_dereference_protected(ife->params, in tcf_ife_dump()
656 lockdep_is_held(&ife->tcf_lock)); in tcf_ife_dump()
657 opt.flags = p->flags; in tcf_ife_dump()
662 tcf_tm_dump(&t, &ife->tcf_tm); in tcf_ife_dump()
666 if (!is_zero_ether_addr(p->eth_dst)) { in tcf_ife_dump()
667 if (nla_put(skb, TCA_IFE_DMAC, ETH_ALEN, p->eth_dst)) in tcf_ife_dump()
671 if (!is_zero_ether_addr(p->eth_src)) { in tcf_ife_dump()
672 if (nla_put(skb, TCA_IFE_SMAC, ETH_ALEN, p->eth_src)) in tcf_ife_dump()
676 if (nla_put(skb, TCA_IFE_TYPE, 2, &p->eth_type)) in tcf_ife_dump()
684 spin_unlock_bh(&ife->tcf_lock); in tcf_ife_dump()
685 return skb->len; in tcf_ife_dump()
688 spin_unlock_bh(&ife->tcf_lock); in tcf_ife_dump()
690 return -1; in tcf_ife_dump()
699 list_for_each_entry(e, &ife->metalist, metalist) { in find_decode_metaid()
700 if (metaid == e->metaid) { in find_decode_metaid()
701 if (e->ops) { in find_decode_metaid()
703 return e->ops->decode(skb, mdata, mlen); in find_decode_metaid()
708 return -ENOENT; in find_decode_metaid()
715 int action = ife->tcf_action; in tcf_ife_decode()
720 bstats_cpu_update(this_cpu_ptr(ife->common.cpu_bstats), skb); in tcf_ife_decode()
721 tcf_lastuse_update(&ife->tcf_tm); in tcf_ife_decode()
724 skb_push(skb, skb->dev->hard_header_len); in tcf_ife_decode()
728 qstats_drop_inc(this_cpu_ptr(ife->common.cpu_qstats)); in tcf_ife_decode()
741 qstats_drop_inc(this_cpu_ptr(ife->common.cpu_qstats)); in tcf_ife_decode()
747 * but dont have an ops for it in tcf_ife_decode()
751 qstats_overlimit_inc(this_cpu_ptr(ife->common.cpu_qstats)); in tcf_ife_decode()
756 qstats_drop_inc(this_cpu_ptr(ife->common.cpu_qstats)); in tcf_ife_decode()
760 skb->protocol = eth_type_trans(skb, skb->dev); in tcf_ife_decode()
774 list_for_each_entry_safe(e, n, &ife->metalist, metalist) { in ife_get_sz()
775 if (e->ops->check_presence) { in ife_get_sz()
776 run_sz = e->ops->check_presence(skb, e); in ife_get_sz()
788 int action = ife->tcf_action; in tcf_ife_encode()
796 int hdrm = metalen + skb->dev->hard_header_len + IFE_METAHDRLEN; in tcf_ife_encode()
798 int new_len = skb->len + hdrm; in tcf_ife_encode()
804 if (new_len > skb->dev->mtu) in tcf_ife_encode()
808 bstats_cpu_update(this_cpu_ptr(ife->common.cpu_bstats), skb); in tcf_ife_encode()
809 tcf_lastuse_update(&ife->tcf_tm); in tcf_ife_encode()
815 qstats_overlimit_inc(this_cpu_ptr(ife->common.cpu_qstats)); in tcf_ife_encode()
821 qstats_drop_inc(this_cpu_ptr(ife->common.cpu_qstats)); in tcf_ife_encode()
826 skb_push(skb, skb->dev->hard_header_len); in tcf_ife_encode()
830 spin_lock(&ife->tcf_lock); in tcf_ife_encode()
832 /* XXX: we dont have a clever way of telling encode to in tcf_ife_encode()
834 * ops->presence_check... in tcf_ife_encode()
836 list_for_each_entry(e, &ife->metalist, metalist) { in tcf_ife_encode()
837 if (e->ops->encode) { in tcf_ife_encode()
838 err = e->ops->encode(skb, (void *)(ife_meta + skboff), in tcf_ife_encode()
843 spin_unlock(&ife->tcf_lock); in tcf_ife_encode()
844 qstats_drop_inc(this_cpu_ptr(ife->common.cpu_qstats)); in tcf_ife_encode()
849 spin_unlock(&ife->tcf_lock); in tcf_ife_encode()
850 oethh = (struct ethhdr *)skb->data; in tcf_ife_encode()
852 if (!is_zero_ether_addr(p->eth_src)) in tcf_ife_encode()
853 ether_addr_copy(oethh->h_source, p->eth_src); in tcf_ife_encode()
854 if (!is_zero_ether_addr(p->eth_dst)) in tcf_ife_encode()
855 ether_addr_copy(oethh->h_dest, p->eth_dst); in tcf_ife_encode()
856 oethh->h_proto = htons(p->eth_type); in tcf_ife_encode()
859 skb_pull(skb, skb->dev->hard_header_len); in tcf_ife_encode()
871 p = rcu_dereference_bh(ife->params); in tcf_ife_act()
872 if (p->flags & IFE_ENCODE) { in tcf_ife_act()
943 MODULE_DESCRIPTION("Inter-FE LFB action");