Lines Matching refs:pt
114 void nla_get_range_unsigned(const struct nla_policy *pt, in nla_get_range_unsigned() argument
117 WARN_ON_ONCE(pt->validation_type != NLA_VALIDATE_RANGE_PTR && in nla_get_range_unsigned()
118 (pt->min < 0 || pt->max < 0)); in nla_get_range_unsigned()
122 switch (pt->type) { in nla_get_range_unsigned()
142 switch (pt->validation_type) { in nla_get_range_unsigned()
145 range->min = pt->min; in nla_get_range_unsigned()
146 range->max = pt->max; in nla_get_range_unsigned()
149 *range = *pt->range; in nla_get_range_unsigned()
152 range->min = pt->min; in nla_get_range_unsigned()
155 range->max = pt->max; in nla_get_range_unsigned()
162 static int nla_validate_range_unsigned(const struct nla_policy *pt, in nla_validate_range_unsigned() argument
170 switch (pt->type) { in nla_validate_range_unsigned()
191 nla_get_range_unsigned(pt, &range); in nla_validate_range_unsigned()
193 if (pt->validation_type == NLA_VALIDATE_RANGE_WARN_TOO_LONG && in nla_validate_range_unsigned()
194 pt->type == NLA_BINARY && value > range.max) { in nla_validate_range_unsigned()
196 current->comm, pt->type); in nla_validate_range_unsigned()
198 NL_SET_ERR_MSG_ATTR_POL(extack, nla, pt, in nla_validate_range_unsigned()
208 bool binary = pt->type == NLA_BINARY; in nla_validate_range_unsigned()
211 NL_SET_ERR_MSG_ATTR_POL(extack, nla, pt, in nla_validate_range_unsigned()
214 NL_SET_ERR_MSG_ATTR_POL(extack, nla, pt, in nla_validate_range_unsigned()
223 void nla_get_range_signed(const struct nla_policy *pt, in nla_get_range_signed() argument
226 switch (pt->type) { in nla_get_range_signed()
248 switch (pt->validation_type) { in nla_get_range_signed()
250 range->min = pt->min; in nla_get_range_signed()
251 range->max = pt->max; in nla_get_range_signed()
254 *range = *pt->range_signed; in nla_get_range_signed()
257 range->min = pt->min; in nla_get_range_signed()
260 range->max = pt->max; in nla_get_range_signed()
267 static int nla_validate_int_range_signed(const struct nla_policy *pt, in nla_validate_int_range_signed() argument
274 switch (pt->type) { in nla_validate_int_range_signed()
291 nla_get_range_signed(pt, &range); in nla_validate_int_range_signed()
294 NL_SET_ERR_MSG_ATTR_POL(extack, nla, pt, in nla_validate_int_range_signed()
302 static int nla_validate_int_range(const struct nla_policy *pt, in nla_validate_int_range() argument
307 switch (pt->type) { in nla_validate_int_range()
314 return nla_validate_range_unsigned(pt, nla, extack, validate); in nla_validate_int_range()
319 return nla_validate_int_range_signed(pt, nla, extack); in nla_validate_int_range()
326 static int nla_validate_mask(const struct nla_policy *pt, in nla_validate_mask() argument
332 switch (pt->type) { in nla_validate_mask()
349 if (value & ~(u64)pt->mask) { in nla_validate_mask()
362 const struct nla_policy *pt; in validate_nla() local
372 pt = &policy[type]; in validate_nla()
374 BUG_ON(pt->type > NLA_TYPE_MAX); in validate_nla()
376 if (nla_attr_len[pt->type] && attrlen != nla_attr_len[pt->type]) { in validate_nla()
380 NL_SET_ERR_MSG_ATTR_POL(extack, nla, pt, in validate_nla()
387 if ((pt->type == NLA_NESTED || pt->type == NLA_NESTED_ARRAY) && in validate_nla()
389 NL_SET_ERR_MSG_ATTR_POL(extack, nla, pt, in validate_nla()
393 if (pt->type != NLA_NESTED && pt->type != NLA_NESTED_ARRAY && in validate_nla()
394 pt->type != NLA_UNSPEC && (nla->nla_type & NLA_F_NESTED)) { in validate_nla()
395 NL_SET_ERR_MSG_ATTR_POL(extack, nla, pt, in validate_nla()
401 switch (pt->type) { in validate_nla()
403 if (extack && pt->reject_message) { in validate_nla()
405 extack->_msg = pt->reject_message; in validate_nla()
420 err = validate_nla_bitfield32(nla, pt->bitfield32_valid); in validate_nla()
426 if (pt->len) in validate_nla()
427 minlen = min_t(int, attrlen, pt->len + 1); in validate_nla()
441 if (pt->len) { in validate_nla()
447 if (attrlen > pt->len) in validate_nla()
453 if (pt->len && attrlen > pt->len) in validate_nla()
465 if (pt->nested_policy) { in validate_nla()
467 pt->len, pt->nested_policy, in validate_nla()
487 if (pt->nested_policy) { in validate_nla()
491 pt->len, pt->nested_policy, in validate_nla()
509 if (attrlen < pt->len) in validate_nla()
514 if (pt->len) in validate_nla()
515 minlen = pt->len; in validate_nla()
517 minlen = nla_attr_minlen[pt->type]; in validate_nla()
524 switch (pt->validation_type) { in validate_nla()
533 err = nla_validate_int_range(pt, nla, extack, validate); in validate_nla()
538 err = nla_validate_mask(pt, nla, extack); in validate_nla()
543 if (pt->validate) { in validate_nla()
544 err = pt->validate(nla, extack); in validate_nla()
553 NL_SET_ERR_MSG_ATTR_POL(extack, nla, pt, in validate_nla()