Lines Matching +full:im +full:-
1 // SPDX-License-Identifier: GPL-2.0-or-later
42 static int check_match(struct net *net, struct em_ipt_match *im, int mdata_len) in check_match() argument
52 mtpar.hook_mask = 1 << im->hook; in check_match()
53 mtpar.family = im->match->family; in check_match()
54 mtpar.match = im->match; in check_match()
56 mtpar.matchinfo = (void *)im->match_data; in check_match()
64 return -EINVAL; in policy_validate_match_data()
69 return -EINVAL; in policy_validate_match_data()
79 return -EINVAL; in addrtype_validate_match_data()
105 for (m = em_ipt_xt_matches; m->match_name; m++) { in get_xt_match()
106 if (!nla_strcmp(mname_attr, m->match_name)) in get_xt_match()
110 if (!m->match_name) { in get_xt_match()
112 return ERR_PTR(-EINVAL); in get_xt_match()
118 ret = m->validate_match_data(tb, mrev); in get_xt_match()
123 return xt_request_find_match(nfproto, m->match_name, mrev); in get_xt_match()
130 struct em_ipt_match *im = NULL; in em_ipt_change() local
142 return -EINVAL; in em_ipt_change()
150 return -EINVAL; in em_ipt_change()
160 im = kzalloc(sizeof(*im) + mdata_len, GFP_KERNEL); in em_ipt_change()
161 if (!im) { in em_ipt_change()
162 ret = -ENOMEM; in em_ipt_change()
166 im->match = match; in em_ipt_change()
167 im->hook = nla_get_u32(tb[TCA_EM_IPT_HOOK]); in em_ipt_change()
168 im->nfproto = nfproto; in em_ipt_change()
169 nla_memcpy(im->match_data, tb[TCA_EM_IPT_MATCH_DATA], mdata_len); in em_ipt_change()
171 ret = check_match(net, im, mdata_len); in em_ipt_change()
175 em->datalen = sizeof(*im) + mdata_len; in em_ipt_change()
176 em->data = (unsigned long)im; in em_ipt_change()
180 kfree(im); in em_ipt_change()
181 module_put(match->me); in em_ipt_change()
187 struct em_ipt_match *im = (void *)em->data; in em_ipt_destroy() local
189 if (!im) in em_ipt_destroy()
192 if (im->match->destroy) { in em_ipt_destroy()
194 .net = em->net, in em_ipt_destroy()
195 .match = im->match, in em_ipt_destroy()
196 .matchinfo = im->match_data, in em_ipt_destroy()
197 .family = im->match->family in em_ipt_destroy()
199 im->match->destroy(&par); in em_ipt_destroy()
201 module_put(im->match->me); in em_ipt_destroy()
202 kfree(im); in em_ipt_destroy()
208 const struct em_ipt_match *im = (const void *)em->data; in em_ipt_match() local
211 u8 nfproto = im->match->family; in em_ipt_match()
234 if (skb->skb_iif) in em_ipt_match()
235 indev = dev_get_by_index_rcu(em->net, skb->skb_iif); in em_ipt_match()
237 nf_hook_state_init(&state, im->hook, nfproto, in em_ipt_match()
238 indev ?: skb->dev, skb->dev, NULL, em->net, NULL); in em_ipt_match()
240 acpar.match = im->match; in em_ipt_match()
241 acpar.matchinfo = im->match_data; in em_ipt_match()
244 ret = im->match->match(skb, &acpar); in em_ipt_match()
252 struct em_ipt_match *im = (void *)em->data; in em_ipt_dump() local
254 if (nla_put_string(skb, TCA_EM_IPT_MATCH_NAME, im->match->name) < 0) in em_ipt_dump()
255 return -EMSGSIZE; in em_ipt_dump()
256 if (nla_put_u32(skb, TCA_EM_IPT_HOOK, im->hook) < 0) in em_ipt_dump()
257 return -EMSGSIZE; in em_ipt_dump()
258 if (nla_put_u8(skb, TCA_EM_IPT_MATCH_REVISION, im->match->revision) < 0) in em_ipt_dump()
259 return -EMSGSIZE; in em_ipt_dump()
260 if (nla_put_u8(skb, TCA_EM_IPT_NFPROTO, im->nfproto) < 0) in em_ipt_dump()
261 return -EMSGSIZE; in em_ipt_dump()
263 im->match->usersize ?: im->match->matchsize, in em_ipt_dump()
264 im->match_data) < 0) in em_ipt_dump()
265 return -EMSGSIZE; in em_ipt_dump()