Commit 63c82997 authored by Jakub Kicinski's avatar Jakub Kicinski Committed by David S. Miller
Browse files

net: sched: cls_flower: validate nested enc_opts_policy to avoid warning

currently contain further nested attributes, which are parsed by
hand, so the policy is never actually used resulting in a W=1
build warning:

net/sched/cls_flower.c:492:1: warning: ‘enc_opts_policy’ defined but not used [-Wunused-const-variable=]
 enc_opts_policy[TCA_FLOWER_KEY_ENC_OPTS_MAX + 1] = {

Add the validation anyway to avoid potential bugs when other
attributes are added and to make the attribute structure slightly
more clear.  Validation will also set extact to point to bad
attribute on error.

Fixes: 0a6e7778

 ("net/sched: allow flower to match tunnel options")
Signed-off-by: default avatarJakub Kicinski <>
Acked-by: default avatarSimon Horman <>
Acked-by: default avatarJiri Pirko <>
Signed-off-by: default avatarDavid S. Miller <>
parent fbd1d524
......@@ -709,11 +709,23 @@ static int fl_set_enc_opt(struct nlattr **tb, struct fl_flow_key *key,
struct netlink_ext_ack *extack)
const struct nlattr *nla_enc_key, *nla_opt_key, *nla_opt_msk = NULL;
int option_len, key_depth, msk_depth = 0;
int err, option_len, key_depth, msk_depth = 0;
err = nla_validate_nested(tb[TCA_FLOWER_KEY_ENC_OPTS],
enc_opts_policy, extack);
if (err)
return err;
nla_enc_key = nla_data(tb[TCA_FLOWER_KEY_ENC_OPTS]);
err = nla_validate_nested(tb[TCA_FLOWER_KEY_ENC_OPTS_MASK],
enc_opts_policy, extack);
if (err)
return err;
nla_opt_msk = nla_data(tb[TCA_FLOWER_KEY_ENC_OPTS_MASK]);
msk_depth = nla_len(tb[TCA_FLOWER_KEY_ENC_OPTS_MASK]);
Supports Markdown
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