Commit 0c805e80 authored by Lin Ma's avatar Lin Ma Committed by Florian Westphal

netfilter: conntrack: validate cta_ip via parsing

In current ctnetlink_parse_tuple_ip() function, nested parsing and
validation is splitting as two parts,  which could be cleanup to a
simplified form. As the nla_parse_nested_deprecated function
supports validation in the fly. These two finially reach same place
__nla_validate_parse with same validate flag.

nla_parse_nested_deprecated
  __nla_parse(.., NL_VALIDATE_LIBERAL, ..)
    __nla_validate_parse

nla_validate_nested_deprecated
  __nla_validate_nested(.., NL_VALIDATE_LIBERAL, ..)
    __nla_validate
      __nla_validate_parse

This commit removes the call to nla_validate_nested_deprecated and pass
cta_ip_nla_policy when do parsing.
Signed-off-by: default avatarLin Ma <linma@zju.edu.cn>
Reviewed-by: default avatarSimon Horman <simon.horman@corigine.com>
Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
parent 100a11b6
......@@ -1321,15 +1321,11 @@ static int ctnetlink_parse_tuple_ip(struct nlattr *attr,
struct nlattr *tb[CTA_IP_MAX+1];
int ret = 0;
ret = nla_parse_nested_deprecated(tb, CTA_IP_MAX, attr, NULL, NULL);
ret = nla_parse_nested_deprecated(tb, CTA_IP_MAX, attr,
cta_ip_nla_policy, NULL);
if (ret < 0)
return ret;
ret = nla_validate_nested_deprecated(attr, CTA_IP_MAX,
cta_ip_nla_policy, NULL);
if (ret)
return ret;
switch (tuple->src.l3num) {
case NFPROTO_IPV4:
ret = ipv4_nlattr_to_tuple(tb, tuple, flags);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment