[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190429.224951.1389806535373048089.davem@davemloft.net>
Date: Mon, 29 Apr 2019 22:49:51 -0400 (EDT)
From: David Miller <davem@...emloft.net>
To: johannes@...solutions.net
Cc: netdev@...r.kernel.org, dsa@...ulusnetworks.com,
pablo@...filter.org, johannes.berg@...el.com
Subject: Re: [PATCH 2/6] netlink: extend policy range validation
From: Johannes Berg <johannes@...solutions.net>
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.
Powered by blists - more mailing lists