Lines Matching refs:attrs
37 static int verify_one_alg(struct nlattr **attrs, enum xfrm_attr_type_t type) in verify_one_alg() argument
39 struct nlattr *rt = attrs[type]; in verify_one_alg()
63 static int verify_auth_trunc(struct nlattr **attrs) in verify_auth_trunc() argument
65 struct nlattr *rt = attrs[XFRMA_ALG_AUTH_TRUNC]; in verify_auth_trunc()
79 static int verify_aead(struct nlattr **attrs) in verify_aead() argument
81 struct nlattr *rt = attrs[XFRMA_ALG_AEAD]; in verify_aead()
95 static void verify_one_addr(struct nlattr **attrs, enum xfrm_attr_type_t type, in verify_one_addr() argument
98 struct nlattr *rt = attrs[type]; in verify_one_addr()
104 static inline int verify_sec_ctx_len(struct nlattr **attrs) in verify_sec_ctx_len() argument
106 struct nlattr *rt = attrs[XFRMA_SEC_CTX]; in verify_sec_ctx_len()
121 struct nlattr **attrs) in verify_replay() argument
123 struct nlattr *rt = attrs[XFRMA_REPLAY_ESN_VAL]; in verify_replay()
149 struct nlattr **attrs) in verify_newsa_info() argument
198 if ((!attrs[XFRMA_ALG_AUTH] && in verify_newsa_info()
199 !attrs[XFRMA_ALG_AUTH_TRUNC]) || in verify_newsa_info()
200 attrs[XFRMA_ALG_AEAD] || in verify_newsa_info()
201 attrs[XFRMA_ALG_CRYPT] || in verify_newsa_info()
202 attrs[XFRMA_ALG_COMP] || in verify_newsa_info()
203 attrs[XFRMA_TFCPAD]) in verify_newsa_info()
208 if (attrs[XFRMA_ALG_COMP]) in verify_newsa_info()
210 if (!attrs[XFRMA_ALG_AUTH] && in verify_newsa_info()
211 !attrs[XFRMA_ALG_AUTH_TRUNC] && in verify_newsa_info()
212 !attrs[XFRMA_ALG_CRYPT] && in verify_newsa_info()
213 !attrs[XFRMA_ALG_AEAD]) in verify_newsa_info()
215 if ((attrs[XFRMA_ALG_AUTH] || in verify_newsa_info()
216 attrs[XFRMA_ALG_AUTH_TRUNC] || in verify_newsa_info()
217 attrs[XFRMA_ALG_CRYPT]) && in verify_newsa_info()
218 attrs[XFRMA_ALG_AEAD]) in verify_newsa_info()
220 if (attrs[XFRMA_TFCPAD] && in verify_newsa_info()
226 if (!attrs[XFRMA_ALG_COMP] || in verify_newsa_info()
227 attrs[XFRMA_ALG_AEAD] || in verify_newsa_info()
228 attrs[XFRMA_ALG_AUTH] || in verify_newsa_info()
229 attrs[XFRMA_ALG_AUTH_TRUNC] || in verify_newsa_info()
230 attrs[XFRMA_ALG_CRYPT] || in verify_newsa_info()
231 attrs[XFRMA_TFCPAD] || in verify_newsa_info()
239 if (attrs[XFRMA_ALG_COMP] || in verify_newsa_info()
240 attrs[XFRMA_ALG_AUTH] || in verify_newsa_info()
241 attrs[XFRMA_ALG_AUTH_TRUNC] || in verify_newsa_info()
242 attrs[XFRMA_ALG_AEAD] || in verify_newsa_info()
243 attrs[XFRMA_ALG_CRYPT] || in verify_newsa_info()
244 attrs[XFRMA_ENCAP] || in verify_newsa_info()
245 attrs[XFRMA_SEC_CTX] || in verify_newsa_info()
246 attrs[XFRMA_TFCPAD] || in verify_newsa_info()
247 !attrs[XFRMA_COADDR]) in verify_newsa_info()
256 if ((err = verify_aead(attrs))) in verify_newsa_info()
258 if ((err = verify_auth_trunc(attrs))) in verify_newsa_info()
260 if ((err = verify_one_alg(attrs, XFRMA_ALG_AUTH))) in verify_newsa_info()
262 if ((err = verify_one_alg(attrs, XFRMA_ALG_CRYPT))) in verify_newsa_info()
264 if ((err = verify_one_alg(attrs, XFRMA_ALG_COMP))) in verify_newsa_info()
266 if ((err = verify_sec_ctx_len(attrs))) in verify_newsa_info()
268 if ((err = verify_replay(p, attrs))) in verify_newsa_info()
285 if (attrs[XFRMA_MTIMER_THRESH]) in verify_newsa_info()
286 if (!attrs[XFRMA_ENCAP]) in verify_newsa_info()
520 static void xfrm_update_ae_params(struct xfrm_state *x, struct nlattr **attrs, in xfrm_update_ae_params() argument
523 struct nlattr *rp = attrs[XFRMA_REPLAY_VAL]; in xfrm_update_ae_params()
524 struct nlattr *re = update_esn ? attrs[XFRMA_REPLAY_ESN_VAL] : NULL; in xfrm_update_ae_params()
525 struct nlattr *lt = attrs[XFRMA_LTIME_VAL]; in xfrm_update_ae_params()
526 struct nlattr *et = attrs[XFRMA_ETIMER_THRESH]; in xfrm_update_ae_params()
527 struct nlattr *rt = attrs[XFRMA_REPLAY_THRESH]; in xfrm_update_ae_params()
528 struct nlattr *mt = attrs[XFRMA_MTIMER_THRESH]; in xfrm_update_ae_params()
565 static void xfrm_smark_init(struct nlattr **attrs, struct xfrm_mark *m) in xfrm_smark_init() argument
567 if (attrs[XFRMA_SET_MARK]) { in xfrm_smark_init()
568 m->v = nla_get_u32(attrs[XFRMA_SET_MARK]); in xfrm_smark_init()
569 if (attrs[XFRMA_SET_MARK_MASK]) in xfrm_smark_init()
570 m->m = nla_get_u32(attrs[XFRMA_SET_MARK_MASK]); in xfrm_smark_init()
580 struct nlattr **attrs, in xfrm_state_construct() argument
591 if (attrs[XFRMA_ENCAP]) { in xfrm_state_construct()
592 x->encap = kmemdup(nla_data(attrs[XFRMA_ENCAP]), in xfrm_state_construct()
598 if (attrs[XFRMA_COADDR]) { in xfrm_state_construct()
599 x->coaddr = kmemdup(nla_data(attrs[XFRMA_COADDR]), in xfrm_state_construct()
605 if (attrs[XFRMA_SA_EXTRA_FLAGS]) in xfrm_state_construct()
606 x->props.extra_flags = nla_get_u32(attrs[XFRMA_SA_EXTRA_FLAGS]); in xfrm_state_construct()
608 if ((err = attach_aead(x, attrs[XFRMA_ALG_AEAD]))) in xfrm_state_construct()
611 attrs[XFRMA_ALG_AUTH_TRUNC]))) in xfrm_state_construct()
615 attrs[XFRMA_ALG_AUTH]))) in xfrm_state_construct()
618 if ((err = attach_crypt(x, attrs[XFRMA_ALG_CRYPT]))) in xfrm_state_construct()
622 attrs[XFRMA_ALG_COMP]))) in xfrm_state_construct()
625 if (attrs[XFRMA_TFCPAD]) in xfrm_state_construct()
626 x->tfcpad = nla_get_u32(attrs[XFRMA_TFCPAD]); in xfrm_state_construct()
628 xfrm_mark_get(attrs, &x->mark); in xfrm_state_construct()
630 xfrm_smark_init(attrs, &x->props.smark); in xfrm_state_construct()
632 if (attrs[XFRMA_IF_ID]) in xfrm_state_construct()
633 x->if_id = nla_get_u32(attrs[XFRMA_IF_ID]); in xfrm_state_construct()
635 err = __xfrm_init_state(x, false, attrs[XFRMA_OFFLOAD_DEV]); in xfrm_state_construct()
639 if (attrs[XFRMA_SEC_CTX]) { in xfrm_state_construct()
641 nla_data(attrs[XFRMA_SEC_CTX])); in xfrm_state_construct()
647 attrs[XFRMA_REPLAY_ESN_VAL]))) in xfrm_state_construct()
659 xfrm_update_ae_params(x, attrs, 0); in xfrm_state_construct()
662 if (attrs[XFRMA_OFFLOAD_DEV]) { in xfrm_state_construct()
664 nla_data(attrs[XFRMA_OFFLOAD_DEV])); in xfrm_state_construct()
680 struct nlattr **attrs) in xfrm_add_sa() argument
688 err = verify_newsa_info(p, attrs); in xfrm_add_sa()
692 x = xfrm_state_construct(net, p, attrs, &err); in xfrm_add_sa()
726 struct nlattr **attrs, in xfrm_user_state_lookup() argument
732 u32 mark = xfrm_mark_get(attrs, &m); in xfrm_user_state_lookup()
740 verify_one_addr(attrs, XFRMA_SRCADDR, &saddr); in xfrm_user_state_lookup()
759 struct nlattr **attrs) in xfrm_del_sa() argument
767 x = xfrm_user_state_lookup(net, p, attrs, &err); in xfrm_del_sa()
1147 struct nlattr *attrs[XFRMA_MAX+1]; in xfrm_dump_sa() local
1152 err = nlmsg_parse_deprecated(cb->nlh, 0, attrs, XFRMA_MAX, in xfrm_dump_sa()
1157 if (attrs[XFRMA_ADDRESS_FILTER]) { in xfrm_dump_sa()
1158 filter = kmemdup(nla_data(attrs[XFRMA_ADDRESS_FILTER]), in xfrm_dump_sa()
1173 if (attrs[XFRMA_PROTO]) in xfrm_dump_sa()
1174 proto = nla_get_u8(attrs[XFRMA_PROTO]); in xfrm_dump_sa()
1301 struct nlattr **attrs) in xfrm_set_spdinfo() argument
1308 if (attrs[XFRMA_SPD_IPV4_HTHRESH]) { in xfrm_set_spdinfo()
1309 struct nlattr *rta = attrs[XFRMA_SPD_IPV4_HTHRESH]; in xfrm_set_spdinfo()
1317 if (attrs[XFRMA_SPD_IPV6_HTHRESH]) { in xfrm_set_spdinfo()
1318 struct nlattr *rta = attrs[XFRMA_SPD_IPV6_HTHRESH]; in xfrm_set_spdinfo()
1346 struct nlattr **attrs) in xfrm_get_spdinfo() argument
1405 struct nlattr **attrs) in xfrm_get_sadinfo() argument
1425 struct nlattr **attrs) in xfrm_get_sa() argument
1433 x = xfrm_user_state_lookup(net, p, attrs, &err); in xfrm_get_sa()
1449 struct nlattr **attrs) in xfrm_alloc_userspi() argument
1473 mark = xfrm_mark_get(attrs, &m); in xfrm_alloc_userspi()
1475 if (attrs[XFRMA_IF_ID]) in xfrm_alloc_userspi()
1476 if_id = nla_get_u32(attrs[XFRMA_IF_ID]); in xfrm_alloc_userspi()
1609 static int copy_from_user_sec_ctx(struct xfrm_policy *pol, struct nlattr **attrs) in copy_from_user_sec_ctx() argument
1611 struct nlattr *rt = attrs[XFRMA_SEC_CTX]; in copy_from_user_sec_ctx()
1699 static int copy_from_user_tmpl(struct xfrm_policy *pol, struct nlattr **attrs) in copy_from_user_tmpl() argument
1701 struct nlattr *rt = attrs[XFRMA_TMPL]; in copy_from_user_tmpl()
1719 static int copy_from_user_policy_type(u8 *tp, struct nlattr **attrs) in copy_from_user_policy_type() argument
1721 struct nlattr *rt = attrs[XFRMA_POLICY_TYPE]; in copy_from_user_policy_type()
1766 …policy_construct(struct net *net, struct xfrm_userpolicy_info *p, struct nlattr **attrs, int *errp) in xfrm_policy_construct() argument
1778 err = copy_from_user_policy_type(&xp->type, attrs); in xfrm_policy_construct()
1782 if (!(err = copy_from_user_tmpl(xp, attrs))) in xfrm_policy_construct()
1783 err = copy_from_user_sec_ctx(xp, attrs); in xfrm_policy_construct()
1787 xfrm_mark_get(attrs, &xp->mark); in xfrm_policy_construct()
1789 if (attrs[XFRMA_IF_ID]) in xfrm_policy_construct()
1790 xp->if_id = nla_get_u32(attrs[XFRMA_IF_ID]); in xfrm_policy_construct()
1801 struct nlattr **attrs) in xfrm_add_policy() argument
1813 err = verify_sec_ctx_len(attrs); in xfrm_add_policy()
1817 xp = xfrm_policy_construct(net, p, attrs, &err); in xfrm_add_policy()
2062 struct nlattr **attrs) in xfrm_set_default() argument
2083 struct nlattr **attrs) in xfrm_get_default() argument
2113 struct nlattr **attrs) in xfrm_get_policy() argument
2128 err = copy_from_user_policy_type(&type, attrs); in xfrm_get_policy()
2136 if (attrs[XFRMA_IF_ID]) in xfrm_get_policy()
2137 if_id = nla_get_u32(attrs[XFRMA_IF_ID]); in xfrm_get_policy()
2139 xfrm_mark_get(attrs, &m); in xfrm_get_policy()
2145 struct nlattr *rt = attrs[XFRMA_SEC_CTX]; in xfrm_get_policy()
2148 err = verify_sec_ctx_len(attrs); in xfrm_get_policy()
2196 struct nlattr **attrs) in xfrm_flush_sa() argument
2296 struct nlattr **attrs) in xfrm_get_ae() argument
2308 mark = xfrm_mark_get(attrs, &m); in xfrm_get_ae()
2340 struct nlattr **attrs) in xfrm_new_ae() argument
2349 struct nlattr *rp = attrs[XFRMA_REPLAY_VAL]; in xfrm_new_ae()
2350 struct nlattr *re = attrs[XFRMA_REPLAY_ESN_VAL]; in xfrm_new_ae()
2351 struct nlattr *lt = attrs[XFRMA_LTIME_VAL]; in xfrm_new_ae()
2352 struct nlattr *et = attrs[XFRMA_ETIMER_THRESH]; in xfrm_new_ae()
2353 struct nlattr *rt = attrs[XFRMA_REPLAY_THRESH]; in xfrm_new_ae()
2362 mark = xfrm_mark_get(attrs, &m); in xfrm_new_ae()
2376 xfrm_update_ae_params(x, attrs, 1); in xfrm_new_ae()
2391 struct nlattr **attrs) in xfrm_flush_policy() argument
2398 err = copy_from_user_policy_type(&type, attrs); in xfrm_flush_policy()
2419 struct nlattr **attrs) in xfrm_add_pol_expire() argument
2430 err = copy_from_user_policy_type(&type, attrs); in xfrm_add_pol_expire()
2438 if (attrs[XFRMA_IF_ID]) in xfrm_add_pol_expire()
2439 if_id = nla_get_u32(attrs[XFRMA_IF_ID]); in xfrm_add_pol_expire()
2441 xfrm_mark_get(attrs, &m); in xfrm_add_pol_expire()
2447 struct nlattr *rt = attrs[XFRMA_SEC_CTX]; in xfrm_add_pol_expire()
2450 err = verify_sec_ctx_len(attrs); in xfrm_add_pol_expire()
2485 struct nlattr **attrs) in xfrm_add_sa_expire() argument
2493 u32 mark = xfrm_mark_get(attrs, &m); in xfrm_add_sa_expire()
2519 struct nlattr **attrs) in xfrm_add_acquire() argument
2525 struct nlattr *rt = attrs[XFRMA_TMPL]; in xfrm_add_acquire()
2535 xfrm_mark_get(attrs, &mark); in xfrm_add_acquire()
2540 err = verify_sec_ctx_len(attrs); in xfrm_add_acquire()
2545 xp = xfrm_policy_construct(net, &ua->policy, attrs, &err); in xfrm_add_acquire()
2583 struct nlattr **attrs, int *num) in copy_from_user_migrate() argument
2585 struct nlattr *rt = attrs[XFRMA_MIGRATE]; in copy_from_user_migrate()
2592 uk = nla_data(attrs[XFRMA_KMADDRESS]); in copy_from_user_migrate()
2624 struct nlattr **attrs) in xfrm_do_migrate() argument
2636 if (attrs[XFRMA_MIGRATE] == NULL) in xfrm_do_migrate()
2639 kmp = attrs[XFRMA_KMADDRESS] ? &km : NULL; in xfrm_do_migrate()
2641 err = copy_from_user_policy_type(&type, attrs); in xfrm_do_migrate()
2645 err = copy_from_user_migrate((struct xfrm_migrate *)m, kmp, attrs, &n); in xfrm_do_migrate()
2652 if (attrs[XFRMA_ENCAP]) { in xfrm_do_migrate()
2653 encap = kmemdup(nla_data(attrs[XFRMA_ENCAP]), in xfrm_do_migrate()
2659 if (attrs[XFRMA_IF_ID]) in xfrm_do_migrate()
2660 if_id = nla_get_u32(attrs[XFRMA_IF_ID]); in xfrm_do_migrate()
2670 struct nlattr **attrs) in xfrm_do_migrate() argument
2909 struct nlattr *attrs[XFRMA_MAX+1]; in xfrm_user_rcv_msg() local
2961 err = nlmsg_parse_deprecated(nlh, xfrm_msg_min[type], attrs, in xfrm_user_rcv_msg()
2972 err = link->doit(skb, nlh, attrs); in xfrm_user_rcv_msg()