Lines Matching refs:pt
119 void nla_get_range_unsigned(const struct nla_policy *pt, in nla_get_range_unsigned() argument
122 WARN_ON_ONCE(pt->validation_type != NLA_VALIDATE_RANGE_PTR && in nla_get_range_unsigned()
123 (pt->min < 0 || pt->max < 0)); in nla_get_range_unsigned()
127 switch (pt->type) { in nla_get_range_unsigned()
150 switch (pt->validation_type) { in nla_get_range_unsigned()
153 range->min = pt->min; in nla_get_range_unsigned()
154 range->max = pt->max; in nla_get_range_unsigned()
157 *range = *pt->range; in nla_get_range_unsigned()
160 range->min = pt->min; in nla_get_range_unsigned()
163 range->max = pt->max; in nla_get_range_unsigned()
170 static int nla_validate_range_unsigned(const struct nla_policy *pt, in nla_validate_range_unsigned() argument
178 switch (pt->type) { in nla_validate_range_unsigned()
210 nla_get_range_unsigned(pt, &range); in nla_validate_range_unsigned()
212 if (pt->validation_type == NLA_VALIDATE_RANGE_WARN_TOO_LONG && in nla_validate_range_unsigned()
213 pt->type == NLA_BINARY && value > range.max) { in nla_validate_range_unsigned()
215 current->comm, pt->type); in nla_validate_range_unsigned()
217 NL_SET_ERR_MSG_ATTR_POL(extack, nla, pt, in nla_validate_range_unsigned()
227 bool binary = pt->type == NLA_BINARY; in nla_validate_range_unsigned()
230 NL_SET_ERR_MSG_ATTR_POL(extack, nla, pt, in nla_validate_range_unsigned()
233 NL_SET_ERR_MSG_ATTR_POL(extack, nla, pt, in nla_validate_range_unsigned()
242 void nla_get_range_signed(const struct nla_policy *pt, in nla_get_range_signed() argument
245 switch (pt->type) { in nla_get_range_signed()
268 switch (pt->validation_type) { in nla_get_range_signed()
270 range->min = pt->min; in nla_get_range_signed()
271 range->max = pt->max; in nla_get_range_signed()
274 *range = *pt->range_signed; in nla_get_range_signed()
277 range->min = pt->min; in nla_get_range_signed()
280 range->max = pt->max; in nla_get_range_signed()
287 static int nla_validate_int_range_signed(const struct nla_policy *pt, in nla_validate_int_range_signed() argument
294 switch (pt->type) { in nla_validate_int_range_signed()
314 nla_get_range_signed(pt, &range); in nla_validate_int_range_signed()
317 NL_SET_ERR_MSG_ATTR_POL(extack, nla, pt, in nla_validate_int_range_signed()
325 static int nla_validate_int_range(const struct nla_policy *pt, in nla_validate_int_range() argument
330 switch (pt->type) { in nla_validate_int_range()
340 return nla_validate_range_unsigned(pt, nla, extack, validate); in nla_validate_int_range()
346 return nla_validate_int_range_signed(pt, nla, extack); in nla_validate_int_range()
353 static int nla_validate_mask(const struct nla_policy *pt, in nla_validate_mask() argument
359 switch (pt->type) { in nla_validate_mask()
385 if (value & ~(u64)pt->mask) { in nla_validate_mask()
398 const struct nla_policy *pt; in validate_nla() local
409 pt = &policy[type]; in validate_nla()
411 BUG_ON(pt->type > NLA_TYPE_MAX); in validate_nla()
413 if (nla_attr_len[pt->type] && attrlen != nla_attr_len[pt->type]) { in validate_nla()
417 NL_SET_ERR_MSG_ATTR_POL(extack, nla, pt, in validate_nla()
424 if ((pt->type == NLA_NESTED || pt->type == NLA_NESTED_ARRAY) && in validate_nla()
426 NL_SET_ERR_MSG_ATTR_POL(extack, nla, pt, in validate_nla()
430 if (pt->type != NLA_NESTED && pt->type != NLA_NESTED_ARRAY && in validate_nla()
431 pt->type != NLA_UNSPEC && (nla->nla_type & NLA_F_NESTED)) { in validate_nla()
432 NL_SET_ERR_MSG_ATTR_POL(extack, nla, pt, in validate_nla()
438 switch (pt->type) { in validate_nla()
440 if (extack && pt->reject_message) { in validate_nla()
442 extack->_msg = pt->reject_message; in validate_nla()
456 NL_SET_ERR_MSG_ATTR_POL(extack, nla, pt, in validate_nla()
466 err = validate_nla_bitfield32(nla, pt->bitfield32_valid); in validate_nla()
472 if (pt->len) in validate_nla()
473 minlen = min_t(int, attrlen, pt->len + 1); in validate_nla()
487 if (pt->len) { in validate_nla()
493 if (attrlen > pt->len) in validate_nla()
499 if (pt->len && attrlen > pt->len) in validate_nla()
511 if (pt->nested_policy) { in validate_nla()
513 pt->len, pt->nested_policy, in validate_nla()
533 if (pt->nested_policy) { in validate_nla()
537 pt->len, pt->nested_policy, in validate_nla()
555 if (attrlen < pt->len) in validate_nla()
560 if (pt->len) in validate_nla()
561 minlen = pt->len; in validate_nla()
563 minlen = nla_attr_minlen[pt->type]; in validate_nla()
570 switch (pt->validation_type) { in validate_nla()
579 err = nla_validate_int_range(pt, nla, extack, validate); in validate_nla()
584 err = nla_validate_mask(pt, nla, extack); in validate_nla()
589 if (pt->validate) { in validate_nla()
590 err = pt->validate(nla, extack); in validate_nla()
599 NL_SET_ERR_MSG_ATTR_POL(extack, nla, pt, in validate_nla()