From: Johannes Berg <[email protected]>
Date: Fri, 26 Apr 2019 14:13:02 +0200
> * NLA_POLICY_RANGE() macros.
> + * NLA_U8,
> + * NLA_U16,
> + * NLA_U32,
> + * NLA_U64 If the validation_type field instead is set to
> + * NLA_VALIDATE_RANGE_PTR, `range' must be a pointer
> + * to a struct netlink_range_validation that
> indicates
> + * the min/max values.
> + * Use NLA_POLICY_FULL_RANGE().
> + * NLA_S8,
> + * NLA_S16,
> + * NLA_S32,
> + * NLA_S64 If the validation_type field instead is set to
> + * NLA_VALIDATE_RANGE_PTR, `range_signed' must be a
> + * pointer to a struct
> netlink_range_validation_signed
> + * that indicates the min/max values.
> + * Use NLA_POLICY_FULL_RANGE_SIGNED().
Documentation and datastructure says that "range_signed" member should be set
for signed ranges, however:
> +#define NLA_POLICY_FULL_RANGE(tp, _range) { \
> + .type = NLA_ENSURE_UINT_TYPE(tp), \
> + .validation_type = NLA_VALIDATE_RANGE_PTR, \
> + .range = _range, \
> +}
> +
> +#define NLA_POLICY_FULL_RANGE_SIGNED(tp, _range) { \
> + .type = NLA_ENSURE_SINT_TYPE(tp), \
> + .validation_type = NLA_VALIDATE_RANGE_PTR, \
> + .range = _range, \
> +}
The NLA_POLICY_FULL_RANGE_SIGNED macros sets 'range' not 'range_signed'.
Also, since range and range_signed are in a union however there is only one
NLA_VALIDATE_RANGE_PTR type, how does one differentiate between signed and
unsigned ranges exactly?
Thanks.